summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2008-01-11 11:13:53 +0100
committerOliver Tappe2008-01-11 11:13:53 +0100
commitc52faf87a3b98200e52d1a80bc1c0c48faeedf4e (patch)
treeb8d7fff78347c3463905833df84a4f9b7245a1d4 /config-db
parent* added implementation for zypper meta-packager (untested yet) (diff)
downloadcore-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.tar.gz
core-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.tar.xz
core-c52faf87a3b98200e52d1a80bc1c0c48faeedf4e.zip
* added new column 'description' to system, which holds an optional
descriptive text that is going to be shown via PXE TEXT (as outlined by Michael in his work on PXE themes) * made setup of DB upgrade functions less error-prone (it is now harder to forget parts of the necessary setup) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1458 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/DBSchema.pm535
-rwxr-xr-xconfig-db/slxconfig-demuxer50
2 files changed, 318 insertions, 267 deletions
diff --git a/config-db/OpenSLX/DBSchema.pm b/config-db/OpenSLX/DBSchema.pm
index 5bfc4122..e533fe56 100644
--- a/config-db/OpenSLX/DBSchema.pm
+++ b/config-db/OpenSLX/DBSchema.pm
@@ -35,7 +35,7 @@ use OpenSLX::Basics;
### fk => foreign key (integer)
################################################################################
-my $VERSION = 0.22;
+my $VERSION = 0.23;
my $DbSchema = {
'version' => $VERSION,
@@ -189,6 +189,7 @@ my $DbSchema = {
'kernel:s.128', # path to kernel file, relative to /boot
'kernel_params:s.512', # kernel-param string for pxe
'hidden:b', # hidden systems won't be offered for booting
+ 'description:s.512',# visible description (for PXE TEXT)
'comment:s.1024', # internal comment (optional, for admins)
],
'vals' => [
@@ -332,273 +333,297 @@ sub _synchronizeAttributesWithDefaultSystem
### methods for upgrading the DB schema
###
################################################################################
+my %DbSchemaHistory;
+
sub _schemaUpgradeDBFrom
{
my $self = shift;
my $metaDB = shift;
my $currVersion = shift;
- $self->_upgradeDBTo0_2($metaDB) if $currVersion < 0.2;
- $self->_upgradeDBTo0_21($metaDB) if $currVersion < 0.21;
- $self->_upgradeDBTo0_22($metaDB) if $currVersion < 0.22;
+ foreach my $version (sort { $a cmp $b } keys %DbSchemaHistory) {
+ next if $currVersion >= $version;
+ $DbSchemaHistory{$version}->($metaDB);
+ }
return 1;
}
-sub _upgradeDBTo0_2
-{
- my $self = shift;
- my $metaDB = shift;
-
- vlog(0, "upgrading schema version to 0.2");
-
- # move attributes into separate tables ...
- #
- # ... system attributes ...
- $metaDB->schemaAddTable(
- 'system_attr',
- [
- 'id:pk',
- 'system_id:fk',
- 'name:s.128',
- 'value:s.255',
- ]
- );
- foreach my $system ($metaDB->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;
+%DbSchemaHistory = (
+ 0.2 => sub {
+ my $metaDB = shift;
+
+ vlog(0, "upgrading schema version to 0.2");
+
+ # move attributes into separate tables ...
+ #
+ # ... system attributes ...
+ $metaDB->schemaAddTable(
+ 'system_attr',
+ [
+ 'id:pk',
+ 'system_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $system ($metaDB->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;
+ }
+ $metaDB->setSystemAttrs($system->{id}, \%attrs);
}
- $metaDB->setSystemAttrs($system->{id}, \%attrs);
- }
- $metaDB->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 ...
- $metaDB->schemaAddTable(
- 'client_attr',
- [
- 'id:pk',
- 'client_id:fk',
- 'name:s.128',
- 'value:s.255',
- ]
- );
- foreach my $client ($metaDB->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;
+ $metaDB->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 ...
+ $metaDB->schemaAddTable(
+ 'client_attr',
+ [
+ 'id:pk',
+ 'client_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $client ($metaDB->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;
+ }
+ $metaDB->setClientAttrs($client->{id}, \%attrs);
}
- $metaDB->setClientAttrs($client->{id}, \%attrs);
- }
- $metaDB->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 ...
- $metaDB->schemaAddTable(
- 'group_attr',
- [
- 'id:pk',
- 'group_id:fk',
- 'name:s.128',
- 'value:s.255',
- ]
- );
- foreach my $group ($metaDB->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;
+ $metaDB->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 ...
+ $metaDB->schemaAddTable(
+ 'group_attr',
+ [
+ 'id:pk',
+ 'group_id:fk',
+ 'name:s.128',
+ 'value:s.255',
+ ]
+ );
+ foreach my $group ($metaDB->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;
+ }
+ $metaDB->setGroupAttrs($group->{id}, \%attrs);
}
- $metaDB->setGroupAttrs($group->{id}, \%attrs);
- }
- $metaDB->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',
- ]
- );
-
- $metaDB->schemaSetDBVersion(0.2);
-
- return 1;
-}
-
-sub _upgradeDBTo0_21
-{
- my $self = shift;
- my $metaDB = shift;
-
- vlog(0, "upgrading schema version to 0.21");
-
- # move attributes into separate tables ...
- #
- # ... system attributes ...
- $metaDB->schemaAddTable(
- 'installed_plugin',
- [
- 'id:pk',
- 'vendor_os_id:fk',
- 'plugin_name:s.64',
- ]
- );
-
- $metaDB->schemaSetDBVersion(0.21);
-
- return 1;
-}
-
-sub _upgradeDBTo0_22
-{
- my $self = shift;
- my $metaDB = shift;
-
- vlog(0, "upgrading schema version to 0.22");
-
- # dummy schema change, just to trigger the attribute synchronization
- # into the default system
-
- $metaDB->schemaSetDBVersion(0.22);
+ $metaDB->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',
+ ]
+ );
+
+ $metaDB->schemaSetDBVersion(0.2);
+
+ return 1;
+ },
+ 0.21 => sub {
+ my $metaDB = shift;
+
+ vlog(0, "upgrading schema version to 0.21");
+
+ # add new table installed_plugins
+ $metaDB->schemaAddTable(
+ 'installed_plugin',
+ [
+ 'id:pk',
+ 'vendor_os_id:fk',
+ 'plugin_name:s.64',
+ ]
+ );
+
+ $metaDB->schemaSetDBVersion(0.21);
+
+ return 1;
+ },
+ 0.22 => sub {
+ my $metaDB = shift;
+
+ vlog(0, "upgrading schema version to 0.22");
+
+ # dummy schema change, just to trigger the attribute synchronization
+ # into the default system
+
+ $metaDB->schemaSetDBVersion(0.22);
+
+ return 1;
+ },
+ 0.23 => sub {
+ my $metaDB = shift;
- return 1;
-}
+ vlog(0, "upgrading schema version to 0.23");
+
+ # add new column system.descripion
+ $metaDB->schemaAddColumns(
+ 'system',
+ [
+ 'description:s.512',
+ ],
+ undef,
+ [
+ 'id:pk',
+ 'export_id:fk',
+ 'name:s.64',
+ 'label:s.64',
+ 'kernel:s.128',
+ 'kernel_params:s.512',
+ 'hidden:b',
+ 'description:s.512',
+ 'comment:s.1024',
+ ]
+ );
+
+ $metaDB->schemaSetDBVersion(0.23);
+
+ return 1;
+ },
+);
1;
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index 2085461e..9558d1ca 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -29,6 +29,7 @@ slxconfig-demuxer
Please use the --man option in order to read the full manual.
];
+use Config::General;
use Fcntl qw(:DEFAULT :flock);
use File::Basename;
use File::Find;
@@ -362,7 +363,7 @@ sub writePXEMenus
slxsystem(qq[cp -p "$vesamenuc32Path" $pxePath/]) unless $dryRun;
}
- # fetch PXE-template, if any:
+ # fetch PXE-template, if any
my $pxeTemplate =
"# generated by slxconfig-demuxer (on $callDate at $callTime)\n";
my $pxeTemplateFile = "$openslxConfig{'config-path'}/PXE-template";
@@ -371,40 +372,65 @@ sub writePXEMenus
} else {
$pxeTemplate .= $pxeDefaultTemplate;
}
+
+ # now append (and thus override) the PXE-template with the settings of the
+ # selected PXE-theme, if any
+ my $pxeTheme = $openslxConfig{'pxe-theme'};
+ my $pxeThemeConfig
+ = "$openslxConfig{'base-path'}/share/themes/${pxeTheme}/pxe/theme.conf";
+ if (-e $pxeThemeConfig) {
+ $pxeTemplate .= slurpFile($pxeThemeConfig);
+ }
+
# PXE uses 'cp850' (codepage 850) but our string is in utf-8, we have
# to convert in order to avoid showing gibberish on the client side...
use Encode 'from_to';
from_to($pxeTemplate, 'utf-8', 'cp850');
+ # pick out the last background picture and copy it over
+ my $pic;
+ while ($pxeTemplate =~ m{^\s*MENU BACKGROUND (\S+?)\s*$}gims) {
+ chomp($pic = $1);
+ }
+ if (defined $pic) {
+ my $pxeBackground
+ = "$openslxConfig{'base-path'}/share/themes/${pxeTheme}/pxe/$pic";
+ if (-e $pxeBackground) {
+ slxsystem(qq[cp "$pxeBackground" $pxePath/]) unless $dryRun;
+ }
+ }
+
my @clients = $openslxDB->fetchClientByFilter();
foreach my $client (@clients) {
+ my $pxeConfig = $pxeTemplate;
my $externalClientID = externalIDForClient($client);
my $pxeFile = "$pxeConfigPath/$externalClientID";
my $clientAppend = $client->{kernel_params} || '';
vlog(1, _tr("writing PXE-file %s", $pxeFile));
next if $dryRun;
- my $pxeFH;
- open($pxeFH, '>', $pxeFile)
- or croak _tr("unable to create file '%s' (%s)\n", $pxeFile, $!);
- print $pxeFH $pxeTemplate;
my %systemIDs;
@systemIDs{$openslxDB->aggregatedSystemIDsOfClient($client)} = ();
my @systemInfos = grep { exists $systemIDs{$_->{id}} } @infos;
# now @systemInfos holds all infos relevant to this client
+ my $slxLabels = '';
foreach my $info (@systemInfos) {
my $extID = $info->{'vendor-os'}->{name};
my $kernelName = basename($info->{'kernel-file'});
my $append = $info->{kernel_params};
$append .= " initrd=$extID/$info->{'initramfs-name'}";
$append .= " $clientAppend";
- print $pxeFH "LABEL openslx-$info->{'external-id'}\n";
- print $pxeFH "\tMENU LABEL ^$info->{label}\n";
- print $pxeFH "\tKERNEL $extID/$kernelName\n";
- print $pxeFH "\tAPPEND $append\n";
- print $pxeFH "\tIPAPPEND 1\n";
+ $slxLabels .= "LABEL openslx-$info->{'external-id'}\n";
+ $slxLabels .= "\tMENU LABEL ^$info->{label}\n";
+ $slxLabels .= "\tKERNEL $extID/$kernelName\n";
+ $slxLabels .= "\tAPPEND $append\n";
+ $slxLabels .= "\tIPAPPEND 1\n";
+ }
+$slxLabels .= $slxLabels . $slxLabels . $slxLabels . $slxLabels;
+ # now add the slx-labels (inline or appended) and write the config file
+ if (!($pxeConfig =~ s{\@\@\@SLX_LABELS\@\@\@}{$slxLabels})) {
+ $pxeConfig .= $slxLabels;
}
- close($pxeFH)
- or croak _tr("unable to close file '%s' (%s)\n", $pxeFile, $!);
+ spitFile($pxeFile, $pxeConfig);
}
return;
}