[OVN] rename get_port_groups to get_sg_port_groups
OVN's API called get_port_groups is poorly named and has misleading docstring. It returns only the OVN port groups that map to the security group in Neutron. Therefore, it should be called get_sg_port_groups. Closes-Bug: #1883716 Related-Bug: #1881316 Change-Id: Iae3f413dd1c4b0813b05d9bfd593c9e709540370 Signed-off-by: Flavio Fernandes <flaviof@redhat.com>
This commit is contained in:
parent
14b279bcdf
commit
e661a6b641
neutron
plugins/ml2/drivers/ovn/mech_driver
tests
functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb
unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb
@ -1260,7 +1260,7 @@ def create_default_drop_port_group(nb_idl):
|
||||
txn.add(nb_idl.pg_acl_add(may_exist=True, **acl))
|
||||
|
||||
ports_with_pg = set()
|
||||
for pg in nb_idl.get_port_groups().values():
|
||||
for pg in nb_idl.get_sg_port_groups().values():
|
||||
ports_with_pg.update(pg['ports'])
|
||||
|
||||
if ports_with_pg:
|
||||
|
@ -372,8 +372,8 @@ class API(api.API, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_port_groups(self):
|
||||
"""Gets all port groups in the OVN_Northbound DB
|
||||
def get_sg_port_groups(self):
|
||||
"""Gets port groups in the OVN_Northbound DB that map to SGs.
|
||||
|
||||
:returns: dictionary indexed by name, DB columns as values
|
||||
"""
|
||||
|
@ -685,7 +685,13 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
||||
# removed at some point.
|
||||
return
|
||||
|
||||
def get_port_groups(self):
|
||||
def get_sg_port_groups(self):
|
||||
"""Returns OVN port groups used as Neutron Security Groups.
|
||||
|
||||
This method will return all port group entries in OVN that map to
|
||||
a Security Group. Even though neutron_pg_drop is used to assist on
|
||||
SGs, it will also not be returned.
|
||||
"""
|
||||
port_groups = {}
|
||||
try:
|
||||
for row in self._tables['Port_Group'].rows.values():
|
||||
|
@ -1315,7 +1315,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
db_pgs.append(utils.ovn_port_group_name(sg['id']))
|
||||
db_pgs.append(ovn_const.OVN_DROP_PORT_GROUP_NAME)
|
||||
|
||||
nb_pgs = _plugin_nb_ovn.get_port_groups()
|
||||
nb_pgs = _plugin_nb_ovn.get_sg_port_groups()
|
||||
|
||||
mn_pgs = []
|
||||
for row in self.nb_api.tables['Port_Group'].rows.values():
|
||||
|
@ -775,11 +775,11 @@ class TestNBImplIdlOvn(TestDBImplIdlOvn):
|
||||
port_group = self.nb_ovn_idl.get_port_group(str(uuid.uuid4()))
|
||||
self.assertIsNone(port_group)
|
||||
|
||||
def test_get_port_groups_not_supported(self):
|
||||
def test_get_sg_port_groups_not_supported(self):
|
||||
self._load_nb_db()
|
||||
# Make sure that PG tables doesn't exist in fake db.
|
||||
self._tables.pop('Port_Group', None)
|
||||
port_groups = self.nb_ovn_idl.get_port_groups()
|
||||
port_groups = self.nb_ovn_idl.get_sg_port_groups()
|
||||
self.assertEqual({}, port_groups)
|
||||
|
||||
|
||||
|
@ -131,18 +131,18 @@ class TestOvnNbSyncML2(test_mech_driver.OVNMechanismDriverTestCase):
|
||||
'security_group_id': 'sg2'}],
|
||||
'name': 'all-tcpe'}]
|
||||
|
||||
self.port_groups_ovn = [mock.Mock(), mock.Mock(), mock.Mock()]
|
||||
self.port_groups_ovn[0].configure_mock(
|
||||
self.sg_port_groups_ovn = [mock.Mock(), mock.Mock(), mock.Mock()]
|
||||
self.sg_port_groups_ovn[0].configure_mock(
|
||||
name='pg_sg1',
|
||||
external_ids={ovn_const.OVN_SG_EXT_ID_KEY: 'sg1'},
|
||||
ports=[],
|
||||
acls=[])
|
||||
self.port_groups_ovn[1].configure_mock(
|
||||
self.sg_port_groups_ovn[1].configure_mock(
|
||||
name='pg_unknown_del',
|
||||
external_ids={ovn_const.OVN_SG_EXT_ID_KEY: 'sg2'},
|
||||
ports=[],
|
||||
acls=[])
|
||||
self.port_groups_ovn[2].configure_mock(
|
||||
self.sg_port_groups_ovn[2].configure_mock(
|
||||
name='neutron_pg_drop',
|
||||
external_ids=[],
|
||||
ports=[],
|
||||
@ -410,9 +410,9 @@ class TestOvnNbSyncML2(test_mech_driver.OVNMechanismDriverTestCase):
|
||||
ovn_nb_synchronizer.get_acls.return_value = self.acls_ovn
|
||||
core_plugin.get_security_groups = mock.MagicMock(
|
||||
return_value=self.security_groups)
|
||||
get_port_groups = mock.MagicMock()
|
||||
get_port_groups.execute.return_value = self.port_groups_ovn
|
||||
ovn_api.db_list_rows.return_value = get_port_groups
|
||||
get_sg_port_groups = mock.MagicMock()
|
||||
get_sg_port_groups.execute.return_value = self.sg_port_groups_ovn
|
||||
ovn_api.db_list_rows.return_value = get_sg_port_groups
|
||||
ovn_api.lsp_list.execute.return_value = self.ports_ovn
|
||||
# end of acl-sync block
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user