Fix shellscript for gateway static
Change-Id: I40001520f6175aa31bde51a33a7b13685d83ffcc
This commit is contained in:
parent
28c122ab6f
commit
195d3799cc
@ -93,7 +93,7 @@ class midonet::gateway::static (
|
||||
$uplink_script = 'create_fake_uplink_l2.sh',
|
||||
$ensure_scripts = 'present',
|
||||
$hostname = $::hostname,
|
||||
$masquerade = true
|
||||
$masquerade = 'on'
|
||||
) {
|
||||
|
||||
# Place script and helper files before executing it
|
||||
|
@ -23,14 +23,14 @@ EDGE_ROUTER=<%= @edge_router %>
|
||||
VETH0_IP=<%= @veth0_ip %>
|
||||
VETH1_IP=<%= @veth1_ip %>
|
||||
VETH_NETWORK=<%= @veth_network %>
|
||||
HOSTNAME=<% @hostname %>
|
||||
MASQUERADE_ON= <% @masquerade %>
|
||||
HOSTNAME=<%= @hostname %>
|
||||
MASQUERADE_ON=<%= @masquerade %>
|
||||
|
||||
HOST_ID=$(midonet-cli -A -e host list | grep ${HOSTNAME} | awk '{ print $2 }')
|
||||
BINDING=$(midonet-cli -A -e host ${HOST_ID} list binding interface veth1)
|
||||
|
||||
# Create veth pair
|
||||
if [ -z "$(ip l | /bin/grep -e veth0 -e veth)"]; then
|
||||
if [ -z "$(ip l | /bin/grep -e veth0 -e veth)" ]; then
|
||||
ip link add type veth
|
||||
echo "Succesfully created veth pair"
|
||||
fi
|
||||
@ -39,18 +39,18 @@ ip link set dev veth0 up
|
||||
ip link set dev veth1 up
|
||||
|
||||
# Create a bridge, set an IP address and attach veth0
|
||||
if [-z "$(ip l | /bin/grep -e uplinkbridge)"]; then
|
||||
if [ -z "$(ip l | /bin/grep -e uplinkbridge)" ]; then
|
||||
brctl addbr uplinkbridge
|
||||
fi
|
||||
|
||||
if [-z "$(brctl show uplinkbridge | /bin/grep veth0)"]; then
|
||||
if [ -z "$(brctl show | /bin/grep uplinkbridge | head -n1)" ]; then
|
||||
brctl addif uplinkbridge veth0
|
||||
echo "ZzZ..."
|
||||
sleep 3
|
||||
fi
|
||||
|
||||
IP_NETNL = $(echo ${VETH_NETWORK} | cut -d'/' -f2)
|
||||
if [ -z "$(ip a | grep ${VETH0_IP})"]; then
|
||||
IP_NETNL=$(echo ${VETH_NETWORK} | cut -d'/' -f2)
|
||||
if [ -z "$(ip a | grep ${VETH0_IP})" ]; then
|
||||
ip addr add ${VETH0_IP}/$(echo ${IP_NETNL} | cut -d'/' -f2) dev uplinkbridge
|
||||
echo "ZzZ..."
|
||||
sleep 3
|
||||
@ -66,7 +66,7 @@ sleep 3
|
||||
sysctl -w net.ipv4.ip_forward=1
|
||||
|
||||
# Route packets towards floating IP network through the bridge
|
||||
if [ -z "$(ip route | /bin/grep '${FIP} via ${VETH_1}')"]; then
|
||||
if [ -z "$(ip route | /bin/grep "${FIP} via ${VETH_1}")" ]; then
|
||||
ip route add ${FIP} via ${VETH1_IP}
|
||||
echo "Succesfully added route to send packets on the bridge"
|
||||
fi
|
||||
@ -75,7 +75,7 @@ fi
|
||||
ROUTER_ID=$(midonet-cli -A -e router list | grep ${EDGE_ROUTER} | awk '{ print $2 }')
|
||||
PORT_ID=$(midonet-cli -A -e router ${ROUTER_ID} port list | grep ${VETH1_IP} | cut -f 2 -d " ")
|
||||
|
||||
if [ -z "$(midonet-cli -A -e router ${ROUTER_ID} route list | grep 'src 0.0.0.0/0 dst 0.0.0.0/0 port ${PORT_ID}')"]; then
|
||||
if [ -z "$(midonet-cli -A -e router ${ROUTER_ID} route list | grep "src 0.0.0.0/0 dst 0.0.0.0/0 port ${PORT_ID}")"]; then
|
||||
midonet-cli -e router ${ROUTER_ID} add route src 0.0.0.0/0 dst 0.0.0.0/0 \
|
||||
type normal port router ${ROUTER_ID} port ${PORT_ID} gw ${VETH0_IP}
|
||||
echo "Successfully added default route on edge router"
|
||||
@ -85,7 +85,7 @@ fi
|
||||
#port ${PORT_ID} interface veth1
|
||||
|
||||
# Add masquerading to enable NATing
|
||||
if [ "${MASQUERADE_ON} = true "]; then
|
||||
if [ "${MASQUERADE_ON} = 'on' " ]; then
|
||||
iptables -t nat -I POSTROUTING -o ${NIC} -s ${FIP} -j MASQUERADE
|
||||
iptables -I FORWARD -s ${FIP} -j ACCEPT
|
||||
echo "Succesfully enabled masquerading"
|
||||
|
Loading…
x
Reference in New Issue
Block a user