From 1c49571d296db07deb766149fe66756b5b4db66a Mon Sep 17 00:00:00 2001 From: Romil Gupta Date: Sun, 22 Mar 2015 23:38:00 -0700 Subject: [PATCH] Follow up patch for Validate when DVR enabled, l2_pop is also enabled Reference: https://review.openstack.org/#/c/165311/ For a VLAN underlays, DVR does not mandate l2-pop to be turned ON. So just checking for enable_tunneling and validating for l2-pop being turned ON is more than sufficient. Change-Id: I96695dc623b4ea37d3ef1384eb9ac9c1384d3da3 Closes-Bug: #1417633 --- .../openvswitch/agent/ovs_neutron_agent.py | 18 ++++++++++-------- .../unit/openvswitch/test_ovs_neutron_agent.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 9b8aabb72..051cf7a04 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -180,6 +180,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, 'agent_type': q_const.AGENT_TYPE_OVS, 'start_flag': True} + if tunnel_types: + self.enable_tunneling = True + else: + self.enable_tunneling = False + # Validate agent configurations self._check_agent_configurations() @@ -200,11 +205,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, self.polling_interval = polling_interval self.minimize_polling = minimize_polling self.ovsdb_monitor_respawn_interval = ovsdb_monitor_respawn_interval - - if tunnel_types: - self.enable_tunneling = True - else: - self.enable_tunneling = False self.local_ip = local_ip self.tunnel_count = 0 self.vxlan_udp_port = cfg.CONF.AGENT.vxlan_udp_port @@ -1556,9 +1556,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, rpc_api.client.timeout = timeout def _check_agent_configurations(self): - if self.enable_distributed_routing and not self.l2_pop: - raise ValueError(_("DVR cannot be enabled without " - "L2 population.")) + if (self.enable_distributed_routing and self.enable_tunneling + and not self.l2_pop): + raise ValueError(_("DVR deployments for VXLAN/GRE underlays " + "require L2-pop to be enabled, in both the " + "Agent and Server side.")) def _ofport_set_to_str(ofport_set): diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index 1df71fe84..21314e491 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -167,17 +167,25 @@ class TestOvsNeutronAgent(base.BaseTestCase): self.assertFalse(set_ovs_db_func.called) self.assertFalse(delete_flows_func.called) - def test_check_agent_configurations_raises(self): + def test_check_agent_configurations_for_dvr_raises(self): self.agent.enable_distributed_routing = True + self.agent.enable_tunneling = True self.agent.l2_pop = False self.assertRaises(ValueError, self.agent._check_agent_configurations) - def test_check_agent_configurations(self): + def test_check_agent_configurations_for_dvr(self): self.agent.enable_distributed_routing = True + self.agent.enable_tunneling = True self.agent.l2_pop = True self.assertIsNone(self.agent._check_agent_configurations()) + def test_check_agent_configurations_for_dvr_with_vlan(self): + self.agent.enable_distributed_routing = True + self.agent.enable_tunneling = False + self.agent.l2_pop = False + self.assertIsNone(self.agent._check_agent_configurations()) + def test_port_bound_deletes_flows_for_valid_ofport(self): self._mock_port_bound(ofport=1, new_local_vlan=1) -- 2.45.2