diff --git a/neutron/common/ovn/constants.py b/neutron/common/ovn/constants.py index 038f08bd93a..f4fa5b74c79 100644 --- a/neutron/common/ovn/constants.py +++ b/neutron/common/ovn/constants.py @@ -273,6 +273,7 @@ PORT_SECURITYGROUPS = 'security_groups' LSP_TYPE_LOCALNET = 'localnet' LSP_TYPE_VIRTUAL = 'virtual' LSP_TYPE_EXTERNAL = 'external' +LSP_TYPE_LOCALPORT = 'localport' LSP_OPTIONS_VIRTUAL_PARENTS_KEY = 'virtual-parents' LSP_OPTIONS_VIRTUAL_IP_KEY = 'virtual-ip' LSP_OPTIONS_MCAST_FLOOD_REPORTS = 'mcast_flood_reports' diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py index c67ebada37e..c5136827a33 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py @@ -887,7 +887,7 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend): except idlutils.RowNotFound: return None cmd = self.db_find_rows('Port_Binding', ('datapath', '=', dp), - ('type', '=', 'localport')) + ('type', '=', ovn_const.LSP_TYPE_LOCALPORT)) return next(iter(cmd.execute(check_error=True)), None) def set_chassis_neutron_description(self, chassis, description, diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py index d0c0c0fab78..7aea6ad1131 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py @@ -673,7 +673,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase): cmds = [] for port in self._nb_idl.lsp_list().execute(check_error=True): port_type = port.type.strip() - if port_type in ("vtep", "localport", "router"): + if port_type in ("vtep", ovn_const.LSP_TYPE_LOCALPORT, "router"): continue options = port.options diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index c4a06da5d5f..b95f022e3e2 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -268,7 +268,7 @@ class OVNClient(object): const.DEVICE_OWNER_DISTRIBUTED, const.DEVICE_OWNER_DHCP] and not utils.is_neutron_dhcp_agent_port(port)): - port_type = 'localport' + port_type = ovn_const.LSP_TYPE_LOCALPORT if utils.is_port_external(port): if self.is_external_ports_supported(): @@ -311,7 +311,7 @@ class OVNClient(object): # and will be ignored when mcast_snoop is False. We can revise # this once https://bugzilla.redhat.com/show_bug.cgi?id=1933990 # (see comment #3) is fixed in Core OVN. - if port_type not in ('vtep', 'localport', 'router'): + if port_type not in ('vtep', ovn_const.LSP_TYPE_LOCALPORT, 'router'): options.update({ovn_const.LSP_OPTIONS_MCAST_FLOOD_REPORTS: 'true'}) device_owner = port.get('device_owner', '') diff --git a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py index a2483aa1cd8..9e50f9a11dc 100644 --- a/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py +++ b/neutron/tests/functional/agent/ovn/metadata/test_metadata_agent.py @@ -131,7 +131,7 @@ class TestMetadataAgent(base.TestOVNFunctionalBase): self.nb_api.lsp_add( lswitch_name, mdt_port_name, - type='localport', + type=ovn_const.LSP_TYPE_LOCALPORT, addresses='AA:AA:AA:AA:AA:AA 192.168.122.123', external_ids={ ovn_const.OVN_CIDRS_EXT_ID_KEY: '192.168.122.123/24'})) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py index b6845760fc5..3ca442048e7 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py @@ -99,7 +99,8 @@ class TestSbApi(BaseOvnIdlTest): self.assertGreaterEqual(set(mapping.keys()), {c['name'] for c in self.data['chassis']}) - def _add_switch_port(self, chassis_name, type='localport'): + def _add_switch_port(self, chassis_name, + type=ovn_const.LSP_TYPE_LOCALPORT): sname, pname = (utils.get_rand_device_name(prefix=p) for p in ('switch', 'port')) chassis = self.api.lookup('Chassis', chassis_name) diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_db_sync.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_db_sync.py index b8b5d405818..ccf489d1bdf 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_db_sync.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_ovn_db_sync.py @@ -963,7 +963,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase): _plugin_nb_ovn = self.mech_driver._nb_ovn plugin_metadata_ports = [row.name for row in ( _plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values()) - if row.type == 'localport'] + if row.type == ovn_const.LSP_TYPE_LOCALPORT] if should_match: # Check that metadata ports exist in both Neutron and OVN dbs. @@ -1481,7 +1481,7 @@ class TestOvnNbSync(base.TestOVNFunctionalBase): _plugin_nb_ovn = self.mech_driver._nb_ovn plugin_metadata_ports = [row.name for row in ( _plugin_nb_ovn._tables['Logical_Switch_Port'].rows.values()) - if row.type == 'localport'] + if row.type == ovn_const.LSP_TYPE_LOCALPORT] with self.nb_api.transaction(check_error=True) as txn: for port in plugin_metadata_ports: diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py index 82180c591f3..ffdfe354bd2 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py @@ -421,7 +421,7 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight, 'type': "vtep"}) lsp3 = fakes.FakeOvsdbRow.create_one_ovsdb_row( attrs={'name': 'lsp3', 'options': {}, - 'type': "localport"}) + 'type': constants.LSP_TYPE_LOCALPORT}) lsp4 = fakes.FakeOvsdbRow.create_one_ovsdb_row( attrs={'name': 'lsp4', 'options': {}, 'type': "router"}) diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index e82e0cedcd3..525fd146f38 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -3316,7 +3316,8 @@ class TestOVNMechanismDriverMetadataPort(test_plugin.Ml2PluginV2TestCase): with self.network(): self.assertEqual(1, self.nb_ovn.create_lswitch_port.call_count) args, kwargs = self.nb_ovn.create_lswitch_port.call_args - self.assertEqual('localport', kwargs['type']) + self.assertEqual(ovn_const.LSP_TYPE_LOCALPORT, + kwargs['type']) def test_metadata_port_not_created_if_exists(self): """Check that metadata port is not created if it already exists. @@ -3349,7 +3350,8 @@ class TestOVNMechanismDriverMetadataPort(test_plugin.Ml2PluginV2TestCase): self.assertEqual( 2, self.nb_ovn.set_lswitch_port.call_count) args, kwargs = self.nb_ovn.set_lswitch_port.call_args - self.assertEqual('localport', kwargs['type']) + self.assertEqual(ovn_const.LSP_TYPE_LOCALPORT, + kwargs['type']) self.assertEqual('10.0.0.2/24 20.0.0.2/24', kwargs['external_ids'].get( ovn_const.OVN_CIDRS_EXT_ID_KEY,