From 2c98145b5eb2a322b5e03d6658d9536692c566ea Mon Sep 17 00:00:00 2001 From: caberos Date: Thu, 5 May 2022 17:31:06 -0400 Subject: [PATCH 1/3] fix issue on loadbal order command --- SoftLayer/CLI/loadbal/order.py | 4 +++- SoftLayer/managers/load_balancer.py | 2 +- tests/managers/loadbal_tests.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SoftLayer/CLI/loadbal/order.py b/SoftLayer/CLI/loadbal/order.py index 9df0af1cc..719fa48b7 100644 --- a/SoftLayer/CLI/loadbal/order.py +++ b/SoftLayer/CLI/loadbal/order.py @@ -41,8 +41,10 @@ def order(env, **args): """Creates a LB. Protocols supported are TCP, HTTP, and HTTPS.""" mgr = SoftLayer.LoadBalancerManager(env.client) + network = SoftLayer.NetworkManager(env.client) - location = args.get('datacenter') + datacenter = network.get_datacenter(args.get('datacenter')) + location = {'id': datacenter[0]['id']} name = args.get('name') description = args.get('label', None) diff --git a/SoftLayer/managers/load_balancer.py b/SoftLayer/managers/load_balancer.py index f7f4cedd5..ecd48dd59 100644 --- a/SoftLayer/managers/load_balancer.py +++ b/SoftLayer/managers/load_balancer.py @@ -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], diff --git a/tests/managers/loadbal_tests.py b/tests/managers/loadbal_tests.py index 7f580474a..fd231be78 100644 --- a/tests/managers/loadbal_tests.py +++ b/tests/managers/loadbal_tests.py @@ -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'} @@ -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']}], From 0bd0acd8d590a16ffef4979bd6ed599f90bd4010 Mon Sep 17 00:00:00 2001 From: caberos Date: Mon, 9 May 2022 14:24:52 -0400 Subject: [PATCH 2/3] fix the team code review comments --- SoftLayer/CLI/loadbal/order.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SoftLayer/CLI/loadbal/order.py b/SoftLayer/CLI/loadbal/order.py index 719fa48b7..823d974b2 100644 --- a/SoftLayer/CLI/loadbal/order.py +++ b/SoftLayer/CLI/loadbal/order.py @@ -43,8 +43,12 @@ def order(env, **args): mgr = SoftLayer.LoadBalancerManager(env.client) network = SoftLayer.NetworkManager(env.client) - datacenter = network.get_datacenter(args.get('datacenter')) - location = {'id': datacenter[0]['id']} + datacenter = network.get_datacenter(datacenter=args.get('datacenter')) + if datacenter: + location = {'id': datacenter[0]['id']} + else: + raise exceptions.CLIHalt('Missing the datacenter') + name = args.get('name') description = args.get('label', None) From 686fc74506688929651d8462050dddd5baa954fa Mon Sep 17 00:00:00 2001 From: Christopher Gallo Date: Tue, 10 May 2022 12:32:43 -0500 Subject: [PATCH 3/3] Update SoftLayer/CLI/loadbal/order.py --- SoftLayer/CLI/loadbal/order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoftLayer/CLI/loadbal/order.py b/SoftLayer/CLI/loadbal/order.py index 823d974b2..c73a2ae67 100644 --- a/SoftLayer/CLI/loadbal/order.py +++ b/SoftLayer/CLI/loadbal/order.py @@ -47,7 +47,7 @@ def order(env, **args): if datacenter: location = {'id': datacenter[0]['id']} else: - raise exceptions.CLIHalt('Missing the datacenter') + raise exceptions.CLIHalt('Datacenter {} was not found'.format(datacenter)) name = args.get('name') description = args.get('label', None)