本文整理汇总了Python中marvin.integration.lib.common.list_routers函数的典型用法代码示例。如果您正苦于以下问题:Python list_routers函数的具体用法?Python list_routers怎么用?Python list_routers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list_routers函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: reboot_Router
def reboot_Router(self):
vm_network_id = self.virtual_machine.nic[0].networkid
list_routers_response = list_routers(self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
networkid=vm_network_id)
self.assertEqual(isinstance(list_routers_response, list),
True,
"Check for list routers response return valid data")
router = list_routers_response[0]
#Reboot the router
cmd = rebootRouter.rebootRouterCmd()
cmd.id = router.id
self.apiclient.rebootRouter(cmd)
#List routers to check state of router
router_response = list_routers(self.apiclient,
id=router.id)
self.assertEqual(isinstance(router_response, list),
True,
"Check list response returns a valid list")
#List router should have router in running state and same public IP
self.assertEqual(router_response[0].state,
'Running',
"Check list router response for router state")
开发者ID:Bhathiya90,项目名称:cloudstack,代码行数:25,代码来源:test_egress_fw_rules.py
示例2: start_VPC_VRouter
def start_VPC_VRouter(self, router):
# Start the VPC Router
cmd = startRouter.startRouterCmd()
cmd.id = router.id
self.apiclient.startRouter(cmd)
routers = list_routers(
self.apiclient, account=self.account.name, domainid=self.account.domainid, zoneid=self.zone.id
)
self.assertEqual(isinstance(routers, list), True, "Check for list routers response return valid data")
router = routers[0]
self.assertEqual(router.state, "Running", "Check list router response for router state")
开发者ID:vogxn,项目名称:cloudstack,代码行数:12,代码来源:test_vpc_network_pfrules.py
示例3: stop_VPC_VRouter
def stop_VPC_VRouter(self):
router = self.get_Router_For_VPC()
self.debug("Stopping router ID: %s" % router.id)
cmd = stopRouter.stopRouterCmd()
cmd.id = router.id
self.apiclient.stopRouter(cmd)
routers = list_routers(self.apiclient, account=self.account.name, domainid=self.account.domainid)
self.assertEqual(isinstance(routers, list), True, "Check for list routers response return valid data")
router = routers[0]
self.assertEqual(router.state, "Stopped", "Check list router response for router state")
return router
开发者ID:vogxn,项目名称:cloudstack,代码行数:12,代码来源:test_vpc_network_pfrules.py
示例4: test_basicZoneVirtualRouter
def test_basicZoneVirtualRouter(self):
"""
Tests for basic zone virtual router
1. Is Running
2. is in the account the VM was deployed in
@return:
"""
routers = list_routers(self.apiclient, account=self.account.name)
self.assertTrue(len(routers) > 0, msg = "No virtual router found")
router = routers[0]
self.assertEqual(router.state, 'Running', msg="Router is not in running state")
self.assertEqual(router.account, self.account.name, msg="Router does not belong to the account")
开发者ID:Blufe,项目名称:cloudstack,代码行数:13,代码来源:test_vm_life_cycle.py
示例5: get_vpcrouter
def get_vpcrouter(self):
routers = list_routers(self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
)
self.assertEqual(isinstance(routers, list),
True,
"Check for list routers response return valid data"
)
self.assertNotEqual(len(routers),
0,
"Check list router response"
)
router = routers[0]
return router
开发者ID:baishuo,项目名称:cloudstack,代码行数:15,代码来源:test_vpc_network_pfrules.py
示例6: test_advZoneVirtualRouter
def test_advZoneVirtualRouter(self):
"""
Test advanced zone virtual router
1. Is Running
2. is in the account the VM was deployed in
3. Has a linklocalip, publicip and a guestip
@return:
"""
routers = list_routers(self.apiclient, account=self.account.name)
self.assertTrue(len(routers) > 0, msg = "No virtual router found")
router = routers[0]
self.assertEqual(router.state, 'Running', msg="Router is not in running state")
self.assertEqual(router.account, self.account.name, msg="Router does not belong to the account")
#Has linklocal, public and guest ips
self.assertIsNotNone(router.linklocalip, msg="Router has no linklocal ip")
self.assertIsNotNone(router.publicip, msg="Router has no public ip")
self.assertIsNotNone(router.guestipaddress, msg="Router has no guest ip")
开发者ID:Blufe,项目名称:cloudstack,代码行数:19,代码来源:test_vm_life_cycle.py
示例7: exec_script_on_user_vm
def exec_script_on_user_vm(self, script, exec_cmd_params, expected_result, negative_test=False):
try:
vm_network_id = self.virtual_machine.nic[0].networkid
vm_ipaddress = self.virtual_machine.nic[0].ipaddress
list_routers_response = list_routers(self.apiclient,
account=self.account.name,
domainid=self.account.domainid,
networkid=vm_network_id)
self.assertEqual(isinstance(list_routers_response, list),
True,
"Check for list routers response return valid data")
router = list_routers_response[0]
#Once host or mgt server is reached, SSH to the router connected to VM
# look for Router for Cloudstack VM network.
if self.apiclient.hypervisor.lower() == 'vmware':
#SSH is done via management server for Vmware
sourceip = self.apiclient.connection.mgtSvr
else:
#For others, we will have to get the ipaddress of host connected to vm
hosts = list_hosts(self.apiclient,
id=router.hostid)
self.assertEqual(isinstance(hosts, list),
True,
"Check list response returns a valid list")
host = hosts[0]
sourceip = host.ipaddress
self.debug("Sleep %s seconds for network on router to be up"
% self.services['sleep'])
time.sleep(self.services['sleep'])
if self.apiclient.hypervisor.lower() == 'vmware':
key_file = " -i /var/cloudstack/management/.ssh/id_rsa "
else:
key_file = " -i /root/.ssh/id_rsa.cloud "
ssh_cmd = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet"
expect_script = "#!/usr/bin/expect\n" + \
"spawn %s %s -p 3922 [email protected]%s\n" % (ssh_cmd, key_file, router.linklocalip) + \
"expect \"[email protected]%s:~#\"\n" % (router.name) + \
"send \"%s [email protected]%s %s; exit $?\r\"\n" % (ssh_cmd, vm_ipaddress, script) + \
"expect \"[email protected]%s's password: \"\n" % (vm_ipaddress) + \
"send \"password\r\"\n" + \
"interact\n"
self.debug("expect_script>>\n%s<<expect_script" % expect_script)
script_file = '/tmp/expect_script.exp'
fd = open(script_file,'w')
fd.write(expect_script)
fd.close()
ssh = SshClient(host=sourceip,
port=22,
user='root',
passwd=self.services["host_password"])
self.debug("SSH client to : %s obtained" % sourceip)
ssh.scp(script_file, script_file)
ssh.execute('chmod +x %s' % script_file)
self.debug("%s %s" % (script_file, exec_cmd_params))
exec_success = False
#Timeout set to 6 minutes
timeout = 360
while timeout:
self.debug('sleep %s seconds for egress rule to affect on Router.' % self.services['sleep'])
time.sleep(self.services['sleep'])
result = ssh.execute("%s %s" % (script_file, exec_cmd_params))
self.debug('Result is=%s' % result)
self.debug('Expected result is=%s' % expected_result)
if str(result).strip() == expected_result:
exec_success = True
break
else:
if result == []:
self.fail("Router is not accessible")
# This means router network did not come up as yet loop back.
if "send" in result[0]:
timeout -= self.services['sleep']
else: # Failed due to some other error
break
#end while
if timeout == 0:
self.fail("Router network failed to come up after 6 minutes.")
ssh.execute('rm -rf %s' % script_file)
if negative_test:
self.assertEqual(exec_success,
True,
"Script result is %s matching with %s" % (result, expected_result))
else:
self.assertEqual(exec_success,
True,
"Script result is %s is not matching with %s" % (result, expected_result))
except Exception as e:
#.........这里部分代码省略.........
开发者ID:ebrahimsami01,项目名称:cloudstack,代码行数:101,代码来源:test_egress_fw_rules.py
示例8: exec_script_on_user_vm
def exec_script_on_user_vm(self, script, exec_cmd_params, expected_result, negative_test=False):
try:
vm_network_id = self.virtual_machine.nic[0].networkid
vm_ipaddress = self.virtual_machine.nic[0].ipaddress
list_routers_response = list_routers(
self.apiclient, account=self.account.name, domainid=self.account.domainid, networkid=vm_network_id
)
self.assertEqual(
isinstance(list_routers_response, list), True, "Check for list routers response return valid data"
)
router = list_routers_response[0]
# Once host or mgt server is reached, SSH to the router connected to VM
# look for Router for Cloudstack VM network.
if self.apiclient.hypervisor.lower() == "vmware":
# SSH is done via management server for Vmware
sourceip = self.apiclient.connection.mgtSvr
else:
# For others, we will have to get the ipaddress of host connected to vm
hosts = list_hosts(self.apiclient, id=router.hostid)
self.assertEqual(isinstance(hosts, list), True, "Check list response returns a valid list")
host = hosts[0]
sourceip = host.ipaddress
self.debug("Sleep %s seconds for network on router to be up" % self.services["sleep"])
time.sleep(self.services["sleep"])
if self.apiclient.hypervisor.lower() == "vmware":
key_file = " -i /var/cloudstack/management/.ssh/id_rsa "
else:
key_file = " -i /root/.ssh/id_rsa.cloud "
ssh_cmd = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet"
expect_script = (
"#!/usr/bin/expect\n"
+ "spawn %s %s -p 3922 [email protected]%s\n" % (ssh_cmd, key_file, router.linklocalip)
+ 'expect "[email protected]%s:~#"\n' % (router.name)
+ 'send "%s [email protected]%s %s; exit $?\r"\n' % (ssh_cmd, vm_ipaddress, script)
+ 'expect "[email protected]%s\'s password: "\n' % (vm_ipaddress)
+ 'send "password\r"\n'
+ "interact\n"
)
self.debug("expect_script>>\n%s<<expect_script" % expect_script)
script_file = "/tmp/expect_script.exp"
fd = open(script_file, "w")
fd.write(expect_script)
fd.close()
ssh = remoteSSHClient(host=sourceip, port=22, user="root", passwd=self.services["host_password"])
self.debug("SSH client to : %s obtained" % sourceip)
ssh.scp(script_file, script_file)
ssh.execute("chmod +x %s" % script_file)
self.debug("%s %s" % (script_file, exec_cmd_params))
self.debug("sleep %s seconds for egress rule to affect on Router." % self.services["sleep"])
time.sleep(self.services["sleep"])
result = ssh.execute("%s %s" % (script_file, exec_cmd_params))
self.debug("Result is=%s" % result)
exec_success = False
if str(result).strip() == expected_result:
self.debug("script executed successfully exec_success=True")
exec_success = True
ssh.execute("rm -rf %s" % script_file)
if negative_test:
self.assertEqual(exec_success, True, "Script result is %s matching with %s" % (result, expected_result))
else:
self.assertEqual(
exec_success, True, "Script result is %s is not matching with %s" % (result, expected_result)
)
except Exception as e:
self.debug("Error=%s" % e)
raise e
开发者ID:ngtuna,项目名称:cloudstack-autoscale,代码行数:79,代码来源:test_egress_fw_rules.py
注:本文中的marvin.integration.lib.common.list_routers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论