def test_quota_destroy_all_by_project(self): reservations = _quota_reserve(self.ctxt, "project1") db.quota_destroy_all_by_project(self.ctxt, "project1") self.assertEqual(db.quota_get_all_by_project(self.ctxt, "project1"), {"project_id": "project1"}) self.assertEqual(db.quota_usage_get_all_by_project(self.ctxt, "project1"), {"project_id": "project1"}) for r in reservations: self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, r)
def delete(self, req, id): context = req.environ['cinder.context'] authorize_delete(context) try: db.quota_destroy_all_by_project(context, id) except exception.AdminRequired: raise webob.exc.HTTPForbidden()
def destroy_all_by_project(self, context, project_id): """Destroy all that is associated with a project. This includes quotas, usages and reservations. :param context: The request context, for access checks. :param project_id: The ID of the project being deleted. """ db.quota_destroy_all_by_project(context, project_id)
def test_quota_destroy_all_by_project(self): reservations = _quota_reserve(self.ctxt, 'project1') db.quota_destroy_all_by_project(self.ctxt, 'project1') self.assertEqual(db.quota_get_all_by_project(self.ctxt, 'project1'), {'project_id': 'project1'}) self.assertEqual( db.quota_usage_get_all_by_project(self.ctxt, 'project1'), {'project_id': 'project1'}) for r in reservations: self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, r)
def test_quota_destroy_all_by_project(self): _quota_reserve(self.ctxt, "project1") db.quota_destroy_all_by_project(self.ctxt, "project1") self.assertEqual(db.quota_get_all_by_project(self.ctxt, "project1"), {"project_id": "project1"}) self.assertEqual(db.quota_usage_get_all_by_project(self.ctxt, "project1"), {"project_id": "project1"})