Merge "Fix DVR to service DHCP Ports"
This commit is contained in:
commit
a28bab140d
@ -353,6 +353,7 @@ def is_dvr_serviced(device_owner):
|
|||||||
if they are required for DVR or any service directly or
|
if they are required for DVR or any service directly or
|
||||||
indirectly associated with DVR.
|
indirectly associated with DVR.
|
||||||
"""
|
"""
|
||||||
if (device_owner.startswith('compute:') or (
|
dvr_serviced_device_owners = (q_const.DEVICE_OWNER_LOADBALANCER,
|
||||||
q_const.DEVICE_OWNER_LOADBALANCER == device_owner)):
|
q_const.DEVICE_OWNER_DHCP)
|
||||||
return True
|
return (device_owner.startswith('compute:') or
|
||||||
|
device_owner in dvr_serviced_device_owners)
|
||||||
|
@ -291,6 +291,10 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
self._test_port_bound_for_dvr(
|
self._test_port_bound_for_dvr(
|
||||||
device_owner=n_const.DEVICE_OWNER_LOADBALANCER)
|
device_owner=n_const.DEVICE_OWNER_LOADBALANCER)
|
||||||
|
|
||||||
|
def test_port_bound_for_dvr_with_dhcp_ports(self):
|
||||||
|
self._test_port_bound_for_dvr(
|
||||||
|
device_owner=n_const.DEVICE_OWNER_DHCP)
|
||||||
|
|
||||||
def test_port_bound_for_dvr_with_csnat_ports(self, ofport=10):
|
def test_port_bound_for_dvr_with_csnat_ports(self, ofport=10):
|
||||||
self._setup_for_dvr_test()
|
self._setup_for_dvr_test()
|
||||||
with mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
|
with mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
|
||||||
@ -434,6 +438,10 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
self._test_treat_devices_removed_for_dvr(
|
self._test_treat_devices_removed_for_dvr(
|
||||||
device_owner=n_const.DEVICE_OWNER_LOADBALANCER)
|
device_owner=n_const.DEVICE_OWNER_LOADBALANCER)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def test_treat_devices_removed_for_dvr_csnat_port(self, ofport=10):
|
def test_treat_devices_removed_for_dvr_csnat_port(self, ofport=10):
|
||||||
self._setup_for_dvr_test()
|
self._setup_for_dvr_test()
|
||||||
with mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
|
with mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
|
||||||
|
@ -528,3 +528,18 @@ class TestExceptionLogger(base.BaseTestCase):
|
|||||||
calls.assert_has_calls([mock.call(0), mock.call(1), mock.call(3)],
|
calls.assert_has_calls([mock.call(0), mock.call(1), mock.call(3)],
|
||||||
any_order=True)
|
any_order=True)
|
||||||
self.assertTrue(logger.called)
|
self.assertTrue(logger.called)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDvrServices(base.BaseTestCase):
|
||||||
|
|
||||||
|
def _test_is_dvr_serviced(self, device_owner, expected):
|
||||||
|
self.assertEqual(expected, utils.is_dvr_serviced(device_owner))
|
||||||
|
|
||||||
|
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_dhcp_port(self):
|
||||||
|
self._test_is_dvr_serviced(constants.DEVICE_OWNER_DHCP, True)
|
||||||
|
|
||||||
|
def test_is_dvr_serviced_with_vm_port(self):
|
||||||
|
self._test_is_dvr_serviced('compute:', True)
|
||||||
|
@ -911,7 +911,17 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase,
|
|||||||
sub_ids)
|
sub_ids)
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
|
|
||||||
def test_check_dvr_serviced_port_exists_on_subnet(self):
|
def _test_dvr_serviced_port_exists_on_subnet(self, port):
|
||||||
|
with mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.'
|
||||||
|
'get_ports', return_value=[port]):
|
||||||
|
result = self.dut.check_ports_active_on_host_and_subnet(
|
||||||
|
self.adminContext,
|
||||||
|
'thisHost',
|
||||||
|
'dvr1-intf-id',
|
||||||
|
'my-subnet-id')
|
||||||
|
self.assertTrue(result)
|
||||||
|
|
||||||
|
def test_dvr_serviced_vip_port_exists_on_subnet(self):
|
||||||
vip_port = {
|
vip_port = {
|
||||||
'id': 'lbaas-vip-port1',
|
'id': 'lbaas-vip-port1',
|
||||||
'device_id': 'vip-pool-id',
|
'device_id': 'vip-pool-id',
|
||||||
@ -925,19 +935,23 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase,
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
self._test_dvr_serviced_port_exists_on_subnet(port=vip_port)
|
||||||
|
|
||||||
with contextlib.nested(
|
def test_dvr_serviced_dhcp_port_exists_on_subnet(self):
|
||||||
mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
|
dhcp_port = {
|
||||||
'.get_ports', return_value=[vip_port]),
|
'id': 'dhcp-port1',
|
||||||
mock.patch('neutron.common.utils.is_dvr_serviced',
|
'device_id': 'dhcp-net-id',
|
||||||
return_value=True)) as (get_ports_fn, dvr_serv_fn):
|
'status': 'ACTIVE',
|
||||||
result = self.dut.check_ports_active_on_host_and_subnet(
|
'binding:host_id': 'thisHost',
|
||||||
self.adminContext,
|
'device_owner': constants.DEVICE_OWNER_DHCP,
|
||||||
'thisHost',
|
'fixed_ips': [
|
||||||
'dvr1-intf-id',
|
{
|
||||||
'my-subnet-id')
|
'subnet_id': 'my-subnet-id',
|
||||||
self.assertTrue(result)
|
'ip_address': '10.10.10.2'
|
||||||
self.assertEqual(dvr_serv_fn.call_count, 1)
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
self._test_dvr_serviced_port_exists_on_subnet(port=dhcp_port)
|
||||||
|
|
||||||
def _prepare_schedule_snat_tests(self):
|
def _prepare_schedule_snat_tests(self):
|
||||||
agent = agents_db.Agent()
|
agent = agents_db.Agent()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user