Skip to content
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
107 changes: 106 additions & 1 deletion SoftLayer/fixtures/SoftLayer_Product_Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@
]
}


SAAS_REST_PACKAGE = {
'categories': [
{'categoryCode': 'storage_as_a_service'}
Expand Down Expand Up @@ -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"
}]
Expand Down Expand Up @@ -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",
Expand Down
43 changes: 36 additions & 7 deletions SoftLayer/managers/dedicated_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]
'''
Expand Down Expand Up @@ -317,18 +318,46 @@ 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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating 4 variables, it would makes sense to do something like this:

gpuComponent =  {
                                    'hardwareComponentModel': {
                                        'hardwareGenericComponentModel': {
                                            'id': hardwareGenericComponentModelId,
                                            'hardwareComponentType': {
                                                'keyName': hardwareComponentTypeKeyName
                                            }
                                        }
                                    }
                                },
                                {
                                    'hardwareComponentModel': {
                                        'hardwareGenericComponentModel': {
                                            'id': hardwareGenericComponentModelId,
                                            'hardwareComponentType': {
                                                'keyName': hardwareComponentTypeKeyName
                                            }
                                        }
                                    }
                                }

Then just use gpuComponent further down.

Copy link
Contributor Author

@FernandoOjeda FernandoOjeda Aug 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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']
host = {
'cpuCount': cpu_count,
'memoryCapacity': mem_capacity,
'diskCapacity': disk_capacity,
'datacenter': {
'id': loc_id
'cpuCount': cpu_count,
'memoryCapacity': mem_capacity,
'diskCapacity': disk_capacity,
'datacenter': {
'id': loc_id
}
}
}
if item['keyName'].find("GPU") != -1:
host['pciDevices'] = gpuComponents
routers = self.host.getAvailableRouters(host, mask=mask)
return routers

Expand Down
Loading