From 7c3f1e63dfd06e7dbda37b7edd8659801e04a901 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Thu, 22 Mar 2018 07:06:35 +0200 Subject: [PATCH] NSX|V3: fix ENS VLAN attach to router When the default TZ is a ENS VLAN TZ then we identify this this is not a regular overlay network. It is a VLAN network. There was a missing check for regular networks that were not provider networks. Change-Id: I9e4241fd2e1047ba14442babc4677efa4dcab3a5 --- vmware_nsx/plugins/nsx_v3/plugin.py | 10 ++++++++++ vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index e55346fe54..9b225881d8 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -1037,6 +1037,16 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, bindings = nsx_db.get_network_bindings(context.session, network_id) # With NSX plugin, "normal" overlay networks will have no binding if not bindings: + # check the backend network + # TODO(asarfaty): Keep TZ type in DB to avoid going to the backend + az = self.get_network_az_by_net_id(context, network_id) + ls = self.nsxlib.logical_switch.get(az._default_overlay_tz_uuid) + tz = ls.get('transport_zone_id') + if tz: + backend_type = self.nsxlib.transport_zone.get_transport_type( + tz) + return (backend_type == + self.nsxlib.transport_zone.TRANSPORT_TYPE_OVERLAY) return True binding = bindings[0] if binding.binding_type == utils.NsxV3NetworkTypes.GENEVE: diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index fe85a5d1a9..2c72d65433 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -169,6 +169,8 @@ def _mock_nsx_backend_calls(): mock.patch( "vmware_nsxlib.v3.load_balancer.Service.get_router_lb_service", return_value=None).start() + mock.patch('vmware_nsxlib.v3.core_resources.NsxLibTransportZone.' + 'get_transport_type', return_value='OVERLAY').start() class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,