[LON-CAPA-cvs] cvs: loncom / production_dns_sanity.pl

www lon-capa-cvs-allow@mail.lon-capa.org
Tue, 20 May 2008 15:43:12 -0000


www		Tue May 20 11:43:12 2008 EDT

  Added files:                 
    /loncom	production_dns_sanity.pl 
  Log:
  Little testing program for domain tables
  
  

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

# Read the tables

open(IN,"production_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);
   $domserv{$domain}=$lib;
   $domname{$domain}=$name;
}
close(IN);
open(IN,"production_dns_hosts.tab");
while (my $line=<IN>) {
   if ($line=~/^\s*\#/) { next; }
   chomp($line);
   unless ($line=~/\S/) { next; }
   my ($server,$domain,$function,$ip)=split(/\:/,$line);
   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

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";
    }
}