
Agent will still need privs for host bridge manipulations and for this the standard sudo-helper mechanism should hold. Change-Id: Ia61e4a80abaaccfeeaf82564823032b9a910fd3d Closes-Bug: 1651309
98 lines
3.3 KiB
Bash
98 lines
3.3 KiB
Bash
#!/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
|
|
baseurl=https://nexus.fd.io/content/repositories/fd.io.$VPP_BRANCH.centos7/
|
|
enabled=1
|
|
gpgcheck=0
|
|
EOF
|
|
sudo yum --enablerepo=fdio-master clean metadata
|
|
elif is_ubuntu; then
|
|
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
|
|
else
|
|
die $LINENO "Can't install VPP on unsupported os: $os_VENDOR"
|
|
fi
|
|
install_package vpp
|
|
# 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
|
|
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
|
|
# 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
|
|
user="$(id -un)"
|
|
sudo sed -i "/api-segment *{/a\ \ uid $user" /etc/vpp/startup.conf
|
|
sudo sed -i "/dpdk *{/a\ \ dev $VPP_INT_PCI_DEV" /etc/vpp/startup.conf
|
|
else
|
|
die $LINENO "VPP_STARTUP_CONFIG or VPP_INT_PCI_DEV must be set"
|
|
fi
|
|
}
|
|
|
|
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
|
|
|
|
# This relies on a bunch of etcd state, and if you're stacking and unstacking
|
|
# stale cruft builds up.
|
|
|
|
clean_etcd
|
|
|
|
set_hugepages
|
|
systemctl is-active vpp || start_vpp
|
|
}
|
|
|
|
function clean_etcd() {
|
|
|
|
# etcd_host may be complex, so we do our best with it
|
|
|
|
if [[ ! "$ETCD_HOST" =~ "://" ]] ; then
|
|
hostarg=""
|
|
for f in $(echo "$ETCD_HOST" | tr "," "\n"); do
|
|
hostarg="$hostarg,http://$f:$ETCD_PORT/"
|
|
done
|
|
# Strip that leading comma
|
|
|
|
hostarg="${hostarg:1}"
|
|
else
|
|
hostarg="$ETCD_HOST"
|
|
fi
|
|
args="--endpoints $hostarg"
|
|
|
|
# TODO(ijw): deal with username and password
|
|
|
|
sleep 2 # settle time for the daemon
|
|
etcdctl rm --recursive /networking-vpp 2>/dev/null
|
|
}
|