Add confirmation to disable command

This commit is contained in:
Joshua Boniface 2022-07-21 16:43:37 -04:00
parent 2739c27299
commit 71ffd5a191
1 changed files with 18 additions and 2 deletions

View File

@ -1357,15 +1357,31 @@ def vm_stop(domain, confirm_flag):
default=False, default=False,
help="Forcibly stop the VM instead of waiting for shutdown.", 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 @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. 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. 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) cleanup(retcode, retmsg)