Created
August 12, 2016 08:05
-
-
Save aojea/60bc52daeb66e0d22fe97a14922aeeee to your computer and use it in GitHub Desktop.
Midonet automatic tunnel zone
This file contains hidden or 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
#!/bin/bash | |
midonet-cli -e "list host" > /tmp/midonet-hosts.list | |
if midonet-cli -e list tunnel-zone 2>&1 | grep tz | |
then | |
TZONE0=$(midonet-cli -e list tunnel-zone | awk '{ print $2 }') | |
else | |
TZONE0=$(midonet-cli -e "tunnel-zone create name tz type vxlan") | |
fi | |
# This regex takes all the 10.0.X.X addresses, change it to switch your needs | |
regex="host[[:space:]]([A-Za-z0-9._%+-]+).*(10\.0\.[0-9]{1,3}\.[0-9]{1,3})" | |
while read line | |
do if [[ $line =~ $regex ]] | |
then | |
HOST_ID=${BASH_REMATCH[1]} | |
HOST_IP=${BASH_REMATCH[2]} | |
midonet-cli -e "tunnel-zone $TZONE0 add member host $HOST_ID address $HOST_IP" | |
fi | |
done < /tmp/midonet-hosts.list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment