diff options
author | Oliver Tappe | 2008-01-09 13:23:47 +0100 |
---|---|---|
committer | Oliver Tappe | 2008-01-09 13:23:47 +0100 |
commit | fe18e621405083a4f1bbb52e86181f057f1293e3 (patch) | |
tree | 652c652a5bc10415f42559c3f7644a7e85689a65 | |
parent | * implemented automatic synchronization of new/changed attributes (either (diff) | |
download | core-fe18e621405083a4f1bbb52e86181f057f1293e3.tar.gz core-fe18e621405083a4f1bbb52e86181f057f1293e3.tar.xz core-fe18e621405083a4f1bbb52e86181f057f1293e3.zip |
* several fixes related to the handling of plugin-specific attributes
by the config-demuxer
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1452 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r-- | config-db/OpenSLX/ConfigDB.pm | 32 | ||||
-rwxr-xr-x | config-db/slxconfig-demuxer | 53 | ||||
-rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Base.pm | 4 | ||||
-rw-r--r-- | os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm | 10 | ||||
-rw-r--r-- | os-plugins/plugins/VMware/OpenSLX/OSPlugin/VMware.pm | 7 |
5 files changed, 37 insertions, 69 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm index 025af2f6..329473ce 100644 --- a/config-db/OpenSLX/ConfigDB.pm +++ b/config-db/OpenSLX/ConfigDB.pm @@ -85,7 +85,7 @@ to filtering (with boolean operators and hierarchical expressions)]. my @supportExports = qw( mergeAttributes pushAttributes externalIDForSystem externalIDForClient externalConfigNameForClient - externalAttrName generatePlaceholderFor + generatePlaceholderFor ); @EXPORT_OK = (@supportExports); @@ -2836,36 +2836,6 @@ sub externalConfigNameForClient return $name; } -=item C<externalAttrName($attr)> - -Returns the given attribute as it is referenced externally - without the -'attr'_-prefix. - -=over - -=item Param C<attr> - -The attribute you are interested in. - -=item Return Value - -The external name of the given attribute. - -=back - -=cut - -sub externalAttrName -{ - my $attr = shift; - - if ($attr =~ m[^attr_]) { - return substr($attr, 5); - } - - return $attr; -} - =item C<generatePlaceholdersFor($varName)> Returns the given variable as a placeholder - surrounded by '@@@' markers. diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer index 5019cab9..9cdc4c51 100755 --- a/config-db/slxconfig-demuxer +++ b/config-db/slxconfig-demuxer @@ -245,12 +245,13 @@ sub writeAttributesToFile my $content = "# attributes set by slxconfig-demuxer:\n"; my $attrs = $object->{attrs} || {}; - foreach my $attr (sort keys %$attrs) { - my $attrVal = $attrs->{$attr} || ''; - if (length($attrVal) > 0) { - my $externalAttrName = externalAttrName($attr); - $content .= qq[$externalAttrName="$attrVal"\n]; - } + # filter out any plugin-specific attributes (we only want to handle + # the attributes relevant to the core here) + my @attrs = sort grep { index($_, '::') == -1 } keys %$attrs; + foreach my $attr (@attrs) { + my $attrVal = $attrs->{$attr}; + next if !defined $attrVal; + $content .= qq[$attr="$attrVal"\n]; } # Overwrite attribute file even if it exists, to make sure that our users # will never again try to fiddle with machine-setup directly the @@ -560,8 +561,9 @@ sub writeClientConfigurationsForSystem # merge default, system and client configuration files into # the system configuration for the current client: - copyExternalSystemConfig($externalSystemID, $buildPath, - $externalClientName); + copyExternalSystemConfig( + $externalSystemID, $buildPath, $externalClientName + ); writeAttributesToFile($client, $attrFile); @@ -571,8 +573,10 @@ sub writeClientConfigurationsForSystem # be accessed from the client-PC, which doesn't know about the # name it is referred to in the openslx-config-DB: my $externalClientID = externalIDForClient($client); - createTarOfPath($buildPath, "${externalClientID}.tgz", - "$tftpbootPath/client-config/$info->{'external-id'}"); + createTarOfPath( + $buildPath, "${externalClientID}.tgz", + "$tftpbootPath/client-config/$info->{'external-id'}" + ); } } return; @@ -589,25 +593,25 @@ sub writePluginConfigurationsForSystem my $pluginInitdPath = "$buildPath/initramfs/plugin-init.d"; slxsystem("mkdir -p $pluginInitdPath") unless -d $pluginInitdPath; + my $attrs = $info->{attrs} || {}; + foreach my $pluginName (OpenSLX::OSPlugin::Engine->getAvailablePlugins()) { - vlog(2, _tr("writing configuration file for plugin '%s'", $pluginName)); + vlog(2, _tr("checking configuration of plugin '%s'", $pluginName)); - # create plugin engine and fetch specific plugin module config hash: - my $pluginEngine = OpenSLX::OSPlugin::Engine->new(); - $pluginEngine->initialize($pluginName, $info->{'vendor-os'}->{name}); - my $config = $pluginEngine->getPlugin()->getConfig(); - # skip inactive plugins - next unless $config->{active}; + my $pluginScope = lc($pluginName); + next unless $attrs->{"${pluginScope}::active"}; + vlog(2, _tr("writing configuration file for plugin '%s'", $pluginName)); # write plugin configuration to a file: my $content; - foreach my $attr (sort keys %$config) { - my $attrVal = $config->{$attr} || ''; - if (length($attrVal) > 0) { - my $externalAttrName = externalAttrName($attr); - $content .= qq[$externalAttrName="$attrVal"\n]; - } + my @pluginAttrs = grep { $_ =~ m{^${pluginScope}::} } keys %$attrs; + foreach my $attr (sort @pluginAttrs) { + my $attrVal = $attrs->{$attr}; + next if !defined $attrVal; + my $attrName = substr($attr, index($attr, '::')+2); + next if $attrName eq 'active' || $attrName eq 'precedence'; + $content .= qq[$attrName="$attrVal"\n]; } my $fileName = "$pluginConfPath/${pluginName}.conf"; spitFile($fileName, $content); @@ -618,7 +622,8 @@ sub writePluginConfigurationsForSystem } # copy runlevel script to be used in stage3: - my $precedence = sprintf('%02d', $config->{precedence}); + my $precedence + = sprintf('%02d', $attrs->{"${pluginScope}::precedence"}); my $scriptFolder = "$openslxConfig{'base-path'}/lib/plugins/$pluginName"; my $scriptName = "$scriptFolder/XX_${pluginName}.sh"; diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm index 0f2123d7..34b551d9 100644 --- a/os-plugins/OpenSLX/OSPlugin/Base.pm +++ b/os-plugins/OpenSLX/OSPlugin/Base.pm @@ -61,8 +61,8 @@ 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 & client - # by means of slxconfig. + # 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 diff --git a/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm b/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm index ec5dd03d..e872b023 100644 --- a/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm +++ b/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm @@ -53,13 +53,13 @@ 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 & client - # by means of slxconfig. + # system, such that it can be overruled for any specific system by means + # of slxconfig. return { # attribute 'active' is mandatory for all plugins 'example::active' => { applies_to_systems => 1, - applies_to_clients => 1, + applies_to_clients => 0, description => unshiftHereDoc(<<' End-of-Here'), should the 'Example'-plugin be executed during boot? End-of-Here @@ -70,7 +70,7 @@ sub getAttrInfo # attribute 'precedence' is mandatory for all plugins 'example::precedence' => { applies_to_systems => 1, - applies_to_clients => 1, + applies_to_clients => 0, description => unshiftHereDoc(<<' End-of-Here'), the execution precedence of the 'Example' plugin End-of-Here @@ -82,7 +82,7 @@ sub getAttrInfo # plugin specific attributes start here ... 'example::preferred_side' => { applies_to_systems => 1, - applies_to_clients => 1, + applies_to_clients => 0, description => unshiftHereDoc(<<' End-of-Here'), determines to which side you have to tilt your head in order to read the smiley diff --git a/os-plugins/plugins/VMware/OpenSLX/OSPlugin/VMware.pm b/os-plugins/plugins/VMware/OpenSLX/OSPlugin/VMware.pm index 6fddf78c..f764722e 100644 --- a/os-plugins/plugins/VMware/OpenSLX/OSPlugin/VMware.pm +++ b/os-plugins/plugins/VMware/OpenSLX/OSPlugin/VMware.pm @@ -21,13 +21,6 @@ use base qw(OpenSLX::OSPlugin::Base); use OpenSLX::Basics; use OpenSLX::Utils; -################################################################################ -# if you have any questions regarding the concept of OS-plugins and their -# implementation, please drop a mail to: ot@openslx.com, or join the IRC-channel -# '#openslx' (on freenode). -################################################################################ -### interface methods -################################################################################ sub new { my $class = shift; |