From 0cd6bfffe36554af0c2f3755ab0639d834cde569 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Fri, 26 Jun 2026 14:37:35 +0200 Subject: [PATCH] Show Ironic UUID in baremetal list Add a UUID column to the output of `osism baremetal list` so node UUIDs can be cross-referenced with Ironic logs and other tooling. Closes osism/python-osism#1394 Assisted-by: Claude:claude-opus-4-8[1m] Signed-off-by: Christian Berendt --- osism/commands/baremetal.py | 6 +++-- tests/unit/commands/test_baremetal.py | 32 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/osism/commands/baremetal.py b/osism/commands/baremetal.py index 659bc1a5..972f6b7a 100644 --- a/osism/commands/baremetal.py +++ b/osism/commands/baremetal.py @@ -84,6 +84,7 @@ def take_action(self, parsed_args): for b in baremetal: row = [ b["name"], + b["id"], b["power_state"] if b["power_state"] is not None else "n/a", b["provision_state"], b["maintenance"], @@ -94,6 +95,7 @@ def take_action(self, parsed_args): headers = [ "Name", + "UUID", "Power State", "Provision State", "Maintenance", @@ -104,8 +106,8 @@ def take_action(self, parsed_args): for row in result: info = get_baremetal_node_netbox_info(row[0]) - row.insert(1, info.get("device_role") or "N/A") - headers.insert(1, "Device Role") + row.insert(2, info.get("device_role") or "N/A") + headers.insert(2, "Device Role") print( tabulate( diff --git a/tests/unit/commands/test_baremetal.py b/tests/unit/commands/test_baremetal.py index bf254b8d..45604597 100644 --- a/tests/unit/commands/test_baremetal.py +++ b/tests/unit/commands/test_baremetal.py @@ -46,6 +46,38 @@ def test_node_not_found_returns_1(cls): assert _run_not_found(cls) == 1 +# --- BaremetalList output --- + + +def test_list_includes_uuid_column(capsys): + # The node UUID must be shown so it can be cross-referenced with Ironic logs. + cmd = baremetal.BaremetalList(MagicMock(), MagicMock()) + parsed_args = cmd.get_parser("test").parse_args([]) + + node = { + "name": "node1", + "id": "11111111-2222-3333-4444-555555555555", + "power_state": "power on", + "provision_state": "active", + "maintenance": False, + } + conn = MagicMock() + conn.baremetal.nodes.return_value = [node] + + setup = MagicMock(return_value=("pw", [], None, True)) + getconn = MagicMock(return_value=conn) + cleanup = MagicMock() + with patch( + "osism.tasks.openstack.get_cloud_helpers", + return_value=(setup, getconn, cleanup), + ): + cmd.take_action(parsed_args) + + out = capsys.readouterr().out + assert "UUID" in out + assert node["id"] in out + + # --- BaremetalDump failure paths ---