From 46722ca0bab0d0bb3aacd51d14fc02c33ee338b8 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 13:39:02 -0400 Subject: [PATCH 1/8] create dedicated host with gpu fixed. --- tests/CLI/modules/dedicatedhost_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CLI/modules/dedicatedhost_tests.py b/tests/CLI/modules/dedicatedhost_tests.py index ead835261..6c3ac4085 100644 --- a/tests/CLI/modules/dedicatedhost_tests.py +++ b/tests/CLI/modules/dedicatedhost_tests.py @@ -149,7 +149,7 @@ def test_create_options_get_routers(self): "Available Backend Routers": "bcr04a.dal05" } ]] - ) + ) def test_create(self): SoftLayer.CLI.formatting.confirm = mock.Mock() From d40d150912a625d9362d72fc9a7246db21bb43f4 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 13:40:41 -0400 Subject: [PATCH 2/8] create dedicated host with flavor gpu fixed. --- .../fixtures/SoftLayer_Product_Package.py | 107 +++++++++- SoftLayer/managers/dedicated_host.py | 48 ++++- tests/CLI/modules/dedicatedhost_tests.py | 184 +++++++++++------- 3 files changed, 257 insertions(+), 82 deletions(-) diff --git a/SoftLayer/fixtures/SoftLayer_Product_Package.py b/SoftLayer/fixtures/SoftLayer_Product_Package.py index deef58258..9b5d53741 100644 --- a/SoftLayer/fixtures/SoftLayer_Product_Package.py +++ b/SoftLayer/fixtures/SoftLayer_Product_Package.py @@ -666,7 +666,6 @@ ] } - SAAS_REST_PACKAGE = { 'categories': [ {'categoryCode': 'storage_as_a_service'} @@ -1133,12 +1132,14 @@ "bundleItems": [ { "capacity": "1200", + "keyName": "1_4_TB_LOCAL_STORAGE_DEDICATED_HOST_CAPACITY", "categories": [{ "categoryCode": "dedicated_host_disk" }] }, { "capacity": "242", + "keyName": "242_GB_RAM", "categories": [{ "categoryCode": "dedicated_host_ram" }] @@ -1218,6 +1219,110 @@ "description": "Dedicated Host" }] +getAllObjectsDHGpu = [{ + "subDescription": "Dedicated Host", + "name": "Dedicated Host", + "items": [{ + "capacity": "56", + "description": "56 Cores x 360 RAM x 1.2 TB x 2 GPU P100 [encryption enabled]", + "bundleItems": [ + { + "capacity": "1200", + "keyName": "1.2 TB Local Storage (Dedicated Host Capacity)", + "categories": [{ + "categoryCode": "dedicated_host_disk" + }] + }, + { + "capacity": "242", + "keyName": "2_GPU_P100_DEDICATED", + "hardwareGenericComponentModel": { + "capacity": "16", + "id": 849, + "hardwareComponentType": { + "id": 20, + "keyName": "GPU" + } + }, + "categories": [{ + "categoryCode": "dedicated_host_ram" + }] + } + ], + "prices": [ + { + "itemId": 10195, + "setupFee": "0", + "recurringFee": "2099", + "tierMinimumThreshold": "", + "hourlyRecurringFee": "3.164", + "oneTimeFee": "0", + "currentPriceFlag": "", + "id": 200269, + "sort": 0, + "onSaleFlag": "", + "laborFee": "0", + "locationGroupId": "", + "quantity": "" + }, + { + "itemId": 10195, + "setupFee": "0", + "recurringFee": "2161.97", + "tierMinimumThreshold": "", + "hourlyRecurringFee": "3.258", + "oneTimeFee": "0", + "currentPriceFlag": "", + "id": 200271, + "sort": 0, + "onSaleFlag": "", + "laborFee": "0", + "locationGroupId": 503, + "quantity": "" + } + ], + "keyName": "56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100", + "id": 10195, + "itemCategory": { + "categoryCode": "dedicated_virtual_hosts" + } + }], + "keyName": "DEDICATED_HOST", + "unitSize": "", + "regions": [{ + "location": { + "locationPackageDetails": [{ + "isAvailable": 1, + "locationId": 138124, + "packageId": 813 + }], + "location": { + "statusId": 2, + "priceGroups": [{ + "locationGroupTypeId": 82, + "description": "CDN - North America - Akamai", + "locationGroupType": { + "name": "PRICING" + }, + "securityLevelId": "", + "id": 1463, + "name": "NORTH-AMERICA-AKAMAI" + }], + "id": 138124, + "name": "dal05", + "longName": "Dallas 5" + } + }, + "keyname": "DALLAS05", + "description": "DAL05 - Dallas", + "sortOrder": 12 + }], + "firstOrderStepId": "", + "id": 813, + "isActive": 1, + "description": "Dedicated Host" +}] + getRegions = [{ "description": "WDC07 - Washington, DC", "keyname": "WASHINGTON07", diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index 6f6fe596c..38b905043 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -243,7 +243,8 @@ def _get_package(self): capacity, keyName, itemCategory[categoryCode], - bundleItems[capacity, categories[categoryCode]] + bundleItems[capacity, keyName, categories[categoryCode], hardwareGenericComponentModel[id, + hardwareComponentType[keyName]]] ], regions[location[location[priceGroups]]] ''' @@ -317,18 +318,49 @@ def _get_backend_router(self, locations, item): if category['categoryCode'] == 'dedicated_host_disk': disk_capacity = capacity['capacity'] + for hardwareComponent in item['bundleItems']: + if hardwareComponent['keyName'].find("GPU") != -1: + hardwareComponentModel = hardwareComponent['hardwareGenericComponentModel'] + hardwareGenericComponentModelId = hardwareComponentModel['id'] + hardwareComponentType = hardwareComponentModel['hardwareComponentType'] + hardwareComponentTypeKeyName = hardwareComponentType['keyName'] + if locations is not None: for location in locations: if location['locationId'] is not None: loc_id = location['locationId'] - host = { - 'cpuCount': cpu_count, - 'memoryCapacity': mem_capacity, - 'diskCapacity': disk_capacity, - 'datacenter': { - 'id': loc_id + if item['keyName'].find("GPU") == -1: + host = { + 'cpuCount': cpu_count, + 'memoryCapacity': mem_capacity, + 'diskCapacity': disk_capacity, + 'datacenter': { + 'id': loc_id + } + } + else: + host = { + 'cpuCount': cpu_count, + 'memoryCapacity': mem_capacity, + 'diskCapacity': disk_capacity, + 'datacenter': { + 'id': loc_id + }, + 'pciDevices': [ + {'hardwareComponentModel': + {'hardwareGenericComponentModel': + {'id': hardwareGenericComponentModelId, + 'hardwareComponentType': + {'keyName': hardwareComponentTypeKeyName}}} + }, + {'hardwareComponentModel': + {'hardwareGenericComponentModel': + {'id': hardwareGenericComponentModelId, + 'hardwareComponentType': + {'keyName': hardwareComponentTypeKeyName}}} + } + ] } - } routers = self.host.getAvailableRouters(host, mask=mask) return routers diff --git a/tests/CLI/modules/dedicatedhost_tests.py b/tests/CLI/modules/dedicatedhost_tests.py index 6c3ac4085..8a9a082ae 100644 --- a/tests/CLI/modules/dedicatedhost_tests.py +++ b/tests/CLI/modules/dedicatedhost_tests.py @@ -85,10 +85,10 @@ def test_details_no_owner(self): 'disk capacity': 1200, 'guest count': 1, 'guests': [{ - 'domain': 'Softlayer.com', - 'hostname': 'khnguyenDHI', - 'id': 43546081, - 'uuid': '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2'}], + 'domain': 'Softlayer.com', + 'hostname': 'khnguyenDHI', + 'id': 43546081, + 'uuid': '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2'}], 'id': 44701, 'memory capacity': 242, 'modify date': '2017-11-06T11:38:20-06:00', @@ -116,8 +116,8 @@ def test_create_options(self): '56 Cores X 242 RAM X 1.2 TB', 'value': '56_CORES_X_242_RAM_X_1_4_TB' } - ]] - ) + ]] + ) def test_create_options_with_only_datacenter(self): mock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects') @@ -137,16 +137,16 @@ def test_create_options_get_routers(self): self.assert_no_fail(result) self.assertEqual(json.loads(result.output), [[ { - "Available Backend Routers": "bcr01a.dal05" + 'Available Backend Routers': 'bcr01a.dal05' }, { - "Available Backend Routers": "bcr02a.dal05" + 'Available Backend Routers': 'bcr02a.dal05' }, { - "Available Backend Routers": "bcr03a.dal05" + 'Available Backend Routers': 'bcr03a.dal05' }, { - "Available Backend Routers": "bcr04a.dal05" + 'Available Backend Routers': 'bcr04a.dal05' } ]] ) @@ -166,24 +166,62 @@ def test_create(self): '--billing=hourly']) self.assert_no_fail(result) args = ({ - 'hardware': [{ - 'domain': 'example.com', - 'primaryBackendNetworkComponent': { - 'router': { - 'id': 51218 - } - }, - 'hostname': 'host' - }], - 'prices': [{ - 'id': 200269 - }], - 'location': 'DALLAS05', - 'packageId': 813, - 'complexType': - 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', - 'useHourlyPricing': True, - 'quantity': 1}, + 'hardware': [{ + 'domain': 'example.com', + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + }, + 'hostname': 'host' + }], + 'prices': [{ + 'id': 200269 + }], + 'location': 'DALLAS05', + 'packageId': 813, + 'complexType': + 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'useHourlyPricing': True, + 'quantity': 1}, + ) + + self.assert_called_with('SoftLayer_Product_Order', 'placeOrder', + args=args) + + def test_create_with_gpu(self): + SoftLayer.CLI.formatting.confirm = mock.Mock() + SoftLayer.CLI.formatting.confirm.return_value = True + mock_package_obj = self.set_mock('SoftLayer_Product_Package', + 'getAllObjects') + mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDHGpu + + result = self.run_command(['dedicatedhost', 'create', + '--hostname=host', + '--domain=example.com', + '--datacenter=dal05', + '--flavor=56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100', + '--billing=hourly']) + self.assert_no_fail(result) + args = ({ + 'hardware': [{ + 'domain': 'example.com', + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + }, + 'hostname': 'host' + }], + 'prices': [{ + 'id': 200269 + }], + 'location': 'DALLAS05', + 'packageId': 813, + 'complexType': + 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'useHourlyPricing': True, + 'quantity': 1}, ) self.assert_called_with('SoftLayer_Product_Order', 'placeOrder', @@ -207,22 +245,22 @@ def test_create_verify(self): self.assert_no_fail(result) args = ({ - 'useHourlyPricing': True, - 'hardware': [{ + 'useHourlyPricing': True, + 'hardware': [{ - 'hostname': 'host', - 'domain': 'example.com', + 'hostname': 'host', + 'domain': 'example.com', - 'primaryBackendNetworkComponent': { - 'router': { - 'id': 51218 - } - } - }], - 'packageId': 813, 'prices': [{'id': 200269}], - 'location': 'DALLAS05', - 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', - 'quantity': 1},) + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + } + }], + 'packageId': 813, 'prices': [{'id': 200269}], + 'location': 'DALLAS05', + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'quantity': 1},) self.assert_called_with('SoftLayer_Product_Order', 'verifyOrder', args=args) @@ -237,20 +275,20 @@ def test_create_verify(self): self.assert_no_fail(result) args = ({ - 'useHourlyPricing': True, - 'hardware': [{ - 'hostname': 'host', - 'domain': 'example.com', - 'primaryBackendNetworkComponent': { - 'router': { - 'id': 51218 - } - } - }], - 'packageId': 813, 'prices': [{'id': 200269}], - 'location': 'DALLAS05', - 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', - 'quantity': 1},) + 'useHourlyPricing': True, + 'hardware': [{ + 'hostname': 'host', + 'domain': 'example.com', + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + } + }], + 'packageId': 813, 'prices': [{'id': 200269}], + 'location': 'DALLAS05', + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'quantity': 1},) self.assert_called_with('SoftLayer_Product_Order', 'verifyOrder', args=args) @@ -306,22 +344,22 @@ def test_create_verify_no_price_or_more_than_one(self): self.assertIsInstance(result.exception, exceptions.ArgumentError) args = ({ - 'hardware': [{ - 'domain': 'example.com', - 'primaryBackendNetworkComponent': { - 'router': { - 'id': 51218 - } - }, - 'hostname': 'host' - }], - 'prices': [{ - 'id': 200269 - }], - 'location': 'DALLAS05', - 'packageId': 813, - 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', - 'useHourlyPricing': True, - 'quantity': 1},) + 'hardware': [{ + 'domain': 'example.com', + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + }, + 'hostname': 'host' + }], + 'prices': [{ + 'id': 200269 + }], + 'location': 'DALLAS05', + 'packageId': 813, + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'useHourlyPricing': True, + 'quantity': 1},) self.assert_called_with('SoftLayer_Product_Order', 'verifyOrder', args=args) From e40bd2e09031bbf3b7d72d81e8e750b6f6af37f4 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 15:13:05 -0400 Subject: [PATCH 3/8] create dedicated host with flavor gpu fixed. --- SoftLayer/managers/dedicated_host.py | 2 +- tests/managers/dedicated_host_tests.py | 58 +++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index 38b905043..a884f07e0 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -243,7 +243,7 @@ def _get_package(self): capacity, keyName, itemCategory[categoryCode], - bundleItems[capacity, keyName, categories[categoryCode], hardwareGenericComponentModel[id, + bundleItems[capacity,keyName,categories[categoryCode],hardwareGenericComponentModel[id, hardwareComponentType[keyName]]] ], regions[location[location[priceGroups]]] diff --git a/tests/managers/dedicated_host_tests.py b/tests/managers/dedicated_host_tests.py index d6ced1305..2f21edacf 100644 --- a/tests/managers/dedicated_host_tests.py +++ b/tests/managers/dedicated_host_tests.py @@ -133,6 +133,57 @@ def test_place_order(self): 'placeOrder', args=(values,)) + def test_place_order_with_gpu(self): + create_dict = self.dedicated_host._generate_create_dict = mock.Mock() + + values = { + 'hardware': [ + { + 'primaryBackendNetworkComponent': { + 'router': { + 'id': 51218 + } + }, + 'domain': u'test.com', + 'hostname': u'test' + } + ], + 'useHourlyPricing': True, + 'location': 'AMSTERDAM', + 'packageId': 813, + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'prices': [ + { + 'id': 200269 + } + ], + 'quantity': 1 + } + create_dict.return_value = values + + location = 'dal05' + hostname = 'test' + domain = 'test.com' + hourly = True + flavor = '56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100' + + self.dedicated_host.place_order(hostname=hostname, + domain=domain, + location=location, + flavor=flavor, + hourly=hourly) + + create_dict.assert_called_once_with(hostname=hostname, + router=None, + domain=domain, + datacenter=location, + flavor=flavor, + hourly=True) + + self.assert_called_with('SoftLayer_Product_Order', + 'placeOrder', + args=(values,)) + def test_verify_order(self): create_dict = self.dedicated_host._generate_create_dict = mock.Mock() @@ -286,7 +337,8 @@ def test_get_package(self): capacity, keyName, itemCategory[categoryCode], - bundleItems[capacity, categories[categoryCode]] + bundleItems[capacity,keyName,categories[categoryCode],hardwareGenericComponentModel[id, + hardwareComponentType[keyName]]] ], regions[location[location[priceGroups]]] ''' @@ -388,12 +440,14 @@ def test_get_item(self): item = { 'bundleItems': [{ 'capacity': '1200', + 'keyName': '1_4_TB_LOCAL_STORAGE_DEDICATED_HOST_CAPACITY', 'categories': [{ 'categoryCode': 'dedicated_host_disk' }] }, { 'capacity': '242', + 'keyName': '242_GB_RAM', 'categories': [{ 'categoryCode': 'dedicated_host_ram' }] @@ -517,6 +571,7 @@ def _get_package(self): "bundleItems": [ { "capacity": "1200", + "keyName": "1_4_TB_LOCAL_STORAGE_DEDICATED_HOST_CAPACITY", "categories": [ { "categoryCode": "dedicated_host_disk" @@ -525,6 +580,7 @@ def _get_package(self): }, { "capacity": "242", + "keyName": "242_GB_RAM", "categories": [ { "categoryCode": "dedicated_host_ram" From 18da115c353ec7f3bb3d4f58ffe9536027f840f1 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 17:49:22 -0400 Subject: [PATCH 4/8] create dedicated host with flavor gpu fixed. --- SoftLayer/managers/dedicated_host.py | 16 ++++++++-------- tests/CLI/modules/dedicatedhost_tests.py | 12 ++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index a884f07e0..aa281a7ac 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -348,16 +348,16 @@ def _get_backend_router(self, locations, item): }, 'pciDevices': [ {'hardwareComponentModel': - {'hardwareGenericComponentModel': - {'id': hardwareGenericComponentModelId, - 'hardwareComponentType': - {'keyName': hardwareComponentTypeKeyName}}} + {'hardwareGenericComponentModel': + {'id': hardwareGenericComponentModelId, + 'hardwareComponentType': + {'keyName': hardwareComponentTypeKeyName}}} }, {'hardwareComponentModel': - {'hardwareGenericComponentModel': - {'id': hardwareGenericComponentModelId, - 'hardwareComponentType': - {'keyName': hardwareComponentTypeKeyName}}} + {'hardwareGenericComponentModel': + {'id': hardwareGenericComponentModelId, + 'hardwareComponentType': + {'keyName': hardwareComponentTypeKeyName}}} } ] } diff --git a/tests/CLI/modules/dedicatedhost_tests.py b/tests/CLI/modules/dedicatedhost_tests.py index 8a9a082ae..59f6cab7c 100644 --- a/tests/CLI/modules/dedicatedhost_tests.py +++ b/tests/CLI/modules/dedicatedhost_tests.py @@ -180,11 +180,9 @@ def test_create(self): }], 'location': 'DALLAS05', 'packageId': 813, - 'complexType': - 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', 'useHourlyPricing': True, - 'quantity': 1}, - ) + 'quantity': 1},) self.assert_called_with('SoftLayer_Product_Order', 'placeOrder', args=args) @@ -218,11 +216,9 @@ def test_create_with_gpu(self): }], 'location': 'DALLAS05', 'packageId': 813, - 'complexType': - 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', + 'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost', 'useHourlyPricing': True, - 'quantity': 1}, - ) + 'quantity': 1},) self.assert_called_with('SoftLayer_Product_Order', 'placeOrder', args=args) From 8b9bcf09fccb96a9cab600d366fabcc6e1f11418 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 18:19:23 -0400 Subject: [PATCH 5/8] create dedicated host with flavor gpu fixed. --- SoftLayer/managers/dedicated_host.py | 34 +++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index aa281a7ac..b25e79a41 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -7,10 +7,10 @@ """ import logging -import SoftLayer -from SoftLayer.managers import ordering +import SoftLayer from SoftLayer import utils +from SoftLayer.managers import ordering # Invalid names are ignored due to long method names and short argument names # pylint: disable=invalid-name, no-self-use @@ -347,18 +347,26 @@ def _get_backend_router(self, locations, item): 'id': loc_id }, 'pciDevices': [ - {'hardwareComponentModel': - {'hardwareGenericComponentModel': - {'id': hardwareGenericComponentModelId, - 'hardwareComponentType': - {'keyName': hardwareComponentTypeKeyName}}} + { + 'hardwareComponentModel': { + 'hardwareGenericComponentModel': { + 'id': hardwareGenericComponentModelId, + 'hardwareComponentType': { + 'keyName': hardwareComponentTypeKeyName + } + } + } }, - {'hardwareComponentModel': - {'hardwareGenericComponentModel': - {'id': hardwareGenericComponentModelId, - 'hardwareComponentType': - {'keyName': hardwareComponentTypeKeyName}}} - } + { + 'hardwareComponentModel': { + 'hardwareGenericComponentModel': { + 'id': hardwareGenericComponentModelId, + 'hardwareComponentType': { + 'keyName': hardwareComponentTypeKeyName + } + } + } + } ] } routers = self.host.getAvailableRouters(host, mask=mask) From ccf3a368bffa5c16b020ab1bc0c096751a6a4948 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 18:26:00 -0400 Subject: [PATCH 6/8] create dedicated host with flavor gpu fixed. --- SoftLayer/managers/dedicated_host.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index b25e79a41..28ec9fe83 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -7,10 +7,10 @@ """ import logging - import SoftLayer -from SoftLayer import utils + from SoftLayer.managers import ordering +from SoftLayer import utils # Invalid names are ignored due to long method names and short argument names # pylint: disable=invalid-name, no-self-use From ad8ebaf47a1e77d9120e7bc59305f266996c35e5 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Thu, 23 Aug 2018 18:37:48 -0400 Subject: [PATCH 7/8] create dedicated host with flavor gpu fixed. --- SoftLayer/managers/dedicated_host.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index 28ec9fe83..7f0782117 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -356,7 +356,7 @@ def _get_backend_router(self, locations, item): } } } - }, + }, { 'hardwareComponentModel': { 'hardwareGenericComponentModel': { From ac9e28e29aba39b4ea4590220bd5478008040b90 Mon Sep 17 00:00:00 2001 From: Fernando Ojeda Date: Tue, 28 Aug 2018 11:34:27 -0400 Subject: [PATCH 8/8] Fixed create dedicated host issue. --- SoftLayer/managers/dedicated_host.py | 63 ++++++++++++---------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/SoftLayer/managers/dedicated_host.py b/SoftLayer/managers/dedicated_host.py index 7f0782117..6d3b6bb9d 100644 --- a/SoftLayer/managers/dedicated_host.py +++ b/SoftLayer/managers/dedicated_host.py @@ -320,17 +320,35 @@ def _get_backend_router(self, locations, item): for hardwareComponent in item['bundleItems']: if hardwareComponent['keyName'].find("GPU") != -1: - hardwareComponentModel = hardwareComponent['hardwareGenericComponentModel'] - hardwareGenericComponentModelId = hardwareComponentModel['id'] - hardwareComponentType = hardwareComponentModel['hardwareComponentType'] - hardwareComponentTypeKeyName = hardwareComponentType['keyName'] + hardwareComponentType = hardwareComponent['hardwareGenericComponentModel']['hardwareComponentType'] + gpuComponents = [ + { + 'hardwareComponentModel': { + 'hardwareGenericComponentModel': { + 'id': hardwareComponent['hardwareGenericComponentModel']['id'], + 'hardwareComponentType': { + 'keyName': hardwareComponentType['keyName'] + } + } + } + }, + { + 'hardwareComponentModel': { + 'hardwareGenericComponentModel': { + 'id': hardwareComponent['hardwareGenericComponentModel']['id'], + 'hardwareComponentType': { + 'keyName': hardwareComponentType['keyName'] + } + } + } + } + ] if locations is not None: for location in locations: if location['locationId'] is not None: loc_id = location['locationId'] - if item['keyName'].find("GPU") == -1: - host = { + host = { 'cpuCount': cpu_count, 'memoryCapacity': mem_capacity, 'diskCapacity': disk_capacity, @@ -338,37 +356,8 @@ def _get_backend_router(self, locations, item): 'id': loc_id } } - else: - host = { - 'cpuCount': cpu_count, - 'memoryCapacity': mem_capacity, - 'diskCapacity': disk_capacity, - 'datacenter': { - 'id': loc_id - }, - 'pciDevices': [ - { - 'hardwareComponentModel': { - 'hardwareGenericComponentModel': { - 'id': hardwareGenericComponentModelId, - 'hardwareComponentType': { - 'keyName': hardwareComponentTypeKeyName - } - } - } - }, - { - 'hardwareComponentModel': { - 'hardwareGenericComponentModel': { - 'id': hardwareGenericComponentModelId, - 'hardwareComponentType': { - 'keyName': hardwareComponentTypeKeyName - } - } - } - } - ] - } + if item['keyName'].find("GPU") != -1: + host['pciDevices'] = gpuComponents routers = self.host.getAvailableRouters(host, mask=mask) return routers