Skip to content

Commit ad26784

Browse files
#1768 improved the flow of firewall cancel and it should be able to do multiVlan and single server firewall cancels now
1 parent 8d9037e commit ad26784

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

SoftLayer/CLI/firewall/cancel.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212

1313
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1414
@click.argument('identifier')
15+
@click.option('--firewall-type', required=True, show_default=True, default='vlan',
16+
type=click.Choice(['vlan', 'server'], case_sensitive=False),
17+
help='Firewall type.')
1518
@environment.pass_env
16-
def cli(env, identifier):
19+
def cli(env, identifier, firewall_type):
1720
"""Cancels a firewall."""
1821

1922
mgr = SoftLayer.FirewallManager(env.client)
20-
firewall_type, firewall_id = firewall.parse_id(identifier)
2123

2224
if not (env.skip_confirmations or
23-
formatting.confirm("This action will cancel a firewall from your "
24-
"account. Continue?")):
25+
formatting.confirm("This action will cancel a firewall from your account. Continue?")):
2526
raise exceptions.CLIAbort('Aborted.')
2627

27-
if firewall_type in ['vs', 'server']:
28-
mgr.cancel_firewall(firewall_id, dedicated=False)
29-
elif firewall_type == 'vlan':
30-
mgr.cancel_firewall(firewall_id, dedicated=True)
28+
if firewall_type == 'server':
29+
mgr.cancel_firewall(identifier, dedicated=False)
3130
else:
32-
raise exceptions.CLIAbort('Unknown firewall type: %s' % firewall_type)
31+
mgr.cancel_firewall(identifier, dedicated=True)
3332

3433
env.fout('Firewall with id %s is being cancelled!' % identifier)

SoftLayer/managers/firewall.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@ def _get_fwl_billing_item(self, firewall_id, dedicated=False):
157157
firewall_service = self.client['Network_Component_Firewall']
158158
firewall = firewall_service.getObject(id=firewall_id, mask=mask)
159159
if firewall is None:
160-
raise exceptions.SoftLayerError(
161-
"Unable to find firewall %d" % firewall_id)
160+
raise exceptions.SoftLayerError(f"Unable to find firewall {firewall_id}")
162161
if firewall.get('billingItem') is None:
163-
raise exceptions.SoftLayerError(
164-
"Unable to find billing item for firewall %d" % firewall_id)
162+
raise exceptions.SoftLayerError(f"Unable to find billing item for firewall {firewall_id}")
165163

166164
return firewall['billingItem']
167165

0 commit comments

Comments
 (0)