Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue on loadbal order command #1633

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion SoftLayer/CLI/loadbal/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ def order(env, **args):
"""Creates a LB. Protocols supported are TCP, HTTP, and HTTPS."""

mgr = SoftLayer.LoadBalancerManager(env.client)
network = SoftLayer.NetworkManager(env.client)

datacenter = network.get_datacenter(datacenter=args.get('datacenter'))
if datacenter:
location = {'id': datacenter[0]['id']}
else:
raise exceptions.CLIHalt('Datacenter {} was not found'.format(datacenter))

location = args.get('datacenter')
name = args.get('name')
description = args.get('label', None)

Expand Down
2 changes: 1 addition & 1 deletion SoftLayer/managers/load_balancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def order_lbaas(self, datacenter, name, desc, protocols, subnet_id, public=False
'complexType': 'SoftLayer_Container_Product_Order_Network_LoadBalancer_AsAService',
'name': name,
'description': desc,
'location': datacenter,
'locationObject': datacenter,
'packageId': package.get('id'),
'useHourlyPricing': True, # Required since LBaaS is an hourly service
'prices': [{'id': price_id} for price_id in prices],
Expand Down
4 changes: 2 additions & 2 deletions tests/managers/loadbal_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_remove_lb_listener(self):
args=(uuid, [listener]))

def test_order_lbaas(self):
datacenter = 'tes01'
datacenter = {'id': 1854895}
name = 'test-lb'
desc = 'my lb'
protocols = {'frontendPort': 80, 'frontendProtocol': 'HTTP'}
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_order_lbaas(self):
'complexType': 'SoftLayer_Container_Product_Order_Network_LoadBalancer_AsAService',
'name': name,
'description': desc,
'location': datacenter,
'locationObject': {'id': 1854895},
'packageId': package[0]['id'],
'useHourlyPricing': True, # Required since LBaaS is an hourly service
'prices': [{'id': package[0]['itemPrices'][0]['id']}],
Expand Down