Skip to content

Instantly share code, notes, and snippets.

@keithchambers
Created January 9, 2015 06:50
Show Gist options
  • Save keithchambers/cfca81f0f7936a45a9d1 to your computer and use it in GitHub Desktop.
Save keithchambers/cfca81f0f7936a45a9d1 to your computer and use it in GitHub Desktop.
Get OpenStack instances with specific image prefix
#!/bin/bash
PREFIX="centos"
STATUS="ACTIVE"
INSTANCES="$(nova list | awk -v status="$STATUS" '$6 == status { print $4 }')"
for INSTANCE in $INSTANCES; do
IMAGE="$(nova show "$INSTANCE" | awk -v prefix=$PREFIX '$2 == "image" && $4 ~ "^"prefix { print $4 }')"
echo "$INSTANCE" "$IMAGE"
done
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment