summaryrefslogtreecommitdiffstats
path: root/os-plugins
diff options
context:
space:
mode:
authorOliver Tappe2008-03-19 01:03:17 +0100
committerOliver Tappe2008-03-19 01:03:17 +0100
commitbc8dfbba0983cb320bfaa5c1b294bb6923ac48c0 (patch)
treeead998d1c1e69537ea43ea114cdc2560c5e400fa /os-plugins
parent* fixed incorrect behaviour with respect to merging of plugin attributes: (diff)
downloadcore-bc8dfbba0983cb320bfaa5c1b294bb6923ac48c0.tar.gz
core-bc8dfbba0983cb320bfaa5c1b294bb6923ac48c0.tar.xz
core-bc8dfbba0983cb320bfaa5c1b294bb6923ac48c0.zip
* added separate class methods for adding stage1-, stage3- or all attributes to
a given hash and simplified the implementation git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1654 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Roster.pm84
1 files changed, 79 insertions, 5 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm
index 991bb64d..a8df3b38 100644
--- a/os-plugins/OpenSLX/OSPlugin/Roster.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm
@@ -78,11 +78,71 @@ sub getPluginAttrInfo
return $plugins{$pluginName}->getAttrInfo();
}
+=item C<addAllAttributesToHash()>
+
+Fetches attribute info from all available plugins and adds it to the given
+hash-ref.
+
+If a plugin name has been given, only the attributes of that plugin will be
+added.
+
+=over
+
+=item Return Value
+
+1
+
+=back
+
+=cut
+
+sub addAllAttributesToHash
+{
+ my $class = shift;
+ my $attrInfo = shift;
+ my $pluginName = shift;
+
+ return $class->_addAttributesToHash($attrInfo, $pluginName, sub { 1 } );
+}
+
+=item C<addAllStage1AttributesToHash()>
+
+Fetches attribute info relevant for stage1 (i.e. vendor-OS-attributes)
+from all available plugins and adds it to the given hash-ref.
+
+If a plugin name has been given, only the attributes of that plugin will be
+added.
+
+=over
+
+=item Return Value
+
+1
+
+=back
+
+=cut
+
+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};
+ } );
+}
+
=item C<addAllStage3AttributesToHash()>
Fetches attribute info relevant for stage3 (i.e. system- or client-attributes)
from all available plugins and adds it to the given hash-ref.
+If a plugin name has been given, only the attributes of that plugin will be
+added.
+
=over
=item Return Value
@@ -95,17 +155,31 @@ from all available plugins and adds it to the given hash-ref.
sub addAllStage3AttributesToHash
{
- my $class = shift;
- my $attrInfo = shift;
+ 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 !$pluginAttrInfo->{$attr}->{applies_to_systems}
- && !$pluginAttrInfo->{$attr}->{applies_to_clients};
- $attrInfo->{$attr} = $pluginAttrInfo->{$attr};
+ next if !$testFunc->($pluginAttrInfo->{$attr});
+ $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr});
}
}
return 1;