From 744c1bd2f1ae1caf3cd6d0c07d61b034a21204bc Mon Sep 17 00:00:00 2001 From: Sean Mooney Date: Tue, 10 Jun 2014 11:41:49 +0100 Subject: [PATCH] changes ovs agent_id init to use hostname instead of mac In the Open vSwitch agent, the Agent id is currently based off the mac address of the br-int. Userspace only Open vSwitch derivatives such as Intel's DPDK Accelerated Open vSwitch do not currently create a tap device in the kernel to back the ovs bridges local port. This limitation prevents reuse of the OpenVSwitch agent between both switches. To enable reuse of the ovs agent with Intel's DPDK Accelerated Open vSwitch, the proposal is to change the generation of the agent_id to use the hostname, instead of the mac address of the br-int. For several plugins such as the nec,mlnx,hyperv and onconvergence agents the hostname is used to create the agent id. Using the hostname will normalise the agent_id between these 5 neutron agents, additionally log readability will also be improved, if log aggregation is preformed across a cluster as it will be easier to identify which node the log is from. the hostname is retrived from cfg.CONF.host Closes-Bug: #1323259 Change-Id: I9abfac17a74d298f1a17a0931fc98ac00234ac0b --- .../plugins/openvswitch/agent/ovs_neutron_agent.py | 3 +-- neutron/tests/unit/openvswitch/test_ovs_tunnel.py | 13 ++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index f4a46c242..b706e4173 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -236,8 +236,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, LOG.exception(_("Failed reporting state!")) def setup_rpc(self): - mac = self.int_br.get_local_port_mac() - self.agent_id = '%s%s' % ('ovs', (mac.replace(":", ""))) + self.agent_id = 'ovs-agent-%s' % cfg.CONF.host self.topic = topics.AGENT self.plugin_rpc = OVSPluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) diff --git a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py index cb4c7cd98..7835dda8f 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/neutron/tests/unit/openvswitch/test_ovs_tunnel.py @@ -105,10 +105,8 @@ class TunnelTest(base.BaseTestCase): ] self.mock_int_bridge = self.ovs_bridges[self.INT_BRIDGE] - self.mock_int_bridge.get_local_port_mac.return_value = '000000000001' self.mock_int_bridge_expected = [ mock.call.set_secure_mode(), - mock.call.get_local_port_mac(), mock.call.delete_port('patch-tun'), mock.call.remove_all_flows(), mock.call.add_flow(priority=1, actions='normal'), @@ -249,11 +247,12 @@ class TunnelTest(base.BaseTestCase): self._verify_mock_call(self.execute, self.execute_expected) def test_construct(self): - ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, - self.TUN_BRIDGE, - '10.0.0.1', self.NET_MAPPING, - 'sudo', 2, ['gre'], - self.VETH_MTU) + agent = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, + self.TUN_BRIDGE, + '10.0.0.1', self.NET_MAPPING, + 'sudo', 2, ['gre'], + self.VETH_MTU) + self.assertEqual(agent.agent_id, 'ovs-agent-%s' % cfg.CONF.host) self._verify_mock_calls() # TODO(ethuleau): Initially, local ARP responder is be dependent to the -- 2.45.2