From 5ef6c3e2e40954886c72d7705cddf421966ea0b8 Mon Sep 17 00:00:00 2001 From: Nathan Reller Date: Sun, 13 Mar 2016 14:14:04 -0400 Subject: [PATCH] Added KMIP Secret Store to Devstack Added code to devstack libraries to allow KMIP secret store to be enabled. This edits barbican.conf to enable the KMIP secret store. The Barbican PyKMIP client can be configured to connect to an existing KMIP device or use PyKMIP's server. If the client configuration is all that is needed then enable the 'barbican-pykmip' service in the devstack configuration and set the appropriate key, certificate, and CA path variables. This will allow the Barbican KMIP secret store to connect to an existing KMIP server. If a KMIP server is requested then also enable the 'pykmip-server' service in the devstack configuration. This will install, configure, and start the KMIP server. This option requires the 'barbican-pykmip' service be configured as well. Added passenv command to tox to allow the KMIP_PLUGIN_ENABLED environment variable to be passed to the underlying command. Without this the environment variable will not be seen by the tox command. Change-Id: Ib804fa97545f14ed866bfd73bb251e85923a2e4e Depends-On: Ifda13a84607bb199b794dc24f5dbba0ee8108dbf --- devstack/lib/barbican | 59 +++++++++++++++++++++++++++++++++++++++++++ devstack/plugin.sh | 12 +++++++++ devstack/settings | 4 +++ test-requirements.txt | 2 +- tox.ini | 1 + 5 files changed, 77 insertions(+), 1 deletion(-) diff --git a/devstack/lib/barbican b/devstack/lib/barbican index 798743fb2..5daa6cf17 100644 --- a/devstack/lib/barbican +++ b/devstack/lib/barbican @@ -25,6 +25,12 @@ XTRACE=$(set +o | grep xtrace) set +o xtrace +# PyKMIP configuration +PYKMIP_SERVER_KEY=${PYKMIP_SERVER_KEY:-$INT_CA_DIR/private/pykmip-server.key} +PYKMIP_SERVER_CERT=${PYKMIP_SERVER_CERT:-$INT_CA_DIR/pykmip-server.crt} +PYKMIP_CLIENT_KEY=${PYKMIP_CLIENT_KEY:-$INT_CA_DIR/private/pykmip-client.key} +PYKMIP_CLIENT_CERT=${PYKMIP_CLIENT_CERT:-$INT_CA_DIR/pykmip-client.crt} +PYKMIP_CA_PATH=${PYKMIP_CA_PATH:-$INT_CA_DIR/ca-chain.pem} # Functions # --------- @@ -355,6 +361,59 @@ function create_barbican_accounts { } +# PyKMIP functions +# ---------------- + +# install_pykmip - install the PyKMIP python module +# create keys and certificate for server +function install_pykmip { + pip_install 'pykmip' + + if is_service_enabled pykmip-server; then + [ ! -d ${PYKMIP_CONF_DIR} ] && sudo mkdir -p ${PYKMIP_CONF_DIR} + sudo chown ${USER} ${PYKMIP_CONF_DIR} + [ ! -d ${PYKMIP_LOG_DIR} ] && sudo mkdir -p ${PYKMIP_LOG_DIR} + sudo chown ${USER} ${PYKMIP_LOG_DIR} + + init_CA + if [ ! -e ${PYKMIP_SERVER_KEY} ]; then + make_cert ${INT_CA_DIR} 'pykmip-server' 'pykmip-server' + chmod 400 ${PYKMIP_SERVER_KEY} + fi + if [ ! -e ${PYKMIP_CLIENT_KEY} ]; then + make_cert ${INT_CA_DIR} 'pykmip-client' 'pykmip-client' + chmod 400 ${PYKMIP_CLIENT_KEY} + fi + + if [ ! -e ${PYKMIP_CONF} ]; then + cat > ${PYKMIP_CONF} <=3.6 # Apache-2.0 hacking<0.11,>=0.10.0 mock>=1.2 # BSD oslotest>=1.10.0 # Apache-2.0 -pykmip>=0.4.0 # Apache 2.0 License +pykmip>=0.5.0 # Apache 2.0 License testrepository>=0.0.18 # Apache-2.0/BSD testtools>=1.4.0 # MIT fixtures<2.0,>=1.3.1 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index dfa9345ba..ee9e09d0e 100644 --- a/tox.ini +++ b/tox.ini @@ -116,6 +116,7 @@ setenv = OS_TEST_PATH={toxinidir}/functionaltests commands = /usr/bin/find . -type f -name "*.pyc" -delete /bin/bash {toxinidir}/functionaltests/pretty_tox.sh '{posargs}' +passenv = KMIP_PLUGIN_ENABLED [flake8] exclude = .git,.idea,.tox,bin,dist,debian,rpmbuild,tools,*.egg-info,*.eggs,*openstack/common,contrib,