Esempio n. 1
0
    def __wait_vmnet_ready(self):
        """
        wait for 120 seconds for vm net ready
        10.0.2.* is the default ip address allocated by qemu
        """
        count = 40
        while count:
            out = self.__control_session('ifconfig')
            if "10.0.2" in out:
                return True
            time.sleep(6)
            count -= 1

        raise StartVMFailedException(
            'Virtual machine control net not ready in 120 seconds!!!')
    def _start_vm(self):
        xml_file = "/tmp/%s.xml" % self.vm_name
        try:
            os.remove(xml_file)
        except:
            pass
        self.root.write(xml_file)
        self.host_session.copy_file_to(xml_file)
        time.sleep(2)

        self.host_session.send_expect("virsh", "virsh #")
        self.host_session.send_expect("create /root/%s.xml" % self.vm_name,
                                      "virsh #")
        self.host_session.send_expect("quit", "# ")
        out = self.__control_session('ping', '120')

        if "Not responded" in out:
            raise StartVMFailedException("Not response in 120 seconds!!!")

        self.__wait_vmnet_ready()
Esempio n. 3
0
    def wait_migration_done(self):
        """
        Wait for migration done. If not finished after three minutes
        will raise exception.
        """
        # wait for migration done
        count = 30
        while count:
            out = self.__monitor_session('info', 'migrate')
            if "completed" in out:
                self.host_logger.info("%s" % out)
                # after migration done, status is pause
                self.vm_status = ST_PAUSE
                return True

            time.sleep(6)
            count -= 1

        raise StartVMFailedException(
            'Virtual machine can not finished in 180 seconds!!!')