Skip to content

Instantly share code, notes, and snippets.

@Apsu
Last active September 21, 2015 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apsu/c8b6ee0b2438c938aac7 to your computer and use it in GitHub Desktop.
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
#!/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