Fix incorrect arg while getting ports by portgroup

get_ports_by_portgroup_id accepts id instead of uuid.

Change-Id: Ia21beb5675d2c4383a734a5a434d623aa628db6c
Signed-off-by: Kaifeng Wang <kaifeng.w@gmail.com>
Signed-off-by: Julia Kreger <juliaashleykreger@gmail.com>
This commit is contained in:
Kaifeng Wang
2025-09-23 09:12:01 +08:00
parent b3feb6335f
commit 595f126b4d
3 changed files with 12 additions and 5 deletions

View File

@@ -2697,7 +2697,7 @@ class ConductorManager(base_manager.BaseConductorManager):
# any Port associated to the PortGroup, otherwise
# PortgroupNotEmpty exception is raised.
associated_ports = self.dbapi.get_ports_by_portgroup_id(
portgroup_uuid)
portgroup_obj.id)
if associated_ports:
action = _("Portgroup %(portgroup)s can not be associated "
"with node %(node)s because there are ports "

View File

@@ -5373,7 +5373,7 @@ class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self.service.update_portgroup(self.context, portgroup)
portgroup.refresh()
self.assertEqual(update_node.id, portgroup.node_id)
mock_get_ports.assert_called_once_with(portgroup.uuid)
mock_get_ports.assert_called_once_with(portgroup.id)
mock_val.assert_called_once_with(mock.ANY, mock.ANY)
mock_pgc.assert_called_once_with(mock.ANY, mock.ANY, portgroup)
@@ -5399,7 +5399,7 @@ class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self.service.update_portgroup(self.context, portgroup)
portgroup.refresh()
self.assertEqual(update_node.id, portgroup.node_id)
mock_get_ports.assert_called_once_with(portgroup.uuid)
mock_get_ports.assert_called_once_with(portgroup.id)
mock_val.assert_called_once_with(mock.ANY, mock.ANY)
mock_pgc.assert_called_once_with(mock.ANY, mock.ANY, portgroup)
@@ -5425,7 +5425,7 @@ class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self.service.update_portgroup(self.context, portgroup)
portgroup.refresh()
self.assertEqual(update_node.id, portgroup.node_id)
mock_get_ports.assert_called_once_with(portgroup.uuid)
mock_get_ports.assert_called_once_with(portgroup.id)
mock_val.assert_called_once_with(mock.ANY, mock.ANY)
mock_pgc.assert_called_once_with(mock.ANY, mock.ANY, portgroup)
@@ -5454,7 +5454,7 @@ class UpdatePortgroupTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self.assertEqual(exception.PortgroupNotEmpty, exc.exc_info[0])
portgroup.refresh()
self.assertEqual(old_node_id, portgroup.node_id)
mock_get_ports.assert_called_once_with(portgroup.uuid)
mock_get_ports.assert_called_once_with(portgroup.id)
self.assertFalse(mock_val.called)
self.assertFalse(mock_pgc.called)

View File

@@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue around handling of portgroup updates where the associated
node ID is changed. While a rare operation, it exists as a capability
and a bug existed from the wrong ID value being used to query the
database. The correct ID value is now utilized.