summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2007-06-20 20:04:19 +0200
committerOliver Tappe2007-06-20 20:04:19 +0200
commit898eca2232289d3f64431bc3763da4b65bb3ae61 (patch)
tree2a213ff0429b76037a6cc0f2fbf9f99ec025ed2a /config-db
parent* added support for invoking a chrooted shell for any installed vendor-OS, (diff)
downloadcore-898eca2232289d3f64431bc3763da4b65bb3ae61.tar.gz
core-898eca2232289d3f64431bc3763da4b65bb3ae61.tar.xz
core-898eca2232289d3f64431bc3763da4b65bb3ae61.zip
* split export type into filesystem and (optional) blockdevice, closing
ticket#139 * code-reformatting with perltidy git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1176 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/ConfigDB.pm487
-rw-r--r--config-db/OpenSLX/Export/DHCP/ISC.pm2
-rw-r--r--config-db/OpenSLX/MetaDB/Base.pm2
-rw-r--r--config-db/OpenSLX/MetaDB/CSV.pm2
-rw-r--r--config-db/OpenSLX/MetaDB/DBI.pm36
-rw-r--r--config-db/OpenSLX/MetaDB/SQLite.pm10
-rw-r--r--config-db/OpenSLX/MetaDB/mysql.pm22
-rwxr-xr-xconfig-db/slxconfig20
-rwxr-xr-xconfig-db/slxconfig-demuxer34
9 files changed, 306 insertions, 309 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm
index 3926fb9f..f121c9be 100644
--- a/config-db/OpenSLX/ConfigDB.pm
+++ b/config-db/OpenSLX/ConfigDB.pm
@@ -12,7 +12,7 @@ package OpenSLX::ConfigDB;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
-$VERSION = 1; # API-version
+$VERSION = 1; # API-version
################################################################################
### This module defines the data abstraction layer for the OpenSLX configuration
@@ -32,16 +32,14 @@ use Exporter;
@ISA = qw(Exporter);
my @supportExports = qw(
- isAttribute mergeAttributes pushAttributes
- externalIDForSystem externalIDForClient externalConfigNameForClient
- externalAttrName generatePlaceholderFor
+ isAttribute mergeAttributes pushAttributes
+ externalIDForSystem externalIDForClient externalConfigNameForClient
+ externalAttrName generatePlaceholderFor
);
-@EXPORT = ();
-@EXPORT_OK = (@supportExports);
-%EXPORT_TAGS = (
- 'support' => [ @supportExports ],
-);
+@EXPORT = ();
+@EXPORT_OK = (@supportExports);
+%EXPORT_TAGS = ('support' => [@supportExports],);
################################################################################
### private stuff
@@ -54,7 +52,7 @@ sub _checkAndUpgradeDBSchemaIfNecessary
{
my $metaDB = shift;
- vlog 2, "trying to determine schema version...";
+ vlog(2, "trying to determine schema version...");
my $currVersion = $metaDB->schemaFetchDBVersion();
if (!defined $currVersion) {
# that's bad, someone has messed with our DB, as there is a
@@ -65,58 +63,69 @@ sub _checkAndUpgradeDBSchemaIfNecessary
}
if ($currVersion < $DbSchema->{version}) {
- vlog 1, _tr('Our schema-version is %s, DB is %s, upgrading DB...',
- $DbSchema->{version}, $currVersion);
+ vlog(1,
+ _tr('Our schema-version is %s, DB is %s, upgrading DB...',
+ $DbSchema->{version}, $currVersion));
foreach my $v (sort { $a <=> $b } keys %DbSchemaHistory) {
next if $v <= $currVersion;
my $changeSet = $DbSchemaHistory{$v};
- foreach my $c (0..scalar(@$changeSet)-1) {
+ foreach my $c (0 .. scalar(@$changeSet) - 1) {
my $changeDescr = @{$changeSet}[$c];
- my $cmd = $changeDescr->{cmd};
+ my $cmd = $changeDescr->{cmd};
if ($cmd eq 'add-table') {
- $metaDB->schemaAddTable($changeDescr->{'table'},
- $changeDescr->{'cols'},
- $changeDescr->{'vals'});
+ $metaDB->schemaAddTable(
+ $changeDescr->{'table'},
+ $changeDescr->{'cols'},
+ $changeDescr->{'vals'}
+ );
} elsif ($cmd eq 'drop-table') {
$metaDB->schemaDropTable($changeDescr->{'table'});
} elsif ($cmd eq 'rename-table') {
- $metaDB->schemaRenameTable($changeDescr->{'old-table'},
- $changeDescr->{'new-table'},
- $changeDescr->{'cols'});
+ $metaDB->schemaRenameTable(
+ $changeDescr->{'old-table'},
+ $changeDescr->{'new-table'},
+ $changeDescr->{'cols'}
+ );
} elsif ($cmd eq 'add-columns') {
- $metaDB->schemaAddColumns($changeDescr->{'table'},
- $changeDescr->{'new-cols'},
- $changeDescr->{'new-default-vals'},
- $changeDescr->{'cols'});
+ $metaDB->schemaAddColumns(
+ $changeDescr->{'table'},
+ $changeDescr->{'new-cols'},
+ $changeDescr->{'new-default-vals'},
+ $changeDescr->{'cols'}
+ );
} elsif ($cmd eq 'drop-columns') {
- $metaDB->schemaDropColumns($changeDescr->{'table'},
- $changeDescr->{'drop-cols'},
- $changeDescr->{'cols'});
+ $metaDB->schemaDropColumns(
+ $changeDescr->{'table'},
+ $changeDescr->{'drop-cols'},
+ $changeDescr->{'cols'}
+ );
} elsif ($cmd eq 'rename-columns') {
- $metaDB->schemaRenameColumns($changeDescr->{'table'},
- $changeDescr->{'col-renames'},
- $changeDescr->{'cols'});
+ $metaDB->schemaRenameColumns(
+ $changeDescr->{'table'},
+ $changeDescr->{'col-renames'},
+ $changeDescr->{'cols'}
+ );
} else {
confess _tr('UnknownDbSchemaCommand', $cmd);
}
}
}
- vlog 1, _tr('upgrade done');
+ vlog(1, _tr('upgrade done'));
} else {
- vlog 1, _tr('DB matches current schema version %s', $currVersion);
+ vlog(1, _tr('DB matches current schema version %s', $currVersion));
}
}
sub _aref
-{ # transparently converts the given reference to an array-ref
+{ # transparently converts the given reference to an array-ref
my $ref = shift;
return [] unless defined $ref;
- $ref = [ $ref ] unless ref($ref) eq 'ARRAY';
+ $ref = [$ref] unless ref($ref) eq 'ARRAY';
return $ref;
}
sub _unique
-{ # return given array filtered to unique elements
+{ # return given array filtered to unique elements
my %seenIDs;
return grep { !$seenIDs{$_}++; } @_;
}
@@ -127,25 +136,25 @@ sub _unique
sub new
{
my $class = shift;
- my $self = {};
+ my $self = {};
return bless $self, $class;
}
sub connect
{
- my $self = shift;
+ my $self = shift;
my $dbParams = shift;
- # hash-ref with any additional info that might be required by
- # specific metadb-module (not used yet)
+ # hash-ref with any additional info that might be required by
+ # specific metadb-module (not used yet)
my $dbType = $openslxConfig{'db-type'};
- # name of underlying database module...
+ # name of underlying database module...
# map db-type to name of module, such that the user doesn't have
# to type the correct case:
my %dbTypeMap = (
- 'csv' => 'CSV',
- 'mysql' => 'mysql',
+ 'csv' => 'CSV',
+ 'mysql' => 'mysql',
'sqlite' => 'SQLite',
);
my $lcType = lc($dbType);
@@ -156,16 +165,19 @@ sub connect
my $dbModule = "OpenSLX::MetaDB::$dbType";
unless (eval "require $dbModule") {
if ($! == 2) {
- die _tr("Unable to load DB-module <%s>\nthat database type is not supported (yet?)\n",
- $dbModule);
+ die _tr(
+ "Unable to load DB-module <%s>\nthat database type is not supported (yet?)\n",
+ $dbModule
+ );
} else {
die _tr("Unable to load DB-module <%s> (%s)\n", $dbModule, $@);
}
}
my $modVersion = $dbModule->VERSION;
if ($modVersion < $VERSION) {
- confess _tr('Could not load module <%s> (Version <%s> required, but <%s> found)',
- $dbModule, $VERSION, $modVersion);
+ confess _tr(
+ 'Could not load module <%s> (Version <%s> required, but <%s> found)',
+ $dbModule, $VERSION, $modVersion);
}
my $metaDB = $dbModule->new();
if (!eval '$metaDB->connect($dbParams);1') {
@@ -173,10 +185,11 @@ sub connect
warn _tr("These DB-modules seem to work ok:");
foreach my $dbMod ('CSV', 'mysql', 'SQLite') {
if (eval "require DBD::$dbMod;") {
- vlog 0, "\t$dbMod\n";
+ vlog(0, "\t$dbMod\n");
}
}
- die _tr('Please use slxsettings if you want to switch to another db-type.');
+ die _tr(
+ 'Please use slxsettings if you want to switch to another db-type.');
}
$self->{'db-type'} = $dbType;
@@ -218,51 +231,48 @@ sub rollback_transaction
sub fetchVendorOSByFilter
{
- my $self = shift;
- my $filter = shift;
+ my $self = shift;
+ my $filter = shift;
my $resultCols = shift;
- my @vendorOS
- = $self->{'meta-db'}->fetchVendorOSByFilter($filter, $resultCols);
+ my @vendorOS =
+ $self->{'meta-db'}->fetchVendorOSByFilter($filter, $resultCols);
return wantarray() ? @vendorOS : shift @vendorOS;
}
sub fetchVendorOSByID
{
- my $self = shift;
- my $ids = _aref(shift);
+ my $self = shift;
+ my $ids = _aref(shift);
my $resultCols = shift;
- my @vendorOS
- = $self->{'meta-db'}->fetchVendorOSByID($ids, $resultCols);
+ my @vendorOS = $self->{'meta-db'}->fetchVendorOSByID($ids, $resultCols);
return wantarray() ? @vendorOS : shift @vendorOS;
}
sub fetchExportByFilter
{
- my $self = shift;
- my $filter = shift;
+ my $self = shift;
+ my $filter = shift;
my $resultCols = shift;
- my @exports
- = $self->{'meta-db'}->fetchExportByFilter($filter, $resultCols);
+ my @exports = $self->{'meta-db'}->fetchExportByFilter($filter, $resultCols);
return wantarray() ? @exports : shift @exports;
}
sub fetchExportByID
{
- my $self = shift;
- my $ids = _aref(shift);
+ my $self = shift;
+ my $ids = _aref(shift);
my $resultCols = shift;
- my @exports
- = $self->{'meta-db'}->fetchExportByID($ids, $resultCols);
+ my @exports = $self->{'meta-db'}->fetchExportByID($ids, $resultCols);
return wantarray() ? @exports : shift @exports;
}
sub fetchExportIDsOfVendorOS
{
- my $self = shift;
+ my $self = shift;
my $vendorOSID = shift;
return $self->{'meta-db'}->fetchExportIDsOfVendorOS($vendorOSID);
@@ -271,26 +281,25 @@ sub fetchExportIDsOfVendorOS
sub fetchGlobalInfo
{
my $self = shift;
- my $id = shift;
+ my $id = shift;
return $self->{'meta-db'}->fetchGlobalInfo($id);
}
sub fetchSystemByFilter
{
- my $self = shift;
- my $filter = shift;
+ my $self = shift;
+ my $filter = shift;
my $resultCols = shift;
- my @systems
- = $self->{'meta-db'}->fetchSystemByFilter($filter, $resultCols);
+ my @systems = $self->{'meta-db'}->fetchSystemByFilter($filter, $resultCols);
return wantarray() ? @systems : shift @systems;
}
sub fetchSystemByID
{
- my $self = shift;
- my $ids = _aref(shift);
+ my $self = shift;
+ my $ids = _aref(shift);
my $resultCols = shift;
my @systems = $self->{'meta-db'}->fetchSystemByID($ids, $resultCols);
@@ -299,7 +308,7 @@ sub fetchSystemByID
sub fetchSystemIDsOfExport
{
- my $self = shift;
+ my $self = shift;
my $exportID = shift;
return $self->{'meta-db'}->fetchSystemIDsOfExport($exportID);
@@ -307,7 +316,7 @@ sub fetchSystemIDsOfExport
sub fetchSystemIDsOfClient
{
- my $self = shift;
+ my $self = shift;
my $clientID = shift;
return $self->{'meta-db'}->fetchSystemIDsOfClient($clientID);
@@ -315,7 +324,7 @@ sub fetchSystemIDsOfClient
sub fetchSystemIDsOfGroup
{
- my $self = shift;
+ my $self = shift;
my $groupID = shift;
return $self->{'meta-db'}->fetchSystemIDsOfGroup($groupID);
@@ -323,7 +332,7 @@ sub fetchSystemIDsOfGroup
sub fetchClientByFilter
{
- my $self = shift;
+ my $self = shift;
my $filter = shift;
my @clients = $self->{'meta-db'}->fetchClientByFilter($filter);
@@ -332,8 +341,8 @@ sub fetchClientByFilter
sub fetchClientByID
{
- my $self = shift;
- my $ids = _aref(shift);
+ my $self = shift;
+ my $ids = _aref(shift);
my $resultCols = shift;
my @clients = $self->{'meta-db'}->fetchClientByID($ids, $resultCols);
@@ -342,7 +351,7 @@ sub fetchClientByID
sub fetchClientIDsOfSystem
{
- my $self = shift;
+ my $self = shift;
my $systemID = shift;
return $self->{'meta-db'}->fetchClientIDsOfSystem($systemID);
@@ -350,7 +359,7 @@ sub fetchClientIDsOfSystem
sub fetchClientIDsOfGroup
{
- my $self = shift;
+ my $self = shift;
my $groupID = shift;
return $self->{'meta-db'}->fetchClientIDsOfGroup($groupID);
@@ -358,19 +367,18 @@ sub fetchClientIDsOfGroup
sub fetchGroupByFilter
{
- my $self = shift;
- my $filter = shift;
+ my $self = shift;
+ my $filter = shift;
my $resultCols = shift;
- my @groups
- = $self->{'meta-db'}->fetchGroupByFilter($filter, $resultCols);
+ my @groups = $self->{'meta-db'}->fetchGroupByFilter($filter, $resultCols);
return wantarray() ? @groups : shift @groups;
}
sub fetchGroupByID
{
- my $self = shift;
- my $ids = _aref(shift);
+ my $self = shift;
+ my $ids = _aref(shift);
my $resultCols = shift;
my @groups = $self->{'meta-db'}->fetchGroupByID($ids, $resultCols);
@@ -379,7 +387,7 @@ sub fetchGroupByID
sub fetchGroupIDsOfSystem
{
- my $self = shift;
+ my $self = shift;
my $systemID = shift;
return $self->{'meta-db'}->fetchGroupIDsOfSystem($systemID);
@@ -387,7 +395,7 @@ sub fetchGroupIDsOfSystem
sub fetchGroupIDsOfClient
{
- my $self = shift;
+ my $self = shift;
my $clientID = shift;
return $self->{'meta-db'}->fetchGroupIDsOfClient($clientID);
@@ -398,7 +406,7 @@ sub fetchGroupIDsOfClient
################################################################################
sub addVendorOS
{
- my $self = shift;
+ my $self = shift;
my $valRows = _aref(shift);
return $self->{'meta-db'}->addVendorOS($valRows);
@@ -406,7 +414,7 @@ sub addVendorOS
sub removeVendorOS
{
- my $self = shift;
+ my $self = shift;
my $vendorOSIDs = _aref(shift);
return $self->{'meta-db'}->removeVendorOS($vendorOSIDs);
@@ -414,9 +422,9 @@ sub removeVendorOS
sub changeVendorOS
{
- my $self = shift;
+ my $self = shift;
my $vendorOSIDs = _aref(shift);
- my $valRows = _aref(shift);
+ my $valRows = _aref(shift);
return $self->{'meta-db'}->changeVendorOS($vendorOSIDs, $valRows);
}
@@ -424,14 +432,13 @@ sub changeVendorOS
sub incrementExportCounterForVendorOS
{
my $self = shift;
- my $id = shift;
+ my $id = shift;
$self->start_transaction();
- my $vendorOS
- = $self->fetchVendorOSByID($id);
+ my $vendorOS = $self->fetchVendorOSByID($id);
return undef unless defined $vendorOS;
- my $exportCounter = $vendorOS->{export_counter}+1;
- $self->changeVendorOS($id, { 'export_counter' => $exportCounter });
+ my $exportCounter = $vendorOS->{export_counter} + 1;
+ $self->changeVendorOS($id, {'export_counter' => $exportCounter});
$self->commit_transaction();
return $exportCounter;
@@ -439,13 +446,13 @@ sub incrementExportCounterForVendorOS
sub incrementGlobalCounter
{
- my $self = shift;
+ my $self = shift;
my $counterName = shift;
$self->start_transaction();
my $value = $self->fetchGlobalInfo($counterName);
return undef unless defined $value;
- my $newValue = $value+1;
+ my $newValue = $value + 1;
$self->changeGlobalInfo($counterName, $newValue);
$self->commit_transaction();
@@ -454,7 +461,7 @@ sub incrementGlobalCounter
sub addExport
{
- my $self = shift;
+ my $self = shift;
my $valRows = _aref(shift);
return $self->{'meta-db'}->addExport($valRows);
@@ -462,7 +469,7 @@ sub addExport
sub removeExport
{
- my $self = shift;
+ my $self = shift;
my $exportIDs = _aref(shift);
return $self->{'meta-db'}->removeExport($exportIDs);
@@ -470,17 +477,17 @@ sub removeExport
sub changeExport
{
- my $self = shift;
+ my $self = shift;
my $exportIDs = _aref(shift);
- my $valRows = _aref(shift);
+ my $valRows = _aref(shift);
return $self->{'meta-db'}->changeExport($exportIDs, $valRows);
}
sub changeGlobalInfo
{
- my $self = shift;
- my $id = shift;
+ my $self = shift;
+ my $id = shift;
my $value = shift;
return $self->{'meta-db'}->changeGlobalInfo($id, $value);
@@ -488,7 +495,7 @@ sub changeGlobalInfo
sub addSystem
{
- my $self = shift;
+ my $self = shift;
my $valRows = _aref(shift);
foreach my $valRow (@$valRows) {
@@ -505,7 +512,7 @@ sub addSystem
sub removeSystem
{
- my $self = shift;
+ my $self = shift;
my $systemIDs = _aref(shift);
foreach my $system (@$systemIDs) {
@@ -518,28 +525,28 @@ sub removeSystem
sub changeSystem
{
- my $self = shift;
+ my $self = shift;
my $systemIDs = _aref(shift);
- my $valRows = _aref(shift);
+ my $valRows = _aref(shift);
return $self->{'meta-db'}->changeSystem($systemIDs, $valRows);
}
sub setClientIDsOfSystem
{
- my $self = shift;
- my $systemID = shift;
+ my $self = shift;
+ my $systemID = shift;
my $clientIDs = _aref(shift);
my @uniqueClientIDs = _unique(@$clientIDs);
- return $self->{'meta-db'}->setClientIDsOfSystem($systemID,
- \@uniqueClientIDs);
+ return $self->{'meta-db'}
+ ->setClientIDsOfSystem($systemID, \@uniqueClientIDs);
}
sub addClientIDsToSystem
{
- my $self = shift;
- my $systemID = shift;
+ my $self = shift;
+ my $systemID = shift;
my $newClientIDs = _aref(shift);
my @clientIDs = $self->{'meta-db'}->fetchClientIDsOfSystem($systemID);
@@ -549,33 +556,32 @@ sub addClientIDsToSystem
sub removeClientIDsFromSystem
{
- my $self = shift;
- my $systemID = shift;
+ my $self = shift;
+ my $systemID = shift;
my $removedClientIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$removedClientIDs} = ();
- my @clientIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchClientIDsOfSystem($systemID);
+ my @clientIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchClientIDsOfSystem($systemID);
return $self->setClientIDsOfSystem($systemID, \@clientIDs);
}
sub setGroupIDsOfSystem
{
- my $self = shift;
+ my $self = shift;
my $systemID = shift;
my $groupIDs = _aref(shift);
my @uniqueGroupIDs = _unique(@$groupIDs);
- return $self->{'meta-db'}->setGroupIDsOfSystem($systemID,
- \@uniqueGroupIDs);
+ return $self->{'meta-db'}->setGroupIDsOfSystem($systemID, \@uniqueGroupIDs);
}
sub addGroupIDsToSystem
{
- my $self = shift;
- my $systemID = shift;
+ my $self = shift;
+ my $systemID = shift;
my $newGroupIDs = _aref(shift);
my @groupIDs = $self->{'meta-db'}->fetchGroupIDsOfSystem($systemID);
@@ -585,21 +591,21 @@ sub addGroupIDsToSystem
sub removeGroupIDsFromSystem
{
- my $self = shift;
- my $systemID = shift;
+ my $self = shift;
+ my $systemID = shift;
my $toBeRemovedGroupIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$toBeRemovedGroupIDs} = ();
- my @groupIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchGroupIDsOfSystem($systemID);
+ my @groupIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchGroupIDsOfSystem($systemID);
return $self->setGroupIDsOfSystem($systemID, \@groupIDs);
}
sub addClient
{
- my $self = shift;
+ my $self = shift;
my $valRows = _aref(shift);
foreach my $valRow (@$valRows) {
@@ -613,7 +619,7 @@ sub addClient
sub removeClient
{
- my $self = shift;
+ my $self = shift;
my $clientIDs = _aref(shift);
foreach my $client (@$clientIDs) {
@@ -626,28 +632,28 @@ sub removeClient
sub changeClient
{
- my $self = shift;
+ my $self = shift;
my $clientIDs = _aref(shift);
- my $valRows = _aref(shift);
+ my $valRows = _aref(shift);
return $self->{'meta-db'}->changeClient($clientIDs, $valRows);
}
sub setSystemIDsOfClient
{
- my $self = shift;
- my $clientID = shift;
+ my $self = shift;
+ my $clientID = shift;
my $systemIDs = _aref(shift);
my @uniqueSystemIDs = _unique(@$systemIDs);
- return $self->{'meta-db'}->setSystemIDsOfClient($clientID,
- \@uniqueSystemIDs);
+ return $self->{'meta-db'}
+ ->setSystemIDsOfClient($clientID, \@uniqueSystemIDs);
}
sub addSystemIDsToClient
{
- my $self = shift;
- my $clientID = shift;
+ my $self = shift;
+ my $clientID = shift;
my $newSystemIDs = _aref(shift);
my @systemIDs = $self->{'meta-db'}->fetchSystemIDsOfClient($clientID);
@@ -657,33 +663,32 @@ sub addSystemIDsToClient
sub removeSystemIDsFromClient
{
- my $self = shift;
- my $clientID = shift;
+ my $self = shift;
+ my $clientID = shift;
my $removedSystemIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$removedSystemIDs} = ();
- my @systemIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchSystemIDsOfClient($clientID);
+ my @systemIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchSystemIDsOfClient($clientID);
return $self->setSystemIDsOfClient($clientID, \@systemIDs);
}
sub setGroupIDsOfClient
{
- my $self = shift;
+ my $self = shift;
my $clientID = shift;
my $groupIDs = _aref(shift);
my @uniqueGroupIDs = _unique(@$groupIDs);
- return $self->{'meta-db'}->setGroupIDsOfClient($clientID,
- \@uniqueGroupIDs);
+ return $self->{'meta-db'}->setGroupIDsOfClient($clientID, \@uniqueGroupIDs);
}
sub addGroupIDsToClient
{
- my $self = shift;
- my $clientID = shift;
+ my $self = shift;
+ my $clientID = shift;
my $newGroupIDs = _aref(shift);
my @groupIDs = $self->{'meta-db'}->fetchGroupIDsOfClient($clientID);
@@ -693,21 +698,21 @@ sub addGroupIDsToClient
sub removeGroupIDsFromClient
{
- my $self = shift;
- my $clientID = shift;
+ my $self = shift;
+ my $clientID = shift;
my $toBeRemovedGroupIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$toBeRemovedGroupIDs} = ();
- my @groupIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchGroupIDsOfClient($clientID);
+ my @groupIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchGroupIDsOfClient($clientID);
return $self->setGroupIDsOfClient($clientID, \@groupIDs);
}
sub addGroup
{
- my $self = shift;
+ my $self = shift;
my $valRows = _aref(shift);
return $self->{'meta-db'}->addGroup($valRows);
@@ -715,7 +720,7 @@ sub addGroup
sub removeGroup
{
- my $self = shift;
+ my $self = shift;
my $groupIDs = _aref(shift);
foreach my $group (@$groupIDs) {
@@ -728,28 +733,27 @@ sub removeGroup
sub changeGroup
{
- my $self = shift;
+ my $self = shift;
my $groupIDs = _aref(shift);
- my $valRows = _aref(shift);
+ my $valRows = _aref(shift);
return $self->{'meta-db'}->changeGroup($groupIDs, $valRows);
}
sub setClientIDsOfGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $clientIDs = _aref(shift);
my @uniqueClientIDs = _unique(@$clientIDs);
- return $self->{'meta-db'}->setClientIDsOfGroup($groupID,
- \@uniqueClientIDs);
+ return $self->{'meta-db'}->setClientIDsOfGroup($groupID, \@uniqueClientIDs);
}
sub addClientIDsToGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $newClientIDs = _aref(shift);
my @clientIDs = $self->{'meta-db'}->fetchClientIDsOfGroup($groupID);
@@ -759,33 +763,32 @@ sub addClientIDsToGroup
sub removeClientIDsFromGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $removedClientIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$removedClientIDs} = ();
- my @clientIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchClientIDsOfGroup($groupID);
+ my @clientIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchClientIDsOfGroup($groupID);
return $self->setClientIDsOfGroup($groupID, \@clientIDs);
}
sub setSystemIDsOfGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $systemIDs = _aref(shift);
my @uniqueSystemIDs = _unique(@$systemIDs);
- return $self->{'meta-db'}->setSystemIDsOfGroup($groupID,
- \@uniqueSystemIDs);
+ return $self->{'meta-db'}->setSystemIDsOfGroup($groupID, \@uniqueSystemIDs);
}
sub addSystemIDsToGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $newSystemIDs = _aref(shift);
my @systemIDs = $self->{'meta-db'}->fetchSystemIDsOfGroup($groupID);
@@ -795,49 +798,39 @@ sub addSystemIDsToGroup
sub removeSystemIDsFromGroup
{
- my $self = shift;
- my $groupID = shift;
+ my $self = shift;
+ my $groupID = shift;
my $removedSystemIDs = _aref(shift);
my %toBeRemoved;
@toBeRemoved{@$removedSystemIDs} = ();
- my @systemIDs
- = grep { !exists $toBeRemoved{$_} }
- $self->{'meta-db'}->fetchSystemIDsOfGroup($groupID);
+ my @systemIDs =
+ grep { !exists $toBeRemoved{$_} }
+ $self->{'meta-db'}->fetchSystemIDsOfGroup($groupID);
return $self->setSystemIDsOfGroup($groupID, \@systemIDs);
}
sub emptyDatabase
-{ # clears all user-data from the database
+{ # clears all user-data from the database
my $self = shift;
- my @groupIDs
- = map { $_->{id} }
- $self->fetchGroupByFilter();
+ my @groupIDs = map { $_->{id} } $self->fetchGroupByFilter();
$self->removeGroup(\@groupIDs);
- my @clientIDs
- = map { $_->{id} }
- grep { $_->{id} > 0 }
- $self->fetchClientByFilter();
+ my @clientIDs = map { $_->{id} }
+ grep { $_->{id} > 0 } $self->fetchClientByFilter();
$self->removeClient(\@clientIDs);
- my @sysIDs
- = map { $_->{id} }
- grep { $_->{id} > 0 }
- $self->fetchSystemByFilter();
+ my @sysIDs = map { $_->{id} }
+ grep { $_->{id} > 0 } $self->fetchSystemByFilter();
$self->removeSystem(\@sysIDs);
- my @exportIDs
- = map { $_->{id} }
- grep { $_->{id} > 0 }
- $self->fetchExportByFilter();
+ my @exportIDs = map { $_->{id} }
+ grep { $_->{id} > 0 } $self->fetchExportByFilter();
$self->removeExport(\@exportIDs);
- my @vendorOSIDs
- = map { $_->{id} }
- grep { $_->{id} > 0 }
- $self->fetchVendorOSByFilter();
+ my @vendorOSIDs = map { $_->{id} }
+ grep { $_->{id} > 0 } $self->fetchVendorOSByFilter();
$self->removeVendorOS(\@vendorOSIDs);
}
@@ -845,9 +838,9 @@ sub emptyDatabase
### data aggregation interface
################################################################################
sub mergeDefaultAttributesIntoSystem
-{ # merge default system attributes into given system
- # and push the default client attributes on top of that
- my $self = shift;
+{ # merge default system attributes into given system
+ # and push the default client attributes on top of that
+ my $self = shift;
my $system = shift;
my $defaultSystem = $self->fetchSystemByID(0);
@@ -858,31 +851,33 @@ sub mergeDefaultAttributesIntoSystem
}
sub mergeDefaultAndGroupAttributesIntoClient
-{ # merge default and group configurations into given client
- my $self = shift;
+{ # merge default and group configurations into given client
+ my $self = shift;
my $client = shift;
# step over all groups this client belongs to
# (ordered by priority from highest to lowest):
my @groupIDs = $self->fetchGroupIDsOfClient($client->{id});
- my @groups = sort { $b->{priority} <=> $a->{priority} }
- $self->fetchGroupByID(\@groupIDs);
+ my @groups =
+ sort { $b->{priority} <=> $a->{priority} }
+ $self->fetchGroupByID(\@groupIDs);
foreach my $group (@groups) {
# merge configuration from this group into the current client:
- vlog 3, _tr('merging from group %d:%s...', $group->{id}, $group->{name});
+ vlog(3,
+ _tr('merging from group %d:%s...', $group->{id}, $group->{name}));
mergeAttributes($client, $group);
}
# merge configuration from default client:
- vlog 3, _tr('merging from default client...');
+ vlog(3, _tr('merging from default client...'));
my $defaultClient = $self->fetchClientByID(0);
mergeAttributes($client, $defaultClient);
}
sub aggregatedSystemIDsOfClient
-{ # return aggregated list of system-IDs this client should offer
- # (as indicated by itself, the default client and the client's groups)
- my $self = shift;
+{ # return aggregated list of system-IDs this client should offer
+ # (as indicated by itself, the default client and the client's groups)
+ my $self = shift;
my $client = shift;
# add all systems directly linked to client:
@@ -890,7 +885,7 @@ sub aggregatedSystemIDsOfClient
# step over all groups this client belongs to:
my @groupIDs = $self->fetchGroupIDsOfClient($client->{id});
- my @groups = $self->fetchGroupByID(\@groupIDs);
+ my @groups = $self->fetchGroupByID(\@groupIDs);
foreach my $group (@groups) {
# add all systems that the client inherits from the current group:
push @systemIDs, $self->fetchSystemIDsOfGroup($group->{id});
@@ -903,9 +898,9 @@ sub aggregatedSystemIDsOfClient
}
sub aggregatedClientIDsOfSystem
-{ # return aggregated list of client-IDs this system is linked to
- # (as indicated by itself, the default system and the system's groups).
- my $self = shift;
+{ # return aggregated list of client-IDs this system is linked to
+ # (as indicated by itself, the default system and the system's groups).
+ my $self = shift;
my $system = shift;
# add all clients directly linked to system:
@@ -916,13 +911,12 @@ sub aggregatedClientIDsOfSystem
# the default client, as that means that all clients should offer
#this system for booting:
push @clientIDs,
- map { $_->{id} } $self->fetchClientByFilter(undef, 'id');
+ map { $_->{id} } $self->fetchClientByFilter(undef, 'id');
}
-
# step over all groups this system belongs to:
my @groupIDs = $self->fetchGroupIDsOfSystem($system->{id});
- my @groups = $self->fetchGroupByID(\@groupIDs);
+ my @groups = $self->fetchGroupByID(\@groupIDs);
foreach my $group (@groups) {
# add all clients that the system inherits from the current group:
push @clientIDs, $self->fetchClientIDsOfGroup($group->{id});
@@ -935,35 +929,39 @@ sub aggregatedClientIDsOfSystem
}
sub aggregatedSystemFileInfoFor
-{ # return aggregated information about the kernel and initialramfs
- # this system is using
- my $self = shift;
+{ # return aggregated information about the kernel and initialramfs
+ # this system is using
+ my $self = shift;
my $system = shift;
- my $info = { %$system };
+ my $info = {%$system};
my $export = $self->fetchExportByID($system->{export_id});
if (!defined $export) {
- die _tr("DB-problem: system '%s' references export with id=%s, but that doesn't exist!",
- $system->{name}, $system->{export_id});
+ die _tr(
+ "DB-problem: system '%s' references export with id=%s, but that doesn't exist!",
+ $system->{name}, $system->{export_id}
+ );
}
$info->{'export'} = $export;
my $vendorOS = $self->fetchVendorOSByID($export->{vendor_os_id});
if (!defined $vendorOS) {
- die _tr("DB-problem: export '%s' references vendor-OS with id=%s, but that doesn't exist!",
- $export->{name}, $export->{vendor_os_id});
+ die _tr(
+ "DB-problem: export '%s' references vendor-OS with id=%s, but that doesn't exist!",
+ $export->{name}, $export->{vendor_os_id}
+ );
}
$info->{'vendor-os'} = $vendorOS;
- my $kernelPath
- = "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}/boot";
+ my $kernelPath =
+ "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}/boot";
$info->{'kernel-file'} = "$kernelPath/$system->{kernel}";
my $exportURI = $export->{'uri'};
if ($exportURI !~ m[\w]) {
# auto-generate export_uri if none has been given:
- my $type = $export->{'type'};
+ my $type = $export->{'type'};
my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
$osExportEngine->initializeFromExisting($export->{name});
$exportURI = $osExportEngine->generateExportURI($export, $vendorOS);
@@ -977,41 +975,41 @@ sub aggregatedSystemFileInfoFor
### support interface
################################################################################
sub isAttribute
-{ # returns whether or not the given key is an exportable attribute
+{ # returns whether or not the given key is an exportable attribute
my $key = shift;
return $key =~ m[^attr_];
}
sub mergeAttributes
-{ # copies all attributes of source that are unset in target over
+{ # copies all attributes of source that are unset in target over
my $target = shift;
my $source = shift;
foreach my $key (grep { isAttribute($_) } keys %$source) {
if (length($source->{$key}) > 0 && length($target->{$key}) == 0) {
- vlog 3, _tr("merging %s (val=%s)", $key, $source->{$key});
+ vlog(3, _tr("merging %s (val=%s)", $key, $source->{$key}));
$target->{$key} = $source->{$key};
}
}
}
sub pushAttributes
-{ # copies all attributes that are set in source into the target
+{ # copies all attributes that are set in source into the target
my $target = shift;
my $source = shift;
foreach my $key (grep { isAttribute($_) } keys %$source) {
if (length($source->{$key}) > 0) {
- vlog 3, _tr("pushing %s (val=%s)", $key, $source->{$key});
+ vlog(3, _tr("pushing %s (val=%s)", $key, $source->{$key}));
$target->{$key} = $source->{$key};
}
}
}
sub externalIDForSystem
-{ # returns given system's name as the external ID, worked into a
- # state that is usable as a filename:
+{ # returns given system's name as the external ID, worked into a
+ # state that is usable as a filename:
my $system = shift;
return "default" if $system->{id} == 0;
@@ -1021,23 +1019,22 @@ sub externalIDForSystem
return $name;
}
-
sub externalIDForClient
-{ # returns given client's MAC as the external ID, worked into a
- # state that is usable as a filename:
+{ # returns given client's MAC as the external ID, worked into a
+ # state that is usable as a filename:
my $client = shift;
return "default" if $client->{id} == 0;
my $mac = lc($client->{mac});
- # PXE seems to expect MACs being all lowercase
+ # PXE seems to expect MACs being all lowercase
$mac =~ tr[:][-];
return "01-$mac";
}
sub externalConfigNameForClient
-{ # returns given client's name as the external ID, worked into a
- # state that is usable as a filename:
+{ # returns given client's name as the external ID, worked into a
+ # state that is usable as a filename:
my $client = shift;
return "default" if $client->{id} == 0;
@@ -1056,7 +1053,7 @@ sub externalAttrName
sub generatePlaceholderFor
{
my $varName = shift;
- return '@@@'.$varName.'@@@';
+ return '@@@' . $varName . '@@@';
}
1;
diff --git a/config-db/OpenSLX/Export/DHCP/ISC.pm b/config-db/OpenSLX/Export/DHCP/ISC.pm
index fcc24b16..194876fa 100644
--- a/config-db/OpenSLX/Export/DHCP/ISC.pm
+++ b/config-db/OpenSLX/Export/DHCP/ISC.pm
@@ -38,7 +38,7 @@ sub execute
my $self = shift;
my $clients = shift;
- vlog 1, _tr("writing dhcp-config for %s clients", scalar(@$clients));
+ vlog(1, _tr("writing dhcp-config for %s clients", scalar(@$clients)));
foreach my $client (@$clients) {
print "ISC-DHCP: $client->{name}\n";
}
diff --git a/config-db/OpenSLX/MetaDB/Base.pm b/config-db/OpenSLX/MetaDB/Base.pm
index 74daf5f1..2738cb16 100644
--- a/config-db/OpenSLX/MetaDB/Base.pm
+++ b/config-db/OpenSLX/MetaDB/Base.pm
@@ -287,7 +287,7 @@ OpenSLX::MetaDB::Base - the base class for all MetaDB drivers
my $self = shift;
my $dbName = $openslxConfig{'db-name'};
- vlog 1, "trying to connect to coolnewDB-database <$dbName>";
+ vlog(1, "trying to connect to coolnewDB-database <$dbName>");
$self->{'dbh'} = ... # get connection handle from coolnewDB
}
diff --git a/config-db/OpenSLX/MetaDB/CSV.pm b/config-db/OpenSLX/MetaDB/CSV.pm
index cd2a7da4..bee5ca80 100644
--- a/config-db/OpenSLX/MetaDB/CSV.pm
+++ b/config-db/OpenSLX/MetaDB/CSV.pm
@@ -54,7 +54,7 @@ sub connect
system("mkdir -p $dbPath") unless -e $dbPath;
$dbSpec = "f_dir=$dbPath;csv_eol=\n;";
}
- vlog 1, "trying to connect to CSV-database <$dbSpec>";
+ vlog(1, "trying to connect to CSV-database <$dbSpec>");
$self->{'dbh'} = DBI->connect("dbi:CSV:$dbSpec", undef, undef,
{PrintError => 0})
or die _tr("Cannot connect to database '%s' (%s)",
diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm
index e59c9996..54d567cf 100644
--- a/config-db/OpenSLX/MetaDB/DBI.pm
+++ b/config-db/OpenSLX/MetaDB/DBI.pm
@@ -85,7 +85,7 @@ sub _doSelect
my $dbh = $self->{'dbh'};
- vlog 3, _trim($sql);
+ vlog(3, _trim($sql));
my $sth = $dbh->prepare($sql)
or confess _tr(q[Can't prepare SQL-statement <%s> (%s)], $sql,
$dbh->errstr);
@@ -377,12 +377,12 @@ sub _doInsert
if (!defined $valRow->{id} && !$ignoreIDs && $needToGenerateIDs) {
# let DB-backend pre-specify ID, as current DB can't generate IDs:
$valRow->{id} = $self->generateNextIdForTable($table);
- vlog 3, "generated id for <$table> is <$valRow->{id}>";
+ vlog(3, "generated id for <$table> is <$valRow->{id}>");
}
my $cols = join ', ', keys %$valRow;
my $values = join ', ', map { $self->quote($valRow->{$_}) } keys %$valRow;
my $sql = "INSERT INTO $table ( $cols ) VALUES ( $values )";
- vlog 3, $sql;
+ vlog(3, $sql);
my $sth = $dbh->prepare($sql)
or confess _tr(q[Can't insert into table <%s> (%s)], $table,
$dbh->errstr);
@@ -392,7 +392,7 @@ sub _doInsert
if (!$ignoreIDs && !defined $valRow->{id}) {
# id has not been pre-specified, we need to fetch it from DB:
$valRow->{'id'} = $dbh->last_insert_id(undef, undef, $table, 'id');
- vlog 3, "DB-generated id for <$table> is <$valRow->{id}>";
+ vlog(3, "DB-generated id for <$table> is <$valRow->{id}>");
}
push @ids, $valRow->{'id'};
}
@@ -419,7 +419,7 @@ sub _doDelete
$sql .= $additionalWhereClause;
}
}
- vlog 3, $sql;
+ vlog(3, $sql);
my $sth = $dbh->prepare($sql)
or confess _tr(q[Can't delete from table <%s> (%s)], $table,
$dbh->errstr);
@@ -457,7 +457,7 @@ sub _doUpdate
if (defined $id) {
$sql .= " WHERE id = ".$self->quote($id);
}
- vlog 3, $sql;
+ vlog(3, $sql);
my $sth = $dbh->prepare($sql)
or confess _tr(q[Can't update table <%s> (%s)], $table, $dbh->errstr);
$sth->execute()
@@ -823,10 +823,10 @@ sub schemaAddTable
my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog 1, "adding table <$table> to schema..." unless $isSubCmd;
+ vlog(1, "adding table <$table> to schema..." unless $isSubCmd);
my $colDescrString = $self->_convertColDescrsToDBNativeString($colDescrs);
my $sql = "CREATE TABLE $table ($colDescrString)";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't create table <%s> (%s)], $table, $dbh->errstr);
if (defined $initialVals) {
@@ -843,9 +843,9 @@ sub schemaDropTable
my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog 1, "dropping table <$table> from schema..." unless $isSubCmd;
+ vlog(1, "dropping table <$table> from schema..." unless $isSubCmd);
my $sql = "DROP TABLE $table";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't drop table <%s> (%s)], $table, $dbh->errstr);
}
@@ -866,17 +866,17 @@ sub schemaRenameTable
my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog 1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd;
+ vlog(1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd);
my $colDescrString = $self->_convertColDescrsToDBNativeString($colDescrs);
my $sql = "CREATE TABLE $newTable ($colDescrString)";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't create table <%s> (%s)], $oldTable, $dbh->errstr);
my $colNamesString = $self->_convertColDescrsToColNamesString($colDescrs);
my @dataRows = $self->_doSelect("SELECT $colNamesString FROM $oldTable");
$self->_doInsert($newTable, \@dataRows);
$sql = "DROP TABLE $oldTable";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't drop table <%s> (%s)], $oldTable, $dbh->errstr);
}
@@ -902,7 +902,7 @@ sub schemaAddColumns
my $tempTable = "${table}_temp";
my @newColNames = $self->_convertColDescrsToColNames($newColDescrs);
my $newColStr = join ', ', @newColNames;
- vlog 1, "adding columns <$newColStr> to table <$table>..." unless $isSubCmd;
+ vlog(1, "adding columns <$newColStr> to table <$table>..." unless $isSubCmd);
$self->schemaAddTable($tempTable, $colDescrs, undef, 1);
# copy the data from the old table to the new:
@@ -940,8 +940,8 @@ sub schemaDropColumns
my $dbh = $self->{'dbh'};
my $tempTable = "${table}_temp";
my $dropColStr = join ', ', @$dropColNames;
- vlog 1, "dropping columns <$dropColStr> from table <$table>..."
- unless $isSubCmd;
+ vlog(1, "dropping columns <$dropColStr> from table <$table>..."
+ unless $isSubCmd);
$self->schemaAddTable($tempTable, $colDescrs, undef, 1);
# copy the data from the old table to the new:
@@ -972,8 +972,8 @@ sub schemaChangeColumns
my $dbh = $self->{'dbh'};
my $tempTable = "${table}_temp";
my $changeColStr = join ', ', keys %$colChanges;
- vlog 1, "changing columns <$changeColStr> of table <$table>..."
- unless $isSubCmd;
+ vlog(1, "changing columns <$changeColStr> of table <$table>..."
+ unless $isSubCmd);
$self->schemaAddTable($tempTable, $colDescrs, undef, 1);
# copy the data from the old table to the new:
diff --git a/config-db/OpenSLX/MetaDB/SQLite.pm b/config-db/OpenSLX/MetaDB/SQLite.pm
index d2b91a03..d073f305 100644
--- a/config-db/OpenSLX/MetaDB/SQLite.pm
+++ b/config-db/OpenSLX/MetaDB/SQLite.pm
@@ -51,7 +51,7 @@ sub connect
system("mkdir -p $dbPath") unless -e $dbPath;
$dbSpec = "dbname=$dbPath/$openslxConfig{'db-name'}";
}
- vlog 1, "trying to connect to SQLite-database <$dbSpec>";
+ vlog(1, "trying to connect to SQLite-database <$dbSpec>");
eval ('require DBD::SQLite; 1;')
or die _tr(qq[%s doesn't seem to be installed,
so there is no support for %s available, sorry!\n%s], 'DBD::SQLite', 'SQLite', $@);
@@ -70,9 +70,9 @@ sub schemaRenameTable
my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog 1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd;
+ vlog(1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd);
my $sql = "ALTER TABLE $oldTable RENAME TO $newTable";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr);
}
@@ -88,12 +88,12 @@ sub schemaAddColumns
my $dbh = $self->{'dbh'};
my $newColNames = $self->_convertColDescrsToColNamesString($newColDescrs);
- vlog 1, "adding columns <$newColNames> to table <$table>" unless $isSubCmd;
+ vlog(1, "adding columns <$newColNames> to table <$table>" unless $isSubCmd);
foreach my $colDescr (@$newColDescrs) {
my $colDescrString
= $self->_convertColDescrsToDBNativeString([$colDescr]);
my $sql = "ALTER TABLE $table ADD COLUMN $colDescrString";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't add column to table <%s> (%s)], $table,
$dbh->errstr);
diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm
index 25cc93a8..eb6f9551 100644
--- a/config-db/OpenSLX/MetaDB/mysql.pm
+++ b/config-db/OpenSLX/MetaDB/mysql.pm
@@ -48,7 +48,7 @@ sub connect
$dbSpec = "database=$openslxConfig{'db-name'}";
}
my $user = (getpwuid($>))[0];
- vlog 1, "trying to connect user <$user> to mysql-database <$dbSpec>";
+ vlog(1, "trying to connect user <$user> to mysql-database <$dbSpec>");
$self->{'dbh'} = DBI->connect("dbi:mysql:$dbSpec", $user, '',
{PrintError => 0})
or die _tr("Cannot connect to database <%s> (%s)",
@@ -84,9 +84,9 @@ sub schemaRenameTable
my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog 1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd;
+ vlog(1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd);
my $sql = "ALTER TABLE $oldTable RENAME TO $newTable";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr);
}
@@ -102,7 +102,7 @@ sub schemaAddColumns
my $dbh = $self->{'dbh'};
my $newColNames = $self->_convertColDescrsToColNamesString($newColDescrs);
- vlog 1, "adding columns <$newColNames> to table <$table>" unless $isSubCmd;
+ vlog(1, "adding columns <$newColNames> to table <$table>" unless $isSubCmd);
my $addClause
= join ', ',
map {
@@ -111,7 +111,7 @@ sub schemaAddColumns
}
@$newColDescrs;
my $sql = "ALTER TABLE $table $addClause";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't add columns to table <%s> (%s)], $table,
$dbh->errstr);
@@ -131,11 +131,11 @@ sub schemaDropColumns
my $dbh = $self->{'dbh'};
my $dropColStr = join ', ', @$dropColNames;
- vlog 1, "dropping columns <$dropColStr> from table <$table>..."
- unless $isSubCmd;
+ vlog(1, "dropping columns <$dropColStr> from table <$table>..."
+ unless $isSubCmd);
my $dropClause = join ', ', map { "DROP COLUMN $_" } @$dropColNames;
my $sql = "ALTER TABLE $table $dropClause";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't drop columns from table <%s> (%s)], $table,
$dbh->errstr);
@@ -151,8 +151,8 @@ sub schemaChangeColumns
my $dbh = $self->{'dbh'};
my $changeColStr = join ', ', keys %$colChanges;
- vlog 1, "changing columns <$changeColStr> in table <$table>..."
- unless $isSubCmd;
+ vlog(1, "changing columns <$changeColStr> in table <$table>..."
+ unless $isSubCmd);
my $changeClause
= join ', ',
map {
@@ -161,7 +161,7 @@ sub schemaChangeColumns
}
keys %$colChanges;
my $sql = "ALTER TABLE $table $changeClause";
- vlog 3, $sql;
+ vlog(3, $sql);
$dbh->do($sql)
or confess _tr(q[Can't change columns in table <%s> (%s)], $table,
$dbh->errstr);
diff --git a/config-db/slxconfig b/config-db/slxconfig
index f64b1fcd..cb6c912e 100755
--- a/config-db/slxconfig
+++ b/config-db/slxconfig
@@ -294,8 +294,8 @@ sub addClientToConfigDB
$clientData->{mac});
}
my $clientID = $openslxDB->addClient([$clientData]);
- vlog 0, _tr("client '%s' has been successfully added to DB (ID=%s)\n",
- $clientName, $clientID);
+ vlog(0, _tr("client '%s' has been successfully added to DB (ID=%s)\n",
+ $clientName, $clientID));
if (@systemIDs) {
$openslxDB->addSystemIDsToClient($clientID, \@systemIDs);
}
@@ -380,8 +380,8 @@ sub addSystemToConfigDB
}
my $systemID = $openslxDB->addSystem([$systemData]);
- vlog 0, _tr("system '%s' has been successfully added to DB (ID=%s)\n",
- $systemName, $systemID);
+ vlog(0, _tr("system '%s' has been successfully added to DB (ID=%s)\n",
+ $systemName, $systemID));
if (@clientIDs) {
$openslxDB->addClientIDsToSystem($systemID, \@clientIDs);
}
@@ -457,7 +457,7 @@ sub changeClientInConfigDB
}
$openslxDB->changeClient($client->{id}, [$clientData]);
- vlog 0, _tr("client '%s' has been successfully changed\n", $clientName);
+ vlog(0, _tr("client '%s' has been successfully changed\n", $clientName));
if (@systemIDs) {
$openslxDB->setSystemIDsOfClient($client->{id}, \@systemIDs);
}
@@ -527,7 +527,7 @@ sub changeSystemInConfigDB
delete $systemData->{'remove-clients'};
}
$openslxDB->changeSystem($system->{id}, [$systemData]);
- vlog 0, _tr("system '%s' has been successfully changed\n", $systemName);
+ vlog(0, _tr("system '%s' has been successfully changed\n", $systemName));
if (@clientIDs) {
$openslxDB->setClientIDsOfSystem($system->{id}, \@clientIDs);
}
@@ -555,8 +555,8 @@ sub removeClientFromConfigDB
die _tr("you can't remove the default-client!\n");
}
$openslxDB->removeClient($client->{id});
- vlog 0, _tr("client '%s' has been successfully removed from DB\n",
- $clientName);
+ vlog(0, _tr("client '%s' has been successfully removed from DB\n",
+ $clientName));
}
sub removeSystemFromConfigDB
@@ -578,8 +578,8 @@ sub removeSystemFromConfigDB
die _tr("you can't remove the default-client!\n");
}
$openslxDB->removeSystem($system->{id});
- vlog 0, _tr("system '%s' has been successfully removed from DB\n",
- $systemName);
+ vlog(0, _tr("system '%s' has been successfully removed from DB\n",
+ $systemName));
}
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index 5d3804c7..ff1dc18d 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -199,7 +199,7 @@ sub folderContainsFiles
$result = 1 if -f;
};
find({ wanted => $wanted, follow_fast => 1 }, $folder);
- vlog 2, "result for folderContainsFiles($folder): $result\n";
+ vlog(2, "result for folderContainsFiles($folder): $result\n");
return $result;
}
@@ -214,7 +214,7 @@ sub digestAttributes
sort { $a cmp $b }
grep { isAttribute($_) } keys %$attrs;
- vlog 3, "Attribute-string: $attrsAsString";
+ vlog(3, "Attribute-string: $attrsAsString");
use Digest::MD5 qw(md5_hex);
return md5_hex($attrsAsString);
}
@@ -279,14 +279,14 @@ sub copyExternalSystemConfig
# first copy default files ...
my $defaultConfigPath = "$clientConfigPath/default";
- vlog 2, "checking $defaultConfigPath for default config...";
+ vlog(2, "checking $defaultConfigPath for default config...");
if (-d $defaultConfigPath) {
slxsystem("cp -a $defaultConfigPath/* $targetPath");
}
# ... now pour system-specific configuration on top (if any):
my $systemSpecConfigPath
= "$clientConfigPath/$systemName/default";
- vlog 2, "checking $systemSpecConfigPath for system config...";
+ vlog(2, "checking $systemSpecConfigPath for system config...");
if (folderContainsFiles($systemSpecConfigPath)) {
slxsystem("cp -a $systemSpecConfigPath/* $targetPath");
}
@@ -295,7 +295,7 @@ sub copyExternalSystemConfig
# configuration on top (if any):
my $clientSpecConfigPath
= "$clientConfigPath/$systemName/$clientName";
- vlog 2, "checking $clientSpecConfigPath for client config...";
+ vlog(2, "checking $clientSpecConfigPath for client config...");
if (folderContainsFiles($clientSpecConfigPath)) {
slxsystem("cp -a $clientSpecConfigPath/* $targetPath")
}
@@ -309,7 +309,7 @@ sub createTarOfPath
my $destinationPath = shift;
my $tarFile = "$destinationPath/$tarName";
- vlog 1, _tr('creating tar %s', $tarFile);
+ vlog(1, _tr('creating tar %s', $tarFile));
return if $dryRun;
mkdir $destinationPath;
@@ -363,7 +363,7 @@ sub writePXEMenus
my $externalClientID = externalIDForClient($client);
my $pxeFile = "$pxeConfigPath/$externalClientID";
my $clientAppend = $client->{kernel_params};
- vlog 1, _tr("writing PXE-file %s", $pxeFile);
+ vlog(1, _tr("writing PXE-file %s", $pxeFile));
next if $dryRun;
open(PXE, ">$pxeFile") or die "unable to write to $pxeFile";
print PXE $pxeTemplate;
@@ -399,7 +399,7 @@ sub generateInitalRamFS
my $osExportEngine = instantiateClass("OpenSLX::OSExport::Engine");
$osExportEngine->initializeFromExisting($info->{export}->{name});
- vlog 1, _tr('generating initialramfs %s/initramfs', $pxeVendorOSPath);
+ vlog(1, _tr('generating initialramfs %s/initramfs', $pxeVendorOSPath));
my $cmd = "$openslxConfig{'base-path'}/bin/mkdxsinitrd ";
if (length($info->{attr_ramfs_nicmods}) > 0) {
$cmd .= qq[-n "$info->{attr_ramfs_nicmods}" ];
@@ -449,7 +449,7 @@ sub writeSystemPXEFiles
my $targetKernel = "$pxeVendorOSPath/$kernelName";
if (!-e $targetKernel) {
- vlog 1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel);
+ vlog(1, _tr('copying kernel %s to %s', $kernelFile, $targetKernel));
slxsystem(qq[cp -p "$kernelFile" "$targetKernel"]) unless $dryRun;
}
$vendorOSInitramfsMap{$info->{'vendor-os'}->{id}}++;
@@ -461,7 +461,7 @@ sub writeSystemPXEFiles
sub writeDhcpConfig
{
-vlog 0, _tr("sorry, exporting dhcp data is not implemented yet!");
+vlog(0, _tr("sorry, exporting dhcp data is not implemented yet!"));
my $dhcpModule = "OpenSLX::Export::DHCP::$dhcpType";
if (!eval "require $dhcpModule") {
die _tr("unable to load DHCP-Export backend '%s'! (%s)\n", $dhcpModule, $@);
@@ -493,15 +493,15 @@ sub writeClientConfigurationsForSystem
mergeAttributes($client, $info);
my $clientAttrDigest = digestAttributes($client);
- vlog 2, _tr("attribute-digest for client '%s' is '%s'", $client->{name},
- $clientAttrDigest);
+ vlog(2, _tr("attribute-digest for client '%s' is '%s'", $client->{name},
+ $clientAttrDigest));
# export client-specific config only if attributes are different
# from system and/or a client-specific config-folder exists:
if ($clientAttrDigest ne $info->{'attr-digest'}
|| -d $clientConfigPath) {
- vlog 1, _tr("creating config-tgz for client %d:%s", $client->{id},
- $client->{name});
+ vlog(1, _tr("creating config-tgz for client %d:%s", $client->{id},
+ $client->{name}));
$clientSystemConfCount++;
# merge default, system and client configuration files into
@@ -532,8 +532,8 @@ sub writeSystemConfiguration
$openslxDB->mergeDefaultAttributesIntoSystem($info);
$info->{'attr-digest'} = digestAttributes($info);
- vlog 2, _tr("attribute-digest for system '%s' is '%s'", $info->{name},
- $info->{'attr-digest'});
+ vlog(2, _tr("attribute-digest for system '%s' is '%s'", $info->{name},
+ $info->{'attr-digest'}));
my $attrFile = "$buildPath/initramfs/machine-setup";
writeAttributesToFile($info, $attrFile);
@@ -555,7 +555,7 @@ sub writeConfigurations
foreach my $system (@systems) {
next unless $system->{id} > 0;
- vlog 0, _tr('exporting system %d:%s', $system->{id}, $system->{name});
+ vlog(0, _tr('exporting system %d:%s', $system->{id}, $system->{name}));
$systemConfCount++;
my $info = $openslxDB->aggregatedSystemFileInfoFor($system);