Merge "[OVN] Allow VIP ports with a defined "device_owner""
This commit is contained in:
commit
db83514d05
neutron
plugins/ml2/drivers/ovn/mech_driver/ovsdb
tests/unit/plugins/ml2/drivers/ovn/mech_driver
@ -299,13 +299,15 @@ class OVNClient(object):
|
||||
subnet['cidr'].split('/')[1])
|
||||
|
||||
# Check if the port being created is a virtual port
|
||||
if not port['device_owner']:
|
||||
parents = self.get_virtual_port_parents(ip_addr, port)
|
||||
if parents:
|
||||
port_type = ovn_const.LSP_TYPE_VIRTUAL
|
||||
options[ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY] = ip_addr
|
||||
options[ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY] = (
|
||||
','.join(parents))
|
||||
parents = self.get_virtual_port_parents(ip_addr, port)
|
||||
if not parents:
|
||||
continue
|
||||
|
||||
port_type = ovn_const.LSP_TYPE_VIRTUAL
|
||||
options[ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY] = ip_addr
|
||||
options[ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY] = (
|
||||
','.join(parents))
|
||||
break
|
||||
|
||||
# Metadata port.
|
||||
if port['device_owner'] == const.DEVICE_OWNER_DISTRIBUTED:
|
||||
|
@ -2771,7 +2771,9 @@ class TestOVNMechanismDriverSegment(MechDriverSetupBase,
|
||||
segment_id=self.seg_2['id']) as subnet:
|
||||
self.sub_2 = subnet
|
||||
|
||||
def test_create_segments_subnet_metadata_ip_allocation(self):
|
||||
@mock.patch.object(ovn_client.OVNClient, 'get_virtual_port_parents',
|
||||
return_value=[])
|
||||
def test_create_segments_subnet_metadata_ip_allocation(self, *args):
|
||||
self._test_segments_helper()
|
||||
ovn_nb_api = self.mech_driver.nb_ovn
|
||||
|
||||
@ -3843,7 +3845,9 @@ class TestOVNMechanismDriverMetadataPort(MechDriverSetupBase,
|
||||
with self.network():
|
||||
self.assertEqual(0, self.nb_ovn.create_lswitch_port.call_count)
|
||||
|
||||
def test_metadata_ip_on_subnet_create(self):
|
||||
@mock.patch.object(ovn_client.OVNClient, 'get_virtual_port_parents',
|
||||
return_value=[])
|
||||
def test_metadata_ip_on_subnet_create(self, *args):
|
||||
"""Check metadata port update.
|
||||
|
||||
Check that the metadata port is updated with a new IP address when a
|
||||
@ -4013,26 +4017,24 @@ class TestOVNVVirtualPort(OVNMechanismDriverTestCase):
|
||||
self, mock_get_parents, mock_determine_bind_host):
|
||||
fake_parents = ['parent-0', 'parent-1']
|
||||
mock_get_parents.return_value = fake_parents
|
||||
port = {'id': 'virt-port',
|
||||
'mac_address': '00:00:00:00:00:00',
|
||||
'device_owner': '',
|
||||
'network_id': self.net['id'],
|
||||
'fixed_ips': [{'subnet_id': self.subnet['id'],
|
||||
'ip_address': '10.0.0.55'}]}
|
||||
port_info = self.mech_driver._ovn_client._get_port_options(
|
||||
port)
|
||||
self.assertEqual(ovn_const.LSP_TYPE_VIRTUAL, port_info.type)
|
||||
self.assertEqual(
|
||||
'10.0.0.55',
|
||||
port_info.options[ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY])
|
||||
self.assertIn(
|
||||
'parent-0',
|
||||
port_info.options[
|
||||
ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY])
|
||||
self.assertIn(
|
||||
'parent-1',
|
||||
port_info.options[
|
||||
ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY])
|
||||
for device_owner in ('', 'myVIPowner'):
|
||||
port = {'id': 'virt-port',
|
||||
'mac_address': '00:00:00:00:00:00',
|
||||
'device_owner': device_owner,
|
||||
'network_id': self.net['id'],
|
||||
'fixed_ips': [{'subnet_id': self.subnet['id'],
|
||||
'ip_address': '10.0.0.55'}]}
|
||||
port_info = self.mech_driver._ovn_client._get_port_options(port)
|
||||
self.assertEqual(ovn_const.LSP_TYPE_VIRTUAL, port_info.type)
|
||||
self.assertEqual(
|
||||
'10.0.0.55',
|
||||
port_info.options[ovn_const.LSP_OPTIONS_VIRTUAL_IP_KEY])
|
||||
self.assertIn(
|
||||
'parent-0',
|
||||
port_info.options[ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY])
|
||||
self.assertIn(
|
||||
'parent-1',
|
||||
port_info.options[ovn_const.LSP_OPTIONS_VIRTUAL_PARENTS_KEY])
|
||||
|
||||
@mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2, 'get_ports')
|
||||
def _test_set_unset_virtual_port_type(self, mock_get_ports, unset=False):
|
||||
|
Loading…
x
Reference in New Issue
Block a user