Diff for /loncom/clusteradmin between versions 1.2 and 1.4

version 1.2, 2009/03/16 09:43:00 version 1.4, 2011/05/12 14:08:54
Line 8 Line 8
   
 =head1 DESCRIPTION  =head1 DESCRIPTION
   
 Performs an adiminstrative action on all hosts in the current dns_hosts.tab  Performs an adminstrative action on DNS hosts in the current hosts.tab
 file.  For this to work, the current host must be the cluster administrator  file.  For this to work, the current host must be the cluster administrator
 on the target systems.  That is this must be a host in managers.tab  on the target systems.  That is this must be a host in managers.tab
 Furthermore, lonc must be running on this system.  Furthermore, lonc must be running on this system.
Line 16  Furthermore, lonc must be running on thi Line 16  Furthermore, lonc must be running on thi
 The action is specified by the 'command' parameter which may have additional arguments.  The action is specified by the 'command' parameter which may have additional arguments.
   
 All communications with remote clients are made critical so that  All communications with remote clients are made critical so that
 they will eventually happen even if the147 host we want to talk with  they will eventually happen even if the host we want to talk with
 is dead.  is dead.
   
   
Line 219  sub push_file { Line 219  sub push_file {
   
     foreach my $host (@$hosts) {      foreach my $host (@$hosts) {
  my $loncapa_name = &Apache::lonnet::host_from_dns($host);   my $loncapa_name = &Apache::lonnet::host_from_dns($host);
           next if ($loncapa_name eq $config{'lonHostID'});
  my $reply  = &Apache::lonnet::critical($cmd, $loncapa_name);   my $reply  = &Apache::lonnet::critical($cmd, $loncapa_name);
  if ($reply ne 'ok') {   if ($reply ne 'ok') {
     print STDERR "Reply from $host ($loncapa_name)  not 'ok' was: $reply\n";      print STDERR "Reply from $host ($loncapa_name)  not 'ok' was: $reply\n";
Line 260  sub update_file { Line 261  sub update_file {
     }      }
 }  }
 &define_command("update", \&update_file);  &define_command("update", \&update_file);
   
   #
   # Checks if current lonHostID is in managers.tab for the cluster, and is in the cluster.
   # Parameters:
   #    args   - none
   # Returns:
   #    1      - lonHostID is is managers.tab
   #    ''     - Failure (printing messages to STDERR).
   #
   sub is_manager {
       my $currhost = $config{'lonHostID'};
       my $canmanage;
       if ($currhost eq '') {
           print STDERR "Could not determine LON-CAPA host ID\n";
           return;
       } elsif (!defined &Apache::lonnet::get_host_ip($currhost)) {
           print STDERR "This LON-CAPA host is not part of the cluster.\n";
       }
       my $tablename = &construct_table_path('managers.tab');
       if (!open (MANAGERS, $tablename)) {
           print STDERR "No managers.tab table. Could not verify host is a manager\n";
           return;
       }
       while(my $host = <MANAGERS>) {
           chomp($host);
           next if ($host =~ /^\#/);
           if ($host eq $currhost) {
               $canmanage = 1;
               last;
           }
       }
       close(MANAGERS);
       return $canmanage;
   }
 #---------------------------------------------------------------------------------  #---------------------------------------------------------------------------------
 #  #
 #  Program entry point.  Decode the subcommand from the args array and  #  Program entry point.  Decode the subcommand from the args array and
Line 273  if ($argc == 0) { Line 308  if ($argc == 0) {
     exit(-1);      exit(-1);
 }  }
   
   if (!&is_manager()) {
       print STDERR  'Script needs to be run from a server designated as a "Manager" in the LON-CAPA cluster'."\n";
       exit(-1);
   }
   
 my $subcommand = shift(@ARGV);     # argv now the tail.  my $subcommand = shift(@ARGV);     # argv now the tail.
   
 if (!&dispatch_command($subcommand, \@ARGV)) {  if (!&dispatch_command($subcommand, \@ARGV)) {

Removed from v.1.2  
changed lines
  Added in v.1.4


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