Commit 4f72a60c authored by David Johnson's avatar David Johnson

Scripts to install and configure Openstack on Ubuntu.

These are a collection of scripts that install and configuration
Openstack Juno on Ubuntu 14 and onwards, within an Emulab/Apt/Cloudlab
testbed experiment.

(The included dh2048.pem is a time-saving optimization enabling faster
experiment swapins; it's optional.)
parents
These are a collection of scripts that install and configuration
Openstack Juno on Ubuntu 14 and onwards, within an Emulab/Apt/Cloudlab
testbed experiment.
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAmcQ4qMNk9huVihLjy5axr5C+K5tiwQDrIP5ONcH9dZHQMZiP/IhD
unCVvOxXeJ8KrXB2dffe7HUvE3c4j9ILzlKXVXaDv8iNQ5YWKKgAtkmjmEMXiZQ7
HBJCO/znGIVC1mYkIqZ9qWIvhbJ+ymC94TJksEYIs7suudwQFp0VAnyfZRQXmyxf
Tils3PGAT4EUuKl9QOlCXCJ4pJcltaQIGcgDlkWFZfdn9Ztb9x9Z5wI8Ru4bpsT/
fnBxYAa9rj6Y021jiZZK2hyBzfmFtbw893c/pdq/juZMywybhYQgOVQBpx6IvnIV
FMf4jAHI6gJTYLPKLMl7bajyiedY+oIiswIBAg==
-----END DH PARAMETERS-----
#!/bin/sh
##
## Initialize some basic useful stuff.
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
HOSTNAME=`hostname -s`
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
. $OURDIR/admin-openrc.sh
echo "*** Building an ARM64 image ..."
# Grab some files
wget http://boss.utah.cloudlab.us/downloads/vmlinuz-3.13.0-40-arm64-generic
wget http://boss.utah.cloudlab.us/downloads/initrd.img-3.13.0-40-arm64-generic
wget http://boss.utah.cloudlab.us/downloads/ubuntu-core-14.04.1-core-arm64.tar.gz
core=ubuntu-core-14.04.1-core-arm64.tar.gz
out=ubuntu-core-14.04.1-core-arm64.img
dd if=/dev/zero of="$out" bs=1M count=1024
echo "*** making a new ext4 filesystem ..."
echo "y" | mkfs -t ext4 "$out" >/dev/null
mkdir -p mnt
mount -o loop "$out" mnt
echo "*** adding contents of core tarball ..."
tar xzf "$core" -C mnt
echo "*** adding ttyAMA0 ..."
{
cat - <<EOM
# ttyAMA0 - getty
#
# This service maintains a getty on ttyAMA0 from the point the system is
# started until it is shut down again.
#start on stopped rc RUNLEVEL=[2345] and (
# not-container or
# container CONTAINER=lxc or
# container CONTAINER=lxc-libvirt)
start on started
stop on runlevel [!2345]
respawn
exec /sbin/getty -L ttyAMA0 115200
EOM
} | tee mnt/etc/init/ttyAMA0.conf >/dev/null
echo "*** adding NTP date and time synchronization ..."
{
cat - <<EOM
#
# This task is run on startup to set the system date and time via NTP
description "set the date and time via NTP"
start on startup
task
exec ntpdate -u ntp.ubuntu.com
EOM
} | tee mnt/etc/init/ntpdate.conf >/dev/null
#
# NOTE: we reduce the MTU arbitrarily here so that we can (easily) fit
# through a GRE tunnel.
#
echo "*** adding networking for qemu ..."
{
cat - <<EOM
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
post-up /sbin/ifconfig eth0 mtu 1300
EOM
} | tee -a mnt/etc/network/interfaces >/dev/null
echo 'Acquire::CompressionTypes::Order { "gz"; "bz2"; }' | tee mnt/etc/apt/apt.conf.d/99gzip >/dev/null
echo "*** fixing root password to root/root ..."
sed -in -e 's@root:\*:@root:$6$pDWQLJGt$813e.4.vXznRlkCpxRtBdUZmHf6DnYg.XM58h6SGLF0Q2tCh5kTF2hCi7fm9NeaSSHeGBaUfpKQ9/wA54mcb51:@' mnt/etc/shadow
echo "*** unmounting ..."
umount mnt
rmdir mnt
echo "*** Importing new image ..."
glance image-create --name vmlinuz-3.13.0-40-arm64-generic --is-public True --progress --file vmlinuz-3.13.0-40-arm64-generic --disk-format aki --container-format aki
KERNEL_ID=`glance image-show vmlinuz-3.13.0-40-arm64-generic | grep id | sed -n -e 's/^.*id.*| \([0-9a-zA-Z-]*\).*$/\1/p'`
glance image-create --name initrd-3.13.0-40-arm64-generic --is-public True --progress --file initrd.img-3.13.0-40-arm64-generic --disk-format ari --container-format ari
RAMDISK_ID=`glance image-show initrd-3.13.0-40-arm64-generic | grep id | sed -n -e 's/^.*id.*| \([0-9a-zA-Z-]*\).*$/\1/p'`
glance image-create --name ubuntu-core-14.04.1-core-arm64 --is-public True --progress --file $out --disk-format ami --container-format ami
glance image-update --property kernel_args="console=ttyAMA0 root=/dev/sda" ubuntu-core-14.04.1-core-arm64
glance image-update --property kernel_id=${KERNEL_ID} ubuntu-core-14.04.1-core-arm64
glance image-update --property ramdisk_id=${RAMDISK_ID} ubuntu-core-14.04.1-core-arm64
echo "*** Creating data network and subnet ..."
neutron net-create ${EPID}-net
neutron subnet-create ${EPID}-net --name ${EPID}-subnet 172.16/12
neutron router-create ${EPID}-router
neutron router-interface-add ${EPID}-router ${EPID}-subnet
neutron router-gateway-set ${EPID}-router ext-net
#
# Now do another one, with sshd installed
#
mkdir -p mnt
mount -o loop "$out" mnt
echo "*** installing ssh/sshd..."
echo "nameserver 8.8.8.8" > mnt/etc/resolv.conf
chroot mnt /usr/bin/apt-get install -y openssh-server openssh-client
chroot mnt /usr/sbin/update-rc.d ssh defaults
chroot mnt /usr/sbin/update-rc.d ssh enable
cat <<EOF > mnt/etc/ssh/sshd_config
Port 22
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 1024
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
#PermitEmptyPasswords no
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
UseDNS no
StrictModes no
PermitRootLogin yes
PasswordAuthentication yes
EOF
echo "*** unmounting ..."
umount mnt
rmdir mnt
echo "*** Importing new image (with sshd) ..."
glance image-create --name ubuntu-core-14.04.1-core-arm64-sshd --is-public True --progress --file $out --disk-format ami --container-format ami
glance image-update --property kernel_args="console=ttyAMA0 root=/dev/sda" ubuntu-core-14.04.1-core-arm64-sshd
glance image-update --property kernel_id=${KERNEL_ID} ubuntu-core-14.04.1-core-arm64-sshd
glance image-update --property ramdisk_id=${RAMDISK_ID} ubuntu-core-14.04.1-core-arm64-sshd
exit 0
#!/bin/sh
##
## Setup a OpenStack compute node for Nova.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
HOSTNAME=`hostname -s`
if [ "$HOSTNAME" = "$CONTROLLER" -o "$HOSTNAME" = "$NETWORKMANAGER" ]; then
exit 0;
fi
if [ -f $OURDIR/setup-compute-network-done ]; then
exit 0
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
myip=`ip addr show ${DATA_NETWORK_INTERFACE} | sed -n -e 's/^.*inet \([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
cat <<EOF >> /etc/sysctl.conf
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
EOF
sysctl -p
apt-get install -y neutron-plugin-ml2 neutron-plugin-openvswitch-agent
sed -i -e "s/^\\(.*connection.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_host.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_port.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_protocol.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
# Just slap these in.
cat <<EOF >> /etc/neutron/neutron.conf
[DEFAULT]
rpc_backend = rabbit
rabbit_host = $CONTROLLER
rabbit_password = ${RABBIT_PASS}
auth_strategy = keystone
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
verbose = True
[keystone_authtoken]
auth_uri = http://$CONTROLLER:5000/v2.0
identity_uri = http://$CONTROLLER:35357
admin_tenant_name = service
admin_user = neutron
admin_password = ${NEUTRON_PASS}
EOF
# enable_security_group = True
# firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
# Just slap these in.
cat <<EOF >> /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
[ml2_type_flat]
flat_networks = external
[ml2_type_gre]
tunnel_id_ranges = 1:1000
[securitygroup]
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.firewall.NoopFirewallDriver
[ovs]
local_ip = $myip
enable_tunneling = True
bridge_mappings = external:br-ex
[agent]
tunnel_types = gre
EOF
cat <<EOF >> /etc/nova/nova.conf
[DEFAULT]
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[neutron]
url = http://$CONTROLLER:9696
auth_strategy = keystone
admin_auth_url = http://$CONTROLLER:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = ${NEUTRON_PASS}
EOF
service openvswitch-switch restart
service nova-compute restart
service neutron-plugin-openvswitch-agent restart
touch $OURDIR/setup-compute-network-done
exit 0
#!/bin/sh
##
## Setup a OpenStack compute node for Nova.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
HOSTNAME=`hostname -s`
if [ "$HOSTNAME" == "$CONTROLLER" -o "$HOSTNAME" == "$NETWORKMANAGER" ]; then
exit 0;
fi
if [ -f $OURDIR/setup-compute-done ]; then
exit 0
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
myip=`cat /etc/hosts | grep $NODEID | head -1 | sed -n -e 's/^\\([0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*\\).*$/\\1/p'`
apt-get install -y nova-compute sysfsutils
apt-get install -y libguestfs-tools libguestfs0 python-guestfs
#
# Change vnc_enabled = True for x86 -- but for aarch64, there is
# no video device, for KVM mode, anyway, it seems.
#
cat <<EOF >> /etc/nova/nova.conf
[DEFAULT]
rpc_backend = rabbit
rabbit_host = $CONTROLLER
rabbit_password = ${RABBIT_PASS}
auth_strategy = keystone
my_ip = $myip
vnc_enabled = False
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = $myip
novncproxy_base_url = http://$CONTROLLER:6080/vnc_auto.html
verbose = True
[keystone_authtoken]
auth_uri = http://$CONTROLLER:5000/v2.0
identity_uri = http://$CONTROLLER:35357
admin_tenant_name = service
admin_user = nova
admin_password = ${NOVA_PASS}
[glance]
host = $CONTROLLER
EOF
cat <<EOF >> /etc/nova/nova-compute.conf
[DEFAULT]
compute_driver=libvirt.LibvirtDriver
[libvirt]
virt_type=kvm
cpu_mode=custom
cpu_model=host
EOF
service nova-compute restart
# XXXX ???
# rm -f /var/lib/nova/nova.sqlite
touch $OURDIR/setup-compute-done
exit 0
This diff is collapsed.
#!/bin/sh
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
# All nodes need to publish public keys, and acquire others'
$DIRNAME/setup-root-ssh.sh 1> $OURDIR/setup-root-ssh.log 2>&1
HOSTNAME=`hostname -s`
if [ "$HOSTNAME" != "$NETWORKMANAGER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
echo "*** Waiting for all nodes..."
for node in $CONTROLLER $COMPUTENODES ; do
SUCCESS=1
fqdn=$node.$EEID.$EPID.$OURDOMAIN
while [ $SUCCESS -ne 0 ] ; do
sleep 1
#su -c "ssh -l $SWAPPER -o ConnectTimeout=1 -o PasswordAuthentication=No -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=No $fqdn /bin/ls" $SWAPPER > /dev/null
ssh -o ConnectTimeout=1 -o PasswordAuthentication=No -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=No $fqdn /bin/ls > /dev/null
SUCCESS=$?
done
echo "*** $node is up!"
done
echo "*** Building an Openstack!"
#$DIRNAME/setup-root-ssh.sh 1> $OURDIR/setup-root-ssh.log 2>&1
$DIRNAME/setup-ovs.sh 1> $OURDIR/setup-ovs.log 2>&1
$DIRNAME/setup-vpn.sh 1> $OURDIR/setup-vpn.log 2>&1
# Give the VPN a chance to settle down
PINGED=0
while [ $PINGED -eq 0 ]; do
sleep 2
ping -c 1 controller
if [ $? -eq 0 ]; then
PINGED=1
fi
done
ssh -o StrictHostKeyChecking=no controller "sh -c $DIRNAME/setup-controller.sh 1> $OURDIR/setup-controller.log 2>&1 </dev/null &"
exit 0
#!/bin/sh
BOOTDIR=/var/emulab/boot
TMCC=/usr/local/etc/emulab/tmcc
CREATOR=`cat $BOOTDIR/creator`
SWAPPER=`cat $BOOTDIR/swapper`
NODEID=`cat $BOOTDIR/nickname | cut -d . -f 1`
PNODEID=`cat $BOOTDIR/nodeid`
EEID=`cat $BOOTDIR/nickname | cut -d . -f 2`
EPID=`cat $BOOTDIR/nickname | cut -d . -f 3`
OURDOMAIN=`cat $BOOTDIR/mydomain`
NFQDN="`cat $BOOTDIR/nickname`.$OURDOMAIN"
PFQDN="`cat $BOOTDIR/nodeid`.$OURDOMAIN"
MYIP=`cat $BOOTDIR/myip`
SSH="ssh -o StrictHostKeyChecking=no"
if [ "$SWAPPER" = "geniuser" ]; then
SWAPPER_EMAIL=`geni-get user_email`
else
SWAPPER_EMAIL="$SWAPPER@$OURDOMAIN"
fi
#
# Grab our topomap so we can see how many nodes we have.
#
TTF=`mktemp topomap.XXXXXX`
$TMCC topomap | gunzip > $TTF
CONTROLLER="controller"
NETWORKMANAGER="networkmanager"
NODES=`cat $TTF | grep -v '^#' | sed -n -e 's/^\([a-zA-Z0-9\-]*\),.*:.*$/\1/p' | xargs`
COMPUTENODES=""
for node in $NODES
do
if [ "$node" != "$CONTROLLER" -a "$node" != "$NETWORKMANAGER" ]; then
COMPUTENODES="$COMPUTENODES $node"
fi
done
rm -f $TTF
#
# Openstack stuff
#
PSWDGEN="openssl rand -hex 10"
OURDIR=/root/setup
SETTINGS=$OURDIR/settings
mkdir -p $OURDIR
cd $OURDIR
USE_EXISTING_DATA_IPS=1
EXTERNAL_NETWORK_INTERFACE="eth0"
EXTERNAL_NETWORK_BRIDGE="br-ex"
DATA_NETWORK_INTERFACE="eth1"
DATA_NETWORK_BRIDGE="br-int"
EXT_FLOAT_IP_START=128.110.154.240
EXT_FLOAT_IP_END=128.110.154.254
#!/bin/sh
##
## Setup the OpenStack networkmanager node for Neutron.
##
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
HOSTNAME=`hostname -s`
if [ "$HOSTNAME" != "$NETWORKMANAGER" ]; then
exit 0;
fi
if [ -f $OURDIR/setup-networkmanager-done ]; then
exit 0
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
dataip=`cat $OURDIR/data-hosts | grep $HOSTNAME | sed -n -e 's/^\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
cat <<EOF >> /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
EOF
sysctl -p
apt-get install -y neutron-plugin-ml2 neutron-plugin-openvswitch-agent \
neutron-l3-agent neutron-dhcp-agent
apt-get install conntrack
sed -i -e "s/^\\(.*connection.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_host.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_port.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
sed -i -e "s/^\\(.*auth_protocol.*=.*\\)$/#\1/" /etc/neutron/neutron.conf
# Just slap these in.
cat <<EOF >> /etc/neutron/neutron.conf
[DEFAULT]
rpc_backend = rabbit
rabbit_host = $CONTROLLER
rabbit_password = ${RABBIT_PASS}
auth_strategy = keystone
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
verbose = True
[keystone_authtoken]
auth_uri = http://$CONTROLLER:5000/v2.0
identity_uri = http://$CONTROLLER:35357
admin_tenant_name = service
admin_user = neutron
admin_password = ${NEUTRON_PASS}
EOF
# enable_security_group = False
# firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
# Just slap these in.
cat <<EOF >> /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
[ml2_type_flat]
flat_networks = external
[ml2_type_gre]
tunnel_id_ranges = 1:1000
[securitygroup]
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.firewall.NoopFirewallDriver
[ovs]
local_ip = $dataip
enable_tunneling = True
bridge_mappings = external:br-ex
[agent]
tunnel_types = gre
EOF
# Just slap these in.
cat <<EOF >> /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
external_network_bridge = br-ex
verbose = True
EOF
# Just slap these in.
cat <<EOF >> /etc/neutron/dhcp_agent.ini
[DEFAULT]
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = True
verbose = True
EOF
# Uncomment if dhcp has trouble due to MTU
#cat <<EOF >> /etc/neutron/dhcp_agent.ini
#[DEFAULT]
#dnsmasq_config_file = /etc/neutron/dnsmasq-neutron.conf
#EOF
#cat <<EOF >> /etc/neutron/dnsmasq-neutron.conf
#dhcp-option-force=26,1454
#EOF
#pkill dnsmasq
sed -i -e "s/^.*auth_url.*=.*$/auth_url = http:\\/\\/$CONTROLLER:5000\\/v2.0/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*auth_region.*=.*$/auth_region = regionOne/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*admin_tenant_name.*=.*$/admin_tenant_name = service/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*admin_user.*=.*$/admin_user = neutron/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*admin_password.*=.*$/admin_password = ${NEUTRON_PASS}/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*nova_metadata_ip.*=.*$/nova_metadata_ip = $CONTROLLER/" /etc/neutron/metadata_agent.ini
sed -i -e "s/^.*metadata_proxy_shared_secret.*=.*$/metadata_proxy_shared_secret = $NEUTRON_METADATA_SECRET/" /etc/neutron/metadata_agent.ini
cat <<EOF >> /etc/neutron/metadata_agent.ini
[DEFAULT]
verbose = True
EOF
service openvswitch-switch restart
service neutron-plugin-openvswitch-agent restart
service neutron-l3-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart
touch $OURDIR/setup-networkmanager-done
exit 0
#!/bin/sh
#
# This sets up openvswitch networks (on neutron, the external and data
# networks). The networkmanager and compute nodes' physical interfaces
# have to get moved into br-ex and br-int, respectively -- on the
# moonshots, that's eth0 and eth1. The controller is special; it doesn't
# get an openvswitch setup, and gets eth1 10.0.0.3/8 . The networkmanager
# is also special; it gets eth1 10.0.0.1/8, but its eth0 moves into br-ex,
# and its eth1 moves into br-int. The compute nodes get IP addrs from
# 10.0.1.1/8 and up, but setup-ovs.sh determines that.
#
set -x
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "`dirname $0`/setup-lib.sh"
HOSTNAME=`hostname -s`
dataip=`cat $OURDIR/data-hosts | grep $HOSTNAME | sed -n -e 's/^\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
#
# If this is the controller, we don't have to do much network setup; just
# setup the data network with its IP.
#
if [ "$HOSTNAME" = "$CONTROLLER" ]; then
if [ ${USE_EXISTING_DATA_IPS} -eq 0 ]; then
ifconfig ${DATA_NETWORK_INTERFACE} $dataip netmask 255.0.0.0 up
fi
exit 0;
fi
#
# Otherwise, first we need openvswitch.
#
apt-get install -y openvswitch-common openvswitch-switch
# Make sure it's running
service openvswitch restart
#
# Setup the external network
#
ovs-vsctl add-br br-ex
ovs-vsctl add-port br-ex ${EXTERNAL_NETWORK_INTERFACE}
#ethtool -K $EXTERNAL_NETWORK_INTERFACE gro off
#
# Now move the $EXTERNAL_NETWORK_INTERFACE and default route config to br-ex
#
myip=`ifconfig ${EXTERNAL_NETWORK_INTERFACE} | sed -n -e 's/^.*inet addr:\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
mynetmask=`ifconfig ${EXTERNAL_NETWORK_INTERFACE} | sed -n -e 's/^.*Mask:\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
mygw=`ip route show default | sed -n -e 's/^default via \([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*$/\1/p'`
#
# We need to blow away the Emulab config -- no more dhcp
# This would definitely break experiment modify, of course
#
cat <<EOF > /etc/network/interfaces
# Openstack Network Node in Cloudlab