Skip to content

Commit

Permalink
added force flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramkishor Chaladi authored and Ramkishor Chaladi committed Aug 21, 2023
1 parent 5798373 commit c048566
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion SoftLayer/CLI/hardware/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
10 changes: 6 additions & 4 deletions SoftLayer/CLI/hardware/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit c048566

Please sign in to comment.