[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 08 Mar 2007 01:54:51 -0000
albertel Wed Mar 7 20:54:51 2007 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- elmiinate global libserv
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.844 loncom/lonnet/perl/lonnet.pm:1.845
--- loncom/lonnet/perl/lonnet.pm:1.844 Fri Mar 2 21:16:10 2007
+++ loncom/lonnet/perl/lonnet.pm Wed Mar 7 20:54:50 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.844 2007/03/03 02:16:10 albertel Exp $
+# $Id: lonnet.pm,v 1.845 2007/03/08 01:54:50 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,7 @@
# use Date::Parse;
use vars
qw(%perlvar %badServerCache %iphost %spareid
- %libserv %pr %prp $memcache %packagetab
+ %pr %prp $memcache %packagetab
%courselogs %accesshash %userrolehash %domainrolehash $processmarker $dumpcount
%coursedombuf %coursenumbuf %coursehombuf %coursedescrbuf %courseinstcodebuf %courseownerbuf %coursetypebuf
%domaindescription %domain_auth_def %domain_auth_arg_def
@@ -2133,9 +2133,14 @@
my ($domfilter,$descfilter,$sincefilter,$instcodefilter,$ownerfilter,$coursefilter,$hostidflag,$hostidref,$typefilter,$regexp_ok)=@_;
my %returnhash=();
unless ($domfilter) { $domfilter=''; }
- foreach my $tryserver (keys %libserv) {
- if ( ($hostidflag == 1 && grep/^$tryserver$/,@{$hostidref}) || (!defined($hostidflag)) ) {
- if ((!$domfilter) || (&host_domain($tryserver) eq $domfilter)) {
+ my %libserv = &all_library();
+ foreach my $tryserver (keys(%libserv)) {
+ if ( ( $hostidflag == 1
+ && grep(/^\Q$tryserver\E$/,@{$hostidref}) )
+ || (!defined($hostidflag)) ) {
+
+ if ($domfilter eq ''
+ || (&host_domain($tryserver) eq $domfilter)) {
foreach my $line (
split(/\&/,&reply('courseiddump:'.&host_domain($tryserver).':'.
$sincefilter.':'.&escape($descfilter).':'.
@@ -4170,6 +4175,7 @@
sub metadata_query {
my ($query,$custom,$customshow,$server_array)=@_;
my %rhash;
+ my %libserv = &all_library();
my @server_list = (defined($server_array) ? @$server_array
: keys(%libserv) );
for my $server (@server_list) {
@@ -5038,7 +5044,7 @@
}
# ------------------------------------------------ Check supplied server name
$course_server = $env{'user.homeserver'} if (! defined($course_server));
- if (! exists($libserv{$course_server})) {
+ if (! &is_library($course_server)) {
return 'error:bad server name '.$course_server;
}
# ------------------------------------------------------------- Make the course
@@ -7593,6 +7599,7 @@
{
my %hostname;
my %hostdom;
+ my %libserv;
open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");
while (my $configline=<$config>) {
@@ -7614,9 +7621,19 @@
my ($lonid) = @_;
return $hostname{$lonid};
}
+
sub all_hostnames {
return %hostname;
}
+
+ sub is_library {
+ return exists($libserv{$_[0]});
+ }
+
+ sub all_library {
+ return %libserv;
+ }
+
sub get_servers {
my ($domain,$type) = @_;
my %possible_hosts = ($type eq 'library') ? %libserv
@@ -7637,6 +7654,7 @@
}
return %result;
}
+
sub host_domain {
my ($lonid) = @_;
return $hostdom{$lonid};