Devstack setup for nova-dpm

+ Updated tox.ini to install nova
+ Modified tox_install script to install zhmcclient requirements and removed
conditional nova installation check because new folder nova introduced for
devstack setup always returns true for the check that verifies if nova is
already installed

blueprint: devstack-setup-nova

Change-Id: I0c16e4bdda38eb331fa76010e39b5d8457475af4
This commit is contained in:
preethipy 2016-12-07 19:54:17 +05:30 committed by Sreeram Vancheeswaran
parent 3b2c0aa7ac
commit 00c646ab77
13 changed files with 362 additions and 40 deletions

63
devstack/README.rst Normal file
View File

@ -0,0 +1,63 @@
========================
Installing with DevStack
========================
What is DevStack?
--------------------------
DevStack is a script to quickly create an OpenStack development environment.
Find out more `here <http://docs.openstack.org/developer/devstack/>`_.
What are DevStack plugins?
--------------------------
DevStack plugins act as project-specific extensions of DevStack. They allow external projects to
execute code directly in the DevStack run, supporting configuration and installation changes as
part of the normal local.conf and stack.sh execution. The devstack plugin setup in this project
is for nova-dpm. Without any additional scripting required the nova-dpm plugin would be plugged
to devstack environment.
More details can be `found here. <http://docs.openstack.org/developer/devstack/plugins.html>`_
How to use the nova-dpm DevStack plugins:
-----------------------------------------
1. Download DevStack::
$ git clone https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack
2. Set up your local.conf file to pull in our projects:
1. If you have an existing DevStack local.conf, modify it to pull in this project by adding::
[[local|localrc]]
enable_plugin nova-dpm http://git.openstack.org/openstack/nova-dpm
2. nova-dpm driver requires zhmcclient to be installed and hence add the following line to
install zhmcclient.
INSTALL_ZHMCCLIENT=TRUE
3. A few notes:
* By default this will pull in the latest/trunk versions of all the projects. If you want to
run a stable version instead, you can either check out that stable branch in the DevStack
repo (git checkout stable/liberty) which is the preferred method, or you can do it on a
project by project basis in the local.conf file as needed.
* If you need any special services enabled for your environment, you can also specify those
in your local.conf file. In our example files we demonstrate enabling and disabling services
(n-cpu, q-agt, etc) required for our drivers.
6. Run ``stack.sh`` from DevStack::
$ cd /opt/stack/devstack
$ FORCE=yes ./stack.sh
``FORCE=yes`` is needed on Ubuntu 15.10 since only Ubuntu LTS releases are officially supported
by DevStack. If you're running a control only node on a different, supported OS version you can
skip using ``FORCE=yes``.
7. At this point DevStack will run through stack.sh, and barring any DevStack issues, you should
end up with a standard link to your Horizon portal at the end of the stack run. Congratulations!

21
devstack/dpm-functions.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# devstack/dpm-functions.sh
# Functions to control the installation and configuration of the DPM compute services
GITREPO["zhmcclient"]=${ZHMCCLIENT_REPO:-https://github.com/zhmcclient/python-zhmcclient}
GITBRANCH["zhmcclient"]=${ZHMCCLIENT_BRANCH:-master}
GITDIR["zhmcclient"]=$DEST/zhmcclient
function install_zhmcclient {
# Install the latest zhmcclient from git
echo_summary "Installing zhmcclient"
git_clone_by_name "zhmcclient"
setup_dev_lib "zhmcclient"
echo_summary "zhmcclient install complete"
}
function cleanup_zhmcclient {
echo_summary "Cleaning zhmcclient"
rm -rf ${GITDIR["zhmcclient"]}
}

View File

@ -0,0 +1,21 @@
#Minimal Contents
#----------------
ADMIN_PASSWORD=admin
MYSQL_PASSWORD=mysql
RABBIT_PASSWORD=rabbit
SERVICE_PASSWORD=admin
SERVICE_TOKEN=service
[[local|localrc]]
# Enable plugins
enable_plugin nova-dpm https://git.openstack.org/openstack/nova-dpm.git
# Set to True to install the latest zhmcclient from source
INSTALL_ZHMCCLIENT=TRUE
#Logging
#-------
LOGFILE=/opt/stack/logs/stack.sh.log
SCREEN_LOGDIR=~/screen_log/
LOGDAYS=1

View File

@ -0,0 +1,3 @@
# Plug-in overrides
VIRT_DRIVER=dpm

134
devstack/plugin.sh Executable file
View File

@ -0,0 +1,134 @@
#!/bin/bash
#
# plugin.sh - Devstack extras script to install and configure the nova compute
# driver for dpm
# This driver is enabled in override-defaults with:
# VIRT_DRIVER=${VIRT_DRIVER:-dpm}
# The following entry points are called in this order for nova-dpm:
#
# - install_nova_dpm
# - configure_nova_dpm
# - start_nova_dpm
# - stop_nova_dpm
# - cleanup_nova_dpm
# Save trace setting
MY_XTRACE=$(set +o | grep xtrace)
set +o xtrace
# Defaults
# --------
# Set up base directories
NOVA_DIR=${NOVA_DIR:-$DEST/nova}
NOVA_CONF_DIR=${NOVA_CONF_DIR:-/etc/nova}
NOVA_CONF=${NOVA_CONF:-NOVA_CONF_DIR/nova.conf}
# nova-dpm directories
NOVA_DPM_DIR=${NOVA_DPM_DIR:-${DEST}/nova-dpm}
NOVA_DPM_PLUGIN_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
# Support entry points installation of console scripts
if [[ -d $NOVA_DIR/bin ]]; then
NOVA_BIN_DIR=$NOVA_DIR/bin
echo_summary $NOVA_BIN_DIR
else
NOVA_BIN_DIR=$(get_python_exec_prefix)
echo_summary $NOVA_BIN_DIR
fi
# Source functions
source $NOVA_DPM_PLUGIN_DIR/dpm-functions.sh
# Entry Points
# ------------
# configure_nova_dpm() - Configure the system to use nova_dpm
function configure_nova_dpm {
# Default configuration
iniset $NOVA_CONF DEFAULT compute_driver $DPM_DRIVER
# dpm configuration
iniset $NOVA_CONF dpm hmc $HMC
iniset $NOVA_CONF dpm hmc_username $HMC_USERNAME
iniset $NOVA_CONF dpm hmc_password $HMC_PASSWORD
iniset $NOVA_CONF dpm host $HOST
iniset $NOVA_CONF dpm cpc_uuid $CPC_UUID
iniset $NOVA_CONF dpm max_processors $MAX_PROC
iniset $NOVA_CONF dpm max_memory $MAX_MEM
iniset $NOVA_CONF dpm max_instances $MAX_INSTANCES
}
# install_nova_dpm() - Install nova_dpm and necessary dependencies
function install_nova_dpm {
if [[ "$INSTALL_ZHMCCLIENT" == "True" ]]; then
echo_summary "Installing zhmcclient"
install_zhmcclient
fi
# Install the nova-dpm package
setup_develop $NOVA_DPM_DIR
}
# start_nova_dpm() - Start the nova_dpm process
function start_nova_dpm {
# This function intentionally functionless as the
# compute service will start normally
:
}
# stop_nova_dpm() - Stop the nova_dpm process
function stop_nova_dpm {
# This function intentionally left blank as the
# compute service will stop normally
:
}
# cleanup_nova_dpm() - Cleanup the nova_dpm process
function cleanup_nova_dpm {
# This function intentionally left blank
:
}
# Core Dispatch
# -------------
if is_service_enabled nova-dpm; then
if [[ "$1" == "stack" && "$2" == "install" ]]; then
# Perform installation of nova-dpm
echo_summary "Installing nova-dpm"
install_nova_dpm
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
# Lay down configuration post install
echo_summary "Configuring nova-dpm"
configure_nova_dpm
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
# Initialize and start the nova-dpm/nova-compute service
echo_summary "Starting nova-dpm"
start_nova_dpm
fi
if [[ "$1" == "unstack" ]]; then
# Shut down nova-dpm/nova-compute
echo_summary "Stopping nova-dpm"
stop_nova_dpm
fi
if [[ "$1" == "clean" ]]; then
# Remove any lingering configuration data
# clean.sh first calls unstack.sh
echo_summary "Cleaning up nova-dpm and associated data"
cleanup_nova_dpm
cleanup_zhmcclient
fi
fi
# Restore xtrace
$MY_XTRACE
# Local variables:
# mode: shell-script
# End:

21
devstack/settings Normal file
View File

@ -0,0 +1,21 @@
# Devstack settings
# These defaults can be overridden in the localrc section of the local.conf file
# Add nova-dpm to enabled services
enable_service nova-dpm
# NovaLink install/upgrade settings
INSTALL_ZHMCCLIENT=$(trueorfalse False INSTALL_ZHMCCLIENT)
# Nova settings
DPM_DRIVER=dpm.driver.DPMDriver
# dpm settings
HMC=$HMC
HMC_USERNAME=$HMC_USERNAME
HMC_PASSWORD=$HMC_PASSWORD
HOST=$HOST
CPC_UUID=$CPC_UUID
MAX_PROC=$MAX_PROC
MAX_MEM=$MAX_MEM
MAX_INSTANCES=$MAX_INSTANCES

18
nova/__init__.py Normal file
View File

@ -0,0 +1,18 @@
# Copyright 2016 IBM Corp.
#
# All Rights Reserved.
#
# 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.
# Required to play nicely with namespace composition (PEP420).
__import__('pkg_resources').declare_namespace(__name__)

18
nova/virt/__init__.py Normal file
View File

@ -0,0 +1,18 @@
# Copyright 2016 IBM Corp.
#
# All Rights Reserved.
#
# 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.
# Required to play nicely with namespace composition (PEP420).
__import__('pkg_resources').declare_namespace(__name__)

View File

27
nova/virt/dpm/driver.py Normal file
View File

@ -0,0 +1,27 @@
# Copyright 2016 IBM Corp.
#
# All Rights Reserved.
#
# 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.
"""Shim layer for nova_dpm.virt.dpm.driver.DPMDriver.
Duplicate all public symbols. This is necessary for the constants as well as
the classes - because instances of the classes need to be able to resolve
references to the constants.
"""
import nova_dpm.virt.dpm.driver as real_drv
LOG = real_drv.LOG
CONF = real_drv.CONF
DPMDriver = real_drv.DPMDriver

View File

@ -23,6 +23,7 @@ classifier =
[files]
packages =
nova_dpm
nova/virt/dpm
[build_sphinx]
source-dir = doc/source

View File

@ -1,65 +1,59 @@
#!/usr/bin/env bash
# This wrapper for tox's package installer will use the existing package
# if it exists, else use zuul-cloner if that program exists. That last case should only
# happen with devs running unit tests locally.
# From the tox.ini config page:
# install_command=ARGV
# default:
# pip install {opts} {packages}
# Base code from https://github.com/openstack/glance_store/blob/master/tools/tox_install.sh
#
# Library constraint file contains version pin that is in conflict with
# installing the library from source. We should replace the version pin in
# the constraints file before applying it for from-source installation.
ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner
BRANCH_NAME=master
nova_installed=$(echo "import nova" | python 2>/dev/null ; echo $?)
NOVA_DIR=$HOME/nova
LIB_DIR=python-zhmcclient
LIB_NAME=zhmcclient
LIB_LOCATION=git+https://github.com/zhmcclient/$LIB_DIR#egg=$LIB_NAME
requirements_installed=$(echo "import openstack_requirements" | python 2>/dev/null ; echo $?)
set -e
set -x
set -e -x
install_cmd="pip install -c$1"
CONSTRAINTS_FILE=$1
shift
# The devstack based functional tests have nova checked out in
# $NOVA_DIR on the test systems - with the change to test in it.
# Use this directory if it exists, so that this script installs the
# nova version to test here.
# Note that the functional tests use sudo to run tox and thus
# variables used for zuul-cloner to check out the correct version are
# lost.
if [ -d "$NOVA_DIR" ]; then
echo "FOUND nova code at $NOVA_DIR - using"
$install_cmd -U -e $NOVA_DIR
elif [ $nova_installed -eq 0 ]; then
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
location=$(python -c "import nova; print(nova.__file__)")
echo "ALREADY INSTALLED at $location"
install_cmd="pip install"
mydir=$(mktemp -dt "$LIB_NAME-tox_install-XXXXXXX")
trap "rm -rf $mydir" EXIT
localfile=$mydir/upper-constraints.txt
if [[ $CONSTRAINTS_FILE != http* ]]; then
CONSTRAINTS_FILE=file://$CONSTRAINTS_FILE
fi
curl $CONSTRAINTS_FILE -k -o $localfile
install_cmd="$install_cmd -c$localfile"
echo "Nova already installed; using existing package"
if [ $requirements_installed -eq 0 ]; then
echo "ALREADY INSTALLED" > /tmp/tox_install.txt
echo "Requirements already installed; using existing package"
elif [ -x "$ZUUL_CLONER" ]; then
echo "ZUUL CLONER" > /tmp/tox_install.txt
# Make this relative to current working directory so that
# git clean can remove it. We cannot remove the directory directly
# since it is referenced after $install_cmd -e.
mkdir -p .tmp
NOVA_DIR=$(/bin/mktemp -d -p $(pwd)/.tmp)
pushd $NOVA_DIR
pushd $mydir
$ZUUL_CLONER --cache-dir \
/opt/git \
--branch $BRANCH_NAME \
git://git.openstack.org \
openstack/nova
cd openstack/nova
openstack/requirements
cd openstack/requirements
$install_cmd -e .
popd
else
echo "PIP HARDCODE" > /tmp/tox_install.txt
if [ -z "$NOVA_PIP_LOCATION" ]; then
NOVA_PIP_LOCATION="git+https://git.openstack.org/openstack/nova@$BRANCH_NAME#egg=nova"
if [ -z "$REQUIREMENTS_PIP_LOCATION" ]; then
REQUIREMENTS_PIP_LOCATION="git+https://git.openstack.org/openstack/requirements@$BRANCH_NAME#egg=requirements"
fi
$install_cmd -U -e ${NOVA_PIP_LOCATION}
$install_cmd -U -e ${REQUIREMENTS_PIP_LOCATION}
fi
# This is the main purpose of the script: Allow local installation of
# the current repo. It is listed in constraints file and thus any
# install will be constrained and we need to unconstrain it.
edit-constraints $localfile -- $LIB_NAME "-e $LIB_LOCATION"
$install_cmd -U $*
exit $?

View File

@ -11,6 +11,7 @@ setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
-egit+https://github.com/openstack/nova#egg=nova
-egit+https://github.com/zhmcclient/python-zhmcclient#egg=zhmcclient
whitelist_externals = bash
install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}