[stable only][ovn]Update get datapath id to network from Port_Binding

The value about neutron-metadata-proxy-networks of Chassis's
 external_ids are network_id, and the datapath field of
 Port_Binding table is the uuid of Datapath_Binding tables.
When call function set_port_status_up after boot server instance,
 it check datapath in neutron-metadata-proxy-networks of
 Chassis's external_ids, the datapath id is not match with
 network id, so change get datapath id from Port_Binding
 to get network id.
Since [1], this is not needed in Xena.
[1]https://review.opendev.org/c/openstack/neutron/+/791997

Closes-Bug: #1946588
Change-Id: Ib3c1bea9b805dc7d9967f66b3b0136efb3e8e08d
(cherry picked from commit f5ea47b095)
This commit is contained in:
hailun.huang 2021-10-11 11:25:45 +08:00 committed by Frode Nordahl
parent 124215ccd6
commit cff314f92e
2 changed files with 6 additions and 3 deletions

View File

@ -930,6 +930,7 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
def get_logical_port_chassis_and_datapath(self, name):
for port in self._tables['Port_Binding'].rows.values():
if port.logical_port == name:
datapath = str(port.datapath.uuid)
network_id = utils.get_network_name_from_datapath(
port.datapath)
chassis = port.chassis[0].name if port.chassis else None
return chassis, datapath
return chassis, network_id

View File

@ -158,8 +158,10 @@ class TestSbApi(BaseOvnIdlTest):
chassis, switch, port, binding = self._add_switch_port(
self.data['chassis'][0]['name'])
self.api.lsp_bind(port.name, chassis.name).execute(check_error=True)
network_id = binding.datapath.external_ids['name'].replace(
'neutron-', '')
self.assertEqual(
(chassis.name, str(binding.datapath.uuid)),
(chassis.name, network_id),
self.api.get_logical_port_chassis_and_datapath(port.name))