Skip to content

Commit

Permalink
Merge pull request F5Networks#910 from ssorenso/newton.l7policy_valid…
Browse files Browse the repository at this point in the history
…ation_for_bug.895

Fixes purge orphaned l7policy_objects
  • Loading branch information
jlongstaf authored Jan 29, 2018
2 parents 7c2fca1 + 9f136bf commit 6c8b6b3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions f5lbaasdriver/v2/bigip/plugin_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,46 @@ def validate_listeners_state(self, context, listeners, host=None):
e.message)
listener_status[listener_id] = 'Unknown'
return listener_status

# validate a list of l7policys id - assure they are not deleted
@log_helpers.log_method_call
def validate_l7policys_state_by_listener(self, context, listeners):
"""Performs a validation against l7policies with a list of listeners
This method will attempt to check the Neutron DB for a list of
l7policies that reference the given list of listener_id's.
This will return a dict of:
{listener_id_0: bool,
...
}
The bool will indicate that true: there are l7policies here, false:
there are none on this listener.
"""
has_l7policy = {}
try:
# NOTE: neutron_lbaas has a deprecated code filter for queries
# that appears to silence filter queries for 'listener_id'
l7policy_db = self.driver.plugin.db.get_l7policies(context)
except Exception as error:
LOG.exception("Exception: plugin.db.get_l7policies({}): "
"({})".format(listeners, error))
return {}
LOG.debug("({}) = get_l7policies({})".format(l7policy_db, context))
for listener_id in listeners:
# Given filter limitations, double-loop iterator results
result = False
if l7policy_db:
if isinstance(l7policy_db, list):
for l7policy in l7policy_db:
if l7policy.listener_id == listener_id:
result = True
break
else:
if l7policy_db.listener_id == listener_id:
result = True
else:
result = False
has_l7policy[listener_id] = result
LOG.debug("has_l7policy: ({})".format(has_l7policy))
return has_l7policy

0 comments on commit 6c8b6b3

Please sign in to comment.