summaryrefslogtreecommitdiff
path: root/ironic/api
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-03-17 00:47:04 +0000
committerGerrit Code Review <review@openstack.org>2021-03-17 00:47:04 +0000
commite058a5a3a144568f007448fee84ac137caa80a73 (patch)
treeb7e4b811facc468161f0f383515e2bfe11fabbcc /ironic/api
parent5584cc4cbbc5dd7eb25280532bc8cad8c497bd0f (diff)
parent30a85bd0cecc395a83790e637368ce4476cdf7f9 (diff)
downloadironic-e058a5a3a144568f007448fee84ac137caa80a73.tar.gz
Merge "API to force manual cleaning without booting IPA"
Diffstat (limited to 'ironic/api')
-rw-r--r--ironic/api/controllers/v1/node.py17
-rw-r--r--ironic/api/controllers/v1/utils.py11
-rw-r--r--ironic/api/controllers/v1/versions.py4
3 files changed, 25 insertions, 7 deletions
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py
index be5f0106d..328d020a5 100644
--- a/ironic/api/controllers/v1/node.py
+++ b/ironic/api/controllers/v1/node.py
@@ -793,7 +793,7 @@ class NodeStatesController(rest.RestController):
def _do_provision_action(self, rpc_node, target, configdrive=None,
clean_steps=None, deploy_steps=None,
- rescue_password=None):
+ rescue_password=None, disable_ramdisk=None):
topic = api.request.rpcapi.get_topic_for(rpc_node)
# Note that there is a race condition. The node state(s) could change
# by the time the RPC call is made and the TaskManager manager gets a
@@ -834,7 +834,8 @@ class NodeStatesController(rest.RestController):
msg, status_code=http_client.BAD_REQUEST)
_check_clean_steps(clean_steps)
api.request.rpcapi.do_node_clean(
- api.request.context, rpc_node.uuid, clean_steps, topic)
+ api.request.context, rpc_node.uuid, clean_steps,
+ disable_ramdisk, topic=topic)
elif target in PROVISION_ACTION_STATES:
api.request.rpcapi.do_provisioning_action(
api.request.context, rpc_node.uuid, target, topic)
@@ -849,10 +850,11 @@ class NodeStatesController(rest.RestController):
configdrive=args.types(type(None), dict, str),
clean_steps=args.types(type(None), list),
deploy_steps=args.types(type(None), list),
- rescue_password=args.string)
+ rescue_password=args.string,
+ disable_ramdisk=args.boolean)
def provision(self, node_ident, target, configdrive=None,
clean_steps=None, deploy_steps=None,
- rescue_password=None):
+ rescue_password=None, disable_ramdisk=None):
"""Asynchronous trigger the provisioning of the node.
This will set the target provision state of the node, and a
@@ -909,6 +911,7 @@ class NodeStatesController(rest.RestController):
:param rescue_password: A string representing the password to be set
inside the rescue environment. This is required (and only valid),
when target is "rescue".
+ :param disable_ramdisk: Whether to skip booting ramdisk for cleaning.
:raises: NodeLocked (HTTP 409) if the node is currently locked.
:raises: ClientSideError (HTTP 409) if the node is already being
provisioned.
@@ -920,7 +923,7 @@ class NodeStatesController(rest.RestController):
performed because the node is in maintenance mode.
:raises: NoFreeConductorWorker (HTTP 503) if no workers are available.
:raises: NotAcceptable (HTTP 406) if the API version specified does
- not allow the requested state transition.
+ not allow the requested state transition or parameters.
"""
rpc_node = api_utils.check_node_policy_and_retrieve(
'baremetal:node:set_provision_state', node_ident)
@@ -951,6 +954,7 @@ class NodeStatesController(rest.RestController):
state=rpc_node.provision_state)
api_utils.check_allow_configdrive(target, configdrive)
+ api_utils.check_allow_clean_disable_ramdisk(target, disable_ramdisk)
if clean_steps and target != ir_states.VERBS['clean']:
msg = (_('"clean_steps" is only valid when setting target '
@@ -973,7 +977,8 @@ class NodeStatesController(rest.RestController):
raise exception.NotAcceptable()
self._do_provision_action(rpc_node, target, configdrive, clean_steps,
- deploy_steps, rescue_password)
+ deploy_steps, rescue_password,
+ disable_ramdisk)
# Set the HTTP Location Header
url_args = '/'.join([node_ident, 'states'])
diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py
index 1fea853d0..7d25670c2 100644
--- a/ironic/api/controllers/v1/utils.py
+++ b/ironic/api/controllers/v1/utils.py
@@ -1986,3 +1986,14 @@ def check_allow_deploy_steps(target, deploy_steps):
'provision state to %s or %s') % allowed_states)
raise exception.ClientSideError(
msg, status_code=http_client.BAD_REQUEST)
+
+
+def check_allow_clean_disable_ramdisk(target, disable_ramdisk):
+ if disable_ramdisk is None:
+ return
+ elif api.request.version.minor < versions.MINOR_70_CLEAN_DISABLE_RAMDISK:
+ raise exception.NotAcceptable(
+ _("disable_ramdisk is not acceptable in this API version"))
+ elif target != "clean":
+ raise exception.BadRequest(
+ _("disable_ramdisk is supported only with manual cleaning"))
diff --git a/ironic/api/controllers/v1/versions.py b/ironic/api/controllers/v1/versions.py
index d00d68f60..bff79e75e 100644
--- a/ironic/api/controllers/v1/versions.py
+++ b/ironic/api/controllers/v1/versions.py
@@ -107,6 +107,7 @@ BASE_VERSION = 1
# v1.67: Add support for port_uuid/portgroup_uuid in node vif_attach
# v1.68: Add agent_verify_ca to heartbeat.
# v1.69: Add deploy_steps to provisioning
+# v1.70: Add disable_ramdisk to manual cleaning.
MINOR_0_JUNO = 0
MINOR_1_INITIAL_VERSION = 1
@@ -178,6 +179,7 @@ MINOR_66_NODE_NETWORK_DATA = 66
MINOR_67_NODE_VIF_ATTACH_PORT = 67
MINOR_68_HEARTBEAT_VERIFY_CA = 68
MINOR_69_DEPLOY_STEPS = 69
+MINOR_70_CLEAN_DISABLE_RAMDISK = 70
# When adding another version, update:
# - MINOR_MAX_VERSION
@@ -185,7 +187,7 @@ MINOR_69_DEPLOY_STEPS = 69
# explanation of what changed in the new version
# - common/release_mappings.py, RELEASE_MAPPING['master']['api']
-MINOR_MAX_VERSION = MINOR_69_DEPLOY_STEPS
+MINOR_MAX_VERSION = MINOR_70_CLEAN_DISABLE_RAMDISK
# String representations of the minor and maximum versions
_MIN_VERSION_STRING = '{}.{}'.format(BASE_VERSION, MINOR_1_INITIAL_VERSION)