diff options
author | Oliver Tappe | 2008-07-23 20:27:33 +0200 |
---|---|---|
committer | Oliver Tappe | 2008-07-23 20:27:33 +0200 |
commit | c13e5631307f48236be9155aea76fc9951741020 (patch) | |
tree | 8b864474bc810a039df5bfec4cb4f67b6ac18c84 /os-plugins/OpenSLX/OSPlugin/Engine.pm | |
parent | vmchooser changes: (diff) | |
download | core-c13e5631307f48236be9155aea76fc9951741020.tar.gz core-c13e5631307f48236be9155aea76fc9951741020.tar.xz core-c13e5631307f48236be9155aea76fc9951741020.zip |
implemented plugin dependency handling:
* installing a plugin into a vendor-OS is now only possible when required
plugins are already installed
* removing a plugin from a vendor-OS is now only possible when now plugins
that depend on this one are still installed
* the config-demuxer will check the plugin depedency hierarchy and bail if
any plugin is missing
* when several plugins are being auto-installed (e.g. when copying all
plugins from the '<<<default>>>' vendor-OS) the order of the plugins is
adjusted to comply with the dependency hierarchy
* declared one single dependency: vmchooser depends on vmware (please shout
if that is incorrect)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1936 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/OpenSLX/OSPlugin/Engine.pm')
-rw-r--r-- | os-plugins/OpenSLX/OSPlugin/Engine.pm | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index 3f73a97a..ae76c9e0 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -23,6 +23,7 @@ use File::Path; use Storable; use OpenSLX::Basics; +use OpenSLX::OSPlugin::Roster; use OpenSLX::OSSetup::Engine; use OpenSLX::ScopedResource; use OpenSLX::Utils; @@ -146,6 +147,8 @@ Invokes the plugin's installer method while chrooted into that vendor-OS. sub installPlugin { my $self = shift; + + $self->_checkIfRequiredPluginsAreInstalled(); if ($self->{'vendor-os-name'} ne '<<<default>>>') { @@ -209,6 +212,8 @@ sub removePlugin { my $self = shift; + $self->_checkIfPluginIsRequiredByOthers(); + if ($self->{'vendor-os-name'} ne '<<<default>>>') { mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); @@ -638,6 +643,83 @@ sub _addInstalledPluginToDB return 1; } +sub _checkIfRequiredPluginsAreInstalled +{ + my $self = shift; + + my $requiredPlugins = $self->{plugin}->getInfo()->{required} || []; + return 1 if !@$requiredPlugins; + + 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 @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id}); + $openslxDB->disconnect(); + + my @missingPlugins + = grep { + my $required = $_; + ! grep { $_->{plugin_name} eq $required } @installedPlugins; + } + @$requiredPlugins; + + if (@missingPlugins) { + die _tr( + 'the plugin "%s" requires the following plugins to be installed first: "%s"!', + $self->{'plugin-name'}, join(',', @missingPlugins) + ); + } + + return 1; +} + +sub _checkIfPluginIsRequiredByOthers +{ + 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 @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id}); + $openslxDB->disconnect(); + + my @lockingPlugins + = grep { + my $installed + = OpenSLX::OSPlugin::Roster->getPlugin($_->{plugin_name}); + my $requiredByInstalled + = $installed + ? ($installed->getInfo()->{required} || []) + : []; + grep { $_ eq $self->{'plugin-name'} } @$requiredByInstalled; + } + @installedPlugins; + + if (@lockingPlugins) { + die _tr( + 'the plugin "%s" is required by the following plugins: "%s"!', + $self->{'plugin-name'}, + join(',', map { $_->{plugin_name} } @lockingPlugins) + ); + } + + return 1; +} + sub _fetchInstalledPluginAttrs { my $self = shift; |