summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX
diff options
context:
space:
mode:
Diffstat (limited to 'os-plugins/OpenSLX')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Engine.pm10
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Roster.pm63
2 files changed, 58 insertions, 15 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm
index bdf259f4..fe2bf1ac 100644
--- a/os-plugins/OpenSLX/OSPlugin/Engine.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm
@@ -36,16 +36,6 @@ sub new
return bless $self, $class;
}
-sub getAvailablePlugins
-{ # Class-method!
- my $class = shift;
-
- return
- map { basename($_); }
- sort
- glob("$openslxConfig{'base-path'}/lib/plugins/*");
-}
-
sub initialize
{
my $self = shift;
diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm
index 776907e4..832b0bb3 100644
--- a/os-plugins/OpenSLX/OSPlugin/Roster.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm
@@ -18,6 +18,46 @@ use warnings;
use OpenSLX::Basics;
+my %plugins;
+
+=item C<getAvailablePlugins()>
+
+Returns a hash that keys the names of available plugins to their info hash.
+
+=cut
+
+sub getAvailablePlugins
+{
+ my $class = shift;
+
+ $class->_init() if !%plugins;
+
+ my %pluginInfo;
+ foreach my $pluginName (keys %plugins) {
+ $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo();
+ }
+ return \%pluginInfo;
+}
+
+=item C<getPluginAttrInfo()>
+
+Returns a hash that contains info about the attributes support by the
+given plugin
+
+=cut
+
+sub getPluginAttrInfo
+{
+ my $class = shift;
+ my $pluginName = shift;
+
+ $class->_init() if !%plugins;
+
+ return if !$plugins{$pluginName};
+
+ return $plugins{$pluginName}->getAttrInfo();
+}
+
=item C<addAllDefaultAttributesToHash()>
Fetches attribute info from all available plugins and adds it to the given
@@ -38,6 +78,22 @@ sub addAllDefaultAttributesToHash
my $class = shift;
my $attrInfo = shift;
+ $class->_init() if !%plugins;
+
+ foreach my $plugin (values %plugins) {
+ my $pluginAttrInfo = $plugin->getAttrInfo();
+ foreach my $attr (keys %$pluginAttrInfo) {
+ $attrInfo->{$attr} = $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{/([^/]+)$};
@@ -45,12 +101,9 @@ sub addAllDefaultAttributesToHash
my $class = "OpenSLX::OSPlugin::$pluginName";
vlog(2, "loading plugin $class from path '$modulePath'");
my $plugin = instantiateClass($class, { pathToClass => $modulePath });
- my $pluginAttrInfo = $plugin->getAttrInfo();
- foreach my $attr (keys %$pluginAttrInfo) {
- $attrInfo->{$attr} = $pluginAttrInfo->{$attr};
- }
+ $plugins{$pluginName} = $plugin;
}
- return 1;
+ return;
}
1;