本文整理汇总了Python中pyvcloud.vcloudair.VCA.block_until_completed方法的典型用法代码示例。如果您正苦于以下问题:Python VCA.block_until_completed方法的具体用法?Python VCA.block_until_completed怎么用?Python VCA.block_until_completed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.block_until_completed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
class TestVCloud:
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']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
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:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
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 VDC"""
vdc_name = config['vcloud']['vdc']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
def test_0003(self):
"""Create vApp"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
catalog = config['vcloud']['catalog']
template = config['vcloud']['template']
network = config['vcloud']['network']
mode = config['vcloud']['mode']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog, vm_name=vm_name)
assert task
result = self.vca.block_until_completed(task)
assert result
the_vdc = self.vca.get_vdc(vdc_name)
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
def test_0004(self):
"""Disconnect vApp from pre-defined networks"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.disconnect_from_networks()
assert task
result = self.vca.block_until_completed(task)
assert result
def test_0005(self):
"""Connect vApp to network"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
network = config['vcloud']['network']
mode = config['vcloud']['mode']
the_vdc = self.vca.get_vdc(vdc_name)
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
class TestCatalog:
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']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
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:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
assert result
def logout_from_vcloud(self):
"""Logout from vCloud"""
print 'logout'
selfl.vca.logout()
self.vca = None
assert self.vca is None
def catalog_exists(self, catalog_name, catalogs):
for catalog in catalogs:
if catalog.name == catalog_name:
return True
return False
def test_0001(self):
"""Loggin in to vCloud"""
assert self.vca.token
def test_0002(self):
"""Get VDC"""
vdc_name = config['vcloud']['vdc']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
def test_0009(self):
"""Validate that catalog doesn't exist"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
custom_catalog = config['vcloud']['custom_catalog']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
catalogs = self.vca.get_catalogs()
assert not self.catalog_exists(custom_catalog, catalogs)
def test_0010(self):
"""Create Catalog"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
custom_catalog = config['vcloud']['custom_catalog']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
task = self.vca.create_catalog(custom_catalog, custom_catalog)
assert task
result = self.vca.block_until_completed(task)
assert result
catalogs = self.vca.get_catalogs()
assert self.catalog_exists(custom_catalog, catalogs)
def test_0011(self):
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
class TestVApp:
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']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
assert self.vca
if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif VCA.VCA_SERVICE_TYPE_VCHS == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif VCA.VCA_SERVICE_TYPE_VCA == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
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 VDC"""
vdc_name = config['vcloud']['vdc']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
def test_0003(self):
"""Create vApp"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
catalog = config['vcloud']['catalog']
template = config['vcloud']['template']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog, vm_name=vm_name)
assert task
result = self.vca.block_until_completed(task)
assert result
the_vdc = self.vca.get_vdc(vdc_name)
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
def test_0004(self):
"""Validate vApp State is powered off (8)"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.me.get_status() == 8
def test_0009(self):
"""Disconnect VM from pre-defined networks"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
the_vdc = self.vca.get_vdc(vdc_name)
#.........这里部分代码省略.........
示例4:
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
# vca_2.block_until_completed(task)
#
#
# task_3 = vapp.connect_to_network(network_name="ServiceNet-Inside-VLAN3082",network_href=ser_href)
# print "Connecting VAPP to Network 2"
# vca_2.block_until_completed(task_3)
# print "Connecting VM to Network 2"
# task_4 = vapp.connect_vms(network_name="ServiceNet-Inside-VLAN3082", connections_primary_index=0,connection_index=0, ip_allocation_mode='POOL')
# vca_2.block_until_completed(task_4)
# vdc = vca_2.get_vdc(vdc_name)
# vapp = vca_2.get_vapp(vdc, 'sample')
#
task_1 = vapp.disconnect_vms('ServiceNet-Inside-VLAN3082')
vca_2.block_until_completed(task_1)
task = vapp.disconnect_from_network('ServiceNet-Inside-VLAN3082')
vca_2.block_until_completed(task)
task_3 = vapp.connect_to_network(network_name="ExNet-Inside-VLAN1470",network_href=net_href_2)
print "Connecting VAPP to Network 2"
vca_2.block_until_completed(task_3)
task_4 = vapp.connect_vms(network_name="ExNet-Inside-VLAN1470", connections_primary_index=0,connection_index=0, ip_allocation_mode='POOL')
vca_2.block_until_completed(task_4)
#
# task_3 = vapp.connect_to_network(network_name="ExNet-Inside-VLAN1470",network_href=net_href_2)
# print "Connecting VAPP to Network 2"
# vca_2.block_until_completed(task_3)
示例5: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
class TestVApp:
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']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
assert self.vca
if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif VCA.VCA_SERVICE_TYPE_VCHS == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif VCA.VCA_SERVICE_TYPE_VCA == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
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 VDC"""
vdc_name = config['vcloud']['vdc']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
def test_0003(self):
"""Create vApp"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
catalog = config['vcloud']['catalog']
template = config['vcloud']['template']
cpu = config['vcloud']['cpus_new']
memory = config['vcloud']['memory_new']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog,
vm_name=vm_name,
vm_cpus=cpu,
vm_memory=memory)
assert task
result = self.vca.block_until_completed(task)
assert result
the_vdc = self.vca.get_vdc(vdc_name)
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
def test_0004(self):
"""Validate vApp State is powered off (8)"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.me.get_status() == 8
def test_0031(self):
#.........这里部分代码省略.........
示例6: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
class TestNet:
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']
org = config['vcloud']['org']
service = config['vcloud']['service']
instance = config['vcloud']['instance']
self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
assert self.vca
if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
result = self.vca.login(password=password, org=org)
assert result
result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
assert result
elif VCA.VCA_SERVICE_TYPE_VCHS == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login(token=self.vca.token)
assert result
result = self.vca.login_to_org(service, org)
assert result
elif VCA.VCA_SERVICE_TYPE_VCA == service_type:
result = self.vca.login(password=password)
assert result
result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
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_0003(self):
"""Get Networks"""
print('')
vdc_name = config['vcloud']['vdc']
networks = self.vca.get_networks(vdc_name)
for network in networks:
print(network)
def test_0004(self):
""" Connect to Networks"""
print('')
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
network_name = config['vcloud']['network']
network_name2 = config['vcloud']['network2']
network_name3 = config['vcloud']['network3']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
print('disconnect vms')
task = the_vapp.disconnect_vms()
assert task
result = self.vca.block_until_completed(task)
assert result
print('disconnect vapp')
task = the_vapp.disconnect_from_networks()
assert task
result = self.vca.block_until_completed(task)
assert result
index = 0
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
nets = filter(lambda n: n.name == network_name,
self.vca.get_networks(vdc_name))
mode = 'POOL'
if len(nets) == 1:
print("connecting vApp to network"
" '%s' with mode '%s'" %
(network_name, mode))
task = the_vapp.connect_to_network(
#.........这里部分代码省略.........
示例7: diff
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import block_until_completed [as 别名]
instance=instance, password=None, token=vca.vcloud_session.token, org_url=vca.vcloud_session.org_url
)
# this tests the vca token
result = vca.login(token=vca.token)
network = vca.get_network(vdc_name, network_name)
# vapp = vca.get_vapp(vca.get_vdc(vdc_name), vapp_name)
# internal_ip = vapp.get_vms_network_info()[0][0]['ip']
internal_ip = "192.168.109.3"
gateway = vca.get_gateways(vdc_name)[0]
used_ips = gateway.get_public_ips()
task = gateway.allocate_public_ip()
task_result = vca.block_until_completed(task)
gateway = vca.get_gateways(vdc_name)[0]
public_ip = diff(gateway.get_public_ips(), used_ips)[0]
gateway.add_nat_rule("DNAT", public_ip, 22, internal_ip, 22, "Tcp")
gateway.add_nat_rule("DNAT", public_ip, 80, internal_ip, 80, "Tcp")
gateway.add_nat_rule("DNAT", public_ip, 443, internal_ip, 443, "Tcp")
gateway.add_nat_rule("SNAT", internal_ip, -1, public_ip, -1, "Tcp")
task = gateway.save_services_configuration()
task_result = vca.block_until_completed(task)
gateway = vca.get_gateways(vdc_name)[0]
gateway.add_fw_rule(True, "anythinggoes", "allow", "Any", "Any", "any", "Any", "any", True)
task = gateway.save_services_configuration()
task_result = vca.block_until_completed(task)
print(internal_ip + "," + public_ip) # use this ip to connect to ops manager