Example #1
0
    def detail(self, req, replica_id):
        context = req.environ["coriolis.context"]
        context.can(
            executions_policies.get_replica_executions_policy_label("show"))

        return replica_tasks_execution_view.collection(
            req,
            self._replica_tasks_execution_api.get_executions(
                context, replica_id, include_tasks=True))
Example #2
0
    def delete(self, req, replica_id, id):
        context = req.environ["coriolis.context"]
        context.can(
            executions_policies.get_replica_executions_policy_label("delete"))

        try:
            self._replica_tasks_execution_api.delete(context, replica_id, id)
            raise exc.HTTPNoContent()
        except exception.NotFound as ex:
            raise exc.HTTPNotFound(explanation=ex.msg)
Example #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)
Example #4
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))
Example #5
0
    def _cancel(self, req, replica_id, id, body):
        context = req.environ['coriolis.context']
        context.can(
            execution_policies.get_replica_executions_policy_label('cancel'))
        try:
            force = (body["cancel"] or {}).get("force", False)

            self._replica_tasks_execution_api.cancel(context, replica_id, id,
                                                     force)
            raise exc.HTTPNoContent()
        except exception.NotFound as ex:
            raise exc.HTTPNotFound(explanation=ex.msg)
        except exception.InvalidParameterValue as ex:
            raise exc.HTTPNotFound(explanation=ex.msg)