Last active
August 29, 2015 14:08
-
-
Save freyes/c05fe90553a6dd8c19a6 to your computer and use it in GitHub Desktop.
Allow a vip to float across ports, this is needed when you configure a vip for corosync
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
#!/bin/bash -e | |
# Usage exmaple: | |
# ./prepare-vip.sh 10.5.0.107 port1,port2,port3 foo_net | |
# | |
# This will prepare the vip 10.5.0.107 to be used by machines in ports `port1`, `port2` and `port3` | |
# in the the next `foo_net`0 | |
PROG=$0 | |
VIP="$1" | |
PORTS="$2" | |
PRIV_NET=${3:-"freyes_admin_net"} | |
function die() { | |
local exit_code=$1 | |
local msg=${2:-"error message"} | |
echo "$msg" >&2 | |
echo "Usage:" >&2 | |
echo " $PROG <VIP> <PORTS> [PRIV_NET]" | |
exit $exit_code | |
} | |
if [ "x$VIP" == "x" ]; then | |
die 1 "please set VIP" | |
fi | |
if [ "x$PORTS" == "x" ]; then | |
die 1 "please set PORTS" | |
fi | |
l="" | |
for p in $(echo $VIP | tr ',' "\n"); do | |
neutron port-create --fixed-ip ip_address=$p --security-group default $PRIV_NET || echo "skip port already created for $p" | |
l="$l ip_address=$p" | |
done | |
for PORT in $(echo $PORTS | tr ',' "\n"); do | |
neutron port-update $PORT --allowed_address_pairs list=true type=dict $l | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment