summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2007-12-29 15:55:18 +0100
committerOliver Tappe2007-12-29 15:55:18 +0100
commitb669004e354102de77458600b8be705032d375a4 (patch)
tree09c982a5aca15c397073bd36212a12fd20e9f03b /config-db
parent* completed basic tests and started to work on tests for aggregated values (diff)
downloadcore-b669004e354102de77458600b8be705032d375a4.tar.gz
core-b669004e354102de77458600b8be705032d375a4.tar.xz
core-b669004e354102de77458600b8be705032d375a4.zip
* completed test set for attribute merging, fixing several bugs along the
way - these tests expose the known problem of attributes not being resetable by higher priority layers (you can't set attr_start_xdmcp to '' in a client if it set by a system). git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1437 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/ConfigDB.pm30
-rw-r--r--config-db/t/25-attributes.t602
2 files changed, 574 insertions, 58 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm
index f4f9b0e2..9b6218cb 100644
--- a/config-db/OpenSLX/ConfigDB.pm
+++ b/config-db/OpenSLX/ConfigDB.pm
@@ -2158,14 +2158,19 @@ sub mergeDefaultAndGroupAttributesIntoClient
# step over all groups this client belongs to
# (ordered by priority from highest to lowest):
- my @groupIDs = $self->fetchGroupIDsOfClient($client->{id});
- my @groups =
- sort { $a->{priority} <=> $b->{priority} }
- $self->fetchGroupByID(\@groupIDs);
+ my @groupIDs = _unique(
+ $self->fetchGroupIDsOfClient(0),
+ $self->fetchGroupIDsOfClient($client->{id})
+ );
+ my @groups
+ = sort { $a->{priority} <=> $b->{priority} }
+ $self->fetchGroupByID(\@groupIDs);
foreach my $group (@groups) {
# merge configuration from this group into the current client:
- vlog(3,
- _tr('merging from group %d:%s...', $group->{id}, $group->{name}));
+ vlog(
+ 3,
+ _tr('merging from group %d:%s...', $group->{id}, $group->{name})
+ );
mergeAttributes($client, $group);
}
@@ -2251,8 +2256,10 @@ sub aggregatedClientIDsOfSystem
# add *all* client-IDs if the system is being referenced by
# the default client, as that means that all clients should offer
# this system for booting:
- push @clientIDs,
- map { $_->{id} } $self->fetchClientByFilter(undef, 'id');
+ push(
+ @clientIDs,
+ map { $_->{id} } $self->fetchClientByFilter(undef, 'id')
+ );
}
# step over all groups this system belongs to:
@@ -2317,8 +2324,8 @@ sub aggregatedSystemFileInfoFor
# check if the specified kernel file really exists (follow links while
# checking) and if not, find the newest kernel file that is available.
- my $kernelPath =
- "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}/boot";
+ my $kernelPath
+ = "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}/boot";
my $kernelFile = "$kernelPath/$system->{kernel}";
while (-l $kernelFile) {
$kernelFile = followLink($kernelFile);
@@ -2409,7 +2416,8 @@ sub mergeAttributes
my $target = shift;
my $source = shift;
- foreach my $key (grep { isAttribute($_) } keys %$source) {
+ foreach my $key (keys %$source) {
+ next if !isAttribute($key);
my $sourceVal = $source->{$key} || '';
my $targetVal = $target->{$key} || '';
if (length($sourceVal) && !length($targetVal)) {
diff --git a/config-db/t/25-attributes.t b/config-db/t/25-attributes.t
index 35c9d537..fe684679 100644
--- a/config-db/t/25-attributes.t
+++ b/config-db/t/25-attributes.t
@@ -3,7 +3,7 @@ use Test::More qw(no_plan);
use lib '/opt/openslx/lib';
# basic init
-use OpenSLX::ConfigDB;
+use OpenSLX::ConfigDB qw(:support);
my $configDB = OpenSLX::ConfigDB->new;
$configDB->connect();
@@ -63,17 +63,14 @@ ok(
$configDB->changeSystem(1, $sys1Attrs),
'attributes of system 1 have been set'
);
-my $changedSystem1 = $configDB->fetchSystemByID(1);
-foreach my $key (keys %$changedSystem1) {
- is(
- $changedSystem1->{$key},
- exists $sys1Attrs->{$key} ? $sys1Attrs->{$key} : $system1->{$key},
- "checking value for $key of system 1"
- );
-}
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',
@@ -110,63 +107,574 @@ ok(
$configDB->changeSystem(3, $sys3Attrs),
'attributes of system 3 have been set'
);
-my $changedSystem3 = $configDB->fetchSystemByID(3);
-foreach my $key (keys %$changedSystem3) {
- is(
- $changedSystem3->{$key},
- exists $sys3Attrs->{$key} ? $sys3Attrs->{$key} : $system3->{$key},
- "checking value for $key of system 3"
- );
-}
my $defaultClient = $configDB->fetchClientByID(0);
my $defaultClientAttrs = {
# pretend the whole computer centre has been warped to London ;-)
'attr_timezone' => 'Europe/London',
+ # pretend we wanted to activate snmp globally (e.g. for testing)
+ 'attr_start_snmp' => 'yes',
};
ok(
$configDB->changeClient(0, $defaultClientAttrs),
'attributes of default client have been set'
);
-my $changedDefaultClient = $configDB->fetchClientByID(0);
-foreach my $key (keys %$changedDefaultClient) {
+
+# check merging of default attributes, the order should be:
+# 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',
+};
+my $mergedSystem1 = $configDB->fetchSystemByID(1);
+ok(
+ $configDB->mergeDefaultAttributesIntoSystem($mergedSystem1),
+ 'merging default attributes into system 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
is(
- $changedDefaultClient->{$key},
- exists $defaultClientAttrs->{$key}
- ? $defaultClientAttrs->{$key}
- : $defaultClient->{$key},
- "checking value for $key of default client"
+ $mergedSystem1->{$key} || '', $shouldBeAttrs1->{$key} || '',
+ "checking merged attribute $key for system 1"
);
}
-# check merging of default attributes, the order should be:
-# default system attributes overruled by system attributes overruled by
-# default client attributes
-$system1 = $changedSystem1;
-$system3 = $changedSystem3;
-$defaultClient = $changedDefaultClient;
-my $shouldBeAttrs1 = { %$defaultSystem };
-foreach my $key (keys %$system1) {
- next if !$configDB->isAttribute($key);
- if (defined $system1->{$key} && length($system1->{$key})) {
- $shouldBeAttrs1->{$key} = $system1->{$key};
- }
+# 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',
+};
+my $mergedSystem3 = $configDB->fetchSystemByID(3);
+ok(
+ $configDB->mergeDefaultAttributesIntoSystem($mergedSystem3),
+ 'merging default attributes into system 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs3) {
+ is(
+ $mergedSystem3->{$key}, $shouldBeAttrs3->{$key},
+ "checking merged attribute $key for system 3"
+ );
+}
+
+# setup client / group relations
+my $group1 = $configDB->fetchGroupByID(1);
+my $group1Attrs = {
+ 'priority' => '50',
+ # this group of clients is connected via underwater cable ...
+ 'attr_timezone' => 'America/New_York',
+ # ... and use a local scratch partition
+ 'attr_scratch' => '/dev/sdd1',
+ # the following should be a noop (as that attribute is system-specific)
+# 'attr_ramfs_nicmods' => 'e1000',
+};
+ok(
+ $configDB->changeGroup(1, $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',
+};
+ok(
+ $configDB->changeGroup(3, $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',
+};
+ok(
+ $configDB->changeClient(1, $client1Attrs),
+ 'attributes of client 1 have been set'
+);
+ok(
+ $configDB->setGroupIDsOfClient(1, [1]),
+ 'group-IDs of client 1 have been set'
+);
+ok(
+ $configDB->setGroupIDsOfClient(3, []),
+ 'group-IDs of client 3 have been set'
+);
+
+# check merging of attributes into client, the order should be:
+# 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' => '',
+};
+my $mergedClient1 = $configDB->fetchClientByID(1);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1),
+ 'merging default and group attributes into client 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient1->{$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' => '',
+};
+my $mergedClient3 = $configDB->fetchClientByID(3);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3),
+ 'merging default and group attributes into client 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '',
+ "checking merged attribute $key for client 3"
+ );
+}
+
+# now associate default client with group 3 and try again
+ok(
+ $configDB->setGroupIDsOfClient(0, [3]),
+ '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',
+};
+$mergedClient1 = $configDB->fetchClientByID(1);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1),
+ 'merging default and group attributes into client 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient1->{$key} || '', $shouldBeAttrs1->{$key} || '',
+ "checking merged attribute $key for client 1"
+ );
}
-foreach my $key (keys %$defaultClient) {
- next if !$configDB->isAttribute($key);
- if (defined $defaultClient->{$key} && length($defaultClient->{$key})) {
- $shouldBeAttrs1->{$key} = $defaultClient->{$key};
- }
+
+$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',
+};
+$mergedClient3 = $configDB->fetchClientByID(3);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3),
+ 'merging default and group attributes into client 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '',
+ "checking merged attribute $key for client 3"
+ );
}
-my $mergedSystem1 = $configDB->fetchSystemByID(1);
+# finally we merge systems into clients and check the outcome of that
+my $fullMerge11 = { %$mergedClient1 };
ok(
- $configDB->mergeAttributes($mergedSystem1),
- 'merging default attributes for system 1'
+ mergeAttributes($fullMerge11, $mergedSystem1),
+ 'merging system 1 into client 1'
);
-is_deeply(
- $mergedSystem1, $shouldBeAttrs1,
- 'checking merged attributes for system 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',
+};
+foreach my $key (sort keys %$shouldBeAttrs11) {
+ is(
+ $fullMerge11->{$key} || '', $shouldBeAttrs11->{$key} || '',
+ "checking merged attribute $key for client 1 / system 1"
+ );
+}
+
+my $fullMerge31 = { %$mergedClient3 };
+ok(
+ mergeAttributes($fullMerge31, $mergedSystem1),
+ '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',
+};
+foreach my $key (sort keys %$shouldBeAttrs31) {
+ is(
+ $fullMerge31->{$key} || '', $shouldBeAttrs31->{$key} || '',
+ "checking merged attribute $key for client 3 / system 1"
+ );
+}
+
+my $fullMerge13 = { %$mergedClient1 };
+ok(
+ mergeAttributes($fullMerge13, $mergedSystem3),
+ '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',
+};
+foreach my $key (sort keys %$shouldBeAttrs13) {
+ is(
+ $fullMerge13->{$key} || '', $shouldBeAttrs13->{$key} || '',
+ "checking merged attribute $key for client 1 / system 3"
+ );
+}
+
+my $fullMerge33 = { %$mergedClient3 };
+ok(
+ mergeAttributes($fullMerge33, $mergedSystem3),
+ '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',
+};
+foreach my $key (sort keys %$shouldBeAttrs33) {
+ is(
+ $fullMerge33->{$key} || '', $shouldBeAttrs33->{$key} || '',
+ "checking merged attribute $key for client 3 / system 3"
+ );
+}
$configDB->disconnect();