"Fossies" - the Fresh Open Source Software archive

Member "sbin/cluster/clset" of archive linuxha14-1.4.9-i486-1.tgz:


#!/usr/bin/perl -w

BEGIN {
	push @INC,"/usr/local/cluster/lib/perl";
}

use clutils;
use File::Basename;
use Getopt::Long;

$ARG_application=undef;
$ARG_nodes=undef;
$ARG_nochecksums=0;
$ARG_verbose=0;

sub usage {
	print "
";
	exit 1;
}

Getopt::Long::Configure("no_ignore_case");

if(!GetOptions(
	"nochecksums"		=> \$ARG_nochecksums,
	"A|application=s"	=> \$ARG_application,
	"V|verbose"		=> \$ARG_verbose,
	"N|nodes=s"		=> \$ARG_nodes,
)) {
	usage;
}

usage if !defined($ARG_application);
$ARG_config="/etc/cluster/clconf.xml" if ! defined $ARG_config;

#########################################################################
# Load the cluster configuration and validate before continuing.	#
#########################################################################

@info=validate_cluster_cfg($ARG_config,$ARG_nochecksums);
if(scalar(@info)>1) {
	$rc=$info[1];
	foreach (@info[2..$#info]) {
		errmsg($_);
	}
	exit($rc);
}
$xml=$info[0];

#########################################################################
# If nodes have been specified validate them.				#
#########################################################################
@nodes=sort(keys(%{$xml->{node}}));
if(defined($ARG_nodes)) {
	@t=split(/,/,$ARG_nodes);
	if(@t >2) {
		errmsg("Specified node list contains more than 2 nodes!",1);
	}
	for $cnode (@t) {
		if(!scalar(grep {$_ eq $cnode} @nodes)) {
			errmsg("Node '$cnode' is not part of the cluster.",1);
		}
	}
} else {
	$ARG_nodes=join(",",@nodes);
}

#########################################################################
# Get a connection of a cluster daemon or abort.			#
#########################################################################

$xml=$info[0];
logmsg("Validated checksum for cluster configuration");
$conn=get_cldaemon_connection($xml);
if(!defined($conn)) {
        errmsg("Cluster ".$xml->{global}->{name}." is not running.",3);
}

#########################################################################
# Now validate the applicatino information or abort.			#
#########################################################################

@info=validate_application_cfg($ARG_application,$ARG_nochecksums);

if(!defined($info[0])) {
	$rc=$info[1];
	foreach (@info[2..$#info]) {
		errmsg($_);
	}
	exit($rc);
}
logmsg("Validated application configuration.");

#########################################################################
# Now build up the message to send ... it will be SETVALIDNODES with	#
# suitable arguments...							#
#########################################################################

$cmd="SETVALIDNODES APP=$ARG_application FORWARD=yes NODES=$ARG_nodes";
$resp=get_cldaemon_info($conn,$cmd);
if(!defined($resp)) {
	errmsg("No response from cldaemon - did it die?",4);
}
chomp $resp;
print "$resp\n";
exit 0;