From patchwork Fri Feb 5 16:26:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 8236941 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B27B6BEEE5 for ; Fri, 5 Feb 2016 16:30:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84A4A201EC for ; Fri, 5 Feb 2016 16:30:19 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 324682015E for ; Fri, 5 Feb 2016 16:30:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRjDx-0005wb-Nr; Fri, 05 Feb 2016 16:27:09 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aRjDv-0005wD-Jo for xen-devel@lists.xen.org; Fri, 05 Feb 2016 16:27:07 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 28/7A-29293-A5DC4B65; Fri, 05 Feb 2016 16:27:06 +0000 X-Env-Sender: prvs=836b819b4=anthony.perard@citrix.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1454689624!20370442!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45598 invoked from network); 5 Feb 2016 16:27:05 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 5 Feb 2016 16:27:05 -0000 X-IronPort-AV: E=Sophos;i="5.22,401,1449532800"; d="scan'208";a="329958390" From: Anthony PERARD To: Xen Devel Date: Fri, 5 Feb 2016 16:26:51 +0000 Message-ID: <1454689613-12814-2-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1454689613-12814-1-git-send-email-anthony.perard@citrix.com> References: <1454689613-12814-1-git-send-email-anthony.perard@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Anthony PERARD , Ian Jackson , Ian Campbell Subject: [Xen-devel] [PATCH v5 1/3] ts-openstack-deploy: Deploy OpenStack on a host with devstack X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Ian Campbell --- Only change in V5: - edit stackrc from devstack file to change the hardcoded path DEST No change in V4: - acked 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 | 314 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100755 ts-openstack-deploy diff --git a/sg-run-job b/sg-run-job index ca9a621..a995db5 100755 --- a/sg-run-job +++ b/sg-run-job @@ -410,6 +410,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..f42778b --- /dev/null +++ b/ts-openstack-deploy @@ -0,0 +1,314 @@ +#!/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 . + +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, 'devstack', $builddir, 'devstack'); + 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'); + + my $vg = target_choose_vg($ho, 10*1024); # 10GB + target_putfilecontents_stash($ho, 60, <) { + if (m/^DEST=\/opt\/stack$/) { + s/DEST=\/opt\/stack/DEST=$builddir/; + } + print EO or die $!; + } + }); + + # 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 () { + next if m/.*libvirt.*/; + print EO or die $!; + } + }); + target_editfile($ho, "$builddir/devstack/lib/nova_plugins/functions-libvirt", sub { + while () { + next if m/install_package.*libvirt.*/; + print EO or die $!; + } + }); + + # OpenStack needs access to libvirt from a user. + target_cmd_root($ho, <> /etc/libvirt/libvirtd.conf </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 +}