Merge "[OVN] Implement a utility method to retrieve the Neutron name"
This commit is contained in:
@ -922,8 +922,12 @@ def parse_ovn_lb_port_forwarding(ovn_rtr_lb_pfs):
|
||||
return result
|
||||
|
||||
|
||||
def get_neutron_name(ovn_name):
|
||||
return ovn_name.replace('neutron-', '', 1)
|
||||
|
||||
|
||||
def get_network_name_from_datapath(datapath):
|
||||
return datapath.external_ids['name'].replace('neutron-', '')
|
||||
return get_neutron_name(datapath.external_ids['name'])
|
||||
|
||||
|
||||
def is_port_external(port):
|
||||
|
@ -357,7 +357,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
||||
elif nat.type == 'snat':
|
||||
snat.append(columns)
|
||||
|
||||
result.append({'name': lrouter.name.replace('neutron-', ''),
|
||||
result.append({'name': utils.get_neutron_name(lrouter.name),
|
||||
'static_routes': sroutes,
|
||||
'ports': lrports,
|
||||
'snats': snat,
|
||||
@ -376,7 +376,7 @@ class OvsdbNbOvnIdl(nb_impl_idl.OvnNbApiIdlImpl, Backend):
|
||||
if (ovn_const.OVN_ROUTER_NAME_EXT_ID_KEY not in
|
||||
lrouter.external_ids):
|
||||
continue
|
||||
result.append({'name': lrouter.name.replace('neutron-', ''),
|
||||
result.append({'name': utils.get_neutron_name(lrouter.name),
|
||||
'static_routes': getattr(lrouter, 'static_routes',
|
||||
[])})
|
||||
|
||||
|
@ -1000,7 +1000,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
|
||||
cmds = []
|
||||
for ls in self._nb_idl.ls_list().execute(check_error=True):
|
||||
if ovn_const.OVN_NETTYPE_EXT_ID_KEY not in ls.external_ids:
|
||||
net_id = ls.name.replace('neutron-', '')
|
||||
net_id = utils.get_neutron_name(ls.name)
|
||||
external_ids = {
|
||||
ovn_const.OVN_NETTYPE_EXT_ID_KEY: net_segments[net_id]}
|
||||
cmds.append(self._nb_idl.db_set(
|
||||
|
@ -814,7 +814,7 @@ class OVNClient:
|
||||
ovn_port = self._nb_idl.lookup('Logical_Switch_Port', port_id)
|
||||
ovn_network_name = ovn_port.external_ids.get(
|
||||
ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY)
|
||||
network_id = ovn_network_name.replace('neutron-', '')
|
||||
network_id = utils.get_neutron_name(ovn_network_name)
|
||||
|
||||
with self._nb_idl.transaction(check_error=True) as txn:
|
||||
txn.add(self._nb_idl.delete_lswitch_port(
|
||||
|
@ -149,7 +149,7 @@ class OVNPortForwardingHandler:
|
||||
ovn_const.OVN_NETWORK_NAME_EXT_ID_KEY)
|
||||
if not ovn_network_name:
|
||||
continue
|
||||
network_id = ovn_network_name.replace('neutron-', '')
|
||||
network_id = ovn_utils.get_neutron_name(ovn_network_name)
|
||||
if not network_id:
|
||||
continue
|
||||
if ovn_utils.is_provider_network(network_id):
|
||||
|
@ -183,7 +183,7 @@ class TestSbApi(BaseOvnIdlTest):
|
||||
ipaddr = '192.0.2.1'
|
||||
binding, switch = self._create_bound_port_with_ip(mac, ipaddr)
|
||||
# binding, ipaddr, switch = self._create_bound_port_with_ip()
|
||||
network_id = switch.name.replace('neutron-', '')
|
||||
network_id = ovn_utils.get_neutron_name(switch.name)
|
||||
result = self.api.get_network_port_bindings_by_ip(network_id, ipaddr)
|
||||
self.assertIn(binding, result)
|
||||
|
||||
@ -191,7 +191,7 @@ class TestSbApi(BaseOvnIdlTest):
|
||||
ipaddr = 'fe80::99'
|
||||
mac = str(netutils.get_mac_addr_by_ipv6(netaddr.IPAddress(ipaddr)))
|
||||
binding, switch = self._create_bound_port_with_ip(mac, ipaddr)
|
||||
network_id = switch.name.replace('neutron-', '')
|
||||
network_id = ovn_utils.get_neutron_name(switch.name)
|
||||
result = self.api.get_network_port_bindings_by_ip(network_id, ipaddr)
|
||||
self.assertIn(binding, result)
|
||||
|
||||
@ -205,7 +205,7 @@ class TestSbApi(BaseOvnIdlTest):
|
||||
txn.add(
|
||||
self.nbapi.lsp_add(switch.name, unbound_port_name, type=type))
|
||||
txn.add(self.nbapi.lsp_set_addresses(unbound_port_name, [mac_ip]))
|
||||
network_id = switch.name.replace('neutron-', '')
|
||||
network_id = ovn_utils.get_neutron_name(switch.name)
|
||||
result = self.api.get_network_port_bindings_by_ip(network_id, ipaddr)
|
||||
self.assertIn(binding, result)
|
||||
self.assertEqual(1, len(result))
|
||||
|
@ -920,12 +920,12 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
# Get the list of lswitch ids stored in the OVN plugin IDL
|
||||
_plugin_nb_ovn = self.mech_driver.nb_ovn
|
||||
plugin_lswitch_ids = [
|
||||
row.name.replace('neutron-', '') for row in (
|
||||
utils.get_neutron_name(row.name) for row in (
|
||||
_plugin_nb_ovn._tables['Logical_Switch'].rows.values())]
|
||||
|
||||
# Get the list of lswitch ids stored in the monitor IDL connection
|
||||
monitor_lswitch_ids = [
|
||||
row.name.replace('neutron-', '') for row in (
|
||||
utils.get_neutron_name(row.name) for row in (
|
||||
self.nb_api.tables['Logical_Switch'].rows.values())]
|
||||
|
||||
# Get the list of provnet ports stored in the OVN plugin IDL
|
||||
@ -1238,11 +1238,11 @@ class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
|
||||
_plugin_nb_ovn = self.mech_driver.nb_ovn
|
||||
plugin_lrouter_ids = [
|
||||
row.name.replace('neutron-', '') for row in (
|
||||
utils.get_neutron_name(row.name) for row in (
|
||||
_plugin_nb_ovn._tables['Logical_Router'].rows.values())]
|
||||
|
||||
monitor_lrouter_ids = [
|
||||
row.name.replace('neutron-', '') for row in (
|
||||
utils.get_neutron_name(row.name) for row in (
|
||||
self.nb_api.tables['Logical_Router'].rows.values())]
|
||||
|
||||
if should_match:
|
||||
|
Reference in New Issue
Block a user