summaryrefslogtreecommitdiffstats
path: root/os-plugins/OpenSLX/OSPlugin/Engine.pm
diff options
context:
space:
mode:
authorOliver Tappe2008-03-14 23:49:57 +0100
committerOliver Tappe2008-03-14 23:49:57 +0100
commit431e6e2f2811dc277feaca90f52466d623a74b0b (patch)
tree07b07b4d6970e49762f1eb76935c820d60552da1 /os-plugins/OpenSLX/OSPlugin/Engine.pm
parent* Adding temporary plugin which install vmplayer in stage1 (diff)
downloadcore-431e6e2f2811dc277feaca90f52466d623a74b0b.tar.gz
core-431e6e2f2811dc277feaca90f52466d623a74b0b.tar.xz
core-431e6e2f2811dc277feaca90f52466d623a74b0b.zip
* added support for stage1 attributes that are stored along each plugin installed
into a vendor-OS. * an update of the slxos-plugin documentation is still missing (coming soon ;-) git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1633 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin/Engine.pm')
-rw-r--r--os-plugins/OpenSLX/OSPlugin/Engine.pm50
1 files changed, 49 insertions, 1 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm
index 23d3d953..d42141a7 100644
--- a/os-plugins/OpenSLX/OSPlugin/Engine.pm
+++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm
@@ -67,6 +67,7 @@ sub initialize
my $self = shift;
my $pluginName = shift;
my $vendorOSName = shift;
+ my $givenAttrs = shift || {};
$self->{'vendor-os-name'} = $vendorOSName;
@@ -92,6 +93,27 @@ sub initialize
$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)
+ );
+ }
+ $self->{'plugin-attrs'} = $givenAttrs;
+ my $defaultAttrs = $self->{plugin}->getAttrInfo();
+ 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;
@@ -124,6 +146,7 @@ sub installPlugin
$self->{'chrooted-plugin-repo-path'},
$self->{'chrooted-plugin-temp-path'},
$self->{'chrooted-openslx-base-path'},
+ $self->{'plugin-attrs'},
);
}
);
@@ -426,12 +449,37 @@ sub _addInstalledPluginToDB
'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'}
);
}
- $openslxDB->addInstalledPlugin($vendorOS->{id}, $self->{'plugin-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};
+}
+
sub _removeInstalledPluginFromDB
{
my $self = shift;