|
|
@@ -339,51 +339,35 @@ class RestoreReplicaDiskSnapshotsTask(base.TaskRunner):
|
|
|
return task_info
|
|
|
|
|
|
|
|
|
-class ValidateReplicaExecutionParametersTask(base.TaskRunner):
|
|
|
+class ValidateReplicaExecutionSourceInputsTask(base.TaskRunner):
|
|
|
def run(self, ctxt, instance, origin, destination, task_info,
|
|
|
event_handler):
|
|
|
event_manager = events.EventManager(event_handler)
|
|
|
- # validate source params:
|
|
|
origin_type = origin["type"]
|
|
|
- origin_connection_info = base.get_connection_info(ctxt, origin)
|
|
|
- destination_connection_info = base.get_connection_info(
|
|
|
- ctxt, destination)
|
|
|
- destination_type = destination["type"]
|
|
|
source_provider = providers_factory.get_provider(
|
|
|
origin_type, constants.PROVIDER_TYPE_VALIDATE_REPLICA_EXPORT,
|
|
|
event_handler, raise_if_not_found=False)
|
|
|
- export_info = None
|
|
|
- if source_provider:
|
|
|
- export_info = source_provider.validate_replica_export_input(
|
|
|
- ctxt, base.get_connection_info(ctxt, origin), instance,
|
|
|
- source_environment=origin.get("source_environment", {}))
|
|
|
- else:
|
|
|
+ origin_connection_info = base.get_connection_info(ctxt, origin)
|
|
|
+ if not source_provider:
|
|
|
event_manager.progress_update(
|
|
|
"Replica Export Provider for platform '%s' does not support "
|
|
|
"Replica input validation" % origin_type)
|
|
|
+ else:
|
|
|
+ source_provider.validate_replica_export_input(
|
|
|
+ ctxt, origin_connection_info, instance,
|
|
|
+ source_environment=origin.get("source_environment", {}))
|
|
|
|
|
|
- if export_info is None:
|
|
|
- source_endpoint_provider = providers_factory.get_provider(
|
|
|
- origin_type, constants.PROVIDER_TYPE_ENDPOINT_INSTANCES,
|
|
|
- event_handler, raise_if_not_found=False)
|
|
|
- if not source_endpoint_provider:
|
|
|
- event_manager.progress_update(
|
|
|
- "Replica Export Provider for platform '%s' does not "
|
|
|
- "support querying instance export info. Cannot perform "
|
|
|
- "Replica Import validation for destination platform "
|
|
|
- "'%s'" % (origin_type, destination_type))
|
|
|
- return task_info
|
|
|
- export_info = source_endpoint_provider.get_instance(
|
|
|
- ctxt, origin_connection_info, instance)
|
|
|
+ return task_info
|
|
|
|
|
|
- # validate Export info:
|
|
|
- schemas.validate_value(
|
|
|
- export_info, schemas.CORIOLIS_VM_EXPORT_INFO_SCHEMA)
|
|
|
- # NOTE: this export info will get overriden with updated values
|
|
|
- # and disk paths after the ExportInstanceTask.
|
|
|
- task_info["export_info"] = export_info
|
|
|
|
|
|
- # validate destination params:
|
|
|
+class ValidateReplicaExecutionDestinationInputsTask(base.TaskRunner):
|
|
|
+ def run(self, ctxt, instance, origin, destination, task_info,
|
|
|
+ event_handler):
|
|
|
+ event_manager = events.EventManager(event_handler)
|
|
|
+ destination_type = destination["type"]
|
|
|
+
|
|
|
+ destination_connection_info = base.get_connection_info(
|
|
|
+ ctxt, destination)
|
|
|
destination_provider = providers_factory.get_provider(
|
|
|
destination_type,
|
|
|
constants.PROVIDER_TYPE_VALIDATE_REPLICA_IMPORT, event_handler,
|
|
|
@@ -394,11 +378,19 @@ class ValidateReplicaExecutionParametersTask(base.TaskRunner):
|
|
|
"Replica input validation" % destination_type)
|
|
|
return task_info
|
|
|
|
|
|
+ export_info = task_info.get("export_info")
|
|
|
+ if not export_info:
|
|
|
+ raise exception.CoriolisException(
|
|
|
+ "Instance export info is not set. Cannot perform "
|
|
|
+ "Replica Import validation for destination platform "
|
|
|
+ "'%s'" % destination_type)
|
|
|
+
|
|
|
# NOTE: the target environment JSON schema should have been validated
|
|
|
# upon accepting the Replica API creation request.
|
|
|
target_environment = destination.get("target_environment", {})
|
|
|
destination_provider.validate_replica_import_input(
|
|
|
- ctxt, destination_connection_info, target_environment, export_info)
|
|
|
+ ctxt, destination_connection_info, target_environment,
|
|
|
+ export_info)
|
|
|
|
|
|
return task_info
|
|
|
|
|
|
@@ -436,62 +428,74 @@ class ValidateReplicaDeploymentParametersTask(base.TaskRunner):
|
|
|
return task_info
|
|
|
|
|
|
|
|
|
-class UpdateReplicaTask(base.TaskRunner):
|
|
|
+class UpdateSourceReplicaTask(base.TaskRunner):
|
|
|
def run(self, ctxt, instance, origin, destination, task_info,
|
|
|
event_handler):
|
|
|
- destination_provider = None
|
|
|
- source_provider = None
|
|
|
- new_source_environment = task_info.get('source_environment')
|
|
|
- new_destination_environment = task_info.get('destination_environment')
|
|
|
-
|
|
|
- if new_source_environment:
|
|
|
- source_provider = providers_factory.get_provider(
|
|
|
- origin["type"], constants.PROVIDER_TYPE_REPLICA_UPDATE,
|
|
|
- event_handler, raise_if_not_found=False)
|
|
|
- if not source_provider:
|
|
|
- raise exception.CoriolisException(
|
|
|
- "Replica source provider plugin for '%s' does not support"
|
|
|
- " updating Replicas." % origin["type"])
|
|
|
-
|
|
|
- if new_destination_environment:
|
|
|
- destination_provider = providers_factory.get_provider(
|
|
|
- destination["type"], constants.PROVIDER_TYPE_REPLICA_UPDATE,
|
|
|
- event_handler, raise_if_not_found=False)
|
|
|
- if not destination_provider:
|
|
|
- raise exception.CoriolisException(
|
|
|
- "Replica destination provider plugin for '%s' does not "
|
|
|
- "support updating Replicas." % destination["type"])
|
|
|
+ event_manager = events.EventManager(event_handler)
|
|
|
+ new_source_env = task_info.get('source_environment', {})
|
|
|
+ if not new_source_env:
|
|
|
+ event_manager.progress_update(
|
|
|
+ "No new source environment options provided")
|
|
|
+ return task_info
|
|
|
|
|
|
- connection_info = base.get_connection_info(ctxt, destination)
|
|
|
+ source_provider = providers_factory.get_provider(
|
|
|
+ origin["type"], constants.PROVIDER_TYPE_REPLICA_UPDATE,
|
|
|
+ event_handler, raise_if_not_found=False)
|
|
|
+ if not source_provider:
|
|
|
+ raise exception.CoriolisException(
|
|
|
+ "Replica source provider plugin for '%s' does not support"
|
|
|
+ " updating Replicas" % origin["type"])
|
|
|
+
|
|
|
+ origin_connection_info = base.get_connection_info(ctxt, origin)
|
|
|
+ export_info = task_info.get("export_info", {})
|
|
|
+ volumes_info = task_info.get("volumes_info", {})
|
|
|
+
|
|
|
+ LOG.info("Checking source provider environment params")
|
|
|
+ # NOTE: the `source_environment` in the `origin` is the one set
|
|
|
+ # in the dedicated DB column of the Replica and thus stores
|
|
|
+ # the previous value of it:
|
|
|
+ old_source_env = origin.get('source_environment', {})
|
|
|
+ volumes_info = source_provider.check_update_environment_params(
|
|
|
+ ctxt, origin_connection_info, export_info, volumes_info,
|
|
|
+ old_source_env, new_source_env)
|
|
|
+
|
|
|
+ task_info['volumes_info'] = volumes_info
|
|
|
+
|
|
|
+ return task_info
|
|
|
+
|
|
|
+
|
|
|
+class UpdateDestinationReplicaTask(base.TaskRunner):
|
|
|
+ def run(self, ctxt, instance, origin, destination, task_info,
|
|
|
+ event_handler):
|
|
|
+ event_manager = events.EventManager(event_handler)
|
|
|
+ new_destination_env = task_info.get('destination_environment', {})
|
|
|
+ if not new_destination_env:
|
|
|
+ event_manager.progress_update(
|
|
|
+ "No new destination environment options provided")
|
|
|
+ return task_info
|
|
|
+
|
|
|
+ destination_provider = providers_factory.get_provider(
|
|
|
+ destination["type"], constants.PROVIDER_TYPE_REPLICA_UPDATE,
|
|
|
+ event_handler, raise_if_not_found=False)
|
|
|
+ if not destination_provider:
|
|
|
+ raise exception.CoriolisException(
|
|
|
+ "Replica destination provider plugin for '%s' does not "
|
|
|
+ "support updating Replicas" % destination["type"])
|
|
|
+
|
|
|
+ destination_connection_info = base.get_connection_info(
|
|
|
+ ctxt, destination)
|
|
|
export_info = task_info.get("export_info", {})
|
|
|
volumes_info = task_info.get("volumes_info", {})
|
|
|
|
|
|
- if source_provider:
|
|
|
- LOG.info("Checking source provider environment params")
|
|
|
- # NOTE: the `source_environment` in the `origin` is the one set
|
|
|
- # in the dedicated DB column of the Replica and thus stores
|
|
|
- # the previous value of it:
|
|
|
- old_source_environment = origin.get('source_environment', {})
|
|
|
- new_source_environment = task_info.get('source_environment', {})
|
|
|
- source_provider.check_update_environment_params(
|
|
|
- ctxt, connection_info, export_info, volumes_info,
|
|
|
- old_source_environment, new_source_environment)
|
|
|
-
|
|
|
- if destination_provider:
|
|
|
- LOG.info("Checking destination provider environment params")
|
|
|
- # NOTE: the `target_environment` in the `destination` is the one
|
|
|
- # set in the dedicated DB column of the Replica and thus stores
|
|
|
- # the previous value of it:
|
|
|
- old_destination_environment = destination.get(
|
|
|
- 'target_environment', {})
|
|
|
- new_destination_environment = task_info.get(
|
|
|
- 'destination_environment', {})
|
|
|
-
|
|
|
- volumes_info = (
|
|
|
- destination_provider.check_update_environment_params(
|
|
|
- ctxt, connection_info, export_info, volumes_info,
|
|
|
- old_destination_environment, new_destination_environment))
|
|
|
-
|
|
|
- task_info['volumes_info'] = volumes_info
|
|
|
+ LOG.info("Checking destination provider environment params")
|
|
|
+ # NOTE: the `target_environment` in the `destination` is the one
|
|
|
+ # set in the dedicated DB column of the Replica and thus stores
|
|
|
+ # the previous value of it:
|
|
|
+ old_destination_env = destination.get('target_environment', {})
|
|
|
+ volumes_info = destination_provider.check_update_environment_params(
|
|
|
+ ctxt, destination_connection_info, export_info, volumes_info,
|
|
|
+ old_destination_env, new_destination_env)
|
|
|
+
|
|
|
+ task_info['volumes_info'] = volumes_info
|
|
|
|
|
|
return task_info
|