diff options
author | Oliver Tappe | 2008-03-14 23:49:57 +0100 |
---|---|---|
committer | Oliver Tappe | 2008-03-14 23:49:57 +0100 |
commit | 431e6e2f2811dc277feaca90f52466d623a74b0b (patch) | |
tree | 07b07b4d6970e49762f1eb76935c820d60552da1 /os-plugins/OpenSLX/OSPlugin | |
parent | * Adding temporary plugin which install vmplayer in stage1 (diff) | |
download | core-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')
-rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Engine.pm | 50 | ||||
-rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Roster.pm | 8 |
2 files changed, 53 insertions, 5 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; diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm index 8bc2c305..bacbd183 100644 --- a/os-plugins/OpenSLX/OSPlugin/Roster.pm +++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm @@ -78,10 +78,10 @@ sub getPluginAttrInfo return $plugins{$pluginName}->getAttrInfo(); } -=item C<addAllDefaultAttributesToHash()> +=item C<addAllStage3AttributesToHash()> -Fetches attribute info from all available plugins and adds it to the given -hash-ref. +Fetches attribute info relevant for stage3 (i.e. system- or client-attributes) +from all available plugins and adds it to the given hash-ref. =over @@ -93,7 +93,7 @@ hash-ref. =cut -sub addAllDefaultAttributesToHash +sub addAllStage3AttributesToHash { my $class = shift; my $attrInfo = shift; |