From e3d5a058d6fe29135f0772980d837e4d587e93ed Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 2 Dec 2021 14:52:16 -0500 Subject: [PATCH] Change nodestorage to interactive and alias it to be interactive by default --- confluent_client/bin/nodestorage | 13 +++++++++++++ confluent_client/confluent_env.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/nodestorage b/confluent_client/bin/nodestorage index d892bc05..dafd6b88 100644 --- a/confluent_client/bin/nodestorage +++ b/confluent_client/bin/nodestorage @@ -20,6 +20,10 @@ import os import signal import sys +try: + input = raw_input +except NameError: + pass try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) except AttributeError: @@ -195,6 +199,8 @@ def main(): help='Comma separated list of disks to use, or the ' 'word "rest" to indicate use of all available ' 'disks') + argparser.add_option('-i', '--interactive', default=False, action='store_true', + help='Confirm any potentially destructive changes interactively') argparser.add_option('-s', '--size', type='str', help='Comma separated list of sizes to use when ' 'creating volumes. The sizes may be absolute ' @@ -230,6 +236,13 @@ def main(): except KeyError: argparser.print_help() sys.exit(1) + if options.interactive and operation != 'show': + showstorage(noderange, None, None) + sys.stdout.write('The above configuration will be changed by this action, do you wish to continue (y/N): ') + confirm = input() + if confirm and confirm.lower()[0] != 'y': + sys.stdout.write('Aborting\n') + sys.exit(1) handler(noderange, options, args[2:]) diff --git a/confluent_client/confluent_env.sh b/confluent_client/confluent_env.sh index fc07068d..0b13574b 100644 --- a/confluent_client/confluent_env.sh +++ b/confluent_client/confluent_env.sh @@ -37,7 +37,7 @@ alias nodereseat='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export C alias noderun='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; noderun' alias nodesensors='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodesensors' alias nodesetboot='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodesetboot' -alias nodestorage='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodestorage' +alias nodestorage='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodestorage -i' alias nodeshell='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodeshell' alias nodelicense='CURRENT_CMDLINE=$(HISTTIMEFORMAT= builtin history 1); export CURRENT_CMDLINE; nodelicense' # Do not continue for non-bash shells, the rest of this sets up bash completion functions