本文整理匯總了Python中pyvcloud.vcloudair.VCA.get_network方法的典型用法代碼示例。如果您正苦於以下問題:Python VCA.get_network方法的具體用法?Python VCA.get_network怎麽用?Python VCA.get_network使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.get_network方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: VCA
# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_network [as 別名]
username = os.environ['VCAUSER']
password = os.environ['PASSWORD']
instance = 'c40ba6b4-c158-49fb-b164-5c66f90344fa'
org = 'a6545fcb-d68a-489f-afff-2ea055104cc1'
vdc = 'VDC1'
vapp = 'ubu'
network = 'default-routed-network'
vca = VCA(host=host, username=username, service_type='ondemand', version='5.7', verify=True)
assert vca
result = vca.login(password=password)
assert result
result = vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
assert result
result = vca.login_to_instance(instance=instance, password=None, token=vca.vcloud_session.token, org_url=vca.vcloud_session.org_url)
assert result
print_vca(vca)
the_vdc = vca.get_vdc(vdc)
assert the_vdc
print the_vdc.get_name()
the_vapp = vca.get_vapp(the_vdc, vapp)
assert the_vapp
print the_vapp.me.name
the_network = vca.get_network(vdc, network)
assert the_network
# this assumes that the vApp is already connected to the network so it should return immediately with success
task = the_vapp.connect_to_network(network, the_network.get_href(), 'bridged')
print task.get_status()
assert 'success' == task.get_status()
示例2: VCA
# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_network [as 別名]
catalog = 'Rackspace Catalog'
vapp = ''
api = "https://vcd02-2848639.mv.rackspace.com/api/sessions"
#sample login sequence on vCloud Air On Demand
vca = VCA(host=host, username=username, service_type='vcd', version='5.5', verify=False)
#first login, with password
result = vca.login(password=password, org=org)
# print_vca(vca)
vca_2 = VCA(host=host, username=username, service_type='vcd', version='5.5', verify=False)
vca_2.login(password=password, token=vca.vcloud_session.token, org=vca.vcloud_session.org, org_url=vca.vcloud_session.org_url)
net_href = vca_2.get_network(vdc_name, network_name="ExNet-TenDot-vlan1653").get_href()
net_href_2 = vca_2.get_network(vdc_name, network_name="ExNet-Inside-VLAN1470").get_href()
ser_href = vca_2.get_network(vdc_name, network_name="ServiceNet-Inside-VLAN3082").get_href()
# vdc = vca_2.get_vdc(vdc_name)
# vapp = vca_2.get_vapp(vdc, 'sample-2')
# vapp.disconnect_vms("ExNet-Inside-VLAN1470")
# vapp.disconnect_from_network("ExNet-Inside-VLAN1470")
# vApp_task = vca_2.create_vapp(vdc_name=vdc_name, vapp_name="sample", template_name=template_name, catalog_name=catalog)
# #
# print "Creating VApp"
# vca_2.block_until_completed(vApp_task)
#
# #time.sleep(60)
示例3: VCA
# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_network [as 別名]
vca = VCA(host=host, username=username, service_type="ondemand", version="5.7", verify=True)
# first login, with password
result = vca.login(password=password)
# then login with password and instance id, this will generate a session_token
result = vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
# next login, with token, org and org_url, no password, it will retrieve the organization
result = vca.login_to_instance(
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")