[LON-CAPA-cvs] cvs: loncom / development_dns_domain.tab development_dns_sanity.pl

www www@source.lon-capa.org
Thu, 09 Jun 2011 19:36:06 -0000


www		Thu Jun  9 19:36:06 2011 EDT

  Added files:                 
    /loncom	development_dns_sanity.pl 

  Modified files:              
    /loncom	development_dns_domain.tab 
  Log:
  Development DNS Sanity and fixing MIT entry
  
  
Index: loncom/development_dns_domain.tab
diff -u loncom/development_dns_domain.tab:1.17 loncom/development_dns_domain.tab:1.18
--- loncom/development_dns_domain.tab:1.17	Thu Mar 31 22:52:15 2011
+++ loncom/development_dns_domain.tab	Thu Jun  9 19:36:06 2011
@@ -25,4 +25,4 @@
 #banghart:Development domain::banghartl1:::::banghartl1
 hope:Hope College Chemistry Development Server::tea01:::::tea01
 #nscldev:National Superconducting Cyclotron Lab Dev:krb4:MSU.EDU:en-US:East Lansing, MI:::nscldevl6
-MIT:MIT::::::MITd1
+MIT:MIT:::::::MITd1

Index: loncom/development_dns_sanity.pl
+++ loncom/development_dns_sanity.pl
use strict;
my %domserv=();
my %domname=();
my %hostdom=();
my %hostfunc=();

# Read the tables

open(IN,"development_dns_domain.tab");
while (my $line=<IN>) {
   if ($line=~/^\s*\#/) { next; }
   chomp($line);
   unless ($line=~/\S/) { next; }
   my ($domain,$name,$auth,$authparm,$lang,$city,$coord1,$coord2,$lib)=split(/\:/,$line);
   if ($domserv{$domain}) {
      print "Domain $domain defined more than once in domain.tab\n";
   }
   $domserv{$domain}=$lib;
   $domname{$domain}=$name;
}
close(IN);
open(IN,"development_dns_hosts.tab");
while (my $line=<IN>) {
   if ($line=~/^\s*\#/) { next; }
   chomp($line);
   unless ($line=~/\S/) { next; }
   my ($server,$domain,$function,$ip,$protocol,$interdom)=split(/\:/,$line);
   unless (($protocol eq 'http') || ($protocol eq 'https')) {
      print "Invalid protocol $protocol for $server\n";
   }
   unless ($interdom=~/\./) {
      print "Invalid internet domain $interdom for $server\n";
   }
   if ($hostdom{$server}) {
      print "$server defined more than once in hosts.tab\n";
   }
   $hostdom{$server}=$domain;
   $hostfunc{$server}=$function;
}
close(IN);

# Every mentioned library server should be in hosts.tab

my $doms=0;
foreach my $dom (keys %domserv) {
    unless ($hostdom{$domserv{$dom}} eq $dom) {
       print "Did not find $domserv{$dom} in hosts.tab\n";
    }
    unless ($hostfunc{$domserv{$dom}} eq 'library') {
       print "$domserv{$dom} is not a library server ($hostfunc{$domserv{$dom}})\n";
    }
    $doms++;
}

# Every server should have a valid domain

my $servs=0;
foreach my $serv (keys %hostdom) {
   unless ($domserv{$hostdom{$serv}}) {
      print "Server $serv has invalid domain in hosts.tab\n";
   }
   unless (($hostfunc{$serv} eq 'library') || ($hostfunc{$serv} eq 'access')) {
      print "Server $serv has invalid function $hostfunc{$serv} in hosts.tab\n";
   }
   $servs++;
}
print "\nValidated $doms domains and $servs servers\n";