Last active
August 29, 2015 14:27
-
-
Save bmpotter/f7791ab08819eafc93e0 to your computer and use it in GitHub Desktop.
Code for calculating the precise price of hourly bare metal pre-set configurations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
# http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getActivePresets | |
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 | |
pprint.pprint(presets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment