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
# | |
# List all the possible options for creating a VirtualGuest | |
# | |
curl https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/getCreateObjectOptions.json | python -mjson.tool | |
# | |
# Create a new VirtualGuest | |
# | |
curl -X POST --data @/tmp/post https://<user>:<api_key>@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject |
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
# | |
# grouping files of 2014-04-12-01.json format into one json per mday (2014-04-12) | |
# | |
distinct_dates=$(ls -l | awk '{print $9}' | awk -F "-" '{count[$1"-"$2"-"$3]++}END{for(j in count) print j}') | |
for i in $distinct_dates | |
do | |
echo "Grouping for $i month" | |
cat $i-*.json* > /tmp/$i.json | |
done |
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
fetch_s3_file() { | |
local bucket=$1 | |
local file_path=$2 | |
local iam_policy=$3 | |
local metadata_path="169.254.169.254/latest/meta-data/iam/security-credentials" | |
CREDENTIALS=$(curl http://$metadata_path/$iam_policy/) | |
key_id=$(echo $CREDENTIALS | jq '.AccessKeyId' | sed 's/"//g') | |
key_secret=$(echo $CREDENTIALS | jq '.SecretAccessKey' | sed 's/"//g') |
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 | |
ip_from_instance() { | |
echo $(aws ec2 describe-instances \ | |
--filters \ | |
"{\"Name\":\"tag:Name\", \"Values\":[\"$1\"]}" \ | |
"{\"Name\":\"instance-state-name\", \"Values\":[\"running\"]}" \ | |
--query='Reservations[0].Instances[0].PublicIpAddress' | tr -d '"') | |
} |