From: Anthony PERARD <anthony.perard@citrix.com>
To: xen-devel@lists.xen.org
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH OSSTEST v3 1/3] ts-openstack-deploy: Deploy OpenStack on a host with devstack
Date: Mon, 28 Sep 2015 16:56:13 +0100 [thread overview]
Message-ID: <1443455775-26131-2-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1443455775-26131-1-git-send-email-anthony.perard@citrix.com>
This script installs any necessary packages and clones all of the OpenStack
trees which are used by devstack to deploy OpenStack.
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
Change in V3:
- Use host as argument to run the job.
- Use selectjob() and get rid of the unused $gho.
- Use target_jobdir() instead of builddirsprops().
- Remove GIT_BASE from devstack config.
- Rename the script to ts-openstack-deploy (from ts-openstack-devstack).
---
sg-run-job | 5 +
ts-openstack-deploy | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 309 insertions(+)
create mode 100755 ts-openstack-deploy
diff --git a/sg-run-job b/sg-run-job
index 591ac54..4f87f30 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -373,6 +373,11 @@ proc run-job/test-rumpuserxen {} {
ts-guest-destroy-hard host $g +
}
+proc need-hosts/test-devstack {} { return host }
+proc run-job/test-devstack {} {
+ run-ts . = ts-openstack-deploy host
+}
+
if {[file exists sg-run-job-adhoc]} {
source sg-run-job-adhoc
}
diff --git a/ts-openstack-deploy b/ts-openstack-deploy
new file mode 100755
index 0000000..25a83fa
--- /dev/null
+++ b/ts-openstack-deploy
@@ -0,0 +1,304 @@
+#!/usr/bin/perl
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use strict qw(vars);
+use Osstest;
+use Osstest::TestSupport;
+use Osstest::BuildSupport;
+
+tsreadconfig();
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho = selecthost($whhost);
+our $builddir = target_jobdir($ho);
+
+sub tgt_init ();
+
+sub packages () {
+ # Install open-iscsi ahead of devstack ...
+ target_install_packages($ho, qw(git sudo open-iscsi));
+ # ... and start open-iscsi to have /etc/iscsi/initiatorname.iscsi
+ # generated. This is done on install on Ubuntu.
+ target_cmd_root($ho, 'service open-iscsi start');
+}
+
+sub checkout () {
+ prepbuilddirs();
+ build_clone($ho, 'cinder', $builddir, 'cinder');
+ build_clone($ho, 'glance', $builddir, 'glance');
+ build_clone($ho, 'keystone', $builddir, 'keystone');
+ build_clone($ho, 'nova', $builddir, 'nova');
+ build_clone($ho, 'requirements', $builddir, 'requirements');
+ build_clone($ho, 'tempest', $builddir, 'tempest');
+
+ build_clone($ho, 'devstack', $builddir, 'devstack');
+ my $vg = target_choose_vg($ho, 10*1024); # 10GB
+ target_putfilecontents_stash($ho, 60, <<END, $builddir.'/devstack/local.conf');
+[[local|localrc]]
+# Everything should be cloned by osstest, so devstack don't have to do it
+ERROR_ON_CLONE=True
+USE_SCREEN=False
+ADMIN_PASSWORD=secretadmin
+DATABASE_PASSWORD=secretdatabase
+RABBIT_PASSWORD=secretrabbit
+SERVICE_PASSWORD=secretservice
+SERVICE_TOKEN=atokenserviced
+# make it small because there is no way to not have this lvm volume created
+VOLUME_BACKING_FILE_SIZE=500M
+DEST=$builddir
+LOGFILE=\$DEST/logs/stack.sh.log
+# stackrc set this but don't take \$DEST into account
+SERVICE_DIR=\${DEST}/status
+LOG_COLOR=False
+LIBVIRT_TYPE=xen
+disable_service horizon
+disable_service n-novnc
+enable_service n-obj
+[[post-config|\$CINDER_CONF]]
+[lvmdriver-1]
+volume_group = $vg
+END
+
+ # libvirt is already installed, but not as a package, so avoid installation of
+ # the libvirt package with devstack
+ target_editfile($ho, "$builddir/devstack/files/debs/nova", sub {
+ while (<EI>) {
+ next if m/.*libvirt.*/;
+ print EO or die $!;
+ }
+ });
+ target_editfile($ho, "$builddir/devstack/lib/nova_plugins/functions-libvirt", sub {
+ while (<EI>) {
+ next if m/install_package.*libvirt.*/;
+ print EO or die $!;
+ }
+ });
+
+ # OpenStack needs access to libvirt from a user.
+ target_cmd_root($ho, <<END);
+ cat >> /etc/libvirt/libvirtd.conf <<EOF
+unix_sock_group = "libvirt"
+unix_sock_ro_perms = "0777"
+unix_sock_rw_perms = "0770"
+EOF
+END
+
+ # devstack is going to setup the host, install some dependency.
+ target_putfilecontents_root_stash($ho, 100, <<END,"/etc/sudoers.d/devstack");
+osstest ALL=(ALL) NOPASSWD:ALL
+END
+
+ target_putfilecontents_root_stash($ho, 60, tgt_init(), "/etc/init.d/tgt");
+ target_cmd_root($ho, <<END);
+ chmod +x /etc/init.d/tgt
+END
+}
+
+sub deploy() {
+ target_cmd($ho, <<END, 1800);
+ cd $builddir/devstack
+ ./stack.sh
+END
+}
+
+packages();
+checkout();
+deploy();
+
+# This is missing from Debian but required by devstack
+# Got it from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=577925
+sub tgt_init () {
+ return <<'END';
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: tgtd
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Should-Start: zfs
+# Should-Stop: zfs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: iscsi target daemon
+# Description: iscsi target daemon
+### END INIT INFO
+
+DESC="target framework daemon"
+NAME=tgtd
+DAEMON=/usr/sbin/${NAME}
+
+TGTD_CONFIG=/etc/tgt/targets.conf
+
+TASK=$1
+
+. /lib/lsb/init-functions
+
+[ -x $DAEMON ] || exit 0
+
+start()
+{
+ log_daemon_msg "Starting $DESC" "$NAME"
+ # Start tgtd first.
+ tgtd &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ log_end_msg 1
+ exit 1
+ else
+ log_end_msg 0
+ fi
+ # Put tgtd into "offline" state until all the targets are configured.
+ # We don't want initiators to (re)connect and fail the connection
+ # if it's not ready.
+ tgtadm --op update --mode sys --name State -v offline
+ # Configure the targets.
+ tgt-admin -e -c $TGTD_CONFIG
+ # Put tgtd into "ready" state.
+ tgtadm --op update --mode sys --name State -v ready
+}
+
+stop()
+{
+ if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
+ forcedstop
+ fi
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ # Remove all targets. It only removes targets which are not in use.
+ tgt-admin --update ALL -c /dev/null &>/dev/null
+ # tgtd will exit if all targets were removed
+ tgtadm --op delete --mode system &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ if [ "$TASK" != "restart" ] ; then
+ log_end_msg 1
+ exit 1
+ else
+ log_end_msg 0
+ fi
+ elif [ "$RETVAL" -ne 0 ] ; then
+ log_end_msg 1
+ echo "Some initiators are still connected - could not stop tgtd"
+ exit 2
+ else
+ log_end_msg 0
+ fi
+ echo -n
+}
+
+forcedstop()
+{
+ # NOTE: Forced shutdown of the iscsi target may cause data corruption
+ # for initiators that are connected.
+ echo "Force-stopping target framework daemon"
+ # Offline everything first. May be needed if we're rebooting, but
+ # expect the initiators to reconnect cleanly when we boot again
+ # (i.e. we don't want them to reconnect to a tgtd which is still
+ # working, but the target is gone).
+ tgtadm --op update --mode sys --name State -v offline &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ [ "$TASK" != "restart" ] && exit 1
+ else
+ tgt-admin --offline ALL
+ # Remove all targets, even if they are still in use.
+ tgt-admin --update ALL -c /dev/null -f
+ # It will shut down tgtd only after all targets were removed.
+ tgtadm --op delete --mode system
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ echo "Failed to shutdown tgtd"
+ exit 1
+ fi
+ fi
+ echo -n
+}
+
+reload()
+{
+ log_daemon_msg "Reloading configuration of $DESC" "$NAME"
+ # Update configuration for targets. Only targets which
+ # are not in use will be updated.
+ tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ log_end_msg 1
+ echo "tgtd is not running"
+ exit 1
+ fi
+ log_end_msg 0
+}
+
+forcedreload()
+{
+ log_daemon_msg "Forced-reload configuration of $DESC" "$NAME"
+ # Update configuration for targets, even those in use.
+ tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ log_end_msg 1
+ echo "tgtd is not running"
+ exit 1
+ else
+ log_end_msg 0
+ fi
+}
+
+status()
+{
+ # Don't name this script "tgtd"...
+ TGTD_PROC=$(ps -C tgtd | grep -c tgtd)
+ if [ "$TGTD_PROC" -eq 2 ] ; then
+ echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info."
+ else
+ echo "tgtd is NOT running."
+ fi
+}
+
+case $1 in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ forcedstop)
+ forcedstop
+ ;;
+ restart)
+ TASK=restart
+ stop && start
+ ;;
+ forcedrestart)
+ TASK=restart
+ forcedstop && start
+ ;;
+ reload)
+ reload
+ ;;
+ force-reload)
+ forcedreload
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|forcedstop|restart|forcedrestart|reload|force-reload|status}"
+ exit 2
+ ;;
+esac
+END
+}
--
Anthony PERARD
next prev parent reply other threads:[~2015-09-28 15:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 15:56 [PATCH OSSTEST v3 0/3] Have OpenStack tested on top of xen's master and libvirt's master Anthony PERARD
2015-09-28 15:56 ` Anthony PERARD [this message]
2015-09-29 15:34 ` [PATCH OSSTEST v3 1/3] ts-openstack-deploy: Deploy OpenStack on a host with devstack Ian Campbell
2015-09-29 16:19 ` Anthony PERARD
2015-09-29 17:04 ` Ian Jackson
2015-09-30 8:29 ` Ian Campbell
2015-09-29 17:02 ` Ian Jackson
2015-09-30 8:32 ` Ian Campbell
2015-09-30 10:52 ` Ian Jackson
2015-09-28 15:56 ` [PATCH OSSTEST v3 2/3] ts-openstack-tempest: Run Tempest to check OpenStack Anthony PERARD
2015-09-29 15:43 ` Ian Campbell
2015-09-29 17:15 ` Anthony PERARD
2015-09-30 8:38 ` Ian Campbell
2015-09-28 15:56 ` [PATCH OSSTEST v3 3/3] Create a flight to test OpenStack with xen-unstable and libvirt Anthony PERARD
2015-09-29 15:49 ` Ian Campbell
2015-09-29 17:21 ` Anthony PERARD
2015-09-29 16:52 ` Ian Jackson
2015-10-08 16:08 ` Ian Campbell
2015-10-08 16:42 ` Ian Jackson
2015-10-09 10:54 ` Anthony PERARD
2015-10-13 11:02 ` Ian Jackson
2015-10-13 11:39 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443455775-26131-2-git-send-email-anthony.perard@citrix.com \
--to=anthony.perard@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).