Added a generic user confirmation prompt in the Software CLI Framework
for all service-impacting commands.
This ensures critical operations require explicit user approval unless
overridden with --yes.
The "cli_confirmations" system service parameter is used to enabling or
disabling the confirmation prompt.
Confirmation Prompt:
WARNING: This is a high-risk operation that may cause a
service interruption or remove critical resources.
Do you want to continue? (yes/No):
Service-Impacting Commands:
software deploy host 1
software delete fake-release
Behavior:
1. When cli_confirmations is disabled, commands execute without
confirmation.
2. When cli_confirmations is disabled & --yes is used, commands
proceed normally to maintain consistency in internal calls.
3. When cli_confirmations is enabled & --yes is used, commands
execute without prompts.
4. When cli_confirmations is enabled & --yes is not provided, a
confirmation prompt appears, and if no response is given, it
times out.
5. Normal operations should not prompt cli confirmations prompt.
Test Plan:
PASS - AIO-SX:
Verified CLI behavior aligns with the above conditions.
Story: 2011240
Task: 51197
Change-Id: If7ab960272bff6cc1f33fc3500435c225f2b5dc9
Signed-off-by: Sabyasachi Nayak <sabyasachi.nayak@windriver.com>
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
#
|
|
# Copyright (c) 2013-2025 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
#
|
|
|
|
from software_client.common import utils
|
|
from software_client.v1 import deploy_shell
|
|
|
|
|
|
DEPLOY_COMMAND_MODULES = [
|
|
deploy_shell,
|
|
]
|
|
|
|
# sofware deploy commands
|
|
# - precheck
|
|
# - start
|
|
# - host
|
|
# - abort
|
|
# - activate
|
|
# - activate-rollback
|
|
# - complete
|
|
# - delete
|
|
# non root/sudo users can run:
|
|
# - host-list
|
|
# - show
|
|
# Deploy commands are region_restricted, which means
|
|
# that they are not permitted to be run in DC
|
|
#
|
|
# UN_RESTRICTED_COMMANDS is used to set argparser argument 'restricted' to False
|
|
UN_RESTRICTED_COMMANDS = ['show', 'host-list']
|
|
|
|
|
|
def enhance_parser(parser, subparsers, cmd_mapper):
|
|
'''Take a basic (nonversioned) parser and enhance it with
|
|
commands and options specific for this version of API.
|
|
|
|
:param parser: top level parser :param subparsers: top level
|
|
parser's subparsers collection where subcommands will go
|
|
'''
|
|
deploy_cmds = {}
|
|
|
|
for command_module in DEPLOY_COMMAND_MODULES:
|
|
utils.define_commands_from_module(subparsers, command_module,
|
|
deploy_cmds, UN_RESTRICTED_COMMANDS, cmd_area='deploy')
|
|
|
|
cmd_mapper.update({f"deploy {k}": v for k, v in deploy_cmds.items()})
|