Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Code for calculating the precise price of hourly bare metal pre-set configurations
import os
import pprint
import SoftLayer
client = SoftLayer.Client(username=os.environ['SLUSERNAME'], api_key=os.environ['SLAPIKEY'], endpoint_url=SoftLayer.API_PUBLIC_ENDPOINT)
pkgId = 200
mask = 'id, description, keyName, totalMinimumRecurringFee, configuration, configuration.price.hourlyRecurringFee, configuration.price.item.keyName'
presets = client['Product_Package'].getActivePresets(id=pkgId, mask=mask)
# The totalMinimumHourlyFee returned is rounded to the nearest dollar (not very helpful). So we need to add up
# all of the fees of the item prices in the configuration of each preset.
for p in presets:
hourlyFee = 0
for c in p['configuration']:
hourlyFee += float(c['price']['hourlyRecurringFee'])
p['totalMinimumHourlyFee'] = hourlyFee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.