[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH [RFC] 1/3] ts-debian-install: support for installing multiple guests



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@xxxxxxxxxx>
---
 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);
+}


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.