Skip to content

Commit

Permalink
Merge pull request #2079 from softlayer/jayasilan-issue2042
Browse files Browse the repository at this point in the history
slcli ipsec cancel, ipsec list, loadbal cancel command missing feature fix #2042
  • Loading branch information
allmightyspiff authored Aug 31, 2023
2 parents ce5cd07 + f4cc2a1 commit f982312
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion SoftLayer/CLI/loadbal/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,19 @@ def order_options(env, datacenter):

@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@click.argument('identifier')
@click.option('--force', default=False, is_flag=True, help="Force cancel LBaaS Instance without confirmation")
@environment.pass_env
def cancel(env, identifier):
def cancel(env, identifier, force):
"""Cancels a LBaaS instance"""

mgr = SoftLayer.LoadBalancerManager(env.client)
uuid, _ = mgr.get_lbaas_uuid_id(identifier)

if not force:
if not (env.skip_confirmations or
formatting.confirm("This will cancel the LBaaS Instance and cannot be undone. Continue?")):
raise exceptions.CLIAbort('Aborted')

try:
mgr.cancel_lbaas(uuid)
click.secho(f"LB {identifier} canceled succesfully.", fg='green')
Expand Down
10 changes: 9 additions & 1 deletion SoftLayer/CLI/vpn/ipsec/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import SoftLayer
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting


@click.command(cls=SoftLayer.CLI.command.SLCommand, )
Expand All @@ -15,8 +17,9 @@
help="Cancels the service immediately (instead of on the billing anniversary)")
@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 cancel ipsec vpn without confirmation")
@environment.pass_env
def cli(env, identifier, immediate, reason):
def cli(env, identifier, immediate, reason, force):
"""Cancel a IPSEC VPN tunnel context."""

manager = SoftLayer.IPSECManager(env.client)
Expand All @@ -25,6 +28,11 @@ def cli(env, identifier, immediate, reason):
if 'billingItem' not in context:
raise SoftLayer.SoftLayerError("Cannot locate billing. May already be cancelled.")

if not force:
if not (env.skip_confirmations or
formatting.confirm("This will cancel the Ipsec Vpn and cannot be undone. Continue?")):
raise exceptions.CLIAbort('Aborted')

result = manager.cancel_item(context['billingItem']['id'], immediate, reason)

if result:
Expand Down
6 changes: 5 additions & 1 deletion SoftLayer/CLI/vpn/ipsec/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@


@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@click.option('--sortby', help='Column to sort by',
default='created')
@environment.pass_env
def cli(env):
def cli(env, sortby):
"""List IPSec VPN tunnel contexts"""
manager = SoftLayer.IPSECManager(env.client)
contexts = manager.get_tunnel_contexts()
Expand All @@ -21,6 +23,8 @@ def cli(env):
'internal peer IP address',
'remote peer IP address',
'created'])
table.sortby = sortby

for context in contexts:
table.add_row([context.get('id', ''),
context.get('name', ''),
Expand Down

0 comments on commit f982312

Please sign in to comment.