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

[Xen-devel] [OSSTEST RFC 08/16] ts-centos-host-install: Install CentOS on a host



Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 ts-centos-host-install | 154 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)
 create mode 100755 ts-centos-host-install

diff --git a/ts-centos-host-install b/ts-centos-host-install
new file mode 100755
index 0000000..943002d
--- /dev/null
+++ b/ts-centos-host-install
@@ -0,0 +1,154 @@
+#!/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 POSIX;
+
+BEGIN { unshift @INC, qw(.); }
+use Osstest;
+use Osstest::CentOS;
+use Osstest::TestSupport;
+use Osstest::Logtailer;
+
+tsreadconfig();
+
+my $poweron_test_only;
+
+our %xopts;
+
+while (@ARGV and $ARGV[0] =~ m/^-/) {
+    $_= shift @ARGV;
+    last if m/^--$/;
+    if  (m/^--poweron-test-only$/) {
+       $poweron_test_only= 1;
+    } else {
+       die "$_ $!";
+    }
+}
+
+our ($whhost) = @ARGV;
+$whhost ||= 'host';
+our $ho= selecthost($whhost);
+exit 0 if $ho->{Flags}{'no-reinstall'};
+exit 0 if $ho->{SharedReady};
+
+our %timeout= qw(ReadPreseed  350
+                 Sshd        2400);
+
+sub install () {
+    power_state($ho, 0);
+
+    my ($ks_url,$ps_file) = kickstart_create
+        ($ho, '',
+         DiskDevice => $ho->{DiskDevice},
+         Properties => $ho->{Properties},
+         Hostname   => $ho->{Name},
+         IpAddress  => $ho->{Ip}
+         );
+
+    setup_netboot_firstboot($ks_url);
+    power_cycle_sleep($ho);
+
+    my $logtailer = Osstest::Logtailer->new($c{WebspaceLog});
+    power_state($ho, 1);
+
+    await_webspace_fetch_byleaf(get_timeout($ho,'reboot',$timeout{ReadPreseed})
+                                , 1,
+                                $logtailer, $ho, $ks_url);
+
+    if ($poweron_test_only) {
+       logm("Hooray, power on worked.");
+       power_state($ho, 0);
+       exit 0;
+    }
+
+    setup_netboot_local($ho);
+
+    await_tcp(get_timeout($ho, 'reboot', $timeout{Sshd}), 14, $ho);
+
+    our $vgname = ks_vg_name($ho);
+
+    my $partitions= target_cmd_output_root($ho, 'cat /proc/partitions');
+    foreach my $l (split /\n/, $partitions) {
+        logm("| $l");
+        next unless $l =~ m/^\s*\d+\s+\d+\s+\d+\s+((?:sd|hd)[b-z])\s*$/;
+        my $dev= "/dev/$1";
+        target_cmd_root($ho, "pvcreate $dev");
+        target_cmd_root($ho, "vgextend $vgname $dev");
+    }
+
+    my $kpath= $c{TestHostKeypairPath};
+    my $kleaf= $kpath;
+    $kleaf =~ s,.*/,,;
+    my $ktarg= $kleaf;
+    $ktarg =~ s/^(id_[a-z]+)_.*/$1/;
+    foreach my $ext ('', '.pub') {
+       target_putfile     ($ho,10, "${kpath}${ext}", ".ssh/${ktarg}${ext}");
+       target_putfile_root($ho,10, "${kpath}${ext}", ".ssh/${ktarg}${ext}");
+    }
+    target_cmd     ($ho, "chmod g-r .ssh/${ktarg}");
+    target_cmd_root($ho, "chmod g-r .ssh/${ktarg}");
+
+    target_cmd_root($ho, "chmod 2755 /root");
+
+    if ($c{HttpProxy}) {
+        target_editfile_root($ho, '/etc/yum.conf',
+            sub { target_editfile_kvp_replace("proxy", $c{HttpProxy}) });
+    }
+
+    host_install_postboot_complete($ho);
+
+    logm('OK: install completed');
+}
+
+sub setup_netboot_firstboot ($) {
+    my ($ks_url) = @_;
+
+    my $TftpCiBase = "$c{TftpPlayDir}centos";
+    my $CiVersion = 'current';
+    my $Suite = 'centos7';
+    my $c_i = "$TftpCiBase/$r{arch}/$CiVersion-$Suite";
+
+    my @dicmdline= qw(vga=normal);
+    push @dicmdline, kickstart_installcmdline_core($ho, $ks_url, %xopts);
+
+    my $kernel= "$c_i/vmlinuz";
+    my $initrd= "$c_i/initrd.img";
+
+    my $ipappend = 2;
+
+    push @dicmdline,
+        get_host_property($ho, "install-append $ho->{Suite}", ''),
+        get_host_property($ho, "install-append $ho->{Suite} $r{arch}", '');
+
+    my $console = get_host_native_linux_console($ho);
+
+    push @dicmdline, "console=$console" unless $console eq "NONE";
+
+    my @hocmdline;
+
+    push @hocmdline,
+        get_host_property($ho, "linux-boot-append $ho->{Suite}", ''),
+        get_host_property($ho, "linux-boot-append $ho->{Suite} $r{arch}", '');
+
+    $xopts{ipappend} = $ipappend;
+    setup_netboot_di($ho, $kernel, "/$initrd", \@dicmdline, \@hocmdline,
+                    %xopts);
+}
+
+install();
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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