Merge "Remove extra network scheduling from vmware nsx plugin"
This commit is contained in:
commit
340daa129b
@ -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]
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user