summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2008-01-04 17:50:15 +0100
committerOliver Tappe2008-01-04 17:50:15 +0100
commit9507d838668846666d2c790a0a1e6e51eb8670de (patch)
tree2c843db4b2865319b8d26604c212c5fea07e5bbc /config-db
parentmore work at refactoring of the way attributes are handled: (diff)
downloadcore-9507d838668846666d2c790a0a1e6e51eb8670de.tar.gz
core-9507d838668846666d2c790a0a1e6e51eb8670de.tar.xz
core-9507d838668846666d2c790a0a1e6e51eb8670de.zip
more refactoring (not limited to attribute handling)
* completed separation of attributes and standard (column) values * improved tests a lot That work is still not finished, so expect things to fail horribly. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1443 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/ConfigDB.pm301
-rw-r--r--config-db/OpenSLX/DBSchema.pm173
-rw-r--r--config-db/OpenSLX/MetaDB/DBI.pm543
-rwxr-xr-xconfig-db/slxconfig65
-rw-r--r--config-db/t/01-basics.t3
-rw-r--r--config-db/t/10-vendor-os.t6
-rw-r--r--config-db/t/11-export.t6
-rw-r--r--config-db/t/12-system.t215
-rw-r--r--config-db/t/13-client.t179
-rw-r--r--config-db/t/14-group.t182
-rw-r--r--config-db/t/15-global_info.t5
-rw-r--r--config-db/t/20-client_system_ref.t7
-rw-r--r--config-db/t/21-group_system_ref.t7
-rw-r--r--config-db/t/22-group_client_ref.t7
-rw-r--r--config-db/t/25-attributes.t929
-rw-r--r--config-db/t/29-transaction.t3
16 files changed, 1753 insertions, 878 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm
index 95183c95..289f6f7f 100644
--- a/config-db/OpenSLX/ConfigDB.pm
+++ b/config-db/OpenSLX/ConfigDB.pm
@@ -561,6 +561,15 @@ sub fetchSystemByFilter
$filter, $resultCols, $attrFilter
);
+ # unless specific result cols have been given, we mix in the attributes
+ # of each system, too:
+ if (!defined $resultCols) {
+ foreach my $system (@systems) {
+ $system->{attrs}
+ = $self->{'meta-db'}->fetchSystemAttrs($system->{id});
+ }
+ }
+
return wantarray() ? @systems : shift @systems;
}
@@ -596,91 +605,16 @@ sub fetchSystemByID
# unless specific result cols have been given, we mix in the attributes
# of each system, too:
-# if (!defined $resultCols) {
-# foreach my $system (@systems) {
-# $system->{attrs}
-# = $self->{'meta-db'}->fetchSystemAttrs($system->{id});
-# }
-# }
+ if (!defined $resultCols) {
+ foreach my $system (@systems) {
+ $system->{attrs}
+ = $self->{'meta-db'}->fetchSystemAttrs($system->{id});
+ }
+ }
return wantarray() ? @systems : shift @systems;
}
-=item C<fetchSystemAttrs($systemID, [$attrNames])>
-
-Fetches and returns the information about the attributes of the system
-with the given ID.
-
-=over
-
-=item Param C<$systemID>
-
-The ID of the system whose attributes you are interested in.
-
-=item Param C<$attrNames> [Optional]
-
-A comma-separated list of attribute names that shall be returned. If not
-defined,all available attributes will be returned.
-
-=item Return Value
-
-An array of hash-refs containing the resulting data rows (or a single hash-ref
-mapping all attribute names to the respective value).
-
-=back
-
-=cut
-
-sub fetchSystemAttrs
-{
- my $self = shift;
- my $systemID = shift;
- my $attrNames = shift;
-
- my @attrs = $self->{'meta-db'}->fetchSystemAttrs($systemID, $attrNames);
-
- return wantarray() ? @attrs : shift @attrs;
-}
-
-=item C<fetchSystemAttrsAsHash($systemID, [$attrNames])>
-
-Fetches and returns the information about the attributes of the system
-with the given ID.
-
-=over
-
-=item Param C<$systemID>
-
-The ID of the system whose attributes you are interested in.
-
-=item Param C<$attrNames> [Optional]
-
-A comma-separated list of attribute names that shall be returned. If not
-defined,all available attributes will be returned.
-
-=item Return Value
-
-A single hash-ref mapping all attribute names to their respective value.
-
-=back
-
-=cut
-
-sub fetchSystemAttrsAsHash
-{
- my $self = shift;
- my $systemID = shift;
- my $attrNames = shift;
-
- my @attrs = $self->{'meta-db'}->fetchSystemAttrs($systemID, $attrNames);
-
- my $Result = {};
- foreach my $attr (@attrs) {
- $Result->{$attr->{name}} = $attr->{value};
- }
- return $Result;
-}
-
=item C<fetchSystemIDsOfExport($id)>
Fetches the IDs of all systems that make use of the export with the given ID.
@@ -787,10 +721,23 @@ An array of hash-refs containing the resulting data rows.
sub fetchClientByFilter
{
- my $self = shift;
- my $filter = shift;
+ my $self = shift;
+ my $filter = shift;
+ my $resultCols = shift;
+ my $attrFilter = shift;
- my @clients = $self->{'meta-db'}->fetchClientByFilter($filter);
+ my @clients = $self->{'meta-db'}->fetchClientByFilter(
+ $filter, $resultCols, $attrFilter
+ );
+
+ # unless specific result cols have been given, we mix in the attributes
+ # of each client, too:
+ if (!defined $resultCols) {
+ foreach my $client (@clients) {
+ $client->{attrs}
+ = $self->{'meta-db'}->fetchClientAttrs($client->{id});
+ }
+ }
return wantarray() ? @clients : shift @clients;
}
@@ -825,6 +772,15 @@ sub fetchClientByID
my @clients = $self->{'meta-db'}->fetchClientByID($ids, $resultCols);
+ # unless specific result cols have been given, we mix in the attributes
+ # of each client, too:
+ if (!defined $resultCols) {
+ foreach my $client (@clients) {
+ $client->{attrs}
+ = $self->{'meta-db'}->fetchClientAttrs($client->{id});
+ }
+ }
+
return wantarray() ? @clients : shift @clients;
}
@@ -911,8 +867,20 @@ sub fetchGroupByFilter
my $self = shift;
my $filter = shift;
my $resultCols = shift;
+ my $attrFilter = shift;
- my @groups = $self->{'meta-db'}->fetchGroupByFilter($filter, $resultCols);
+ my @groups = $self->{'meta-db'}->fetchGroupByFilter(
+ $filter, $resultCols, $attrFilter
+ );
+
+ # unless specific result cols have been given, we mix in the attributes
+ # of each group, too:
+ if (!defined $resultCols) {
+ foreach my $group (@groups) {
+ $group->{attrs}
+ = $self->{'meta-db'}->fetchGroupAttrs($group->{id});
+ }
+ }
return wantarray() ? @groups : shift @groups;
}
@@ -947,6 +915,15 @@ sub fetchGroupByID
my @groups = $self->{'meta-db'}->fetchGroupByID($ids, $resultCols);
+ # unless specific result cols have been given, we mix in the attributes
+ # of each group, too:
+ if (!defined $resultCols) {
+ foreach my $group (@groups) {
+ $group->{attrs}
+ = $self->{'meta-db'}->fetchGroupAttrs($group->{id});
+ }
+ }
+
return wantarray() ? @groups : shift @groups;
}
@@ -1707,6 +1684,43 @@ sub changeClient
return $self->{'meta-db'}->changeClient($clientIDs, $valRows);
}
+=item C<setClientAttr($clientID, $attrName, $attrValue)>
+
+Sets a value for an attribute of the given client. If the client already
+has a value for this attribute, it will be overwritten.
+
+=over
+
+=item Param C<clientID>
+
+The ID of the client whose attribute shall be changed.
+
+=item Param C<attrName>
+
+The name of the attribute to change.
+
+=item Param C<attrValue>
+
+The new value for the attribute.
+
+=item Return Value
+
+C<1> if the attribute could be set, C<undef> if not.
+
+=back
+
+=cut
+
+sub setClientAttr
+{
+ my $self = shift;
+ my $clientID = shift;
+ my $attrName = shift;
+ my $attrValue = shift;
+
+ return $self->{'meta-db'}->setClientAttr($clientID, $attrName, $attrValue);
+}
+
=item C<setSystemIDsOfClient($clientID, @$systemIDs)>
Specifies all systems that should be offered for booting by the given client.
@@ -1987,6 +2001,43 @@ sub removeGroup
return $self->{'meta-db'}->removeGroup($groupIDs);
}
+=item C<setGroupAttr($groupID, $attrName, $attrValue)>
+
+Sets a value for an attribute of the given group. If the group already
+has a value for this attribute, it will be overwritten.
+
+=over
+
+=item Param C<groupID>
+
+The ID of the group whose attribute shall be changed.
+
+=item Param C<attrName>
+
+The name of the attribute to change.
+
+=item Param C<attrValue>
+
+The new value for the attribute.
+
+=item Return Value
+
+C<1> if the attribute could be set, C<undef> if not.
+
+=back
+
+=cut
+
+sub setGroupAttr
+{
+ my $self = shift;
+ my $groupID = shift;
+ my $attrName = shift;
+ my $attrValue = shift;
+
+ return $self->{'meta-db'}->setGroupAttr($groupID, $attrName, $attrValue);
+}
+
=item C<changeGroup(@$groupIDs, @$valRows)>
Changes the data of one or more groups.
@@ -2588,13 +2639,17 @@ sub mergeAttributes
my $target = shift;
my $source = shift;
- foreach my $key (keys %$source) {
- next if !isAttribute($key);
- my $sourceVal = $source->{$key} || '';
- my $targetVal = $target->{$key} || '';
- if (length($sourceVal) && !length($targetVal)) {
- vlog(3, _tr("merging %s (val=%s)", $key, $sourceVal));
- $target->{$key} = $sourceVal;
+ my $sourceAttrs = $source->{attrs} || {};
+
+ $target->{attrs} ||= {};
+ my $targetAttrs = $target->{attrs};
+
+ foreach my $key (keys %$sourceAttrs) {
+ my $sourceVal = $sourceAttrs->{$key};
+ my $targetVal = $targetAttrs->{$key};
+ if (defined $sourceVal && !defined $targetVal) {
+ vlog(0, _tr("merging %s (val=%s)", $key, $sourceVal));
+ $targetAttrs->{$key} = $sourceVal;
}
}
@@ -2628,11 +2683,16 @@ sub pushAttributes
my $target = shift;
my $source = shift;
- foreach my $key (grep { isAttribute($_) } keys %$source) {
- my $sourceVal = $source->{$key} || '';
- if (length($sourceVal)) {
+ my $sourceAttrs = $source->{attrs} || {};
+
+ $target->{attrs} ||= {};
+ my $targetAttrs = $target->{attrs};
+
+ foreach my $key (keys %$sourceAttrs) {
+ my $sourceVal = $sourceAttrs->{$key};
+ if (defined $sourceVal) {
vlog(3, _tr("pushing %s (val=%s)", $key, $sourceVal));
- $target->{$key} = $sourceVal;
+ $targetAttrs->{$key} = $sourceVal;
}
}
@@ -2826,54 +2886,7 @@ sub _checkAndUpgradeDBSchemaIfNecessary
$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) {
- my $changeDescr = @{$changeSet}[$c];
- my $cmd = $changeDescr->{cmd};
- if ($cmd eq 'add-table') {
- $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'}
- );
- } elsif ($cmd eq 'add-columns') {
- $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'}
- );
- } elsif ($cmd eq 'rename-columns') {
- $metaDB->schemaRenameColumns(
- $changeDescr->{'table'},
- $changeDescr->{'col-renames'},
- $changeDescr->{'cols'}
- );
- } elsif ($cmd eq 'perl-func') {
- if (!$changeDescr->{code}->($self)) {
- croak _tr('problem in perl-func cmd!');
- }
- } else {
- croak _tr('UnknownDbSchemaCommand', $cmd);
- }
- }
- }
+ $metaDB->schemaUpgradeDBFrom($currVersion);
$metaDB->schemaSetDBVersion($DbSchema->{version});
vlog(1, _tr('upgrade done'));
} else {
diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm
index 54596c9f..801f50a9 100644
--- a/config-db/OpenSLX/DBSchema.pm
+++ b/config-db/OpenSLX/DBSchema.pm
@@ -33,12 +33,7 @@ use OpenSLX::Basics;
use POSIX qw(locale_h);
my $lang = setlocale(LC_MESSAGES);
-my $country;
-if ($lang =~ m[^\w\w_(\w\w)]) {
- $country = lc($1);
-} else {
- $country = 'us';
-}
+my $country = $lang =~ m[^\w\w_(\w\w)] ? lc($1) : 'us';
################################################################################
### DB-schema definition
@@ -73,12 +68,22 @@ $DbSchema = {
],
'vals' => [
{ # add default client
- 'id' => 0,
- 'name' => '<<<default>>>',
- 'comment' => 'internal client that holds default values',
+ 'id' => 0,
+ 'name' => '<<<default>>>',
+ 'comment' => 'internal client that holds default values',
+ 'unbootable' => 0,
},
],
},
+ 'client_attr' => {
+ # attributes of clients
+ 'cols' => [
+ 'id:pk', # primary key
+ 'client_id:fk', # foreign key to client
+ 'name:s.128', # attribute name
+ 'value:s.255', # attribute value
+ ],
+ },
'client_system_ref' => {
# clients referring to the systems they should offer for booting
'cols' => [
@@ -134,6 +139,15 @@ $DbSchema = {
'comment:s.1024', # internal comment (optional, for admins)
],
},
+ 'group_attr' => {
+ # attributes of groups
+ 'cols' => [
+ 'id:pk', # primary key
+ 'group_id:fk', # foreign key to group
+ 'name:s.128', # attribute name
+ 'value:s.255', # attribute value
+ ],
+ },
'group_client_ref' => {
# groups referring to their clients
'cols' => [
@@ -394,146 +408,9 @@ $DbSchema = {
};
################################################################################
-### DB-schema history
-###
-### This hash contains a description of all the different changes that have
-### taken place on the schema. Each version contains a changeset (array)
-### with the commands that take the schema from the last version to the
-### current.
-###
-### The following 'cmd'-types are supported:
-###
-### add-table => creates a new table
-### 'table' => contains the name of the new table
-### 'cols' => contains a list of column descriptions
-### 'vals' => optional, contains list of data hashes to be inserted
-### into new table
-###
-### drop-table => drops an existing table
-### 'table => contains the name of the table to be dropped
-###
-### rename-table => renames a table
-### 'old-table' => contains the old name of the table
-### 'new-table' => contains the new name of the table
-### 'cols' => contains a full list of column descriptions
-###
-### add-columns => adds columns to a table
-### 'table' => the name of the table the columns should be added to
-### 'new-cols' => contains a list of new column descriptions
-### 'new-default-vals' => optional, a list of data hashes to be used
-### as default values for the new columns
-### 'cols' => contains a full list of resulting column descriptions
-###
-### drop-columns => drops columns from a table
-### 'table' => the name of the table the columns should be dropped from
-### 'drop-cols' => a list of column names to be dropped
-### 'cols' => contains a full list of resulting column descriptions
-###
-### perl-func => a perl function invoked with config-DB object as param
-### 'code' => the function (sub) that shall be executed
-###
-################################################################################
-
-%DbSchemaHistory = (
- '0.01' => [
- # there's no need to upgrade to the initial schema version, as we
- # create the newest schema automatically if none exists yet.
- ],
- '0.2' => [
- # move attributes into separate tables ...
- #
- # ... system attributes ...
- {
- 'cmd' => 'add-table',
- 'table' => 'system_attr',
- 'cols' => [
- 'id:pk',
- 'system_id:fk',
- 'name:s.128',
- 'value:s.255',
- ],
- },
- {
- 'cmd' => 'perl-func',
- 'code' => sub {
- my $configDB = shift;
- foreach my $system ($configDB->fetchSystemByFilter()) {
- foreach my $key (keys %$system) {
- next if substr($key, 0, 5) ne 'attr_';
- my $attrValue = $system->{$key} || '';
- next if $system->{id}>0 && !length($attrValue);
- my $newAttrName = substr($key, 5);
- $configDB->setSystemAttr(
- $system->{id}, $newAttrName, $attrValue
- );
- }
- }
- 1;
- }
- },
- {
- 'cmd' => 'drop-columns',
- 'table' => 'system',
- 'drop-cols' => [
- 'attr_automnt_dir',
- 'attr_automnt_src',
- 'attr_country',
- 'attr_dm_allow_shutdown',
- 'attr_hw_graphic',
- 'attr_hw_monitor',
- 'attr_hw_mouse',
- 'attr_late_dm',
- 'attr_netbios_workgroup',
- 'attr_nis_domain',
- 'attr_nis_servers',
- 'attr_ramfs_fsmods',
- 'attr_ramfs_miscmods',
- 'attr_ramfs_nicmods',
- 'attr_ramfs_screen',
- 'attr_sane_scanner',
- 'attr_scratch',
- 'attr_slxgrp',
- 'attr_start_alsasound',
- 'attr_start_atd',
- 'attr_start_cron',
- 'attr_start_dreshal',
- 'attr_start_ntp',
- 'attr_start_nfsv4',
- 'attr_start_printer',
- 'attr_start_samba',
- 'attr_start_snmp',
- 'attr_start_sshd',
- 'attr_start_syslog',
- 'attr_start_x',
- 'attr_start_xdmcp',
- 'attr_tex_enable',
- 'attr_timezone',
- 'attr_tvout',
- 'attr_vmware',
- ],
- 'cols' => [
- 'id:pk',
- 'export_id:fk',
- 'name:s.64',
- 'label:s.64',
- 'kernel:s.128',
- 'kernel_params:s.512',
- 'hidden:b',
- 'comment:s.1024',
- ],
- },
- #
- # ... client attributes ...
- #
- # ... group attributes ...
- ],
-);
-
-
-################################################################################
###
-### Load all available AttrInfo modules and build the complete hash containing
-### info about all known attributes from that.
+### Load the available AttrInfo-modules and build a hash containing info about
+### all known attributes from the data contained in those modules.
###
################################################################################
diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm
index 774ab90e..98754777 100644
--- a/config-db/OpenSLX/MetaDB/DBI.pm
+++ b/config-db/OpenSLX/MetaDB/DBI.pm
@@ -78,14 +78,13 @@ sub _trim
sub _buildFilterClause
{
- my $self = shift;
- my $filter = shift || {};
- my $connector = shift;
+ my $self = shift;
+ my $filter = shift || {};
+ my $filterClause = shift || '';
- my $filterClause = '';
- my ($quotedVal);
+ my ($connector, $quotedVal);
foreach my $col (keys %$filter) {
- $connector = !defined $connector ? 'WHERE' : 'AND';
+ $connector = !length($filterClause) ? 'WHERE' : 'AND';
if (defined $filter->{$col}) {
$quotedVal = $self->{dbh}->quote($filter->{$col});
$filterClause .= " $connector $col = $quotedVal";
@@ -94,42 +93,48 @@ sub _buildFilterClause
}
}
- return $filterClause;
+ return $filterClause || '';
}
sub _buildAttrFilterClause
{
- my $self = shift;
- my $attrFilter = shift || {};
- my $connector = shift;
+ my $self = shift;
+ my $attrFilter = shift || {};
+ my $table = shift;
+ my $filterClause = shift || '';
+
+ my %tableMap = (
+ 'client' => 'client',
+ 'group' => 'groups',
+ 'system' => 'system',
+ );
- my $attrFilterClause = '';
- my ($quotedName, $quotedValue);
+ my ($connector, $quotedName, $quotedValue);
foreach my $name (keys %$attrFilter) {
- $connector = !defined $connector ? 'WHERE' : 'AND';
+ $connector = !length($filterClause) ? 'WHERE' : 'AND';
$quotedName = $self->{dbh}->quote($name);
if (defined $attrFilter->{$name}) {
$quotedValue = $self->{dbh}->quote($attrFilter->{$name});
- $attrFilterClause .= <<" End-of-Here";
+ $filterClause .= <<" End-of-Here";
$connector EXISTS (
- SELECT name FROM system_attr
+ SELECT name FROM ${table}_attr
WHERE name = $quotedName
AND value = $quotedValue
- AND system_id = system.id
+ AND ${table}_id = $tableMap{$table}.id
)
End-of-Here
} else {
- $attrFilterClause .= <<" End-of-Here";
+ $filterClause .= <<" End-of-Here";
$connector NOT EXISTS (
- SELECT name FROM system_attr
+ SELECT name FROM ${table}_attr
WHERE name = $quotedName
- AND system_id = system.id
+ AND ${table}_id = $tableMap{$table}.id
)
End-of-Here
}
}
- return $attrFilterClause;
+ return $filterClause;
}
sub _doSelect
@@ -245,13 +250,13 @@ sub fetchSystemByFilter
my $attrFilter = shift;
$resultCols = '*' unless (defined $resultCols);
- my $filterClause = $self->_buildFilterClause($filter, 'AND');
- my $attrFilterClause = $self->_buildAttrFilterClause($attrFilter, 'AND');
+ my $filterClause = $self->_buildFilterClause($filter);
+ $filterClause = $self->_buildAttrFilterClause(
+ $attrFilter, 'system', $filterClause
+ );
my $sql = <<" End-of-Here";
SELECT $resultCols FROM system
- WHERE 1=1
$filterClause
- $attrFilterClause
End-of-Here
return $self->_doSelect($sql);
}
@@ -273,17 +278,17 @@ sub fetchSystemAttrs
{
my $self = shift;
my $systemID = $self->{dbh}->quote(shift);
- my $attrNames = shift;
my $sql = <<" End-of-Here";
- SELECT id, name, value FROM system_attr
+ SELECT name, value FROM system_attr
WHERE system_id = $systemID
End-of-Here
- if (defined $attrNames) {
- my $attrList = join ',', map { $self->{dbh}->quote($_) } @$attrNames;
- $sql .= " AND name IN ($attrList)";
+ my @attrs = $self->_doSelect($sql);
+ my $Result = {};
+ foreach my $attr (@attrs) {
+ $Result->{$attr->{name}} = $attr->{value};
}
- return $self->_doSelect($sql);
+ return $Result;
}
sub fetchSystemIDsOfExport
@@ -324,10 +329,17 @@ sub fetchClientByFilter
my $self = shift;
my $filter = shift;
my $resultCols = shift;
+ my $attrFilter = shift;
$resultCols = '*' unless (defined $resultCols);
my $filterClause = $self->_buildFilterClause($filter);
- my $sql = "SELECT $resultCols FROM client $filterClause";
+ $filterClause = $self->_buildAttrFilterClause(
+ $attrFilter, 'client', $filterClause
+ );
+ my $sql = <<" End-of-Here";
+ SELECT $resultCols FROM client
+ $filterClause
+ End-of-Here
return $self->_doSelect($sql);
}
@@ -344,6 +356,23 @@ sub fetchClientByID
return $self->_doSelect($sql);
}
+sub fetchClientAttrs
+{
+ my $self = shift;
+ my $clientID = $self->{dbh}->quote(shift);
+
+ my $sql = <<" End-of-Here";
+ SELECT name, value FROM client_attr
+ WHERE client_id = $clientID
+ End-of-Here
+ my @attrs = $self->_doSelect($sql);
+ my $Result = {};
+ foreach my $attr (@attrs) {
+ $Result->{$attr->{name}} = $attr->{value};
+ }
+ return $Result;
+}
+
sub fetchClientIDsOfSystem
{
my $self = shift;
@@ -371,10 +400,17 @@ sub fetchGroupByFilter
my $self = shift;
my $filter = shift;
my $resultCols = shift;
+ my $attrFilter = shift;
$resultCols = '*' unless (defined $resultCols);
my $filterClause = $self->_buildFilterClause($filter);
- my $sql = "SELECT $resultCols FROM groups $filterClause";
+ $filterClause = $self->_buildAttrFilterClause(
+ $attrFilter, 'group', $filterClause
+ );
+ my $sql = <<" End-of-Here";
+ SELECT $resultCols FROM groups
+ $filterClause
+ End-of-Here
return $self->_doSelect($sql);
}
@@ -391,6 +427,23 @@ sub fetchGroupByID
return $self->_doSelect($sql);
}
+sub fetchGroupAttrs
+{
+ my $self = shift;
+ my $groupID = $self->{dbh}->quote(shift);
+
+ my $sql = <<" End-of-Here";
+ SELECT name, value FROM group_attr
+ WHERE group_id = $groupID
+ End-of-Here
+ my @attrs = $self->_doSelect($sql);
+ my $Result = {};
+ foreach my $attr (@attrs) {
+ $Result->{$attr->{name}} = $attr->{value};
+ }
+ return $Result;
+}
+
sub fetchGroupIDsOfSystem
{
my $self = shift;
@@ -505,20 +558,22 @@ sub _doUpdate
my $dbh = $self->{'dbh'};
my $valRow = (@$valRows)[0];
- return if !defined $valRow || !scalar keys %$valRow;
+ return 1 if !defined $valRow || !scalar keys %$valRow;
my $idx = 0;
foreach my $valRow (@$valRows) {
my $id = $IDs->[$idx++];
my %valData = %$valRow;
- delete $valData{'id'};
- # filter column 'id' if present, as we don't want to update it
+ # fail if asked to change the column 'id', as that is bogus
+ return if exists $valData{id} && $valData{id} ne $id;
+ # filter column 'id' if present, as we don't want to write it
+ delete $valData{id};
my @cols = map { "$_ = " . $self->quote($valRow->{$_}) }
grep { $_ ne 'id' }
# filter column 'id' if present, as we don't want
# to update it!
keys %$valRow;
- return if !@cols;
+ next if !@cols;
my $cols = join ', ', @cols;
my $sql = "UPDATE $table SET $cols";
if (defined $id) {
@@ -661,7 +716,26 @@ sub addSystem
my $self = shift;
my $valRows = shift;
- return $self->_doInsert('system', $valRows);
+ # separate the attribute hashes ...
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+
+ # ... store the systems to get the IDs ...
+ my @systemIDs = $self->_doInsert('system', $valRows);
+
+ # ... finally store the individual attribute sets
+ foreach my $id (@systemIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setSystemAttrs($id, $attrs);
+ }
+
+ return @systemIDs;
}
sub removeSystem
@@ -678,37 +752,44 @@ sub changeSystem
my $systemIDs = shift;
my $valRows = shift;
+ # separate the attribute hashes and store them individually
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+ foreach my $id (@$systemIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setSystemAttrs($id, $attrs);
+ }
+
+ # finally update all systems in one go
return $self->_doUpdate('system', $systemIDs, $valRows);
}
-sub setSystemAttr
+sub setSystemAttrs
{
- my $self = shift;
- my $systemID = shift;
- my $attrName = shift;
- my $attrValue = shift;
-
- my $quotedSystemID = $self->{dbh}->quote($systemID);
- my $quotedAttrName = $self->{dbh}->quote($attrName);
-
- my $sql = <<" End-of-Here";
- SELECT id FROM system_attr
- WHERE system_id = $quotedSystemID
- AND name = $quotedAttrName
- End-of-Here
- my $id = $self->_doSelect($sql, 'id');
- if ($id) {
- return $self->_doUpdate(
- 'system_attr', [ $id ], [ { value => $attrValue } ]
+ my $self = shift;
+ my $systemID = shift;
+ my $attrs = shift;
+
+ # we take the simple path and remove all attributes ...
+ return if !$self->_doDelete('system_attr', [ $systemID ], 'system_id');
+
+ # ... and (re-)insert the given ones
+ foreach my $key (keys %$attrs) {
+ return if !$self->_doInsert(
+ 'system_attr', [ {
+ system_id => $systemID,
+ name => $key,
+ value => $attrs->{$key},
+ } ]
);
}
- return $self->_doInsert(
- 'system_attr', [ {
- system_id => $systemID,
- name => $attrName,
- value => $attrValue,
- } ]
- );
+ return 1;
}
sub setClientIDsOfSystem
@@ -742,7 +823,26 @@ sub addClient
my $self = shift;
my $valRows = shift;
- return $self->_doInsert('client', $valRows);
+ # separate the attribute hashes ...
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+
+ # ... store the clients to get the IDs ...
+ my @clientIDs = $self->_doInsert('client', $valRows);
+
+ # ... finally store the individual attribute sets
+ foreach my $id (@clientIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setClientAttrs($id, $attrs);
+ }
+
+ return @clientIDs;
}
sub removeClient
@@ -759,9 +859,46 @@ sub changeClient
my $clientIDs = shift;
my $valRows = shift;
+ # separate the attribute hashes and store them individually
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+ foreach my $id (@$clientIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setClientAttrs($id, $attrs);
+ }
+
+ # finally update all systems in one go
return $self->_doUpdate('client', $clientIDs, $valRows);
}
+sub setClientAttrs
+{
+ my $self = shift;
+ my $clientID = shift;
+ my $attrs = shift;
+
+ # we take the simple path and remove all attributes ...
+ return if !$self->_doDelete('client_attr', [ $clientID ], 'client_id');
+
+ # ... and (re-)insert the given ones
+ foreach my $key (keys %$attrs) {
+ return if !$self->_doInsert(
+ 'client_attr', [ {
+ client_id => $clientID,
+ name => $key,
+ value => $attrs->{$key},
+ } ]
+ );
+ }
+ return 1;
+}
+
sub setSystemIDsOfClient
{
my $self = shift;
@@ -793,7 +930,26 @@ sub addGroup
my $self = shift;
my $valRows = shift;
- return $self->_doInsert('groups', $valRows);
+ # separate the attribute hashes ...
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+
+ # ... store the groups to get the IDs ...
+ my @groupIDs = $self->_doInsert('groups', $valRows);
+
+ # ... finally store the individual attribute sets
+ foreach my $id (@groupIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setGroupAttrs($id, $attrs);
+ }
+
+ return @groupIDs;
}
sub removeGroup
@@ -810,9 +966,46 @@ sub changeGroup
my $groupIDs = shift;
my $valRows = shift;
+ # separate the attribute hashes and store them individually
+ my @attrValRows
+ = map {
+ my $attrs = $_->{attrs};
+ delete $_->{attrs};
+ $attrs;
+ }
+ @$valRows;
+ foreach my $id (@$groupIDs) {
+ my $attrs = shift @attrValRows;
+ next if !defined $attrs;
+ return if !$self->setGroupAttrs($id, $attrs);
+ }
+
+ # finally update all groups in one go
return $self->_doUpdate('groups', $groupIDs, $valRows);
}
+sub setGroupAttrs
+{
+ my $self = shift;
+ my $groupID = shift;
+ my $attrs = shift;
+
+ # we take the simple path and remove all attributes ...
+ return if !$self->_doDelete('group_attr', [ $groupID ], 'group_id');
+
+ # ... and (re-)insert the given ones
+ foreach my $key (keys %$attrs) {
+ return if !$self->_doInsert(
+ 'group_attr', [ {
+ group_id => $groupID,
+ name => $key,
+ value => $attrs->{$key},
+ } ]
+ );
+ }
+ return 1;
+}
+
sub setClientIDsOfGroup
{
my $self = shift;
@@ -896,6 +1089,16 @@ sub schemaFetchDBVersion
return $row->{schema_version};
}
+sub schemaUpgradeDBFrom
+{
+ my $self = shift;
+ my $currVersion = shift;
+
+ $self->_upgradeDBTo0_2() if $currVersion < 0.2;
+
+ return 1;
+}
+
sub schemaSetDBVersion
{
my $self = shift;
@@ -1114,6 +1317,218 @@ sub schemaChangeColumns
return;
}
+sub _upgradeDBTo0_2
+{
+ my $self = shift;
+
+ # move attributes into separate tables ...
+ #
+ # ... system attributes ...
+ $self->schemaAddTable(
+ 'system_attr',
+ [
+ 'id:pk',
+ 'system_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $system ($self->fetchSystemByFilter()) {
+ my %attrs;
+ foreach my $key (keys %$system) {
+ next if substr($key, 0, 5) ne 'attr_';
+ my $attrValue = $system->{$key} || '';
+ next if $system->{id} > 0 && !length($attrValue);
+ my $newAttrName = substr($key, 5);
+ $attrs{$newAttrName} = $attrValue;
+ }
+ $self->setSystemAttrs($system->{id}, \%attrs);
+ }
+ $self->schemaDropColumns(
+ 'system',
+ [
+ 'attr_automnt_dir',
+ 'attr_automnt_src',
+ 'attr_country',
+ 'attr_dm_allow_shutdown',
+ 'attr_hw_graphic',
+ 'attr_hw_monitor',
+ 'attr_hw_mouse',
+ 'attr_late_dm',
+ 'attr_netbios_workgroup',
+ 'attr_nis_domain',
+ 'attr_nis_servers',
+ 'attr_ramfs_fsmods',
+ 'attr_ramfs_miscmods',
+ 'attr_ramfs_nicmods',
+ 'attr_ramfs_screen',
+ 'attr_sane_scanner',
+ 'attr_scratch',
+ 'attr_slxgrp',
+ 'attr_start_alsasound',
+ 'attr_start_atd',
+ 'attr_start_cron',
+ 'attr_start_dreshal',
+ 'attr_start_ntp',
+ 'attr_start_nfsv4',
+ 'attr_start_printer',
+ 'attr_start_samba',
+ 'attr_start_snmp',
+ 'attr_start_sshd',
+ 'attr_start_syslog',
+ 'attr_start_x',
+ 'attr_start_xdmcp',
+ 'attr_tex_enable',
+ 'attr_timezone',
+ 'attr_tvout',
+ 'attr_vmware',
+ ],
+ [
+ 'id:pk',
+ 'export_id:fk',
+ 'name:s.64',
+ 'label:s.64',
+ 'kernel:s.128',
+ 'kernel_params:s.512',
+ 'hidden:b',
+ 'comment:s.1024',
+ ]
+ );
+ #
+ # ... client attributes ...
+ $self->schemaAddTable(
+ 'client_attr',
+ [
+ 'id:pk',
+ 'client_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $client ($self->fetchClientByFilter()) {
+ my %attrs;
+ foreach my $key (keys %$client) {
+ next if substr($key, 0, 5) ne 'attr_';
+ my $attrValue = $client->{$key} || '';
+ next if !length($attrValue);
+ my $newAttrName = substr($key, 5);
+ $attrs{$newAttrName} = $attrValue;
+ }
+ $self->setClientAttrs($client->{id}, \%attrs);
+ }
+ $self->schemaDropColumns(
+ 'client',
+ [
+ 'attr_automnt_dir',
+ 'attr_automnt_src',
+ 'attr_country',
+ 'attr_dm_allow_shutdown',
+ 'attr_hw_graphic',
+ 'attr_hw_monitor',
+ 'attr_hw_mouse',
+ 'attr_late_dm',
+ 'attr_netbios_workgroup',
+ 'attr_nis_domain',
+ 'attr_nis_servers',
+ 'attr_sane_scanner',
+ 'attr_scratch',
+ 'attr_slxgrp',
+ 'attr_start_alsasound',
+ 'attr_start_atd',
+ 'attr_start_cron',
+ 'attr_start_dreshal',
+ 'attr_start_ntp',
+ 'attr_start_nfsv4',
+ 'attr_start_printer',
+ 'attr_start_samba',
+ 'attr_start_snmp',
+ 'attr_start_sshd',
+ 'attr_start_syslog',
+ 'attr_start_x',
+ 'attr_start_xdmcp',
+ 'attr_tex_enable',
+ 'attr_timezone',
+ 'attr_tvout',
+ 'attr_vmware',
+ ],
+ [
+ 'id:pk',
+ 'name:s.128',
+ 'mac:s.20',
+ 'boot_type:s.20',
+ 'unbootable:b',
+ 'kernel_params:s.128',
+ 'comment:s.1024',
+ ]
+ );
+ #
+ # ... group attributes ...
+ $self->schemaAddTable(
+ 'group_attr',
+ [
+ 'id:pk',
+ 'group_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $group ($self->fetchGroupByFilter()) {
+ my %attrs;
+ foreach my $key (keys %$group) {
+ next if substr($key, 0, 5) ne 'attr_';
+ my $attrValue = $group->{$key} || '';
+ next if !length($attrValue);
+ my $newAttrName = substr($key, 5);
+ $attrs{$newAttrName} = $attrValue;
+ }
+ $self->setGroupAttrs($group->{id}, \%attrs);
+ }
+ $self->schemaDropColumns(
+ 'groups',
+ [
+ 'attr_automnt_dir',
+ 'attr_automnt_src',
+ 'attr_country',
+ 'attr_dm_allow_shutdown',
+ 'attr_hw_graphic',
+ 'attr_hw_monitor',
+ 'attr_hw_mouse',
+ 'attr_late_dm',
+ 'attr_netbios_workgroup',
+ 'attr_nis_domain',
+ 'attr_nis_servers',
+ 'attr_sane_scanner',
+ 'attr_scratch',
+ 'attr_slxgrp',
+ 'attr_start_alsasound',
+ 'attr_start_atd',
+ 'attr_start_cron',
+ 'attr_start_dreshal',
+ 'attr_start_ntp',
+ 'attr_start_nfsv4',
+ 'attr_start_printer',
+ 'attr_start_samba',
+ 'attr_start_snmp',
+ 'attr_start_sshd',
+ 'attr_start_syslog',
+ 'attr_start_x',
+ 'attr_start_xdmcp',
+ 'attr_tex_enable',
+ 'attr_timezone',
+ 'attr_tvout',
+ 'attr_vmware',
+ ],
+ [
+ 'id:pk',
+ 'name:s.128',
+ 'priority:i',
+ 'comment:s.1024',
+ ]
+ );
+
+ return 1;
+}
+
1;
=head1 NAME
diff --git a/config-db/slxconfig b/config-db/slxconfig
index 95019e3b..6df489ca 100755
--- a/config-db/slxconfig
+++ b/config-db/slxconfig
@@ -66,18 +66,24 @@ my $openslxDB = OpenSLX::ConfigDB->new();
$openslxDB->connect();
my $action = shift @ARGV || '';
-if ($action =~ m[^add-s]i) {
- addSystemToConfigDB(@ARGV);
-}
-elsif ($action =~ m[^add-c]i) {
+if ($action =~ m[^add-c]i) {
addClientToConfigDB(@ARGV);
}
+elsif ($action =~ m[^add-g]i) {
+ addGroupToConfigDB(@ARGV);
+}
+elsif ($action =~ m[^add-s]i) {
+ addSystemToConfigDB(@ARGV);
+}
elsif ($action =~ m[^change-v]i) {
changeVendorOSInConfigDB(@ARGV);
}
elsif ($action =~ m[^change-e]i) {
changeExportInConfigDB(@ARGV);
}
+elsif ($action =~ m[^change-g]i) {
+ changeGroupInConfigDB(@ARGV);
+}
elsif ($action =~ m[^change-s]i) {
changeSystemInConfigDB(@ARGV);
}
@@ -112,6 +118,10 @@ elsif ($action =~ m[^search-e]) {
print _tr("Matching exports:\n");
searchExports(@ARGV);
}
+elsif ($action =~ m[^search-g]) {
+ print _tr("Matching groups:\n");
+ searchGroups(@ARGV);
+}
elsif ($action =~ m[^search-s]) {
print _tr("Matching systems:\n");
searchSystems(@ARGV);
@@ -120,10 +130,13 @@ elsif ($action =~ m[^search-v]) {
print _tr("Matching vendor-OSes:\n");
searchVendorOSes(@ARGV);
}
-elsif ($action =~ m[^remove-cli]i) {
+elsif ($action =~ m[^remove-c]i) {
removeClientFromConfigDB(@ARGV);
}
-elsif ($action =~ m[^remove-sys]i) {
+elsif ($action =~ m[^remove-g]i) {
+ removeClientFromConfigDB(@ARGV);
+}
+elsif ($action =~ m[^remove-s]i) {
removeSystemFromConfigDB(@ARGV);
}
else {
@@ -227,7 +240,7 @@ sub dumpElements
print join(
'',
map {
- my $elemVal = $elem->{$_} || '';
+ my $elemVal = defined $elem->{$_} ? $elem->{$_} : '-';
if (ref($elemVal) eq 'HASH') {
my $spcLen
= max(map { length($_) } keys %$elemVal) || 0;
@@ -237,7 +250,7 @@ sub dumpElements
map {
my $spc = ' ' x $spcLen;
my $val = $elemVal->{$_} || '';
- $val =~ s[\n][\n\t$spc ]g;
+ $val =~ s[\n][\n$ind$spc ]g;
"$ind$_" . substr($spc, length($_)) . " = $val";
}
sort keys %$elemVal
@@ -246,7 +259,7 @@ sub dumpElements
" $_:\n$subLines\n";
} else {
my $spc = ' ' x $spcLen;
- $elemVal =~ s[\n][\n\t$spc ]g;
+ $elemVal =~ s[\n][\n$ind$spc ]g;
"$ind$_" . substr($spc, length($_)) . " = $elemVal\n";
}
}
@@ -285,6 +298,9 @@ sub listClients
map { $_->{name} }
sort { $a->{name} cmp $b->{name} }
$openslxDB->fetchSystemByID(\@sysIDs, 'name');
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
@@ -319,6 +335,9 @@ sub listGroups
= join "\n", map { $_->{name} }
sort { $a->{name} cmp $b->{name} }
$openslxDB->fetchClientByID(\@clientIDs, 'name');
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
@@ -387,7 +406,9 @@ sub listSystems
if (defined $export) {
$_->{export_id} = "$export->{name} ($export->{type})";
}
- $_->{ATTRIBUTES} = $openslxDB->fetchSystemAttrsAsHash($_->{id});
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
@@ -419,7 +440,10 @@ sub listVendorOSes
sub searchClients
{
my @clientKeys = $openslxDB->getColumnsOfTable('client');
- my $clientData = parseKeyValueArgs(\@clientKeys, 'client', @_);
+ my @clientAttrKeys = $openslxDB->getKnownClientAttrs();
+ my ($clientData, $clientAttrs) = parseKeyValueArgsWithAttrs(
+ \@clientKeys, \@clientAttrKeys, 'client', @_
+ );
# set verbose mode if any params have been passed in:
$verbose = 1 if %$clientData;
@@ -432,10 +456,13 @@ sub searchClients
= join "\n", map { $_->{name} }
sort { $a->{name} cmp $b->{name} }
$openslxDB->fetchSystemByID(\@sysIDs, 'name');
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
- $openslxDB->fetchClientByFilter($clientData)
+ $openslxDB->fetchClientByFilter($clientData, undef, $clientAttrs)
);
return 1;
@@ -444,7 +471,10 @@ sub searchClients
sub searchGroups
{
my @groupKeys = $openslxDB->getColumnsOfTable('groups');
- my $groupData = parseKeyValueArgs(\@groupKeys, 'groups', @_);
+ my @groupAttrKeys = $openslxDB->getKnownClientAttrs();
+ my ($groupData, $groupAttrs) = parseKeyValueArgsWithAttrs(
+ \@groupKeys, \@groupAttrKeys, 'group', @_
+ );
# set verbose mode if any params have been passed in:
$verbose = 1 if %$groupData;
@@ -462,10 +492,13 @@ sub searchGroups
= join "\n", map { $_->{name} }
sort { $a->{name} cmp $b->{name} }
$openslxDB->fetchClientByID(\@clientIDs, 'name');
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
- $openslxDB->fetchGroupByFilter($groupData)
+ $openslxDB->fetchGroupByFilter($groupData, undef, $groupAttrs)
);
return 1;
@@ -523,7 +556,9 @@ sub searchSystems
if (defined $export) {
$_->{export_id} = "$export->{name} ($export->{type})";
}
- $_->{ATTRIBUTES} = $openslxDB->fetchSystemAttrsAsHash($_->{id});
+ # rename attrs to ATTRIBUTES for display
+ $_->{ATTRIBUTES} = $_->{attrs};
+ delete $_->{attrs};
$_;
}
sort { $a->{name} cmp $b->{name} }
diff --git a/config-db/t/01-basics.t b/config-db/t/01-basics.t
index fdc7a052..903783c4 100644
--- a/config-db/t/01-basics.t
+++ b/config-db/t/01-basics.t
@@ -5,6 +5,9 @@ use lib '/opt/openslx/lib';
# basic stuff
use_ok(OpenSLX::ConfigDB);
+use strict;
+use warnings;
+
# connecting and disconnecting
ok(my $configDB = OpenSLX::ConfigDB->new, 'can create object');
isa_ok($configDB, 'OpenSLX::ConfigDB');
diff --git a/config-db/t/10-vendor-os.t b/config-db/t/10-vendor-os.t
index b0754be7..04aa4f2e 100644
--- a/config-db/t/10-vendor-os.t
+++ b/config-db/t/10-vendor-os.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -176,6 +179,9 @@ ok(
is($vendorOS1->{id}, 1, 'really got vendor-OS number 1');
is($vendorOS1->{name}, q{VOS-'1'}, q{really got vendor-OS named "VOS-'1'"});
+# changing nothing at all should succeed
+ok($configDB->changeVendorOS(1), 'changing nothing at all in vendor-OS 1');
+
# changing a non-existing column should fail
ok(
! eval { $configDB->changeVendorOS(1, { xname => "xx" }) },
diff --git a/config-db/t/11-export.t b/config-db/t/11-export.t
index 96fad00b..0cdc688c 100644
--- a/config-db/t/11-export.t
+++ b/config-db/t/11-export.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -223,6 +226,9 @@ ok(
is($export1->{id}, 1, 'really got export number 1');
is($export1->{name}, q{EXP-'1'}, q{really got export named "EXP-'1'"});
+# changing nothing at all should succeed
+ok($configDB->changeExport(1), 'changing nothing at all in export 1');
+
# changing a non-existing column should fail
ok(
! eval { $configDB->changeExport(1, { xname => "xx" }) },
diff --git a/config-db/t/12-system.t b/config-db/t/12-system.t
index ee908dba..7a3e5e1e 100644
--- a/config-db/t/12-system.t
+++ b/config-db/t/12-system.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -35,6 +38,11 @@ my $inSystem1 = {
'name' => 'sys-1',
'export_id' => 1,
'comment' => '',
+ 'attrs' => {
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_nicmods' => 'e1000 forcedeth r8169',
+ 'start_sshd' => 'yes',
+ },
};
is(
my $system1ID = $configDB->addSystem($inSystem1), 1,
@@ -55,10 +63,43 @@ my $fullSystem = {
'label' => 'BlingBling System - really kuul!',
'kernel_params' => 'debug=3 console=ttyS1',
'hidden' => '1',
- 'attr_ramfs_nicmods' => 'e1000 forcedeth',
- 'attr_ramfs_fsmods' => 'squashfs',
- 'attr_ramfs_miscmods' => 'tpm',
- 'attr_ramfs_screen' => '1024x768',
+ 'attrs' => {
+ 'automnt_dir' => 'a',
+ 'automnt_src' => 'b',
+ 'country' => 'c',
+ 'dm_allow_shutdown' => 'd',
+ 'hw_graphic' => 'e',
+ 'hw_monitor' => 'f',
+ 'hw_mouse' => 'g',
+ 'late_dm' => 'h',
+ 'netbios_workgroup' => 'i',
+ 'nis_domain' => 'j',
+ 'nis_servers' => 'k',
+ 'ramfs_fsmods' => 'l',
+ 'ramfs_miscmods' => 'm',
+ 'ramfs_nicmods' => 'n',
+ 'ramfs_screen' => 'o',
+ 'sane_scanner' => 'p',
+ 'scratch' => 'q',
+ 'slxgrp' => 'r',
+ 'start_alsasound' => 's',
+ 'start_atd' => 't',
+ 'start_cron' => 'u',
+ 'start_dreshal' => 'v',
+ 'start_ntp' => 'w',
+ 'start_nfsv4' => 'x',
+ 'start_printer' => 'y',
+ 'start_samba' => 'z',
+ 'start_snmp' => 'A',
+ 'start_sshd' => 'B',
+ 'start_syslog' => 'C',
+ 'start_x' => 'D',
+ 'start_xdmcp' => 'E',
+ 'tex_enable' => 'F',
+ 'timezone' => 'G',
+ 'tvout' => 'H',
+ 'vmware' => 'I',
+ },
};
ok(
my ($system2ID, $system3ID) = $configDB->addSystem([
@@ -79,39 +120,72 @@ is($system3->{comment}, 'nuff said', 'system 3 - comment
is($system3->{label}, 'BlingBling System - really kuul!', 'system 3 - label');
is($system3->{kernel_params}, 'debug=3 console=ttyS1', 'system 3 - kernel_params');
is($system3->{hidden}, '1', 'system 3 - hidden');
-is($system3->{attr_ramfs_nicmods}, 'e1000 forcedeth', 'system 3 - attr_ramfs_nicmods');
-is($system3->{attr_ramfs_fsmods}, 'squashfs', 'system 3 - attr_ramfs_fsmods');
-is($system3->{attr_ramfs_miscmods}, 'tpm', 'system 3 - attr_ramfs_miscmods');
-is($system3->{attr_ramfs_screen}, '1024x768', 'system 3 - attr_ramfs_screen');
+is($system3->{attrs}->{automnt_dir}, 'a', 'system 3 - attr automnt_dir');
+is($system3->{attrs}->{automnt_src}, 'b', 'system 3 - attr automnt_src');
+is($system3->{attrs}->{country}, 'c', 'system 3 - attr country');
+is($system3->{attrs}->{dm_allow_shutdown}, 'd', 'system 3 - attr dm_allow_shutdown');
+is($system3->{attrs}->{hw_graphic}, 'e', 'system 3 - attr hw_graphic');
+is($system3->{attrs}->{hw_monitor}, 'f', 'system 3 - attr hw_monitor');
+is($system3->{attrs}->{hw_mouse}, 'g', 'system 3 - attr hw_mouse');
+is($system3->{attrs}->{late_dm}, 'h', 'system 3 - attr late_dm');
+is($system3->{attrs}->{netbios_workgroup}, 'i', 'system 3 - attr netbios_workgroup');
+is($system3->{attrs}->{nis_domain}, 'j', 'system 3 - attr nis_domain');
+is($system3->{attrs}->{nis_servers}, 'k', 'system 3 - attr nis_servers');
+is($system3->{attrs}->{ramfs_fsmods}, 'l', 'system 3 - attr ramfs_fsmods');
+is($system3->{attrs}->{ramfs_miscmods}, 'm', 'system 3 - attr ramfs_miscmods');
+is($system3->{attrs}->{ramfs_nicmods}, 'n', 'system 3 - attr ramfs_nicmods');
+is($system3->{attrs}->{ramfs_screen}, 'o', 'system 3 - attr ramfs_screen');
+is($system3->{attrs}->{sane_scanner}, 'p', 'system 3 - attr sane_scanner');
+is($system3->{attrs}->{scratch}, 'q', 'system 3 - attr scratch');
+is($system3->{attrs}->{slxgrp}, 'r', 'system 3 - attr slxgrp');
+is($system3->{attrs}->{start_alsasound}, 's', 'system 3 - attr start_alsasound');
+is($system3->{attrs}->{start_atd}, 't', 'system 3 - attr start_atd');
+is($system3->{attrs}->{start_cron}, 'u', 'system 3 - attr start_cron');
+is($system3->{attrs}->{start_dreshal}, 'v', 'system 3 - attr start_dreshal');
+is($system3->{attrs}->{start_ntp}, 'w', 'system 3 - attr start_ftp');
+is($system3->{attrs}->{start_nfsv4}, 'x', 'system 3 - attr start_nfsv4');
+is($system3->{attrs}->{start_printer}, 'y', 'system 3 - attr start_printer');
+is($system3->{attrs}->{start_samba}, 'z', 'system 3 - attr start_samba');
+is($system3->{attrs}->{start_snmp}, 'A', 'system 3 - attr start_snmp');
+is($system3->{attrs}->{start_sshd}, 'B', 'system 3 - attr start_sshd');
+is($system3->{attrs}->{start_syslog}, 'C', 'system 3 - attr start_syslog');
+is($system3->{attrs}->{start_x}, 'D', 'system 3 - attr start_x');
+is($system3->{attrs}->{start_xdmcp}, 'E', 'system 3 - attr start_xdmcp');
+is($system3->{attrs}->{tex_enable}, 'F', 'system 3 - attr tex_enable');
+is($system3->{attrs}->{timezone}, 'G', 'system 3 - attr timezone');
+is($system3->{attrs}->{tvout}, 'H', 'system 3 - attr tvout');
+is($system3->{attrs}->{vmware}, 'I', 'system 3 - attr vmware');
+is(keys %{$system3->{attrs}}, 35, 'system 3 - attribute count');
# fetch system 2 by a filter on id and check all values
ok(
my $system2 = $configDB->fetchSystemByFilter({ id => 2 }),
'fetch system 2 by filter on id'
);
-is($system2->{id}, 2, 'system 2 - id');
-is($system2->{name}, 'sys-2.0', 'system 2 - name');
-is($system2->{kernel}, 'vmlinuz', 'system 2 - kernel');
-is($system2->{export_id}, '1', 'system 2 - export_id');
-is($system2->{comment}, undef, 'system 2 - comment');
+is($system2->{id}, 2, 'system 2 - id');
+is($system2->{name}, 'sys-2.0', 'system 2 - name');
+is($system2->{kernel}, 'vmlinuz', 'system 2 - kernel');
+is($system2->{export_id}, '1', 'system 2 - export_id');
+is($system2->{comment}, undef, 'system 2 - comment');
+is(keys %{$system2->{attrs}}, 0, 'system 2 - attribute count');
# fetch system 1 by filter on name and check all values
ok(
my $system1 = $configDB->fetchSystemByFilter({ name => 'sys-1' }),
'fetch system 1 by filter on name'
);
-is($system1->{id}, 1, 'system 1 - id');
-is($system1->{name}, 'sys-1', 'system 1 - name');
-is($system1->{export_id}, '1', 'system 1 - export_id');
-is($system1->{kernel}, 'vmlinuz', 'system 1 - kernel');
-is($system1->{comment}, '', 'system 1 - comment');
-is($system1->{label}, 'sys-1', 'system 1 - label');
-is($system1->{kernel_params}, undef, 'system 1 - kernel_params');
-is($system1->{hidden}, undef, 'system 1 - hidden');
-is($system1->{attr_ramfs_nicmods}, undef, 'system 1 - attr_ramfs_nicmods');
-is($system1->{attr_ramfs_fsmods}, undef, 'system 1 - attr_ramfs_fsmods');
-is($system1->{attr_ramfs_miscmods}, undef, 'system 1 - attr_ramfs_miscmods');
-is($system1->{attr_ramfs_screen}, undef, 'system 1 - attr_ramfs_screen');
+is($system1->{id}, 1, 'system 1 - id');
+is($system1->{name}, 'sys-1', 'system 1 - name');
+is($system1->{export_id}, '1', 'system 1 - export_id');
+is($system1->{kernel}, 'vmlinuz', 'system 1 - kernel');
+is($system1->{comment}, '', 'system 1 - comment');
+is($system1->{label}, 'sys-1', 'system 1 - label');
+is($system1->{kernel_params}, undef, 'system 1 - kernel_params');
+is($system1->{hidden}, undef, 'system 1 - hidden');
+is(keys %{$system1->{attrs}}, 3, 'system 1 - attribute count');
+is($system1->{attrs}->{ramfs_fsmods}, 'squashfs', 'system 1 - attr ramfs_fsmods');
+is($system1->{attrs}->{ramfs_nicmods}, 'e1000 forcedeth r8169', 'system 1 - attr ramfs_nicmods');
+is($system1->{attrs}->{start_sshd}, 'yes', 'system 1 - attr start_sshd');
# fetch systems 3 & 1 by id
ok(
@@ -148,6 +222,17 @@ is(@systems1And2, 2, 'should have got 2 systems');
is($systems1And2[0]->{id}, 1, 'first id should be 1');
is($systems1And2[1]->{id}, 2, 'second id should be 2');
+# fetch systems 1 & 2 by filter on hidden being undef'd
+ok(
+ @systems1And2 = $configDB->fetchSystemByFilter({ hidden => undef }),
+ 'fetch systems 1 & 2 by filter on hidden being undefined'
+);
+is(@systems1And2, 2, 'should have got 2 systems');
+# now sort by ID and check if we have really got 1 and 2
+@systems1And2 = sort { $a->{id} cmp $b->{id} } @systems1And2;
+is($systems1And2[0]->{id}, 1, 'first id should be 1');
+is($systems1And2[1]->{id}, 2, 'second id should be 2');
+
# try to fetch with multi-column filter
ok(
($system2, $system3)
@@ -169,6 +254,83 @@ is(@systems1And3, 2, 'should have got 2 systems');
is($systems1And3[0]->{id}, 1, 'first id should be 1');
is($systems1And3[1]->{id}, 3, 'second id should be 3');
+# filter systems by different attributes & values in combination
+ok(
+ my @system1Only = $configDB->fetchSystemByFilter( {}, undef, {
+ ramfs_nicmods => 'e1000 forcedeth r8169'
+ } ),
+ 'fetch system 1 by filter on attribute ramfs_nicmods'
+);
+
+is(@system1Only, 1, 'should have got 1 system');
+is($system1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @system1Only = $configDB->fetchSystemByFilter( undef, 'id', {
+ ramfs_nicmods => 'e1000 forcedeth r8169',
+ slxgrp => undef,
+ } ),
+ 'fetch system 1 by filter on attribute ramfs_nicmods'
+);
+is(@system1Only, 1, 'should have got 1 system');
+is($system1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @system1Only = $configDB->fetchSystemByFilter( {
+ export_id => 1,
+ hidden => undef,
+ }, 'id', {
+ ramfs_nicmods => 'e1000 forcedeth r8169',
+ slxgrp => undef,
+ } ),
+ 'fetch system 1 by multiple filter on values and attributes'
+);
+is(@system1Only, 1, 'should have got 1 system');
+is($system1Only[0]->{id}, 1, 'first id should be 1');
+
+is(
+ $configDB->fetchSystemByFilter( {
+ export_id => 2,
+ }, 'id', {
+ ramfs_nicmods => 'e1000 forcedeth r8169',
+ slxgrp => undef,
+ } ),
+ undef,
+ 'mismatch system 1 by filter with incorrect value'
+);
+is(
+ $configDB->fetchSystemByFilter( {
+ export_id => 1,
+ }, 'id', {
+ ramfs_nicmods => 'xxxx',
+ slxgrp => undef,
+ } ),
+ undef,
+ 'mismatch system 1 by filter with incorrect attribute value'
+);
+is(
+ $configDB->fetchSystemByFilter( {
+ name => 'sys-1',
+ }, 'id', {
+ start_sshd => undef,
+ } ),
+ undef,
+ 'mismatch system 1 by filter with attribute not being empty'
+);
+
+# fetch systems 1 & 2 by filter on attribute start_samba not existing
+ok(
+ @systems1And2 = $configDB->fetchSystemByFilter( {}, undef, {
+ start_samba => undef,
+ } ),
+ 'fetch systems 1 & 2 by filter on attribute start_samba not existing'
+);
+is(@systems1And2, 2, 'should have got 2 systems');
+# now sort by ID and check if we have really got 1 and 2
+@systems1And2 = sort { $a->{id} cmp $b->{id} } @systems1And2;
+is($systems1And2[0]->{id}, 1, 'first id should be 1');
+is($systems1And2[1]->{id}, 2, 'second id should be 2');
+
# try to fetch a couple of non-existing systems by id
is(
$configDB->fetchSystemByID(-1), undef,
@@ -203,6 +365,9 @@ ok(
is($system1->{id}, 1, 'really got system number 1');
is($system1->{name}, q{SYS-'1'}, q{really got system named "SYS-'1'"});
+# changing nothing at all should succeed
+ok($configDB->changeSystem(1), 'changing nothing at all in system 1');
+
# changing a non-existing column should fail
ok(
! eval { $configDB->changeSystem(1, { xname => "xx" }) },
diff --git a/config-db/t/13-client.t b/config-db/t/13-client.t
index 70ed569c..5848ba53 100644
--- a/config-db/t/13-client.t
+++ b/config-db/t/13-client.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -35,6 +38,11 @@ my $inClient1 = {
'name' => 'cli-1',
'mac' => '01:02:03:04:05:01',
'comment' => '',
+ 'attrs' => {
+ 'slxgrp' => 'slxgrp',
+ 'start_snmp' => 'no',
+ 'start_sshd' => 'yes',
+ },
};
is(
my $client1ID = $configDB->addClient($inClient1), 1,
@@ -55,6 +63,39 @@ my $fullClient = {
'kernel_params' => 'debug=3 console=ttyS1',
'unbootable' => '0',
'boot_type' => 'pxe',
+ 'attrs' => {
+ 'automnt_dir' => 'a',
+ 'automnt_src' => 'b',
+ 'country' => 'c',
+ 'dm_allow_shutdown' => 'd',
+ 'hw_graphic' => 'e',
+ 'hw_monitor' => 'f',
+ 'hw_mouse' => 'g',
+ 'late_dm' => 'h',
+ 'netbios_workgroup' => 'i',
+ 'nis_domain' => 'j',
+ 'nis_servers' => 'k',
+ 'sane_scanner' => 'p',
+ 'scratch' => 'q',
+ 'slxgrp' => 'r',
+ 'start_alsasound' => 's',
+ 'start_atd' => 't',
+ 'start_cron' => 'u',
+ 'start_dreshal' => 'v',
+ 'start_ntp' => 'w',
+ 'start_nfsv4' => 'x',
+ 'start_printer' => 'y',
+ 'start_samba' => 'z',
+ 'start_snmp' => 'A',
+ 'start_sshd' => 'B',
+ 'start_syslog' => 'C',
+ 'start_x' => 'D',
+ 'start_xdmcp' => 'E',
+ 'tex_enable' => 'F',
+ 'timezone' => 'G',
+ 'tvout' => 'H',
+ 'vmware' => 'I',
+ },
};
ok(
my ($client2ID, $client3ID) = $configDB->addClient([
@@ -74,18 +115,51 @@ is($client3->{comment}, 'nuff said', 'client 3 - comment');
is($client3->{boot_type}, 'pxe', 'client 3 - boot_type');
is($client3->{kernel_params}, 'debug=3 console=ttyS1', 'client 3 - kernel_params');
is($client3->{unbootable}, '0', 'client 3 - unbootable');
+is($client3->{attrs}->{automnt_dir}, 'a', 'client 3 - attr automnt_dir');
+is($client3->{attrs}->{automnt_src}, 'b', 'client 3 - attr automnt_src');
+is($client3->{attrs}->{country}, 'c', 'client 3 - attr country');
+is($client3->{attrs}->{dm_allow_shutdown}, 'd', 'client 3 - attr dm_allow_shutdown');
+is($client3->{attrs}->{hw_graphic}, 'e', 'client 3 - attr hw_graphic');
+is($client3->{attrs}->{hw_monitor}, 'f', 'client 3 - attr hw_monitor');
+is($client3->{attrs}->{hw_mouse}, 'g', 'client 3 - attr hw_mouse');
+is($client3->{attrs}->{late_dm}, 'h', 'client 3 - attr late_dm');
+is($client3->{attrs}->{netbios_workgroup}, 'i', 'client 3 - attr netbios_workgroup');
+is($client3->{attrs}->{nis_domain}, 'j', 'client 3 - attr nis_domain');
+is($client3->{attrs}->{nis_servers}, 'k', 'client 3 - attr nis_servers');
+is($client3->{attrs}->{sane_scanner}, 'p', 'client 3 - attr sane_scanner');
+is($client3->{attrs}->{scratch}, 'q', 'client 3 - attr scratch');
+is($client3->{attrs}->{slxgrp}, 'r', 'client 3 - attr slxgrp');
+is($client3->{attrs}->{start_alsasound}, 's', 'client 3 - attr start_alsasound');
+is($client3->{attrs}->{start_atd}, 't', 'client 3 - attr start_atd');
+is($client3->{attrs}->{start_cron}, 'u', 'client 3 - attr start_cron');
+is($client3->{attrs}->{start_dreshal}, 'v', 'client 3 - attr start_dreshal');
+is($client3->{attrs}->{start_ntp}, 'w', 'client 3 - attr start_ftp');
+is($client3->{attrs}->{start_nfsv4}, 'x', 'client 3 - attr start_nfsv4');
+is($client3->{attrs}->{start_printer}, 'y', 'client 3 - attr start_printer');
+is($client3->{attrs}->{start_samba}, 'z', 'client 3 - attr start_samba');
+is($client3->{attrs}->{start_snmp}, 'A', 'client 3 - attr start_snmp');
+is($client3->{attrs}->{start_sshd}, 'B', 'client 3 - attr start_sshd');
+is($client3->{attrs}->{start_syslog}, 'C', 'client 3 - attr start_syslog');
+is($client3->{attrs}->{start_x}, 'D', 'client 3 - attr start_x');
+is($client3->{attrs}->{start_xdmcp}, 'E', 'client 3 - attr start_xdmcp');
+is($client3->{attrs}->{tex_enable}, 'F', 'client 3 - attr tex_enable');
+is($client3->{attrs}->{timezone}, 'G', 'client 3 - attr timezone');
+is($client3->{attrs}->{tvout}, 'H', 'client 3 - attr tvout');
+is($client3->{attrs}->{vmware}, 'I', 'client 3 - attr vmware');
+is(keys %{$client3->{attrs}}, 31, 'client 3 - attribute count');
# fetch client 2 by a filter on id and check all values
ok(
my $client2 = $configDB->fetchClientByFilter({ id => 2 }),
'fetch client 2 by filter on id'
);
-is($client2->{id}, 2, 'client 2 - id');
-is($client2->{name}, 'cli-2.0', 'client 2 - name');
-is($client2->{unbootable}, '1', 'client 2 - unbootable');
-is($client2->{mac}, '01:02:03:04:05:02', 'client 2 - mac');
-is($client2->{comment}, undef, 'client 2 - comment');
-is($client2->{boot_type}, 'etherboot', 'client 2 - boot_type');
+is($client2->{id}, 2, 'client 2 - id');
+is($client2->{name}, 'cli-2.0', 'client 2 - name');
+is($client2->{unbootable}, '1', 'client 2 - unbootable');
+is($client2->{mac}, '01:02:03:04:05:02', 'client 2 - mac');
+is($client2->{comment}, undef, 'client 2 - comment');
+is($client2->{boot_type}, 'etherboot', 'client 2 - boot_type');
+is(keys %{$client2->{attrs}}, 0, 'client 2 - attribute count');
# fetch client 1 by filter on name and check all values
ok(
@@ -99,6 +173,10 @@ is($client1->{unbootable}, undef, 'client 1 - unbootable');
is($client1->{comment}, '', 'client 1 - comment');
is($client1->{boot_type}, 'pxe', 'client 1 - boot_type');
is($client1->{kernel_params}, undef, 'client 1 - kernel_params');
+is(keys %{$client1->{attrs}}, 3, 'client 1 - attribute count');
+is($client1->{attrs}->{slxgrp}, 'slxgrp', 'client 1 - attr slxgrp');
+is($client1->{attrs}->{start_snmp}, 'no', 'client 1 - attr start_snmp');
+is($client1->{attrs}->{start_sshd}, 'yes', 'client 1 - attr start_sshd');
# fetch clients 3 & 1 by id
ok(
@@ -144,6 +222,14 @@ ok(
is($client1->{name}, 'cli-1', 'should have got cli-1');
is($client3, undef, 'should not get cli-nr-3');
+# fetch client 1 by filter on unbootable being undef'd
+ok(
+ my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }),
+ 'fetch client 1 by filter on unbootable being undefined'
+);
+is(@client1Only, 1, 'should have got 1 client');
+is($client1Only[0]->{id}, 1, 'first id should be 1');
+
# try to fetch multiple occurrences of the same client, combined with
# some unknown IDs
ok(
@@ -156,6 +242,84 @@ is(@clients1And3, 2, 'should have got 2 clients');
is($clients1And3[0]->{id}, 1, 'first id should be 1');
is($clients1And3[1]->{id}, 3, 'second id should be 3');
+# filter clients by different attributes & values in combination
+ok(
+ @client1Only = $configDB->fetchClientByFilter( {}, undef, {
+ start_snmp => 'no',
+ } ),
+ 'fetch client 1 by filter on attribute start_snmp'
+);
+
+is(@client1Only, 1, 'should have got 1 client');
+is($client1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @client1Only = $configDB->fetchClientByFilter( undef, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ 'fetch client 1 by filter on attribute start_snmp + non-existing attr'
+);
+is(@client1Only, 1, 'should have got 1 client');
+is($client1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @client1Only = $configDB->fetchClientByFilter( {
+ name => 'cli-1',
+ unbootable => undef,
+ }, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ 'fetch client 1 by multiple filter on values and attributes'
+);
+is(@client1Only, 1, 'should have got 1 client');
+is($client1Only[0]->{id}, 1, 'first id should be 1');
+
+is(
+ $configDB->fetchClientByFilter( {
+ comment => 'xxx',
+ }, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ undef,
+ 'mismatch client 1 by filter with incorrect value'
+);
+is(
+ $configDB->fetchClientByFilter( {
+ name => 'cli-1',
+ }, 'id', {
+ start_snmp => 'yes',
+ tex_enable => undef,
+ } ),
+ undef,
+ 'mismatch client 1 by filter with incorrect attribute value'
+);
+is(
+ $configDB->fetchClientByFilter( {
+ name => 'cli-1',
+ }, 'id', {
+ start_sshd => undef,
+ } ),
+ undef,
+ 'mismatch client 1 by filter with attribute not being empty'
+);
+
+# fetch clients 0, 1 & 2 by filter on attribute start_samba not existing
+ok(
+ my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, {
+ start_samba => undef,
+ } ),
+ 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing'
+);
+is(@clients01And2, 3, 'should have got 3 clients');
+# now sort by ID and check if we have really got 0, 1 and 2
+@clients01And2 = sort { $a->{id} cmp $b->{id} } @clients01And2;
+is($clients01And2[0]->{id}, 0, 'first id should be 0');
+is($clients01And2[1]->{id}, 1, 'second id should be 1');
+is($clients01And2[2]->{id}, 2, 'third id should be 2');
+
# try to fetch a couple of non-existing clients by id
is(
$configDB->fetchClientByID(-1), undef,
@@ -190,6 +354,9 @@ ok(
is($client1->{id}, 1, 'really got client number 1');
is($client1->{name}, q{CLI-'1'}, q{really got client named "CLI-'1'"});
+# changing nothing at all should succeed
+ok($configDB->changeClient(1), 'changing nothing at all in client 1');
+
# changing a non-existing column should fail
ok(
! eval { $configDB->changeClient(1, { xname => "xx" }) },
diff --git a/config-db/t/14-group.t b/config-db/t/14-group.t
index 70831a5e..59530257 100644
--- a/config-db/t/14-group.t
+++ b/config-db/t/14-group.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -34,6 +37,11 @@ is(
my $inGroup1 = {
'name' => 'grp-1',
'comment' => '',
+ 'attrs' => {
+ 'slxgrp' => 'slxgrp',
+ 'start_snmp' => 'no',
+ 'start_sshd' => 'yes',
+ },
};
is(
my $group1ID = $configDB->addGroup($inGroup1), 1,
@@ -49,6 +57,39 @@ my $fullGroup = {
'name' => 'grp-nr-3',
'priority' => 50,
'comment' => 'nuff said',
+ 'attrs' => {
+ 'automnt_dir' => 'a',
+ 'automnt_src' => 'b',
+ 'country' => 'c',
+ 'dm_allow_shutdown' => 'd',
+ 'hw_graphic' => 'e',
+ 'hw_monitor' => 'f',
+ 'hw_mouse' => 'g',
+ 'late_dm' => 'h',
+ 'netbios_workgroup' => 'i',
+ 'nis_domain' => 'j',
+ 'nis_servers' => 'k',
+ 'sane_scanner' => 'p',
+ 'scratch' => 'q',
+ 'slxgrp' => 'r',
+ 'start_alsasound' => 's',
+ 'start_atd' => 't',
+ 'start_cron' => 'u',
+ 'start_dreshal' => 'v',
+ 'start_ntp' => 'w',
+ 'start_nfsv4' => 'x',
+ 'start_printer' => 'y',
+ 'start_samba' => 'z',
+ 'start_snmp' => 'A',
+ 'start_sshd' => 'B',
+ 'start_syslog' => 'C',
+ 'start_x' => 'D',
+ 'start_xdmcp' => 'E',
+ 'tex_enable' => 'F',
+ 'timezone' => 'G',
+ 'tvout' => 'H',
+ 'vmware' => 'I',
+ },
};
ok(
my ($group2ID, $group3ID) = $configDB->addGroup([
@@ -61,10 +102,42 @@ is($group3ID, 3, 'group 3 should have ID=3');
# fetch group 3 by id and check all values
ok(my $group3 = $configDB->fetchGroupByID(3), 'fetch group 3');
-is($group3->{id}, '3', 'group 3 - id');
-is($group3->{name}, 'grp-nr-3', 'group 3 - name');
-is($group3->{priority}, 50, 'group 3 - priority');
-is($group3->{comment}, 'nuff said', 'group 3 - comment');
+is($group3->{id}, '3', 'group 3 - id');
+is($group3->{name}, 'grp-nr-3', 'group 3 - name');
+is($group3->{priority}, 50, 'group 3 - priority');
+is($group3->{comment}, 'nuff said', 'group 3 - comment');
+is($group3->{attrs}->{automnt_dir}, 'a', 'group 3 - attr automnt_dir');
+is($group3->{attrs}->{automnt_src}, 'b', 'group 3 - attr automnt_src');
+is($group3->{attrs}->{country}, 'c', 'group 3 - attr country');
+is($group3->{attrs}->{dm_allow_shutdown}, 'd', 'group 3 - attr dm_allow_shutdown');
+is($group3->{attrs}->{hw_graphic}, 'e', 'group 3 - attr hw_graphic');
+is($group3->{attrs}->{hw_monitor}, 'f', 'group 3 - attr hw_monitor');
+is($group3->{attrs}->{hw_mouse}, 'g', 'group 3 - attr hw_mouse');
+is($group3->{attrs}->{late_dm}, 'h', 'group 3 - attr late_dm');
+is($group3->{attrs}->{netbios_workgroup}, 'i', 'group 3 - attr netbios_workgroup');
+is($group3->{attrs}->{nis_domain}, 'j', 'group 3 - attr nis_domain');
+is($group3->{attrs}->{nis_servers}, 'k', 'group 3 - attr nis_servers');
+is($group3->{attrs}->{sane_scanner}, 'p', 'group 3 - attr sane_scanner');
+is($group3->{attrs}->{scratch}, 'q', 'group 3 - attr scratch');
+is($group3->{attrs}->{slxgrp}, 'r', 'group 3 - attr slxgrp');
+is($group3->{attrs}->{start_alsasound}, 's', 'group 3 - attr start_alsasound');
+is($group3->{attrs}->{start_atd}, 't', 'group 3 - attr start_atd');
+is($group3->{attrs}->{start_cron}, 'u', 'group 3 - attr start_cron');
+is($group3->{attrs}->{start_dreshal}, 'v', 'group 3 - attr start_dreshal');
+is($group3->{attrs}->{start_ntp}, 'w', 'group 3 - attr start_ftp');
+is($group3->{attrs}->{start_nfsv4}, 'x', 'group 3 - attr start_nfsv4');
+is($group3->{attrs}->{start_printer}, 'y', 'group 3 - attr start_printer');
+is($group3->{attrs}->{start_samba}, 'z', 'group 3 - attr start_samba');
+is($group3->{attrs}->{start_snmp}, 'A', 'group 3 - attr start_snmp');
+is($group3->{attrs}->{start_sshd}, 'B', 'group 3 - attr start_sshd');
+is($group3->{attrs}->{start_syslog}, 'C', 'group 3 - attr start_syslog');
+is($group3->{attrs}->{start_x}, 'D', 'group 3 - attr start_x');
+is($group3->{attrs}->{start_xdmcp}, 'E', 'group 3 - attr start_xdmcp');
+is($group3->{attrs}->{tex_enable}, 'F', 'group 3 - attr tex_enable');
+is($group3->{attrs}->{timezone}, 'G', 'group 3 - attr timezone');
+is($group3->{attrs}->{tvout}, 'H', 'group 3 - attr tvout');
+is($group3->{attrs}->{vmware}, 'I', 'group 3 - attr vmware');
+is(keys %{$group3->{attrs}}, 31, 'group 3 - attribute count');
# fetch group 2 by a filter on id and check all values
ok(
@@ -75,16 +148,21 @@ is($group2->{id}, 2, 'group 2 - id');
is($group2->{name}, 'grp-2.0', 'group 2 - name');
is($group2->{priority}, 30, 'group 2 - priority');
is($group2->{comment}, undef, 'group 2 - comment');
+is(keys %{$group2->{attrs}}, 0, 'group 2 - attribute count');
# fetch group 1 by filter on name and check all values
ok(
my $group1 = $configDB->fetchGroupByFilter({ name => 'grp-1' }),
'fetch group 1 by filter on name'
);
-is($group1->{id}, 1, 'group 1 - id');
-is($group1->{name}, 'grp-1', 'group 1 - name');
-is($group1->{priority}, 50, 'group 1 - priority');
-is($group1->{comment}, '', 'group 1 - comment');
+is($group1->{id}, 1, 'group 1 - id');
+is($group1->{name}, 'grp-1', 'group 1 - name');
+is($group1->{priority}, 50, 'group 1 - priority');
+is($group1->{comment}, '', 'group 1 - comment');
+is(keys %{$group1->{attrs}}, 3, 'group 1 - attribute count');
+is($group1->{attrs}->{slxgrp}, 'slxgrp', 'group 1 - attr slxgrp');
+is($group1->{attrs}->{start_snmp}, 'no', 'group 1 - attr start_snmp');
+is($group1->{attrs}->{start_sshd}, 'yes', 'group 1 - attr start_sshd');
# fetch groups 3 & 1 by id
ok(
@@ -121,6 +199,14 @@ is(@groups1And3, 2, 'should have got 2 groups');
is($groups1And3[0]->{id}, 1, 'first id should be 1');
is($groups1And3[1]->{id}, 3, 'second id should be 3');
+# fetch group 2 by filter on comment being undef'd
+ok(
+ my @group2Only = $configDB->fetchGroupByFilter({ comment => undef }),
+ 'fetch group 2 by filter on comment being undefined'
+);
+is(@group2Only, 1, 'should have got 1 group');
+is($group2Only[0]->{id}, 2, 'first id should be 2');
+
# try to fetch with multi-column filter
ok(
($group1, $group3)
@@ -142,6 +228,83 @@ is(@groups1And3, 2, 'should have got 2 groups');
is($groups1And3[0]->{id}, 1, 'first id should be 1');
is($groups1And3[1]->{id}, 3, 'second id should be 3');
+# filter groups by different attributes & values in combination
+ok(
+ my @group1Only = $configDB->fetchGroupByFilter( {}, undef, {
+ start_snmp => 'no',
+ } ),
+ 'fetch group 1 by filter on attribute start_snmp'
+);
+
+is(@group1Only, 1, 'should have got 1 group');
+is($group1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @group1Only = $configDB->fetchGroupByFilter( undef, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ 'fetch group 1 by filter on attribute start_snmp + non-existing attr'
+);
+is(@group1Only, 1, 'should have got 1 group');
+is($group1Only[0]->{id}, 1, 'first id should be 1');
+
+ok(
+ @group1Only = $configDB->fetchGroupByFilter( {
+ name => 'grp-1',
+ priority => 50,
+ }, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ 'fetch group 1 by multiple filter on values and attributes'
+);
+is(@group1Only, 1, 'should have got 1 group');
+is($group1Only[0]->{id}, 1, 'first id should be 1');
+
+is(
+ $configDB->fetchGroupByFilter( {
+ comment => 'xxx',
+ }, 'id', {
+ start_snmp => 'no',
+ tex_enable => undef,
+ } ),
+ undef,
+ 'mismatch group 1 by filter with incorrect value'
+);
+is(
+ $configDB->fetchGroupByFilter( {
+ name => 'grp-1',
+ }, 'id', {
+ start_snmp => 'yes',
+ tex_enable => undef,
+ } ),
+ undef,
+ 'mismatch group 1 by filter with incorrect attribute value'
+);
+is(
+ $configDB->fetchGroupByFilter( {
+ name => 'grp-1',
+ }, 'id', {
+ start_sshd => undef,
+ } ),
+ undef,
+ 'mismatch group 1 by filter with attribute not being empty'
+);
+
+# fetch groups 1 & 2 by filter on attribute start_samba not existing
+ok(
+ my @groups1And2 = $configDB->fetchGroupByFilter( {}, undef, {
+ start_samba => undef,
+ } ),
+ 'fetch groups 1 & 2 by filter on attribute start_samba not existing'
+);
+is(@groups1And2, 2, 'should have got 2 groups');
+# now sort by ID and check if we have really got 1 and 2
+@groups1And2 = sort { $a->{id} cmp $b->{id} } @groups1And2;
+is($groups1And2[0]->{id}, 1, 'first id should be 1');
+is($groups1And2[1]->{id}, 2, 'second id should be 2');
+
# try to fetch a couple of non-existing groups by id
is($configDB->fetchGroupByID(-1), undef, 'group with id -1 should not exist');
is($configDB->fetchGroupByID(0), undef, 'group with id 0 should not exist');
@@ -173,6 +336,9 @@ ok(
is($group1->{id}, 1, 'really got group number 1');
is($group1->{name}, q{GRP-'1'}, q{really got group named "GRP-'1'"});
+# changing nothing at all should succeed
+ok($configDB->changeGroup(1), 'changing nothing at all in group 1');
+
# changing a non-existing column should fail
ok(
! eval { $configDB->changeGroup(1, { xname => "xx" }) },
diff --git a/config-db/t/15-global_info.t b/config-db/t/15-global_info.t
index 82c04997..628b2495 100644
--- a/config-db/t/15-global_info.t
+++ b/config-db/t/15-global_info.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -10,7 +13,7 @@ $configDB->connect();
# fetch global-info 'next-nbd-server-port'
ok(
- $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'),
+ my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'),
'fetch global-info'
);
is($globalInfo, '5000', 'global-info - value');
diff --git a/config-db/t/20-client_system_ref.t b/config-db/t/20-client_system_ref.t
index 646050e3..46e56ddf 100644
--- a/config-db/t/20-client_system_ref.t
+++ b/config-db/t/20-client_system_ref.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -40,7 +43,7 @@ ok(
'system-ID 3 has been associated to client 1'
);
is(
- @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ my @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)),
0, "default client should have no system-ID"
);
is(
@@ -53,7 +56,7 @@ is(
0, "client 3 should have no system-ID"
);
is(
- @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)),
+ my @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)),
0, "default system should have no client-IDs"
);
is(
diff --git a/config-db/t/21-group_system_ref.t b/config-db/t/21-group_system_ref.t
index e9023feb..6f92a8dd 100644
--- a/config-db/t/21-group_system_ref.t
+++ b/config-db/t/21-group_system_ref.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -39,7 +42,7 @@ ok(
'system-ID 3 has been associated to group 1'
);
is(
- @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)),
+ my @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)),
1, "group 1 should have one system-ID"
);
is($systemIDs[0], 3, "first system of group 1 should have ID 3");
@@ -48,7 +51,7 @@ is(
0, "group 3 should have no system-ID"
);
is(
- @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)),
+ my @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)),
0, "default system should have no group-IDs"
);
is(
diff --git a/config-db/t/22-group_client_ref.t b/config-db/t/22-group_client_ref.t
index 240fcd61..d330bc23 100644
--- a/config-db/t/22-group_client_ref.t
+++ b/config-db/t/22-group_client_ref.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -39,7 +42,7 @@ ok(
'client-ID 3 has been associated to group 1'
);
is(
- @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)),
+ my @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)),
1, "group 1 should have one client-ID"
);
is($clientIDs[0], 3, "first client of group 1 should have ID 3");
@@ -48,7 +51,7 @@ is(
0, "group 3 should have no client-ID"
);
is(
- @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)),
+ my @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)),
0, "default client should have no group-IDs"
);
is(
diff --git a/config-db/t/25-attributes.t b/config-db/t/25-attributes.t
index fe684679..ce83d037 100644
--- a/config-db/t/25-attributes.t
+++ b/config-db/t/25-attributes.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init
@@ -9,114 +12,114 @@ my $configDB = OpenSLX::ConfigDB->new;
$configDB->connect();
my $defaultAttrs = { # mostly copied from DBSchema
- 'attr_ramfs_fsmods' => '',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => 'de',
- 'attr_dm_allow_shutdown' => 'user',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => 'no',
- 'attr_netbios_workgroup' => 'slx-network',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => 'yes',
- 'attr_start_atd' => 'no',
- 'attr_start_cron' => 'no',
- 'attr_start_dreshal' => 'yes',
- 'attr_start_ntp' => 'initial',
- 'attr_start_nfsv4' => 'no',
- 'attr_start_printer' => 'no',
- 'attr_start_samba' => 'may',
- 'attr_start_snmp' => 'no',
- 'attr_start_sshd' => 'yes',
- 'attr_start_syslog' => 'yes',
- 'attr_start_x' => 'yes',
- 'attr_start_xdmcp' => 'kdm',
- 'attr_tex_enable' => 'no',
- 'attr_timezone' => 'Europe/Berlin',
- 'attr_tvout' => 'no',
- 'attr_vmware' => 'no',
+ 'ramfs_fsmods' => '',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '',
+ 'slxgrp' => '',
+ 'start_alsasound' => 'yes',
+ 'start_atd' => 'no',
+ 'start_cron' => 'no',
+ 'start_dreshal' => 'yes',
+ 'start_ntp' => 'initial',
+ 'start_nfsv4' => 'no',
+ 'start_printer' => 'no',
+ 'start_samba' => 'may',
+ 'start_snmp' => 'no',
+ 'start_sshd' => 'yes',
+ 'start_syslog' => 'yes',
+ 'start_x' => 'yes',
+ 'start_xdmcp' => 'kdm',
+ 'tex_enable' => 'no',
+ 'timezone' => 'Europe/Berlin',
+ 'tvout' => 'no',
+ 'vmware' => 'no',
};
ok(
- $configDB->changeSystem(0, $defaultAttrs),
+ $configDB->changeSystem(0, { attrs => $defaultAttrs } ),
'attributes of default system have been set'
);
my $defaultSystem = $configDB->fetchSystemByID(0);
my $system1 = $configDB->fetchSystemByID(1);
my $sys1Attrs = {
- 'attr_ramfs_fsmods' => 'squashfs',
- 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169',
- 'attr_start_x' => 'no',
- 'attr_start_xdmcp' => '',
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+ 'start_x' => 'no',
+ 'start_xdmcp' => '',
};
ok(
- $configDB->changeSystem(1, $sys1Attrs),
+ $configDB->changeSystem(1, { attrs => $sys1Attrs } ),
'attributes of system 1 have been set'
);
my $system3 = $configDB->fetchSystemByID(3);
my $sys3Attrs = {
- 'attr_ramfs_fsmods' => '-4',
- 'attr_ramfs_miscmods' => '-3',
- 'attr_ramfs_nicmods' => '-2',
- 'attr_ramfs_screen' => '-1',
-
- 'attr_automnt_dir' => '1',
- 'attr_automnt_src' => '2',
- 'attr_country' => '3',
- 'attr_dm_allow_shutdown' => '4',
- 'attr_hw_graphic' => '5',
- 'attr_hw_monitor' => '6',
- 'attr_hw_mouse' => '7',
- 'attr_late_dm' => '8',
- 'attr_netbios_workgroup' => '9',
- 'attr_nis_domain' => '10',
- 'attr_nis_servers' => '11',
- 'attr_sane_scanner' => '12',
- 'attr_scratch' => '13',
- 'attr_slxgrp' => '14',
- 'attr_start_alsasound' => '15',
- 'attr_start_atd' => '16',
- 'attr_start_cron' => '17',
- 'attr_start_dreshal' => '18',
- 'attr_start_ntp' => '19',
- 'attr_start_nfsv4' => '20',
- 'attr_start_printer' => '21',
- 'attr_start_samba' => '22',
- 'attr_start_snmp' => '23',
- 'attr_start_sshd' => '24',
- 'attr_start_syslog' => '25',
- 'attr_start_x' => '26',
- 'attr_start_xdmcp' => '27',
- 'attr_tex_enable' => '28',
- 'attr_timezone' => '29',
- 'attr_tvout' => '30',
- 'attr_vmware' => '31',
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+ 'ramfs_screen' => '-1',
+
+ 'automnt_dir' => '1',
+ 'automnt_src' => '2',
+ 'country' => '3',
+ 'dm_allow_shutdown' => '4',
+ 'hw_graphic' => '5',
+ 'hw_monitor' => '6',
+ 'hw_mouse' => '7',
+ 'late_dm' => '8',
+ 'netbios_workgroup' => '9',
+ 'nis_domain' => '10',
+ 'nis_servers' => '11',
+ 'sane_scanner' => '12',
+ 'scratch' => '13',
+ 'slxgrp' => '14',
+ 'start_alsasound' => '15',
+ 'start_atd' => '16',
+ 'start_cron' => '17',
+ 'start_dreshal' => '18',
+ 'start_ntp' => '19',
+ 'start_nfsv4' => '20',
+ 'start_printer' => '21',
+ 'start_samba' => '22',
+ 'start_snmp' => '23',
+ 'start_sshd' => '24',
+ 'start_syslog' => '25',
+ 'start_x' => '26',
+ 'start_xdmcp' => '27',
+ 'tex_enable' => '28',
+ 'timezone' => '29',
+ 'tvout' => '30',
+ 'vmware' => '31',
};
ok(
- $configDB->changeSystem(3, $sys3Attrs),
+ $configDB->changeSystem(3, { attrs => $sys3Attrs } ),
'attributes of system 3 have been set'
);
my $defaultClient = $configDB->fetchClientByID(0);
my $defaultClientAttrs = {
# pretend the whole computer centre has been warped to London ;-)
- 'attr_timezone' => 'Europe/London',
+ 'timezone' => 'Europe/London',
# pretend we wanted to activate snmp globally (e.g. for testing)
- 'attr_start_snmp' => 'yes',
+ 'start_snmp' => 'yes',
};
ok(
- $configDB->changeClient(0, $defaultClientAttrs),
+ $configDB->changeClient(0, { attrs => $defaultClientAttrs } ),
'attributes of default client have been set'
);
@@ -124,42 +127,42 @@ ok(
# default system attributes overruled by system attributes overruled by
# default client attributes:
my $shouldBeAttrs1 = {
- 'attr_ramfs_fsmods' => 'squashfs',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => 'de',
- 'attr_dm_allow_shutdown' => 'user',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => 'no',
- 'attr_netbios_workgroup' => 'slx-network',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => 'yes',
- 'attr_start_atd' => 'no',
- 'attr_start_cron' => 'no',
- 'attr_start_dreshal' => 'yes',
- 'attr_start_ntp' => 'initial',
- 'attr_start_nfsv4' => 'no',
- 'attr_start_printer' => 'no',
- 'attr_start_samba' => 'may',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => 'yes',
- 'attr_start_syslog' => 'yes',
- 'attr_start_x' => 'no',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => 'no',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => 'no',
- 'attr_vmware' => 'no',
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '',
+ 'slxgrp' => '',
+ 'start_alsasound' => 'yes',
+ 'start_atd' => 'no',
+ 'start_cron' => 'no',
+ 'start_dreshal' => 'yes',
+ 'start_ntp' => 'initial',
+ 'start_nfsv4' => 'no',
+ 'start_printer' => 'no',
+ 'start_samba' => 'may',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => 'yes',
+ 'start_syslog' => 'yes',
+ 'start_x' => 'no',
+ 'start_xdmcp' => '',
+ 'tex_enable' => 'no',
+ 'timezone' => 'Europe/London',
+ 'tvout' => 'no',
+ 'vmware' => 'no',
};
my $mergedSystem1 = $configDB->fetchSystemByID(1);
ok(
@@ -168,49 +171,49 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $mergedSystem1->{$key} || '', $shouldBeAttrs1->{$key} || '',
+ $mergedSystem1->{attrs}->{$key}, $shouldBeAttrs1->{$key},
"checking merged attribute $key for system 1"
);
}
# check merging code for completeness (using all attributes):
my $shouldBeAttrs3 = {
- 'attr_ramfs_fsmods' => '-4',
- 'attr_ramfs_miscmods' => '-3',
- 'attr_ramfs_nicmods' => '-2',
- 'attr_ramfs_screen' => '-1',
-
- 'attr_automnt_dir' => '1',
- 'attr_automnt_src' => '2',
- 'attr_country' => '3',
- 'attr_dm_allow_shutdown' => '4',
- 'attr_hw_graphic' => '5',
- 'attr_hw_monitor' => '6',
- 'attr_hw_mouse' => '7',
- 'attr_late_dm' => '8',
- 'attr_netbios_workgroup' => '9',
- 'attr_nis_domain' => '10',
- 'attr_nis_servers' => '11',
- 'attr_sane_scanner' => '12',
- 'attr_scratch' => '13',
- 'attr_slxgrp' => '14',
- 'attr_start_alsasound' => '15',
- 'attr_start_atd' => '16',
- 'attr_start_cron' => '17',
- 'attr_start_dreshal' => '18',
- 'attr_start_ntp' => '19',
- 'attr_start_nfsv4' => '20',
- 'attr_start_printer' => '21',
- 'attr_start_samba' => '22',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '24',
- 'attr_start_syslog' => '25',
- 'attr_start_x' => '26',
- 'attr_start_xdmcp' => '27',
- 'attr_tex_enable' => '28',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => '30',
- 'attr_vmware' => '31',
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+ 'ramfs_screen' => '-1',
+
+ 'automnt_dir' => '1',
+ 'automnt_src' => '2',
+ 'country' => '3',
+ 'dm_allow_shutdown' => '4',
+ 'hw_graphic' => '5',
+ 'hw_monitor' => '6',
+ 'hw_mouse' => '7',
+ 'late_dm' => '8',
+ 'netbios_workgroup' => '9',
+ 'nis_domain' => '10',
+ 'nis_servers' => '11',
+ 'sane_scanner' => '12',
+ 'scratch' => '13',
+ 'slxgrp' => '14',
+ 'start_alsasound' => '15',
+ 'start_atd' => '16',
+ 'start_cron' => '17',
+ 'start_dreshal' => '18',
+ 'start_ntp' => '19',
+ 'start_nfsv4' => '20',
+ 'start_printer' => '21',
+ 'start_samba' => '22',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '24',
+ 'start_syslog' => '25',
+ 'start_x' => '26',
+ 'start_xdmcp' => '27',
+ 'tex_enable' => '28',
+ 'timezone' => 'Europe/London',
+ 'tvout' => '30',
+ 'vmware' => '31',
};
my $mergedSystem3 = $configDB->fetchSystemByID(3);
ok(
@@ -219,7 +222,7 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs3) {
is(
- $mergedSystem3->{$key}, $shouldBeAttrs3->{$key},
+ $mergedSystem3->{attrs}->{$key}, $shouldBeAttrs3->{$key},
"checking merged attribute $key for system 3"
);
}
@@ -229,34 +232,34 @@ my $group1 = $configDB->fetchGroupByID(1);
my $group1Attrs = {
'priority' => '50',
# this group of clients is connected via underwater cable ...
- 'attr_timezone' => 'America/New_York',
+ 'timezone' => 'America/New_York',
# ... and use a local scratch partition
- 'attr_scratch' => '/dev/sdd1',
+ 'scratch' => '/dev/sdd1',
# the following should be a noop (as that attribute is system-specific)
-# 'attr_ramfs_nicmods' => 'e1000',
+# 'ramfs_nicmods' => 'e1000',
};
ok(
- $configDB->changeGroup(1, $group1Attrs),
+ $configDB->changeGroup(1, { attrs => $group1Attrs } ),
'attributes of group 1 have been set'
);
my $group3 = $configDB->fetchGroupByID(3);
my $group3Attrs = {
'priority' => '30',
# this specific client group is older and thus has a different scratch
- 'attr_scratch' => '/dev/hdd1',
- 'attr_vmware' => 'yes',
+ 'scratch' => '/dev/hdd1',
+ 'vmware' => 'yes',
};
ok(
- $configDB->changeGroup(3, $group3Attrs),
+ $configDB->changeGroup(3, { attrs => $group3Attrs } ),
'attributes of group 3 have been set'
);
my $client1 = $configDB->fetchClientByID(1);
my $client1Attrs = {
# this specific client uses yet another local scratch partition
- 'attr_scratch' => '/dev/sdx3',
+ 'scratch' => '/dev/sdx3',
};
ok(
- $configDB->changeClient(1, $client1Attrs),
+ $configDB->changeClient(1, { attrs => $client1Attrs } ),
'attributes of client 1 have been set'
);
ok(
@@ -272,42 +275,42 @@ ok(
# default client attributes overruled by group attributes (ordererd by priority)
# overruled by specific client attributes:
$shouldBeAttrs1 = {
- 'attr_ramfs_fsmods' => '',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => '',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => '',
- 'attr_dm_allow_shutdown' => '',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => '',
- 'attr_netbios_workgroup' => '',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '/dev/sdx3',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => '',
- 'attr_start_atd' => '',
- 'attr_start_cron' => '',
- 'attr_start_dreshal' => '',
- 'attr_start_ntp' => '',
- 'attr_start_nfsv4' => '',
- 'attr_start_printer' => '',
- 'attr_start_samba' => '',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '',
- 'attr_start_syslog' => '',
- 'attr_start_x' => '',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => '',
- 'attr_timezone' => 'America/New_York',
- 'attr_tvout' => '',
- 'attr_vmware' => '',
+ 'ramfs_fsmods' => '',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => '',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => '',
+ 'dm_allow_shutdown' => '',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => '',
+ 'netbios_workgroup' => '',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => '',
+ 'start_alsasound' => '',
+ 'start_atd' => '',
+ 'start_cron' => '',
+ 'start_dreshal' => '',
+ 'start_ntp' => '',
+ 'start_nfsv4' => '',
+ 'start_printer' => '',
+ 'start_samba' => '',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '',
+ 'start_syslog' => '',
+ 'start_x' => '',
+ 'start_xdmcp' => '',
+ 'tex_enable' => '',
+ 'timezone' => 'America/New_York',
+ 'tvout' => '',
+ 'vmware' => '',
};
my $mergedClient1 = $configDB->fetchClientByID(1);
ok(
@@ -316,49 +319,53 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $mergedClient1->{$key} || '', $shouldBeAttrs1->{$key} || '',
+ $mergedClient1->{attrs}->{$key} || '', $shouldBeAttrs1->{$key} || '',
"checking merged attribute $key for client 1"
);
}
$shouldBeAttrs3 = {
- 'attr_ramfs_fsmods' => '',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => '',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => '',
- 'attr_dm_allow_shutdown' => '',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => '',
- 'attr_netbios_workgroup' => '',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => '',
- 'attr_start_atd' => '',
- 'attr_start_cron' => '',
- 'attr_start_dreshal' => '',
- 'attr_start_ntp' => '',
- 'attr_start_nfsv4' => '',
- 'attr_start_printer' => '',
- 'attr_start_samba' => '',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '',
- 'attr_start_syslog' => '',
- 'attr_start_x' => '',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => '',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => '',
- 'attr_vmware' => '',
+ 'ramfs_fsmods' => '',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => '',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => '',
+ 'dm_allow_shutdown' => '',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => '',
+ 'netbios_workgroup' => '',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '',
+ 'slxgrp' => '',
+ 'start_alsasound' => '',
+ 'start_atd' => '',
+ 'start_cron' => '',
+ 'start_dreshal' => '',
+ 'start_ntp' => '',
+ 'start_nfsv4' => '',
+ 'start_printer' => '',
+ 'start_samba' => '',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '',
+ 'start_syslog' => '',
+ 'start_x' => '',
+ 'start_xdmcp' => '',
+ 'tex_enable' => '',
+ 'timezone' => 'Europe/London',
+ 'tvout' => '',
+ 'vmware' => '',
};
+
+# remove all attributes from client 3
+$configDB->changeClient(3, { attrs => {} } );
+
my $mergedClient3 = $configDB->fetchClientByID(3);
ok(
$configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3),
@@ -366,7 +373,7 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '',
+ $mergedClient3->{attrs}->{$key} || '', $shouldBeAttrs3->{$key} || '',
"checking merged attribute $key for client 3"
);
}
@@ -377,42 +384,42 @@ ok(
'group-IDs of default client have been set'
);
$shouldBeAttrs1 = {
- 'attr_ramfs_fsmods' => '',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => '',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => '',
- 'attr_dm_allow_shutdown' => '',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => '',
- 'attr_netbios_workgroup' => '',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '/dev/sdx3',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => '',
- 'attr_start_atd' => '',
- 'attr_start_cron' => '',
- 'attr_start_dreshal' => '',
- 'attr_start_ntp' => '',
- 'attr_start_nfsv4' => '',
- 'attr_start_printer' => '',
- 'attr_start_samba' => '',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '',
- 'attr_start_syslog' => '',
- 'attr_start_x' => '',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => '',
- 'attr_timezone' => 'America/New_York',
- 'attr_tvout' => '',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => '',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => '',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => '',
+ 'dm_allow_shutdown' => '',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => '',
+ 'netbios_workgroup' => '',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => '',
+ 'start_alsasound' => '',
+ 'start_atd' => '',
+ 'start_cron' => '',
+ 'start_dreshal' => '',
+ 'start_ntp' => '',
+ 'start_nfsv4' => '',
+ 'start_printer' => '',
+ 'start_samba' => '',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '',
+ 'start_syslog' => '',
+ 'start_x' => '',
+ 'start_xdmcp' => '',
+ 'tex_enable' => '',
+ 'timezone' => 'America/New_York',
+ 'tvout' => '',
+ 'vmware' => 'yes',
};
$mergedClient1 = $configDB->fetchClientByID(1);
ok(
@@ -421,48 +428,48 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $mergedClient1->{$key} || '', $shouldBeAttrs1->{$key} || '',
+ $mergedClient1->{attrs}->{$key} || '', $shouldBeAttrs1->{$key} || '',
"checking merged attribute $key for client 1"
);
}
$shouldBeAttrs3 = {
- 'attr_ramfs_fsmods' => '',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => '',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => '',
- 'attr_dm_allow_shutdown' => '',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => '',
- 'attr_netbios_workgroup' => '',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '/dev/hdd1',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => '',
- 'attr_start_atd' => '',
- 'attr_start_cron' => '',
- 'attr_start_dreshal' => '',
- 'attr_start_ntp' => '',
- 'attr_start_nfsv4' => '',
- 'attr_start_printer' => '',
- 'attr_start_samba' => '',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '',
- 'attr_start_syslog' => '',
- 'attr_start_x' => '',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => '',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => '',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => '',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => '',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => '',
+ 'dm_allow_shutdown' => '',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => '',
+ 'netbios_workgroup' => '',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '/dev/hdd1',
+ 'slxgrp' => '',
+ 'start_alsasound' => '',
+ 'start_atd' => '',
+ 'start_cron' => '',
+ 'start_dreshal' => '',
+ 'start_ntp' => '',
+ 'start_nfsv4' => '',
+ 'start_printer' => '',
+ 'start_samba' => '',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '',
+ 'start_syslog' => '',
+ 'start_x' => '',
+ 'start_xdmcp' => '',
+ 'tex_enable' => '',
+ 'timezone' => 'Europe/London',
+ 'tvout' => '',
+ 'vmware' => 'yes',
};
$mergedClient3 = $configDB->fetchClientByID(3);
ok(
@@ -471,7 +478,7 @@ ok(
);
foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '',
+ $mergedClient3->{attrs}->{$key} || '', $shouldBeAttrs3->{$key} || '',
"checking merged attribute $key for client 3"
);
}
@@ -483,46 +490,46 @@ ok(
'merging system 1 into client 1'
);
my $shouldBeAttrs11 = {
- 'attr_ramfs_fsmods' => 'squashfs',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => 'de',
- 'attr_dm_allow_shutdown' => 'user',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => 'no',
- 'attr_netbios_workgroup' => 'slx-network',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '/dev/sdx3',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => 'yes',
- 'attr_start_atd' => 'no',
- 'attr_start_cron' => 'no',
- 'attr_start_dreshal' => 'yes',
- 'attr_start_ntp' => 'initial',
- 'attr_start_nfsv4' => 'no',
- 'attr_start_printer' => 'no',
- 'attr_start_samba' => 'may',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => 'yes',
- 'attr_start_syslog' => 'yes',
- 'attr_start_x' => 'no',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => 'no',
- 'attr_timezone' => 'America/New_York',
- 'attr_tvout' => 'no',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => '',
+ 'start_alsasound' => 'yes',
+ 'start_atd' => 'no',
+ 'start_cron' => 'no',
+ 'start_dreshal' => 'yes',
+ 'start_ntp' => 'initial',
+ 'start_nfsv4' => 'no',
+ 'start_printer' => 'no',
+ 'start_samba' => 'may',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => 'yes',
+ 'start_syslog' => 'yes',
+ 'start_x' => 'no',
+ 'start_xdmcp' => '',
+ 'tex_enable' => 'no',
+ 'timezone' => 'America/New_York',
+ 'tvout' => 'no',
+ 'vmware' => 'yes',
};
foreach my $key (sort keys %$shouldBeAttrs11) {
is(
- $fullMerge11->{$key} || '', $shouldBeAttrs11->{$key} || '',
+ $fullMerge11->{attrs}->{$key} || '', $shouldBeAttrs11->{$key} || '',
"checking merged attribute $key for client 1 / system 1"
);
}
@@ -533,46 +540,46 @@ ok(
'merging system 1 into client 3'
);
my $shouldBeAttrs31 = {
- 'attr_ramfs_fsmods' => 'squashfs',
- 'attr_ramfs_miscmods' => '',
- 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169',
- 'attr_ramfs_screen' => '',
-
- 'attr_automnt_dir' => '',
- 'attr_automnt_src' => '',
- 'attr_country' => 'de',
- 'attr_dm_allow_shutdown' => 'user',
- 'attr_hw_graphic' => '',
- 'attr_hw_monitor' => '',
- 'attr_hw_mouse' => '',
- 'attr_late_dm' => 'no',
- 'attr_netbios_workgroup' => 'slx-network',
- 'attr_nis_domain' => '',
- 'attr_nis_servers' => '',
- 'attr_sane_scanner' => '',
- 'attr_scratch' => '/dev/hdd1',
- 'attr_slxgrp' => '',
- 'attr_start_alsasound' => 'yes',
- 'attr_start_atd' => 'no',
- 'attr_start_cron' => 'no',
- 'attr_start_dreshal' => 'yes',
- 'attr_start_ntp' => 'initial',
- 'attr_start_nfsv4' => 'no',
- 'attr_start_printer' => 'no',
- 'attr_start_samba' => 'may',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => 'yes',
- 'attr_start_syslog' => 'yes',
- 'attr_start_x' => 'no',
- 'attr_start_xdmcp' => '',
- 'attr_tex_enable' => 'no',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => 'no',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => '',
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+ 'ramfs_screen' => '',
+
+ 'automnt_dir' => '',
+ 'automnt_src' => '',
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => '',
+ 'hw_monitor' => '',
+ 'hw_mouse' => '',
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => '',
+ 'nis_servers' => '',
+ 'sane_scanner' => '',
+ 'scratch' => '/dev/hdd1',
+ 'slxgrp' => '',
+ 'start_alsasound' => 'yes',
+ 'start_atd' => 'no',
+ 'start_cron' => 'no',
+ 'start_dreshal' => 'yes',
+ 'start_ntp' => 'initial',
+ 'start_nfsv4' => 'no',
+ 'start_printer' => 'no',
+ 'start_samba' => 'may',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => 'yes',
+ 'start_syslog' => 'yes',
+ 'start_x' => 'no',
+ 'start_xdmcp' => '',
+ 'tex_enable' => 'no',
+ 'timezone' => 'Europe/London',
+ 'tvout' => 'no',
+ 'vmware' => 'yes',
};
foreach my $key (sort keys %$shouldBeAttrs31) {
is(
- $fullMerge31->{$key} || '', $shouldBeAttrs31->{$key} || '',
+ $fullMerge31->{attrs}->{$key} || '', $shouldBeAttrs31->{$key} || '',
"checking merged attribute $key for client 3 / system 1"
);
}
@@ -583,46 +590,46 @@ ok(
'merging system 3 into client 1'
);
my $shouldBeAttrs13 = {
- 'attr_ramfs_fsmods' => '-4',
- 'attr_ramfs_miscmods' => '-3',
- 'attr_ramfs_nicmods' => '-2',
- 'attr_ramfs_screen' => '-1',
-
- 'attr_automnt_dir' => '1',
- 'attr_automnt_src' => '2',
- 'attr_country' => '3',
- 'attr_dm_allow_shutdown' => '4',
- 'attr_hw_graphic' => '5',
- 'attr_hw_monitor' => '6',
- 'attr_hw_mouse' => '7',
- 'attr_late_dm' => '8',
- 'attr_netbios_workgroup' => '9',
- 'attr_nis_domain' => '10',
- 'attr_nis_servers' => '11',
- 'attr_sane_scanner' => '12',
- 'attr_scratch' => '/dev/sdx3',
- 'attr_slxgrp' => '14',
- 'attr_start_alsasound' => '15',
- 'attr_start_atd' => '16',
- 'attr_start_cron' => '17',
- 'attr_start_dreshal' => '18',
- 'attr_start_ntp' => '19',
- 'attr_start_nfsv4' => '20',
- 'attr_start_printer' => '21',
- 'attr_start_samba' => '22',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '24',
- 'attr_start_syslog' => '25',
- 'attr_start_x' => '26',
- 'attr_start_xdmcp' => '27',
- 'attr_tex_enable' => '28',
- 'attr_timezone' => 'America/New_York',
- 'attr_tvout' => '30',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+ 'ramfs_screen' => '-1',
+
+ 'automnt_dir' => '1',
+ 'automnt_src' => '2',
+ 'country' => '3',
+ 'dm_allow_shutdown' => '4',
+ 'hw_graphic' => '5',
+ 'hw_monitor' => '6',
+ 'hw_mouse' => '7',
+ 'late_dm' => '8',
+ 'netbios_workgroup' => '9',
+ 'nis_domain' => '10',
+ 'nis_servers' => '11',
+ 'sane_scanner' => '12',
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => '14',
+ 'start_alsasound' => '15',
+ 'start_atd' => '16',
+ 'start_cron' => '17',
+ 'start_dreshal' => '18',
+ 'start_ntp' => '19',
+ 'start_nfsv4' => '20',
+ 'start_printer' => '21',
+ 'start_samba' => '22',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '24',
+ 'start_syslog' => '25',
+ 'start_x' => '26',
+ 'start_xdmcp' => '27',
+ 'tex_enable' => '28',
+ 'timezone' => 'America/New_York',
+ 'tvout' => '30',
+ 'vmware' => 'yes',
};
foreach my $key (sort keys %$shouldBeAttrs13) {
is(
- $fullMerge13->{$key} || '', $shouldBeAttrs13->{$key} || '',
+ $fullMerge13->{attrs}->{$key} || '', $shouldBeAttrs13->{$key} || '',
"checking merged attribute $key for client 1 / system 3"
);
}
@@ -633,46 +640,46 @@ ok(
'merging system 3 into client 3'
);
my $shouldBeAttrs33 = {
- 'attr_ramfs_fsmods' => '-4',
- 'attr_ramfs_miscmods' => '-3',
- 'attr_ramfs_nicmods' => '-2',
- 'attr_ramfs_screen' => '-1',
-
- 'attr_automnt_dir' => '1',
- 'attr_automnt_src' => '2',
- 'attr_country' => '3',
- 'attr_dm_allow_shutdown' => '4',
- 'attr_hw_graphic' => '5',
- 'attr_hw_monitor' => '6',
- 'attr_hw_mouse' => '7',
- 'attr_late_dm' => '8',
- 'attr_netbios_workgroup' => '9',
- 'attr_nis_domain' => '10',
- 'attr_nis_servers' => '11',
- 'attr_sane_scanner' => '12',
- 'attr_scratch' => '/dev/hdd1',
- 'attr_slxgrp' => '14',
- 'attr_start_alsasound' => '15',
- 'attr_start_atd' => '16',
- 'attr_start_cron' => '17',
- 'attr_start_dreshal' => '18',
- 'attr_start_ntp' => '19',
- 'attr_start_nfsv4' => '20',
- 'attr_start_printer' => '21',
- 'attr_start_samba' => '22',
- 'attr_start_snmp' => 'yes',
- 'attr_start_sshd' => '24',
- 'attr_start_syslog' => '25',
- 'attr_start_x' => '26',
- 'attr_start_xdmcp' => '27',
- 'attr_tex_enable' => '28',
- 'attr_timezone' => 'Europe/London',
- 'attr_tvout' => '30',
- 'attr_vmware' => 'yes',
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+ 'ramfs_screen' => '-1',
+
+ 'automnt_dir' => '1',
+ 'automnt_src' => '2',
+ 'country' => '3',
+ 'dm_allow_shutdown' => '4',
+ 'hw_graphic' => '5',
+ 'hw_monitor' => '6',
+ 'hw_mouse' => '7',
+ 'late_dm' => '8',
+ 'netbios_workgroup' => '9',
+ 'nis_domain' => '10',
+ 'nis_servers' => '11',
+ 'sane_scanner' => '12',
+ 'scratch' => '/dev/hdd1',
+ 'slxgrp' => '14',
+ 'start_alsasound' => '15',
+ 'start_atd' => '16',
+ 'start_cron' => '17',
+ 'start_dreshal' => '18',
+ 'start_ntp' => '19',
+ 'start_nfsv4' => '20',
+ 'start_printer' => '21',
+ 'start_samba' => '22',
+ 'start_snmp' => 'yes',
+ 'start_sshd' => '24',
+ 'start_syslog' => '25',
+ 'start_x' => '26',
+ 'start_xdmcp' => '27',
+ 'tex_enable' => '28',
+ 'timezone' => 'Europe/London',
+ 'tvout' => '30',
+ 'vmware' => 'yes',
};
foreach my $key (sort keys %$shouldBeAttrs33) {
is(
- $fullMerge33->{$key} || '', $shouldBeAttrs33->{$key} || '',
+ $fullMerge33->{attrs}->{$key} || '', $shouldBeAttrs33->{$key} || '',
"checking merged attribute $key for client 3 / system 3"
);
}
diff --git a/config-db/t/29-transaction.t b/config-db/t/29-transaction.t
index 89b0df83..2088a16c 100644
--- a/config-db/t/29-transaction.t
+++ b/config-db/t/29-transaction.t
@@ -1,5 +1,8 @@
use Test::More qw(no_plan);
+use strict;
+use warnings;
+
use lib '/opt/openslx/lib';
# basic init