Skip to content

Commit f4cc2a1

Browse files
committed
slcli ipsec cancel, ipsec list, loadbal cancel command missing feature fix
1 parent 5798373 commit f4cc2a1

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

SoftLayer/CLI/loadbal/order.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,19 @@ def order_options(env, datacenter):
153153

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

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

164+
if not force:
165+
if not (env.skip_confirmations or
166+
formatting.confirm("This will cancel the LBaaS Instance and cannot be undone. Continue?")):
167+
raise exceptions.CLIAbort('Aborted')
168+
163169
try:
164170
mgr.cancel_lbaas(uuid)
165171
click.secho(f"LB {identifier} canceled succesfully.", fg='green')

SoftLayer/CLI/vpn/ipsec/cancel.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
9+
from SoftLayer.CLI import formatting
810

911

1012
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
@@ -15,8 +17,9 @@
1517
help="Cancels the service immediately (instead of on the billing anniversary)")
1618
@click.option('--reason',
1719
help="An optional cancellation reason. See cancel-reasons for a list of available options")
20+
@click.option('--force', default=False, is_flag=True, help="Force cancel ipsec vpn without confirmation")
1821
@environment.pass_env
19-
def cli(env, identifier, immediate, reason):
22+
def cli(env, identifier, immediate, reason, force):
2023
"""Cancel a IPSEC VPN tunnel context."""
2124

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

31+
if not force:
32+
if not (env.skip_confirmations or
33+
formatting.confirm("This will cancel the Ipsec Vpn and cannot be undone. Continue?")):
34+
raise exceptions.CLIAbort('Aborted')
35+
2836
result = manager.cancel_item(context['billingItem']['id'], immediate, reason)
2937

3038
if result:

SoftLayer/CLI/vpn/ipsec/list.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010

1111
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
12+
@click.option('--sortby', help='Column to sort by',
13+
default='created')
1214
@environment.pass_env
13-
def cli(env):
15+
def cli(env, sortby):
1416
"""List IPSec VPN tunnel contexts"""
1517
manager = SoftLayer.IPSECManager(env.client)
1618
contexts = manager.get_tunnel_contexts()
@@ -21,6 +23,8 @@ def cli(env):
2123
'internal peer IP address',
2224
'remote peer IP address',
2325
'created'])
26+
table.sortby = sortby
27+
2428
for context in contexts:
2529
table.add_row([context.get('id', ''),
2630
context.get('name', ''),

0 commit comments

Comments
 (0)