From 1e165b002abd40279cf8f3d0e745777545eb4e6b Mon Sep 17 00:00:00 2001
From: Adit Sarfaty <asarfaty@vmware.com>
Date: Tue, 6 Mar 2018 12:47:42 +0200
Subject: [PATCH] NSX-V3: Add router overlay TZ with GW

When setting the gateway of a logical router, we should set the
overlay transport-zone-id as well, to allow vlan switches traffic

Depends-on: I3a447202785b7b6ac320ddbb6a3f2cdeac1f78aa
Change-Id: If94474f907938e2997951f1a4e8269de45063ec5
---
 vmware_nsx/plugins/nsx_v3/plugin.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py
index 8e6b4d9d0b..f156752a77 100644
--- a/vmware_nsx/plugins/nsx_v3/plugin.py
+++ b/vmware_nsx/plugins/nsx_v3/plugin.py
@@ -3319,11 +3319,25 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
         if remove_router_link_port:
             self.nsxlib.router.remove_router_link_port(
                 nsx_router_id, org_tier0_uuid)
+            self.nsxlib.router.update_router_edge_cluster(
+                nsx_router_id, None)
+            if self.nsxlib.feature_supported(
+                nsxlib_consts.FEATURE_ROUTER_TRANSPORT_ZONE):
+                self.nsxlib.router.update_router_transport_zone(
+                    nsx_router_id, None)
         if add_router_link_port:
             # First update edge cluster info for router
             edge_cluster_uuid = self._get_edge_cluster(new_tier0_uuid)
             self.nsxlib.router.update_router_edge_cluster(
                 nsx_router_id, edge_cluster_uuid)
+            # Add the overlay transport zone to the router config
+            if self.nsxlib.feature_supported(
+                nsxlib_consts.FEATURE_ROUTER_TRANSPORT_ZONE):
+                tz_uuid = self.nsxlib.router.get_tier0_router_overlay_tz(
+                    new_tier0_uuid)
+                if tz_uuid:
+                    self.nsxlib.router.update_router_transport_zone(
+                        nsx_router_id, tz_uuid)
             tags = self.nsxlib.build_v3_tags_payload(
                    router, resource_type='os-neutron-rport',
                    project_name=context.tenant_name)