コード例 #1
0
    def run(self, ctxt, instance, origin, destination, task_info,
            event_handler):
        target_environment = destination.get("target_environment") or {}
        export_info = task_info['export_info']

        provider = providers_factory.get_provider(
            destination["type"], constants.PROVIDER_TYPE_REPLICA_IMPORT,
            event_handler)
        connection_info = base.get_connection_info(ctxt, destination)

        volumes_info = _get_volumes_info(task_info)

        replica_resources_info = provider.deploy_replica_target_resources(
            ctxt, connection_info, target_environment, volumes_info)
        schemas.validate_value(
            replica_resources_info,
            schemas.CORIOLIS_DISK_SYNC_RESOURCES_INFO_SCHEMA,
            # NOTE: we avoid raising so that the cleanup task
            # can [try] to deal with the temporary resources.
            raise_on_error=False)

        volumes_info = _check_ensure_volumes_info_ordering(
            export_info, replica_resources_info["volumes_info"])

        task_info["volumes_info"] = volumes_info
        task_info["migr_target_resources"] = replica_resources_info[
            "migr_resources"]

        migr_connection_info = replica_resources_info["connection_info"]
        try:
            backup_writers.BackupWritersFactory(migr_connection_info,
                                                None).get_writer()
        except BaseException as err:
            LOG.exception("Invalid connection info: %s" % err)

        task_info["migr_target_connection_info"] = migr_connection_info

        return task_info
コード例 #2
0
    def _run(self, ctxt, instance, origin, destination, task_info,
             event_handler):
        target_environment = task_info["target_environment"]
        export_info = task_info['export_info']

        provider = providers_factory.get_provider(
            destination["type"], constants.PROVIDER_TYPE_REPLICA_IMPORT,
            event_handler)
        connection_info = base.get_connection_info(ctxt, destination)

        volumes_info = _get_volumes_info(task_info)

        replica_resources_info = provider.deploy_replica_target_resources(
            ctxt, connection_info, target_environment, volumes_info)
        schemas.validate_value(
            replica_resources_info,
            schemas.CORIOLIS_DISK_SYNC_RESOURCES_INFO_SCHEMA,
            # NOTE: we avoid raising so that the cleanup task
            # can [try] to deal with the temporary resources.
            raise_on_error=False)

        if "volumes_info" in replica_resources_info:
            volumes_info = replica_resources_info["volumes_info"]
            volumes_info = _check_ensure_volumes_info_ordering(
                export_info, volumes_info)
        else:
            LOG.warn("Replica target provider for '%s' did not return any "
                     "'volumes_info'. Using the previous value of it.")

        migr_connection_info = {}
        if 'connection_info' in replica_resources_info:
            migr_connection_info = replica_resources_info['connection_info']
            try:
                backup_writers.BackupWritersFactory(migr_connection_info,
                                                    None).get_writer()
            except Exception as err:
                LOG.warn(
                    "Seemingly invalid backup writer conn info. Replica will "
                    "likely fail during disk Replication. Error is: %s" %
                    (str(err)))

            if migr_connection_info:
                if 'connection_details' in migr_connection_info:
                    migr_connection_info['connection_details'] = (
                        base.marshal_migr_conn_info(
                            migr_connection_info['connection_details']))
                schemas.validate_value(
                    migr_connection_info,
                    schemas.CORIOLIS_DISK_SYNC_RESOURCES_CONN_INFO_SCHEMA,
                    # NOTE: we avoid raising so that the cleanup task
                    # can [try] to deal with the temporary resources.
                    raise_on_error=False)
        else:
            LOG.warn(
                "Replica target provider for '%s' did NOT return any "
                "'connection_info'. Defaulting to %s", destination["type"],
                migr_connection_info)

        target_resources = {}
        if 'migr_resources' not in replica_resources_info:
            LOG.warn(
                "Replica target provider for '%s' did NOT return any "
                "'migr_resources'. Defaulting to %s", destination["type"],
                target_resources)
        else:
            target_resources = replica_resources_info["migr_resources"]

        return {
            "volumes_info": volumes_info,
            "target_resources": target_resources,
            "target_resources_connection_info": migr_connection_info
        }