예제 #1
0
    def migration_start(self, context, ignore_list, share_id,
                        share_instance_id, dest_share_instance_id,
                        connection_info_src, connection_info_dest):

        LOG.debug(
            "Received request to migrate share content from share instance "
            "%(instance_id)s to instance %(dest_instance_id)s.", {
                'instance_id': share_instance_id,
                'dest_instance_id': dest_share_instance_id
            })

        share_ref = self.db.share_get(context, share_id)
        share_instance_ref = self.db.share_instance_get(context,
                                                        share_instance_id,
                                                        with_share_data=True)

        share_rpcapi = share_rpc.ShareAPI()

        mount_path = CONF.mount_tmp_location

        try:
            copy = data_utils.Copy(
                os.path.join(mount_path, share_instance_id),
                os.path.join(mount_path, dest_share_instance_id), ignore_list,
                CONF.check_hash)

            self._copy_share_data(context, copy, share_ref, share_instance_id,
                                  dest_share_instance_id, connection_info_src,
                                  connection_info_dest)
        except exception.ShareDataCopyCancelled:
            share_rpcapi.migration_complete(context, share_instance_ref,
                                            dest_share_instance_id)
            return
        except Exception:
            self.db.share_update(
                context, share_id,
                {'task_state': constants.TASK_STATE_DATA_COPYING_ERROR})
            msg = _("Failed to copy contents from instance %(src)s to "
                    "instance %(dest)s.") % {
                        'src': share_instance_id,
                        'dest': dest_share_instance_id
                    }
            LOG.exception(msg)
            share_rpcapi.migration_complete(context, share_instance_ref,
                                            dest_share_instance_id)
            raise exception.ShareDataCopyFailed(reason=msg)
        finally:
            self.busy_tasks_shares.pop(share_id, None)

        LOG.info(
            "Completed copy operation of migrating share content from share "
            "instance %(instance_id)s to instance %(dest_instance_id)s.", {
                'instance_id': share_instance_id,
                'dest_instance_id': dest_share_instance_id
            })
예제 #2
0
    def setUp(self):
        super(CopyClassTestCase, self).setUp()
        src = '/path/fake/src'
        dest = '/path/fake/dst'
        ignore_list = ['item']
        self._copy = data_utils.Copy(src, dest, ignore_list)
        self._copy.total_size = 10000
        self._copy.current_size = 100
        self._copy.current_copy = {'file_path': '/fake/path', 'size': 100}

        self.mock_log = self.mock_object(data_utils, 'LOG')