Last active
November 2, 2018 11:09
-
-
Save mungi/861cd915bada872272577f08467efaef to your computer and use it in GitHub Desktop.
slcli call-api examples
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
slcli call-api Account getHardware --offset=0 --limit=20 --mask=id,hostname,tagReferences.tag.name | |
slcli --format=json call-api Account getVirtualGuests --mask="id,maxCpu,maxMemory,hostname,billingItem[id,orderItem[id,order[id,userRecord[id,username]]]]" | |
slcli call-api Account getVirtualGuests --mask="id,maxCpu,maxMemory,hostname,billingItem[id,orderItem[id,order[id,userRecord[id,username]]]]" | |
slcli --format=json call-api Account getHardware --mask="id,processorPhysicalCoreAmount,memoryCapacity,hostname,billingItem[id,orderItem[id,order[id,userRecord[id,username]]]]" | |
slcli --format json call-api Account getHardware --mask=id,fullyQualifiedDomainName,operatingSystem.passwords.password | |
slcli call-api Account getHardware --mask="id,processorPhysicalCoreAmount,memoryCapacity,hostname,billingItem[id,orderItem[id,order[id,userRecord[id,username]]]]" | |
slcli call-api Account getVirtualDedicatedRacks --mask="id,name,metricTrackingObjectId" | |
# get IPMI connection info | |
slcli --format raw call-api Account getHardware --mask="mask[networkManagementIpAddress,remoteManagementAccounts[username,password],id,fullyQualifiedDomainName]" | |
#Get Bandwidth Pool Usage | |
slcli call-api Account getBandwidthAllotments --filter "bandwidthAllotments.bandwidthAllotmentTypeId=2" --mask="id, name, hardwareCount, virtualGuestCount, totalBandwidthAllocated, outboundPublicBandwidthUsage, bandwidthAllotmentTypeId, projectedPublicBandwidthUsage" | |
:..........................:...............:........:...................:..............................:...............................:.........................:...................: | |
: bandwidthAllotmentTypeId : hardwareCount : id : name : outboundPublicBandwidthUsage : projectedPublicBandwidthUsage : totalBandwidthAllocated : virtualGuestCount : | |
:..........................:...............:........:...................:..............................:...............................:.........................:...................: | |
: 2 : 150 : 621111 : KOR-XXX-Pool : 4688039.27267 : 6613230.78 : 7200000 : 210 : | |
: 2 : 70 : 632222 : HKG-XXX-Pool : 613715.03632 : 1219887.25 : 1881159 : 78 : | |
:..........................:...............:........:...................:..............................:...............................:.........................:...................: | |
#Pool outbound using Metric Tracking | |
POOLNAME="KOR-XXX-Pool" | |
START=$(date +%Y-%m-01T00:00:00-05:00) | |
TODAY=$(date -Iseconds) | |
TID=$(slcli call-api Account getVirtualDedicatedRacks --mask="id,name,metricTrackingObjectId" | grep $POOLNAME | awk '{print $2}') | |
OUTBW=$(slcli call-api Metric_Tracking_Object getBandwidthTotal --id=$TID $START $TODAY "OUT" "PUBLIC") | |
numfmt --to=iec --suffix=B $OUTBW | |
curl -u $SL_USER:$SL_APIKEY -X GET 'https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getHardware.json?objectMask=mask%28SoftLayer_Hardware_Server%29%5BactiveTransaction%5Bid%2C+transactio nStatus%5Bname%2C+friendlyName%5D%5D%2Chostname%2CprimaryIpAddress%2Cdatacenter.name%2CprimaryBackendIpAddress%2Cid%5D&resultLimit=0%2C100' | |
curl -u $SL_USER:$SL_APIKEY -X POST -d '{"parameters": ["FORCE", {}]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Hardware_Server/1602345/reloadOperatingSystem.json' | |
curl -u $SL_USER:$SL_APIKEY -X POST -d '{"parameters": ["FORCE", "{upgradeBios: 1, customProvisionScriptUri: https://raw.githubusercontent.com/mungi/gist/master/pv-cent.sh}"]}' 'https://api.softlayer.com/rest/v3.1/SoftLayer_Hardware_Server/1703483/reloadOperatingSystem.json' |
Author
mungi
commented
Nov 2, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment