Fix the check for allowed_cidrs in listeners

The allowed_cidrs value could be an empty list if the
request involves the sdk, so change the check to
account for that.

Change-Id: I2df7e5a944cbd40c60943ad105f6e09f7afa85a9
Closes-bug: #1896603
This commit is contained in:
Brian Haley 2020-09-22 08:34:29 -04:00 committed by Brian Haley
parent 481f0b3b3c
commit 76b20882aa
1 changed files with 13 additions and 12 deletions

View File

@ -58,6 +58,16 @@ class OvnProviderDriver(driver_base.ProviderDriver):
user_fault_string=msg,
operator_fault_string=msg)
def _check_for_allowed_cidrs(self, allowed_cidrs):
# TODO(haleyb): add support for this
if isinstance(allowed_cidrs, o_datamodels.UnsetType):
allowed_cidrs = []
if allowed_cidrs:
msg = _('OVN provider does not support allowed_cidrs option')
raise driver_exceptions.UnsupportedOptionError(
user_fault_string=msg,
operator_fault_string=msg)
def loadbalancer_create(self, loadbalancer):
admin_state_up = loadbalancer.admin_state_up
if isinstance(admin_state_up, o_datamodels.UnsetType):
@ -138,12 +148,8 @@ class OvnProviderDriver(driver_base.ProviderDriver):
def listener_create(self, listener):
self._check_for_supported_protocols(listener.protocol)
# TODO(haleyb): add support for this
if not isinstance(listener.allowed_cidrs, o_datamodels.UnsetType):
msg = _('OVN provider does not support allowed_cidrs option')
raise driver_exceptions.UnsupportedOptionError(
user_fault_string=msg,
operator_fault_string=msg)
self._check_for_allowed_cidrs(listener.allowed_cidrs)
admin_state_up = listener.admin_state_up
if isinstance(admin_state_up, o_datamodels.UnsetType):
admin_state_up = True
@ -167,12 +173,7 @@ class OvnProviderDriver(driver_base.ProviderDriver):
self._ovn_helper.add_request(request)
def listener_update(self, old_listener, new_listener):
# TODO(haleyb): add support for this
if not isinstance(new_listener.allowed_cidrs, o_datamodels.UnsetType):
msg = _('OVN provider does not support allowed_cidrs option')
raise driver_exceptions.UnsupportedOptionError(
user_fault_string=msg,
operator_fault_string=msg)
self._check_for_allowed_cidrs(new_listener.allowed_cidrs)
request_info = {'id': new_listener.listener_id,
'loadbalancer_id': old_listener.loadbalancer_id,