本文整理汇总了Python中zstackwoodpecker.test_lib.lib_find_vr_by_vm函数的典型用法代码示例。如果您正苦于以下问题:Python lib_find_vr_by_vm函数的具体用法?Python lib_find_vr_by_vm怎么用?Python lib_find_vr_by_vm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib_find_vr_by_vm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
'''
Test Description:
Will check if test VM's mac/ip assignment will be removed in VR's DNS config, after VM is shutdown. And if VM's mac/ip will be added back after it restart.
Resource required:
Need support 2 VMs.
'''
global test_obj_dict
test_util.test_dsc('Create test vm and check. VR only has DNS and DHCP services')
vm = test_stub.create_vlan_vm()
test_obj_dict.add_vm(vm)
vm.check()
vm.stop()
if linux.wait_callback_success(check_dhcp_remove, vm.vm, 5, 0.2):
test_util.test_logger('[vm:] %s mac/ip was removed in VR /etc/hosts.dhcp' % vm.vm.uuid)
else:
test_util.test_logger('check dhcp remove failure, will try to print VR DHCP tables')
test_lib.lib_print_vr_dhcp_tables(test_lib.lib_find_vr_by_vm(vm.vm)[0])
test_util.test_fail('[vm:] %s mac was not removed in VR /etc/hosts.dhcp, after vm was stopped.' % vm.vm.uuid)
if linux.wait_callback_success(check_dhcp_release, vm.vm, 5, 0.2):
test_util.test_logger('[vm:] %s mac/ip was removed in VR /etc/hosts.leases' % vm.vm.uuid)
else:
test_util.test_logger('check dhcp lease failure, will try to print VR DHCP tables')
test_lib.lib_print_vr_dhcp_tables(test_lib.lib_find_vr_by_vm(vm.vm)[0])
test_util.test_fail('[vm:] %s mac was not removed in VR /etc/hosts.leases, after vm was stopped.' % vm.vm.uuid)
vm.start()
vm.check()
vm.destroy()
vm.check()
test_util.test_pass('Successfully check VM DHCP release when VM stopped')
示例2: test
def test():
test_util.test_dsc("create vr vm and vpc vrouter")
vm = test_stub.create_vr_vm('vr_vm','imageName_s','l3NoVlanNetworkName2')
test_obj_dict.add_vm(vm)
if not test_lib.lib_find_vr_by_vm(vm.vm) or not test_lib.lib_find_vr_by_vm(vm.vm)[0]:
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_skip("skip the test for no vr found in the env.")
vpc_vr = test_stub.create_vpc_vrouter()
check_host_prometheus_conf()
check_vrouter_prometheus_conf()
check_prometheus_data()
hosts = test_lib.lib_get_all_hosts_from_plan()
for host in hosts:
host_ops.reconnect_host(host_uuid)
check_host_prometheus_conf()
check_vrouter_prometheus_conf()
check_prometheus_data()
test_lib.lib_execute_ssh_cmd(mn_ip,"root","password","zstack-ctl restart_node",timeout=300)
check_host_prometheus_conf()
check_vrouter_prometheus_conf()
check_prometheus_data()
test_lib.lib_error_cleanup(test_obj_dict)
test_util.test_pass('Test prometheus Success')
示例3: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr1_l3_uuid)
temp_vm1 = None
if not vrs:
#create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
temp_vm1 = test_stub.create_vlan_vm()
test_obj_dict.add_vm(temp_vm1)
vr1 = test_lib.lib_find_vr_by_vm(temp_vm1.vm)[0]
else:
vr1 = vrs[0]
l3_name = os.environ.get('l3NoVlanNetworkName1')
vr2_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr2_l3_uuid)
temp_vm2 = None
if not vrs:
#create temp_vm2 for getting novlan's vr for test pf_vm portforwarding
temp_vm2 = test_stub.create_user_vlan_vm()
test_obj_dict.add_vm(temp_vm2)
vr2 = test_lib.lib_find_vr_by_vm(temp_vm2.vm)[0]
else:
vr2 = vrs[0]
#we do not need temp_vm1 and temp_vm2, since we just use their VRs.
if temp_vm1:
temp_vm1.destroy()
test_obj_dict.rm_vm(temp_vm1)
if temp_vm2:
temp_vm2.destroy()
test_obj_dict.rm_vm(temp_vm2)
vm_nic = vm.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('create_eip_test', l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
vip.check()
vm.destroy()
test_obj_dict.rm_vm(vm)
vip.check()
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例4: test
def test():
global test_obj_dict
test_util.test_dsc("Create 1 VMs with vlan VR L3 network for SG testing.")
vm1 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm1)
vm1.check()
nic_uuid = vm1.vm.vmNics[0].uuid
vm_nics = (nic_uuid, vm1)
l3_uuid = vm1.vm.vmNics[0].l3NetworkUuid
vr_vm = test_lib.lib_find_vr_by_vm(vm1.vm)[0]
vm1_ip = test_lib.lib_get_vm_nic_by_l3(vr_vm, l3_uuid).ip
target_ip_prefix = '10.10.10.'
test_util.test_dsc("Create security groups.")
for i in range(sg_num):
target_ip = '%s%s' % (target_ip_prefix, str(1+i))
rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule4 = test_lib.lib_gen_sg_rule(Port.rule4_ports, inventory.TCP, inventory.INGRESS, target_ip)
rule5 = test_lib.lib_gen_sg_rule(Port.rule5_ports, inventory.TCP, inventory.INGRESS, target_ip)
sg = test_stub.create_sg()
test_obj_dict.add_sg(sg.security_group.uuid)
sg.add_rule([rule1, rule2, rule3, rule4, rule5])
sg_vm.attach(sg, [vm_nics])
time.sleep(3)
#need regularlly clean up log files in virtual router when doing stress test
test_lib.lib_check_cleanup_vr_logs_by_vm(vm1.vm)
#clean up all vm and sg
test_lib.lib_robot_cleanup(test_obj_dict)
test_util.test_pass('Create/Destroy VM with VR successfully')
示例5: test
def test():
global default_l3_mtu
test_util.test_dsc('Create test vm and check. VR has DNS SNAT EIP PF and DHCP services')
l3_name = os.environ.get('l3VlanNetworkName1')
l3_net_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
default_l3_mtu = net_ops.get_l3_mtu(l3_net_uuid)
vm = test_stub.create_vlan_vm(l3_name)
test_obj_dict.add_vm(vm)
vrs = test_lib.lib_find_vr_by_vm(vm.vm)
for vr in vrs:
if vr.applianceVmType != "vrouter":
test_util.test_skip("Skip l3 mtu test for non vrouter")
vm.check()
if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu %s"' % (default_l3_mtu)):
test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))
net_ops.set_l3_mtu(l3_net_uuid, 1200)
vm.reboot()
vm.check()
if not test_lib.lib_execute_command_in_vm(vm.get_vm(), 'tracepath -n yyk.net | tail -1 | grep "pmtu 1200"'):
test_util.test_fail("fail to check mtu in [vm:] %s" % (vm.get_vm().uuid))
vm.destroy()
test_util.test_pass('Create VirtualRouter VM DNS DHCP SANT EIP PF Test Success')
示例6: check
def check(self):
super(zstack_kvm_vm_network_checker, self).check()
vm = self.test_obj.vm
host = test_lib.lib_get_vm_host(vm)
test_lib.lib_install_testagent_to_host(host)
test_lib.lib_set_vm_host_l2_ip(vm)
vr_vms = test_lib.lib_find_vr_by_vm(vm)
if not vr_vms:
test_util.test_warn('No Virtual Router was found for VM: %s. Skip testing.' % vm.uuid)
return self.judge(self.exp_result)
for vr_vm in vr_vms:
nic = test_lib.lib_get_vm_nic_by_vr(vm, vr_vm)
if not 'DHCP' in test_lib.lib_get_l3_service_type(nic.l3NetworkUuid):
test_util.test_logger("Skip [VR:] %s, since it doesn't provide DHCP service" % vr_vm.uuid)
continue
guest_ip = nic.ip
command = 'ping -c 5 -W 5 %s >/tmp/ping_result 2>&1; ret=$?; cat /tmp/ping_result; exit $ret' % guest_ip
if not test_lib.lib_execute_sh_cmd_by_agent_with_retry(host.managementIp, command, self.exp_result):
test_util.test_logger('Checker result: FAIL to ping [target:] %s [ip:] %s from [host:] %s' % (vm.uuid, guest_ip, host.uuid))
if self.exp_result == True:
test_util.test_logger("network connection result is not expected pass, will print VR's network configuration:")
test_lib.lib_print_vr_network_conf(vr_vm)
return self.judge(False)
else:
test_util.test_logger('Checker result: SUCCESSFULLY ping [target:] %s [ip:] %s from [host:] %s' % (vm.uuid, guest_ip, host.uuid))
test_util.test_logger("Checker result: ping target [vm:] %s from [host:] %s SUCCESS" % (vm.uuid, host.uuid))
return self.judge(True)
示例7: check
def check(self):
super(zstack_kvm_vm_snat_checker, self).check()
vm = self.test_obj.vm
test_lib.lib_install_testagent_to_vr(vm)
host = test_lib.lib_get_vm_host(vm)
vm_cmd_result = None
vr_vms = test_lib.lib_find_vr_by_vm(vm)
test_lib.lib_set_vm_host_l2_ip(vm)
for vr_vm in vr_vms:
test_util.test_logger("Begin to check [vm:] %s SNAT" % vm.uuid)
nic = test_lib.lib_get_vm_nic_by_vr(vm, vr_vm)
if not 'SNAT' in test_lib.lib_get_l3_service_type(nic.l3NetworkUuid):
test_util.test_logger("Skip [VR:] %s, since it doesn't provide SNAT service" % vr_vm.uuid)
continue
ping_target = test_lib.test_config.pingTestTarget.text_
#Check if there is a SG rule to block ICMP checking
if test_lib.lib_is_sg_rule_exist(nic.uuid, None, None, inventory.EGRESS):
if not test_lib.lib_is_sg_rule_exist(nic.uuid, inventory.ICMP, ping_target, inventory.EGRESS):
test_util.test_warn('Skip SNAT checker: because there is ICMP Egress Rule was assigned to [nic:] %s and the allowed target ip is not %s' % (nic.uuid, ping_target))
return self.judge(self.exp_result)
guest_ip = nic.ip
vm_command = 'ping -c 5 -W 5 %s >/tmp/ping_result 2>&1; ret=$?; cat /tmp/ping_result; exit $ret' % ping_target
vm_cmd_result = test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host.managementIp, nic.ip, test_lib.lib_get_vm_username(vm), test_lib.lib_get_vm_password(vm), vm_command, self.exp_result)
if not vm_cmd_result:
test_util.test_logger('Checker result: FAIL to ping [target:] %s from [vm:] %s .' % (ping_target, vm.uuid))
if self.exp_result == True:
test_util.test_logger("network connection result is not expected pass, will print VR's network configuration:")
test_lib.lib_print_vr_network_conf(vr_vm)
return self.judge(False)
else:
test_util.test_logger('Checker result: SUCCEED to ping [target:] %s from [vm:] %s .' % (ping_target, vm.uuid))
return self.judge(True)
示例8: test
def test():
global test_obj_dict
test_util.test_dsc('Create test vm and check')
vm = test_stub.create_vlan_vm()
test_obj_dict.add_vm(vm)
vm.check()
test_util.test_dsc('Create volume and check')
volume = test_stub.create_volume()
vr_vm = test_lib.lib_find_vr_by_vm(vm.vm)[0]
test_vr_vm = zstack_test_vm.ZstackTestVm()
test_vr_vm.vm = vr_vm
test_vr_vm.state = vm_header.RUNNING
volume.attach(vm)
volume.check()
volume.detach()
volume.check()
test_util.test_dsc('Attach volume to VR vm and check')
volume.attach(test_vr_vm)
volume.check()
volume.detach()
volume.check()
volume.delete()
volume.check()
vm.destroy()
test_util.test_pass('Create Data Volume for Vlan VirtualRouter Test Success')
示例9: create_checker
def create_checker(self, test_obj):
kvm_vm_checker_chain = checker_header.CheckerChain()
checker_dict = {}
if test_obj.state == vm_header.RUNNING:
checker_dict[vm_checker.zstack_kvm_vm_set_host_vlan_ip] = True
checker_dict[db_checker.zstack_vm_db_checker] = True
checker_dict[vm_checker.zstack_kvm_vm_running_checker] = True
#if behind of VR
vrs = test_lib.lib_find_vr_by_vm(test_obj.vm)
if vrs:
svr_types = test_lib.lib_get_l3s_service_type(test_obj.vm)
#The first DHCP checker will wait for VM start up.
if 'DHCP' in svr_types:
checker_dict[vm_checker.zstack_kvm_vm_dhcp_checker] = True
checker_dict[vm_checker.zstack_kvm_vm_network_checker] = True
#if guest can't get IP address from DHCP, auto case can
# not test DNS feature.
if 'DNS' in svr_types:
checker_dict[vm_checker.zstack_kvm_vm_dns_checker] \
= True
else:
checker_dict[vm_checker.zstack_kvm_vm_dns_checker] \
= False
else:
checker_dict[vm_checker.zstack_kvm_vm_dhcp_checker] = False
checker_dict[vm_checker.zstack_kvm_vm_network_checker] \
= False
if 'SNAT' in svr_types:
checker_dict[vm_checker.zstack_kvm_vm_snat_checker] = True
else:
checker_dict[vm_checker.zstack_kvm_vm_snat_checker] = False
#if 'PortForwarding' in svr_types:
# checker_dict[vm_checker.zstack_kvm_vm_dnat_checker] = True
#else:
# checker_dict[vm_checker.zstack_kvm_vm_dnat_checker] = False
else:
sp_types = test_lib.lib_get_vm_l3_service_provider_types(test_obj.vm)
if 'Flat' in sp_types:
checker_dict[vm_checker.zstack_kvm_vm_ssh_no_vr_checker] = True
if test_obj.get_creation_option().get_default_l3_uuid():
checker_dict[vm_checker.zstack_kvm_vm_default_l3_checker] = True
elif test_obj.state == vm_header.STOPPED:
checker_dict[db_checker.zstack_vm_db_checker] = True
#stopped_checker is deprecated, since the stopped vm will be removed
#from host.
#checker_dict[vm_checker.zstack_kvm_vm_stopped_checker] = True
elif test_obj.state == vm_header.DESTROYED:
#VM destroy will cause vm structure be removed from DB, when VmExpungeInterval is set to 1, so doesn't need to check destroyed state sync in db in most case.
checker_dict[db_checker.zstack_vm_db_checker] = True
checker_dict[vm_checker.zstack_kvm_vm_destroyed_checker] = True
elif test_obj.state == vm_header.EXPUNGED:
checker_dict[db_checker.zstack_vm_db_checker] = True
kvm_vm_checker_chain.add_checker_dict(checker_dict, test_obj)
return kvm_vm_checker_chain
示例10: test
def test():
'''
Test image requirements:
1. have nc to check the network port
2. have "nc" to open any port
3. it doesn't include a default firewall
VR image is a good candiate to be the guest image.
'''
test_util.test_dsc("Create 3 VMs with vlan VR L3 network and using VR image.")
vm1 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm2)
vm1.check()
vm2.check()
test_util.test_dsc("Create security groups.")
sg1 = test_stub.create_sg()
sg_vm = test_sg_vm_header.ZstackTestSgVm()
test_obj_dict.set_sg_vm(sg_vm)
l3_uuid = vm1.vm.vmNics[0].l3NetworkUuid
vr_vm = test_lib.lib_find_vr_by_vm(vm1.vm)[0]
vm2_ip = test_lib.lib_get_vm_nic_by_l3(vm2.vm, l3_uuid).ip
rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, vm2_ip)
rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.INGRESS, vm2_ip)
rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.INGRESS, vm2_ip)
sg1.add_rule([rule1])
sg1.add_rule([rule2])
sg1.add_rule([rule3])
sg_vm.check()
nic_uuid1 = vm1.vm.vmNics[0].uuid
nic_uuid2 = vm2.vm.vmNics[0].uuid
# nic_uuid3 = vm2.vm.vmNics[0].uuid
vm1_nics = (nic_uuid1, vm1)
vm2_nics = (nic_uuid2, vm2)
# vm3_nics = (nic_uuid3, vm3)
#test_stub.lib_add_sg_rules(sg1.uuid, [rule0, rule1])
test_util.test_dsc("Add nic to security group 1.")
test_util.test_dsc("Allowed ingress ports: %s" % test_stub.rule1_ports)
#sg_vm.attach(sg1, [vm1_nics, vm2_nics, vm3_nics])
sg_vm.attach(sg1, [vm1_nics, vm2_nics])
sg_vm.check()
sg_vm.delete_sg(sg1)
sg_vm.check()
vm1.destroy()
test_obj_dict.rm_vm(vm1)
vm2.destroy()
test_obj_dict.rm_vm(vm2)
test_util.test_pass('Delete Security Group with 2 attached NICs Success')
示例11: test
def test():
'''
Test image requirements:
1. have nc to check the network port
2. have "nc" to open any port
3. it doesn't include a default firewall
VR image is a good candiate to be the guest image.
'''
global test_obj_dict
test_util.test_dsc("Create 2 VMs with vlan VR L3 network and using VR image.")
vm1 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm1)
vm2 = test_stub.create_sg_vm()
test_obj_dict.add_vm(vm2)
vm1.check()
vm2.check()
test_util.test_dsc("Create security groups.")
sg1 = test_stub.create_sg()
sg_vm = test_sg_vm_header.ZstackTestSgVm()
nic_uuid = vm1.vm.vmNics[0].uuid
vm_nics = (nic_uuid, vm1)
l3_uuid = vm1.vm.vmNics[0].l3NetworkUuid
vr_vm = test_lib.lib_find_vr_by_vm(vm1.vm)[0]
vm2_ip = test_lib.lib_get_vm_nic_by_l3(vm2.vm, l3_uuid).ip
rule1 = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.EGRESS, vm2_ip)
rule2 = test_lib.lib_gen_sg_rule(Port.rule2_ports, inventory.TCP, inventory.EGRESS, vm2_ip)
rule3 = test_lib.lib_gen_sg_rule(Port.rule3_ports, inventory.TCP, inventory.EGRESS, vm2_ip)
sg1.add_rule([rule1, rule2, rule3])
sg_vm.add_stub_vm(l3_uuid, vm2)
#add sg1
test_util.test_dsc("Add VM1 nic to security group 1.")
sg_vm.attach(sg1, [vm_nics])
sg_vm.check()
#shutdown vm1
test_util.test_dsc("Shutdown VM1")
vm1.stop()
#remove vm1 nic from sg1
test_util.test_dsc("Remove nic from security group 1 to stopped vm1.")
sg_vm.detach(sg1, nic_uuid)
test_util.test_dsc("Start VM1")
vm1.start()
vm1.check()
sg_vm.check()
vm1.destroy()
vm2.destroy()
sg_vm.delete_sg(sg1)
test_util.test_pass('Detach stopped VM NIC from Security Group Test Success')
示例12: test
def test():
test_util.test_dsc('Create test vm with EIP and check.')
vm = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm)
vm2 = test_stub.create_vlan_vm(os.environ.get('l3VlanNetworkName1'))
test_obj_dict.add_vm(vm2)
l3_name = os.environ.get('l3VlanNetworkName1')
vr1_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr1_l3_uuid)
temp_vm1 = None
if not vrs:
#create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
temp_vm1 = test_stub.create_vlan_vm()
test_obj_dict.add_vm(temp_vm1)
vr1 = test_lib.lib_find_vr_by_vm(temp_vm1.vm)[0]
else:
vr1 = vrs[0]
#we do not need temp_vm1 and temp_vm2, since we just use their VRs.
if temp_vm1:
temp_vm1.destroy()
test_obj_dict.rm_vm(temp_vm1)
vm_nic = vm.vm.vmNics[0]
vm2_nic = vm2.vm.vmNics[0]
vm_nic_uuid = vm_nic.uuid
pri_l3_uuid = vm_nic.l3NetworkUuid
vr = test_lib.lib_find_vr_by_l3_uuid(pri_l3_uuid)[0]
if vr.applianceVmType == "VirtualRouter":
test_util.test_skip("This test only for vrouter network")
vr_pub_nic = test_lib.lib_find_vr_pub_nic(vr)
l3_uuid = vr_pub_nic.l3NetworkUuid
vip = test_stub.create_vip('create_eip_test', l3_uuid)
test_obj_dict.add_vip(vip)
eip = test_stub.create_eip('create eip test', vip_uuid=vip.get_vip().uuid, vnic_uuid=vm_nic_uuid, vm_obj=vm)
vip.attach_eip(eip)
vm.check()
vm2.check()
test_stub.make_ssh_no_password(vm2.get_vm())
vm_ip = vm_nic.ip
vm2_ip = vm2_nic.ip
ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null'
cmd = 'ping -c 8 %s' % (eip.get_eip().vipIp)
shell.call("%s %s %s" % (ssh_cmd, vm2_ip, cmd))
cmd = '''"echo quit | timeout 4 telnet %s 22|grep 'Escape character'"''' % (eip.get_eip().vipIp)
shell.call("%s %s %s" % (ssh_cmd, vm2_ip, cmd))
vm.destroy()
test_obj_dict.rm_vm(vm)
vip.check()
eip.delete()
vip.delete()
test_obj_dict.rm_vip(vip)
test_util.test_pass('Create EIP for VM Success')
示例13: vm_check
def vm_check(self, test_result):
vm = self.test_obj.vm
test_util.test_logger("Begin to check VM DHCP in VM: %s" % vm.uuid)
nic = test_lib.lib_get_nic_by_uuid(self.test_obj.get_creation_option().get_vm_nic_uuid())
test_lib.lib_find_vr_by_vm(vm)
guest_ip = nic.ip
host = test_lib.lib_get_vm_host(vm)
vm_command = '/sbin/ifconfig'
vm_cmd_result = test_lib.lib_ssh_vm_cmd_by_agent_with_retry(host.managementIp, self.test_obj.vip.ip, test_lib.lib_get_vm_username(vm), test_lib.lib_get_vm_password(vm), vm_command)
if not vm_cmd_result:
test_util.test_logger('Checker result: FAIL to execute test ssh command in test [vm:] %s throught [host:] %s.' % (vm.uuid, host.name))
return self.judge(False)
if guest_ip in vm_cmd_result:
test_util.test_logger('Checker result: guest [ip:] %s is SET in guest [vm:] %s.' % (guest_ip, vm.uuid))
else:
test_util.test_logger('Checker result: guest [ip:] %s is NOT found in guest [vm:] %s. \n It might be because the ifconfig is not reflect the ip address yet. \n The current ifconfig result is: %s' % (guest_ip, vm.uuid, vm_cmd_result))
return self.judge(False)
return self.judge(True)
示例14: get_vr_by_private_l3_name
def get_vr_by_private_l3_name(l3_name):
vr_l3_uuid = test_lib.lib_get_l3_by_name(l3_name).uuid
vrs = test_lib.lib_find_vr_by_l3_uuid(vr_l3_uuid)
if not vrs:
#create temp_vm for getting vlan1's vr
temp_vm = create_vlan_vm(l3_name)
vr = test_lib.lib_find_vr_by_vm(temp_vm.vm)[0]
temp_vm.destroy()
else:
vr = vrs[0]
return vr
示例15: test
def test():
test_util.test_dsc('Create test vm and check the time spend on each stage')
test_util.test_skip('Time cases need further polish, skip test right now')
vm_name = 'vm_'+key_gen(7)
begin_time = int(time.time()*1000)
vm = test_stub.create_named_vm(vm_name)
test_obj_dict.add_vm(vm)
ps = test_lib.lib_get_primary_storage_by_uuid(vm.get_vm().allVolumes[0].primaryStorageUuid)
if ps.type != inventory.LOCAL_STORAGE_TYPE:
test_util.test_skip('Skip test on non-localstorage')
vr = test_lib.lib_find_vr_by_vm(vm.vm)[0]
if vr.applianceVmType != "vrouter":
test_util.test_skip("This test only for vyos network")
vm.check()
[select_bs_time, allocate_host_time, allocate_ps_time, local_storage_allocate_capacity_time,\
allocate_volume_time, allocate_nic_time, instantiate_res_pre_time, create_on_hypervisor_time,\
instantiate_res_post_time] = test_stub.get_stage_time(vm_name, begin_time)
test_util.test_dsc("select_bs_time is "+str(select_bs_time))
test_util.test_dsc("allocate_host_time is "+str(allocate_host_time))
test_util.test_dsc("allocate_ps_time is "+str(allocate_ps_time))
test_util.test_dsc("local_storage_allocate_capacity_time is "+str(local_storage_allocate_capacity_time))
test_util.test_dsc("allocate_volume_time is "+str(allocate_volume_time))
test_util.test_dsc("allocate_nic_time is "+str(allocate_nic_time))
test_util.test_dsc("instantiate_res_pre_time is "+str(instantiate_res_pre_time))
test_util.test_dsc("create_on_hypervisor_time is "+str(create_on_hypervisor_time))
test_util.test_dsc("instantiate_res_post_time is "+str(instantiate_res_post_time))
if select_bs_time > 10:
test_util.test_fail('select_bs_time is bigger than 10 milliseconds')
if allocate_host_time > 190:
test_util.test_fail('allocate_host_time is bigger than 190 milliseconds')
if allocate_ps_time > 70:
test_util.test_fail('allocate_ps_time is bigger than 70 milliseconds')
if local_storage_allocate_capacity_time > 70:
test_util.test_fail('local_storage_allocate_capacity_time is bigger than 70 milliseconds')
if allocate_volume_time > 90:
test_util.test_fail('allocate_volume_time is bigger than 90 milliseconds')
if allocate_nic_time > 70:
test_util.test_fail('allocate_nic_time is bigger than 70 milliseconds')
if instantiate_res_pre_time > 1300:
test_util.test_fail('instantiate_res_pre_time is bigger than 1300 milliseconds')
if create_on_hypervisor_time > 8000:
test_util.test_fail('create_on_hypervisor_time is bigger than 2500 milliseconds')
if instantiate_res_post_time > 30:
test_util.test_fail('instantiate_res_post_time is bigger than 30 milliseconds')
vm.destroy()
test_util.test_pass('Create VM and Check time for Each Stage Test Success')