Skip to content

Commit ed734ec

Browse files
Merge pull request #1633 from caberos/issue1632
fix issue on loadbal order command
2 parents 06cd4ae + 686fc74 commit ed734ec

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

SoftLayer/CLI/loadbal/order.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ def order(env, **args):
4141
"""Creates a LB. Protocols supported are TCP, HTTP, and HTTPS."""
4242

4343
mgr = SoftLayer.LoadBalancerManager(env.client)
44+
network = SoftLayer.NetworkManager(env.client)
45+
46+
datacenter = network.get_datacenter(datacenter=args.get('datacenter'))
47+
if datacenter:
48+
location = {'id': datacenter[0]['id']}
49+
else:
50+
raise exceptions.CLIHalt('Datacenter {} was not found'.format(datacenter))
4451

45-
location = args.get('datacenter')
4652
name = args.get('name')
4753
description = args.get('label', None)
4854

SoftLayer/managers/load_balancer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def order_lbaas(self, datacenter, name, desc, protocols, subnet_id, public=False
245245
'complexType': 'SoftLayer_Container_Product_Order_Network_LoadBalancer_AsAService',
246246
'name': name,
247247
'description': desc,
248-
'location': datacenter,
248+
'locationObject': datacenter,
249249
'packageId': package.get('id'),
250250
'useHourlyPricing': True, # Required since LBaaS is an hourly service
251251
'prices': [{'id': price_id} for price_id in prices],

tests/managers/loadbal_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_remove_lb_listener(self):
143143
args=(uuid, [listener]))
144144

145145
def test_order_lbaas(self):
146-
datacenter = 'tes01'
146+
datacenter = {'id': 1854895}
147147
name = 'test-lb'
148148
desc = 'my lb'
149149
protocols = {'frontendPort': 80, 'frontendProtocol': 'HTTP'}
@@ -174,7 +174,7 @@ def test_order_lbaas(self):
174174
'complexType': 'SoftLayer_Container_Product_Order_Network_LoadBalancer_AsAService',
175175
'name': name,
176176
'description': desc,
177-
'location': datacenter,
177+
'locationObject': {'id': 1854895},
178178
'packageId': package[0]['id'],
179179
'useHourlyPricing': True, # Required since LBaaS is an hourly service
180180
'prices': [{'id': package[0]['itemPrices'][0]['id']}],

0 commit comments

Comments
 (0)