summaryrefslogtreecommitdiff
path: root/ironicclient/v1/node.py
diff options
context:
space:
mode:
authorCenne <cennedee+opendev@protonmail.com>2021-08-09 19:32:53 +0200
committerCenne <cennedee+opendev@protonmail.com>2021-08-13 18:24:58 +0200
commit00808631c1ffa3a9ec2cecafd5ea9f7447f440a8 (patch)
tree035d6232e171c2940a80f6fa5e8e4c87f0a09251 /ironicclient/v1/node.py
parenta5a3d4e4426ce8700f193aae77688cd63ac26b05 (diff)
downloadpython-ironicclient-00808631c1ffa3a9ec2cecafd5ea9f7447f440a8.tar.gz
Add support for changing 'boot_mode' and 'secure_boot' states
Story: 2008567 Task: 41709 depends-on: https://review.opendev.org/c/openstack/ironic/+/800084 Change-Id: I2937ea924ccc4ca6e9ab5599aa02e3c078c166b3
Diffstat (limited to 'ironicclient/v1/node.py')
-rw-r--r--ironicclient/v1/node.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/ironicclient/v1/node.py b/ironicclient/v1/node.py
index 88879f0..df00867 100644
--- a/ironicclient/v1/node.py
+++ b/ironicclient/v1/node.py
@@ -590,6 +590,64 @@ class NodeManager(base.CreateManager):
os_ironic_api_version=os_ironic_api_version,
global_request_id=global_request_id)
+ def set_boot_mode(self, node_id, state,
+ os_ironic_api_version=None, global_request_id=None):
+ """Sets boot mode for a node.
+
+ :param node_id: Node identifier
+ :param state: One of target boot modes, 'uefi' or 'bios'
+ :param os_ironic_api_version: String version (e.g. "1.76") to use for
+ the request. If not specified, the client's default is used.
+ :param global_request_id: String containing global request ID header
+ value (in form "req-<UUID>") to use for the request.
+
+ :raises: ValueError if boot mode is not one of 'uefi' / 'bios'
+ :returns: The status of the request
+ """
+ if state not in ('uefi', 'bios'):
+ raise ValueError(
+ _("Valid boot modes are 'uefi' or 'bios'"))
+
+ path = "%s/states/boot_mode" % node_id
+ target = state
+ body = {'target': target}
+
+ return self.update(path, body, http_method='PUT',
+ os_ironic_api_version=os_ironic_api_version,
+ global_request_id=global_request_id)
+
+ def set_secure_boot(self, node_id, state,
+ os_ironic_api_version=None, global_request_id=None):
+ """Set the secure boot state for the node.
+
+ :param node_id: The UUID of the node.
+ :param state: the secure boot state; either a Boolean or a string
+ representation of a Boolean (eg, 'true', 'on', 'false',
+ 'off'). True to turn secure boot on; False
+ to turn secure boot off.
+ :param os_ironic_api_version: String version (e.g. "1.76") to use for
+ the request. If not specified, the client's default is used.
+ :param global_request_id: String containing global request ID header
+ value (in form "req-<UUID>") to use for the request.
+
+ :raises: InvalidAttribute if state is an invalid string (that doesn't
+ represent a Boolean).
+ """
+ if isinstance(state, bool):
+ target = state
+ else:
+ try:
+ target = strutils.bool_from_string(state, strict=True)
+ except ValueError as e:
+ raise exc.InvalidAttribute(_("Argument 'state': %(err)s") %
+ {'err': e})
+ path = "%s/states/secure_boot" % node_id
+ body = {'target': target}
+
+ return self.update(path, body, http_method='PUT',
+ os_ironic_api_version=os_ironic_api_version,
+ global_request_id=global_request_id)
+
def set_target_raid_config(
self, node_ident, target_raid_config,
os_ironic_api_version=None, global_request_id=None):