Skip to content

Commit a236652

Browse files
Merge pull request softlayer#1810 from caberos/issue1795
subnet route and subnet clear-route
2 parents 8ebebc3 + dc0dc9d commit a236652

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

SoftLayer/CLI/subnet/route.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import SoftLayer
77
from SoftLayer.CLI import environment
8+
from SoftLayer.CLI import exceptions
89

910
target_types = {'vlan': 'SoftLayer_Network_Vlan',
1011
'ip': 'SoftLayer_Network_Subnet_IpAddress',
@@ -17,10 +18,25 @@
1718
@click.argument('identifier')
1819
@click.option('--target', type=click.Choice(['vlan', 'ip', 'hardware', 'vsi']),
1920
help='choose the type. vlan, ip, hardware, vsi')
20-
@click.option('--target-id', help='The identifier for the destination resource to route this subnet to. ')
21+
@click.option('--target-resource', help='Allows you to change the route of your secondary subnets.'
22+
'Subnets may be routed as either Static or Portable, and that designation is '
23+
'dictated by the routing destination specified.'
24+
'Static subnets have an ultimate routing destination of a single IP address '
25+
'but may not be routed to an existing subnet’s IP address whose '
26+
'subnet is routed as a Static.'
27+
'Portable subnets have an ultimate routing destination of a VLAN.'
28+
'A subnet can be routed to any resource within the same "routing region"'
29+
' as the subnet itself, usually limited to a single data center.'
30+
'See Also: '
31+
'https://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/route/')
2132
@environment.pass_env
22-
def cli(env, identifier, target, target_id):
33+
def cli(env, identifier, target, target_resource):
2334
"""Assigns the subnet to a target."""
2435

2536
mgr = SoftLayer.NetworkManager(env.client)
26-
mgr.route(identifier, target_types.get(target), target_id)
37+
route = mgr.route(identifier, target_types.get(target), target_resource)
38+
39+
if route:
40+
click.secho("Route updated successfully.")
41+
else:
42+
raise exceptions.CLIAbort('Failed to route the subnet.')

0 commit comments

Comments
 (0)