本文整理汇总了Python中pyvcloud.vcloudair.VCA.get_instances方法的典型用法代码示例。如果您正苦于以下问题:Python VCA.get_instances方法的具体用法?Python VCA.get_instances怎么用?Python VCA.get_instances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.get_instances方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VCAInventory
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_instances [as 别名]
#.........这里部分代码省略.........
self.meta['hostvars'][vm.name] = hostvars
table1.append(dict(vapp_name=vdc_name + '_' + entity.name, vms=vms, status=the_vapp.me.get_status(),\
Deployed= 'yes' if the_vapp.me.deployed else 'no', desciption = the_vapp.me.Description))
return table1
def get_inventory_vcd(self):
if not self.vca.login(password=self.password, org=self.org):
sys.stdout.write("Login Failed: Please check username or password or your api version")
if not self.vca.login(token=self.vca.token, org=self.org, org_url=self.vca.vcloud_session.org_url):
sys.stdout.write("Failed to login to org")
vdcs = self.get_vdcs(self.vca)
org_children = []
for j in vdcs:
actual_vdc = j.name
j.name = self.to_safe(j.name)
self.results[j.name] = dict(children=[])
org_children.append(j.name)
vapps = self.get_vapps(self.vca, j.name)
for k in vapps:
k['vapp_name'] = self.to_safe(k['vapp_name'])
self.results[j.name]['children'].append(k['vapp_name'])
self.results[k['vapp_name']] = k['vms']
self.results[self.org] = dict(children=org_children)
self.results['_meta'] = self.meta
cache_name = '__inventory_all__' + self.service_type
self._put_cache(cache_name, self.results)
return self.results
def get_inventory_vca(self):
if not self.vca.login(password=self.password):
sys.stdout.write("Login Failed: Please check username or password")
sys.exit(1)
instances_dict = self.vca.get_instances()
for i in instances_dict:
instance = i['id']
# region = i['id']
region = i['region']
region = self.to_safe(region.split('.')[0])
region_children = []
if len(instance) != 36:
continue
if not self.vca.login_to_instance(password=self.password, instance=instance, token=None, org_url=None):
sys.stdout.write( "Login to Instance failed: Seems like instance provided is wrong .. Please check")
sys.exit(1)
if not self.vca.login_to_instance(instance=instance, password=None, token=self.vca.vcloud_session.token,
org_url=self.vca.vcloud_session.org_url):
sys.stdout.write("Error logging into org for the instance %s" %instance)
vdcs = self.get_vdcs(self.vca)
for j in vdcs:
j.name = self.to_safe(j.name)
self.results[region + '_' + j.name] = dict(children=[])
region_children.append(region + '_' + j.name)
vapps = self.get_vapps(self.vca, j.name)
for k in vapps:
k['vapp_name'] = self.to_safe(k['vapp_name'])
self.results[region + '_' + j.name]['children'].append(region + '_' + j.name + '_' + k['vapp_name'])
self.results[region + '_' + j.name + '_' + k['vapp_name']] = k['vms']
self.results[region] = dict(children=region_children)
self.results['_meta'] = self.meta
cache_name = '__inventory_all__' + self.service_type
self._put_cache(cache_name, self.results)
return self.results
def get_inventory_vchs(self):
示例2: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_instances [as 别名]
class TestVCA:
def __init__(self):
self.vca = None
self.login_to_vcloud()
def login_to_vcloud(self):
"""Login to vCloud"""
username = config['vcloud']['username']
password = config['vcloud']['password']
service_type = config['vcloud']['service_type']
host = config['vcloud']['host']
version = config['vcloud']['version']
self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
assert self.vca
if vcloudair.VCA_SERVICE_TYPE_STANDALONE == service_type:
raise Exception('not-supported')
elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
raise Exception('not-supported')
elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
result = self.vca.login(password=password)
assert result
def logout_from_vcloud(self):
"""Logout from vCloud"""
print 'logout'
selfl.vca.logout()
self.vca = None
assert self.vca is None
def test_0001(self):
"""Loggin in to vCloud"""
assert self.vca.token
def test_0002(self):
"""Get Service Groups"""
service_groups = self.vca.get_service_groups()
assert service_groups
assert len(service_groups)>=0
def test_0003(self):
"""Get Plans"""
plans = self.vca.get_plans()
assert plans
assert len(plans)>=0
def test_0004(self):
"""Get Instances"""
instances = self.vca.get_instances()
assert instances
assert len(instances)>=0
def test_0005(self):
"""Get Users"""
users = self.vca.get_users()
assert users
assert len(users)>=0