diff options
author | Erwan Velu <erwan@mandriva.org> | 2003-06-11 17:55:53 +0000 |
---|---|---|
committer | Erwan Velu <erwan@mandriva.org> | 2003-06-11 17:55:53 +0000 |
commit | f5dabc106fb21263b60dd26eb81853f577fe4fd1 (patch) | |
tree | 3e0418ee2df69e0ad40b6b67e8ea2ea61d16a9de /perl-install/drakcluster/server_conf.pm | |
parent | 644dc2d248a72a3c8dcf4a5a327a4fc952c6c608 (diff) | |
download | drakx-f5dabc106fb21263b60dd26eb81853f577fe4fd1.tar drakx-f5dabc106fb21263b60dd26eb81853f577fe4fd1.tar.gz drakx-f5dabc106fb21263b60dd26eb81853f577fe4fd1.tar.bz2 drakx-f5dabc106fb21263b60dd26eb81853f577fe4fd1.tar.xz drakx-f5dabc106fb21263b60dd26eb81853f577fe4fd1.zip |
Initial release of drakcluster during install
Diffstat (limited to 'perl-install/drakcluster/server_conf.pm')
-rw-r--r-- | perl-install/drakcluster/server_conf.pm | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/perl-install/drakcluster/server_conf.pm b/perl-install/drakcluster/server_conf.pm new file mode 100644 index 000000000..435b013a5 --- /dev/null +++ b/perl-install/drakcluster/server_conf.pm @@ -0,0 +1,109 @@ +package drakcluster::server_conf; + +use strict; +use common; + +sub read() { + my %main = getVarsFromSh("$::prefix/etc/clusterserver.conf"); + \%main; +} + +sub done { + my ($conf, $network_interfaces) = @_; + set_automatic_fields($conf, $network_interfaces); + setVarsInSh("$::prefix/etc/clusterserver.conf", $conf); +} + +my %automatic_when_single_network = ( + ADMIN_INTERFACE => 'COMPUTE_INTERFACE', + NODENAME => 'COMPUTENODENAME', + DOMAINNAME => 'DOMAINCOMP', +); + +sub set_automatic_fields { + my ($conf, $network_interfaces) = @_; + if (@$network_interfaces <= 2) { + $conf->{$_} = $conf->{$automatic_when_single_network{$_}} foreach keys %automatic_when_single_network; + } +} + +sub fields { + my ($conf, $network_interfaces, $default_conf) = @_; + my $current_conf = { %$conf }; + add2hash($conf, $default_conf); + my @l = ( + [ NODENAME => 'node use for administration', check => \&check_non_empty ], + [ COMPUTENODENAME => 'name use for compute interface', check => \&check_non_empty ], + + [ STARTNODE => 'IP start node', check => \&check_number ], + [ FINISHNODE => 'IP end node', check => sub { &check_number || $conf->{STARTNODE} >= $conf->{FINISHNODE} && N("\"start node\" must be lower than \"end node\"") } ], + + [ ADMIN_INTERFACE => 'admin interface', list => $network_interfaces ], + [ EXTERNAL_INTERFACE => 'external interface', list => $network_interfaces ], + [ COMPUTE_INTERFACE => 'compute interface', list => $network_interfaces ], + [ NTPSERVER => N("NTP Server IP"), check => sub { &check_ip || check_default(@_, $default_conf->{NTPSERVER}, $current_conf->{NTPSERVER}) } ], + + [ DOMAINNAME => N("domain name use for administration of node"), check => sub { check_default(@_, $default_conf->{DOMAINNAME}, $current_conf->{DOMAINNAME}) } ], + [ NISDOMAINNAME => N("nis domain name use for NIS"), check => \&check_non_empty ], + [ DOMAINCOMP => N("domain name use for compute"), check => \&check_non_empty ], + [ IPOFFORWARDER => 'IP fo Forwarder resolv ip out of zone ', check => \&check_ip ], + [ DNSKEY => 'dnskey for the dns server', check => \&check_non_empty ], + [ ADDSEARCH => 'ADDSEARCH ' . N("is needed if you want your cluster resolv out of zone ip") ], + + [ USERADMIN => 'useradmin define wich user admin PBS queue', check => \&check_non_empty ], + [ NODEADMIN => 'Nodeadmin define wich node can admin PBS queue', check => \&check_non_empty ], + + [ ORIGIN => 'ORIGIN ' . N("domain that locally-posted mail appears to come from"), check => \&check_non_empty ], + ); + + if (@$network_interfaces <= 2) { + @l = grep { !$automatic_when_single_network{$_->[0]} } @l; + } + + map { + my ($field, $label, %opts) = @$_; + $opts{val} = \$conf->{$field}; + $opts{label} = $label; + \%opts; + } @l; +} + +sub check_field { + my ($in, $field) = @_; + warn "checking $field->{label}\n"; + $field->{check} or return 1; + my $err = $field->{check}->(${$field->{val}}, $field->{label}, warn => $in); + $in->ask_warn('', $err) if $err && $err ne 'already_displayed'; + !$err; +} + + +# CHECKERS ##################################################################### +sub is_ip { + $::isInstall ? &network::network::is_ip : &cluster_fonction_common::is_ip; +} + +sub check_non_empty { + my ($val, $txt) = @_; + !$val && N("Field \"%s\" must not be empty", $txt); +} +sub check_number { + my ($val, $txt) = @_; + $val !~ /^\d+$/ && N("Field \"%s\" must be a number", $txt); +} +sub check_ip { + my ($val, $txt) = @_; + !is_ip($val) && N("Field \"%s\" must be an IP", $txt); +} + +sub check_default { + my ($val, $txt, $warn, $in, $default_val, $pre_val) = @_; + if ($default_val && $val ne $default_val && $val ne $pre_val) { + if ($warn eq 'warn') { + return '' if $in->ask_okcancel('', N("You changed the default value of field \"%s\". Are you sure you want to do this?", $txt)); + } + 'already_displayed'; + } else { + ''; + } +} |