Fix shellscript for gateway static

Change-Id: I40001520f6175aa31bde51a33a7b13685d83ffcc
This commit is contained in:
Alex Ruiz Estradera 2016-09-23 15:49:46 +02:00
parent 28c122ab6f
commit 195d3799cc
2 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -23,8 +23,8 @@ 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)
@ -43,7 +43,7 @@ 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
@ -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"