-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch adds a DevStack plugin to cinderlib so it can be installed directly by DevStack and used for CI jobs as well as development. When installing it will also get the Cinder configuration and generate a .py file with the right initialization of the different backends that have been configured in /etc/cinder/cinder.conf by the DevStack Cinder job and its plugins. Change-Id: I12f6b0e1bc047f1915e4f7532ea59495477f9b4a
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
This directory contains the cinderlib DevStack plugin. | ||
|
||
To configure cinderlib with DevStack, you will need to enable this plugin by | ||
adding one line to the [[local|localrc]] section of your local.conf file. | ||
|
||
To enable the plugin, add a line of the form: | ||
|
||
enable_plugin cinderlib <GITURL> [GITREF] | ||
|
||
where | ||
|
||
<GITURL> is the URL of a cinderlib repository | ||
[GITREF] is an optional git ref (branch/ref/tag). The default is master. | ||
|
||
For example: | ||
|
||
enable_plugin cinderlib https://git.openstack.org/openstack/cinderlib | ||
|
||
Another example using Stein's stable branch: | ||
|
||
enable_plugin cinderlib https://git.openstack.org/openstack/cinderlib stable/stein | ||
|
||
The cinderlib DevStack plugin will install cinderlib from Git by default, but | ||
it can installed from PyPi using the `CINDERLIB_FROM_GIT` configuration option. | ||
|
||
CINDERLIB_FROM_GIT=False | ||
|
||
The plugin will also generate the code equivalent to the deployed Cinder's | ||
configuration in `$CINDERLIB_SAMPLE_DIR/cinderlib.py` which defaults to the | ||
same directory where the Cinder configuration is saved. | ||
|
||
For more information, see the [DevStack plugin documentation](https://docs.openstack.org/devstack/latest/plugins.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ALL_LIBS+=" cinderlib" | ||
CINDERLIB_FROM_GIT=$(trueorfalse True CINDERLIB_FROM_GIT) | ||
|
||
if [[ "$CINDERLIB_FROM_GIT" == "True" ]]; then | ||
PROJECTS="openstack/cinderlib $PROJECTS" | ||
LIBS_FROM_GIT="cinderlib,$LIBS_FROM_GIT" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# plugin.sh - DevStack plugin.sh dispatch script for cinderlib | ||
|
||
_XTRACE_CINDERLIB=$(set +o | grep xtrace) | ||
|
||
function install_cinderlib { | ||
if use_library_from_git "cinderlib"; then | ||
git_clone_by_name "cinderlib" | ||
setup_dev_lib "cinderlib" | ||
else | ||
pip_install cinderlib | ||
fi | ||
} | ||
|
||
function generate_python_code { | ||
if use_library_from_git "cinderlib"; then | ||
sudo ${GITDIR["cinderlib"]}/tools/cinder-cfg-to-python.py $CINDER_CONF $CINDERLIB_SAMPLE | ||
else | ||
# We need to download the script since it's not part of the pypi package | ||
curl -s https://git.openstack.org/cgit/openstack/cinderlib/plain/tools/cinder-cfg-to-python.py | sudo python - $CINDER_CONF $CINDERLIB_SAMPLE | ||
fi | ||
} | ||
|
||
stable_compare="stable/[a-r]" | ||
# Cinderlib only makes sense if Cinder is enabled and we are in stein or later | ||
if [[ ! "${GITBRANCH["cinderlib"]}" =~ $stable_compare ]] && is_service_enabled cinder; then | ||
|
||
if [[ "$1" == "stack" && "$2" == "install" ]]; then | ||
# Perform installation of service source | ||
echo_summary "Installing cinderlib" | ||
install_cinderlib | ||
|
||
# Plugins such as Ceph configure themselves at post-config, so we have to | ||
# configure ourselves at the next stage, "extra" | ||
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then | ||
# Generate the cinderlib configuration | ||
echo_summary "Generating cinderlib initialization example python code" | ||
generate_python_code | ||
fi | ||
|
||
if [[ "$1" == "clean" || "$1" == "unstack" ]]; then | ||
echo_summary "Removing cinderlib and its code example from cinder.conf" | ||
sudo rm -f $CINDERLIB_SAMPLE | ||
pip_uninstall cinderlib | ||
fi | ||
fi | ||
|
||
# Restore xtrace | ||
$_XTRACE_CINDERLIB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Defaults | ||
# -------- | ||
|
||
# Set up default directories | ||
CINDERLIB_SAMPLE_DIR=${CINDERLIB_CONF_DIR:-/etc/cinder} | ||
CINDERLIB_SAMPLE=$CINDERLIB_SAMPLE_DIR/cinderlib.py | ||
CINDERLIB_FROM_GIT=$(trueorfalse True CINDERLIB_FROM_GIT) | ||
|
||
define_plugin cinderlib |