示例#1
0
文件: quotas.py 项目: nicopal/nova
 def show(self, req, id):
     context = req.environ["nova.context"]
     try:
         db.sqlalchemy.api.authorize_project_context(context, id)
         return self._format_quota_set(id, quota.get_project_quotas(context, id))
     except exception.NotAuthorized:
         return webob.Response(status_int=403)
示例#2
0
 def show(self, req, id):
     context = req.environ['nova.context']
     project_id = id
     return {
         'quota_set':
         self._format_quota_set(id, quota.get_project_quotas(context, id))
     }
示例#3
0
 def show(self, req, id):
     context = req.environ['nova.context']
     try:
         db.sqlalchemy.api.authorize_project_context(context, id)
         return self._format_quota_set(
             id, quota.get_project_quotas(context, id))
     except exception.NotAuthorized:
         return webob.Response(status_int=403)
示例#4
0
文件: quotas.py 项目: Razique/nova
 def show(self, req, id):
     context = req.environ['nova.context']
     try:
         db.sqlalchemy.api.authorize_project_context(context, id)
         return self._format_quota_set(id,
                                     quota.get_project_quotas(context, id))
     except exception.NotAuthorized:
         raise webob.exc.HTTPForbidden()
示例#5
0
    def index(self, req):
        """
        Return all global and rate limit information.
        """
        context = req.environ['nova.context']
        abs_limits = quota.get_project_quotas(context, context.project_id)
        rate_limits = req.environ.get("nova.limits", [])

        builder = self._get_view_builder(req)
        return builder.build(rate_limits, abs_limits)
示例#6
0
    def index(self, req):
        """
        Return all global and rate limit information.
        """
        context = req.environ['nova.context']
        abs_limits = quota.get_project_quotas(context, context.project_id)
        rate_limits = req.environ.get("nova.limits", [])

        builder = self._get_view_builder(req)
        return builder.build(rate_limits, abs_limits)
示例#7
0
    def index(self, req):
        if urlparse.parse_qs(req.environ["QUERY_STRING"]).get("defaults", False):
            return {"quota_set_list": [self._format_quota_set("__defaults__", quota._get_default_quotas())]}
        else:
            context = req.environ["nova.context"]
            user = req.environ.get("user")
            projects = auth_manager.AuthManager().get_projects(user=user)

            quota_set_list = [
                self._format_quota_set(project.name, quota.get_project_quotas(context, project.name))
                for project in projects
            ]
            return {"quota_set_list": quota_set_list}
示例#8
0
文件: quotas.py 项目: Razique/nova
 def update(self, req, id, body):
     context = req.environ['nova.context']
     project_id = id
     for key in body['quota_set'].keys():
         if key in quota_resources:
             value = int(body['quota_set'][key])
             try:
                 db.quota_update(context, project_id, key, value)
             except exception.ProjectQuotaNotFound:
                 db.quota_create(context, project_id, key, value)
             except exception.AdminRequired:
                 raise webob.exc.HTTPForbidden()
     return {'quota_set': quota.get_project_quotas(context, project_id)}
示例#9
0
文件: admin.py 项目: mgius/openstackx
    def index(self, req):
        if urlparse.parse_qs(req.environ['QUERY_STRING']).get('defaults', False):
            return {'quota_set_list': [self._format_quota_set('__defaults__',
                quota._get_default_quotas())]}
        else:
            context = req.environ['nova.context']
            user = req.environ.get('user')
            projects = auth_manager.AuthManager().get_projects(user=user)

            quota_set_list = [self._format_quota_set(project.name,
                              quota.get_project_quotas(context, project.name))
                              for project in projects]
            return {'quota_set_list': quota_set_list}
示例#10
0
    def index(self, req):
        if urlparse.parse_qs(req.environ['QUERY_STRING']).get('defaults', False):
            return {'quota_set_list': [self._format_quota_set('__defaults__',
                quota._get_default_quotas())]}
        else:
            context = req.environ['nova.context']
            user = req.environ.get('user')
            projects = auth_manager.AuthManager().get_projects(user=user)

            quota_set_list = [self._format_quota_set(project.name,
                              quota.get_project_quotas(context, project.name))
                              for project in projects]
            return {'quota_set_list': quota_set_list}
示例#11
0
文件: admin.py 项目: mgius/openstackx
    def update(self, req, id, body):
        context = req.environ['nova.context']
        project_id = id
        resources = ['metadata_items', 'injected_file_content_bytes',
                'volumes', 'gigabytes', 'ram', 'floating_ips', 'instances',
                'injected_files', 'cores']

        for key in body['quota_set'].keys():
            if key in resources:
                value = int(body['quota_set'][key])
                try:
                    db.quota_update(context, project_id, key, value)
                except exception.ProjectQuotaNotFound:
                    db.quota_create(context, project_id, key, value)
        return {'quota_set': quota.get_project_quotas(context, project_id)}
示例#12
0
    def update(self, req, id, body):
        context = req.environ['nova.context']
        project_id = id
        resources = ['metadata_items', 'injected_file_content_bytes',
                'volumes', 'gigabytes', 'ram', 'floating_ips', 'instances',
                'injected_files', 'cores']

        for key in body['quota_set'].keys():
            if key in resources:
                value = int(body['quota_set'][key])
                try:
                    db.quota_update(context, project_id, key, value)
                except exception.ProjectQuotaNotFound:
                    db.quota_create(context, project_id, key, value)
        return {'quota_set': quota.get_project_quotas(context, project_id)}
示例#13
0
 def test_project_quotas_overrides_noclass(self):
     self._stub_class()
     self._stub_project(True)
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(result, dict(
             instances=2,
             cores=5,
             ram=12 * 1024,
             volumes=2,
             gigabytes=250,
             floating_ips=2,
             metadata_items=32,
             injected_files=1,
             injected_file_content_bytes=2 * 1024,
             ))
示例#14
0
 def test_project_quotas_defaults_noclass(self):
     self._stub_class()
     self._stub_project()
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(result, dict(
             instances=10,
             cores=20,
             ram=50 * 1024,
             volumes=10,
             gigabytes=1000,
             floating_ips=10,
             metadata_items=128,
             injected_files=5,
             injected_file_content_bytes=10 * 1024,
             ))
示例#15
0
 def test_project_quotas_defaults_withclass(self):
     self._stub_class()
     self._stub_project()
     self.context.quota_class = 'test_class'
     result = quota.get_project_quotas(self.context, 'admin')
     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,
             ))
示例#16
0
 def test_project_quotas_overrides_noclass(self):
     self._stub_class()
     self._stub_project(True)
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(
         result,
         dict(
             instances=2,
             cores=5,
             ram=12 * 1024,
             volumes=2,
             gigabytes=250,
             floating_ips=2,
             metadata_items=32,
             injected_files=1,
             injected_file_content_bytes=2 * 1024,
         ))
示例#17
0
 def test_project_quotas_defaults_noclass(self):
     self._stub_class()
     self._stub_project()
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(
         result,
         dict(
             instances=10,
             cores=20,
             ram=50 * 1024,
             volumes=10,
             gigabytes=1000,
             floating_ips=10,
             metadata_items=128,
             injected_files=5,
             injected_file_content_bytes=10 * 1024,
         ))
示例#18
0
 def test_project_quotas_defaults_withclass(self):
     self._stub_class()
     self._stub_project()
     self.context.quota_class = 'test_class'
     result = quota.get_project_quotas(self.context, 'admin')
     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,
         ))
示例#19
0
 def test_project_quotas_overrides_withclass(self):
     self._stub_class()
     self._stub_project(True)
     self.context.quota_class = 'test_class'
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(result, dict(
             instances=2,
             cores=5,
             ram=12 * 1024,
             volumes=2,
             gigabytes=250,
             floating_ips=2,
             security_groups=5,
             security_group_rules=10,
             key_pairs=5,
             metadata_items=32,
             injected_files=1,
             injected_file_content_bytes=2 * 1024,
             ))
示例#20
0
 def test_project_quotas_overrides_withclass(self):
     self._stub_class()
     self._stub_project(True)
     self.context.quota_class = 'test_class'
     result = quota.get_project_quotas(self.context, 'admin')
     self.assertEqual(
         result,
         dict(
             instances=2,
             cores=5,
             ram=12 * 1024,
             volumes=2,
             gigabytes=250,
             floating_ips=2,
             security_groups=5,
             security_group_rules=10,
             key_pairs=5,
             metadata_items=32,
             injected_files=1,
             injected_file_content_bytes=2 * 1024,
         ))
示例#21
0
    def update(self, req, id, body):
        context = req.environ["nova.context"]
        project_id = id
        resources = [
            "metadata_items",
            "injected_file_content_bytes",
            "volumes",
            "gigabytes",
            "ram",
            "floating_ips",
            "instances",
            "injected_files",
            "cores",
        ]

        for key in body["quota_set"].keys():
            if key in resources:
                value = int(body["quota_set"][key])
                try:
                    db.quota_update(context, project_id, key, value)
                except exception.ProjectQuotaNotFound:
                    db.quota_create(context, project_id, key, value)
        return {"quota_set": quota.get_project_quotas(context, project_id)}
示例#22
0
文件: admin.py 项目: mgius/openstackx
 def show(self, req, id):
     context = req.environ['nova.context']
     project_id = id
     return {'quota_set': self._format_quota_set(id,
             quota.get_project_quotas(context, id))}