#!/usr/bin/perl =pod =head1 SYNOPSIS clusteradmin command [args] =head1 DESCRIPTION Performs an adiminstrative action on all hosts in the current dns_hosts.tab 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 Furthermore, lonc must be running on this system. The action is specified by the 'command' parameter which may have additional arguments. All communications with remote clients are made critical so that they will eventually happen even if the host we want to talk with is dead. =head1 ACTIONS =over 3 =item help Outputs a brief description of the actions supported and what they do. =item update file Update the contents of an administrative file with the contents of that file on this system. 'file' is the name of that file, not the path for example: clusteradmin update dns_hosts.tab =back =cut use strict; #---------------------------------------------------------------------------------- # # Command dispatch handling: # # Dispatch hash for the subcommands. # indexed by the subcommand name, each item is # a reference to the sub that handles the command: # my %Dispatch; # # Define a subcommand: # # Parameters: # command - subcommand name string # handler - reference to the handler sub. # Notes: # The handler is dispatched to with the tail of the command # as an array reference parameter. Suppose the command is # # clusteradmin update dns_hosts.tab, # # the array will have a single element: 'dns_hosts.tab'. # sub define_command { my ($command, $handler) = @_; $Dispatch{$command} = $handler; } # # Dispatch to a command: # Parameters: # command - Name of the command. # tail - Reference to the command tail array. # Returns: # 1 - Success. # 0 - Failure # Notes: # 1. The command handler is assumed to have output any error messages # to stderr by now. # 2. This function will indicate to stderr if the command isn't in the # dispatch hash. # sub dispatch_command { my ($command, $tail) = @_; my $sub; if (exists($Dispatch{$command})) { $sub = $Dispatch{$command}; return $sub->($tail); } else { print STDERR "Unrecognized subcommand keyword $command\n"; &usage(); return 0; } } #-----------------------------------------------------------------------------------