|
5 | 5 |
|
6 | 6 | import SoftLayer |
7 | 7 | from SoftLayer.CLI import environment |
8 | | -from SoftLayer.CLI import helpers |
9 | 8 |
|
| 9 | +target_types = {'vlan': 'SoftLayer_Network_Vlan', |
| 10 | + 'ip': 'SoftLayer_Network_Subnet_IpAddress', |
| 11 | + 'hardware': 'SoftLayer_Hardware_Server', |
| 12 | + 'vsi': 'SoftLayer_Virtual_Guest'} |
10 | 13 |
|
11 | | -@click.command() |
| 14 | + |
| 15 | +@click.command(epilog="More information about types and identifiers " |
| 16 | + "on https://sldn.softlayer.com/reference/services/SoftLayer_Network_Subnet/route/") |
12 | 17 | @click.argument('identifier') |
13 | | -@click.argument('target') |
| 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. ') |
14 | 21 | @environment.pass_env |
15 | | -def cli(env, identifier, target): |
16 | | - """Assigns the global IP to a target.""" |
| 22 | +def cli(env, identifier, target, target_id): |
| 23 | + """Assigns the subnet to a target.""" |
17 | 24 |
|
18 | 25 | mgr = SoftLayer.NetworkManager(env.client) |
19 | | - global_ip_id = helpers.resolve_id(mgr.resolve_global_ip_ids, identifier, |
20 | | - name='global ip') |
21 | | - mgr.assign_global_ip(global_ip_id, target) |
| 26 | + mgr.route(identifier, target_types.get(target), target_id) |
0 commit comments