xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: [OSSTEST PATCH [RFC] 1/3] ts-debian-install: support for installing multiple guests
Date: Thu, 5 Dec 2013 15:09:51 +0000	[thread overview]
Message-ID: <20131205150950.20194.41793.stgit@drall.uk.xensource.com> (raw)
In-Reply-To: <20131205150935.20194.10427.stgit@drall.uk.xensource.com>

so that now, for example, this is possible:

$ OSSTEST_JOB=test-amd64-amd64-xl
$ export OSSTEST_JOB
$ ./ts-debian-install host=tg03 debian1 debian2

This assumes that, if an host is to be explicitly specified,
that happens via the first argument and in the form 'host=somehost',
as it typically is the case for standalone mode.

If no first argument in 'host=' form is found, we assume no explicit
host designation at all, as it typicall is the case for non-standalone
mode, and we consider all the parameters a list of guest names.
We do this also if the first parametr is just 'host', as this seem to
be another way to ask to just use the host from the runvars (typical
in non-standalone, but functional in both modes).

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
 ts-debian-install |   59 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 24 deletions(-)

diff --git a/ts-debian-install b/ts-debian-install
index 519edc9..a9a89dd 100755
--- a/ts-debian-install
+++ b/ts-debian-install
@@ -22,9 +22,14 @@ use Osstest::TestSupport;
 
 tsreadconfig();
 
-our ($whhost,$gn) = @ARGV;
-$whhost ||= 'host';
-$gn ||= 'debian';
+our $whhost = 'host';
+if (@ARGV && ($ARGV[0] =~ m/^host=.*$/ || $ARGV[0] eq 'host')) {
+    $whhost = $ARGV[0];
+    shift @ARGV;
+}
+
+our (@guests) = @ARGV;
+$guests[0] = 'debian' unless defined(@guests);
 
 our $ho= selecthost($whhost);
 
@@ -32,27 +37,30 @@ our $ram_mb=    512;
 our $swap_mb=  1000;
 our $disk_mb= 10000;
 
-our $guesthost= "$gn.guest.osstest";
-our $gho;
+our $guesthost;
+our %gho;
+
+sub prep ($) {
+    my ($gn) = @_;
 
-sub prep () {
     target_install_packages_norec($ho, qw(lvm2 xen-tools));
 
-    $gho= prepareguest($ho, $gn, $guesthost, 22,
-                       $swap_mb + $disk_mb + 2,
-                       40);
-    target_cmd_root($ho, "umount $gho->{Lvdev} ||:");
+    $gho{$gn}= prepareguest($ho, $gn, $guesthost, 22,
+                            $swap_mb + $disk_mb + 2,
+                            40);
+    target_cmd_root($ho, "umount $gho{$gn}->{Lvdev} ||:");
 }
 
-sub ginstall () {
-    my $arch= $r{"$gho->{Guest}_arch"};
+sub ginstall ($) {
+    my ($gn) = @_;
+    my $arch= $r{"$gho{$gn}->{Guest}_arch"};
     my $archarg= defined($arch) ? "--arch $arch" : '';
-    my $gsuite= guest_var($gho,'suite',$c{GuestDebianSuite});
+    my $gsuite= guest_var($gho{$gn},'suite',$c{GuestDebianSuite});
 
-    my $kernpath = guest_var($gho,'kernel_path',$r{xen_kernel_path});
-    my $initrd = guest_var($gho,'initrd_path',$r{xen_initrd_path});
+    my $kernpath = guest_var($gho{$gn},'kernel_path',$r{xen_kernel_path});
+    my $initrd = guest_var($gho{$gn},'initrd_path',$r{xen_initrd_path});
     if (!$kernpath) {
-	my $kernver= guest_var($gho,'kernel_ver',$r{xen_kernel_ver});
+	my $kernver= guest_var($gho{$gn},'kernel_ver',$r{xen_kernel_ver});
 	$kernver ||= target_cmd_output($ho, 'uname -r');
 	$kernpath = "/boot/vmlinuz-$kernver";
 	$initrd ||= "/boot/initrd.img-$kernver";
@@ -65,21 +73,24 @@ sub ginstall () {
     
     target_cmd_root($ho, <<END, 2000);
         xen-create-image \\
-            --dhcp --mac $gho->{Ether} \\
+            --dhcp --mac $gho{$gn}->{Ether} \\
             --memory ${ram_mb}Mb --swap ${swap_mb}Mb \\
             --dist $gsuite \\
             --mirror http://$c{DebianMirrorHost}/$c{DebianMirrorSubpath} \\
-            --hostname $gho->{Name} \\
-            --lvm $gho->{Vg} --force \\
+            --hostname $gho{$gn}->{Name} \\
+            --lvm $gho{$gn}->{Vg} --force \\
             --kernel $kernpath \\
             --genpass 0 --password xenroot \\
             $initrd_opt \\
             $archarg
 END
-    my $cfg_xend= "/etc/xen/$gho->{Name}.cfg";
-    store_runvar("$gho->{Guest}_cfgpath", $cfg_xend);
-    store_runvar("$gho->{Guest}_swap_lv", "$gho->{Name}-swap");
+    my $cfg_xend= "/etc/xen/$gho{$gn}->{Name}.cfg";
+    store_runvar("$gho{$gn}->{Guest}_cfgpath", $cfg_xend);
+    store_runvar("$gho{$gn}->{Guest}_swap_lv", "$gho{$gn}->{Name}-swap");
 }
 
-prep();
-ginstall();
+foreach my $g (@guests) {
+    $guesthost = "$g.guest.osstest";
+    prep($g);
+    ginstall($g);
+}

  reply	other threads:[~2013-12-05 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 15:09 [OSSTEST PATCH [RFC] 0/3] Series short description Dario Faggioli
2013-12-05 15:09 ` Dario Faggioli [this message]
2013-12-05 15:10 ` [OSSTEST PATCH [RFC] 2/3] ts-debian-fixup: support multiple guests Dario Faggioli
2013-12-05 15:10 ` [OSSTEST PATCH [RFC] 3/3] ts-guest-start, -stop, -destroy: " Dario Faggioli
2013-12-05 15:25 ` [OSSTEST PATCH [RFC] 0/3] Series short description Ian Jackson
2013-12-05 16:17   ` Dario Faggioli
2013-12-05 17:34     ` Ian Jackson
2013-12-06  9:23       ` Dario Faggioli

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=20131205150950.20194.41793.stgit@drall.uk.xensource.com \
    --to=dario.faggioli@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.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).