Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.887 and 1.888

version 1.887, 2007/06/11 19:31:41 version 1.888, 2007/06/13 01:43:54
Line 7600  sub machine_ids { Line 7600  sub machine_ids {
     my ($hostname) = @_;      my ($hostname) = @_;
     $hostname ||= &hostname($perlvar{'lonHostID'});      $hostname ||= &hostname($perlvar{'lonHostID'});
     my @ids;      my @ids;
     my %hostname = &all_hostnames();      my %name_to_host = &all_names();
     while( my($id, $name) = each(%hostname)) {      return @{ $name_to_host{$hostname} };
 # &logthis("-$id-$name-$hostname-");  
  if ($hostname eq $name) {  
     push(@ids,$id);  
  }  
     }  
     return @ids;  
 }  }
   
 sub additional_machine_domains {  sub additional_machine_domains {
Line 7720  sub correct_line_ends { Line 7714  sub correct_line_ends {
   
 sub goodbye {  sub goodbye {
    &logthis("Starting Shut down");     &logthis("Starting Shut down");
       &logthis("test");
 #not converted to using infrastruture and probably shouldn't be  #not converted to using infrastruture and probably shouldn't be
    &logthis(sprintf("%-20s is %s",'%badServerCache',length(&nfreeze(\%badServerCache))));     &logthis(sprintf("%-20s is %s",'%badServerCache',length(&nfreeze(\%badServerCache))));
 #converted  #converted
Line 7835  sub get_dns { Line 7830  sub get_dns {
     my %hostdom;      my %hostdom;
     my %libserv;      my %libserv;
     my $loaded;      my $loaded;
       my %name_to_host;
   
     sub parse_hosts_tab {      sub parse_hosts_tab {
  my ($file) = @_;   my ($file) = @_;
Line 7846  sub get_dns { Line 7842  sub get_dns {
     $name=~s/\s//g;      $name=~s/\s//g;
     if ($id && $domain && $role && $name) {      if ($id && $domain && $role && $name) {
  $hostname{$id}=$name;   $hostname{$id}=$name;
    push(@{$name_to_host{$name}}, $id);
  $hostdom{$id}=$domain;   $hostdom{$id}=$domain;
  if ($role eq 'library') { $libserv{$id}=$name; }   if ($role eq 'library') { $libserv{$id}=$name; }
     }      }
Line 7884  sub get_dns { Line 7881  sub get_dns {
  return %hostname;   return %hostname;
     }      }
   
       sub all_names {
    &load_hosts_tab() if (!$loaded);
   
    return %name_to_host;
       }
   
     sub is_library {      sub is_library {
  &load_hosts_tab() if (!$loaded);   &load_hosts_tab() if (!$loaded);
   
Line 8002  sub get_dns { Line 8005  sub get_dns {
  return %iphost;   return %iphost;
     }      }
  }   }
  my %hostname = &all_hostnames();   my %name_to_host = &all_names();
  foreach my $id (keys(%hostname)) {   foreach my $name (keys(%name_to_host)) {
     my $name=&hostname($id);  
     my $ip;      my $ip;
     if (!exists($name_to_ip{$name})) {      if (!exists($name_to_ip{$name})) {
  $ip = gethostbyname($name);   $ip = gethostbyname($name);
  if (!$ip || length($ip) ne 4) {   if (!$ip || length($ip) ne 4) {
     &logthis("Skipping host $id name $name no IP found");      &logthis("Skipping name $name no IP found");
     next;      next;
  }   }
  $ip=inet_ntoa($ip);   $ip=inet_ntoa($ip);
Line 8017  sub get_dns { Line 8019  sub get_dns {
     } else {      } else {
  $ip = $name_to_ip{$name};   $ip = $name_to_ip{$name};
     }      }
     $lonid_to_ip{$id} = $ip;      foreach my $id (@{ $name_to_host{$name} }) {
     push(@{$iphost{$ip}},$id);   $lonid_to_ip{$id} = $ip;
       }
       push(@{$iphost{$ip}},@{$name_to_host{$name}});
  }   }
  &Apache::lonnet::do_cache_new('iphost','iphost',   &Apache::lonnet::do_cache_new('iphost','iphost',
       [\%iphost,\%name_to_ip,\%lonid_to_ip],        [\%iphost,\%name_to_ip,\%lonid_to_ip],

Removed from v.1.887  
changed lines
  Added in v.1.888


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>