Skip to content

Commit

Permalink
Merge pull request #7250 from gurevichmark/ubuntu20_legacy
Browse files Browse the repository at this point in the history
Support for diskful Ubuntu20.04 legacy OS image
  • Loading branch information
besawn committed Sep 19, 2022
2 parents 168adac + 471fd4d commit 94c0e8e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion xCAT-server/lib/perl/xCAT/SvrUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ sub update_tables_with_templates
my $arch = shift; #like ppc64, x86, x86_64
my $ospkgdir = shift;
my $osdistroname = shift;
my $legacyUB20 = shift;
my %args = @_;

my $osname = $osver;; #like sles, rh, centos, windows
Expand Down Expand Up @@ -722,7 +723,7 @@ sub update_tables_with_templates
# for Focal and later Ubuntu we repurpose genos to indicate the use
# of the subiquity installer
if ($osver =~ /ubuntu(\d+\.\d+)/) {
if ($1 >= 20.04) {
if (($1 >= 20.04) and ($legacyUB20 !~ /legacy/)) {
$genos = "subiquity";
}
}
Expand Down
25 changes: 16 additions & 9 deletions xCAT-server/lib/xcat/plugins/debian.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ sub using_dracut
sub using_subiquity
{
my $os = shift;
my $tmplfile = shift;
if ($os =~ /ubuntu(\d+\.\d+)/) {
if ($1 >= 20.04) {
if (($1 >= 20.04) and ($tmplfile =~ /subiquity/)) {
return 1;
}
}
Expand Down Expand Up @@ -258,6 +259,7 @@ sub copycd
close($dinfo);

my $isnetinst = 0;
my $legacyUB20 = ""; # Is this a Ubuntu20.04.1 legacy ISO
my $prod = $line2[0]; # The product should be the first word
my $ver = $line2[1]; # The version should be the second word
my $darch = $line2[6]; # The architecture should be the seventh word
Expand Down Expand Up @@ -339,11 +341,16 @@ sub copycd
return;
}
}
if ((-r $path . "/install/vmlinuz") and ($distname =~ /ubuntu20.04/))
{
# Presence of /install/vmlinuz file on Ubuntu20.04 iso indicates
# a legacy (non subiquity installer) image
$legacyUB20 = "(legacy)";
}
if ($inspection) {
$callback->(
{
info =>
"DISTNAME:$distname\n" . "ARCH:$debarch\n" . "DISCNO:$discno\n"
info => "DISTNAME:$distname" . "$legacyUB20" ." \n" . "ARCH:$debarch\n" . "DISCNO:$discno\n"
}
);
return;
Expand Down Expand Up @@ -440,7 +447,7 @@ sub copycd

$callback->({ data => "Media copy operation successful" });
unless ($noosimage) {
my @ret = xCAT::SvrUtils->update_tables_with_templates($distname, $arch, $temppath, $osdistroname);
my @ret = xCAT::SvrUtils->update_tables_with_templates($distname, $arch, $temppath, $osdistroname, $legacyUB20);
if ($ret[0] != 0) {
$callback->({ data => "Error when updating the osimage tables: " . $ret[1] });
}
Expand Down Expand Up @@ -580,7 +587,7 @@ sub mkinstall {
my $pltfrm = getplatform($ref->{'osvers'});
my $tmplfile = xCAT::SvrUtils::get_tmpl_file_name("$installroot/custom/install/$pltfrm",
$ref->{'profile'}, $ref->{'osvers'}, $ref->{'osarch'}, $ref->{'osvers'});
if (using_subiquity($os)) {
if (using_subiquity($os,$tmplfile)) {

# in this context we use the genos parameter to search for the subiquity template
$tmplfile = xCAT::SvrUtils::get_tmpl_file_name("$installroot/custom/install/$pltfrm",
Expand Down Expand Up @@ -738,7 +745,7 @@ sub mkinstall {
my $autoinstfile = "$installroot/autoinst/" . $node;

# handle nocloud-net datasource for ubuntu 20.04+
if (using_subiquity($os)) {
if (using_subiquity($os,$tmplfile)) {

# clean up existing files to make way for the new directory
if (-f $autoinstfile) {
Expand Down Expand Up @@ -767,7 +774,7 @@ sub mkinstall {

# maybe Debian will decide to use subiquity at some point?
my $prescript = "$::XCATROOT/share/xcat/install/scripts/pre.$platform";
if (using_subiquity($os)) {
if (using_subiquity($os,$tmplfile)) {
$prescript = $prescript . ".subiquity";
}
my $postscript = "$::XCATROOT/share/xcat/install/scripts/post.$platform";
Expand Down Expand Up @@ -896,7 +903,7 @@ sub mkinstall {
mkpath("$tftppath");
copy($kernpath, "$tftppath/vmlinuz");
# we don't want to customise the subiquity initrd
if (using_subiquity($os)) {
if (using_subiquity($os,$tmplfile)) {
copy($initrdpath, "$tftppath/initrd.img");
} else {
copyAndAddCustomizations($initrdpath, "$tftppath/initrd.img");
Expand Down Expand Up @@ -927,7 +934,7 @@ sub mkinstall {

my $kcmdline = "nofb utf8 auto xcatd=" . $instserver;

if (using_subiquity($os)) {
if (using_subiquity($os,$tmplfile)) {
$kcmdline .= " autoinstall ip=dhcp netboot=nfs nfsroot=${instserver}:${pkgdir}";
$kcmdline .= " ds=nocloud-net;s=http://${instserver}:${httpport}/install/autoinst/${node}/";
} else {
Expand Down
4 changes: 3 additions & 1 deletion xCAT-server/share/xcat/install/ubuntu/compute.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ d-i preseed/late_command string \
mount -o bind /dev/pts /target/dev/pts -t devpts; \
mount -o bind /sys /target/sys; \
chroot /target /root/post.script; \
cp /target/etc/network/interfaces /etc/network/interfaces; \
if [ -f /target/etc/network/interfaces ]; then \
cp /target/etc/network/interfaces /etc/network/interfaces; \
fi; \
} >>/target/var/log/xcat/xcat.log 2>&1

0 comments on commit 94c0e8e

Please sign in to comment.