From 8558f59630f81beba2789e6deef2cb5e6b367f20 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Thu, 4 Jul 2024 14:09:23 -0400 Subject: [PATCH] Fix port group network metadata generation When switching to using OpenStack SDK, there was a change missed that didn't account for the SDK returning generators instead of a list, so the loop on ports and port groups made it so that it started returning an empty list afterwards. Since there is no a masse of ports for a baremetal system usually, we take the generator into a list right away to prevent this. Closes-Bug: #2071972 Change-Id: I90766f8c225d834bb2eec606754107ea6a212f6d --- nova/tests/unit/virt/ironic/test_driver.py | 4 ++-- nova/virt/ironic/driver.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/tests/unit/virt/ironic/test_driver.py b/nova/tests/unit/virt/ironic/test_driver.py index 736eac24ca90..bf3291833d20 100644 --- a/nova/tests/unit/virt/ironic/test_driver.py +++ b/nova/tests/unit/virt/ironic/test_driver.py @@ -2785,8 +2785,8 @@ class IronicDriverGenerateConfigDriveTestCase(test.NoDBTestCase): node_id=self.node.id, address='00:00:00:00:00:02', port_group_id=portgroup.id) - self.mock_conn.ports.return_value = [port1, port2] - self.mock_conn.port_groups.return_value = [portgroup] + self.mock_conn.ports.return_value = iter([port1, port2]) + self.mock_conn.port_groups.return_value = iter([portgroup]) metadata = self.driver._get_network_metadata(self.node, self.network_info) diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index 3af85d3bd049..c99021866962 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -1050,10 +1050,10 @@ class IronicDriver(virt_driver.ComputeDriver): :param network_info: Instance network information. """ base_metadata = netutils.get_network_metadata(network_info) - ports = self.ironic_connection.ports(node=node.id, details=True) - port_groups = self.ironic_connection.port_groups( + ports = list(self.ironic_connection.ports(node=node.id, details=True)) + port_groups = list(self.ironic_connection.port_groups( node=node.id, details=True, - ) + )) vif_id_to_objects = {'ports': {}, 'portgroups': {}} for collection, name in ((ports, 'ports'), (port_groups, 'portgroups')):