From a57b37fc56ffe3c1dade796c4663e95b1bbeea80 Mon Sep 17 00:00:00 2001 From: Hong Hui Xiao Date: Thu, 10 Sep 2015 06:38:01 -0400 Subject: [PATCH] Enable servicing lbaasV2 vip by DVR Currently, the vip of lbaasV2 will not have l3 network with DVR. This prevent the usercase of lbaasV2 + DVR. This patch aims to enable servicing lbaasv2 vip by DVR. Change-Id: I1b51550437994fbe78d4db904641d4d9fb75d82e Closes-Bug: #1493809 --- neutron/common/utils.py | 1 + neutron/tests/unit/common/test_utils.py | 3 +++ .../openvswitch/agent/test_ovs_neutron_agent.py | 16 ++++++++++++++++ neutron/tests/unit/plugins/ml2/test_plugin.py | 8 ++++++++ .../unit/scheduler/test_l3_agent_scheduler.py | 12 ++++++++++-- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/neutron/common/utils.py b/neutron/common/utils.py index a8b79e99f..b96327bbb 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -368,6 +368,7 @@ def is_dvr_serviced(device_owner): indirectly associated with DVR. """ dvr_serviced_device_owners = (n_const.DEVICE_OWNER_LOADBALANCER, + n_const.DEVICE_OWNER_LOADBALANCERV2, n_const.DEVICE_OWNER_DHCP) return (device_owner.startswith('compute:') or device_owner in dvr_serviced_device_owners) diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py index f6aee3da9..973a938dc 100644 --- a/neutron/tests/unit/common/test_utils.py +++ b/neutron/tests/unit/common/test_utils.py @@ -562,6 +562,9 @@ class TestDvrServices(base.BaseTestCase): def test_is_dvr_serviced_with_lb_port(self): self._test_is_dvr_serviced(constants.DEVICE_OWNER_LOADBALANCER, True) + def test_is_dvr_serviced_with_lbv2_port(self): + self._test_is_dvr_serviced(constants.DEVICE_OWNER_LOADBALANCERV2, True) + def test_is_dvr_serviced_with_dhcp_port(self): self._test_is_dvr_serviced(constants.DEVICE_OWNER_DHCP, True) diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 1280b10aa..bf44028d7 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -1935,6 +1935,16 @@ class TestOvsDvrNeutronAgent(object): self._test_port_bound_for_dvr_on_vxlan_network( device_owner=n_const.DEVICE_OWNER_LOADBALANCER, ip_version=6) + def test_port_bound_for_dvr_with_lbaasv2_vip_ports(self): + self._test_port_bound_for_dvr_on_vlan_network( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) + self._test_port_bound_for_dvr_on_vlan_network( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) + self._test_port_bound_for_dvr_on_vxlan_network( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) + self._test_port_bound_for_dvr_on_vxlan_network( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) + def test_port_bound_for_dvr_with_dhcp_ports(self): self._test_port_bound_for_dvr_on_vlan_network( device_owner=n_const.DEVICE_OWNER_DHCP) @@ -2211,6 +2221,12 @@ class TestOvsDvrNeutronAgent(object): self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_LOADBALANCER, ip_version=6) + def test_treat_devices_removed_for_dvr_with_lbaasv2_vip_ports(self): + self._test_treat_devices_removed_for_dvr( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2) + self._test_treat_devices_removed_for_dvr( + device_owner=n_const.DEVICE_OWNER_LOADBALANCERV2, ip_version=6) + def test_treat_devices_removed_for_dvr_with_dhcp_ports(self): self._test_treat_devices_removed_for_dvr( device_owner=n_const.DEVICE_OWNER_DHCP) diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index a9d0c43b7..5e6ad0801 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -633,6 +633,10 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase): self.assertTrue(utils.is_dvr_serviced( constants.DEVICE_OWNER_LOADBALANCER)) + def test_check_if_lbaasv2_vip_port_serviced_by_dvr(self): + self.assertTrue(utils.is_dvr_serviced( + constants.DEVICE_OWNER_LOADBALANCERV2)) + def test_check_if_dhcp_port_serviced_by_dvr(self): self.assertTrue(utils.is_dvr_serviced(constants.DEVICE_OWNER_DHCP)) @@ -785,6 +789,10 @@ class TestMl2DvrPortsV2(TestMl2PortsV2): self._test_delete_dvr_serviced_port( device_owner=constants.DEVICE_OWNER_LOADBALANCER) + def test_delete_lbaasv2_vip_port(self): + self._test_delete_dvr_serviced_port( + device_owner=constants.DEVICE_OWNER_LOADBALANCERV2) + def test_concurrent_csnat_port_delete(self): plugin = manager.NeutronManager.get_service_plugins()[ p_const.L3_ROUTER_NAT] diff --git a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py index f1156c456..4f549248a 100644 --- a/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/unit/scheduler/test_l3_agent_scheduler.py @@ -1187,13 +1187,13 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): 'my-subnet-id') self.assertTrue(result) - def test_dvr_serviced_vip_port_exists_on_subnet(self): + def _test_dvr_serviced_vip_port_exists_on_subnet(self, device_owner): vip_port = { 'id': 'lbaas-vip-port1', 'device_id': 'vip-pool-id', 'status': 'ACTIVE', 'binding:host_id': 'thisHost', - 'device_owner': constants.DEVICE_OWNER_LOADBALANCER, + 'device_owner': device_owner, 'fixed_ips': [ { 'subnet_id': 'my-subnet-id', @@ -1203,6 +1203,14 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase): } self._test_dvr_serviced_port_exists_on_subnet(port=vip_port) + def test_dvr_serviced_lbaas_vip_port_exists_on_subnet(self): + self._test_dvr_serviced_vip_port_exists_on_subnet( + device_owner=constants.DEVICE_OWNER_LOADBALANCER) + + def test_dvr_serviced_lbaasv2_vip_port_exists_on_subnet(self): + self._test_dvr_serviced_vip_port_exists_on_subnet( + device_owner=constants.DEVICE_OWNER_LOADBALANCERV2) + def _create_port(self, port_name, tenant_id, host, subnet_id, ip_address, status='ACTIVE', device_owner='compute:nova'): -- 2.45.2