From: Darragh O'Reilly Date: Thu, 8 Jan 2015 11:33:09 +0000 (+0000) Subject: Remove redundant tunnel ids from ovs agent X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5e8a592b5700750fa91a7a6b17c30ff7d6038e09;p=openstack-build%2Fneutron-build.git Remove redundant tunnel ids from ovs agent tunnel ids were specific to the OVS plugin which was removed in Juno. Change-Id: I369203a23ad4af1d307166aae84aee817572370b --- diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 4fd77e37e..18c5f3ea1 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -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'], diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index 8cc66c44b..ca9d5bb1d 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -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( diff --git a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py index ee020d8cb..bd7180593 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py @@ -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):