NSX|P: Fix devstack cleanup for fwaas

Change-Id: Ibe21d84729785294611199a6fe900b86e8896391
This commit is contained in:
asarfaty 2021-03-08 13:03:08 +02:00 committed by Adit Sarfaty
parent 4b8432677d
commit b0946a2ac2
2 changed files with 14 additions and 3 deletions

View File

@ -517,14 +517,22 @@ class NSXClient(object):
tags_to_search,
self.nsxpolicy.group.entry_def.resource_type())['results']
for group in groups:
self.nsxpolicy.group.delete(policy_constants.DEFAULT_DOMAIN,
group['id'])
try:
self.nsxpolicy.group.delete(
policy_constants.DEFAULT_DOMAIN, group['id'])
except exceptions.ResourceInUse:
# This may happen if the rule is used in multiple gateways
pass
services = self.nsxpolicy.search_by_tags(
tags_to_search,
self.nsxpolicy.service.parent_entry_def.resource_type())
for srv in services['results']:
self.nsxpolicy.service.delete(srv['id'])
try:
self.nsxpolicy.service.delete(srv['id'])
except exceptions.ResourceInUse:
# This may happen if the rule is used in multiple gateways
pass
def get_os_qos_policies(self):
policies = self.get_os_resources(self.nsxpolicy.qos_profile.list())

View File

@ -452,6 +452,9 @@ class NsxpFwaasCallbacksV2(com_callbacks.NsxCommonv3FwaasCallbacksV2):
self.cleanup_router_fw_resources(router_id)
def cleanup_router_fw_resources(self, router_id):
# TODO(asarfaty): In case multiple routers are using the same rule,
# the group and service will hold on one of the router ids. so this
# delete may fail or not get called.
tags_to_search = [{'scope': ROUTER_FW_TAG, 'tag': router_id}]
# Delete per rule & per network groups
groups = self.nsxpolicy.search_by_tags(