Ejemplo n.º 1
0
 def test_group_delete(self):
     values_before = {
         "gid": self.gid,
         "user_id": "user_id",
         "project_id": "project_id",
         "display_name": "My_group",
         "display_description": "This is my group.",
         "status": "active"
     }
     db.group_create(self.user_ctxt, values_before)
     deleted_group = db.group_delete(self.ctxt, self.gid)
     self.assertEqual(deleted_group["deleted"], 1)
     self.assertEqual(deleted_group["status"], "DELETING")
     self.assertIsNotNone(deleted_group.get("deleted_at"))
Ejemplo n.º 2
0
    def delete(self, req, gid):

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

            context = req.environ['rack.context']

            keypairs = db.keypair_get_all(context, gid)
            if keypairs:
                raise exception.GroupInUse(gid=gid)

            securitygroups = db.securitygroup_get_all(context, gid)
            if securitygroups:
                raise exception.GroupInUse(gid=gid)

            networks = db.network_get_all(context, gid)
            if networks:
                raise exception.GroupInUse(gid=gid)

            processes = db.process_get_all(context, gid)
            if processes:
                raise exception.GroupInUse(gid=gid)

            db.group_delete(context, gid)

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

        except exception.GroupInUse as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())

        except Exception as e:
            LOG.warn(e)
            raise exception.GroupDeleteFailed()
Ejemplo n.º 3
0
    def delete(self, req, gid):
        def _validate(gid):
            if not uuidutils.is_uuid_like(gid):
                raise exception.GroupNotFound(gid=gid)

        try:
            _validate(gid)

            context = req.environ['rack.context']

            keypairs = db.keypair_get_all(context, gid)
            if keypairs:
                raise exception.GroupInUse(gid=gid)

            securitygroups = db.securitygroup_get_all(context, gid)
            if securitygroups:
                raise exception.GroupInUse(gid=gid)

            networks = db.network_get_all(context, gid)
            if networks:
                raise exception.GroupInUse(gid=gid)

            processes = db.process_get_all(context, gid)
            if processes:
                raise exception.GroupInUse(gid=gid)

            db.group_delete(context, gid)

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

        except exception.GroupInUse as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())

        except Exception as e:
            LOG.warn(e)
            raise exception.GroupDeleteFailed()