From c0485663560e6b192816d35cc9044084d44d4084 Mon Sep 17 00:00:00 2001 From: Ramkishor Chaladi Date: Mon, 21 Aug 2023 15:54:14 +0530 Subject: [PATCH] added force flag --- SoftLayer/CLI/hardware/cancel.py | 8 +++++++- SoftLayer/CLI/hardware/create.py | 10 ++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/SoftLayer/CLI/hardware/cancel.py b/SoftLayer/CLI/hardware/cancel.py index 8af077872..ed8633fcf 100644 --- a/SoftLayer/CLI/hardware/cancel.py +++ b/SoftLayer/CLI/hardware/cancel.py @@ -20,8 +20,9 @@ help="An optional comment to add to the cancellation ticket") @click.option('--reason', help="An optional cancellation reason. See cancel-reasons for a list of available options") +@click.option('--force', default=False, is_flag=True, help="Force modify") @environment.pass_env -def cli(env, identifier, immediate, comment, reason): +def cli(env, identifier, immediate, comment, reason, force): """Cancel a dedicated server.""" mgr = SoftLayer.HardwareManager(env.client) @@ -30,4 +31,9 @@ def cli(env, identifier, immediate, comment, reason): if not (env.skip_confirmations or formatting.no_going_back(hw_id)): raise exceptions.CLIAbort('Aborted') + if not force: + if not (env.skip_confirmations or + formatting.confirm("This action will incur charges on your account. Continue?")): + raise exceptions.CLIAbort('Aborted') + mgr.cancel_hardware(hw_id, reason, comment, immediate) diff --git a/SoftLayer/CLI/hardware/create.py b/SoftLayer/CLI/hardware/create.py index 3547344ac..eaa9e0a23 100644 --- a/SoftLayer/CLI/hardware/create.py +++ b/SoftLayer/CLI/hardware/create.py @@ -37,8 +37,9 @@ help="The ID of the private ROUTER on which you want the virtual server placed") @helpers.multi_option('--key', '-k', help="SSH keys to add to the root user") @helpers.multi_option('--extra', '-e', help="Extra option Key Names") +@click.option('--force', default=False, is_flag=True, help="Force modify") @environment.pass_env -def cli(env, **args): +def cli(env, force, **args): """Order/create a dedicated server.""" mgr = SoftLayer.HardwareManager(env.client) network = SoftLayer.NetworkManager(env.client) @@ -105,9 +106,10 @@ def cli(env, **args): for pod in pods: if args.get('datacenter') in pod['name']: click.secho(f"Warning: Closed soon: {pod['name']}", fg='yellow') - if not (env.skip_confirmations or formatting.confirm( - "This action will incur charges on your account. Continue?")): - raise exceptions.CLIAbort('Aborting dedicated server order.') + if not force: + if not (env.skip_confirmations or formatting.confirm( + "This action will incur charges on your account. Continue?")): + raise exceptions.CLIAbort('Aborting dedicated server order.') result = mgr.place_order(**order)