Exemple #1
0
    def create_checker(self, test_obj):
        if not test_obj.volume:
            test_util.test_fail(
                'test_obj.volume is None, can not create checker')

        if not test_obj.target_vm:
            #only check db.
            return sim_checker.SimVolumeCheckerFactory().create_checker(
                test_obj)
        else:
            if test_lib.lib_is_sharable_volume(test_obj.volume):
                return kvm_checker.KvmSharableVolumeCheckerFactory(
                ).create_checker(test_obj)
            if test_lib.lib_is_vm_kvm(test_obj.target_vm.vm):
                return kvm_checker.KvmVolumeCheckerFactory().create_checker(
                    test_obj)
            if test_lib.lib_is_vm_sim(test_obj.target_vm.vm):
                return sim_checker.SimVolumeCheckerFactory().create_checker(
                    test_obj)
            if test_lib.lib_is_vm_vcenter(test_obj.target_vm.vm):
                return vcenter_checker.VCenterVolumeCheckerFactory(
                ).create_checker(test_obj)

            test_util.test_logger(
                'Did not find checker for Hypervisor type: %s' %
                test_lib.lib_get_hv_type_of_vm(test_obj.target_vm.vm))
    def create_checker(self, test_obj):
        if not test_obj.vm:
            test_util.test_fail('test_obj.vm is None, can not create checker')

        if test_lib.lib_is_vm_kvm(test_obj.vm):
            return kvm_checker.KvmVmCheckerFactory().create_checker(test_obj)

        if test_lib.lib_is_vm_sim(test_obj.vm):
            return sim_checker.SimVmCheckerFactory().create_checker(test_obj)

        if test_lib.lib_is_vm_vcenter(test_obj.vm):
            return vcenter_checker.VCenterVmCheckerFactory().create_checker(test_obj)

        test_util.test_logger('Did not find checker for Hypervisor type: %s' % test_lib.lib_get_hv_type_of_vm(test_obj.vm))
    def create_checker(self, test_obj):
        if not test_obj.vm:
            test_util.test_fail('test_obj.vm is None, can not create checker')

        if test_lib.lib_is_vm_kvm(test_obj.vm):
            return kvm_checker.KvmVmCheckerFactory().create_checker(test_obj)

        if test_lib.lib_is_vm_sim(test_obj.vm):
            return sim_checker.SimVmCheckerFactory().create_checker(test_obj)

        if test_lib.lib_is_vm_vcenter(test_obj.vm):
            return vcenter_checker.VCenterVmCheckerFactory().create_checker(test_obj)

        test_util.test_logger('Did not find checker for Hypervisor type: %s' % test_lib.lib_get_hv_type_of_vm(test_obj.vm))
    def create_checker(self, test_obj):
        if not test_obj.volume:
            test_util.test_fail('test_obj.volume is None, can not create checker')

        if not test_obj.target_vm and not test_obj.sharable_target_vms:
            #only check db.
            return sim_checker.SimVolumeCheckerFactory().create_checker(test_obj)
        else:
            if test_lib.lib_is_sharable_volume(test_obj.volume):
                return kvm_checker.KvmSharableVolumeCheckerFactory().create_checker(test_obj)
            if test_lib.lib_is_vm_kvm(test_obj.target_vm.vm):
                return kvm_checker.KvmVolumeCheckerFactory().create_checker(test_obj)
            if test_lib.lib_is_vm_sim(test_obj.target_vm.vm):
                return sim_checker.SimVolumeCheckerFactory().create_checker(test_obj)
            if test_lib.lib_is_vm_vcenter(test_obj.target_vm.vm):
                return vcenter_checker.VCenterVolumeCheckerFactory().create_checker(test_obj)

            test_util.test_logger('Did not find checker for Hypervisor type: %s' % test_lib.lib_get_hv_type_of_vm(test_obj.target_vm.vm))
Exemple #5
0
    def create_checker(self, test_obj): 
        vcenter_sg_checker_chain = checker_header.CheckerChain()
        checker_dict = {}
        for nic_uuid in test_obj.get_all_nics():
            target_vm = test_obj.get_vm_by_nic(nic_uuid)
            if target_vm.state == vm_header.RUNNING:
                if test_lib.lib_is_vm_sim(target_vm.vm):
                    vcenter_sg_checker_chain.add_checker(db_checker.zstack_sg_db_checker(True), test_obj)
                    continue
                if not test_lib.lib_is_vm_vcenter(target_vm.vm):
                    continue
                    
                if test_obj.get_nic_tcp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_internal_vms_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_tcp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    if not test_obj.get_nic_tcp_ingress_rules(nic_uuid):
                        checker = sg_checker.zstack_vcenter_sg_tcp_internal_vms_checker()
                        checker.set_nic_uuid(nic_uuid)
                        vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_udp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_udp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_icmp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_internal_vms_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_icmp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    #if not test_obj.get_nic_icmp_ingress_rules(nic_uuid):
                    #    checker = sg_checker.zstack_vcenter_sg_icmp_internal_vms_checker()
                    #    checker.set_nic_uuid(nic_uuid)
                    #    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                else:
                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            else:
                #TODO: only do iptables rules check
                checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

        for test_vm in test_obj.get_detached_vm():
            vm = test_vm.vm
            if not test_lib.lib_is_vm_vcenter(vm):
                continue
            checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

        return vcenter_sg_checker_chain
    def create_checker(self, test_obj): 
        vcenter_sg_checker_chain = checker_header.CheckerChain()
        checker_dict = {}
        for nic_uuid in test_obj.get_all_nics():
            target_vm = test_obj.get_vm_by_nic(nic_uuid)
            if target_vm.state == vm_header.RUNNING:
                if test_lib.lib_is_vm_sim(target_vm.vm):
                    vcenter_sg_checker_chain.add_checker(db_checker.zstack_sg_db_checker(True), test_obj)
                    continue
                if not test_lib.lib_is_vm_vcenter(target_vm.vm):
                    continue
                    
                if test_obj.get_nic_tcp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_internal_vms_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_tcp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    if not test_obj.get_nic_tcp_ingress_rules(nic_uuid):
                        checker = sg_checker.zstack_vcenter_sg_tcp_internal_vms_checker()
                        checker.set_nic_uuid(nic_uuid)
                        vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_udp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_udp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_icmp_ingress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_internal_vms_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)
                else:
                    checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                if test_obj.get_nic_icmp_egress_rules(nic_uuid):
                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                    #if not test_obj.get_nic_icmp_ingress_rules(nic_uuid):
                    #    checker = sg_checker.zstack_vcenter_sg_icmp_internal_vms_checker()
                    #    checker.set_nic_uuid(nic_uuid)
                    #    vcenter_sg_checker_chain.add_checker(checker, True, test_obj)

                else:
                    checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                    checker.set_nic_uuid(nic_uuid)
                    vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            else:
                #TODO: only do iptables rules check
                checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

                checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
                checker.set_nic_uuid(nic_uuid)
                vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

        for test_vm in test_obj.get_detached_vm():
            vm = test_vm.vm
            if not test_lib.lib_is_vm_vcenter(vm):
                continue
            checker = sg_checker.zstack_vcenter_sg_tcp_ingress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_tcp_egress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_icmp_egress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_icmp_ingress_exist_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_udp_ingress_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

            checker = sg_checker.zstack_vcenter_sg_udp_egress_checker()
            checker.set_vm(vm)
            vcenter_sg_checker_chain.add_checker(checker, False, test_obj)

        return vcenter_sg_checker_chain