From a5961cff804d2ea7875f1c60140edff5b961e5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Albert?= Date: Tue, 12 May 2015 11:55:27 +0200 Subject: [PATCH] Added support for dashboard in devstack Moved to devstack plugin. Added section in the documentation related to CloudKitty's devstack integration. Change-Id: I9a7ce8c73724a54fb7855d788a1c4cb56a832535 --- contrib/devstack/extras.d/70-cloudkitty.sh | 33 ---------- {contrib/devstack => devstack}/README.rst | 0 .../lib/cloudkitty => devstack/plugin.sh | 60 ++++++++++++++++++- doc/source/devstack.rst | 11 ++++ doc/source/index.rst | 1 + 5 files changed, 71 insertions(+), 34 deletions(-) delete mode 100644 contrib/devstack/extras.d/70-cloudkitty.sh rename {contrib/devstack => devstack}/README.rst (100%) rename contrib/devstack/lib/cloudkitty => devstack/plugin.sh (80%) create mode 100644 doc/source/devstack.rst diff --git a/contrib/devstack/extras.d/70-cloudkitty.sh b/contrib/devstack/extras.d/70-cloudkitty.sh deleted file mode 100644 index 197198c4..00000000 --- a/contrib/devstack/extras.d/70-cloudkitty.sh +++ /dev/null @@ -1,33 +0,0 @@ -# cloudkitty.sh - Devstack extras script to install CloudKitty - -if is_service_enabled ck-api; then - if [[ "$1" == "source" ]]; then - # Initial source - source $TOP_DIR/lib/cloudkitty - elif [[ "$1" == "stack" && "$2" == "install" ]]; then - echo_summary "Installing CloudKitty" - install_cloudkitty - install_python_cloudkittyclient - cleanup_cloudkitty - elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then - echo_summary "Configuring CloudKitty" - configure_cloudkitty - - if is_service_enabled key; then - create_cloudkitty_accounts - fi - - elif [[ "$1" == "stack" && "$2" == "extra" ]]; then - # Initialize cloudkitty - echo_summary "Initializing CloudKitty" - init_cloudkitty - - # Start the CloudKitty API and CloudKitty processor components - echo_summary "Starting CloudKitty" - start_cloudkitty - fi - - if [[ "$1" == "unstack" ]]; then - stop_cloudkitty - fi -fi diff --git a/contrib/devstack/README.rst b/devstack/README.rst similarity index 100% rename from contrib/devstack/README.rst rename to devstack/README.rst diff --git a/contrib/devstack/lib/cloudkitty b/devstack/plugin.sh similarity index 80% rename from contrib/devstack/lib/cloudkitty rename to devstack/plugin.sh index 14ce4eca..e88bb9ad 100644 --- a/contrib/devstack/lib/cloudkitty +++ b/devstack/plugin.sh @@ -1,4 +1,4 @@ -# lib/cloudkitty +# CloudKitty devstack plugin # Install and start **CloudKitty** service # To enable a minimal set of CloudKitty services: @@ -14,6 +14,7 @@ # - SERVICE_PASSWORD, SERVICE_TENANT_NAME for auth in api # - IDENTITY_API_VERSION for the version of Keystone # - STACK_USER service user +# - HORIZON_DIR for horizon integration # stack.sh # --------- @@ -40,6 +41,10 @@ CLOUDKITTY_CONF=$CLOUDKITTY_CONF_DIR/cloudkitty.conf CLOUDKITTY_API_LOG_DIR=/var/log/cloudkitty CLOUDKITTY_AUTH_CACHE_DIR=${CLOUDKITTY_AUTH_CACHE_DIR:-/var/cache/cloudkitty} CLOUDKITTY_REPORTS_DIR=${DATA_DIR}/cloudkitty/reports +# Horizon enabled file +CLOUDKITTY_DASHBOARD=$DEST/cloudkitty-dashboard/cloudkittydashboard +CLOUDKITTY_ENABLED_FILE=${CLOUDKITTY_ENABLED_FILE:-${CLOUDKITTY_DASHBOARD}/_90_enable_ck.py} +CLOUDKITTY_HORIZON_ENABLED_FILE=${CLOUDKITTY_HORIZON_ENABLED_FILE:-$HORIZON_DIR/openstack_dashboard/enabled/_90_enable_ck.py} # Support potential entry-points console scripts if [[ -d $CLOUDKITTY_DIR/bin ]]; then @@ -80,6 +85,11 @@ GITREPO["python-cloudkittyclient"]=${CLOUDKITTYCLIENT_REPO:-${GIT_BASE}/stackfor GITDIR["python-cloudkittyclient"]=$DEST/python-cloudkittyclient GITBRANCH["python-cloudkittyclient"]=${CLOUDKITTYCLIENT_BRANCH:-master} +# Set CloudKitty dashboard info +GITREPO["cloudkitty-dashboard"]=${CLOUDKITTYDASHBOARD_REPO:-${GIT_BASE}/stackforge/cloudkitty-dashboard.git} +GITDIR["cloudkitty-dashboard"]=$DEST/cloudkitty-dashboard +GITBRANCH["cloudkitty-dashboard"]=${CLOUDKITTYDASHBOARD_BRANCH:-master} + # Tell Tempest this project is present TEMPEST_SERVICES+=,cloudkitty @@ -109,6 +119,9 @@ function create_cloudkitty_accounts { # Make cloudkitty an admin get_or_add_user_project_role admin cloudkitty service + + # Make CloudKitty monitor demo project for rating purposes + get_or_add_user_project_role rating cloudkitty demo } # Test if any CloudKitty services are enabled @@ -125,6 +138,7 @@ function cleanup_cloudkitty { rm -rf $CLOUDKITTY_AUTH_CACHE_DIR/* rm -rf $CLOUDKITTY_CONF_DIR/* rm -rf $CLOUDKITTY_OUTPUT_BASEPATH/* + sudo rm $CLOUDKITTY_HORIZON_ENABLED_FILE } # configure_cloudkitty() - Set config files, create data dirs, etc @@ -241,6 +255,50 @@ function install_python_cloudkittyclient { setup_dev_lib "python-cloudkittyclient" } +# install_cloudkitty_dashboard() - Collect source and prepare +function install_cloudkitty_dashboard { + # Install from git since we don't have a release (yet) + git_clone_by_name "cloudkitty-dashboard" + setup_dev_lib "cloudkitty-dashboard" + sudo ln -s $CLOUDKITTY_ENABLED_FILE $CLOUDKITTY_HORIZON_ENABLED_FILE + restart_apache_server +} + +if is_service_enabled ck-api; then + if [[ "$1" == "source" ]]; then + # Initial source + source $TOP_DIR/lib/cloudkitty + elif [[ "$1" == "stack" && "$2" == "install" ]]; then + echo_summary "Installing CloudKitty" + install_cloudkitty + install_python_cloudkittyclient + if is_service_enabled horizon; then + install_cloudkitty_dashboard + fi + cleanup_cloudkitty + elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then + echo_summary "Configuring CloudKitty" + configure_cloudkitty + + if is_service_enabled key; then + create_cloudkitty_accounts + fi + + elif [[ "$1" == "stack" && "$2" == "extra" ]]; then + # Initialize cloudkitty + echo_summary "Initializing CloudKitty" + init_cloudkitty + + # Start the CloudKitty API and CloudKitty processor components + echo_summary "Starting CloudKitty" + start_cloudkitty + fi + + if [[ "$1" == "unstack" ]]; then + stop_cloudkitty + fi +fi + # Restore xtrace $XTRACE diff --git a/doc/source/devstack.rst b/doc/source/devstack.rst new file mode 100644 index 00000000..f3a598ec --- /dev/null +++ b/doc/source/devstack.rst @@ -0,0 +1,11 @@ +##################### +Devstack installation +##################### + +The installation of CloudKitty from devstack is pretty straightforward. Just +add these two lines to your local.conf file. + +:: + + enable_plugin cloudkitty https://github.com/stackforge/cloudkitty master + enable_service ck-api ck-proc diff --git a/doc/source/index.rst b/doc/source/index.rst index df5c584b..731013fe 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -20,6 +20,7 @@ Installation :maxdepth: 1 installation + devstack Architecture