コード例 #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
ファイル: limits.py プロジェクト: baz-reddwarf/nova
    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
ファイル: limits.py プロジェクト: tomchill/reddwarf
    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
ファイル: admin.py プロジェクト: gandelman-a/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}
コード例 #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
ファイル: test_quota.py プロジェクト: ajehang/nova
 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
ファイル: test_quota.py プロジェクト: ajehang/nova
 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
ファイル: test_quota.py プロジェクト: ajehang/nova
 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
ファイル: test_quota.py プロジェクト: andrewbogott/nova
 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
ファイル: admin.py プロジェクト: gandelman-a/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)}
コード例 #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))}