]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove extra network scheduling from vmware nsx plugin
authorarmando-migliaccio <armamig@gmail.com>
Mon, 27 Jan 2014 20:40:15 +0000 (12:40 -0800)
committerarmando-migliaccio <armamig@gmail.com>
Mon, 27 Jan 2014 20:47:38 +0000 (12:47 -0800)
Closes-bug: 1212555

Change-Id: I24dd51df4e3a966b66054fa55e70f6aa1e61da11

neutron/plugins/nicira/dhcp_meta/rpc.py
neutron/tests/unit/nicira/test_agent_scheduler.py

index bfb5181e35554156014d8e832e29191b724214a9..a19fd5f925259df7e9376956e397aa4c3a8ec6b2 100644 (file)
@@ -58,19 +58,10 @@ class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
 
 
 def handle_network_dhcp_access(plugin, context, network, action):
-    # TODO(armando-migliaccio): revise the implementation of this
-    # method in the context bug #1212555; a potential fix might be
-    # as simple as a 'pass', but keeping the hook might be useful
-    # in other agent modes.
-    if action == 'create_network':
-        plugin.schedule_network(context, network)
+    pass
 
 
 def handle_port_dhcp_access(plugin, context, port_data, action):
-    if action == 'create_port':
-        net = plugin.get_network(context, port_data['network_id'])
-        plugin.schedule_network(context, net)
-
     active_port = (cfg.CONF.NSX.metadata_mode == config.MetadataModes.INDIRECT
                    and port_data.get('device_owner') == const.DEVICE_OWNER_DHCP
                    and port_data.get('fixed_ips', []))
@@ -92,6 +83,8 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
             # route. This is done via the enable_isolated_metadata
             # option if desired.
             if not subnet.get('gateway_ip'):
+                LOG.info(_('Subnet %s does not have a gateway, the metadata '
+                           'route will not be created'), subnet['id'])
                 return
             metadata_routes = [r for r in subnet.routes
                                if r['destination'] == METADATA_DHCP_ROUTE]
index 2d8d7e847669e981069f5993614893c01b05bbf9..8442dfd5d9e97d4435b88aa749d8c71949cd7abf 100644 (file)
@@ -21,6 +21,7 @@ from oslo.config import cfg
 from neutron.common import constants
 from neutron.common.test_lib import test_config
 from neutron.plugins.nicira.common import sync
+from neutron.plugins.nicira.dhcp_meta import rpc
 from neutron.tests.unit.nicira import fake_nvpapiclient
 from neutron.tests.unit.nicira import get_fake_conf
 from neutron.tests.unit.nicira import NVPAPI_NAME
@@ -55,44 +56,15 @@ class NVPDhcpAgentNotifierTestCase(test_base.OvsDhcpAgentNotifierTestCase):
         self.addCleanup(self.mock_nvpapi.stop)
         self.addCleanup(cfg.CONF.reset)
 
-    def _notification_mocks(self, hosts, mock_dhcp, net, subnet, port):
-        host_calls = {}
-        for host in hosts:
-            expected_calls = [
-                mock.call(
-                    mock.ANY,
-                    self.dhcp_notifier.make_msg(
-                        'network_create_end',
-                        payload={'network': net['network']}),
-                    topic='dhcp_agent.' + host),
-                mock.call(
-                    mock.ANY,
-                    self.dhcp_notifier.make_msg(
-                        'subnet_create_end',
-                        payload={'subnet': subnet['subnet']}),
-                    topic='dhcp_agent.' + host),
-                mock.call(
-                    mock.ANY,
-                    self.dhcp_notifier.make_msg(
-                        'port_create_end',
-                        payload={'port': port['port']}),
-                    topic='dhcp_agent.' + host)]
-            host_calls[host] = expected_calls
-        return host_calls
-
     def _test_gateway_subnet_notification(self, gateway='10.0.0.1'):
         cfg.CONF.set_override('metadata_mode', 'dhcp_host_route', 'NSX')
         hosts = ['hosta']
-        [mock_dhcp, net, subnet, port] = self._network_port_create(
-            hosts, gateway=gateway, owner=constants.DEVICE_OWNER_DHCP)
-        found = False
-        for call, topic in mock_dhcp.call_args_list:
-            method = call[1]['method']
-            if method == 'subnet_update_end':
-                found = True
-                break
-        self.assertTrue(found)
-        self.assertEqual(subnet['subnet']['gateway_ip'], gateway)
+        with mock.patch.object(rpc.LOG, 'info') as mock_log:
+            [mock_dhcp, net, subnet, port] = self._network_port_create(
+                hosts, gateway=gateway, owner=constants.DEVICE_OWNER_DHCP)
+            self.assertEqual(subnet['subnet']['gateway_ip'], gateway)
+            called = 1 if gateway is None else 0
+            self.assertEqual(called, mock_log.call_count)
 
     def test_gatewayless_subnet_notification(self):
         self._test_gateway_subnet_notification(gateway=None)