NSX|P: Create/delete tier1 locale-service upon router create/delete

The NSX backend needs each logical router to have a locale-service
entry, which should also be deleted before the router is deleted.

Change-Id: If64c1b67c19906105b07c6facedf5d07ac36176d
This commit is contained in:
Adit Sarfaty 2019-05-15 10:45:44 +03:00
parent db82bd3c14
commit 5b591457c0
2 changed files with 5 additions and 1 deletions

View File

@ -174,7 +174,7 @@ class NSXClient(object):
# remove all nat rules from this router before deletion
self.cleanup_tier1_nat_rules(rtr['id'])
try:
self.nsxpolicy.tier1.remove_edge_cluster(rtr['id'])
self.nsxpolicy.tier1.delete_locale_service(rtr['id'])
except exceptions.ManagerError as e:
# Not always exists
pass

View File

@ -1643,6 +1643,9 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
router_name, router['id'],
tier0=None,
tags=tags)
# Also create the empty locale-service as it must always exist
self.nsxpolicy.tier1.create_locale_service(router['id'])
#TODO(annak): narrow down the exception
except Exception as ex:
with excutils.save_and_reraise_exception():
@ -1675,6 +1678,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
context, router_id)
try:
self.nsxpolicy.tier1.delete_locale_service(router_id)
self.nsxpolicy.tier1.delete(router_id)
except nsx_lib_exc.ResourceNotFound:
# If the resource was not found on the backend do not worry about