Grenade Plugin

Change-Id: I890fd4c6e329ad1875bac00e98156f90f52c78f5
This commit is contained in:
Graham Hayes 2016-07-11 13:21:52 +01:00
parent 8e19e56f3e
commit f374b5fe2c
5 changed files with 306 additions and 0 deletions

View File

@ -105,6 +105,11 @@ if [ ! -d "/home/vagrant/devstack" ]; then
git clone https://git.openstack.org/openstack-dev/devstack.git /home/vagrant/devstack git clone https://git.openstack.org/openstack-dev/devstack.git /home/vagrant/devstack
fi fi
if [ -d "/opt/stack/grenade" ]; then
mkdir /opt/stack/plugins
ln -s /opt/stack/designate /opt/stack/plugins/designate
fi
# Install Vagrant local.conf sample # Install Vagrant local.conf sample
cd /opt/stack/designate/contrib/vagrant cd /opt/stack/designate/contrib/vagrant

166
devstack/upgrade/resources.sh Executable file
View File

@ -0,0 +1,166 @@
#!/bin/bash
set -o errexit
source $GRENADE_DIR/grenaderc
source $GRENADE_DIR/functions
source $TOP_DIR/openrc admin admin
set -o xtrace
DESIGNATE_PROJECT=designate_grenade
DESIGNATE_USER=designate_grenade
DESIGNATE_PASS=designate_grenade
DESIGNATE_ZONE_NAME=example.com.
DESIGNATE_ZONE_EMAIL=hostmaster@example.com
DESIGNATE_RRSET_NAME=www.example.com.
DESIGNATE_RRSET_TYPE=A
DESIGNATE_RRSET_RECORD=10.0.0.1
function _set_designate_user {
OS_TENANT_NAME=$DESIGNATE_PROJECT
OS_PROJECT_NAME=$DESIGNATE_PROJECT
OS_USERNAME=$DESIGNATE_USER
OS_PASSWORD=$DESIGNATE_PASS
}
function create {
# create a tenant for the server
eval $(openstack project create -f shell -c id $DESIGNATE_PROJECT)
if [[ -z "$id" ]]; then
die $LINENO "Didn't create $DESIGNATE_PROJECT project"
fi
resource_save designate project_id $id
# create the user, and set $id locally
eval $(openstack user create $DESIGNATE_USER \
--project $id \
--password $DESIGNATE_PASS \
-f shell -c id)
if [[ -z "$id" ]]; then
die $LINENO "Didn't create $DESIGNATE_USER user"
fi
resource_save designate user_id $id
_set_designate_user
# Create a zone, and save the id
eval $(openstack zone create --email $DESIGNATE_ZONE_EMAIL \
$DESIGNATE_ZONE_NAME \
-f shell -c id)
resource_save designate zone_id $id
eval $(openstack recordset create --records $DESIGNATE_RRSET_RECORD \
--type $DESIGNATE_RRSET_TYPE \
$DESIGNATE_ZONE_NAME \
$DESIGNATE_RRSET_NAME \
-f shell -c id)
resource_save designate rrset_id $id
# wait until rrset moves to active state
local timeleft=1000
while [[ $timeleft -gt 0 ]]; do
local status
eval $(openstack recordset show $DESIGNATE_ZONE_NAME \
$DESIGNATE_RRSET_NAME \
-f shell -c status)
if [[ "$status" != "ACTIVE" ]]; then
if [[ "$cluster_state" == "Error" ]]; then
die $LINENO "Zone is in Error state"
fi
echo "Zone is still not in Active state"
sleep 10
timeleft=$((timeleft - 10))
if [[ $timeleft == 0 ]]; then
die $LINENO "Zone hasn't moved to Active state \
during 1000 seconds"
fi
else
break
fi
done
}
function verify {
_set_designate_user
# check that cluster is in Active state
local zone_id
zone_id=$(resource_get designate zone_id)
local rrset_id
rrset_id=$(resource_get designate rrset_id)
eval $(openstack zone show $zone_id -f shell -c status)
echo -n $status
if [[ "$status" != "ACTIVE" ]]; then
die $LINENO "Zone is not in Active state anymore"
fi
eval $(openstack recordset show $zone_id $rrset_id -f shell -c status)
echo -n $status
if [[ "$status" != "ACTIVE" ]]; then
die $LINENO "Recordset is not in Active state anymore"
fi
echo "Designate verification: SUCCESS"
}
function verify_noapi {
:
}
function destroy {
_set_designate_user
set +o errexit
# delete cluster
local cluster_id
zone_id=$(resource_get designate zone_id)
openstack zone delete $zone_id > /dev/null
# wait for cluster deletion
local timeleft=500
while [[ $timeleft -gt 0 ]]; do
openstack zone show $zone_id > /dev/null
local rc=$?
if [[ "$rc" != 1 ]]; then
echo "Zone still exists"
sleep 5
timeleft=$((timeleft - 5))
if [[ $timeleft == 0 ]]; then
die $LINENO "Zone hasn't been deleted during 500 seconds"
fi
else
break
fi
done
}
# Dispatcher
case $1 in
"create")
create
;;
"verify_noapi")
verify_noapi
;;
"verify")
verify
;;
"destroy")
destroy
;;
"force_destroy")
set +o errexit
destroy
;;
esac

11
devstack/upgrade/settings Normal file
View File

@ -0,0 +1,11 @@
register_project_for_upgrade designate
register_db_to_save designate
devstack_localrc base enable_plugin designate https://git.openstack.org/openstack/designate
devstack_localrc target enable_plugin designate https://git.openstack.org/openstack/designate
devstack_localrc base DESIGNATE_BACKEND_DRIVER=powerdns
devstack_localrc target DESIGNATE_BACKEND_DRIVER=powerdns
devstack_localrc base enable_service designate-api designate-central designate-pool-manager designate-zone-manager designate-mdns designate-agent designate-sink designate
devstack_localrc target enable_service designate-api designate-central designate-pool-manager designate-zone-manager designate-mdns designate-agent designate-sink designate

28
devstack/upgrade/shutdown.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# ``shutdown-designate``
set -o errexit
source $GRENADE_DIR/grenaderc
source $GRENADE_DIR/functions
# We need base DevStack functions for this
source $BASE_DEVSTACK_DIR/functions
source $BASE_DEVSTACK_DIR/stackrc # needed for status directory
source $BASE_DEVSTACK_DIR/lib/tls
source ${GITDIR[designate]}/devstack/plugin.sh
set -o xtrace
stop_process designate-central
stop_process designate-api
stop_process designate-pool-manager
stop_process designate-zone-manager
stop_process designate-mdns
stop_process designate-agent
stop_process designate-sink
# sanity check that service is actually down
ensure_services_stopped designate-api designate-central designate-pool-manager designate-zone-manager designate-mdns designate-agent designate-sink

96
devstack/upgrade/upgrade.sh Executable file
View File

@ -0,0 +1,96 @@
#!/usr/bin/env bash
# ``upgrade-designate``
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
RUN_DIR=$(cd $(dirname "$0") && pwd)
# Source params
source $GRENADE_DIR/grenaderc
# Import common functions
source $GRENADE_DIR/functions
# This script exits on an error so that errors don't compound and you see
# only the first error that occurred.
set -o errexit
# Upgrade designate
# ============
# Get functions from current DevStack
source $TARGET_DEVSTACK_DIR/stackrc
source $TARGET_DEVSTACK_DIR/lib/tls
source $(dirname $(dirname $BASH_SOURCE))/plugin.sh
source $(dirname $(dirname $BASH_SOURCE))/settings
# 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
# Save current config files for posterity
[[ -d $SAVE_DIR/etc.designate ]] || cp -pr $DESIGNATE_CONF_DIR $SAVE_DIR/etc.designate
# install_designate()
if is_ubuntu; then
install_package libcap2-bin
elif is_fedora; then
# bind-utils package provides `dig`
install_package libcap bind-utils
fi
git_clone $DESIGNATE_REPO $DESIGNATE_DIR $DESIGNATE_BRANCH
setup_develop $DESIGNATE_DIR
install_designateclient
# calls upgrade-designate for specific release
upgrade_project designate $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH
# Migrate the database
$DESIGNATE_BIN_DIR/designate-manage --config-file $DESIGNATE_CONF \
database sync || die $LINENO "DB sync error"
# Start designate
run_process designate-central "$DESIGNATE_BIN_DIR/designate-central --config-file $DESIGNATE_CONF"
run_process designate-api "$DESIGNATE_BIN_DIR/designate-api --config-file $DESIGNATE_CONF"
run_process designate-pool-manager "$DESIGNATE_BIN_DIR/designate-pool-manager --config-file $DESIGNATE_CONF"
run_process designate-zone-manager "$DESIGNATE_BIN_DIR/designate-zone-manager --config-file $DESIGNATE_CONF"
run_process designate-mdns "$DESIGNATE_BIN_DIR/designate-mdns --config-file $DESIGNATE_CONF"
run_process designate-agent "$DESIGNATE_BIN_DIR/designate-agent --config-file $DESIGNATE_CONF"
run_process designate-sink "$DESIGNATE_BIN_DIR/designate-sink --config-file $DESIGNATE_CONF"
# Start proxies if enabled
if is_service_enabled designate-api && is_service_enabled tls-proxy; then
start_tls_proxy '*' $DESIGNATE_SERVICE_PORT $DESIGNATE_SERVICE_HOST $DESIGNATE_SERVICE_PORT_INT &
fi
if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- $DESIGNATE_SERVICE_PROTOCOL://$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT; do sleep 1; done"; then
die $LINENO "Designate did not start"
fi
# Don't succeed unless the service come up
ensure_services_started designate-api designate-central designate-pool-manager designate-zone-manager designate-mdns designate-agent designate-sink
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End $0"
echo "*********************************************************************"