]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
ts-xen-install: Adapt to install package from a centos repo
authorAnthony PERARD <anthony.perard@citrix.com>
Mon, 11 Jun 2018 18:36:37 +0000 (19:36 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 12 Jul 2018 15:49:19 +0000 (16:49 +0100)
Osstest/RedHat.pm
Osstest/TestSupport.pm
ts-xen-install

index 60531fdf96e6e9e73737d16493e14befd431a23d..1c2ab20283288a152d4511552df0c82ea3d07a13 100644 (file)
@@ -369,4 +369,45 @@ sub ks_installcmdline_core ($$;@) {
     return @cl;
 }
 
+sub yum_add_repository ($@) {
+    my ($ho, @repos_url) = @_;
+
+    my $repos = '';
+    my $yum_repo_number = 1;
+    foreach my $url (@repos_url) {
+        $repos .= <<END;
+[osstest-repo-$yum_repo_number]
+name=osstest-repo-$yum_repo_number
+baseurl=$url
+gpgcheck=0
+END
+        $yum_repo_number += 1;
+    }
+    target_putfilecontents_root_stash($ho, 10, $repos,
+        "/etc/yum.repos.d/Osstest.repo");
+
+    target_cmd_root($ho, 'yum -y update', 30*60);
+}
+
+sub setupbridge ($) {
+    my ($ho) = @_;
+    my $bridge_xenbr0 = <<END;
+DEVICE=xenbr0
+STP=no
+BRIDGING_OPTS="hello_time=0"
+TYPE=Bridge
+BOOTPROTO=dhcp
+ONBOOT=yes
+END
+    target_putfilecontents_root_stash($ho, 10, $bridge_xenbr0,
+        "/etc/sysconfig/network-scripts/ifcfg-xenbr0");
+
+    # Should be setup by install
+    target_editfile_root($ho, "/etc/sysconfig/network-scripts/ifcfg-osstest-if0",
+       sub { target_editfile_kvp_replace("BRIDGE", "xenbr0") });
+    target_editfile_root($ho, "/etc/sysconfig/network-scripts/ifcfg-osstest-if0",
+       sub { target_editfile_kvp_replace("BOOTPROTO", "none") });
+
+}
+
 1;
index 6f20008fb7c251404a4cfb82311ba73b0a6f4417..2839ba407edeb150cac85a13dbcc637833094511 100644 (file)
@@ -145,6 +145,7 @@ BEGIN {
                       host_installer_path
                       host_installcmdline_core
                       host_vg_name
+                      host_add_repository
                       );
     %EXPORT_TAGS = ( );
 
@@ -2995,4 +2996,14 @@ sub host_vg_name ($) {
     }
 }
 
+# Add extra repository where packages can be found
+sub host_add_repository ($) {
+    my ($ho) = @_;
+    if (is_host_redhat_derived($ho)) {
+        return \&Osstest::RedHat::yum_add_repository;
+    } else {
+        die "Unknown OS $ho->{OS}";
+    }
+}
+
 1;
index 8de94ac2de212285eede97546786ac26bcdb3d91..d06e46a3e0a1c7514903cffe7238e0b468e3ab6e 100755 (executable)
@@ -23,6 +23,7 @@ use File::Path;
 use File::Basename;
 use POSIX;
 use Osstest::Debian;
+use Osstest::RedHat;
 use Osstest::TestSupport;
 use Data::Dumper;
 use Osstest::CXFabric;
@@ -46,6 +47,19 @@ my $enable_xsm = ($r{enable_xsm}//'false') =~ m/true/ ? 1 : 0;
 
 my %distpath;
 
+sub setup_package_repo_config () {
+    # TODO: Find an appropriate runvar
+    # all_host_xen_repo?
+    my $repos_url = $r{redhat_repos_url};
+    die "no repo" unless defined($repos_url);
+    my @repos_url = ();
+    while ($repos_url =~ s/^([^,]+),(.*)$/$2/) {
+        push @repos_url, "$1";
+    }
+    push @repos_url, "$repos_url";
+    host_add_repository($ho)->($ho, @repos_url);
+}
+
 sub packages () {
     target_install_packages($ho,
                             qw(bridge-utils vncsnapshot libaio1 libpixman-1-0
@@ -103,6 +117,36 @@ sub some_extradebs ($) {
     }
 }
 
+sub packages_redhat () {
+    # Merge that with packages()
+    # Maybe have a runvar for packages to install
+    # if a runvar exist for Xen package, do not run extract
+    my @packages;
+
+    # For vncpasswd
+    if ($ho->{RedhatRelease} == 6) {
+        push @packages, 'tigervnc-server';
+    } else {
+        push @packages, 'tigervnc-server-minimal';
+    }
+    target_install_packages($ho, @packages);
+
+    # This packages is necessary, in order to get the right kernel
+    # It pull /usr/bin/grub-bootxen.sh (helper to boot Xen by default).
+    target_install_packages($ho, qw(centos-release-xen-common));
+
+    # Xen
+    my @xen_packages = qw(xen);
+    push @xen_packages, qw(libvirt-daemon-xen libvirt-client)
+       if toolstack($ho)->{Name} eq "libvirt";
+    target_install_packages($ho, @xen_packages);
+
+    if ($ho->{RedhatRelease} == 6) {
+        # Update Xen kernel parametter
+        target_cmd_root($ho, "grubby --update-kernel=/boot/xen.gz --args='console=hvc0'");
+    }
+}
+
 sub extradebs () {
     my $suite = $ho->{Suite};
 
@@ -408,12 +452,25 @@ END
 die if @hos > 1;
 $ho= $hos[0];
     
-packages();
-extradebs();
-extract();
+if (is_host_redhat_derived($ho)) {
+    # centos, install packages
+
+    # Could look up for repo url
+    setup_package_repo_config();
+    packages_redhat();
+} else {
+    # debian, extract dist tarballs
+    packages();
+    extradebs();
+    extract();
+}
 forbidden();
 adjustconfig();
-setupboot();
-setupinitd();
-ensurebridge();
+if (is_host_redhat_derived($ho)) {
+    Osstest::RedHat::setupbridge($ho);
+} else {
+    setupboot();
+    setupinitd();
+    ensurebridge();
+}
 hosts();