Skip to content

Commit 2119b84

Browse files
J JayasilanJ Jayasilan
J Jayasilan
authored and
J Jayasilan
committed
Example and sub feature for slcli firewall, slcli globalip assign,cancel,create,list command
1 parent 029e87d commit 2119b84

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

SoftLayer/CLI/firewall/monitoring.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
@click.argument('identifier')
1414
@environment.pass_env
1515
def cli(env, identifier):
16-
"""Gets bandwidth details for a firewall from the past 30 days."""
16+
"""Gets bandwidth details for a firewall from the past 30 days.
17+
18+
Example::
19+
slcli firewall monitoring vs:12345
20+
"""
1721

1822
mgr = SoftLayer.FirewallManager(env.client)
1923

SoftLayer/CLI/globalip/assign.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
@click.option('--target-id', help='The identifier for the destination resource to route this subnet to. ')
2121
@environment.pass_env
2222
def cli(env, identifier, target, target_id):
23-
"""Assigns the subnet to a target."""
23+
"""Assigns the subnet to a target.
24+
25+
Example::
26+
slcli globalip assign 12345678 9.111.123.456
27+
This command assigns IP address with ID 12345678 to a target device whose IP address is 9.111.123.456
28+
"""
2429

2530
mgr = SoftLayer.NetworkManager(env.client)
2631
mgr.route(identifier, target_types.get(target), target_id)

SoftLayer/CLI/globalip/cancel.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@
1212

1313
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1414
@click.argument('identifier')
15+
@click.option('-f', '--force', default=False, is_flag=True, help="Force operation without confirmation")
1516
@environment.pass_env
16-
def cli(env, identifier):
17-
"""Cancel global IP."""
17+
def cli(env, identifier, force):
18+
"""Cancel global IP.
19+
20+
Example::
21+
slcli globalip cancel 12345
22+
"""
1823

1924
mgr = SoftLayer.NetworkManager(env.client)
2025
global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier,
2126
name='global ip')
2227

23-
if not (env.skip_confirmations or formatting.no_going_back(global_ip_id)):
24-
raise exceptions.CLIAbort('Aborted')
28+
if not force:
29+
if not (env.skip_confirmations or
30+
formatting.confirm(f"This will cancel the IP address: {global_ip_id} and cannot be undone. Continue?")):
31+
raise exceptions.CLIAbort('Aborted')
2532

2633
mgr.cancel_global_ip(global_ip_id)

SoftLayer/CLI/globalip/create.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,26 @@
1212
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
1313
@click.option('-v6', '--ipv6', is_flag=True, help='Order a IPv6 IP')
1414
@click.option('--test', help='test order')
15+
@click.option('-f', '--force', default=False, is_flag=True, help="Force operation without confirmation")
1516
@environment.pass_env
16-
def cli(env, ipv6, test):
17-
"""Creates a global IP."""
17+
def cli(env, ipv6, test, force):
18+
"""Creates a global IP.
19+
20+
Example::
21+
slcli globalip create -v6
22+
This command creates an IPv6 address.
23+
"""
1824

1925
mgr = SoftLayer.NetworkManager(env.client)
2026

2127
version = 4
2228
if ipv6:
2329
version = 6
2430

25-
if not (test or env.skip_confirmations):
26-
if not formatting.confirm("This action will incur charges on your "
27-
"account. Continue?"):
28-
raise exceptions.CLIAbort('Cancelling order.')
31+
if not force:
32+
if not (test or env.skip_confirmations):
33+
if not formatting.confirm("This action will incur charges on your account. Continue?"):
34+
raise exceptions.CLIAbort('Cancelling order.')
2935

3036
result = mgr.add_global_ip(version=version, test_order=test)
3137

SoftLayer/CLI/globalip/list.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
type=click.Choice(['v4', 'v6']))
1515
@environment.pass_env
1616
def cli(env, ip_version):
17-
"""List all global IPs."""
17+
"""List all global IPs.
18+
19+
Example::
20+
slcli globalip list
21+
"""
1822

1923
mgr = SoftLayer.NetworkManager(env.client)
2024

0 commit comments

Comments
 (0)