[LON-CAPA-cvs] cvs: loncom / lond /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sat, 11 Apr 2009 14:47:51 -0000
raeburn Sat Apr 11 14:47:51 2009 EDT
Modified files:
/loncom lond
/loncom/lonnet/perl lonnet.pm
Log:
- lonnet.pm/lond infrastructure to support enquiries about LON-CAPA version running on a server.
Work in progress.
Index: loncom/lond
diff -u loncom/lond:1.412 loncom/lond:1.413
--- loncom/lond:1.412 Tue Mar 3 12:08:07 2009
+++ loncom/lond Sat Apr 11 14:47:46 2009
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.412 2009/03/03 12:08:07 foxr Exp $
+# $Id: lond,v 1.413 2009/04/11 14:47:46 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -59,7 +59,7 @@
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.412 $'; #' stupid emacs
+my $VERSION='$Revision: 1.413 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -1645,6 +1645,14 @@
}
®ister_handler("servertimezone", \&server_timezone_handler, 0, 1, 0);
+sub server_loncaparev_handler {
+ my ($cmd,$tail,$client) = @_;
+ my $userinput = "$cmd:$tail";
+ &Reply($client,\$perlvar{'lonVersion'},$userinput);
+ return 1;
+}
+®ister_handler("serverloncaparev", \&server_loncaparev_handler, 0, 1, 0);
+
# Process a reinit request. Reinit requests that either
# lonc or lond be reinitialized so that an updated
# host.tab or domain.tab can be processed.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.992 loncom/lonnet/perl/lonnet.pm:1.993
--- loncom/lonnet/perl/lonnet.pm:1.992 Sat Mar 21 21:43:46 2009
+++ loncom/lonnet/perl/lonnet.pm Sat Apr 11 14:47:51 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.992 2009/03/21 21:43:46 raeburn Exp $
+# $Id: lonnet.pm,v 1.993 2009/04/11 14:47:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -196,6 +196,33 @@
}
}
+sub get_server_loncaparev {
+ my ($dom,$lonhost) = @_;
+ if (defined($lonhost)) {
+ if (!defined(&hostname($lonhost))) {
+ undef($lonhost);
+ }
+ }
+ if (!defined($lonhost)) {
+ if (defined(&domain($dom,'primary'))) {
+ $lonhost=&domain($dom,'primary');
+ if ($lonhost eq 'no_host') {
+ undef($lonhost);
+ }
+ }
+ }
+ if (defined($lonhost)) {
+ my $cachetime = 24*3600;
+ my ($loncaparev,$cached)=&is_cached_new('serverloncaparev',$lonhost);
+ if (defined($cached)) {
+ return $loncaparev;
+ } else {
+ my $loncaparev = &reply('serverloncaparev',$lonhost);
+ return &do_cache_new('serverloncaparev',$lonhost,$loncaparev,$cachetime);
+ }
+ }
+}
+
# -------------------------------------------------- Non-critical communication
sub subreply {
my ($cmd,$server)=@_;
@@ -9055,7 +9082,7 @@
my @hosts;
my $ip;
- if (defined($name_to_ip{$dns})) {
+ if (exists($name_to_ip{$dns})) {
$ip = $name_to_ip{$dns};
}
if (!$ip) {