def index(self, req): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("list")) return replica_view.collection( req, self._replica_api.get_replicas(context, include_tasks_executions=False))
def update(self, req, id, body): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("update")) origin_endpoint_id = body['replica'].get('origin_endpoint_id', None) destination_endpoint_id = body['replica'].get( 'destination_endpoint_id', None) instances = body['replica'].get('instances', None) if origin_endpoint_id or destination_endpoint_id: raise exc.HTTPBadRequest( explanation="The source or destination endpoints for a " "Coriolis Replica cannot be updated after its " "creation. If the credentials of any of the " "Replica's endpoints need updating, please update " "the endpoints themselves.") if instances: raise exc.HTTPBadRequest( explanation="The list of instances of a Replica cannot be " "updated") updated_values = self._validate_update_body(id, context, body) try: return replica_tasks_execution_view.single( req, self._replica_api.update(req.environ['coriolis.context'], id, updated_values)) except exception.NotFound as ex: raise exc.HTTPNotFound(explanation=ex.msg) except exception.InvalidParameterValue as ex: raise exc.HTTPNotFound(explanation=ex.msg)
def detail(self, req): context = req.environ["coriolis.context"] context.can( replica_policies.get_replicas_policy_label("show_executions")) return replica_view.collection( req, self._replica_api.get_replicas(context, include_tasks_executions=True))
def show(self, req, id): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("show")) replica = self._replica_api.get_replica(context, id) if not replica: raise exc.HTTPNotFound() return replica_view.single(req, replica)
def delete(self, req, id): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("delete")) try: self._replica_api.delete(context, id) raise exc.HTTPNoContent() except exception.NotFound as ex: raise exc.HTTPNotFound(explanation=ex.msg)
def update(self, req, id, body): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("update")) updated_values = self._validate_update_body(body) return replica_view.single( req, self._replica_api.update(req.environ['coriolis.context'], id, updated_values))
def index(self, req): show_deleted = api_utils._get_show_deleted( req.GET.get("show_deleted", None)) context = req.environ["coriolis.context"] context.show_deleted = show_deleted context.can(replica_policies.get_replicas_policy_label("list")) return replica_view.collection( req, self._replica_api.get_replicas(context, include_tasks_executions=False))
def _delete_disks(self, req, id, body): context = req.environ['coriolis.context'] context.can(replica_policies.get_replicas_policy_label("delete_disks")) try: return replica_tasks_execution_view.single( req, self._replica_api.delete_disks(context, id)) except exception.NotFound as ex: raise exc.HTTPNotFound(explanation=ex.msg) except exception.InvalidParameterValue as ex: raise exc.HTTPNotFound(explanation=ex.msg)
def update(self, req, id, body): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("update")) updated_values = self._validate_update_body(id, context, body) try: return replica_tasks_execution_view.single( req, self._replica_api.update(req.environ['coriolis.context'], id, updated_values)) except exception.NotFound as ex: raise exc.HTTPNotFound(explanation=ex.msg) except exception.InvalidParameterValue as ex: raise exc.HTTPNotFound(explanation=ex.msg)
def create(self, req, body): context = req.environ["coriolis.context"] context.can(replica_policies.get_replicas_policy_label("create")) (origin_endpoint_id, destination_endpoint_id, source_environment, destination_environment, instances, network_map, 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, source_environment, destination_environment, instances, network_map, storage_mappings, notes))