Last active
September 21, 2015 16:06
-
-
Save Apsu/c8b6ee0b2438c938aac7 to your computer and use it in GitHub Desktop.
Create and associate Neutron floats with Nova instances that do not currently have floats
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
#!/usr/bin/env bash | |
if [[ $# -lt 1 ]] | |
then | |
echo "Usage: $0 <float_network>" | |
exit 1 | |
fi | |
declare -A floats | |
echo "Reading float mappings..." | |
while read float port | |
do | |
if [[ -n $port ]] | |
then | |
floats+=([$port]=$float) | |
fi | |
done < <(neutron floatingip-list -c id -c port_id -f csv --quote none | awk -F, 'NR>1 {print $1,$2}') | |
echo "Creating floats for instances as needed..." | |
for port in $(neutron port-list -c id -c device_owner -f csv --quote none | awk -F, '/compute:None/ {print $1}') | |
do | |
if [[ -z ${floats[$port]} ]] | |
then | |
echo "Creating float and associating with port: $port" | |
neutron floatingip-create --port-id $port $1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment