Skip to content

Instantly share code, notes, and snippets.

@jhanley-com
Created August 7, 2020 02:37
Show Gist options
  • Save jhanley-com/fdd5d49556505f1b0cc5aa89d83db483 to your computer and use it in GitHub Desktop.
Save jhanley-com/fdd5d49556505f1b0cc5aa89d83db483 to your computer and use it in GitHub Desktop.
APIKEY='your_cloud_api_key'
URI='https://clients.hostwinds.com/cloud/api.php'
FILENAME='instances.json'
if [ -f $FILENAME ];
then
rm $FILENAME
fi
curl $URI \
-sS \
-X POST \
-d "action=get_instances&API=$APIKEY" > $FILENAME
status=$?
if test $status -eq 0
then
# Print instance names
echo "Instances"
echo "IP OS ServerName Hostname"
echo "----------------------------------------------------------------------"
cat $FILENAME | jq -r ".success | .[] | [.main_ip, .image.name, .srvrname, .hostname] | @tsv" 2>error.log
status=$?
if test $status -eq 0
then
echo
echo "------------------------------"
echo Success
else
echo Failed
cat $FILENAME | jq
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment