|
6 | 6 | import SoftLayer |
7 | 7 | from SoftLayer.CLI import environment |
8 | 8 |
|
| 9 | +target_types = {'vlan': 'SoftLayer_Network_Vlan', |
| 10 | + 'ip': 'SoftLayer_Network_Subnet_IpAddress', |
| 11 | + 'hardware': 'SoftLayer_Hardware_Server', |
| 12 | + 'vsi': 'SoftLayer_Virtual_Guest'} |
9 | 13 |
|
10 | | -@click.command(epilog="More information about types and ") |
| 14 | + |
| 15 | +@click.command(epilog="More information about types and identifiers " |
| 16 | + "on https://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/route/") |
11 | 17 | @click.argument('identifier') |
12 | | -@click.option('--target', |
13 | | - help='See SLDN docs. ' |
14 | | - 'E.g SoftLayer_Network_Subnet_IpAddress, SoftLayer_Hardware_Server,SoftLayer_Virtual_Guest') |
15 | | -@click.option('--router', help='An appropriate identifier for the specified $type. Some types have multiple identifier') |
| 18 | +@click.option('--target', type=click.Choice(['vlan', 'ip', 'hardware', 'vsi']), |
| 19 | + 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. ') |
16 | 21 | @environment.pass_env |
17 | | -def cli(env, identifier, target, router): |
18 | | - """Assigns the global IP to a target.""" |
| 22 | +def cli(env, identifier, target, target_id): |
| 23 | + """Assigns the subnet to a target.""" |
19 | 24 |
|
20 | 25 | mgr = SoftLayer.NetworkManager(env.client) |
21 | | - mgr.route(identifier, target, router) |
| 26 | + mgr.route(identifier, target_types.get(target), target_id) |
0 commit comments