]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove redundant tunnel ids from ovs agent
authorDarragh O'Reilly <darragh.oreilly@hp.com>
Thu, 8 Jan 2015 11:33:09 +0000 (11:33 +0000)
committerDarragh O'Reilly <darragh.oreilly@hp.com>
Thu, 8 Jan 2015 11:36:18 +0000 (11:36 +0000)
tunnel ids were specific to the OVS plugin which was removed in Juno.

Change-Id: I369203a23ad4af1d307166aae84aee817572370b

neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_tunnel.py

index 4fd77e37ea971be4bd10f7a73377a1db86215763..18c5f3ea1e0fbcbfc0203468138dffb15a350211 100644 (file)
@@ -332,8 +332,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         if not self.enable_tunneling:
             return
         tunnel_ip = kwargs.get('tunnel_ip')
-        tunnel_id = kwargs.get('tunnel_id', self.get_ip_in_hex(tunnel_ip))
-        if not tunnel_id:
+        tunnel_ip_hex = self.get_ip_in_hex(tunnel_ip)
+        if not tunnel_ip_hex:
             return
         tunnel_type = kwargs.get('tunnel_type')
         if not tunnel_type:
@@ -345,7 +345,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
             return
         if tunnel_ip == self.local_ip:
             return
-        tun_name = '%s-%s' % (tunnel_type, tunnel_id)
+        tun_name = '%s-%s' % (tunnel_type, tunnel_ip_hex)
         if not self.l2_pop:
             self._setup_tunnel_port(self.tun_br, tun_name, tunnel_ip,
                                     tunnel_type)
@@ -1310,16 +1310,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                     tunnels = details['tunnels']
                     for tunnel in tunnels:
                         if self.local_ip != tunnel['ip_address']:
-                            tunnel_id = tunnel.get('id')
-                            # Unlike the OVS plugin, ML2 doesn't return an id
-                            # key. So use ip_address to form port name instead.
-                            # Port name must be <=15 chars, so use shorter hex.
                             remote_ip = tunnel['ip_address']
                             remote_ip_hex = self.get_ip_in_hex(remote_ip)
-                            if not tunnel_id and not remote_ip_hex:
+                            if not remote_ip_hex:
                                 continue
-                            tun_name = '%s-%s' % (tunnel_type,
-                                                  tunnel_id or remote_ip_hex)
+                            tun_name = '%s-%s' % (tunnel_type, remote_ip_hex)
                             self._setup_tunnel_port(self.tun_br,
                                                     tun_name,
                                                     tunnel['ip_address'],
index 8cc66c44bbbca5d0526e02f92751f329a9d88038..ca9d5bb1de868410ee135d97036dd3b448e5c612 100644 (file)
@@ -1349,20 +1349,6 @@ class TestOvsNeutronAgent(base.BaseTestCase):
                 {'type': p_const.TYPE_GRE, 'ip': 'remote_ip'})
             self.assertEqual(ofport, 0)
 
-    def test_tunnel_sync_with_ovs_plugin(self):
-        fake_tunnel_details = {'tunnels': [{'id': '42',
-                                            'ip_address': '100.101.102.103'}]}
-        with contextlib.nested(
-            mock.patch.object(self.agent.plugin_rpc, 'tunnel_sync',
-                              return_value=fake_tunnel_details),
-            mock.patch.object(self.agent, '_setup_tunnel_port')
-        ) as (tunnel_sync_rpc_fn, _setup_tunnel_port_fn):
-            self.agent.tunnel_types = ['gre']
-            self.agent.tunnel_sync()
-            expected_calls = [mock.call(self.agent.tun_br, 'gre-42',
-                                        '100.101.102.103', 'gre')]
-            _setup_tunnel_port_fn.assert_has_calls(expected_calls)
-
     def test_tunnel_sync_with_ml2_plugin(self):
         fake_tunnel_details = {'tunnels': [{'ip_address': '100.101.31.15'}]}
         with contextlib.nested(
index ee020d8cbafc964f1f051b042d4636e0ba4bb13a..bd7180593be23dfadf25cbdcc3243de26d3c1eca 100644 (file)
@@ -481,7 +481,7 @@ class TunnelTest(base.BaseTestCase):
         tunnel_port = '9999'
         self.mock_tun_bridge.add_tunnel_port.return_value = tunnel_port
         self.mock_tun_bridge_expected += [
-            mock.call.add_tunnel_port('gre-1', '10.0.10.1', '10.0.0.1',
+            mock.call.add_tunnel_port('gre-0a000a01', '10.0.10.1', '10.0.0.1',
                                       'gre', 4789, True),
             mock.call.add_flow(priority=1, in_port=tunnel_port,
                                actions='resubmit(,3)')
@@ -489,14 +489,14 @@ class TunnelTest(base.BaseTestCase):
 
         a = self._build_agent()
         a.tunnel_update(
-            mock.sentinel.ctx, tunnel_id='1', tunnel_ip='10.0.10.1',
+            mock.sentinel.ctx, tunnel_ip='10.0.10.1',
             tunnel_type=p_const.TYPE_GRE)
         self._verify_mock_calls()
 
     def test_tunnel_update_self(self):
         a = self._build_agent()
         a.tunnel_update(
-            mock.sentinel.ctx, tunnel_id='1', tunnel_ip='10.0.0.1')
+            mock.sentinel.ctx, tunnel_ip='10.0.0.1')
         self._verify_mock_calls()
 
     def test_daemon_loop(self):