Remove extra network scheduling from vmware nsx plugin
Closes-bug: 1212555 Change-Id: I24dd51df4e3a966b66054fa55e70f6aa1e61da11
This commit is contained in:
parent
f0db2da946
commit
afb3013571
@ -58,19 +58,10 @@ class NVPRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
|
|||||||
|
|
||||||
|
|
||||||
def handle_network_dhcp_access(plugin, context, network, action):
|
def handle_network_dhcp_access(plugin, context, network, action):
|
||||||
# TODO(armando-migliaccio): revise the implementation of this
|
pass
|
||||||
# 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)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_port_dhcp_access(plugin, context, port_data, action):
|
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
|
active_port = (cfg.CONF.NSX.metadata_mode == config.MetadataModes.INDIRECT
|
||||||
and port_data.get('device_owner') == const.DEVICE_OWNER_DHCP
|
and port_data.get('device_owner') == const.DEVICE_OWNER_DHCP
|
||||||
and port_data.get('fixed_ips', []))
|
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
|
# route. This is done via the enable_isolated_metadata
|
||||||
# option if desired.
|
# option if desired.
|
||||||
if not subnet.get('gateway_ip'):
|
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
|
return
|
||||||
metadata_routes = [r for r in subnet.routes
|
metadata_routes = [r for r in subnet.routes
|
||||||
if r['destination'] == METADATA_DHCP_ROUTE]
|
if r['destination'] == METADATA_DHCP_ROUTE]
|
||||||
|
@ -21,6 +21,7 @@ from oslo.config import cfg
|
|||||||
from neutron.common import constants
|
from neutron.common import constants
|
||||||
from neutron.common.test_lib import test_config
|
from neutron.common.test_lib import test_config
|
||||||
from neutron.plugins.nicira.common import sync
|
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 fake_nvpapiclient
|
||||||
from neutron.tests.unit.nicira import get_fake_conf
|
from neutron.tests.unit.nicira import get_fake_conf
|
||||||
from neutron.tests.unit.nicira import NVPAPI_NAME
|
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(self.mock_nvpapi.stop)
|
||||||
self.addCleanup(cfg.CONF.reset)
|
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'):
|
def _test_gateway_subnet_notification(self, gateway='10.0.0.1'):
|
||||||
cfg.CONF.set_override('metadata_mode', 'dhcp_host_route', 'NSX')
|
cfg.CONF.set_override('metadata_mode', 'dhcp_host_route', 'NSX')
|
||||||
hosts = ['hosta']
|
hosts = ['hosta']
|
||||||
[mock_dhcp, net, subnet, port] = self._network_port_create(
|
with mock.patch.object(rpc.LOG, 'info') as mock_log:
|
||||||
hosts, gateway=gateway, owner=constants.DEVICE_OWNER_DHCP)
|
[mock_dhcp, net, subnet, port] = self._network_port_create(
|
||||||
found = False
|
hosts, gateway=gateway, owner=constants.DEVICE_OWNER_DHCP)
|
||||||
for call, topic in mock_dhcp.call_args_list:
|
self.assertEqual(subnet['subnet']['gateway_ip'], gateway)
|
||||||
method = call[1]['method']
|
called = 1 if gateway is None else 0
|
||||||
if method == 'subnet_update_end':
|
self.assertEqual(called, mock_log.call_count)
|
||||||
found = True
|
|
||||||
break
|
|
||||||
self.assertTrue(found)
|
|
||||||
self.assertEqual(subnet['subnet']['gateway_ip'], gateway)
|
|
||||||
|
|
||||||
def test_gatewayless_subnet_notification(self):
|
def test_gatewayless_subnet_notification(self):
|
||||||
self._test_gateway_subnet_notification(gateway=None)
|
self._test_gateway_subnet_notification(gateway=None)
|
||||||
|
Loading…
Reference in New Issue
Block a user