From: John Schwarz Date: Thu, 20 Aug 2015 14:05:02 +0000 (+0300) Subject: Only validate local_ip if using tunneling X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b6fd5b9613203819d24a452df982a76c5e7d1daf;p=openstack-build%2Fneutron-build.git Only validate local_ip if using tunneling Change I4b4527c28d0738890e33b343c9e17941e780bc24 introduced a new validation to make sure that local_ip holds a valid IP that is present in one of the interfaces on the machine. However, this test is not relevant if tunneling is not enabled, since the value is ignored anyway. This patch changes validate_local_ip to not check local_ip in case tunneling is not enabled (if no value was put in the 'tunnel_types' option). Change-Id: I07119341076573a4226b5ad998bdff09c021ae30 Closes-Bug: #1487053 Related-Bug: #1408603 --- diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 190c54b3a..800810002 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -1730,7 +1730,10 @@ def create_agent_config_map(config): def validate_local_ip(local_ip): - """Verify if the ip exists on the agent's host.""" + """If tunneling is enabled, verify if the ip exists on the agent's host.""" + if not cfg.CONF.AGENT.tunnel_types: + return + if not ip_lib.IPWrapper().get_device_by_ip(local_ip): LOG.error(_LE("Tunneling can't be enabled with invalid local_ip '%s'." " IP couldn't be found on this host's interfaces."), diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 72eb801e9..1965c5e5a 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -2205,13 +2205,20 @@ class TestOvsDvrNeutronAgentOFCtl(TestOvsDvrNeutronAgent, class TestValidateTunnelLocalIP(base.BaseTestCase): + def test_validate_local_ip_no_tunneling(self): + cfg.CONF.set_override('tunnel_types', [], group='AGENT') + # The test will pass simply if no exception is raised by the next call: + ovs_agent.validate_local_ip(FAKE_IP1) + def test_validate_local_ip_with_valid_ip(self): + cfg.CONF.set_override('tunnel_types', ['vxlan'], group='AGENT') mock_get_device_by_ip = mock.patch.object( ip_lib.IPWrapper, 'get_device_by_ip').start() ovs_agent.validate_local_ip(FAKE_IP1) mock_get_device_by_ip.assert_called_once_with(FAKE_IP1) def test_validate_local_ip_with_invalid_ip(self): + cfg.CONF.set_override('tunnel_types', ['vxlan'], group='AGENT') mock_get_device_by_ip = mock.patch.object( ip_lib.IPWrapper, 'get_device_by_ip').start() mock_get_device_by_ip.return_value = None