Skip to content

Commit

Permalink
Handle PermissionDenied exception for lb resources
Browse files Browse the repository at this point in the history
This patch catches cfgm_common.PermissionDenied exception
and returns BadRequest if the lb resource creation fails
because of quota limit.

This patch also adds other missing lbaas resources for quota
check in the quota driver.

Change-Id: I4436c7ca1ce899c8892c4fa26dd1f957247631ea
Partial-bug: #1418402
  • Loading branch information
numansiddique committed Feb 5, 2015
1 parent 4b429e5 commit c1a2025
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Expand Up @@ -7,6 +7,8 @@
import uuid

from oslo.config import cfg
from cfgm_common import exceptions as vnc_exc
from neutron.common import exceptions as n_exc
from neutron.extensions import loadbalancer
from neutron.extensions.loadbalancer import LoadBalancerPluginBase
from vnc_api.vnc_api import VncApi
Expand Down Expand Up @@ -88,7 +90,10 @@ def get_vip(self, context, id, fields=None):
return self._vip_manager.get_resource(context, id, fields)

def create_vip(self, context, vip):
return self._vip_manager.create(context, vip)
try:
return self._vip_manager.create(context, vip)
except vnc_exc.PermissionDenied as ex:
raise n_exc.BadRequest(resource='vip', msg=str(ex))

def update_vip(self, context, id, vip):
return self._vip_manager.update(context, id, vip)
Expand All @@ -103,7 +108,10 @@ def get_pool(self, context, id, fields=None):
return self._pool_manager.get_resource(context, id, fields)

def create_pool(self, context, pool):
return self._pool_manager.create(context, pool)
try:
return self._pool_manager.create(context, pool)
except vnc_exc.PermissionDenied as ex:
raise n_exc.BadRequest(resource='pool', msg=str(ex))

def update_pool(self, context, id, pool):
return self._pool_manager.update(context, id, pool)
Expand Down Expand Up @@ -213,7 +221,10 @@ def get_member(self, context, id, fields=None):
return self._member_manager.get_resource(context, id, fields)

def create_member(self, context, member):
return self._member_manager.create(context, member)
try:
return self._member_manager.create(context, member)
except vnc_exc.PermissionDenied as ex:
raise n_exc.BadRequest(resource='member', msg=str(ex))

def update_member(self, context, id, member):
return self._member_manager.update(context, id, member)
Expand All @@ -228,7 +239,10 @@ def get_health_monitor(self, context, id, fields=None):
return self._monitor_manager.get_resource(context, id, fields)

def create_health_monitor(self, context, health_monitor):
return self._monitor_manager.create(context, health_monitor)
try:
return self._monitor_manager.create(context, health_monitor)
except vnc_exc.PermissionDenied as ex:
raise n_exc.BadRequest(resource='health_monitor', msg=str(ex))

def update_health_monitor(self, context, id, health_monitor):
return self._monitor_manager.update(context, id, health_monitor)
Expand Down
2 changes: 2 additions & 0 deletions neutron_plugin_contrail/plugins/opencontrail/quota/driver.py
Expand Up @@ -39,6 +39,8 @@ class QuotaDriver(object):
'port': 'virtual_machine_interface',
'pool': 'loadbalancer_pool',
'vip': 'virtual_ip',
'member': 'loadbalancer_member',
'health_monitor': 'loadbalancer_healthmonitor'
};

@classmethod
Expand Down

0 comments on commit c1a2025

Please sign in to comment.