本文整理汇总了Python中pyvcloud.vcloudair.VCA.get_networks方法的典型用法代码示例。如果您正苦于以下问题:Python VCA.get_networks方法的具体用法?Python VCA.get_networks怎么用?Python VCA.get_networks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.get_networks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_networks [as 别名]
#.........这里部分代码省略.........
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
vm_info = the_vapp.get_vms_network_info()
print vm_info
assert vm_info
assert len(vm_info) == 1
assert len(vm_info[0]) == 0
def test_0010(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_0012(self):
"""Connect vApp to network"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
network = config['vcloud']['network']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
nets = filter(lambda n: n.name == network, self.vca.get_networks(vdc_name))
assert len(nets) == 1
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.connect_to_network(nets[0].name, nets[0].href)
result = self.vca.block_until_completed(task)
assert result
def test_0013(self):
"""Connect VM to network - MANUAL static IP mode"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
network = config['vcloud']['network']
ip_address = config['vcloud']['ip_address']
the_vdc = self.vca.get_vdc(vdc_name)
assert the_vdc
assert the_vdc.get_name() == vdc_name
nets = filter(lambda n: n.name == network, self.vca.get_networks(vdc_name))
assert len(nets) == 1
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.connect_vms(nets[0].name, connection_index=0, ip_allocation_mode='MANUAL', ip_address=ip_address)
assert task
result = self.vca.block_until_completed(task)
assert result
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
vm_info = the_vapp.get_vms_network_info()
print vm_info
示例2: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_networks [as 别名]
#.........这里部分代码省略.........
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)
assert the_vdc
assert the_vdc.get_name() == vdc_name
nets = filter(lambda n: n.name == network, self.vca.get_networks(vdc_name))
assert len(nets) == 1
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.connect_to_network(nets[0].name, nets[0].href)
result = self.vca.block_until_completed(task)
assert result
def test_0006(self):
"""Connect VM 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)
assert the_vdc
assert the_vdc.get_name() == vdc_name
nets = filter(lambda n: n.name == network, self.vca.get_networks(vdc_name))
assert len(nets) == 1
the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
assert the_vapp
assert the_vapp.name == vapp_name
task = the_vapp.connect_vms(nets[0].name, connection_index=0, ip_allocation_mode=mode.upper())
result = self.vca.block_until_completed(task)
assert result
def test_0007(self):
"""Change vApp/VM Memory"""
vdc_name = config['vcloud']['vdc']
vapp_name = config['vcloud']['vapp']
vm_name = config['vcloud']['vm']
示例3: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_networks [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(
#.........这里部分代码省略.........