Skip to content

Instantly share code, notes, and snippets.

@j05h
Created April 4, 2013 11:28
Show Gist options
  • Save j05h/5309643 to your computer and use it in GitHub Desktop.
Save j05h/5309643 to your computer and use it in GitHub Desktop.
If you want to generate a hosts file with OpenStack nova, this little gem should set you straight. The last little bit pulls out any instances which don't have a private IP. In this case, we're assuming that our subnet begins with '10'. Feel free to change for whatever else you like.
$ nova list | awk 'BEGIN {FS="[|=,]"} {gsub(/[[:space:]]+/,"",$3);gsub(/[[:space:]]+/,"",$6); print $6" "$3}' | tail -n +3 | grep 10
10.1.1.141 Server2592
10.1.1.136 Server2598
10.1.1.140 Server2599
10.1.1.138 Server2600
10.1.1.143 Server2601
10.1.1.147 Server2602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment