Merge pull request #142 from dmend/management

Added management api and version resource
This commit is contained in:
John Wood 2013-06-10 16:19:01 -07:00
commit 592d406c6e
10 changed files with 56 additions and 137 deletions

View File

@ -57,3 +57,13 @@ def create_main_app(global_config, **local_conf):
api.add_route('/{0}'.format(performance_uri), performance)
return wsgi_app
def create_admin_app(global_config, **local_conf):
config.parse_args()
versions = res.VersionResource()
wsgi_app = api = falcon.API()
api.add_route('/', versions)
return wsgi_app

View File

@ -5,13 +5,12 @@
PKG=barbican
# For local development, set VENV_PYTHON equal to the path to your virtual environment's site-packages location
VENV=.venv
VENV_PYTHON=./$VENV/lib/python2.7/site-packages
VENV=${VENV:-.venv}
VENV_HOME=${VENV_HOME:-$PWD}
VENV_PYTHON=$VENV_HOME/$VENV/lib/python2.7/site-packages
PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/etc/$PKG:$PATH
PKG_DIR=/etc/$PKG
CONF_FILE=$PKG_DIR/barbican-api.ini
PASTE_FILE=$PKG_DIR/barbican-api-paste.ini
CONF_FILE=$PKG_DIR/barbican-api.conf
POLICY_FILE=$PKG_DIR/policy.json
SIGNING_DIR=$PKG_DIR/cache/
OPTS='--daemonize /var/log/barbican/uwsgi.log'
@ -19,10 +18,10 @@ OPTS='--daemonize /var/log/barbican/uwsgi.log'
# Configure for a local deployment environment:
if [ ! -f $CONF_FILE ];
then
CONF_FILE=./etc/$PKG/barbican-api.ini
PKG_DIR=$PWD/etc/$PKG
CONF_FILE=./etc/$PKG/barbican-api.conf
PYTHONPATH=$VENV_PYTHON:$PYTHONPATH
PASTE_FILE=$PWD/etc/$PKG/barbican-api-paste.ini
OPTS='-H ./'$VENV
OPTS='-H '$VENV_HOME/$VENV
# Copy conf file to home directory so oslo.config can find it
LOCAL_CONF_FILE=~/barbican-api.conf
@ -34,17 +33,17 @@ fi
# TODO: This is breaking deployment...need to analyze.
#if [ ! -f $POLICY_FILE ];
#then
#then
# LOCAL_POLICY_FILE=./etc/$PKG/policy.json
# mkdir -p $PKG_DIR
# sudo cp $LOCAL_POLICY_FILE POLICY_FILE
#fi
#
#if [ ! -f $SIGNING_DIR ];
#then
#then
# echo "making "$SIGNING_DIR
# sudo mkdir -p $SIGNING_DIR
# sudo mkdir -p $SIGNING_DIR
#fi
echo 'Running barbican-api uwsgi process, using init file here: ' $CONF_FILE
uwsgi --paste config:$PASTE_FILE --ini $CONF_FILE $OPTS
echo 'Running Barbican uWSGI Emperor '$PKG_DIR/vassals
uwsgi --master --emperor $PKG_DIR/vassals $OPTS

View File

@ -1,94 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: barbican-api
# Required-Start: $network $local_fs $remote_fs $syslog
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Barbican API server
# Description: Frontend Barbican API server
### END INIT INFO
# Author: John Wood <john.wood@rackspace.com>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Key Management Service API"
NAME=barbican-api
DAEMON=/usr/bin/barbican-api
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
. /lib/lsb/init-functions
do_start()
{
start-stop-daemon --start --background --quiet --chuid barbican:barbican --make-pidfile --pidfile $PIDFILE --startas $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --background --quiet --chuid barbican:barbican --make-pidfile --pidfile $PIDFILE --startas $DAEMON \
|| return 2
}
do_stop()
{
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
RETVAL="$?"
rm -f $PIDFILE
# TBD: HACK ALERT! Need to figure out why uwsgi spawns a separate process!
killall -s SIGKILL uwsgi
return "$RETVAL"
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1,4 +1,5 @@
etc/barbican/barbican-api-paste.ini etc/barbican
etc/barbican/barbican-admin-paste.ini etc/barbican
etc/barbican/barbican-api.conf etc/barbican
etc/barbican/barbican-api.ini etc/barbican
usr/bin/barbican-api
etc/barbican/vassals/barbican-api.ini etc/barbican/vassals
etc/barbican/vassals/barbican-admin.ini etc/barbican/vassals

7
debian/barbican-api.upstart vendored Normal file
View File

@ -0,0 +1,7 @@
# Barbican script
description "Barbican Key Management APIs"
start on runlevel [2345]
stop on runlevel [06]
exec uwsgi --master --die-on-term --emperor /etc/barbican/vassals --daemonize /var/log/barbican/uwsgi.log

View File

@ -0,0 +1,8 @@
[pipeline:main]
pipeline = unauthenticated-context admin
[app:admin]
paste.app_factory = barbican.api.app:create_admin_app
[filter:unauthenticated-context]
paste.filter_factory = barbican.api.middleware.context:UnauthenticatedContextMiddleware.factory

View File

@ -1,11 +0,0 @@
[uwsgi]
socket = :9311
protocol = http
processes = 1
master = true
vaccum = true
no-default-app = true
memory-report = true
pythonpath = /etc/barbican
module = barbican.api.app:application

View File

@ -0,0 +1,8 @@
[uwsgi]
socket = :9312
protocol = http
processes = 1
vacuum = true
no-default-app = true
memory-report = true
paste = config:/etc/barbican/barbican-admin-paste.ini

View File

@ -0,0 +1,8 @@
[uwsgi]
socket = :9311
protocol = http
processes = 1
vacuum = true
no-default-app = true
memory-report = true
paste = config:/etc/barbican/barbican-api-paste.ini

View File

@ -1,17 +0,0 @@
[uwsgi]
socket = :8080
protocol = http
processes = 1
master = true
vaccum = true
no-default-app = true
memory-report = true
#env = CONFIG_FILE=/etc/barbican/barbican.cfg
pythonpath = ./
module = barbican.api.app:application