summaryrefslogtreecommitdiffstats
path: root/boot-env/OpenSLX
diff options
context:
space:
mode:
authorOliver Tappe2009-01-28 17:46:42 +0100
committerOliver Tappe2009-01-28 17:46:42 +0100
commitfaa6ae6ae6fe36a5950fd0c10673c2995c0fe099 (patch)
tree5cf8ff9b846d00698f3c3f37028d1023000d3ffb /boot-env/OpenSLX
parent* in case of error during creation of bootmenu files, the demuxer no longer (diff)
downloadcore-faa6ae6ae6fe36a5950fd0c10673c2995c0fe099.tar.gz
core-faa6ae6ae6fe36a5950fd0c10673c2995c0fe099.tar.xz
core-faa6ae6ae6fe36a5950fd0c10673c2995c0fe099.zip
* implemented creation of bootmenu for preboot environments
* separated general preboot-files from the cd-specific ones git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2539 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'boot-env/OpenSLX')
-rw-r--r--boot-env/OpenSLX/BootEnvironment/PXE.pm9
-rw-r--r--boot-env/OpenSLX/BootEnvironment/Preboot.pm119
-rw-r--r--boot-env/OpenSLX/BootEnvironment/PrebootCD.pm10
-rw-r--r--boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm4
-rw-r--r--boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm28
-rw-r--r--boot-env/OpenSLX/MakeInitRamFS/Engine/PrebootCD.pm2
6 files changed, 111 insertions, 61 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm
index 2dd0c2b7..e8c05090 100644
--- a/boot-env/OpenSLX/BootEnvironment/PXE.pm
+++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm
@@ -59,6 +59,7 @@ sub writeBootloaderMenuFor
my $pxeConfig = $self->_getTemplate();
my $pxeFile = "$pxeConfigPath/$externalClientID";
my $clientAppend = $client->{attrs}->{kernel_params_client} || '';
+ my $bootURI = $client->{attrs}->{boot_uri} || '';
vlog(1, _tr("writing PXE-file %s", $pxeFile));
# set label for each system
@@ -73,7 +74,7 @@ sub writeBootloaderMenuFor
$label = $info->{name};
}
}
- $info->{label} = $label;
+ $info->{pxeLabel} = $label;
}
my $slxLabels = '';
foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
@@ -81,9 +82,10 @@ sub writeBootloaderMenuFor
my $kernelName = basename($info->{'kernel-file'});
my $append = $info->{attrs}->{kernel_params};
$append .= " initrd=$vendorOSName/$info->{'initramfs-name'}";
+ $append .= " file=$bootURI" if length($bootURI);
$append .= " $clientAppend";
$slxLabels .= "LABEL openslx-$info->{'external-id'}\n";
- $slxLabels .= "\tMENU LABEL ^$info->{label}\n";
+ $slxLabels .= "\tMENU LABEL ^$info->{pxeLabel}\n";
$slxLabels .= "\tKERNEL $vendorOSName/$kernelName\n";
$slxLabels .= "\tAPPEND $append\n";
$slxLabels .= "\tIPAPPEND 3\n";
@@ -103,7 +105,8 @@ sub writeBootloaderMenuFor
# PXE uses 'cp850' (codepage 850) but our string is in utf-8, we have
# to convert in order to avoid showing gibberish on the client side...
- spitFile($pxeFile, $pxeConfig, { 'io-layer' => 'encoding(cp850)' } );
+ spitFile($pxeFile, $pxeConfig, { 'io-layer' => 'encoding(cp850)' } )
+ unless $self->{'dry-run'};
return 1;
}
diff --git a/boot-env/OpenSLX/BootEnvironment/Preboot.pm b/boot-env/OpenSLX/BootEnvironment/Preboot.pm
index eb6fa730..b5a7ddb8 100644
--- a/boot-env/OpenSLX/BootEnvironment/Preboot.pm
+++ b/boot-env/OpenSLX/BootEnvironment/Preboot.pm
@@ -23,6 +23,7 @@ use File::Basename;
use File::Path;
use OpenSLX::Basics;
+use OpenSLX::ConfigDB qw(:support);
use OpenSLX::Utils;
sub writeBootloaderMenuFor
@@ -39,57 +40,65 @@ sub writeBootloaderMenuFor
= clone($self->_pickSystemWithNewestKernel($systemInfos));
$self->_createImage($client, $prebootSystemInfo);
-# my $pxePath = $self->{'target-path'};
-# my $pxeConfigPath = "$pxePath/pxelinux.cfg";
-#
-# my $pxeConfig = $self->_getTemplate();
-# my $pxeFile = "$pxeConfigPath/$externalClientID";
-# my $clientAppend = $client->{attrs}->{kernel_params_client} || '';
-# vlog(1, _tr("writing PXE-file %s", $pxeFile));
-#
-# # set label for each system
-# foreach my $info (@$systemInfos) {
-# my $label = $info->{label} || '';
-# if (!length($label) || $label eq $info->{name}) {
-# if ($info->{name} =~ m{^(.+)::(.+)$}) {
-# my $system = $1;
-# my $exportType = $2;
-# $label = $system . ' ' x (40-length($system)) . $exportType;
-# } else {
-# $label = $info->{name};
-# }
-# }
-# $info->{label} = $label;
-# }
-# my $slxLabels = '';
-# foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
-# my $vendorOSName = $info->{'vendor-os'}->{name};
-# my $kernelName = basename($info->{'kernel-file'});
-# my $append = $info->{attrs}->{kernel_params};
-# $append .= " initrd=$vendorOSName/$info->{'initramfs-name'}";
-# $append .= " $clientAppend";
-# $slxLabels .= "LABEL openslx-$info->{'external-id'}\n";
-# $slxLabels .= "\tMENU LABEL ^$info->{label}\n";
-# $slxLabels .= "\tKERNEL $vendorOSName/$kernelName\n";
-# $slxLabels .= "\tAPPEND $append\n";
-# $slxLabels .= "\tIPAPPEND 1\n";
-# my $helpText = $info->{description} || '';
-# if (length($helpText)) {
-# # make sure that text matches the given margin
-# my $margin = $openslxConfig{'pxe-theme-menu-margin'} || 0;
-# my $marginAsText = ' ' x $margin;
-# $helpText =~ s{^}{$marginAsText}gms;
-# $slxLabels .= "\tTEXT HELP\n$helpText\n\tENDTEXT\n";
-# }
-# }
-# # now add the slx-labels (inline or appended) and write the config file
-# if (!($pxeConfig =~ s{\@\@\@SLX_LABELS\@\@\@}{$slxLabels})) {
-# $pxeConfig .= $slxLabels;
-# }
-#
-# # PXE uses 'cp850' (codepage 850) but our string is in utf-8, we have
-# # to convert in order to avoid showing gibberish on the client side...
-# spitFile($pxeFile, $pxeConfig, { 'io-layer' => 'encoding(cp850)' } );
+ my $externalClientName = externalConfigNameForClient($client);
+ my $bootloaderPath = "$self->{'target-path'}/bootloader";
+ my $bootloaderConfigPath = "$bootloaderPath/$externalClientName";
+ mkpath($bootloaderConfigPath) unless $self->{'dry-run'};
+ my $menuFile = "$bootloaderConfigPath/bootmenu.dialog";
+
+ my $clientAppend = $client->{attrs}->{kernel_params_client} || '';
+ vlog(1, _tr("writing bootmenu %s", $menuFile));
+
+ # set label for each system
+ foreach my $info (@$systemInfos) {
+ my $label = $info->{label} || '';
+ if (!length($label) || $label eq $info->{name}) {
+ $label = $info->{name};
+ }
+ $info->{label} = $label;
+ }
+ my $bootmenuEntries = '';
+ foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) {
+ my $vendorOSName = $info->{'vendor-os'}->{name};
+ my $kernelName = basename($info->{'kernel-file'});
+ my $append = $info->{attrs}->{kernel_params} || '';
+ $append .= " $clientAppend";
+ $bootmenuEntries .= qq{ "$info->{label}" "" 1};
+
+ # create a file containing the boot-configuration for this system
+ my $systemDescr = unshiftHereDoc(<<" End-of-Here");
+ label="$info->{label}"
+ kernel="$vendorOSName/$kernelName"
+ initramfs="$vendorOSName/$info->{'initramfs-name'}"
+ append="$append"
+ End-of-Here
+ my $systemFile = "$bootloaderConfigPath/$info->{label}";
+ spitFile(
+ $systemFile, $systemDescr, { 'io-layer' => 'encoding(iso8859-1)' }
+ ) unless $self->{'dry-run'};
+ }
+
+ my $entryCount = @$systemInfos;
+ my $bootmenu = unshiftHereDoc(<<" End-of-Here");
+ --radiolist "OpenSLX Boot Menu" 20 65 $entryCount $bootmenuEntries
+ End-of-Here
+
+ if (!$self->{'dry-run'}) {
+ # default to iso encoding, let's see how uclibc copes with it ...
+ spitFile($menuFile, $bootmenu, { 'io-layer' => 'encoding(iso8859-1)' });
+
+ # copy the preboot script into the folder to be tared
+ my $prebootBasePath
+ = "$openslxConfig{'base-path'}/share/boot-env/preboot";
+ slxsystem(qq{cp -p $prebootBasePath/preboot.sh $bootloaderConfigPath/});
+ slxsystem(qq{chmod a+x $bootloaderConfigPath/preboot.sh});
+
+ # create a tar which can/will be downloaded by prebooting clients
+ my $tarCMD
+ = qq{cd $bootloaderConfigPath; tar -czf "${bootloaderConfigPath}.env" *};
+ slxsystem($tarCMD);
+ rmtree($bootloaderConfigPath);
+ }
return 1;
}
@@ -139,12 +148,18 @@ sub _makePrebootInitRamFS
my $self = shift;
my $info = shift;
my $initramfs = shift;
+ my $client = shift;
my $vendorOS = $info->{'vendor-os'};
my $kernelFile = basename(followLink($info->{'kernel-file'}));
my $attrs = clone($info->{attrs} || {});
+ my $bootURI = $client->{attrs}->{boot_uri};
+ if (!$bootURI) {
+ die _tr("client $client->{name} needs an URI in attribute 'boot_uri' to be used for preboot!");
+ }
+
chomp(my $slxVersion = qx{slxversion});
my $params = {
@@ -160,6 +175,8 @@ sub _makePrebootInitRamFS
=> "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}",
'slx-version' => $slxVersion,
'system-name' => $info->{name},
+ 'preboot-id' => $client->{name},
+ 'boot-uri' => $bootURI,
};
# TODO: make debug-level an explicit attribute, it's used in many places!
diff --git a/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm b/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm
index 6da11577..d4126ba9 100644
--- a/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm
+++ b/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm
@@ -33,8 +33,8 @@ sub initialize
return if !$self->SUPER::initialize($params);
- $self->{'original-path'} = "$openslxConfig{'public-path'}/preboot-cd";
- $self->{'target-path'} = "$openslxConfig{'public-path'}/preboot-cd.new";
+ $self->{'original-path'} = "$openslxConfig{'public-path'}/preboot";
+ $self->{'target-path'} = "$openslxConfig{'public-path'}/preboot.new";
if (!$self->{'dry-run'}) {
mkpath([$self->{'original-path'}]);
@@ -68,8 +68,8 @@ sub _createImage
my $imageDir = "$openslxConfig{'public-path'}/images/$client->{name}";
mkpath($imageDir) unless $self->{'dry-run'};
- # copy static data and init script
- my $dataDir = "$openslxConfig{'base-path'}/share/boot-env/preboot-cd";
+ # copy static data
+ my $dataDir = "$openslxConfig{'base-path'}/share/boot-env/preboot/cd";
slxsystem(qq{rsync -rlpt $dataDir/iso "$imageDir/"})
unless $self->{'dry-run'};
@@ -81,7 +81,7 @@ sub _createImage
# create initramfs
my $initramfsName = qq{"$imageDir/iso/isolinux/initramfs"};
- $self->_makePrebootInitRamFS($info, $initramfsName);
+ $self->_makePrebootInitRamFS($info, $initramfsName, $client);
# write trivial isolinux config
my $isolinuxConfig = unshiftHereDoc(<<" End-of-Here");
diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
index baf6d4c3..e6e7155e 100644
--- a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
+++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm
@@ -44,6 +44,8 @@ sub new
'root-path' => '!',
'slx-version' => '!',
'system-name' => '!',
+ 'preboot-id' => '?',
+ 'boot-uri' => '?',
} );
my $self = $params;
@@ -285,7 +287,7 @@ sub _writeInitramfsSetup
# generate initramfs-setup file containing attributes that are
# relevant for the initramfs only (before there's a root-FS):
my $initramfsAttrs = {
- 'host_name' => 'slx-client', # just to have something at all
+ 'host_name' => 'slx-client', # just to have something at all
'ramfs_fsmods' => $self->{attrs}->{ramfs_fsmods} || '',
'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm
index 81074bce..6de04314 100644
--- a/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm
+++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/Preboot.pm
@@ -78,6 +78,34 @@ sub _setupBuildPath
return;
}
+sub _writeInitramfsSetup
+{
+ my $self = shift;
+
+ # generate initramfs-setup file containing attributes that are
+ # relevant for the initramfs only (before there's a root-FS) -
+ # this override adds the name of the client such that the booting
+ # system has an ID to use for accessing the corresponding boot environment
+ # on the server
+ my $initramfsAttrs = {
+ 'host_name' => 'slx-client', # just to have something at all
+ 'ramfs_miscmods' => $self->{attrs}->{ramfs_miscmods} || '',
+ 'ramfs_nicmods' => $self->{attrs}->{ramfs_nicmods} || '',
+ 'preboot_id' => $self->{'preboot-id'} || '',
+ 'boot_uri' => $self->{'boot-uri'} || '',
+ };
+ my $content = "# attributes set by slxconfig-demuxer:\n";
+ foreach my $attr (keys %$initramfsAttrs) {
+ $content .= qq[$attr="$initramfsAttrs->{$attr}"\n];
+ }
+ $self->addCMD( {
+ file => "$self->{'build-path'}/etc/initramfs-setup",
+ content => $content
+ } );
+
+ return;
+}
+
sub _copyUclibcRootfs
{
my $self = shift;
diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/PrebootCD.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/PrebootCD.pm
index 1f6aa045..b447177c 100644
--- a/boot-env/OpenSLX/MakeInitRamFS/Engine/PrebootCD.pm
+++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/PrebootCD.pm
@@ -29,7 +29,7 @@ sub _copyVariantSpecificFiles
{
my $self = shift;
- my $dataDir = "$openslxConfig{'base-path'}/share/boot-env/preboot-cd";
+ my $dataDir = "$openslxConfig{'base-path'}/share/boot-env/preboot";
$self->addCMD("cp $dataDir/init $self->{'build-path'}/");
return 1;