Skip to content

Commit d28da2d

Browse files
Merge pull request #1025 from FernandoOjeda/fo_create_dedicated_host_with_gpu
create dedicated host with gpu
2 parents 1765af9 + ac9e28e commit d28da2d

File tree

4 files changed

+308
-84
lines changed

4 files changed

+308
-84
lines changed

SoftLayer/fixtures/SoftLayer_Product_Package.py

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@
666666
]
667667
}
668668

669-
670669
SAAS_REST_PACKAGE = {
671670
'categories': [
672671
{'categoryCode': 'storage_as_a_service'}
@@ -1133,12 +1132,14 @@
11331132
"bundleItems": [
11341133
{
11351134
"capacity": "1200",
1135+
"keyName": "1_4_TB_LOCAL_STORAGE_DEDICATED_HOST_CAPACITY",
11361136
"categories": [{
11371137
"categoryCode": "dedicated_host_disk"
11381138
}]
11391139
},
11401140
{
11411141
"capacity": "242",
1142+
"keyName": "242_GB_RAM",
11421143
"categories": [{
11431144
"categoryCode": "dedicated_host_ram"
11441145
}]
@@ -1218,6 +1219,110 @@
12181219
"description": "Dedicated Host"
12191220
}]
12201221

1222+
getAllObjectsDHGpu = [{
1223+
"subDescription": "Dedicated Host",
1224+
"name": "Dedicated Host",
1225+
"items": [{
1226+
"capacity": "56",
1227+
"description": "56 Cores x 360 RAM x 1.2 TB x 2 GPU P100 [encryption enabled]",
1228+
"bundleItems": [
1229+
{
1230+
"capacity": "1200",
1231+
"keyName": "1.2 TB Local Storage (Dedicated Host Capacity)",
1232+
"categories": [{
1233+
"categoryCode": "dedicated_host_disk"
1234+
}]
1235+
},
1236+
{
1237+
"capacity": "242",
1238+
"keyName": "2_GPU_P100_DEDICATED",
1239+
"hardwareGenericComponentModel": {
1240+
"capacity": "16",
1241+
"id": 849,
1242+
"hardwareComponentType": {
1243+
"id": 20,
1244+
"keyName": "GPU"
1245+
}
1246+
},
1247+
"categories": [{
1248+
"categoryCode": "dedicated_host_ram"
1249+
}]
1250+
}
1251+
],
1252+
"prices": [
1253+
{
1254+
"itemId": 10195,
1255+
"setupFee": "0",
1256+
"recurringFee": "2099",
1257+
"tierMinimumThreshold": "",
1258+
"hourlyRecurringFee": "3.164",
1259+
"oneTimeFee": "0",
1260+
"currentPriceFlag": "",
1261+
"id": 200269,
1262+
"sort": 0,
1263+
"onSaleFlag": "",
1264+
"laborFee": "0",
1265+
"locationGroupId": "",
1266+
"quantity": ""
1267+
},
1268+
{
1269+
"itemId": 10195,
1270+
"setupFee": "0",
1271+
"recurringFee": "2161.97",
1272+
"tierMinimumThreshold": "",
1273+
"hourlyRecurringFee": "3.258",
1274+
"oneTimeFee": "0",
1275+
"currentPriceFlag": "",
1276+
"id": 200271,
1277+
"sort": 0,
1278+
"onSaleFlag": "",
1279+
"laborFee": "0",
1280+
"locationGroupId": 503,
1281+
"quantity": ""
1282+
}
1283+
],
1284+
"keyName": "56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100",
1285+
"id": 10195,
1286+
"itemCategory": {
1287+
"categoryCode": "dedicated_virtual_hosts"
1288+
}
1289+
}],
1290+
"keyName": "DEDICATED_HOST",
1291+
"unitSize": "",
1292+
"regions": [{
1293+
"location": {
1294+
"locationPackageDetails": [{
1295+
"isAvailable": 1,
1296+
"locationId": 138124,
1297+
"packageId": 813
1298+
}],
1299+
"location": {
1300+
"statusId": 2,
1301+
"priceGroups": [{
1302+
"locationGroupTypeId": 82,
1303+
"description": "CDN - North America - Akamai",
1304+
"locationGroupType": {
1305+
"name": "PRICING"
1306+
},
1307+
"securityLevelId": "",
1308+
"id": 1463,
1309+
"name": "NORTH-AMERICA-AKAMAI"
1310+
}],
1311+
"id": 138124,
1312+
"name": "dal05",
1313+
"longName": "Dallas 5"
1314+
}
1315+
},
1316+
"keyname": "DALLAS05",
1317+
"description": "DAL05 - Dallas",
1318+
"sortOrder": 12
1319+
}],
1320+
"firstOrderStepId": "",
1321+
"id": 813,
1322+
"isActive": 1,
1323+
"description": "Dedicated Host"
1324+
}]
1325+
12211326
getRegions = [{
12221327
"description": "WDC07 - Washington, DC",
12231328
"keyname": "WASHINGTON07",

SoftLayer/managers/dedicated_host.py

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def _get_package(self):
243243
capacity,
244244
keyName,
245245
itemCategory[categoryCode],
246-
bundleItems[capacity, categories[categoryCode]]
246+
bundleItems[capacity,keyName,categories[categoryCode],hardwareGenericComponentModel[id,
247+
hardwareComponentType[keyName]]]
247248
],
248249
regions[location[location[priceGroups]]]
249250
'''
@@ -317,18 +318,46 @@ def _get_backend_router(self, locations, item):
317318
if category['categoryCode'] == 'dedicated_host_disk':
318319
disk_capacity = capacity['capacity']
319320

321+
for hardwareComponent in item['bundleItems']:
322+
if hardwareComponent['keyName'].find("GPU") != -1:
323+
hardwareComponentType = hardwareComponent['hardwareGenericComponentModel']['hardwareComponentType']
324+
gpuComponents = [
325+
{
326+
'hardwareComponentModel': {
327+
'hardwareGenericComponentModel': {
328+
'id': hardwareComponent['hardwareGenericComponentModel']['id'],
329+
'hardwareComponentType': {
330+
'keyName': hardwareComponentType['keyName']
331+
}
332+
}
333+
}
334+
},
335+
{
336+
'hardwareComponentModel': {
337+
'hardwareGenericComponentModel': {
338+
'id': hardwareComponent['hardwareGenericComponentModel']['id'],
339+
'hardwareComponentType': {
340+
'keyName': hardwareComponentType['keyName']
341+
}
342+
}
343+
}
344+
}
345+
]
346+
320347
if locations is not None:
321348
for location in locations:
322349
if location['locationId'] is not None:
323350
loc_id = location['locationId']
324351
host = {
325-
'cpuCount': cpu_count,
326-
'memoryCapacity': mem_capacity,
327-
'diskCapacity': disk_capacity,
328-
'datacenter': {
329-
'id': loc_id
352+
'cpuCount': cpu_count,
353+
'memoryCapacity': mem_capacity,
354+
'diskCapacity': disk_capacity,
355+
'datacenter': {
356+
'id': loc_id
357+
}
330358
}
331-
}
359+
if item['keyName'].find("GPU") != -1:
360+
host['pciDevices'] = gpuComponents
332361
routers = self.host.getAvailableRouters(host, mask=mask)
333362
return routers
334363

0 commit comments

Comments
 (0)