]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
NSX: ensure that no LSN is created on external networks
authorarmando-migliaccio <armamig@gmail.com>
Tue, 6 May 2014 21:00:26 +0000 (14:00 -0700)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 15:06:54 +0000 (23:06 +0800)
Logical Service Nodes (LSN) are those that provide dhcp
and metadata services to networks when the NSX plugin is
used without the openstack dhcp and metadata proxy
agents. External networks do not work with Neutron's
dhcp and metadata services, therefore there is no need
to provision a LSN in this case.

Added UT to avoid regression.

Closes-bug: #1316795

Change-Id: I3dab0c9cbecdd9296466c991d02d590d6bd5bd49
(cherry picked from commit af020da544ac4cf21b293d23710545ee5cdcdfa4)

neutron/plugins/vmware/dhcp_meta/nsx.py
neutron/tests/unit/vmware/test_dhcpmeta.py

index 6fbb350627a40aead16582faba7ddc73044051fa..5c1f3971afffb2c00651798fbc6874e9c1d3e403 100644 (file)
@@ -207,6 +207,9 @@ def handle_network_dhcp_access(plugin, context, network, action):
              % {"action": action, "resource": network})
     if action == 'create_network':
         network_id = network['id']
+        if network.get(external_net.EXTERNAL):
+            LOG.info(_("Network %s is external: no LSN to create"), network_id)
+            return
         plugin.lsn_manager.lsn_create(context, network_id)
     elif action == 'delete_network':
         # NOTE(armando-migliaccio): on delete_network, network
index 383833be71b8db9aa931c81f9bf0c1b719731576..a44da91647112ce9b8e7d1181da4670559b8b94b 100644 (file)
@@ -1152,6 +1152,12 @@ class DhcpTestCase(base.BaseTestCase):
         self.plugin.lsn_manager.lsn_create.assert_called_once_with(
             mock.ANY, network['id'])
 
+    def test_handle_create_network_router_external(self):
+        network = {'id': 'foo_network_id', 'router:external': True}
+        nsx.handle_network_dhcp_access(
+            self.plugin, mock.ANY, network, 'create_network')
+        self.assertFalse(self.plugin.lsn_manager.lsn_create.call_count)
+
     def test_handle_delete_network(self):
         network_id = 'foo_network_id'
         self.plugin.lsn_manager.lsn_delete_by_network.return_value = (