diff options
Diffstat (limited to 'boot-env/OpenSLX/BootEnvironment')
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/Preboot.pm | 92 | ||||
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm | 100 | ||||
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm (renamed from boot-env/OpenSLX/BootEnvironment/PrebootCD.pm) | 17 |
3 files changed, 144 insertions, 65 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/Preboot.pm b/boot-env/OpenSLX/BootEnvironment/Preboot.pm index 84853777..888e32ba 100644 --- a/boot-env/OpenSLX/BootEnvironment/Preboot.pm +++ b/boot-env/OpenSLX/BootEnvironment/Preboot.pm @@ -24,7 +24,6 @@ use File::Path; use OpenSLX::Basics; use OpenSLX::ConfigDB qw(:support); -use OpenSLX::MakeInitRamFS::Engine::Preboot; use OpenSLX::Utils; sub initialize @@ -61,7 +60,8 @@ sub writeBootloaderMenuFor my $prebootSystemInfo = clone($self->_pickSystemWithNewestKernel($systemInfos)); - $self->_createImage($client, $prebootSystemInfo); + + $self->_createImages($client, $prebootSystemInfo); my $externalClientName = externalConfigNameForClient($client); my $bootloaderPath = "$self->{'target-path'}/bootloader"; @@ -131,6 +131,40 @@ sub writeBootloaderMenuFor return 1; } +sub _createImages +{ + my $self = shift; + my $client = shift; + my $info = shift; + + my %mediaMap = ( + 'cd' => 'CD', + ); + my $prebootMedia = $client->{attrs}->{preboot_media} || ''; + if (!$prebootMedia) { + warn _tr( + "no preboot-media defined for client %s, no images will be generated!", + $client->{name} + ); + return 0; + } + foreach my $mediumName (split m{, }, $prebootMedia) { + my $moduleName = $mediaMap{$mediumName} + or die _tr( + "'%s' is not one of the supported preboot-medias (cd)", + $mediumName + ); + + my $prebootMedium = instantiateClass( + "OpenSLX::BootEnvironment::Preboot::$moduleName" + ); + $prebootMedium->initialize($self); + $prebootMedium->createImage($client, $info); + } + + return 1; +} + sub _prepareBootloaderConfigFolder { my $self = shift; @@ -171,58 +205,4 @@ sub _pickSystemWithNewestKernel return $systemWithNewestKernel; } -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 = { - 'attrs' => $attrs, - 'export-name' => undef, - 'export-uri' => undef, - 'initramfs' => $initramfs, - 'kernel-params' - => [ split ' ', ($info->{attrs}->{kernel_params} || '') ], - 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '', - 'plugins' => '', - 'root-path' - => "$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! - my $kernelParams = $info->{attrs}->{kernel_params} || ''; - if ($kernelParams =~ m{debug(?:=(\d+))?}) { - my $debugLevel = defined $1 ? $1 : '1'; - $params->{'debug-level'} = $debugLevel; - } - - my $makeInitRamFSEngine - = OpenSLX::MakeInitRamFS::Engine::Preboot->new($params); - $makeInitRamFSEngine->execute($self->{'dry-run'}); - - # copy back kernel-params, as they might have been changed (by plugins) - $info->{attrs}->{kernel_params} - = join ' ', $makeInitRamFSEngine->kernelParams(); - - return; -} - 1; diff --git a/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm b/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm new file mode 100644 index 00000000..359561e3 --- /dev/null +++ b/boot-env/OpenSLX/BootEnvironment/Preboot/Base.pm @@ -0,0 +1,100 @@ +# Copyright (c) 2008-2009 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# BootEnvironment::Preboot::Base.pm +# - base of the Preboot-BootEnvironment API. +# ----------------------------------------------------------------------------- +package OpenSLX::BootEnvironment::Preboot::Base; + +use strict; +use warnings; + +use Clone qw(clone); + +use OpenSLX::Basics; +use OpenSLX::MakeInitRamFS::Engine::Preboot; +use OpenSLX::Utils; + +sub initialize +{ + my $self = shift; + my $params = shift; + + $self->{'dry-run'} = $params->{'dry-run'}; + + return 1; +} + +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 = { + 'attrs' => $attrs, + 'export-name' => undef, + 'export-uri' => undef, + 'initramfs' => $initramfs, + 'kernel-params' + => [ split ' ', ($info->{attrs}->{kernel_params} || '') ], + 'kernel-version' => $kernelFile =~ m[-(.+)$] ? $1 : '', + 'plugins' => '', + 'root-path' + => "$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! + my $kernelParams = $info->{attrs}->{kernel_params} || ''; + if ($kernelParams =~ m{debug(?:=(\d+))?}) { + my $debugLevel = defined $1 ? $1 : '1'; + $params->{'debug-level'} = $debugLevel; + } + + my $makeInitRamFSEngine + = OpenSLX::MakeInitRamFS::Engine::Preboot->new($params); + $makeInitRamFSEngine->execute($self->{'dry-run'}); + + # copy back kernel-params, as they might have been changed (by plugins) + $info->{attrs}->{kernel_params} + = join ' ', $makeInitRamFSEngine->kernelParams(); + + return; +} + +sub createImage +{ + my $self = shift; + my $client = shift; + my $info = shift; + + # override in subclasses! + + return 1; +} + +1; diff --git a/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm b/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm index cd99de09..7fc61875 100644 --- a/boot-env/OpenSLX/BootEnvironment/PrebootCD.pm +++ b/boot-env/OpenSLX/BootEnvironment/Preboot/CD.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2008 - OpenSLX GmbH +# Copyright (c) 2008-2009 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -8,24 +8,23 @@ # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- -# BootEnvironment::PrebootCD.pm -# - provides CD-specific implementation of the BootEnvironment API. +# BootEnvironment::Preboot::CD.pm +# - provides CD-specific implementation of the Preboot-BootEnvironment API. # ----------------------------------------------------------------------------- -package OpenSLX::BootEnvironment::PrebootCD; +package OpenSLX::BootEnvironment::Preboot::CD; use strict; use warnings; -use base qw(OpenSLX::BootEnvironment::Preboot); +use base qw(OpenSLX::BootEnvironment::Preboot::Base); -use Clone qw(clone); use File::Basename; use File::Path; use OpenSLX::Basics; use OpenSLX::Utils; -sub _createImage +sub createImage { my $self = shift; my $client = shift; @@ -39,7 +38,7 @@ sub _createImage ) ); - my $imageDir = "$openslxConfig{'public-path'}/images/$client->{name}"; + my $imageDir = "$openslxConfig{'public-path'}/images/$client->{name}/cd"; mkpath($imageDir) unless $self->{'dry-run'}; # copy static data @@ -55,7 +54,7 @@ sub _createImage # create initramfs my $initramfsName = qq{"$imageDir/iso/isolinux/initramfs"}; - $self->_makePrebootInitRamFS($info, $initramfsName, $client); + $self->makePrebootInitRamFS($info, $initramfsName, $client); # write trivial isolinux config my $isolinuxConfig = unshiftHereDoc(<<" End-of-Here"); |