All of lore.kernel.org
 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] 2/4] ts-fedora-install: added for installing fedora guests
Date: Thu, 12 Dec 2013 23:53:33 +0100	[thread overview]
Message-ID: <20131212225332.11164.99188.stgit@Solace> (raw)
In-Reply-To: <20131212221933.11164.46804.stgit@Solace>

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
 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();

  parent reply	other threads:[~2013-12-12 22:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12 22:53 [OSSTest PATCH [RFC] 0/4] New test case: Fedora PV guests Dario Faggioli
2013-12-12 22:53 ` [OSSTest PATCH [RFC] 1/4] Introducing Osstest/Fedora.pm Dario Faggioli
2013-12-13 16:33   ` Ian Jackson
2013-12-13 17:47     ` Dario Faggioli
2013-12-12 22:53 ` Dario Faggioli [this message]
2013-12-13 16:44   ` [OSSTest PATCH [RFC] 2/4] ts-fedora-install: added for installing fedora guests Ian Jackson
2013-12-13 18:12     ` Dario Faggioli
2013-12-13 18:24       ` Ian Jackson
2013-12-13 16:45   ` Ian Jackson
2013-12-13 17:36     ` Dario Faggioli
2013-12-12 22:53 ` [OSSTest PATCH [RFC] 3/4] sg-run-job: Fedora guest job Dario Faggioli
2013-12-12 22:53 ` [OSSTest PATCH [RFC] 4/4] make-flight: Fedora guest tests Dario Faggioli
2013-12-13 16:49   ` Ian Jackson
2013-12-13 17:32     ` Dario Faggioli
2013-12-13 17:34       ` Ian Jackson
2013-12-13 18:03         ` Dario Faggioli
2013-12-13 18:20           ` Ian Jackson

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=20131212225332.11164.99188.stgit@Solace \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.