diff --git a/contrib/devstack/README.rst b/contrib/devstack/README.rst deleted file mode 100644 index 08aceb5571..0000000000 --- a/contrib/devstack/README.rst +++ /dev/null @@ -1,28 +0,0 @@ -==================== -Devstack Integration -==================== - -This directory contains the files necessary to integrate Magnum with devstack. - -Refer the quickstart guide for more information on using devstack and magnum. - -Running devestack with magnum for the first time may take a long time as it -needs to download an atomic fedora 21 qcow image. If you already have this image -you can copy it to /opt/stack/devstack/files/fedora-21-atomic.qcow2 to save you -this time. - -To install magnum into devstack: :: - - git clone https://git.openstack.org/stackforge/magnum /opt/stack/magnum - git clone https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack - - # copy example localrc, modify as necessary - cp /opt/stack/magnum/contrib/devstack/localrc.example /opt/stack/devstack/localrc - - cd /opt/stack/magnum - ./contrib/devstack/prepare_devstack.sh - -Run devstack as normal: :: - - cd /opt/stack/devstack - ./stack.sh diff --git a/contrib/devstack/lib/magnum b/contrib/devstack/lib/magnum deleted file mode 100644 index 8b911b1af8..0000000000 --- a/contrib/devstack/lib/magnum +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/bash -# -# lib/magnum -# Functions to control the configuration and operation of the **magnum** service - -# Dependencies: -# -# - ``functions`` file -# - ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined -# - ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined - -# ``stack.sh`` calls the entry points in this order: -# -# - install_magnum -# - configure_magnum -# - create_magnum_conf -# - init_magnum -# - start_magnum -# - stop_magnum -# - cleanup_magnum - -# Save trace setting -XTRACE=$(set +o | grep xtrace) -set +o xtrace - - -# Defaults -# -------- - -# Set up default directories -MAGNUM_REPO=${MAGNUM_REPO:-${GIT_BASE}/stackforge/magnum.git} -MAGNUM_BRANCH=${MAGNUM_BRANCH:-master} -MAGNUM_DIR=$DEST/magnum - -GITREPO["python-magnumclient"]=${MAGNUMCLIENT_REPO:-${GIT_BASE}/stackforge/python-magnumclient.git} -GITBRANCH["python-magnumclient"]=${MAGNUMCLIENT_BRANCH:-master} -GITDIR["python-magnumclient"]=$DEST/python-magnumclient - -MAGNUM_STATE_PATH=${MAGNUM_STATE_PATH:=$DATA_DIR/magnum} -MAGNUM_AUTH_CACHE_DIR=${MAGNUM_AUTH_CACHE_DIR:-/var/cache/magnum} - -MAGNUM_CONF_DIR=/etc/magnum -MAGNUM_CONF=$MAGNUM_CONF_DIR/magnum.conf - -if is_ssl_enabled_service "magnum" || is_service_enabled tls-proxy; then - MAGNUM_SERVICE_PROTOCOL="https" -fi - -# Public facing bits -MAGNUM_SERVICE_HOST=${MAGNUM_SERVICE_HOST:-$SERVICE_HOST} -MAGNUM_SERVICE_PORT=${MAGNUM_SERVICE_PORT:-9511} -MAGNUM_SERVICE_PORT_INT=${MAGNUM_SERVICE_PORT_INT:-19511} -MAGNUM_SERVICE_PROTOCOL=${MAGNUM_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} - -# Support entry points installation of console scripts -if [[ -d $MAGNUM_DIR/bin ]]; then - MAGNUM_BIN_DIR=$MAGNUM_DIR/bin -else - MAGNUM_BIN_DIR=$(get_python_exec_prefix) -fi - -# Functions -# --------- - -# Test if any magnum services are enabled -# is_magnum_enabled -function is_magnum_enabled { - [[ ,${ENABLED_SERVICES} =~ ,"m-" ]] && return 0 - return 1 -} -# cleanup_magnum() - Remove residual data files, anything left over from previous -# runs that a clean run would need to clean up -function cleanup_magnum { - sudo rm -rf $MAGNUM_STATE_PATH $MAGNUM_AUTH_CACHE_DIR -} - -# configure_magnum() - Set config files, create data dirs, etc -function configure_magnum { - # Put config files in ``/etc/magnum`` for everyone to find - if [[ ! -d $MAGNUM_CONF_DIR ]]; then - sudo mkdir -p $MAGNUM_CONF_DIR - sudo chown $STACK_USER $MAGNUM_CONF_DIR - fi - - # Rebuild the config file from scratch - create_magnum_conf - -} - -# create_magnum_accounts() - Set up common required magnum accounts -# -# Project User Roles -# ------------------------------------------------------------------ -# SERVICE_TENANT_NAME magnum service -function create_magnum_accounts { - - create_service_user "magnum" "admin" - - if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then - - local magnum_service=$(get_or_create_service "magnum" \ - "container" "Magnum Container Service") - get_or_create_endpoint $magnum_service \ - "$REGION_NAME" \ - "$MAGNUM_SERVICE_PROTOCOL://$MAGNUM_SERVICE_HOST:$MAGNUM_SERVICE_PORT/v1" \ - "$MAGNUM_SERVICE_PROTOCOL://$MAGNUM_SERVICE_HOST:$MAGNUM_SERVICE_PORT/v1" \ - "$MAGNUM_SERVICE_PROTOCOL://$MAGNUM_SERVICE_HOST:$MAGNUM_SERVICE_PORT/v1" - fi - -} - -# create_magnum_conf() - Create a new magnum.conf file -function create_magnum_conf { - - # (Re)create ``magnum.conf`` - rm -f $MAGNUM_CONF - iniset $MAGNUM_CONF DEFAULT verbose "True" - iniset $MAGNUM_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL" - iniset $MAGNUM_CONF DEFAULT rabbit_userid $RABBIT_USERID - iniset $MAGNUM_CONF DEFAULT rabbit_password $RABBIT_PASSWORD - iniset $MAGNUM_CONF DEFAULT rabbit_host $RABBIT_HOST - - iniset $MAGNUM_CONF database connection `database_connection_url magnum` - iniset $MAGNUM_CONF api host "$MAGNUM_SERVICE_HOST" - iniset $MAGNUM_CONF api port "$MAGNUM_SERVICE_PORT" - iniset $MAGNUM_CONF conductor host "$MAGNUM_SERVICE_HOST" - - configure_auth_token_middleware $MAGNUM_CONF magnum $MAGNUM_AUTH_CACHE_DIR - - if is_fedora || is_suse; then - # magnum defaults to /usr/local/bin, but fedora and suse pip like to - # install things in /usr/bin - iniset $MAGNUM_CONF DEFAULT bindir "/usr/bin" - fi - - if [ -n "$MAGNUM_STATE_PATH" ]; then - iniset $MAGNUM_CONF DEFAULT state_path "$MAGNUM_STATE_PATH" - iniset $MAGNUM_CONF DEFAULT lock_path "$MAGNUM_STATE_PATH" - fi - - if [ "$SYSLOG" != "False" ]; then - iniset $MAGNUM_CONF DEFAULT use_syslog "True" - fi - - # Format logging - if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then - setup_colorized_logging $MAGNUM_CONF DEFAULT - else - # Show user_name and project_name instead of user_id and project_id - iniset $MAGNUM_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s" - fi - - # Register SSL certificates if provided - if is_ssl_enabled_service magnum; then - ensure_certificates MAGNUM - - iniset $MAGNUM_CONF DEFAULT ssl_cert_file "$MAGNUM_SSL_CERT" - iniset $MAGNUM_CONF DEFAULT ssl_key_file "$MAGNUM_SSL_KEY" - - iniset $MAGNUM_CONF DEFAULT enabled_ssl_apis "$MAGNUM_ENABLED_APIS" - fi -} - -function create_magnum_conf_magnum_network { - iniset $MAGNUM_CONF DEFAULT network_manager "magnum.network.manager.$NETWORK_MANAGER" - iniset $MAGNUM_CONF DEFAULT public_interface "$PUBLIC_INTERFACE" - iniset $MAGNUM_CONF DEFAULT vlan_interface "$VLAN_INTERFACE" - iniset $MAGNUM_CONF DEFAULT flat_network_bridge "$FLAT_NETWORK_BRIDGE" - if [ -n "$FLAT_INTERFACE" ]; then - iniset $MAGNUM_CONF DEFAULT flat_interface "$FLAT_INTERFACE" - fi -} - -# create_magnum_cache_dir() - Part of the init_magnum() process -function create_magnum_cache_dir { - # Create cache dir - sudo mkdir -p $MAGNUM_AUTH_CACHE_DIR - sudo chown $STACK_USER $MAGNUM_AUTH_CACHE_DIR - rm -f $MAGNUM_AUTH_CACHE_DIR/* -} - - -# init_magnum() - Initialize databases, etc. -function init_magnum { - # Only do this step once on the API node for an entire cluster. - if is_service_enabled $DATABASE_BACKENDS && is_service_enabled m-api; then - # (Re)create magnum database - recreate_database magnum - - # Migrate magnum database - $MAGNUM_BIN_DIR/magnum-db-manage upgrade - fi - create_magnum_cache_dir -} - -# install_magnumclient() - Collect source and prepare -function install_magnumclient { - if use_library_from_git "python-magnumclient"; then - git_clone_by_name "python-magnumclient" - setup_dev_lib "python-magnumclient" - fi -} - -# install_magnum() - Collect source and prepare -function install_magnum { - git_clone $MAGNUM_REPO $MAGNUM_DIR $MAGNUM_BRANCH - setup_develop $MAGNUM_DIR -} - -# start_magnum_api() - Start the API process ahead of other things -function start_magnum_api { - # Get right service port for testing - local service_port=$MAGNUM_SERVICE_PORT - local service_protocol=$MAGNUM_SERVICE_PROTOCOL - if is_service_enabled tls-proxy; then - service_port=$MAGNUM_SERVICE_PORT_INT - service_protocol="http" - fi - - run_process m-api "$MAGNUM_BIN_DIR/magnum-api" - echo "Waiting for magnum-api to start..." - if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$SERVICE_HOST:$service_port; then - die $LINENO "magnum-api did not start" - fi - - # Start proxies if enabled - if is_service_enabled tls-proxy; then - start_tls_proxy '*' $MAGNUM_SERVICE_PORT $MAGNUM_SERVICE_HOST $MAGNUM_SERVICE_PORT_INT & - start_tls_proxy '*' $EC2_SERVICE_PORT $MAGNUM_SERVICE_HOST $EC2_SERVICE_PORT_INT & - fi -} - - -# start_magnum() - Start running processes, including screen -function start_magnum { - - # ``run_process`` checks ``is_service_enabled``, it is not needed here - start_magnum_api - run_process m-cond "$MAGNUM_BIN_DIR/magnum-conductor" -} - -# stop_magnum() - Stop running processes (non-screen) -function stop_magnum { - for serv in m-api m-cond; do - stop_process $serv - done -} - - -# Restore xtrace -$XTRACE diff --git a/contrib/devstack/prepare_devstack.sh b/contrib/devstack/prepare_devstack.sh deleted file mode 100755 index 0a699497b8..0000000000 --- a/contrib/devstack/prepare_devstack.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -eux - -MAGNUM_DIR=$(readlink -f $(dirname $0)/../..) -INSTALL_DIR=${INSTALL_DIR:-/opt/stack} - -cp ${MAGNUM_DIR}/contrib/devstack/lib/magnum ${INSTALL_DIR}/devstack/lib -cp ${MAGNUM_DIR}/contrib/devstack/extras.d/70-magnum.sh ${INSTALL_DIR}/devstack/extras.d - -# Add magnum specific requirements to global requirements -git clone https://git.openstack.org/openstack/requirements ${INSTALL_DIR}/requirements || true -echo "python-kubernetes>=0.2" >> ${INSTALL_DIR}/requirements/global-requirements.txt -echo "docker-py>=0.5.1" >> ${INSTALL_DIR}/requirements/global-requirements.txt diff --git a/contrib/devstack/extras.d/70-magnum.sh b/devstack/plugin.sh old mode 100644 new mode 100755 similarity index 88% rename from contrib/devstack/extras.d/70-magnum.sh rename to devstack/plugin.sh index c63742d498..36cd78a350 --- a/contrib/devstack/extras.d/70-magnum.sh +++ b/devstack/plugin.sh @@ -1,10 +1,9 @@ # magnum.sh - Devstack extras script to install magnum +source $TOP_DIR/lib/magnum + if is_service_enabled m-api m-cond; then - if [[ "$1" == "source" ]]; then - # Initial source - source $TOP_DIR/lib/magnum - elif [[ "$1" == "stack" && "$2" == "install" ]]; then + if [[ "$1" == "stack" && "$2" == "install" ]]; then echo_summary "Installing magnum" install_magnum diff --git a/contrib/devstack/localrc.example b/devstack/settings similarity index 94% rename from contrib/devstack/localrc.example rename to devstack/settings index 82ee459e2f..52db06e38f 100644 --- a/contrib/devstack/localrc.example +++ b/devstack/settings @@ -1,3 +1,5 @@ +# Devstack settings + # Modify to your environment FLOATING_RANGE=192.168.1.224/27 PUBLIC_NETWORK_GATEWAY=192.168.1.225 @@ -37,4 +39,4 @@ OVS_PHYSICAL_BRIDGE=br-ex # Log all output to files LOGFILE=$HOME/devstack.log -SCREEN_LOGDIR=$HOME/logs +SCREEN_LOGDIR=$HOME/logs \ No newline at end of file diff --git a/tests/contrib/post_test_hook.sh b/tests/contrib/post_test_hook.sh new file mode 100755 index 0000000000..8cdbee8ebd --- /dev/null +++ b/tests/contrib/post_test_hook.sh @@ -0,0 +1,28 @@ +#!/bin/bash -x +# +# 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. + +# This script is executed inside post_test_hook function in devstack gate. + +# Sleep some time until all services are starting +sleep 5 + + +sudo pip install -r test-requirements.txt +sudo OS_STDOUT_CAPTURE=-1 OS_STDERR_CAPTURE=-1 OS_TEST_TIMEOUT=500 OS_TEST_LOCK_PATH=${TMPDIR:-'/tmp'} \ + python -m subunit.run discover -t ./ ./magnum/tests/functional | subunit-2to1 | tools/colorizer.py +RETVAL=$? + +# Here can be some commands for log archiving, etc... + +exit $RETVAL