2016-12-05 09:30:24 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# functions - networking-vpp driver devstack utility functions
|
|
|
|
|
|
|
|
function install_vpp {
|
|
|
|
if is_fedora; then
|
|
|
|
sudo tee /etc/yum.repos.d/fdio.repo <<EOF
|
|
|
|
[fdio-master]
|
|
|
|
name=fd.io master branch latest merge
|
2017-01-03 14:36:36 -05:00
|
|
|
baseurl=https://nexus.fd.io/content/repositories/fd.io.$VPP_BRANCH.centos7/
|
2016-12-05 09:30:24 -05:00
|
|
|
enabled=1
|
|
|
|
gpgcheck=0
|
|
|
|
EOF
|
2017-01-06 11:39:52 +01:00
|
|
|
sudo yum --enablerepo=fdio-master clean metadata
|
2016-12-05 09:30:24 -05:00
|
|
|
elif is_ubuntu; then
|
2017-01-03 14:36:36 -05:00
|
|
|
echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io.$VPP_BRANCH.ubuntu.$os_CODENAME.main/ ./" | sudo tee /etc/apt/sources.list.d/99fd.io.list
|
2017-04-24 18:29:55 -07:00
|
|
|
# installing to prevent failure with https hosts on fd.io source
|
|
|
|
install_package apt-transport-https
|
2016-12-05 09:30:24 -05:00
|
|
|
else
|
|
|
|
die $LINENO "Can't install VPP on unsupported os: $os_VENDOR"
|
|
|
|
fi
|
2017-04-24 18:29:55 -07:00
|
|
|
# stack fails without this package, ensuring it's installed
|
|
|
|
install_package bridge-utils
|
2016-12-05 09:30:24 -05:00
|
|
|
install_package vpp
|
2017-07-26 18:36:04 +00:00
|
|
|
# if vpp service is started while installing it will not have correct
|
|
|
|
# startup conf yet, stop the service it will be started later
|
|
|
|
stop_service vpp || true
|
|
|
|
|
2017-01-06 11:39:52 +01:00
|
|
|
# python api package name was renamed in 17.04, try to install both
|
|
|
|
install_package vpp-python-api || install_package vpp-api-python
|
|
|
|
# plugins are required to support security groups
|
|
|
|
install_package vpp-plugins
|
2016-12-05 09:30:24 -05:00
|
|
|
if is_set VPP_STARTUP_CONFIG; then
|
|
|
|
if [[ -f "$VPP_STARTUP_CONFIG" && -r "$VPP_STARTUP_CONFIG" ]]; then
|
|
|
|
sudo cp -f /etc/vpp/startup.conf /etc/vpp/startup.conf.devstack_bak
|
|
|
|
sudo cp -f $VPP_STARTUP_CONFIG /etc/vpp/startup.conf
|
|
|
|
else
|
|
|
|
die $LINENO "VPP config file $VPP_STARTUP_CONFIG not a file or unreadable"
|
|
|
|
fi
|
|
|
|
elif is_set VPP_INT_PCI_DEV; then
|
2017-07-26 18:36:04 +00:00
|
|
|
# keep a copy of un-modified initial config file
|
|
|
|
sudo cp -f /etc/vpp/startup.conf /etc/vpp/startup.conf.devstack_bak
|
|
|
|
have_dpdk_config=`sed -n '/'^$'dpdk/p' /etc/vpp/startup.conf | wc -l`
|
|
|
|
if [[ $have_dpdk_config -eq 0 ]]; then
|
|
|
|
# we do not have dpdk section, append it to startup.conf
|
|
|
|
echo "dpdk {" | sudo tee -a /etc/vpp/startup.conf
|
|
|
|
echo "}" | sudo tee -a /etc/vpp/startup.conf
|
|
|
|
fi
|
2017-02-22 08:44:59 -08:00
|
|
|
# We have some very poor skills hacking this file - we add but don't substitute
|
|
|
|
# and we don't make any attempt to parse the file, so this works with default
|
|
|
|
# configs and not generally otherwise
|
2017-07-26 18:36:04 +00:00
|
|
|
sudo sed -i "/"^$"dpdk *{/a\ \ dev $VPP_INT_PCI_DEV" /etc/vpp/startup.conf
|
2016-12-05 09:30:24 -05:00
|
|
|
else
|
|
|
|
die $LINENO "VPP_STARTUP_CONFIG or VPP_INT_PCI_DEV must be set"
|
|
|
|
fi
|
2017-03-27 19:55:28 +11:00
|
|
|
user="$(id -un)"
|
|
|
|
sudo sed -i "/api-segment *{/a\ \ uid $user" /etc/vpp/startup.conf
|
2016-12-05 09:30:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function start_vpp {
|
|
|
|
is_package_installed vpp || install_vpp
|
|
|
|
start_service vpp
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_hugepages {
|
|
|
|
if is_set NR_HUGEPAGES; then
|
|
|
|
system_hugepages="$(cat /proc/meminfo | grep HugePages_Total | awk '{print $2}')"
|
|
|
|
die_if_not_set $LINENO system_hugepages "Couldn't determine current system huge page count"
|
|
|
|
if [ "$system_hugepages" -lt "$NR_HUGEPAGES" ]; then
|
|
|
|
sudo sysctl -w vm.nr_hugepages="$NR_HUGEPAGES"
|
|
|
|
system_hugepages=$(cat /proc/meminfo | grep HugePages_Total | awk '{print $2}')
|
|
|
|
if [ "$system_hugepages" -ne "$NR_HUGEPAGES" ]; then
|
|
|
|
die $LINENO "Failed to set system huge page count to $NR_HUGEPAGES"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function setup_host_env {
|
|
|
|
is_package_installed etcd || install_package etcd
|
|
|
|
restart_service etcd
|
2017-03-07 00:32:48 +11:00
|
|
|
|
|
|
|
# This relies on a bunch of etcd state, and if you're stacking and unstacking
|
|
|
|
# stale cruft builds up.
|
|
|
|
|
|
|
|
clean_etcd
|
|
|
|
|
2016-12-05 09:30:24 -05:00
|
|
|
set_hugepages
|
|
|
|
systemctl is-active vpp || start_vpp
|
|
|
|
}
|
2017-03-07 00:32:48 +11:00
|
|
|
|
|
|
|
function clean_etcd() {
|
|
|
|
|
|
|
|
# etcd_host may be complex, so we do our best with it
|
2017-04-23 05:26:55 +10:00
|
|
|
if [ ! -z "$ETCD_CA_CERT" ] ; then
|
|
|
|
proto=https
|
|
|
|
args="--ca-file $ETCD_CA_CERT"
|
|
|
|
else
|
|
|
|
proto=http
|
|
|
|
args=""
|
|
|
|
fi
|
2017-03-07 00:32:48 +11:00
|
|
|
|
|
|
|
if [[ ! "$ETCD_HOST" =~ "://" ]] ; then
|
|
|
|
hostarg=""
|
|
|
|
for f in $(echo "$ETCD_HOST" | tr "," "\n"); do
|
2017-04-23 05:26:55 +10:00
|
|
|
hostarg="$hostarg,$proto://$f:$ETCD_PORT/"
|
2017-03-07 00:32:48 +11:00
|
|
|
done
|
|
|
|
# Strip that leading comma
|
|
|
|
|
|
|
|
hostarg="${hostarg:1}"
|
|
|
|
else
|
|
|
|
hostarg="$ETCD_HOST"
|
|
|
|
fi
|
2017-04-23 05:26:55 +10:00
|
|
|
args="$args --endpoints $hostarg"
|
2017-03-07 00:32:48 +11:00
|
|
|
|
|
|
|
# TODO(ijw): deal with username and password
|
|
|
|
|
|
|
|
sleep 2 # settle time for the daemon
|
2017-04-23 05:26:55 +10:00
|
|
|
etcdctl $args rm --recursive /networking-vpp 2>/dev/null ||:
|
2017-03-07 00:32:48 +11:00
|
|
|
}
|