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

[Xen-devel] [OSSTest PATCH [RFC] 2/4] ts-fedora-install: added for installing fedora guests



Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
---
 ts-fedora-install |  168 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)
 create mode 100755 ts-fedora-install

diff --git a/ts-fedora-install b/ts-fedora-install
new file mode 100755
index 0000000..6b55091
--- /dev/null
+++ b/ts-fedora-install
@@ -0,0 +1,168 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 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 DBI;
+use Osstest;
+use Osstest::Fedora;
+use Osstest::TestSupport;
+
+use Data::Dumper;
+
+tsreadconfig();
+
+our ($whhost,$gn) = @ARGV;
+$whhost ||= 'host';
+$gn ||= 'fedora';
+
+our $ho= selecthost($whhost);
+
+our $ram_mb=   512;
+our $disk_mb= 5000;
+
+our $guesthost= "$gn.guest.osstest";
+our $gho;
+
+sub prep () {
+    target_install_packages_norec($ho, qw(lvm2 kpartx));
+
+    $gho= prepareguest($ho, $gn, $guesthost, 22,
+                       $disk_mb, 40);
+
+    prepareguest_part_lvmdisk($ho, $gho, $disk_mb);
+
+    target_cmd_root($ho, "umount $gho->{Lvdev} ||:");
+}
+
+sub ginstall () {
+    my $arch= defined($r{"$gho->{Guest}_arch"}) ?
+                  $r{"$gho->{Guest}_arch"} : "x86_64";
+    my $pae= ($arch eq 'i386') ? '-PAE' : '';
+    my $fedora_release= guest_var($gho, 'fedora_release',
+                                  $c{GuestFedoraRelease});
+
+    # Paths within a mirror are different depending on whether we are dealing
+    # with an actual released distro, one in development, or one being tested
+    # right before a release (Test Composes or RC-s, see
+    # https://fedoraproject.org/wiki/Test_Results:Current_Installation_Test).
+    my $releaseurl= 
"http://$c{FedoraMirrorHost}/$c{FedoraMirrorSubpath}/releases/$fedora_release/Fedora/$arch/os";;
+    my $develurl = 
"http://$c{FedoraMirrorHost}/$c{FedoraMirrorSubpath}/development/$fedora_release/$arch/os";;
+    my $stageurl = 
"http://dl.fedoraproject.org/pub/alt/stage/$fedora_release/Fedora/$arch/os";;
+    my $repourl;
+
+    if (system("wget -O /tmp/ti --quiet $releaseurl/.treeinfo") == 0) {
+        $repourl = $releaseurl;
+    } elsif (system("wget -O /tmp/ti --quiet $develurl/.treeinfo") == 0) {
+        $repourl = $develurl;
+    } elsif (system("wget -O /tmp/ti --quiet $stageurl/.treeinfo") == 0) {
+        $repourl = $stageurl;
+    } else {
+        die "unable to find images for Fedora $fedora_release for $arch"
+    }
+
+    my $fi_url = "$repourl/images/pxeboot";
+    target_cmd($ho, <<END, 2000);
+       wget --quiet -O /tmp/fi_kernel $fi_url/vmlinuz$pae
+       wget --quiet -O /tmp/fi_initrd $fi_url/initrd$pae.img
+END
+
+    my $ks_url = kickstart_create($gho, $repourl, '');
+
+    my $vcpus= guest_var($gho, 'vcpus', 1);
+
+    my $install_cfg= <<END;
+name = '$gho->{Name}'
+# Fedora installer requires no less than 1GB RAM
+memory = 1024
+#
+kernel      = "/tmp/fi_kernel"
+ramdisk     = "/tmp/fi_initrd"
+extra       = "repo=$repourl console=hvc0 text serial ks=$ks_url"
+#
+vif = [ 'mac=$gho->{Ether}' ]
+#
+on_poweroff = 'destroy'
+# the below is needed for allowing guest_await_reboot() to trigger
+on_reboot   = 'preserve'
+on_crash    = 'preserve'
+#
+vcpus = $vcpus
+#
+disk = [
+        'phy:$gho->{Lvdev},xvda,w'
+       ]
+END
+
+    my $cfgpath= "/etc/xen/$gho->{Name}.cfg";
+
+    $gho->{CfgPath}= $cfgpath;
+    store_runvar("$gho->{Guest}_cfgpath", "$cfgpath");
+    target_putfilecontents_root_stash($ho, 30, $install_cfg, $cfgpath);
+
+    my $cmd= toolstack()->{Command}." create ".
+        $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} };
+    target_cmd_root($ho, $cmd, 300);
+
+    guest_checkrunning($ho, $gho) or die "$gho->{Name} not running";
+
+    guest_await_reboot($ho, $gho, 2000);
+    guest_destroy($ho, $gho);
+
+    # Some fixups
+    store_runvar("$gho->{Guest}_tcpcheckport", 22);
+
+    my $authkeys= authorized_keys();
+    my $rootdev = target_guest_lv_name($ho, $gho->{Name}) . "--disk2";
+    target_cmd_root($ho, <<END);
+        set -ex
+        kpartx -a $gho->{Lvdev}
+        mount $rootdev /mnt
+        mkdir -p /mnt/root/.ssh /mnt/etc/ssh
+        cat <<'ENDKEYS' > /mnt/root/.ssh/authorized_keys
+$authkeys
+ENDKEYS
+        cp -a /etc/ssh/ssh_host_*key* /mnt/etc/ssh/
+        mkdir -p /mnt/home/osstest/.ssh
+        cp /mnt/root/.ssh/authorized_keys /mnt/home/osstest/.ssh
+        chroot /mnt chown -R osstest.osstest /home/osstest/.ssh
+        umount /mnt
+        kpartx -d $gho->{Lvdev}
+END
+
+    my $runtime_cfg= <<END;
+name = '$gho->{Name}'
+memory = ${ram_mb}
+#
+bootloader = "pygrub"
+#
+vif = [ 'mac=$gho->{Ether}' ]
+#
+on_poweroff = 'destroy'
+on_reboot   = 'restart'
+on_crash    = 'preserve'
+#
+vcpus = $vcpus
+#
+disk = [
+        'phy:$gho->{Lvdev},xvda,w'
+       ]
+END
+    target_putfilecontents_root_stash($ho, 30, $runtime_cfg, $cfgpath);
+}
+
+prep();
+ginstall();


_______________________________________________
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®.