Barbican grenade plugin

This patch set will add a upgrade plugin for Grenade

Change-Id: I608dd17e5b22926a50e4d842da050e01f8bfc9cd
This commit is contained in:
Nam Nguyen Hoai 2017-03-15 15:34:16 +07:00
parent e88d79cae0
commit f6605c5129
4 changed files with 208 additions and 0 deletions

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

@ -0,0 +1,99 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -o errexit
source $GRENADE_DIR/grenaderc
source $GRENADE_DIR/functions
source $TOP_DIR/openrc admin admin
source $TOP_DIR/inc/ini-config
set -o xtrace
BARBICAN_USER=barbican_grenade
BARBICAN_PROJECT=barbican_grenade
BARBICAN_PASS=pass
function _barbican_set_user {
OS_TENANT_NAME=$BARBICAN_PROJECT
OS_PROJECT_NAME=$BARBICAN_PROJECT
OS_USERNAME=$BARBICAN_USER
OS_PASSWORD=$BARBICAN_PASS
}
function create {
# create a tenant for the server
eval $(openstack project create -f shell -c id $BARBICAN_PROJECT)
if [[ -z "$id" ]]; then
die $LINENO "Didn't create $BARBICAN_PROJECT project"
fi
resource_save barbican project_id $id
local project_id=$id
# create the user, and set $id locally
eval $(openstack user create $BARBICAN_USER \
--project $id \
--password $BARBICAN_PASS \
-f shell -c id)
if [[ -z "$id" ]]; then
die $LINENO "Didn't create $BARBICAN_USER user"
fi
resource_save barbican user_id $id
openstack role add admin --user $id --project $project_id
_barbican_set_user
local secret_name=test_secret
local secret_data=this_is_a_secret_data
barbican secret store -p $secret_data -n $secret_name
secret_link=$(barbican secret list | awk '/ test_secret / {print $2}')
resource_save barbican secret_link $secret_link
}
function verify {
_barbican_set_user
secret_link=$(resource_get barbican secret_link)
barbican secret get $secret_link
}
function verify_noapi {
:
}
function destroy {
_barbican_set_user
set +o errexit
barbican secret delete $(resource_get barbican secret_link)
local user_id=$(resource_get barbican user_id)
local project_id=$(resource_get barbican project_id)
openstack user delete $user_id
openstack project delete $project_id
}
# Dispatcher
case $1 in
"create")
create
;;
"verify")
verify
;;
"verify_noapi")
verify_noapi
;;
"destroy")
destroy
;;
esac

View File

@ -0,0 +1,8 @@
register_project_for_upgrade barbican
register_db_to_save barbican
devstack_localrc base enable_plugin barbican https://git.openstack.org/openstack/barbican
devstack_localrc target enable_plugin barbican https://git.openstack.org/openstack/barbican
devstack_localrc base enable_service barbican-svc barbican-retry
devstack_localrc target enable_service barbican-svc barbican-retry

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

@ -0,0 +1,30 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# shutdown barbican service
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 $BASE_DEVSTACK_DIR/lib/apache
BARBICAN_DEVSTACK_DIR=$(dirname "$0")/..
source $BARBICAN_DEVSTACK_DIR/lib/barbican
set -o xtrace
stop_barbican

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

@ -0,0 +1,71 @@
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# ``upgrade-barbican``
echo "*********************************************************************"
echo "Begin $0"
echo "*********************************************************************"
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 barbican
# 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.barbican ]] || cp -pr $BARBICAN_CONF_DIR $SAVE_DIR/etc.barbican
git_clone $BARBICAN_REPO $BARBICAN_DIR $BARBICAN_BRANCH
setup_develop $BARBICAN_DIR
# calls upgrade-barbican for specific release
upgrade_project barbican $RUN_DIR $BASE_DEVSTACK_BRANCH $TARGET_DEVSTACK_BRANCH
$BARBICAN_BIN_DIR/barbican-manage db upgrade -v head || die $LINENO "DB sync error"
# Start the Barbican service up.
run_process barbican-svc "uwsgi --master --emperor $BARBICAN_CONF_DIR/vassals"
sleep 10
run_process barbican-retry "$BARBICAN_BIN_DIR/barbican-retry --config-file=$BARBICAN_CONF_DIR/barbican-api.conf"