From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [OSSTest PATCH [RFC] 2/4] ts-fedora-install: added for installing fedora guests Date: Thu, 12 Dec 2013 23:53:33 +0100 Message-ID: <20131212225332.11164.99188.stgit@Solace> References: <20131212221933.11164.46804.stgit@Solace> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20131212221933.11164.46804.stgit@Solace> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org Signed-off-by: Dario Faggioli --- 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 . + +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, <{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, <{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= <{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();