Exemple #1
0
    def _await_trans_server_started(self, host, port, protocol):
        retries = 30
        attempts = 1
        if retries >= 1:
            attempts = retries + 1
        for attempts in range(1, attempts + 1):
            cls = agentclient.get_birdiegateway_client(host, port)
            status = cls.vservices.get_data_transformer_status(protocol)
            task_status = status.get('status')
            # if noe volume data transformer failed, thos clone failed
            if 0 == task_status:
                LOG.debug("Fillp server started.")
                return attempts
            elif 1 == task_status:
                LOG.debug("Fillp server starting, waiting...")
            else:
                _msg = 'Data transformer error: fillp cmd error.'
                LOG.error(_msg)
                raise exception.DownLoadDataError(error=_msg)

            greenthread.sleep(1)

        # NOTE(harlowja: Should only happen if we ran out of attempts
        raise exception.DownLoadDataError(error="Transformer server "
                                          "start failed")
Exemple #2
0
    def _await_data_trans_status(selfself, host, port, protocol):
        retries = CONF.trans_retry_num
        if retries < 0:
            LOG.warning(
                "Treating negative config value (%(retries)s) for "
                " 'data_transformer_retries' as 0.", {'retries': retries})

        attempts = 1
        if retries >= 1:
            attempts = retries + 1
        for attempts in range(1, attempts + 1):
            cls = agentclient.get_birdiegateway_client(host, port)
            status = cls.vservices.get_data_transformer_status(protocol)
            task_status = status.get('status')
            # if noe volume data transformer failed, thos clone failed
            if 1 == task_status:
                return attempts
            elif 0 == task_status:
                LOG.debug("Fillp data transformering, waiting...")
            else:
                _msg = 'Data transformer error: fillp cmd error.'
                LOG.error(_msg)
                raise exception.DownLoadDataError(error=_msg)

            greenthread.sleep(CONF.trans_retry_interval)

        # NOTE(harlowja: Should only happen if we ran out of attempts
        raise exception.DownLoadDataError(error="Transformer data " "time out")
Exemple #3
0
 def stop_fillp_server(self, service, protocol):
     try:
         self.cmd_process.fillp_close_connect(service, protocol)
     except Exception as e:
         _msg = "Fillp stop server errror: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #4
0
 def query_transformer_task_status(self, protocol):
     try:
         status = self.cmd_process.fillp_query_status(protocol)
         return status
     except Exception as e:
         _msg = "Fillp query transfer data failed: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #5
0
 def _start_fillp_server(self, address, port, des_dev, protocol):
     try:
         self.cmd_process.fillp_start_server(address, port, des_dev,
                                             protocol)
     except Exception as e:
         _msg = "Start fillp service failed: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #6
0
 def _transformer_data(self, address, port, src_dev, des_dev, protocol):
     try:
         res = self.cmd_process.fill_send_data(address, port, src_dev,
                                               des_dev, protocol)
         return res
     except Exception as e:
         _msg = "Fillp transformer data failed: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #7
0
 def transformer_data(self, address, port, src_dev, des_dev, protocol):
     try:
         args = [address, port, src_dev, des_dev, protocol]
         fillp_thread = AgentThread(self._transformer_data, *args)
         fillp_thread.start()
         return fillp_thread
     except Exception as e:
         _msg = "Fillp transformer data failed: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #8
0
 def start_fillp_server(self, address, port, des_dev, protocol):
     try:
         args = [address, port, des_dev, protocol]
         fillp_thread = AgentThread(self._start_fillp_server, *args)
         fillp_thread.start()
         return fillp_thread
     except Exception as e:
         _msg = "Start fillp service failed: %s" % unicode(e)
         LOG.error(_msg)
         raise exception.DownLoadDataError(error=_msg)
Exemple #9
0
    def _ftp_copy_volume(self, volume):
        dev_disk_name = volume['des_dev_name']
        disk_format = volume['src_dev_format']

        # 1. format disk
        self.migrate_ssh.format_disk(dev_disk_name, disk_format)

        # 2. make the same directory as the source vm's disk mounted
        mount_dir = volume['src_mount_point'][0]

        self.migrate_ssh.make_dir(mount_dir)

        # mount disk to the directory
        volume['disk_name'] = volume['des_dev_name']
        volume['disk_format'] = volume['src_dev_format']
        self.migrate_ssh.mount_disk(volume, mount_dir)

        # 3.download data to this disk in the directory
        remote_host = volume['src_gw_url']

        # splite remote gw url, get host ip and port
        urls = remote_host.split(':')
        if len(urls) != 2:
            LOG.error("Input source gw url error: %s", remote_host)
            msg = "Input source gw url error: " + remote_host
            raise exception.InvalidInput(reason=msg)

        host_ip = urls[0]
        host_port = urls[1]
        try:
            # create transformer task and return task id for quering its state
            task_id = uuidutils.generate_uuid()
            task_state = task_status.TRANSFORMERING
            task = transformer.TransformerTask(task_id, task_state=task_state)
            self.trans_states.add_task(task)

            # start data transformer task thread
            args = [host_ip, host_port, mount_dir, mount_dir]
            thread = AgentThread(self.downLoadDirTree, self.trans_states,
                                 task_id, *args)
            thread.start()
            return task_id
            # self.downLoadDirTree(host_ip, host_ip, mount_dir, mount_dir)
        except Exception as e:
            LOG.error("DownLoad data error: %s", e)
            raise exception.DownLoadDataError(error=e)
Exemple #10
0
    def _fillp_transformer_data(self, src_host, src_port, trans_ip, trans_port,
                                src_disk, dev_disk, protocol, mount):
        # 1. copy data
        try:
            agent_client = agentclient.get_birdiegateway_client(
                src_host, src_port)
            agent_client.vservices.start_transformer_data(
                trans_ip, trans_port, src_disk, dev_disk, protocol)
            # waiting server started
            self._await_trans_server_started(src_host, src_port, protocol)
        except Exception as e:
            LOG.error("Fillp transformer data error: %s", e)
            raise exception.DownLoadDataError(error=e)

        # 2. wait data transformer finish
        agent_driver = self.agents.get(protocol)
        try:
            self._await_data_trans_status(src_host, src_port, protocol)
        except Exception as e:
            LOG.error("Await data transformer error: %s", unicode(e))
            raise
        finally:
            # 2.2 close fillp server
            if 'socket' != protocol:
                agent_driver.stop_fillp_server('server', protocol)

        # 3. mount disk to directory
        if mount:
            try:
                self.migrate_ssh.make_dir(mount)
                disk = {}
                disk['disk_name'] = dev_disk
                self.migrate_ssh.mount_disk(disk, mount)
            except Exception as e:
                LOG.error("Mount disk %(disk)s to %(dir)s error: %(error)s", {
                    'disk': dev_disk,
                    'dir': mount,
                    'error': e
                })
                raise
Exemple #11
0
    def _fillp_copy_volume(self, volume, protocol):
        # 1. get sgent vm info
        src_disk_name = volume.get('src_dev_name')
        dev_disk_name = volume.get('des_dev_name')
        src_vm_url = volume.get('src_gw_url')
        des_vm_url = volume.get('des_gw_url')
        mount_dir = volume.get('src_mount_point', None)

        mount = None
        if mount_dir:
            mount = mount_dir[0]

        des_urls = des_vm_url.split(':')
        if len(des_urls) != 2:
            LOG.error("Inpute source gw url error: %s", des_vm_url)
            msg = "Inpute source gw url error: %s" % des_vm_url
            raise exception.InvalidInput(reason=msg)

        des_ip = des_urls[0]

        # 2. start fillp server
        trans_port = volume.get('trans_port')
        agent_driver = self.agents.get(protocol)
        try:
            agent_driver.start_fillp_server(des_ip, trans_port, dev_disk_name,
                                            protocol)
        except Exception as e:
            _msg = "Conveyor agent start fillp server error: %s" % e
            LOG.error(_msg)
            raise exception.V2vException(message=_msg)

        # 3. start data transformer
        # splite remove gw url, get host ip and port
        src_urls = src_vm_url.split(':')
        if len(src_urls) != 2:
            LOG.error("Input source gw url error: %s", src_vm_url)
            msg = "Input Source gw url error: %s" % src_vm_url
            raise exception.InvalidInput(reason=msg)

        src_vm_ip = src_urls[0]
        src_vm_port = src_urls[1]

        try:
            # create transformer task and return task id for querying it's
            # state
            task_id = uuidutils.generate_uuid()
            task_state = task_status.TRANSFORMERING
            task = transformer.TransformerTask(task_id, task_state=task_state)
            self.trans_states.add_task(task)

            # start data transformer task thread
            args = [
                src_vm_ip, src_vm_port, des_ip, trans_port, src_disk_name,
                dev_disk_name, protocol, mount
            ]
            thread = AgentThread(self._fillp_transformer_data,
                                 self.trans_states, task_id, *args)
            thread.start()
            return task_id
        except Exception as e:
            LOG.error("Download data error: %s", e)
            raise exception.DownLoadDataError(Error=e)