--- loncom/interface/domainprefs.pm 2018/11/06 15:37:37 1.340
+++ loncom/interface/domainprefs.pm 2018/11/24 16:48:01 1.342
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.340 2018/11/06 15:37:37 raeburn Exp $
+# $Id: domainprefs.pm,v 1.342 2018/11/24 16:48:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3581,7 +3581,7 @@ sub print_contacts {
$sysmail = $defaults->{'sysmail'};
}
if (ref($lonstatus{'weights'}) eq 'HASH') {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
if ($lonstatus{'weights'}{$type} =~ /^\d+$/) {
$weights{$type} = $lonstatus{'weights'}{$type};
} else {
@@ -3589,7 +3589,7 @@ sub print_contacts {
}
}
} else {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
$weights{$type} = $defaults->{$type};
}
}
@@ -3610,7 +3610,7 @@ sub print_contacts {
'
'.
''.$titles->{'errorweights'}.
' | ';
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
$datatable .= ''.$names->{$type}.' '.
' | ';
@@ -6339,13 +6339,13 @@ sub print_loadbalancing {
my $numinrow = 1;
my $datatable;
my %servers = &Apache::lonnet::internet_dom_servers($dom);
- my (%currbalancer,%currtargets,%currrules,%existing);
+ my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
if (ref($settings) eq 'HASH') {
%existing = %{$settings};
}
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
&get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
- \%currtargets,\%currrules);
+ \%currtargets,\%currrules,\%currcookies);
} else {
return;
}
@@ -6422,6 +6422,9 @@ sub print_loadbalancing {
my %hostherechecked = (
no => ' checked="checked"',
);
+ my %balcookiechecked = (
+ no => ' checked="checked"',
+ );
foreach my $sparetype (@sparestypes) {
my $targettable;
for (my $i=0; $i<$numspares; $i++) {
@@ -6477,6 +6480,11 @@ sub print_loadbalancing {
}
}
}
+ if ($currcookies{$lonhost}) {
+ %balcookiechecked = (
+ yes => ' checked="checked"',
+ );
+ }
$datatable .= &mt('Hosting on balancer itself').' '.
' ';
@@ -6485,7 +6493,12 @@ sub print_loadbalancing {
'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' />'.$typetitles{$sparetype}.
' ';
}
- $datatable .= ' '.
+ $datatable .= &mt('Use balancer cookie').' '.
+ ' '.
+ ' '.
+ ''.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
$othertitle,$usertypes,$types,\%servers,
\%currbalancer,$lonhost,
@@ -6499,10 +6512,11 @@ sub print_loadbalancing {
}
sub get_loadbalancers_config {
- my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;
+ my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_;
return unless ((ref($servers) eq 'HASH') &&
(ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&
- (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH'));
+ (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH') &&
+ (ref($currcookies) eq 'HASH'));
if (keys(%{$existing}) > 0) {
my $oldlonhost;
foreach my $key (sort(keys(%{$existing}))) {
@@ -6521,6 +6535,9 @@ sub get_loadbalancers_config {
$currbalancer->{$key} = 1;
$currtargets->{$key} = $existing->{$key}{'targets'};
$currrules->{$key} = $existing->{$key}{'rules'};
+ if ($existing->{$key}{'cookie'}) {
+ $currcookies->{$key} = 1;
+ }
}
}
} else {
@@ -13019,7 +13036,7 @@ sub modify_contacts {
if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') &&
(ref($contacts_hash{contacts}{lonstatus}{$key}) eq 'HASH')) {
if (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
unless ($contacts_hash{contacts}{lonstatus}{$key}{$type} eq
$currsetting{'lonstatus'}{$key}{$type}) {
push(@{$changes{'lonstatus'}},$key);
@@ -13027,7 +13044,7 @@ sub modify_contacts {
}
}
} else {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
if ($contacts_hash{contacts}{lonstatus}{$key}{$type} ne '') {
push(@{$changes{'lonstatus'}},$key);
last;
@@ -13035,7 +13052,7 @@ sub modify_contacts {
}
}
} elsif (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
if ($currsetting{'lonstatus'}{$key}{$type} ne '') {
push(@{$changes{'lonstatus'}},$key);
last;
@@ -13270,7 +13287,7 @@ sub modify_contacts {
$defval{'threshold'} = $lonstatus_defs->{'threshold'};
$defval{'sysmail'} = $lonstatus_defs->{'sysmail'};
$defval{'weights'} =
- join(', ',map { $lonstatus_names->{$_}.'='.$lonstatus_defs->{$_}; } ('E','W','N'));
+ join(', ',map { $lonstatus_names->{$_}.'='.$lonstatus_defs->{$_}; } ('E','W','N','U'));
$defval{'excluded'} = &mt('None');
if (ref($contacts_hash{'contacts'}{'lonstatus'}) eq 'HASH') {
foreach my $item ('threshold','sysmail','weights','excluded') {
@@ -13279,7 +13296,7 @@ sub modify_contacts {
$shown{$item} = $contacts_hash{'contacts'}{'lonstatus'}{$item};
} elsif ($item eq 'weights') {
if (ref($contacts_hash{'contacts'}{'lonstatus'}{$item}) eq 'HASH') {
- foreach my $type ('E','W','N') {
+ foreach my $type ('E','W','N','U') {
$shown{$item} .= $lonstatus_names->{$type}.'=';
if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item}{$type})) {
$shown{$item} .= $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type};
@@ -17003,12 +17020,12 @@ sub modify_loadbalancing {
my @sparestypes = ('primary','default');
my %typetitles = &sparestype_titles();
my $resulttext;
- my (%currbalancer,%currtargets,%currrules,%existing);
+ my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
}
&get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
- \%currtargets,\%currrules);
+ \%currtargets,\%currrules,\%currcookies);
my ($saveloadbalancing,%defaultshash,%changes);
my ($alltypes,$othertypes,$titles) =
&loadbalancing_titles($dom,$intdom,$usertypes,$types);
@@ -17060,6 +17077,18 @@ sub modify_loadbalancing {
}
$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;
}
+ if ($env{'form.loadbalancing_cookie_'.$i}) {
+ $defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
+ if (exists($currbalancer{$balancer})) {
+ unless ($currcookies{$balancer}) {
+ $changes{'curr'}{$balancer}{'cookie'} = 1;
+ }
+ }
+ } elsif (exists($currbalancer{$balancer})) {
+ if ($currcookies{$balancer}) {
+ $changes{'curr'}{$balancer}{'cookie'} = 1;
+ }
+ }
if (ref($currtargets{$balancer}) eq 'HASH') {
foreach my $sparetype (@sparestypes) {
if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {
@@ -17213,6 +17242,10 @@ sub modify_loadbalancing {
}
}
}
+ if ($changes{'curr'}{$balancer}{'cookie'}) {
+ $resulttext .= ''.&mt('Load Balancer: [_1] -- cookie use enabled',
+ $balancer).'';
+ }
if (keys(%toupdate)) {
my %thismachine;
my $updatedhere;
@@ -17442,12 +17475,12 @@ sub lonbalance_targets_js {
}
push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external');
$allinsttypes = join("','",@alltypes);
- my (%currbalancer,%currtargets,%currrules,%existing);
+ my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
if (ref($settings) eq 'HASH') {
%existing = %{$settings};
}
&get_loadbalancers_config($servers,\%existing,\%currbalancer,
- \%currtargets,\%currrules);
+ \%currtargets,\%currrules,\%currcookies);
my $balancers = join("','",sort(keys(%currbalancer)));
return <<"END";
|