55
66import SoftLayer
77from 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 , )
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 :
0 commit comments