Skip to content

Commit

Permalink
get default quota from contrail
Browse files Browse the repository at this point in the history
Change-Id: I794800e7520b809ca0037ac57d2b6b07e4081ae2
Closes-Bug: #1787079
(cherry picked from commit 7348ed9)
  • Loading branch information
junbo42 authored and Shivayogi123 committed Nov 7, 2018
1 parent a6e5903 commit 7a60869
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions neutron_plugin_contrail/plugins/opencontrail/quota/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,23 @@ def commit_reservation(self, context, reservation_id):

def cancel_reservation(self, context, reservation_id):
"""Tnis is a noop as this driver does not support reservations."""

@classmethod
def get_default_quotas(cls, context, resources, tenant_id):
try:
default_project = cls._get_vnc_conn().project_read(
fq_name=['default-domain', 'default-project'])
default_quota = default_project.get_quota()
except vnc_exc.NoIdError:
default_quota = None

qn2c = cls.quota_neutron_to_contrail_type
quotas = {}
for resource in resources:
quota_res = None
if default_quota and resource in qn2c:
quota_res = getattr(default_quota, qn2c[resource], None)
if quota_res is None:
quota_res = default_quota.get_defaults()
quotas[resource] = quota_res
return quotas

0 comments on commit 7a60869

Please sign in to comment.