Skip to content

Commit 554bf7e

Browse files
committed
Subnet and Global IP commands now use resolve_id in order to ensure there's exactly one matching id
1 parent 6e149fa commit 554bf7e

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

SoftLayer/CLI/modules/globalip.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from SoftLayer import NetworkManager
1717
from SoftLayer.CLI import (
18-
CLIRunnable, Table, FormattedItem, confirm, no_going_back)
18+
CLIRunnable, Table, FormattedItem, confirm, no_going_back, resolve_id)
1919
from SoftLayer.CLI.helpers import CLIAbort, SequentialOutput
2020

2121

@@ -33,8 +33,9 @@ class GlobalIpAssign(CLIRunnable):
3333

3434
def execute(self, args):
3535
mgr = NetworkManager(self.client)
36-
37-
global_ip_id = mgr.resolve_global_ip_ids(args.get('<identifier>'))
36+
global_ip_id = resolve_id(mgr.resolve_global_ip_ids,
37+
args.get('<identifier>'),
38+
name='global ip')
3839
if not global_ip_id:
3940
raise CLIAbort("Unable to find global IP record for " +
4041
args['<identifier>'])
@@ -53,7 +54,9 @@ class GlobalIpCancel(CLIRunnable):
5354

5455
def execute(self, args):
5556
mgr = NetworkManager(self.client)
56-
global_ip_id = mgr.resolve_global_ip_ids(args.get('<identifier>'))
57+
global_ip_id = resolve_id(mgr.resolve_global_ip_ids,
58+
args.get('<identifier>'),
59+
name='global ip')(args.get('<identifier>'))
5760

5861
if args['--really'] or no_going_back(global_ip_id):
5962
mgr.cancel_global_ip(global_ip_id)
@@ -172,8 +175,9 @@ class GlobalIpUnassign(CLIRunnable):
172175

173176
def execute(self, args):
174177
mgr = NetworkManager(self.client)
175-
176-
global_ip_id = mgr.resolve_global_ip_ids(args.get('<identifier>'))
178+
global_ip_id = resolve_id(mgr.resolve_global_ip_ids,
179+
args.get('<identifier>'),
180+
name='global ip')
177181
if not global_ip_id:
178182
raise CLIAbort("Unable to find global IP record for " +
179183
args['<identifier>'])

SoftLayer/CLI/modules/subnet.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515

1616
from SoftLayer import NetworkManager
1717
from SoftLayer.CLI import (
18-
CLIRunnable, Table, KeyValueTable, FormattedItem, confirm, no_going_back)
18+
CLIRunnable, Table, KeyValueTable, FormattedItem, confirm, no_going_back,
19+
resolve_id)
1920
from SoftLayer.CLI.helpers import CLIAbort, SequentialOutput
2021

2122

@@ -31,7 +32,9 @@ class SubnetCancel(CLIRunnable):
3132

3233
def execute(self, args):
3334
mgr = NetworkManager(self.client)
34-
subnet_id = mgr.resolve_subnet_ids(args.get('<identifier>'))
35+
subnet_id = resolve_id(mgr.resolve_subnet_ids,
36+
args.get('<identifier>'),
37+
name='subnet')
3538

3639
if args['--really'] or no_going_back(subnet_id):
3740
mgr.cancel_subnet(subnet_id)
@@ -122,8 +125,9 @@ class SubnetDetail(CLIRunnable):
122125

123126
def execute(self, args):
124127
mgr = NetworkManager(self.client)
125-
126-
subnet_id = mgr.resolve_subnet_ids(args.get('<identifier>'))
128+
subnet_id = resolve_id(mgr.resolve_subnet_ids,
129+
args.get('<identifier>'),
130+
name='subnet')
127131
subnet = mgr.get_subnet(subnet_id)
128132

129133
t = KeyValueTable(['Name', 'Value'])

0 commit comments

Comments
 (0)