示例#1
0
 def show(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.sqlalchemy.api.authorize_quota_class_context(context, id)
         return self._format_quota_set(id,
                                       quota.get_class_quotas(context, id))
     except exception.NotAuthorized:
         raise webob.exc.HTTPForbidden()
示例#2
0
 def show(self, req, id):
     context = req.environ['nova.context']
     authorize(context)
     try:
         db.sqlalchemy.api.authorize_quota_class_context(context, id)
         return self._format_quota_set(id,
                                       quota.get_class_quotas(context, id))
     except exception.NotAuthorized:
         raise webob.exc.HTTPForbidden()
示例#3
0
 def test_class_quotas(self):
     self._stub_class()
     result = quota.get_class_quotas(self.context, 'test_class')
     self.assertEqual(result, dict(
             instances=5,
             cores=10,
             ram=25 * 1024,
             volumes=5,
             gigabytes=500,
             floating_ips=5,
             metadata_items=64,
             injected_files=2,
             injected_file_content_bytes=5 * 1024,
             ))
示例#4
0
 def update(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     quota_class = id
     for key in body['quota_class_set'].keys():
         if key in quota.quota_resources:
             value = int(body['quota_class_set'][key])
             try:
                 db.quota_class_update(context, quota_class, key, value)
             except exception.QuotaClassNotFound:
                 db.quota_class_create(context, quota_class, key, value)
             except exception.AdminRequired:
                 raise webob.exc.HTTPForbidden()
     return {'quota_class_set': quota.get_class_quotas(context,
                                                       quota_class)}
示例#5
0
 def update(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     quota_class = id
     for key in body['quota_class_set'].keys():
         if key in quota.quota_resources:
             value = int(body['quota_class_set'][key])
             try:
                 db.quota_class_update(context, quota_class, key, value)
             except exception.QuotaClassNotFound:
                 db.quota_class_create(context, quota_class, key, value)
             except exception.AdminRequired:
                 raise webob.exc.HTTPForbidden()
     return {
         'quota_class_set': quota.get_class_quotas(context, quota_class)
     }
示例#6
0
 def test_class_quotas(self):
     self._stub_class()
     result = quota.get_class_quotas(self.context, 'test_class')
     self.assertEqual(
         result,
         dict(
             instances=5,
             cores=10,
             ram=25 * 1024,
             volumes=5,
             gigabytes=500,
             floating_ips=5,
             metadata_items=64,
             injected_files=2,
             injected_file_content_bytes=5 * 1024,
         ))
示例#7
0
 def test_class_quotas_noclass(self):
     self._stub_class()
     result = quota.get_class_quotas(self.context, 'noclass')
     self.assertEqual(result, dict(
             instances=10,
             cores=20,
             ram=50 * 1024,
             volumes=10,
             gigabytes=1000,
             floating_ips=10,
             security_groups=10,
             security_group_rules=20,
             key_pairs=10,
             metadata_items=128,
             injected_files=5,
             injected_file_content_bytes=10 * 1024,
             ))
示例#8
0
 def test_class_quotas_noclass(self):
     self._stub_class()
     result = quota.get_class_quotas(self.context, 'noclass')
     self.assertEqual(
         result,
         dict(
             instances=10,
             cores=20,
             ram=50 * 1024,
             volumes=10,
             gigabytes=1000,
             floating_ips=10,
             security_groups=10,
             security_group_rules=20,
             key_pairs=10,
             metadata_items=128,
             injected_files=5,
             injected_file_content_bytes=10 * 1024,
         ))