Skip to content

Commit 357ba70

Browse files
caberoscaberos
authored andcommitted
Update global ip assign/unassign to use new API
1 parent 51b594e commit 357ba70

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

SoftLayer/CLI/globalip/assign.py

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

66
import SoftLayer
77
from SoftLayer.CLI import environment
8-
from SoftLayer.CLI import helpers
98

109

11-
@click.command()
10+
@click.command(epilog="More information about types and ")
1211
@click.argument('identifier')
13-
@click.argument('target')
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')
1416
@environment.pass_env
15-
def cli(env, identifier, target):
17+
def cli(env, identifier, target, router):
1618
"""Assigns the global IP to a target."""
1719

1820
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)
21+
mgr.route(identifier, target, router)

SoftLayer/fixtures/SoftLayer_Network_Subnet.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
editNote = True
4545
setTags = True
4646
cancel = True
47+
route = True

SoftLayer/managers/network.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,3 +824,13 @@ def get_closed_pods(self):
824824
mask = """mask[name, datacenterLongName, frontendRouterId, capabilities, datacenterId, backendRouterId,
825825
backendRouterName, frontendRouterName]"""
826826
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', mask=mask, filter=closing_filter)
827+
828+
def route(self, subnet_id, type_serv, target):
829+
"""Assigns a global IP address to a specified target.
830+
831+
:param int subnet_id: The ID of the global IP being assigned
832+
:param string type_serv: The type service to assign
833+
:param string target: The instance to assign
834+
"""
835+
return self.client.call('SoftLayer_Network_Subnet', 'route',
836+
type_serv, target, id=subnet_id, )

tests/CLI/modules/globalip_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class DnsTests(testing.TestCase):
1616

1717
def test_ip_assign(self):
18-
result = self.run_command(['globalip', 'assign', '1', '127.0.0.1'])
18+
result = self.run_command(['globalip', 'assign', '1'])
1919

2020
self.assert_no_fail(result)
2121
self.assertEqual(result.output, "")

tests/managers/network_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,7 @@ def test_vlan_edit(self):
628628
def test_get_all_pods(self):
629629
self.network.get_pods()
630630
self.assert_called_with('SoftLayer_Network_Pod', 'getAllObjects')
631+
632+
def test_route(self):
633+
self.network.route('SoftLayer_Hardware_Server', 123456, 100)
634+
self.assert_called_with('SoftLayer_Network_Subnet', 'route')

0 commit comments

Comments
 (0)