mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-07-31 10:09:40 +00:00
Merge pull request #7589 from VersatusHPC/codex/issue-5843-copycds-sles-media
This commit is contained in:
@@ -33,6 +33,8 @@ DESCRIPTION
|
||||
|
||||
The \ **copycds**\ command copies all contents of Distribution DVDs/ISOs or Service Pack DVDs/ISOs to a destination directory. The destination directory can be specified by the \ **-p**\ option. If no path is specified, the default destination directory will be formed from the \ **installdir**\ site table attribute, distro name and architecture, for example: /install/rhels6.3/x86_64. The \ **copycds**\ command can copy from one or more ISO files, or the CD/DVD device path.
|
||||
|
||||
For SLE 15 media that identifies itself as Installer or Packages media, the primary media are copied to directories ``1`` and ``2``. Source-RPM media in those sets, identified by embedded ``SOURCE`` or ``Media2`` metadata, are kept separately in ``installer2`` or ``packages2``, so they cannot replace the provisioning media. ISO filenames are not used to identify these media.
|
||||
|
||||
For Ubuntu live-server media, \ **copycds**\ copies the installer media and can create install osimages, but the copied media is not a complete Ubuntu apt package mirror. Ubuntu netboot or statelite image generation with \ **genimage**\ may require additional package sources configured through \ **linuximage.pkgdir**\ or \ **linuximage.otherpkgdir**\ , such as a local mirror or an explicitly configured HTTP/HTTPS Ubuntu apt repository.
|
||||
|
||||
You can specify \ **-i**\ or \ **-**\ **-inspection**\ option to check whether the DVDs/ISOs can be recognized by xCAT. If recognized, the distribution name, architecture and the disc no (the disc sequence number of DVDs/ISOs in multi-disk distribution) of the DVD/ISO is displayed. If xCAT doesn't recognize the DVD/ISO, you must manually specify the distro name and architecture using the \ **-n**\ and \ **-a**\ options. This is sometimes the case for distros that have very recently been released, and the xCAT code hasn't been updated for it yet.
|
||||
|
||||
@@ -14,6 +14,8 @@ B<copycds> [B<-h>|B<--help>]
|
||||
|
||||
The B<copycds> command copies all contents of Distribution DVDs/ISOs or Service Pack DVDs/ISOs to a destination directory. The destination directory can be specified by the B<-p> option. If no path is specified, the default destination directory will be formed from the B<installdir> site table attribute, distro name and architecture, for example: /install/rhels6.3/x86_64. The B<copycds> command can copy from one or more ISO files, or the CD/DVD device path.
|
||||
|
||||
For SLE 15 media that identifies itself as Installer or Packages media, the primary media are copied to directories C<1> and C<2>. Source-RPM media in those sets, identified by embedded C<SOURCE> or C<Media2> metadata, are kept separately in C<installer2> or C<packages2>, so they cannot replace the provisioning media. ISO filenames are not used to identify these media.
|
||||
|
||||
You can specify B<-i> or B<--inspection> option to check whether the DVDs/ISOs can be recognized by xCAT. If recognized, the distribution name, architecture and the disc no (the disc sequence number of DVDs/ISOs in multi-disk distribution) of the DVD/ISO is displayed. If xCAT doesn't recognize the DVD/ISO, you must manually specify the distro name and architecture using the B<-n> and B<-a> options. This is sometimes the case for distros that have very recently been released, and the xCAT code hasn't been updated for it yet.
|
||||
|
||||
You can get xCAT to recognize new DVDs/ISOs by adding them to /opt/xcat/lib/perl/xCAT/data/discinfo.pm (the key of the hash is the first line of .discinfo) and reloading xcatd (B<service xcatd reload>).
|
||||
|
||||
@@ -1660,6 +1660,24 @@ sub _copycd_distname_supported
|
||||
return;
|
||||
}
|
||||
|
||||
sub _sle15_supplemental_media_slot
|
||||
{
|
||||
my ($description, $media_type, $primary_slot) = @_;
|
||||
|
||||
return $primary_slot unless $description and $media_type;
|
||||
|
||||
my $media_number;
|
||||
if ($description =~ /Media(\d+)(?:\.iso)?/i) {
|
||||
$media_number = $1;
|
||||
} elsif ($description =~ /SOURCE/i) {
|
||||
$media_number = 2;
|
||||
}
|
||||
|
||||
return $primary_slot unless $media_number and $media_number > 1;
|
||||
|
||||
return $media_type . $media_number;
|
||||
}
|
||||
|
||||
sub copycd
|
||||
{
|
||||
my $request = shift;
|
||||
@@ -1870,7 +1888,7 @@ sub copycd
|
||||
$distname = $opensuse_media_distname unless $distname;
|
||||
$darch = $opensuse_media_arch if $opensuse_media_arch;
|
||||
} elsif ($dsc =~ /Installer/ and $dsc =~ /SLE-15/) {
|
||||
$discnumber = 1;
|
||||
$discnumber = _sle15_supplemental_media_slot($dsc, "installer", 1);
|
||||
unless ($distname) {
|
||||
if ($dsc =~ /SLE-15-SP(\d)/) {
|
||||
$distname = "sle15.$1";
|
||||
@@ -1879,7 +1897,7 @@ sub copycd
|
||||
}
|
||||
};
|
||||
} elsif ($dsc =~ /SLE-15/ and $dsc =~ /Packages/) {
|
||||
$discnumber = 2;
|
||||
$discnumber = _sle15_supplemental_media_slot($dsc, "packages", 2);
|
||||
unless ($distname) {
|
||||
if ($dsc =~ /SLE-15-SP(\d)/) {
|
||||
$distname = "sle15.$1";
|
||||
@@ -1909,7 +1927,6 @@ sub copycd
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unless ($distname and $discnumber)
|
||||
{
|
||||
#failed to parse the disc info
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use Test::More;
|
||||
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/xcat/plugins";
|
||||
|
||||
require sles;
|
||||
|
||||
sub write_file
|
||||
{
|
||||
my ($path, $contents) = @_;
|
||||
open(my $fh, '>', $path) or die "Cannot write $path: $!";
|
||||
print {$fh} $contents;
|
||||
close($fh);
|
||||
}
|
||||
|
||||
sub inspect_media
|
||||
{
|
||||
my $mountpoint = shift;
|
||||
my @responses;
|
||||
my $request = {
|
||||
arg => [ '-m', $mountpoint, '-i' ],
|
||||
};
|
||||
|
||||
{
|
||||
no warnings qw(once redefine);
|
||||
local *xCAT::TableUtils::get_site_attribute = sub { return; };
|
||||
xCAT_plugin::sles::copycd(
|
||||
$request,
|
||||
sub { push @responses, shift; },
|
||||
undef,
|
||||
);
|
||||
}
|
||||
|
||||
my ($info) = map { $_->{info} } grep { defined($_->{info}) } @responses;
|
||||
return $info || '';
|
||||
}
|
||||
|
||||
my $sles12 = tempdir(CLEANUP => 1);
|
||||
make_path("$sles12/media.1");
|
||||
write_file("$sles12/content", "DEFAULTBASE ppc64le\nVERSION 12.4-0\n");
|
||||
write_file("$sles12/media.1/media", "SUSE Linux Enterprise Server 12 SP4\nppc64le\n1\n");
|
||||
write_file("$sles12/media.1/products", "SUSE-Linux-Enterprise-Server 12.4-0 ppc64le\n");
|
||||
|
||||
like(
|
||||
inspect_media($sles12),
|
||||
qr/^DISTNAME:sles12\.4\nARCH:ppc64le\nDISCNO:1\n$/,
|
||||
'SLES 12 primary server media keeps slot 1',
|
||||
);
|
||||
|
||||
my $sles12_source = tempdir(CLEANUP => 1);
|
||||
make_path("$sles12_source/media.2");
|
||||
write_file("$sles12_source/content", "DEFAULTBASE ppc64le\nVERSION 12.4-0\n");
|
||||
write_file("$sles12_source/media.2/media", "SUSE\n20181107140652\n");
|
||||
write_file("$sles12_source/media.2/products", "/ SLES12-SP4 12.4-0\n");
|
||||
like(
|
||||
inspect_media($sles12_source),
|
||||
qr/^DISTNAME:sles12\.4\nARCH:ppc64le\nDISCNO:2\n$/,
|
||||
'SLES 12 source media uses its embedded media.2 sequence',
|
||||
);
|
||||
|
||||
write_file("$sles12/media.1/products", "SUSE-Linux-Enterprise-Software-Development-Kit 12.4-0 ppc64le\n");
|
||||
like(
|
||||
inspect_media($sles12),
|
||||
qr/^DISTNAME:sles12\.4\nARCH:ppc64le\nDISCNO:sdk3\n$/,
|
||||
'SLES 12 SDK workaround remains based on embedded metadata',
|
||||
);
|
||||
|
||||
my $sle15 = tempdir(CLEANUP => 1);
|
||||
make_path("$sle15/media.1");
|
||||
write_file("$sle15/media.1/products", "SLES 15 ppc64le\n");
|
||||
|
||||
write_file("$sle15/media.1/media", "SUSE - SLE-15-Installer-DVD-ppc64le-Build668.1-Media\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:1\n$/,
|
||||
'SLE 15 primary Installer media keeps slot 1',
|
||||
);
|
||||
|
||||
write_file("$sle15/media.1/media", "SUSE - SLE-15-Installer-DVD-ppc64le-Build668.1-Media-SOURCE\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:installer2\n$/,
|
||||
'SLE 15 Installer source media uses its embedded SOURCE marker',
|
||||
);
|
||||
|
||||
write_file("$sle15/media.1/media", "SUSE - SLE-15-Packages-ppc64le-Build668.1-Media1.iso\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:2\n$/,
|
||||
'SLE 15 primary Packages media keeps slot 2',
|
||||
);
|
||||
|
||||
write_file("$sle15/media.1/media", "SUSE - SLE-15-Packages-ppc64le-Build668.1-Media2.iso\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:packages2\n$/,
|
||||
'SLE 15 Packages source media uses its embedded Media2 marker',
|
||||
);
|
||||
|
||||
write_file("$sle15/media.1/media", "SLE-15 SOURCE ppc64le\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:2\n$/,
|
||||
'SLE 15 SOURCE Media2 keeps the existing packages-compatible slot',
|
||||
);
|
||||
|
||||
write_file("$sle15/media.1/media", "SLE-15 Full ppc64le\n");
|
||||
like(
|
||||
inspect_media($sle15),
|
||||
qr/^DISTNAME:sle15\nARCH:ppc64le\nDISCNO:1\n$/,
|
||||
'SLE 15 Full media keeps the existing primary slot',
|
||||
);
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user