[LON-CAPA-cvs] cvs: loncom / loncron

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 25 Jul 2002 18:24:27 -0000


albertel		Thu Jul 25 14:24:27 2002 EDT

  Modified files:              
    /loncom	loncron 
  Log:
  - handles blanks lines in hosts.tab
  - sorts it's output
  
  
Index: loncom/loncron
diff -u loncom/loncron:1.30 loncom/loncron:1.31
--- loncom/loncron:1.30	Sat Jun  8 10:59:04 2002
+++ loncom/loncron	Thu Jul 25 14:24:27 2002
@@ -93,14 +93,21 @@
     my $config=IO::File->new("$perlvar{'lonTabDir'}/hosts.tab");
 
     while (my $configline=<$config>) {
-       my ($id,$domain,$role,$name,$ip)=split(/:/,$configline);
-       $hostname{$id}=$name;
-       $hostdom{$id}=$domain;
-       $hostrole{$id}=$role;
-       $hostip{$id}=$ip;
-       if (($role eq 'library') && ($id ne $perlvar{'lonHostID'})) {
-	   $libserv{$id}=$name;
-       }
+	my ($id,$domain,$role,$name,$ip,$domdescr)=split(/:/,$configline);
+	if ($id && $domain && $role && $name && $ip) {
+	    $hostname{$id}=$name;
+	    $hostdom{$id}=$domain;
+	    $hostip{$id}=$ip;
+	    $hostrole{$id}=$role;
+	    if ($domdescr) { $domaindescription{$domain}=$domdescr; }
+	    if (($role eq 'library') && ($id ne $perlvar{'lonHostID'})) {
+		$libserv{$id}=$name;
+	    }
+	} else {
+	    if ($configline) {
+#		&logthis("Skipping hosts.tab line -$configline-");
+	    }
+	}
     }
 }
 
@@ -160,17 +167,17 @@
 <table border=2>
 ENDHEADERS
 
-foreach $varname (keys %perlvar) {
+foreach $varname (sort(keys(%perlvar))) {
     print $fh "<tr><td>$varname</td><td>$perlvar{$varname}</td></tr>\n";
 }
 print $fh "</table><h3>Hosts</h3><table border=2>";
-foreach $id (keys %hostname) {
-print $fh 
-    "<tr><td>$id</td><td>$hostdom{$id}</td><td>$hostrole{$id}</td>";
-print $fh "<td>$hostname{$id}</td><td>$hostip{$id}</td></tr>\n";
+foreach $id (sort(keys(%hostname))) {
+    print $fh 
+	"<tr><td>$id</td><td>$hostdom{$id}</td><td>$hostrole{$id}</td>";
+    print $fh "<td>$hostname{$id}</td><td>$hostip{$id}</td></tr>\n";
 }
 print $fh "</table><h3>Spare Hosts</h3><ol>";
-foreach $id (keys %spareid) {
+foreach $id (sort(keys(%spareid))) {
     print $fh "<li>$id\n";
 }
 
@@ -643,7 +650,7 @@
 print $fh '<hr><a name="connections"><h2>Connections</h2>';
 
 print $fh "<table border=2>";
-foreach $tryserver (keys %hostname) {
+foreach $tryserver (sort(keys(%hostname))) {
 
     $answer=reply("pong",$tryserver);
     if ($answer eq "$tryserver:$perlvar{'lonHostID'}") {