Skip to content

Commit ac9e28e

Browse files
author
Fernando Ojeda
committed
Fixed create dedicated host issue.
1 parent ad8ebaf commit ac9e28e

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

SoftLayer/managers/dedicated_host.py

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -320,55 +320,44 @@ def _get_backend_router(self, locations, item):
320320

321321
for hardwareComponent in item['bundleItems']:
322322
if hardwareComponent['keyName'].find("GPU") != -1:
323-
hardwareComponentModel = hardwareComponent['hardwareGenericComponentModel']
324-
hardwareGenericComponentModelId = hardwareComponentModel['id']
325-
hardwareComponentType = hardwareComponentModel['hardwareComponentType']
326-
hardwareComponentTypeKeyName = hardwareComponentType['keyName']
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+
]
327346

328347
if locations is not None:
329348
for location in locations:
330349
if location['locationId'] is not None:
331350
loc_id = location['locationId']
332-
if item['keyName'].find("GPU") == -1:
333-
host = {
351+
host = {
334352
'cpuCount': cpu_count,
335353
'memoryCapacity': mem_capacity,
336354
'diskCapacity': disk_capacity,
337355
'datacenter': {
338356
'id': loc_id
339357
}
340358
}
341-
else:
342-
host = {
343-
'cpuCount': cpu_count,
344-
'memoryCapacity': mem_capacity,
345-
'diskCapacity': disk_capacity,
346-
'datacenter': {
347-
'id': loc_id
348-
},
349-
'pciDevices': [
350-
{
351-
'hardwareComponentModel': {
352-
'hardwareGenericComponentModel': {
353-
'id': hardwareGenericComponentModelId,
354-
'hardwareComponentType': {
355-
'keyName': hardwareComponentTypeKeyName
356-
}
357-
}
358-
}
359-
},
360-
{
361-
'hardwareComponentModel': {
362-
'hardwareGenericComponentModel': {
363-
'id': hardwareGenericComponentModelId,
364-
'hardwareComponentType': {
365-
'keyName': hardwareComponentTypeKeyName
366-
}
367-
}
368-
}
369-
}
370-
]
371-
}
359+
if item['keyName'].find("GPU") != -1:
360+
host['pciDevices'] = gpuComponents
372361
routers = self.host.getAvailableRouters(host, mask=mask)
373362
return routers
374363

0 commit comments

Comments
 (0)