summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2008-03-14 23:49:57 +0100
committerOliver Tappe2008-03-14 23:49:57 +0100
commit431e6e2f2811dc277feaca90f52466d623a74b0b (patch)
tree07b07b4d6970e49762f1eb76935c820d60552da1 /config-db
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 'config-db')
-rw-r--r--config-db/OpenSLX/AttributeRoster.pm2
-rw-r--r--config-db/OpenSLX/ConfigDB.pm14
-rw-r--r--config-db/OpenSLX/DBSchema.pm31
-rw-r--r--config-db/OpenSLX/MetaDB/DBI.pm74
4 files changed, 101 insertions, 20 deletions
diff --git a/config-db/OpenSLX/AttributeRoster.pm b/config-db/OpenSLX/AttributeRoster.pm
index b3366c01..5549af3f 100644
--- a/config-db/OpenSLX/AttributeRoster.pm
+++ b/config-db/OpenSLX/AttributeRoster.pm
@@ -369,7 +369,7 @@ sub _init
);
# and add all plugin attributes, too
- OpenSLX::OSPlugin::Roster->addAllDefaultAttributesToHash(\%AttributeInfo);
+ OpenSLX::OSPlugin::Roster->addAllStage3AttributesToHash(\%AttributeInfo);
}
=item C<getAttrInfo()>
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm
index 9d876880..4b13c3f5 100644
--- a/config-db/OpenSLX/ConfigDB.pm
+++ b/config-db/OpenSLX/ConfigDB.pm
@@ -385,9 +385,6 @@ sub fetchInstalledPlugins
my $vendorOSID = shift;
my $pluginName = shift;
- return map {
- $_->{plugin_name}
- }
$self->{'meta-db'}->fetchInstalledPlugins($vendorOSID, $pluginName);
}
@@ -1096,14 +1093,17 @@ The ID of the new reference entry, C<undef> if the creation failed.
sub addInstalledPlugin
{
- my $self = shift;
- my $vendorOSID = shift;
- my $pluginName = shift;
+ my $self = shift;
+ my $vendorOSID = shift;
+ my $pluginName = shift;
+ my $pluginAttrs = 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);
+ return $self->{'meta-db'}->addInstalledPlugin(
+ $vendorOSID, $pluginName, $pluginAttrs
+ );
}
=item C<removeInstalledPlugin($vendorOSID, $pluginName)>
diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm
index 63774dfb..2be6dc7c 100644
--- a/config-db/OpenSLX/DBSchema.pm
+++ b/config-db/OpenSLX/DBSchema.pm
@@ -35,7 +35,7 @@ use OpenSLX::Basics;
### fk => foreign key (integer)
################################################################################
-my $VERSION = 0.28;
+my $VERSION = 0.29;
my $DbSchema = {
'version' => $VERSION,
@@ -162,6 +162,15 @@ my $DbSchema = {
# corresponding stage1, too.
],
},
+ 'installed_plugin_attr' => {
+ # (stage1-)attributes of installed plugins
+ 'cols' => [
+ 'id:pk', # primary key
+ 'installed_plugin_id:fk', # foreign key to installed plugin
+ 'name:s.128', # attribute name
+ 'value:s.255', # attribute value
+ ],
+ },
'meta' => {
# information about the database as such
'cols' => [
@@ -567,7 +576,7 @@ sub _schemaUpgradeDBFrom
0.21 => sub {
my $metaDB = shift;
- # add new table installed_plugins
+ # add new table installed_plugin
$metaDB->schemaAddTable(
'installed_plugin',
[
@@ -590,7 +599,7 @@ sub _schemaUpgradeDBFrom
0.23 => sub {
my $metaDB = shift;
- # add new column system.descripion
+ # add new column system.description
$metaDB->schemaAddColumns(
'system',
[
@@ -695,6 +704,22 @@ sub _schemaUpgradeDBFrom
return 1;
},
+ 0.29 => sub {
+ my $metaDB = shift;
+
+ # add new table installed_plugin_attrs
+ $metaDB->schemaAddTable(
+ 'installed_plugin_attr',
+ [
+ 'id:pk',
+ 'installed_plugin_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ],
+ );
+
+ return 1;
+ },
);
1;
diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm
index 746c407e..50c1465d 100644
--- a/config-db/OpenSLX/MetaDB/DBI.pm
+++ b/config-db/OpenSLX/MetaDB/DBI.pm
@@ -206,6 +206,7 @@ sub fetchInstalledPlugins
my $self = shift;
my $vendorOSID = shift;
my $pluginName = shift;
+ my $fullInfo = shift || 0;
return if !defined $vendorOSID;
my $nameClause
@@ -217,7 +218,26 @@ sub fetchInstalledPlugins
WHERE vendor_os_id = '$vendorOSID'
$nameClause
End-of-Here
- return $self->_doSelect($sql);
+ my @pluginInfos = $self->_doSelect($sql);
+ return if !@pluginInfos;
+
+ @pluginInfos = map {
+ my $pluginInfo = $_;
+ my $sql = unshiftHereDoc(<<" End-of-Here");
+ SELECT * FROM installed_plugin_attr
+ WHERE installed_plugin_id = '$pluginInfo->{id}'
+ End-of-Here
+ my @attrs = $self->_doSelect($sql);
+ $pluginInfo->{attrs} = {
+ map {
+ ( $_->{name}, $fullInfo ? $_ : $_->{value} )
+ } @attrs
+ };
+ $pluginInfo;
+ }
+ @pluginInfos;
+
+ return wantarray() ? @pluginInfos : $pluginInfos[0];
}
sub fetchExportByFilter
@@ -703,17 +723,50 @@ sub changeVendorOS
sub addInstalledPlugin
{
- my $self = shift;
- my $vendorOSID = shift;
- my $pluginName = shift;
+ my $self = shift;
+ my $vendorOSID = shift;
+ my $pluginName = shift;
+ my $pluginAttrs = shift;
return if !defined $vendorOSID || !$pluginName;
- return if $self->fetchInstalledPlugins($vendorOSID, $pluginName);
- return $self->_doInsert('installed_plugin', [ {
- vendor_os_id => $vendorOSID,
- plugin_name => $pluginName,
- } ] );
+ my $installedPlugin
+ = $self->fetchInstalledPlugins($vendorOSID, $pluginName, 1);
+ if (!$installedPlugin) {
+ return if !$self->_doInsert('installed_plugin', [ {
+ vendor_os_id => $vendorOSID,
+ plugin_name => $pluginName,
+ } ] );
+ $installedPlugin
+ = $self->fetchInstalledPlugins($vendorOSID, $pluginName, 1);
+ }
+ return if !$installedPlugin;
+ for my $pluginAttrName (keys %$pluginAttrs) {
+ if (exists $installedPlugin->{attrs}->{$pluginAttrName}) {
+ my $attrInfo = $installedPlugin->{attrs}->{$pluginAttrName};
+ my $currVal
+ = defined $attrInfo->{value} ? $attrInfo->{value} : '-';
+ my $givenVal
+ = defined $pluginAttrs->{$pluginAttrName}
+ ? $pluginAttrs->{$pluginAttrName}
+ : '-';
+print "$pluginAttrName: $currVal <=> $givenVal\n";
+ next if $currVal eq $givenVal;
+ return if ! $self->_doUpdate(
+ 'installed_plugin_attr', [ $attrInfo->{id} ], [ {
+ value => $pluginAttrs->{$pluginAttrName},
+ } ]
+ );
+ }
+ else {
+ return if ! $self->_doInsert('installed_plugin_attr', [ {
+ installed_plugin_id => $installedPlugin->{id},
+ name => $pluginAttrName,
+ value => $pluginAttrs->{$pluginAttrName},
+ } ] );
+ }
+ }
+ return 1;
}
sub removeInstalledPlugin
@@ -726,6 +779,9 @@ sub removeInstalledPlugin
my $plugin = $self->fetchInstalledPlugins($vendorOSID, $pluginName);
return if !$plugin;
+ return if !$self->_doDelete(
+ 'installed_plugin_attr', [ $plugin->{id} ], 'installed_plugin_id'
+ );
return $self->_doDelete('installed_plugin', [ $plugin->{id} ] );
}