Add support for reading node's "boot_mode" and "secure_boot" fields

boot_mode is saved under node object as `node.boot_mode`
secure_boot is saved under node object as `node.is_secure_boot`

Story: 2008567
Task: 41709
Change-Id: I15a22970cd4f5ed0bf43c38004449c988cb04925
This commit is contained in:
Cenne 2021-07-23 21:17:27 +02:00
parent 0bc47cdb93
commit 4d4eafa761
3 changed files with 16 additions and 2 deletions

View File

@ -91,8 +91,8 @@ class Node(_common.ListMixin, resource.Resource):
is_maintenance='maintenance',
)
# Provision state deploy_steps introduced in 1.69 (Wallaby).
_max_microversion = '1.69'
# Node states boot_mode and secure_boot introduced in 1.75 (Xena).
_max_microversion = '1.75'
# Properties
#: The UUID of the allocation associated with this node. Added in API
@ -101,6 +101,8 @@ class Node(_common.ListMixin, resource.Resource):
#: A string or UUID of the tenant who owns the baremetal node. Added in API
#: microversion 1.50.
owner = resource.Body("owner")
#: The current boot mode state (uefi/bios). Added in API microversion 1.75.
boot_mode = resource.Body("boot_mode")
#: The UUID of the chassis associated wit this node. Can be empty or None.
chassis_id = resource.Body("chassis_uuid")
#: The current clean step.
@ -148,6 +150,9 @@ class Node(_common.ListMixin, resource.Resource):
#: Whether the node is marked for retirement. Added in API microversion
#: 1.61.
is_retired = resource.Body("retired", type=bool)
#: Whether the node is currently booted with secure boot turned on.
#: Added in API microversion 1.75.
is_secure_boot = resource.Body("secure_boot", type=bool)
#: Any error from the most recent transaction that started but failed to
#: finish.
last_error = resource.Body("last_error")

View File

@ -23,6 +23,7 @@ from openstack import utils
# NOTE: Sample data from api-ref doc
FAKE = {
"boot_mode": "uefi",
"chassis_uuid": "1", # NOTE: missed in api-ref sample
"clean_step": {},
"console_enabled": False,
@ -81,6 +82,7 @@ FAKE = {
"raid_config": {},
"reservation": None,
"resource_class": None,
"secure_boot": True,
"states": [
{
"href": "http://127.0.0.1:6385/v1/nodes/<NODE_ID>/states",
@ -119,6 +121,7 @@ class TestNode(base.TestCase):
self.assertEqual(FAKE['uuid'], sot.id)
self.assertEqual(FAKE['name'], sot.name)
self.assertEqual(FAKE['boot_mode'], sot.boot_mode)
self.assertEqual(FAKE['chassis_uuid'], sot.chassis_id)
self.assertEqual(FAKE['clean_step'], sot.clean_step)
self.assertEqual(FAKE['created_at'], sot.created_at)
@ -145,6 +148,7 @@ class TestNode(base.TestCase):
self.assertEqual(FAKE['raid_config'], sot.raid_config)
self.assertEqual(FAKE['reservation'], sot.reservation)
self.assertEqual(FAKE['resource_class'], sot.resource_class)
self.assertEqual(FAKE['secure_boot'], sot.is_secure_boot)
self.assertEqual(FAKE['states'], sot.states)
self.assertEqual(FAKE['target_provision_state'],
sot.target_provision_state)

View File

@ -0,0 +1,5 @@
---
features:
- |
Add support to display node fields ``boot_mode`` and ``secure_boot``
which are introduced in API 1.75.