NSX|P: Update tier1 GW and route adv together

When a GW is added or removed, the backend call to update the tier1
connectivity path should be combined with the one to update the
route advertisement.
This will be more efficient, as well as work around a backend issue.

Change-Id: Id90f7ef7ccdef0230c9181f01da3ad056508c6b0
This commit is contained in:
Adit Sarfaty 2019-05-27 08:10:03 +03:00
parent e702f7116e
commit bfb43d2e08

View File

@ -1554,9 +1554,12 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
if (actions['remove_router_link_port'] or
actions['add_router_link_port']):
# GW was changed
self.nsxpolicy.tier1.update(router_id,
tier0=new_tier0_uuid)
# GW was changed. update GW and route advertisement
self.nsxpolicy.tier1.update_route_advertisement(
router_id,
nat=actions['advertise_route_nat_flag'],
subnets=actions['advertise_route_connected_flag'],
tier0=new_tier0_uuid)
# Set/Unset the router TZ to allow vlan switches traffic
if cfg.CONF.nsx_p.allow_passthrough:
@ -1570,6 +1573,12 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
else:
LOG.debug("Not adding transport-zone to tier1 router %s as "
"passthrough api is disabled", router_id)
else:
# Only update route advertisement
self.nsxpolicy.tier1.update_route_advertisement(
router_id,
nat=actions['advertise_route_nat_flag'],
subnets=actions['advertise_route_connected_flag'])
if actions['add_snat_rules']:
# Add SNAT rules for all the subnets which are in different scope
@ -1584,11 +1593,6 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
for subnet in router_subnets:
self._add_subnet_no_dnat_rule(context, router_id, subnet)
self.nsxpolicy.tier1.update_route_advertisement(
router_id,
nat=actions['advertise_route_nat_flag'],
subnets=actions['advertise_route_connected_flag'])
# always advertise ipv6 subnets if gateway is set
advertise_ipv6_subnets = True if info else False
self._update_router_advertisement_rules(router_id,