summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX/OSPlugin
diff options
context:
space:
mode:
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Base.pm224
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Engine.pm616
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Roster.pm152
3 files changed, 496 insertions, 496 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm
index 5da72f2a..cede0bce 100644
--- a/os-plugins/OpenSLX/OSPlugin/Base.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Base.pm
@@ -9,14 +9,14 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Base.pm
-# - provides empty base of the OpenSLX OSPlugin API.
+# - provides empty base of the OpenSLX OSPlugin API.
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::Base;
use strict;
use warnings;
-our $VERSION = 1.01; # API-version . implementation-version
+our $VERSION = 1.01; # API-version . implementation-version
=head1 NAME
@@ -79,7 +79,7 @@ Please note that by convention, plugin names are all lowercase!
sub new
{
- confess "Creating OpenSLX::OSPlugin::Base-objects directly makes no sense!";
+ confess "Creating OpenSLX::OSPlugin::Base-objects directly makes no sense!";
}
=item initialize()
@@ -91,12 +91,12 @@ engine that drives this plugin.
sub initialize
{
- my $self = shift;
+ my $self = shift;
- $self->{'os-plugin-engine'} = shift;
- $self->{'distro'} = shift;
-
- return;
+ $self->{'os-plugin-engine'} = shift;
+ $self->{'distro'} = shift;
+
+ return;
}
=item getInfo()
@@ -109,12 +109,12 @@ this method and return the information about itself.
sub getInfo
{
- my $self = shift;
+ my $self = shift;
- return {
- # a short (one-liner) description of this plugin
- description => '',
- };
+ return {
+ # a short (one-liner) description of this plugin
+ description => '',
+ };
}
=item getAttrInfo()
@@ -143,20 +143,20 @@ Valid values range from 0-99. If your plugin does not have any requirements
in this context, just specify the default value '50'.
=back
-
+
=cut
sub getAttrInfo
{
- my $self = shift;
-
- # This default configuration will be added as attributes to the default
- # system, such that it can be overruled for any specific system by means
- # of slxconfig.
- return {
- # attribute 'active' is mandatory for all plugins
- # attribute 'precedence' is mandatory for all plugins
- };
+ my $self = shift;
+
+ # This default configuration will be added as attributes to the default
+ # system, such that it can be overruled for any specific system by means
+ # of slxconfig.
+ return {
+ # attribute 'active' is mandatory for all plugins
+ # attribute 'precedence' is mandatory for all plugins
+ };
}
=item getDefaultAttrsForVendorOS()
@@ -169,10 +169,10 @@ Returns a hash-ref with the default attribute values for the given vendor-OS.
sub getDefaultAttrsForVendorOS
{
- my $self = shift;
+ my $self = shift;
- # the default implementation does not change the default values at all:
- return $self->getAttrInfo();
+ # the default implementation does not change the default values at all:
+ return $self->getAttrInfo();
}
=back
@@ -199,15 +199,15 @@ any files from the host, fetch them from there.
sub installationPhase
{
- my $self = shift;
- my $pluginRepositoryPath = shift;
- # the repository folder, relative to the vendor-OS root
- my $pluginTempPath = shift;
- # the temporary folder, relative to the vendor-OS root
- my $openslxPath = shift;
- # the openslx base path bind-mounted into the chroot (/mnt/openslx)
-
- return;
+ my $self = shift;
+ my $pluginRepositoryPath = shift;
+ # the repository folder, relative to the vendor-OS root
+ my $pluginTempPath = shift;
+ # the temporary folder, relative to the vendor-OS root
+ my $openslxPath = shift;
+ # the openslx base path bind-mounted into the chroot (/mnt/openslx)
+
+ return;
}
=item removalPhase()
@@ -224,15 +224,15 @@ N.B.: This method is invoked while chrooted into the vendor-OS root.
sub removalPhase
{
- my $self = shift;
- my $pluginRepositoryPath = shift;
- # the repository folder, relative to the vendor-OS root
- my $pluginTempPath = shift;
- # the temporary folder, relative to the vendor-OS root
- my $openslxPath = shift;
- # the openslx base path bind-mounted into the chroot (/mnt/openslx)
-
- return;
+ my $self = shift;
+ my $pluginRepositoryPath = shift;
+ # the repository folder, relative to the vendor-OS root
+ my $pluginTempPath = shift;
+ # the temporary folder, relative to the vendor-OS root
+ my $openslxPath = shift;
+ # the openslx base path bind-mounted into the chroot (/mnt/openslx)
+
+ return;
}
=back
@@ -257,10 +257,10 @@ that it would like to see added.
sub suggestAdditionalKernelParams
{
- my $self = shift;
- my $makeInitRamFSEngine = shift;
-
- return;
+ my $self = shift;
+ my $makeInitRamFSEngine = shift;
+
+ return;
}
=item suggestAdditionalKernelModules()
@@ -270,15 +270,15 @@ requires.
In order to do so, the plugin should return the names of additional kernel
modules that it would like to see added.
-
+
=cut
sub suggestAdditionalKernelModules
{
- my $self = shift;
- my $makeInitRamFSEngine = shift;
-
- return;
+ my $self = shift;
+ my $makeInitRamFSEngine = shift;
+
+ return;
}
=item copyRequiredFilesIntoInitramfs()
@@ -294,12 +294,12 @@ All other files should be taken from the root-fs instead!
sub copyRequiredFilesIntoInitramfs
{
- my $self = shift;
- my $targetPath = shift;
- my $attrs = shift;
- my $makeInitRamFSEngine = shift;
-
- return;
+ my $self = shift;
+ my $targetPath = shift;
+ my $attrs = shift;
+ my $makeInitRamFSEngine = shift;
+
+ return;
}
=item setupPluginInInitramfs()
@@ -315,59 +315,59 @@ suggestAdditionalKernelModules() and maybe copyRequiredFilesIntoInitramfs().
sub setupPluginInInitramfs
{
- my $self = shift;
- my $attrs = shift;
- my $makeInitRamFSEngine = shift;
-
- my $pluginName = $self->{name};
- my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins";
- my $buildPath = $makeInitRamFSEngine->{'build-path'};
- my $pluginInitdPath = "$buildPath/etc/plugin-init.d";
- my $initHooksPath = "$buildPath/etc/init-hooks";
-
- # copy runlevel script
- my $precedence
- = sprintf('%02d', $attrs->{"${pluginName}::precedence"});
- my $scriptName = "$pluginSrcPath/$pluginName/XX_${pluginName}.sh";
- my $targetName = "$pluginInitdPath/${precedence}_${pluginName}.sh";
- if (-e $scriptName) {
- $makeInitRamFSEngine->addCMD("cp $scriptName $targetName");
- $makeInitRamFSEngine->addCMD("chmod a+x $targetName");
- }
-
- # copy init hook scripts, if any
- if (-d "$pluginSrcPath/$pluginName/init-hooks") {
- my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks";
- $makeInitRamFSEngine->addCMD(
- "cp -r $hookSrcPath/* $buildPath/etc/init-hooks/"
- );
- }
-
- # invoke hook methods to suggest additional kernel params ...
- my @suggestedParams
- = $self->suggestAdditionalKernelParams($makeInitRamFSEngine);
- if (@suggestedParams) {
- my $params = join ' ', @suggestedParams;
- vlog(1, "plugin $pluginName suggests these kernel params: $params");
- $makeInitRamFSEngine->addKernelParams(@suggestedParams);
- }
-
- # ... and kernel modules
- my @suggestedModules
- = $self->suggestAdditionalKernelModules($makeInitRamFSEngine);
- if (@suggestedModules) {
- my $modules = join(',', @suggestedModules);
- vlog(1, "plugin $pluginName suggests these kernel modules: $modules");
- $makeInitRamFSEngine->addKernelModules(@suggestedModules);
- }
-
- # invoke hook method to copy any further files that are required in stage3
- # before the root-fs has been mounted
- $self->copyRequiredFilesIntoInitramfs(
- $buildPath, $attrs, $makeInitRamFSEngine
- );
-
- return 1;
+ my $self = shift;
+ my $attrs = shift;
+ my $makeInitRamFSEngine = shift;
+
+ my $pluginName = $self->{name};
+ my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins";
+ my $buildPath = $makeInitRamFSEngine->{'build-path'};
+ my $pluginInitdPath = "$buildPath/etc/plugin-init.d";
+ my $initHooksPath = "$buildPath/etc/init-hooks";
+
+ # copy runlevel script
+ my $precedence
+ = sprintf('%02d', $attrs->{"${pluginName}::precedence"});
+ my $scriptName = "$pluginSrcPath/$pluginName/XX_${pluginName}.sh";
+ my $targetName = "$pluginInitdPath/${precedence}_${pluginName}.sh";
+ if (-e $scriptName) {
+ $makeInitRamFSEngine->addCMD("cp $scriptName $targetName");
+ $makeInitRamFSEngine->addCMD("chmod a+x $targetName");
+ }
+
+ # copy init hook scripts, if any
+ if (-d "$pluginSrcPath/$pluginName/init-hooks") {
+ my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks";
+ $makeInitRamFSEngine->addCMD(
+ "cp -r $hookSrcPath/* $buildPath/etc/init-hooks/"
+ );
+ }
+
+ # invoke hook methods to suggest additional kernel params ...
+ my @suggestedParams
+ = $self->suggestAdditionalKernelParams($makeInitRamFSEngine);
+ if (@suggestedParams) {
+ my $params = join ' ', @suggestedParams;
+ vlog(1, "plugin $pluginName suggests these kernel params: $params");
+ $makeInitRamFSEngine->addKernelParams(@suggestedParams);
+ }
+
+ # ... and kernel modules
+ my @suggestedModules
+ = $self->suggestAdditionalKernelModules($makeInitRamFSEngine);
+ if (@suggestedModules) {
+ my $modules = join(',', @suggestedModules);
+ vlog(1, "plugin $pluginName suggests these kernel modules: $modules");
+ $makeInitRamFSEngine->addKernelModules(@suggestedModules);
+ }
+
+ # invoke hook method to copy any further files that are required in stage3
+ # before the root-fs has been mounted
+ $self->copyRequiredFilesIntoInitramfs(
+ $buildPath, $attrs, $makeInitRamFSEngine
+ );
+
+ return 1;
}
=back
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm
index 344bfdb9..5469a98d 100644
--- a/os-plugins/OpenSLX/OSPlugin/Engine.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# Engine.pm
-# - provides driver engine for the OSPlugin API.
+# - provides driver engine for the OSPlugin API.
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::Engine;
@@ -49,11 +49,11 @@ Trivial constructor
sub new
{
- my $class = shift;
+ my $class = shift;
- my $self = {};
+ my $self = {};
- return bless $self, $class;
+ return bless $self, $class;
}
=item initialize($pluginName, $vendorOSName )
@@ -65,69 +65,69 @@ loads plugin.
sub initialize
{
- my $self = shift;
- my $pluginName = shift;
- my $vendorOSName = shift;
- my $givenAttrs = shift || {};
-
- $self->{'vendor-os-name'} = $vendorOSName;
-
- $self->{'vendor-os-path'}
- = "$openslxConfig{'private-path'}/stage1/$vendorOSName";
- vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
-
- if ($pluginName) {
- $self->{'plugin-name'} = $pluginName;
- $self->{'plugin-path'}
- = "$openslxConfig{'base-path'}/lib/plugins/$pluginName";
- vlog(1, "plugin path is '$self->{'plugin-path'}'");
-
- # create ossetup-engine for given vendor-OS:
- my $osSetupEngine = OpenSLX::OSSetup::Engine->new;
- $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin');
- $self->{'ossetup-engine'} = $osSetupEngine;
-
- $self->{'plugin'} = $self->_loadPlugin();
- return if !$self->{'plugin'};
-
- $self->{'chrooted-plugin-repo-path'}
- = "$openslxConfig{'base-path'}/plugin-repo/$self->{'plugin-name'}";
- $self->{'plugin-repo-path'}
- = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-repo-path'}";
- $self->{'chrooted-plugin-temp-path'}
- = "/tmp/slx-plugin/$self->{'plugin-name'}";
- $self->{'plugin-temp-path'}
- = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-temp-path'}";
- $self->{'chrooted-openslx-base-path'} = '/mnt/openslx';
-
- # check and store given attribute set
- my $knownAttrs = $self->{plugin}->getAttrInfo();
- my @unknownAttrs
- = grep { !exists $knownAttrs->{$_} } keys %$givenAttrs;
- if (@unknownAttrs) {
- die _tr(
- "The plugin '%s' does not support these attributes:\n\t%s",
- $pluginName, join(',', @unknownAttrs)
- );
- }
-
- # merge attributes that were given on cmdline with the ones that
- # already exist in the DB and finally with the default values
- $self->{'plugin-attrs'} = { %$givenAttrs };
- my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS(
- $vendorOSName
- );
- my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName);
- for my $attrName (keys %$defaultAttrs) {
- next if exists $givenAttrs->{$attrName};
- $self->{'plugin-attrs'}->{$attrName}
- = exists $dbAttrs->{$attrName}
- ? $dbAttrs->{$attrName}
- : $defaultAttrs->{$attrName}->{default};
- }
- }
-
- return 1;
+ my $self = shift;
+ my $pluginName = shift;
+ my $vendorOSName = shift;
+ my $givenAttrs = shift || {};
+
+ $self->{'vendor-os-name'} = $vendorOSName;
+
+ $self->{'vendor-os-path'}
+ = "$openslxConfig{'private-path'}/stage1/$vendorOSName";
+ vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'");
+
+ if ($pluginName) {
+ $self->{'plugin-name'} = $pluginName;
+ $self->{'plugin-path'}
+ = "$openslxConfig{'base-path'}/lib/plugins/$pluginName";
+ vlog(1, "plugin path is '$self->{'plugin-path'}'");
+
+ # create ossetup-engine for given vendor-OS:
+ my $osSetupEngine = OpenSLX::OSSetup::Engine->new;
+ $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin');
+ $self->{'ossetup-engine'} = $osSetupEngine;
+
+ $self->{'plugin'} = $self->_loadPlugin();
+ return if !$self->{'plugin'};
+
+ $self->{'chrooted-plugin-repo-path'}
+ = "$openslxConfig{'base-path'}/plugin-repo/$self->{'plugin-name'}";
+ $self->{'plugin-repo-path'}
+ = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-repo-path'}";
+ $self->{'chrooted-plugin-temp-path'}
+ = "/tmp/slx-plugin/$self->{'plugin-name'}";
+ $self->{'plugin-temp-path'}
+ = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-temp-path'}";
+ $self->{'chrooted-openslx-base-path'} = '/mnt/openslx';
+
+ # check and store given attribute set
+ my $knownAttrs = $self->{plugin}->getAttrInfo();
+ my @unknownAttrs
+ = grep { !exists $knownAttrs->{$_} } keys %$givenAttrs;
+ if (@unknownAttrs) {
+ die _tr(
+ "The plugin '%s' does not support these attributes:\n\t%s",
+ $pluginName, join(',', @unknownAttrs)
+ );
+ }
+
+ # merge attributes that were given on cmdline with the ones that
+ # already exist in the DB and finally with the default values
+ $self->{'plugin-attrs'} = { %$givenAttrs };
+ my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS(
+ $vendorOSName
+ );
+ my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName);
+ for my $attrName (keys %$defaultAttrs) {
+ next if exists $givenAttrs->{$attrName};
+ $self->{'plugin-attrs'}->{$attrName}
+ = exists $dbAttrs->{$attrName}
+ ? $dbAttrs->{$attrName}
+ : $defaultAttrs->{$attrName}->{default};
+ }
+ }
+
+ return 1;
}
=back
@@ -148,51 +148,51 @@ the plugin's installer method while chrooted into that vendor-OS.
sub installPlugin
{
- my $self = shift;
-
- if ($self->{'vendor-os-name'} ne '<<<default>>>') {
-
- # as the attrs may be changed by the plugin during installation, we
- # have to find a way to pass them back to this process (remember;
- # installation takes place in a forked process in order to do a chroot).
- # We simply serialize the attributes into a temp and deserialize it
- # in the calling process.
- my $serializedAttrsFile
- = "$self->{'plugin-temp-path'}/serialized-attrs";
- my $chrootedSerializedAttrsFile
- = "$self->{'chrooted-plugin-temp-path'}/serialized-attrs";
-
- mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]);
-
- # HACK: do a dummy serialization here in order to get Storable
- # completely loaded (otherwise it will complain in the chroot about
- # missing modules).
- store $self->{'plugin-attrs'}, $serializedAttrsFile;
-
- $self->_callChrootedFunctionForPlugin(
- sub {
- # invoke plugin and let it install itself into vendor-OS
- $self->{plugin}->installationPhase(
- $self->{'chrooted-plugin-repo-path'},
- $self->{'chrooted-plugin-temp-path'},
- $self->{'chrooted-openslx-base-path'},
- $self->{'plugin-attrs'},
- );
-
- # serialize possibly changed attributes (executed inside chroot)
- store $self->{'plugin-attrs'}, $chrootedSerializedAttrsFile;
- }
- );
-
- # now retrieve (deserialize) the current attributes and store them
- $self->{'plugin-attrs'} = retrieve $serializedAttrsFile;
- $self->_addInstalledPluginToDB();
-
- # cleanup temp path
- rmtree([ $self->{'plugin-temp-path'} ]);
- }
-
- return 1;
+ my $self = shift;
+
+ if ($self->{'vendor-os-name'} ne '<<<default>>>') {
+
+ # as the attrs may be changed by the plugin during installation, we
+ # have to find a way to pass them back to this process (remember;
+ # installation takes place in a forked process in order to do a chroot).
+ # We simply serialize the attributes into a temp and deserialize it
+ # in the calling process.
+ my $serializedAttrsFile
+ = "$self->{'plugin-temp-path'}/serialized-attrs";
+ my $chrootedSerializedAttrsFile
+ = "$self->{'chrooted-plugin-temp-path'}/serialized-attrs";
+
+ mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]);
+
+ # HACK: do a dummy serialization here in order to get Storable
+ # completely loaded (otherwise it will complain in the chroot about
+ # missing modules).
+ store $self->{'plugin-attrs'}, $serializedAttrsFile;
+
+ $self->_callChrootedFunctionForPlugin(
+ sub {
+ # invoke plugin and let it install itself into vendor-OS
+ $self->{plugin}->installationPhase(
+ $self->{'chrooted-plugin-repo-path'},
+ $self->{'chrooted-plugin-temp-path'},
+ $self->{'chrooted-openslx-base-path'},
+ $self->{'plugin-attrs'},
+ );
+
+ # serialize possibly changed attributes (executed inside chroot)
+ store $self->{'plugin-attrs'}, $chrootedSerializedAttrsFile;
+ }
+ );
+
+ # now retrieve (deserialize) the current attributes and store them
+ $self->{'plugin-attrs'} = retrieve $serializedAttrsFile;
+ $self->_addInstalledPluginToDB();
+
+ # cleanup temp path
+ rmtree([ $self->{'plugin-temp-path'} ]);
+ }
+
+ return 1;
}
=item removePlugin()
@@ -204,28 +204,28 @@ the plugin's removal method while chrooted into that vendor-OS.
sub removePlugin
{
- my $self = shift;
+ my $self = shift;
- if ($self->{'vendor-os-name'} ne '<<<default>>>') {
+ if ($self->{'vendor-os-name'} ne '<<<default>>>') {
- mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]);
+ mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]);
- $self->_callChrootedFunctionForPlugin(
- sub {
- $self->{plugin}->removalPhase(
- $self->{'chrooted-plugin-repo-path'},
- $self->{'chrooted-plugin-temp-path'},
- $self->{'chrooted-openslx-base-path'},
- );
- }
- );
+ $self->_callChrootedFunctionForPlugin(
+ sub {
+ $self->{plugin}->removalPhase(
+ $self->{'chrooted-plugin-repo-path'},
+ $self->{'chrooted-plugin-temp-path'},
+ $self->{'chrooted-openslx-base-path'},
+ );
+ }
+ );
- rmtree([ $self->{'plugin-temp-path'} ]);
- }
-
- $self->_removeInstalledPluginFromDB();
+ rmtree([ $self->{'plugin-temp-path'} ]);
+ }
+
+ $self->_removeInstalledPluginFromDB();
- return 1;
+ return 1;
}
=item getInstalledPlugins()
@@ -237,22 +237,22 @@ vendor-OS.
sub getInstalledPlugins
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
- my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
- name => $self->{'vendor-os-name'},
- } );
- if (!$vendorOS) {
- die _tr(
- 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
- );
- }
- my @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id});
- $openslxDB->disconnect();
-
- return @installedPlugins;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
+ name => $self->{'vendor-os-name'},
+ } );
+ if (!$vendorOS) {
+ die _tr(
+ 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
+ );
+ }
+ my @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id});
+ $openslxDB->disconnect();
+
+ return @installedPlugins;
}
=back
@@ -275,9 +275,9 @@ Returns the name of the current vendor-OS.
sub vendorOSName
{
- my $self = shift;
+ my $self = shift;
- return $self->{'vendor-os-name'};
+ return $self->{'vendor-os-name'};
}
=item distroName()
@@ -291,9 +291,9 @@ distro version, like 'suse-10.2' or 'ubuntu-7.04'.
sub distroName
{
- my $self = shift;
+ my $self = shift;
- return $self->{'ossetup-engine'}->distroName();
+ return $self->{'ossetup-engine'}->distroName();
}
=item downloadFile($fileURL, $targetPath, $wgetOptions)
@@ -325,18 +325,18 @@ If the downloaded was successful this method returns C<1>, otherwise it dies.
sub downloadFile
{
- my $self = shift;
- my $fileURL = shift || return;
- my $targetPath = shift || $self->{'chrooted-plugin-temp-path'};
- my $wgetOptions = shift || '';
-
- my $busybox = $self->{'ossetup-engine'}->busyboxBinary();
-
- if (slxsystem("$busybox wget -P $targetPath $wgetOptions $fileURL")) {
- die _tr('unable to download file "%s"! (%s)', $fileURL, $!);
- }
-
- return 1;
+ my $self = shift;
+ my $fileURL = shift || return;
+ my $targetPath = shift || $self->{'chrooted-plugin-temp-path'};
+ my $wgetOptions = shift || '';
+
+ my $busybox = $self->{'ossetup-engine'}->busyboxBinary();
+
+ if (slxsystem("$busybox wget -P $targetPath $wgetOptions $fileURL")) {
+ die _tr('unable to download file "%s"! (%s)', $fileURL, $!);
+ }
+
+ return 1;
}
=item getInstalledPackages()
@@ -350,12 +350,12 @@ install additional packages.
sub getInstalledPackages
{
- my $self = shift;
+ my $self = shift;
- my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
- return if !$metaPackager;
+ my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
+ return if !$metaPackager;
- return $metaPackager->getInstalledPackages();
+ return $metaPackager->getInstalledPackages();
}
=item getInstallablePackagesForSelection()
@@ -368,12 +368,12 @@ to complete the selection.
sub getInstallablePackagesForSelection
{
- my $self = shift;
- my $selection = shift;
+ my $self = shift;
+ my $selection = shift;
- return $self->{'ossetup-engine'}->getInstallablePackagesForSelection(
- $selection
- );
+ return $self->{'ossetup-engine'}->getInstallablePackagesForSelection(
+ $selection
+ );
}
@@ -401,15 +401,15 @@ otherwise it dies.
sub installPackages
{
- my $self = shift;
- my $packages = shift;
+ my $self = shift;
+ my $packages = shift;
- return if !$packages;
+ return if !$packages;
- my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
- return if !$metaPackager;
+ my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
+ return if !$metaPackager;
- return $metaPackager->installPackages($packages);
+ return $metaPackager->installPackages($packages);
}
=item removePackages($packages)
@@ -433,15 +433,15 @@ otherwise it dies.
sub removePackages
{
- my $self = shift;
- my $packages = shift;
+ my $self = shift;
+ my $packages = shift;
- return if !$packages;
+ return if !$packages;
- my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
- return if !$metaPackager;
+ my $metaPackager = $self->{'ossetup-engine'}->metaPackager();
+ return if !$metaPackager;
- return $metaPackager->removePackages($packages);
+ return $metaPackager->removePackages($packages);
}
=back
@@ -450,148 +450,148 @@ sub removePackages
sub _loadPlugin
{
- my $self = shift;
-
- my $pluginModule = "OpenSLX::OSPlugin::$self->{'plugin-name'}";
- my $plugin = instantiateClass(
- $pluginModule, { pathToClass => $self->{'plugin-path'} }
- );
- return if !$plugin;
-
- # if there's a distro folder, instantiate the most appropriate distro class
- my $distro;
- if (-d "$self->{'plugin-path'}/OpenSLX/Distro") {
- unshift @INC, $self->{'plugin-path'};
- my $distroName = $self->distroName();
- $distroName =~ tr{.-}{__};
- my @distroModules;
- while($distroName =~ m{^(.+)_[^_]*$}) {
- push @distroModules, $distroName;
- $distroName = $1;
- }
- push @distroModules, $distroName;
- push @distroModules, 'Base';
- for my $distroModule (@distroModules) {
- last if eval {
- $distro = instantiateClass(
- 'OpenSLX::Distro::' . $distroModule,
- { pathToClass => $self->{'plugin-path'} }
- );
- 1;
- };
- }
- shift @INC;
- if (!$distro) {
- die _tr(
- 'unable to load any distro module for vendor-OS %s',
- $self->{'vendor-os-name'}
- );
- }
- $distro->initialize($self);
- }
-
- $plugin->initialize($self, $distro);
-
- return $plugin;
+ my $self = shift;
+
+ my $pluginModule = "OpenSLX::OSPlugin::$self->{'plugin-name'}";
+ my $plugin = instantiateClass(
+ $pluginModule, { pathToClass => $self->{'plugin-path'} }
+ );
+ return if !$plugin;
+
+ # if there's a distro folder, instantiate the most appropriate distro class
+ my $distro;
+ if (-d "$self->{'plugin-path'}/OpenSLX/Distro") {
+ unshift @INC, $self->{'plugin-path'};
+ my $distroName = $self->distroName();
+ $distroName =~ tr{.-}{__};
+ my @distroModules;
+ while($distroName =~ m{^(.+)_[^_]*$}) {
+ push @distroModules, $distroName;
+ $distroName = $1;
+ }
+ push @distroModules, $distroName;
+ push @distroModules, 'Base';
+ for my $distroModule (@distroModules) {
+ last if eval {
+ $distro = instantiateClass(
+ 'OpenSLX::Distro::' . $distroModule,
+ { pathToClass => $self->{'plugin-path'} }
+ );
+ 1;
+ };
+ }
+ shift @INC;
+ if (!$distro) {
+ die _tr(
+ 'unable to load any distro module for vendor-OS %s',
+ $self->{'vendor-os-name'}
+ );
+ }
+ $distro->initialize($self);
+ }
+
+ $plugin->initialize($self, $distro);
+
+ return $plugin;
}
sub _callChrootedFunctionForPlugin
{
- my $self = shift;
- my $function = shift;
-
- # bind-mount openslx basepath to /mnt/openslx of vendor-OS:
- my $basePath = $openslxConfig{'base-path'};
- my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx";
- mkpath( [ $openslxPathInChroot ] );
- if (slxsystem("mount -o bind $basePath $openslxPathInChroot")) {
- croak(
- _tr(
- "unable to bind mount '%s' to '%s'! (%s)",
- $basePath, $openslxPathInChroot, $!
- )
- );
- }
-
- # now let plugin install itself into vendor-OS
- my $ok = eval {
- $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function);
- };
-
- if (slxsystem("umount $openslxPathInChroot")) {
- croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!));
- }
-
- if (!$ok) {
- die $@;
- }
-
- return;
+ my $self = shift;
+ my $function = shift;
+
+ # bind-mount openslx basepath to /mnt/openslx of vendor-OS:
+ my $basePath = $openslxConfig{'base-path'};
+ my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx";
+ mkpath( [ $openslxPathInChroot ] );
+ if (slxsystem("mount -o bind $basePath $openslxPathInChroot")) {
+ croak(
+ _tr(
+ "unable to bind mount '%s' to '%s'! (%s)",
+ $basePath, $openslxPathInChroot, $!
+ )
+ );
+ }
+
+ # now let plugin install itself into vendor-OS
+ my $ok = eval {
+ $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function);
+ };
+
+ if (slxsystem("umount $openslxPathInChroot")) {
+ croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!));
+ }
+
+ if (!$ok) {
+ die $@;
+ }
+
+ return;
}
sub _addInstalledPluginToDB
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
- my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
- name => $self->{'vendor-os-name'},
- } );
- if (!$vendorOS) {
- die _tr(
- 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
- );
- }
- $openslxDB->addInstalledPlugin(
- $vendorOS->{id}, $self->{'plugin-name'}, $self->{'plugin-attrs'}
- );
- $openslxDB->disconnect();
-
- return 1;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
+ name => $self->{'vendor-os-name'},
+ } );
+ if (!$vendorOS) {
+ die _tr(
+ 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
+ );
+ }
+ $openslxDB->addInstalledPlugin(
+ $vendorOS->{id}, $self->{'plugin-name'}, $self->{'plugin-attrs'}
+ );
+ $openslxDB->disconnect();
+
+ return 1;
}
sub _fetchInstalledPluginAttrs
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
- my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
- name => $self->{'vendor-os-name'},
- } );
- if (!$vendorOS) {
- die _tr(
- 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
- );
- }
- my $installedPlugin = $openslxDB->fetchInstalledPlugins(
- $vendorOS->{id}, $self->{'plugin-name'}
- );
- $openslxDB->disconnect();
-
- return {} if !$installedPlugin;
- return $installedPlugin->{attrs};
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
+ name => $self->{'vendor-os-name'},
+ } );
+ if (!$vendorOS) {
+ die _tr(
+ 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
+ );
+ }
+ my $installedPlugin = $openslxDB->fetchInstalledPlugins(
+ $vendorOS->{id}, $self->{'plugin-name'}
+ );
+ $openslxDB->disconnect();
+
+ return {} if !$installedPlugin;
+ return $installedPlugin->{attrs};
}
sub _removeInstalledPluginFromDB
{
- my $self = shift;
-
- my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
- $openslxDB->connect();
- my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
- name => $self->{'vendor-os-name'},
- } );
- if (!$vendorOS) {
- die _tr(
- 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
- );
- }
- $openslxDB->removeInstalledPlugin($vendorOS->{id}, $self->{'plugin-name'});
- $openslxDB->disconnect();
-
- return 1;
+ my $self = shift;
+
+ my $openslxDB = instantiateClass("OpenSLX::ConfigDB");
+ $openslxDB->connect();
+ my $vendorOS = $openslxDB->fetchVendorOSByFilter( {
+ name => $self->{'vendor-os-name'},
+ } );
+ if (!$vendorOS) {
+ die _tr(
+ 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
+ );
+ }
+ $openslxDB->removeInstalledPlugin($vendorOS->{id}, $self->{'plugin-name'});
+ $openslxDB->disconnect();
+
+ return 1;
}
1;
diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm
index a8df3b38..023abb4c 100644
--- a/os-plugins/OpenSLX/OSPlugin/Roster.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# OSPlugin::Roster.pm
-# - provides information about all available plugins
+# - provides information about all available plugins
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::Roster;
@@ -29,15 +29,15 @@ Returns a hash that keys the names of available plugins to their info hash.
sub getAvailablePlugins
{
- my $class = shift;
+ my $class = shift;
- $class->_init() if !%plugins;
+ $class->_init() if !%plugins;
- my %pluginInfo;
- foreach my $pluginName (keys %plugins) {
- $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo();
- }
- return \%pluginInfo;
+ my %pluginInfo;
+ foreach my $pluginName (keys %plugins) {
+ $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo();
+ }
+ return \%pluginInfo;
}
=item C<getPlugin()>
@@ -48,15 +48,15 @@ Returns an instance of the plugin with the given name
sub getPlugin
{
- my $class = shift;
- my $pluginName = shift;
+ my $class = shift;
+ my $pluginName = shift;
- $class->_init() if !%plugins;
+ $class->_init() if !%plugins;
- my $plugin = $plugins{$pluginName};
- return if !$plugin;
+ my $plugin = $plugins{$pluginName};
+ return if !$plugin;
- return dclone($plugin);
+ return dclone($plugin);
}
=item C<getPluginAttrInfo()>
@@ -68,14 +68,14 @@ given plugin
sub getPluginAttrInfo
{
- my $class = shift;
- my $pluginName = shift;
+ my $class = shift;
+ my $pluginName = shift;
- $class->_init() if !%plugins;
+ $class->_init() if !%plugins;
- return if !$plugins{$pluginName};
+ return if !$plugins{$pluginName};
- return $plugins{$pluginName}->getAttrInfo();
+ return $plugins{$pluginName}->getAttrInfo();
}
=item C<addAllAttributesToHash()>
@@ -98,11 +98,11 @@ added.
sub addAllAttributesToHash
{
- my $class = shift;
- my $attrInfo = shift;
- my $pluginName = shift;
+ my $class = shift;
+ my $attrInfo = shift;
+ my $pluginName = shift;
- return $class->_addAttributesToHash($attrInfo, $pluginName, sub { 1 } );
+ return $class->_addAttributesToHash($attrInfo, $pluginName, sub { 1 } );
}
=item C<addAllStage1AttributesToHash()>
@@ -125,14 +125,14 @@ added.
sub addAllStage1AttributesToHash
{
- my $class = shift;
- my $attrInfo = shift;
- my $pluginName = shift;
-
- return $class->_addAttributesToHash($attrInfo, $pluginName, sub {
- my $attr = shift;
- return $attr->{applies_to_vendor_os};
- } );
+ my $class = shift;
+ my $attrInfo = shift;
+ my $pluginName = shift;
+
+ return $class->_addAttributesToHash($attrInfo, $pluginName, sub {
+ my $attr = shift;
+ return $attr->{applies_to_vendor_os};
+ } );
}
=item C<addAllStage3AttributesToHash()>
@@ -155,59 +155,59 @@ added.
sub addAllStage3AttributesToHash
{
- my $class = shift;
- my $attrInfo = shift;
- my $pluginName = shift;
-
- return $class->_addAttributesToHash($attrInfo, $pluginName, sub {
- my $attr = shift;
- return $attr->{applies_to_systems} || $attr->{applies_to_clients};
- } );
+ my $class = shift;
+ my $attrInfo = shift;
+ my $pluginName = shift;
+
+ return $class->_addAttributesToHash($attrInfo, $pluginName, sub {
+ my $attr = shift;
+ return $attr->{applies_to_systems} || $attr->{applies_to_clients};
+ } );
}
sub _addAttributesToHash
{
- my $class = shift;
- my $attrInfo = shift;
- my $pluginName = shift;
- my $testFunc = shift;
-
- $class->_init() if !%plugins;
-
- foreach my $plugin (values %plugins) {
- next if $pluginName && $plugin->{name} ne $pluginName;
- my $pluginAttrInfo = $plugin->getAttrInfo();
- foreach my $attr (keys %$pluginAttrInfo) {
- next if !$testFunc->($pluginAttrInfo->{$attr});
- $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr});
- }
- }
- return 1;
+ my $class = shift;
+ my $attrInfo = shift;
+ my $pluginName = shift;
+ my $testFunc = shift;
+
+ $class->_init() if !%plugins;
+
+ foreach my $plugin (values %plugins) {
+ next if $pluginName && $plugin->{name} ne $pluginName;
+ my $pluginAttrInfo = $plugin->getAttrInfo();
+ foreach my $attr (keys %$pluginAttrInfo) {
+ next if !$testFunc->($pluginAttrInfo->{$attr});
+ $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr});
+ }
+ }
+ return 1;
}
sub _init
{
- my $class = shift;
-
- %plugins = ();
- my $pluginPath = "$openslxConfig{'base-path'}/lib/plugins";
- foreach my $modulePath (glob("$pluginPath/*")) {
- next if $modulePath !~ m{/([^/]+)$};
- my $pluginName = $1;
- if (!-e "$modulePath/OpenSLX/OSPlugin/$pluginName.pm") {
- vlog(
- 1,
- "skipped plugin-folder $modulePath as no corresponding perl "
- . "module could be found."
- );
- next;
- }
- my $class = "OpenSLX::OSPlugin::$pluginName";
- vlog(2, "loading plugin $class from path '$modulePath'");
- my $plugin = instantiateClass($class, { pathToClass => $modulePath });
- $plugins{$pluginName} = $plugin;
- }
- return;
+ my $class = shift;
+
+ %plugins = ();
+ my $pluginPath = "$openslxConfig{'base-path'}/lib/plugins";
+ foreach my $modulePath (glob("$pluginPath/*")) {
+ next if $modulePath !~ m{/([^/]+)$};
+ my $pluginName = $1;
+ if (!-e "$modulePath/OpenSLX/OSPlugin/$pluginName.pm") {
+ vlog(
+ 1,
+ "skipped plugin-folder $modulePath as no corresponding perl "
+ . "module could be found."
+ );
+ next;
+ }
+ my $class = "OpenSLX::OSPlugin::$pluginName";
+ vlog(2, "loading plugin $class from path '$modulePath'");
+ my $plugin = instantiateClass($class, { pathToClass => $modulePath });
+ $plugins{$pluginName} = $plugin;
+ }
+ return;
}
1;