Esempio n. 1
0
    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 show(self, req, replica_id, id):
        execution = self._replica_tasks_execution_api.get_execution(
            req.environ["coriolis.context"], replica_id, id)
        if not execution:
            raise exc.HTTPNotFound()

        return replica_tasks_execution_view.single(req, execution)
Esempio n. 3
0
    def show(self, req, replica_id, id):
        context = req.environ["coriolis.context"]
        context.can(
            executions_policies.get_replica_executions_policy_label("show"))
        execution = self._replica_tasks_execution_api.get_execution(
            context, replica_id, id)
        if not execution:
            raise exc.HTTPNotFound()

        return replica_tasks_execution_view.single(req, execution)
 def _delete_disks(self, req, id, body):
     try:
         return replica_tasks_execution_view.single(
             req,
             self._replica_api.delete_disks(req.environ['coriolis.context'],
                                            id))
     except exception.NotFound as ex:
         raise exc.HTTPNotFound(explanation=ex.msg)
     except exception.InvalidParameterValue as ex:
         raise exc.HTTPNotFound(explanation=ex.msg)
Esempio n. 5
0
 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 create(self, req, replica_id, body):
        # TODO(alexpilotti): validate body

        execution_body = body.get("execution", {})
        shutdown_instances = execution_body.get("shutdown_instances", False)

        return replica_tasks_execution_view.single(
            req,
            self._replica_tasks_execution_api.create(
                req.environ['coriolis.context'], replica_id,
                shutdown_instances))
Esempio n. 7
0
    def create(self, req, replica_id, body):
        context = req.environ["coriolis.context"]
        context.can(
            executions_policies.get_replica_executions_policy_label("create"))

        # TODO(alexpilotti): validate body

        execution_body = body.get("execution", {})
        shutdown_instances = execution_body.get("shutdown_instances", False)

        return replica_tasks_execution_view.single(
            req,
            self._replica_tasks_execution_api.create(context, replica_id,
                                                     shutdown_instances))
Esempio n. 8
0
    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)