Skip to content

Commit 2758e33

Browse files
committed
exception when there is no prices was refactored
1 parent 23406bb commit 2758e33

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

SoftLayer/CLI/subnet/create.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,10 @@ def cli(env, network, quantity, vlan_id, ipv6, test):
4242
if ipv6:
4343
version = 6
4444

45-
result = mgr.add_subnet(network,
46-
quantity=quantity,
47-
vlan_id=vlan_id,
48-
version=version,
49-
test_order=test)
50-
if not result:
51-
raise exceptions.CLIAbort(
52-
'Unable to place order: No valid price IDs found.')
45+
try:
46+
result = mgr.add_subnet(network, quantity=quantity, vlan_id=vlan_id, version=version, test_order=test)
47+
except SoftLayer.SoftLayerAPIError:
48+
raise exceptions.CLIAbort('There is no price id for {} {} ipv{}'.format(quantity, network, version))
5349

5450
table = formatting.Table(['Item', 'cost'])
5551
table.align['Item'] = 'r'

SoftLayer/managers/network.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ def add_subnet(self, subnet_type, quantity=None, vlan_id=None, version=4,
150150
price_id = item['prices'][0]['id']
151151
break
152152

153-
if not price_id:
154-
raise TypeError('Invalid combination specified for ordering a'
155-
' subnet.')
156-
157153
order = {
158154
'packageId': 0,
159155
'prices': [{'id': price_id}],

0 commit comments

Comments
 (0)