示例#1
0
    def test_delete_not_found_exception(self):
        self.mox.StubOutWithMock(db, 'process_get_all')
        self.mox.StubOutWithMock(db, 'process_delete')

        db.process_get_all(
            IsA(context.RequestContext), GID, {"ppid": PID1}).AndReturn([{}])
        db.process_delete(IsA(context.RequestContext), GID, PID1).AndRaise(
            exception.ProcessNotFound(pid=PID1))
        self.mox.ReplayAll()
        url = get_base_url(GID) + "/" + PID1
        req = get_request(url, "DELETE")
        res = req.get_response(self.app)
        self.assertEqual(res.status_code, 404)
示例#2
0
 def test_process_delete(self):
     values_before = self._get_base_values()
     process = db.process_create(self.user_ctxt,
                                 values_before,
                                 [self.network["network_id"]],
                                 [self.securitygroup["securitygroup_id"]])
     process_after = db.process_delete(
         self.user_ctxt, self.gid, process["pid"])
     self.assertEqual("DELETING", process_after["status"])
     self.assertEqual(1, process_after["deleted"])
     self.assertIsNotNone(process_after.get("deleted_at"))
示例#3
0
    def delete(self, req, gid, pid):

        def _validate(gid, pid):

            if not uuidutils.is_uuid_like(gid):
                raise exception.GroupNotFound(gid=gid)

            if not uuidutils.is_uuid_like(pid):
                raise exception.ProcessNotFound(pid=pid)

        def _get_child_pid(context, gid, pid):
            processes = db.process_get_all(context, gid, {"ppid": pid})
            targets = []
            for process in processes:
                if "pid" in process:
                    targets.append(process["pid"])
                    targets.extend(
                        _get_child_pid(context, gid, process["pid"]))
            return targets

        try:
            _validate(gid, pid)
            context = req.environ['rack.context']
            targets = _get_child_pid(context, gid, pid)
            targets.append(pid)

            for target in targets:
                process = db.process_delete(context, gid, target)
                host = self.scheduler_rpcapi.select_destinations(
                    context,
                    request_spec={},
                    filter_properties={})
                self.operator_rpcapi.process_delete(
                    context,
                    host["host"],
                    nova_instance_id=process["nova_instance_id"])

        except exception.NotFound as exc:
            raise webob.exc.HTTPNotFound(explanation=exc.format_message())

        except Exception as e:
            LOG.exception(e)
            raise exception.ProcessDeleteFailed()
示例#4
0
文件: processes.py 项目: yanyuge/rack
 def _delete(context, gid, pid, nova_id):
     self.manager.process_delete(context, nova_id)
     try:
         db.process_delete(context, gid, pid)
     except exception.NotFound as e:
         LOG.exception(e)