Merge "Fix incorrect arg while getting ports by portgroup"

This commit is contained in:
Zuul
2025-09-26 19:34:41 +00:00
committed by Gerrit Code Review
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.