diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-01-07 17:46:20 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2021-03-16 16:08:46 +0100 |
commit | 30a85bd0cecc395a83790e637368ce4476cdf7f9 (patch) | |
tree | 88217c10787304245bdf0ac3a00de90d22513d00 /ironic/api | |
parent | f152ad370df8bf16e6d4d9ccab8be9a258dc57cf (diff) | |
download | ironic-30a85bd0cecc395a83790e637368ce4476cdf7f9.tar.gz |
API to force manual cleaning without booting IPA
Adds a new argument disable_ramdisk to the manual cleaning API.
Only steps that are marked with requires_ramdisk=False can be
run in this mode. Cleaning prepare/tear down is not done.
Some steps (like redfish BIOS) currently require IPA to detect
a successful reboot. They are not marked with requires_ramdisk
just yet.
Change-Id: Icacac871603bd48536188813647bc669c574de2a
Story: #2008491
Task: #41540
Diffstat (limited to 'ironic/api')
-rw-r--r-- | ironic/api/controllers/v1/node.py | 17 | ||||
-rw-r--r-- | ironic/api/controllers/v1/utils.py | 11 | ||||
-rw-r--r-- | ironic/api/controllers/v1/versions.py | 4 |
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 90a2a258c..3fd24c446 100644 --- a/ironic/api/controllers/v1/utils.py +++ b/ironic/api/controllers/v1/utils.py @@ -1972,3 +1972,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) |