Пример #1
0
    def cleanup_dest(vm, src_uri=""):
        """
        Clean up the destination host environment
        when doing the uni-direction migration.
        """
        logging.info("Cleaning up VMs on %s" % vm.connect_uri)
        try:
            if libvirt_vm.virsh_domain_exists(vm.name, vm.connect_uri):
                vm_state = vm.state()
                if vm_state == "paused":
                    vm.resume()
                elif vm_state == "shut off":
                    vm.start()
                vm.destroy()

                if vm.is_persistent():
                    vm.undefine()

        except Exception, detail:
            logging.error("Cleaning up destination failed.\n%s" % detail)
Пример #2
0
            vm.start()

        # Checking for --persistent.
        logging.debug("Checking for --persistent option.")
        check_dest_persistent = True
        if options.count("persistent") or extra.count("persistent"):
            if not vm.is_persistent():
                check_dest_persistent = False

        # Checking for --undefinesource.
        logging.debug("Checking for --undefinesource option.")
        check_src_undefine = True
        if options.count("undefinesource") or extra.count("undefinesource"):
            logging.info("Verifying <virsh domstate> DOES return an error."
                         "%s should not exist on %s." % (vm_name, src_uri))
            if libvirt_vm.virsh_domain_exists(vm_name, src_uri):
                check_src_undefine = False

        # Checking for --dname.
        logging.debug("Checking for --dname option.")
        check_dest_dname = True
        if options.count("dname") or extra.count("dname"):
            dname = extra.split()[1].strip()
            if not libvirt_vm.virsh_domain_exists(dname, dest_uri):
                check_dest_dname = False

        # Checking for --xml.
        logging.debug("Checking for --xml option.")
        check_dest_xml = True
        if options.count("xml") or extra.count("xml"):
            if dest_xmlfile: