Commit 6d11e4a0 authored by David Johnson's avatar David Johnson

Attempt to generate static openvswitch systemd-networkd config.

Also needed a new service unit file (post network and pre testbed) to
handle the various file writes to testbed locations, that were
previously trivially handled as up hooks in /etc/network/interfaces.
parent 0b40ae0b
......@@ -372,6 +372,7 @@ else
OSCODENAME="juno"
OSVERSION=$OSJUNO
fi
DISTRIB_MAJOR=`echo $DISTRIB_RELEASE | cut -d. -f1`
#
# Default memcached fully on for Mitaka or greater. Too slow without it.
......@@ -1150,6 +1151,7 @@ if [ ! -e $OURDIR/info.mgmt ]; then
MGMTMAC=`cat ${BOOTDIR}/tmcc/ifconfig | sed -n -e "s/^.* VMAC=\([0-9a-f:\.]*\) .* LAN=${MGMTLAN}.*\$/\1/p"`
MGMT_NETWORK_INTERFACE=`/usr/local/etc/emulab/findif -m $MGMTMAC`
MGMTVLANDEV=`ip link show ${MGMT_NETWORK_INTERFACE} | sed -n -e "s/^.*${MGMT_NETWORK_INTERFACE}\@\([0-9a-zA-Z_]*\): .*\$/\1/p"`
MGMTVLANTAG=`cat ${BOOTDIR}/tmcc/ifconfig | sed -n -e "s/^.* LAN=${MGMTLAN} VTAG=\([0-9]*\).*\$/\1/p"`
else
MGMTVLAN=0
MGMTMAC=`cat ${BOOTDIR}/tmcc/ifconfig | sed -n -e "s/.* MAC=\([0-9a-f:\.]*\) .* LAN=${MGMTLAN}/\1/p"`
......@@ -1164,6 +1166,7 @@ if [ ! -e $OURDIR/info.mgmt ]; then
echo "MGMTMAC='$MGMTMAC'" >> $OURDIR/info.mgmt
echo "MGMT_NETWORK_INTERFACE='$MGMT_NETWORK_INTERFACE'" >> $OURDIR/info.mgmt
echo "MGMTVLANDEV='$MGMTVLANDEV'" >> $OURDIR/info.mgmt
echo "MGMTVLANTAG='$MGMTVLANTAG'" >> $OURDIR/info.mgmt
else
. $OURDIR/info.mgmt
fi
......@@ -1179,6 +1182,7 @@ for lan in $DATAFLATLANS $DATAOTHERLANS ; do
DATAIP=`cat $OURDIR/data-hosts.$lan | grep -E "$NODEID$" | sed -n -e 's/^\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
DATANETMASK=`cat $OURDIR/data-netmask.$lan`
DATAPREFIX=`netmask2prefix $DATANETMASK`
cat ${BOOTDIR}/tmcc/ifconfig | grep "IFACETYPE=vlan" | grep "${lan}"
if [ $? = 0 ]; then
DATAVLAN=1
......@@ -1199,6 +1203,7 @@ for lan in $DATAFLATLANS $DATAOTHERLANS ; do
echo "DATABRIDGE=br-${lan}" >> $OURDIR/info.$lan
echo "DATAIP=${DATAIP}" >> $OURDIR/info.$lan
echo "DATANETMASK=${DATANETMASK}" >> $OURDIR/info.$lan
echo "DATAPREFIX=${DATAPREFIX}" >> $OURDIR/info.$lan
echo "DATAVLAN=${DATAVLAN}" >> $OURDIR/info.$lan
echo "DATAVLANTAG=${DATAVLANTAG}" >> $OURDIR/info.$lan
echo "DATAVLANDEV=${DATAVLANDEV}" >> $OURDIR/info.$lan
......
......@@ -57,6 +57,7 @@ if [ ! -f $OURDIR/ctlnet.vars ]; then
ctlnetmask=`ifconfig ${EXTERNAL_NETWORK_INTERFACE} | sed -n -e 's/^.*mask[: ]*\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/ip'`
ctlgw=`ip route show default | sed -n -e 's/^default via \([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
ctlnet=`ip route show dev ${EXTERNAL_NETWORK_INTERFACE} | sed -n -e 's/^\([0-9]*.[0-9]*.[0-9]*.[0-9]*\/[0-9]*\) .*$/\1/p'`
ctlprefix=`echo $ctlnet | cut -d/ -f2`
echo "ctlip=\"$ctlip\"" > $OURDIR/ctlnet.vars
echo "ctlmac=\"$ctlmac\"" >> $OURDIR/ctlnet.vars
......@@ -64,6 +65,7 @@ if [ ! -f $OURDIR/ctlnet.vars ]; then
echo "ctlnetmask=\"$ctlnetmask\"" >> $OURDIR/ctlnet.vars
echo "ctlgw=\"$ctlgw\"" >> $OURDIR/ctlnet.vars
echo "ctlnet=\"$ctlnet\"" >> $OURDIR/ctlnet.vars
echo "ctlprefix=\"$ctlprefix\"" >> $OURDIR/ctlnet.vars
else
. $OURDIR/ctlnet.vars
fi
......@@ -106,7 +108,8 @@ fi
# We need to blow away the Emulab config -- no more dhcp
# This would definitely break experiment modify, of course
#
cat <<EOF > /etc/network/interfaces
if [ $DISTRIB_MAJOR -lt 18 ]; then
cat <<EOF > /etc/network/interfaces
#
# Openstack Network Node in Cloudlab/Emulab/Apt/Federation
#
......@@ -130,6 +133,55 @@ auto ${EXTERNAL_NETWORK_INTERFACE}
iface ${EXTERNAL_NETWORK_INTERFACE} inet static
address 0.0.0.0
EOF
else
mv /etc/udev/rules.d/99-emulab-networkd.rules \
/etc/udev/rules.d/99-emulab-networkd.rules.NO
cat <<EOF >/etc/systemd/system/testbed-pre-static-control-network.service
[Unit]
Description=Testbed Static Control Network Services
After=network.target network-online.target local-fs.target
Wants=network.target
Before=testbed.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/root/setup/testbed-pre-static-control-network.sh
StandardOutput=journal+console
StandardError=journal+console
[Install]
WantedBy=multi-user.target
WantedBy=testbed.service
EOF
cat <<EOF >/root/setup/testbed-pre-static-control-network.sh
#!/bin/sh
#
# These are just the things we cannot do via hook from systemd-networkd,
# that were previously done in /etc/network/interfaces via "up" hook.
#
echo "${EXTERNAL_NETWORK_BRIDGE}" > /var/run/cnet
echo "${EXTERNAL_NETWORK_BRIDGE}" > /var/emulab/boot/controlif
for line in `cat /etc/neutron/ovs-default-flows/br-ex`; do
ovs-ofctl add-flow br-ex $line
done
EOF
chmod 755 /root/setup/testbed-pre-static-control-network.sh
cat <<EOF >/etc/systemd/network/${EXTERNAL_NETWORK_BRIDGE}.network
[Match]
Name=${EXTERNAL_NETWORK_BRIDGE}
[Network]
Description=OpenStack External Network Bridge
DHCP=no
Address=$ctlip/$ctlprefix
Gateway=$ctlgw
DNS=$DNSSERVER
Domains=$DNSDOMAIN
IPForward=yes
EOF
fi
ifconfig ${EXTERNAL_NETWORK_INTERFACE} 0 up
ifconfig ${EXTERNAL_NETWORK_BRIDGE} $ctlip netmask $ctlnetmask up
......@@ -149,7 +201,8 @@ sleep 1
# Add the management network config if necessary (if not, it's already a VPN)
#
if [ ! -z "$MGMTLAN" ]; then
cat <<EOF >> /etc/network/interfaces
if [ $DISTRIB_MAJOR -lt 18 ]; then
cat <<EOF >> /etc/network/interfaces
auto ${MGMT_NETWORK_INTERFACE}
iface ${MGMT_NETWORK_INTERFACE} inet static
......@@ -158,10 +211,46 @@ iface ${MGMT_NETWORK_INTERFACE} inet static
up mkdir -p /var/run/emulab
up echo "${MGMT_NETWORK_INTERFACE} $MGMTIP $MGMTMAC" > /var/run/emulab/interface-done-$MGMTMAC
EOF
else
cat <<EOF >/etc/systemd/network/${MGMT_NETWORK_INTERFACE}.network
[Match]
Name=${MGMT_NETWORK_INTERFACE}
[Network]
Description=OpenStack Management Network
DHCP=no
Address=$MGMTIP/$MGMTPREFIX
IPForward=yes
EOF
cat <<EOF >>/root/setup/testbed-pre-static-control-network.sh
mkdir -p /var/run/emulab
echo "${MGMT_NETWORK_INTERFACE} $MGMTIP $MGMTMAC" > /var/run/emulab/interface-done-$MGMTMAC
EOF
fi
if [ -n "$MGMTVLANDEV" ]; then
cat <<EOF >> /etc/network/interfaces
if [ $DISTRIB_MAJOR -lt 18 ]; then
cat <<EOF >> /etc/network/interfaces
vlan-raw-device ${MGMTVLANDEV}
EOF
else
cat <<EOF >/etc/systemd/network/${MGMT_NETWORK_INTERFACE}.netdev
[NetDev]
Name=${MGMT_NETWORK_INTERFACE}
Kind=vlan
[VLAN]
Id=$MGMTVLANTAG
EOF
cat <<EOF >/etc/systemd/network/${MGMTVLANDEV}.network
[Match]
Name=${MGMTVLANDEV}
[Network]
DHCP=no
VLAN=${MGMT_NETWORK_INTERFACE}
EOF
fi
fi
fi
......@@ -181,7 +270,8 @@ for lan in $DATAFLATLANS ; do
ovs-vsctl add-port ${DATABRIDGE} ${DATADEV}
ifconfig ${DATADEV} 0 up
cat <<EOF >> /etc/network/interfaces
if [ $DISTRIB_MAJOR -lt 18 ]; then
cat <<EOF >> /etc/network/interfaces
auto ${DATABRIDGE}
iface ${DATABRIDGE} inet static
......@@ -194,10 +284,45 @@ auto ${DATADEV}
iface ${DATADEV} inet static
address 0.0.0.0
EOF
if [ -n "$DATAVLANDEV" ]; then
cat <<EOF >> /etc/network/interfaces
if [ -n "$DATAVLANDEV" ]; then
cat <<EOF >> /etc/network/interfaces
vlan-raw-device ${DATAVLANDEV}
EOF
fi
else
cat <<EOF >/etc/systemd/network/${DATABRIDGE}.network
[Match]
Name=${DATABRIDGE}
[Network]
Description=OpenStack Data Flat Lan $DATABRIDGE Network
DHCP=no
Address=$DATAIP/$DATAPREFIX
IPForward=yes
EOF
cat <<EOF >>/root/setup/testbed-pre-static-control-network.sh
mkdir -p /var/run/emulab
echo "${DATABRIDGE} $DATAIP $DATAMAC" > /var/run/emulab/interface-done-$DATAMAC
EOF
if [ -n "$DATAVLANDEV" ]; then
cat <<EOF >/etc/systemd/network/${DATADEV}.netdev
[NetDev]
Name=${DATADEV}
Kind=vlan
[VLAN]
Id=$DATAVLANTAG
EOF
cat <<EOF >/etc/systemd/network/${DATAVLANDEV}.network
[Match]
Name=${DATAVLANDEV}
[Network]
DHCP=no
VLAN=${DATADEV}
EOF
fi
fi
ifconfig ${DATABRIDGE} $DATAIP netmask $DATANETMASK up
......@@ -229,7 +354,8 @@ for lan in $DATAVLANS ; do
grep "^auto ${DATAVLANDEV}$" /etc/network/interfaces
if [ ! $? -eq 0 ]; then
cat <<EOF >> /etc/network/interfaces
if [ $DISTRIB_MAJOR -lt 18 ]; then
cat <<EOF >> /etc/network/interfaces
auto ${DATAVLANDEV}
iface ${DATAVLANDEV} inet static
#address 0.0.0.0
......@@ -239,6 +365,16 @@ iface ${DATAVLANDEV} inet static
# to not setup any of these vlans.
up touch /var/run/emulab/interface-done-$DATAPMAC
EOF
else
cat <<EOF >>/root/setup/testbed-pre-static-control-network.sh
mkdir -p /var/run/emulab
# Just touch it, don't put iface/inet/mac into it; the vlans atop this
# device are being used natively by openstack. So just let Emulab setup
# to not setup any of these vlans.
touch /var/run/emulab/interface-done-$DATAPMAC
EOF
fi
fi
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment