• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_lib.lib_find_vr_by_vm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:32,代码来源:test_remove_dhcp.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:27,代码来源:test_prometheus.py


示例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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:58,代码来源:test_create_eip_vm.py


示例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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:35,代码来源:test_1_vr_vm_with_200_sg.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:26,代码来源:test_update_l3_mtu.py


示例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)
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:32,代码来源:zstack_kvm_vm_checker.py


示例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)
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:35,代码来源:zstack_kvm_vm_checker.py


示例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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:33,代码来源:test_add_volume_vr.py


示例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
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:59,代码来源:kvm_checker_factory.py


示例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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:58,代码来源:delete_sg_with_2_attached_nics.py


示例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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:58,代码来源:rm_nic_sg_on_stopped_vm.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:57,代码来源:test_create_eip_vm3.py


示例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)
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:19,代码来源:zstack_kvm_eip_checker.py


示例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
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:11,代码来源:test_stub.py


示例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')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:52,代码来源:test_create_vyos_vm_time.py


示例16: 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.'
    
    rule_list = []
    for j in range(rule_num):
        target_ip = '%s%s' % (target_ip_prefix, str(1+j))
        rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.INGRESS, target_ip)
        rule_list.append(rule)

    sg1 = test_stub.create_sg()
    test_obj_dict.add_sg(sg1.security_group.uuid)
    sg1.add_rule(rule_list)
    sg_vm.attach(sg1, [vm_nics])

    rule_list = []
    for j in range(rule_num):
        target_ip = '%s%s' % (target_ip_prefix, str(1+j))
        rule = test_lib.lib_gen_sg_rule(Port.rule1_ports, inventory.TCP, inventory.EGRESS, target_ip)
        rule_list.append(rule)

    sg2 = test_stub.create_sg()
    test_obj_dict.add_sg(sg2.security_group.uuid)
    sg2.add_rule(rule_list)
    sg_vm.attach(sg2, [vm_nics])

    sg1_rules = test_lib.lib_get_sg_rule(sg1.security_group.uuid)
    if len(sg1_rules) != 200:
        test_util.test_fail("Did not find 200 SG rules for SG1: %s. We only catch %s rules" % (sg1.security_group.uuid, len(sg1_rules)))

    sg2_rules = test_lib.lib_get_sg_rule(sg2.security_group.uuid)
    if len(sg2_rules) != 200:
        test_util.test_fail("Did not find 200 SG rules for SG2: %s. We only catch %s rules" % (sg2.security_group.uuid, len(sg2_rules)))

    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')
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:51,代码来源:test_1_vr_vm_with_200_sg_rule.py


示例17: test

def test():

    pub_l3_vm, flat_l3_vm, vr_l3_vm = test_stub.generate_pub_test_vm(tbj=test_obj_dict)

    with test_lib.expected_failure('create vm use system network', Exception):
        test_stub.create_vm_with_random_offering(vm_name='test_vm',
                                                 image_name='imageName_net',
                                                 l3_name='l3ManagementNetworkName')

    vr = test_lib.lib_find_vr_by_vm(vr_l3_vm.get_vm())[0]

    for nic in vr.vmNics:
        test_util.test_logger(nic.ip)
        if not test_lib.lib_check_directly_ping(nic.ip):
            test_util.test_fail('IP:{} expected to be able to ping vip while it fail'.format(nic.ip))
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:15,代码来源:test_system_network.py


示例18: test

def test():
    test_util.test_dsc('Create test vm1 and check')
    if test_lib.lib_get_ha_enable() != 'true':
        test_util.test_skip("vm ha not enabled. Skip test")

    vm1 = test_stub.create_vlan_vm()
    test_obj_dict.add_vm(vm1)

    vm1.check()

    vrs = test_lib.lib_find_vr_by_vm(vm1.vm)
    for vr in vrs:
        if vr.applianceVmType != "vrouter":
            continue

        if ha_ops.get_vm_instance_ha_level(vr.uuid) != "NeverStop":
            test_util.test_fail('vr: %s is not set to HA mode NeverStop.' % vr.uuid)
    vm1.destroy()
    test_util.test_pass('Check VR HA mode Success')
开发者ID:mrwangxc,项目名称:zstack-woodpecker,代码行数:19,代码来源:test_vr_ha.py


示例19: test

def test():
    global vm, vm2

    test_stub.skip_if_scenario_is_multiple_networks(mul_nets_sce_list=["scenario-config-ceph-sep-man.xml", "scenario-config-ceph-sep-pub.xml"])
    test_stub.skip_if_vr_not_vyos("vr")
    test_lib.clean_up_all_vr()
    vm = test_stub.create_basic_vm()
    vm.check()
    vr_vm = test_lib.lib_find_vr_by_vm(vm.vm)[0]
    vm.destroy()

    t = threading.Thread(target=async_exec_reboot_vr, args=(vr_vm.uuid,))
    t.start()

    vm2 = test_stub.create_basic_vm(wait_vr_running=False)
    vm2.check()
    vm2.destroy()

    test_util.test_pass('Create VM when vyos is rebooting Test Success')
开发者ID:zstackorg,项目名称:zstack-woodpecker,代码行数:19,代码来源:test_vyos_rebooting_create_vm.py


示例20: create_vr_vm

def create_vr_vm(test_obj_dict, 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)
    temp_vm = None
    if not vrs:
        #create temp_vm1 for getting vlan1's vr for test pf_vm portforwarding
        temp_vm = create_vlan_vm()
        test_obj_dict.add_vm(temp_vm)
        vr = test_lib.lib_find_vr_by_vm(temp_vm.vm)[0]
        temp_vm.destroy()
        test_obj_dict.rm_vm(temp_vm)
    else:
        vr = vrs[0]
        if not test_lib.lib_is_vm_running(vr):
            test_lib.lib_robot_cleanup(test_obj_dict)
            test_util.test_skip('vr: %s is not running. Will skip test.' % vr.uuid)

    return vr
开发者ID:KevinDavidMitnick,项目名称:zstack-woodpecker,代码行数:20,代码来源:test_stub.py



注:本文中的zstackwoodpecker.test_lib.lib_find_vr_by_vm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_lib.lib_find_vr_pub_nic函数代码示例发布时间:2022-05-26
下一篇:
Python test_lib.lib_find_vr_by_l3_uuid函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap