diff options
Diffstat (limited to 'config-db')
-rw-r--r-- | config-db/OpenSLX/ConfigDB.pm | 3 | ||||
-rw-r--r-- | config-db/OpenSLX/DBSchema.pm | 6 | ||||
-rwxr-xr-x | config-db/slxconfig | 68 |
3 files changed, 70 insertions, 7 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm index 2acffa91..e8d0f560 100644 --- a/config-db/OpenSLX/ConfigDB.pm +++ b/config-db/OpenSLX/ConfigDB.pm @@ -1091,6 +1091,9 @@ sub addInstalledPlugin my $vendorOSID = shift; my $pluginName = shift; + # make sure the attributes of this plugin are available via default system + $self->{'db-schema'}->synchronizeAttributesWithDefaultSystem($self); + return $self->{'meta-db'}->addInstalledPlugin($vendorOSID, $pluginName); } diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm index e533fe56..195649b9 100644 --- a/config-db/OpenSLX/DBSchema.pm +++ b/config-db/OpenSLX/DBSchema.pm @@ -271,7 +271,7 @@ sub checkAndUpgradeDBSchemaIfNecessary ); } $metaDB->schemaSetDBVersion($DbSchema->{version}); - $self->_synchronizeAttributesWithDefaultSystem($configDB); + $self->synchronizeAttributesWithDefaultSystem($configDB); vlog(1, _tr('DB has been created successfully')); } elsif ($currVersion < $DbSchema->{version}) { vlog( @@ -282,7 +282,7 @@ sub checkAndUpgradeDBSchemaIfNecessary ) ); $self->_schemaUpgradeDBFrom($metaDB, $currVersion); - $self->_synchronizeAttributesWithDefaultSystem($configDB); + $self->synchronizeAttributesWithDefaultSystem($configDB); vlog(1, _tr('upgrade done')); } else { vlog(1, _tr('DB matches current schema version (%s)', $currVersion)); @@ -301,7 +301,7 @@ sub getColumnsOfTable @{$DbSchema->{tables}->{$tableName}->{cols}}; } -sub _synchronizeAttributesWithDefaultSystem +sub synchronizeAttributesWithDefaultSystem { my $self = shift; my $configDB = shift; diff --git a/config-db/slxconfig b/config-db/slxconfig index 11e1d602..e8aaf2ca 100755 --- a/config-db/slxconfig +++ b/config-db/slxconfig @@ -292,7 +292,10 @@ sub dumpElements "\n", map { my $spc = ' ' x $spcLen; - my $val = $elemVal->{$_} || ''; + my $val + = defined $elemVal->{$_} + ? $elemVal->{$_} + : ''; $val =~ s[\n][\n$ind$spc ]g; "$ind$_" . substr($spc, length($_)) . " = $val"; } @@ -300,6 +303,11 @@ sub dumpElements ); $subLines ||= "$ind<none>"; " $_:\n$subLines\n"; + } elsif (ref($elemVal) eq 'ARRAY') { + my $subLines + = join( "\n", map { "$ind$_" } sort @$elemVal); + $subLines ||= "$ind<none>"; + " $_:\n$subLines\n"; } else { my $spc = ' ' x $spcLen; $elemVal =~ s[\n][\n$ind$spc ]g; @@ -473,10 +481,29 @@ sub listSystems map { $_->{name} } sort { $a->{name} cmp $b->{name} } $openslxDB->fetchClientByID(\@clientIDs, 'name'); + my @activePlugins; my $export = $openslxDB->fetchExportByID($_->{export_id}); if (defined $export) { - $_->{export_id} = "$export->{name} ($export->{type})"; + $_->{export_id} + = "$export->{id} ($export->{name})"; + + # fetch detailed info about active plugins + my @installedPlugins = sort $openslxDB->fetchInstalledPlugins( + $export->{vendor_os_id} + ); + my $mergedSystem = dclone($_); + $openslxDB->mergeDefaultAttributesIntoSystem($mergedSystem); + my $mergedAttrs = $mergedSystem->{attrs} || {}; + foreach my $plugin (@installedPlugins) { + my $pluginScope = lc($plugin); + next if !$mergedAttrs->{"${pluginScope}::active"}; + my $precedence = sprintf( + "%02d", $mergedAttrs->{"${pluginScope}::precedence"} + ); + push(@activePlugins, "$precedence...$plugin"); + } } + $_->{PLUGINS} = [ sort @activePlugins ]; # rename attrs to ATTRIBUTES for display $_->{ATTRIBUTES} = $_->{attrs}; delete $_->{attrs}; @@ -502,6 +529,11 @@ sub listVendorOSes } dumpElements('vendor-OS', undef, + map { + my @plugins = sort $openslxDB->fetchInstalledPlugins($_->{id}); + $_->{plugins} = @plugins ? join(',', @plugins) : '<none>'; + $_; + } sort { $a->{name} cmp $b->{name} } $openslxDB->fetchVendorOSByFilter(\%nameSpec)); @@ -623,10 +655,29 @@ sub searchSystems $_->{clients} = join "\n", map { $_->{name} } sort { $a->{name} cmp $b->{name} } $openslxDB->fetchClientByID(\@clientIDs, 'name'); + my @activePlugins; my $export = $openslxDB->fetchExportByID($_->{export_id}); if (defined $export) { - $_->{export_id} = "$export->{name} ($export->{type})"; + $_->{export_id} + = "$export->{id} ($export->{name})"; + + # fetch detailed info about active plugins + my @installedPlugins = sort $openslxDB->fetchInstalledPlugins( + $export->{vendor_os_id} + ); + my $mergedSystem = dclone($_); + $openslxDB->mergeDefaultAttributesIntoSystem($mergedSystem); + my $mergedAttrs = $mergedSystem->{attrs} || {}; + foreach my $plugin (@installedPlugins) { + my $pluginScope = lc($plugin); + next if !$mergedAttrs->{"${pluginScope}::active"}; + my $precedence = sprintf( + "%02d", $mergedAttrs->{"${pluginScope}::precedence"} + ); + push(@activePlugins, "$precedence...$plugin"); + } } + $_->{PLUGINS} = [ sort @activePlugins ]; # rename attrs to ATTRIBUTES for display $_->{ATTRIBUTES} = $_->{attrs}; delete $_->{attrs}; @@ -649,6 +700,11 @@ sub searchVendorOSes dumpElements( 'vendor-OS', undef, + map { + my @plugins = sort $openslxDB->fetchInstalledPlugins($_->{id}); + $_->{plugins} = @plugins ? join(',', @plugins) : '<none>'; + $_; + } sort { $a->{name} cmp $b->{name} } $openslxDB->fetchVendorOSByFilter($vendorOSData) ); @@ -970,6 +1026,8 @@ sub changeClientInConfigDB $clientName); } + mergeNonExistingAttributes($clientData, $client); + my @systemIDs; if (exists $clientData->{systems}) { @systemIDs = map { @@ -1173,6 +1231,8 @@ sub changeSystemInConfigDB $systemName); } + mergeNonExistingAttributes($systemData, $system); + my @clientIDs; if (exists $systemData->{clients}) { @clientIDs = map { @@ -1214,7 +1274,7 @@ sub changeSystemInConfigDB "you can't rename the default system - no changes were made!\n"); } - $openslxDB->changeSystem($system->{id}, [$systemData]); + $openslxDB->changeSystem($system->{id}, $systemData); vlog(0, _tr("system '%s' has been successfully changed\n", $systemName)); if (@clientIDs) { $openslxDB->setClientIDsOfSystem($system->{id}, \@clientIDs); |