|
|
@@ -45,7 +45,7 @@ class ReplicaController(api_wsgi.Controller):
|
|
|
req, self._replica_api.get_replicas(
|
|
|
context, include_tasks_executions=True))
|
|
|
|
|
|
- def _validate_create_body(self, body):
|
|
|
+ def _validate_create_body(self, context, body):
|
|
|
try:
|
|
|
replica = body["replica"]
|
|
|
|
|
|
@@ -57,6 +57,20 @@ class ReplicaController(api_wsgi.Controller):
|
|
|
|
|
|
network_map = replica.get("network_map", {})
|
|
|
api_utils.validate_network_map(network_map)
|
|
|
+ destination_environment['network_map'] = network_map
|
|
|
+
|
|
|
+ # NOTE(aznashwan): we validate the destination environment for the
|
|
|
+ # import provider before appending the 'storage_mappings' parameter
|
|
|
+ # for plugins with strict property name checks which do not yet
|
|
|
+ # support storage mapping features:
|
|
|
+ is_valid, message = (
|
|
|
+ self._endpoints_api.validate_target_environment(
|
|
|
+ context, destination_endpoint_id,
|
|
|
+ destination_environment))
|
|
|
+ if not is_valid:
|
|
|
+ raise exc.HTTPBadRequest(
|
|
|
+ explanation="Invalid destination "
|
|
|
+ "environment: %s" % message)
|
|
|
|
|
|
storage_mappings = replica.get("storage_mappings", {})
|
|
|
api_utils.validate_storage_mappings(storage_mappings)
|
|
|
@@ -64,7 +78,6 @@ class ReplicaController(api_wsgi.Controller):
|
|
|
# TODO(aznashwan): until the provider plugin interface is updated
|
|
|
# to have separate 'network_map' and 'storage_mappings' fields,
|
|
|
# we add them as part of the destination environment:
|
|
|
- destination_environment['network_map'] = network_map
|
|
|
destination_environment['storage_mappings'] = storage_mappings
|
|
|
|
|
|
return (origin_endpoint_id, destination_endpoint_id,
|
|
|
@@ -81,16 +94,7 @@ class ReplicaController(api_wsgi.Controller):
|
|
|
|
|
|
(origin_endpoint_id, destination_endpoint_id,
|
|
|
destination_environment, instances, network_map,
|
|
|
- storage_mappings, notes) = self._validate_create_body(body)
|
|
|
-
|
|
|
- is_valid, message = (
|
|
|
- self._endpoints_api.validate_target_environment(
|
|
|
- context, destination_endpoint_id,
|
|
|
- destination_environment))
|
|
|
- if not is_valid:
|
|
|
- raise exc.HTTPBadRequest(
|
|
|
- explanation="Invalid destination "
|
|
|
- "environment: %s" % message)
|
|
|
+ storage_mappings, notes) = self._validate_create_body(context, body)
|
|
|
|
|
|
return replica_view.single(req, self._replica_api.create(
|
|
|
context, origin_endpoint_id, destination_endpoint_id,
|