From cff314f92e158c8142dcd238a072fe2a7ca04d87 Mon Sep 17 00:00:00 2001 From: "hailun.huang" Date: Mon, 11 Oct 2021 11:25:45 +0800 Subject: [PATCH] [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 f5ea47b09507e7bd620ba3bcd1af771238d79d6d) --- .../ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py | 5 +++-- .../ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) 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 bd748bf891c..5532ea0c5bd 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 @@ -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 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 ad3cbe9f329..18b35232ede 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 @@ -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))