|
5 | 5 |
|
6 | 6 | import SoftLayer |
7 | 7 | from SoftLayer.CLI import environment |
| 8 | +from SoftLayer.CLI import exceptions |
8 | 9 |
|
9 | 10 | target_types = {'vlan': 'SoftLayer_Network_Vlan', |
10 | 11 | 'ip': 'SoftLayer_Network_Subnet_IpAddress', |
|
17 | 18 | @click.argument('identifier') |
18 | 19 | @click.option('--target', type=click.Choice(['vlan', 'ip', 'hardware', 'vsi']), |
19 | 20 | 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/') |
21 | 32 | @environment.pass_env |
22 | | -def cli(env, identifier, target, target_id): |
| 33 | +def cli(env, identifier, target, target_resource): |
23 | 34 | """Assigns the subnet to a target.""" |
24 | 35 |
|
25 | 36 | 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