Skip to content

Instantly share code, notes, and snippets.

@andrewdmcleod
Created September 12, 2016 23:15
Show Gist options
  • Save andrewdmcleod/c4c429a5f1c82386852a64e316d35191 to your computer and use it in GitHub Desktop.
Save andrewdmcleod/c4c429a5f1c82386852a64e316d35191 to your computer and use it in GitHub Desktop.
juju status with public ips
#!/bin/bash
set -f; IFS=$'\n'
juju status --format=tabular|sed -n '1,/Machines/ p'
#juju status --format=tabular|sed '/\[Machines\]/q'
echo .
echo 'ID STATE VERSION PRIVATE-IP PUBLIC-IP INS-ID SERIES HARDWARE'
machines=$(juju status --format=tabular|grep arch)
for a in $machines
do
novaIP=$(nova list | grep $(echo $a|awk '{print $4}')|awk -F ',' '{print $2}'|tr -d ' ')
if [ "$novaIP" == "" ] ; then novaIP='no public ip' ; fi
echo $a|sed "s/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/\0|${novaIP}/g"
done
set +f; unset IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment