Created
November 6, 2016 21:33
-
-
Save jkapusi/96a725c784030d6340dad0cf75015edf to your computer and use it in GitHub Desktop.
Softlayer VM Location based pricing calculator
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
#!/bin/bash | |
for DC in "wdc04" "tok02" "ams03"; do | |
echo $DC | |
PARAMS="{ | |
'hostname': 'test', | |
'domain': 'example.com', | |
'datacenter': { 'name': '$DC' }, | |
'startCpus': 16, | |
'maxMemory': 16384, | |
'hourlyBillingFlag': true, | |
'localDiskFlag': true, | |
'blockDevices': [{'device': '0', 'diskImage': {'capacity': 25}}], | |
'networkComponents': [{'maxSpeed': 100}], | |
'operatingSystemReferenceCode': 'UBUNTU_LATEST' | |
}" | |
response=`echo '{"parameters":['$PARAMS']}' | tr "'" '"' | curl -s -X POST -d @- https://$SLUSERNAME:$SLAPIKEY@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/generateOrderTemplate.json` | |
# Standard price: | |
# echo $response | jq "[.prices[].hourlyRecurringFee] | map(tonumber) | add" | |
echo '{"parameters":['$response']}' | curl -s -X POST --data @- https://$SLUSERNAME:$SLAPIKEY@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json | jq -r .postTaxRecurringHourly | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment