Skip to content

Commit db55c21

Browse files
committed
Fix wrong usage of the python ironic client
1 parent 4a7074b commit db55c21

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • python/understack-workflows/understack_workflows/ironic

python/understack-workflows/understack_workflows/ironic/client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ironicclient.v1.client import Client as IronicV1Client
66
from ironicclient.v1.node import Node
77
from ironicclient.v1.port import Port
8+
from ironicclient.v1.runbook import Runbook
89

910
from understack_workflows.openstack.client import get_ironic_client
1011

@@ -58,8 +59,17 @@ def set_node_target_raid_config(self, node_id: str, raid_config: dict) -> None:
5859
def get_node_traits(self, node_id: str) -> list[str]:
5960
return cast(list[str], self.client.node.get_traits(node_id))
6061

61-
def get_runbook(self, runbook_id: str):
62-
return self.client.node.api.runbook.get(runbook_id)
62+
def get_runbook(self, runbook_name_or_id: str) -> Runbook:
63+
"""Get runbook by name or by UUID.
64+
65+
raises ironicclient.common.apiclient.exceptions.NotFound
66+
"""
67+
runbook = self.client.runbook.get(runbook_name_or_id)
68+
# The above raises an error if there was no such runbook. The following
69+
# is just to make the type checker happy:
70+
if not runbook:
71+
raise ironic_exceptions.NotFound
72+
return runbook
6373

6474
def get_node_inventory(self, node_ident: str) -> dict:
6575
"""Fetch node inventory data from Ironic API.

0 commit comments

Comments
 (0)