]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Only validate local_ip if using tunneling
authorJohn Schwarz <jschwarz@redhat.com>
Thu, 20 Aug 2015 14:05:02 +0000 (17:05 +0300)
committerJohn Schwarz <jschwarz@redhat.com>
Thu, 20 Aug 2015 15:09:53 +0000 (18:09 +0300)
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

neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py

index 190c54b3a7e4bd0c39ae33e2b9df764dad35c8af..80081000232645d26c4108df9eeae27c4bc625de 100644 (file)
@@ -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."),
index 72eb801e96aa4cde367dd3f23525ed53fde08d8d..1965c5e5a4e0c6f0b4a5ba597ecbd7f03125a266 100644 (file)
@@ -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