Skip to content

Commit

Permalink
Add Additional Ironic Attributes to Nodes Resource
Browse files Browse the repository at this point in the history
Currently, the UI calls both esi node list and Ironic's
node list and merges both information together. The REST
API in esi-leap already calls Ironic's node list and
uses some of the information.

This commit modifies esi-leap's API so that power state
information and target provision state is also added,
eliminating the redundant call to Ironic's node list.

Resolves CCI-MOC/esi#571
  • Loading branch information
ajamias committed Jul 13, 2024
1 parent 822016c commit 42bc791
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion esi_leap/api/controllers/v1/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Node(base.ESILEAPBase):
owner = wsme.wsattr(wtypes.text)
maintenance = wsme.wsattr(wtypes.text)
provision_state = wsme.wsattr(wtypes.text)
target_provision_state = wsme.wsattr(wtypes.text)
power_state = wsme.wsattr(wtypes.text)
target_power_state = wsme.wsattr(wtypes.text)
properties = {wtypes.text: types.jsontype}
resource_class = wsme.wsattr(wtypes.text)
uuid = wsme.wsattr(wtypes.text)
Expand All @@ -49,7 +52,8 @@ def __init__(self, **kwargs):
self.fields = ('name', 'owner', 'uuid', 'offer_uuid', 'lease_uuid',
'lessee', 'future_offers', 'future_leases',
'resource_class', 'provision_state', 'maintenance',
'properties')
'properties', 'target_provision_state', 'power_state',
'target_power_state')
for field in self.fields:
setattr(self, field, kwargs.get(field, wtypes.Unset))

Expand Down Expand Up @@ -122,6 +126,9 @@ def get_all(self, resource_class=None, owner=None,

n = Node(name=node.name, uuid=node.uuid,
provision_state=node.provision_state,
target_provision_state=node.target_provision_state,
power_state=node.power_state,
target_power_state=node.target_power_state,
resource_class=node.resource_class,
properties=ironic.get_condensed_properties(
node.properties),
Expand Down
3 changes: 3 additions & 0 deletions esi_leap/tests/api/controllers/v1/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self):
self.lessee = 'fake-project-uuid'
self.maintenance = False
self.provision_state = 'active'
self.target_provision_state = 'target_state'
self.power_state = 'power off'
self.target_power_state = 'power on'
self.resource_class = 'baremetal'


Expand Down

0 comments on commit 42bc791

Please sign in to comment.