Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 237 lines (189 sloc) 8.56 KB
#!/usr/bin/env bash
# ``upgrade-nova``
echo "*********************************************************************"
echo "Begin $0"
echo "*********************************************************************"
# Clean up any resources that may be in use
cleanup() {
set +o errexit
echo "*********************************************************************"
echo "ERROR: Abort $0"
echo "*********************************************************************"
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM
# Keep track of the grenade directory
GRENADE_DIR=$(cd $(dirname "$0") && pwd)
# Import common functions
source $GRENADE_DIR/functions
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
# and ``DISTRO``
GetDistro
# Source params
source $GRENADE_DIR/grenaderc
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Upgrade Nova
# ============
# Kill running Nova processes
for serv in n-api n-cauth n-cpu n-crt n-net n-novnc n-obj n-sch n-vol n-xvnc; do
screen -S $SCREEN_NAME -p $serv -X kill
done
# Support entry points installation of console scripts
if [ -d $NOVA_DIR/bin ] ; then
NOVA_BIN_DIR=$NOVA_DIR/bin
else
NOVA_BIN_DIR=/usr/local/bin
fi
if [[ "$os_PACKAGE" = "deb" ]]; then
NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap
else
NOVA_ROOTWRAP=/usr/bin/nova-rootwrap
fi
NOVA_CONF_DIR=${NOVA_CONF_DIR:-/etc/nova}
NOVA_CONF=${NOVA_CONF:-$NOVA_CONF_DIR/nova.conf}
NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini}
NOVNC_DIR=$DEST/noVNC
QUANTUMCLIENT_DIR=$DEST/python-quantumclient
QUANTUM_DIR=$DEST/quantum
SYSLOG=`trueorfalse False $SYSLOG`
# Duplicate some setup bits from trunk DevStack
cd $TRUNK_DEVSTACK_DIR
source $TRUNK_DEVSTACK_DIR/stackrc
# Get functions from current DevStack
source $TRUNK_DEVSTACK_DIR/lib/cinder
RECLONE=yes
install_cinder
setup_develop $CINDERCLIENT_DIR
# install_quantumclient()
[[ -d $QUANTUMCLIENT_DIR ]] && sudo chown -R `whoami` $QUANTUMCLIENT_DIR
git_clone $QUANTUM_CLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUM_CLIENT_BRANCH
setup_develop $QUANTUMCLIENT_DIR
# install_nova()
sudo chown -R `whoami` $NOVACLIENT_DIR $NOVA_DIR
git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
# configure_quantumclient()
setup_develop $QUANTUMCLIENT_DIR
# configure_nova()
setup_develop $NOVACLIENT_DIR
setup_develop $NOVA_DIR
# ``nova.conf``
# Normally created from scratch on each run if ``stack.sh``
# Until we can call that without duplicating the code just convert the old one
[[ -r $NOVA_CONF.$START_RELEASE ]] || \
cp -p $NOVA_CONF $NOVA_CONF.$START_RELEASE
cp -p $NOVA_CONF.$START_RELEASE $NOVA_CONF
if is_service_enabled cinder; then
# Move to Cinder
#+volume_api_class=nova.volume.cinder.API
iniset $NOVA_CONF DEFAULT volume_api_class nova.volume.cinder.API
#-volume_group=nova-volumes
inicomment $NOVA_CONF DEFAULT volume_group
#-volume_name_template=volume-%08x
inicomment $NOVA_CONF DEFAULT volume_name_template
#-iscsi_helper=tgtadm
inicomment $NOVA_CONF DEFAULT iscsi_helper
fi
#+libvirt_cpu_mode=none
iniset $NOVA_CONF DEFAULT libvirt_cpu_mode none
#-connection_type=libvirt
#+compute_driver=libvirt.LibvirtDriver
# if not OpenVZ - not supported...leave in even if it is the default
if [[ "$(iniget $NOVA_CONF DEFAULT connection_type)" == "libvirt" ]]; then
# Explicitly set the new default value
inicomment $NOVA_CONF DEFAULT connection_type
iniset $NOVA_CONF DEFAULT compute_driver libvirt.LibvirtDriver
fi
if [ "$SYSLOG" != "False" ]; then
iniset $NOVA_CONF DEFAULT use_syslog True
fi
#+logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
# Add color to logging output
iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
iniset $NOVA_CONF DEFAULT logging_default_format_string "%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
iniset $NOVA_CONF DEFAULT logging_debug_format_suffix "from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
iniset $NOVA_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s TRACE %(name)s %(instance)s"
else
# Show user_name and project_name instead of user_id and project_id
iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
fi
if is_service_enabled cinder; then
# Force nova volumes off
NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/osapi_volume,//")
fi
#+enabled_apis=ec2,osapi_compute,metadata
iniset $NOVA_CONF DEFAULT enabled_apis $NOVA_ENABLED_APIS
# ``api-paste.ini``
# Get template from source and migrate auth settings
[[ -r $NOVA_API_PASTE_INI.$START_RELEASE ]] || \
cp -p $NOVA_API_PASTE_INI $NOVA_API_PASTE_INI.$START_RELEASE
cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_API_PASTE_INI
for key in auth_host auth_port auth_protocol admin_tenant_name admin_user admin_password; do
iniset $NOVA_API_PASTE_INI filter:authtoken $key $(iniget $NOVA_API_PASTE_INI.$START_RELEASE filter:authtoken $key)
done
# ``policy.json``
# New file
cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR
# rootwrap
# If Nova ships the new rootwrap filters files, deploy them
# (owned by root) and add a parameter to ``$NOVA_ROOTWRAP``
ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP"
if [[ -d $NOVA_DIR/etc/nova/rootwrap.d ]]; then
# Wipe any existing rootwrap.d files first
if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then
sudo rm -rf $NOVA_CONF_DIR/rootwrap.d
fi
# Deploy filters to /etc/nova/rootwrap.d
sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d
sudo cp -p $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d
sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d
sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/*
# Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d
sudo cp -p $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/
sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf
sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf
sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf
# Specify rootwrap.conf as first parameter to nova-rootwrap
NOVA_ROOTWRAP="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf"
ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP *"
fi
# Set up the rootwrap sudoers for nova
TEMPFILE=`mktemp`
echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
chmod 0440 $TEMPFILE
sudo chown root:root $TEMPFILE
sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap
#-root_helper=sudo /usr/local/bin/nova-rootwrap
#+root_helper=sudo /usr/local/bin/nova-rootwrap /etc/nova/rootwrap.conf
iniset $NOVA_CONF DEFAULT root_helper "sudo $NOVA_ROOTWRAP"
# Migrate the database
nova-manage db sync || die "DB sync error"
# Update noVNC to new repo
if is_service_enabled n-novnc; then
[[ -d $NOVNC_DIR.$START_RELEASE ]] || mv $NOVNC_DIR $NOVNC_DIR.$START_RELEASE
# a websockets/html5 or flash powered VNC console for vm instances
git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH
fi
# Start Nova
screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api"
screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute"
screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert"
screen_it n-vol "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-volume"
screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network"
screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler"
screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF --web ."
screen_it n-xvnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-xvpvncproxy --config-file $NOVA_CONF"
screen_it n-cauth "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-consoleauth"
is_service_enabled swift3 || screen_it n-obj "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-objectstore"
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End $0"
echo "*********************************************************************"