From 71ffd5a1917cc71578bbab51f2fc2423a1ef4b40 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 21 Jul 2022 16:43:37 -0400 Subject: [PATCH] Add confirmation to disable command --- client-cli/pvc/pvc.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client-cli/pvc/pvc.py b/client-cli/pvc/pvc.py index a83f0374..5817bfbf 100755 --- a/client-cli/pvc/pvc.py +++ b/client-cli/pvc/pvc.py @@ -1357,15 +1357,31 @@ def vm_stop(domain, confirm_flag): default=False, help="Forcibly stop the VM instead of waiting for shutdown.", ) +@click.option( + "-y", + "--yes", + "confirm_flag", + is_flag=True, + default=False, + help="Confirm the disable", +) @cluster_req -def vm_disable(domain, force): +def vm_disable(domain, force_flag, confirm_flag): """ Shut down virtual machine DOMAIN and mark it as disabled. DOMAIN may be a UUID or name. Disabled VMs will not be counted towards a degraded cluster health status, unlike stopped VMs. Use this option for a VM that will remain off for an extended period. """ - retcode, retmsg = pvc_vm.vm_state(config, domain, "disable", force=force) + if not confirm_flag and not config["unsafe"]: + try: + click.confirm( + "Disable VM {}".format(domain), prompt_suffix="? ", abort=True + ) + except Exception: + exit(0) + + retcode, retmsg = pvc_vm.vm_state(config, domain, "disable", force=force_flag) cleanup(retcode, retmsg)