"Fossies" - the Fresh Open Source Software Archive

Member "opt/linuxha14/bin/clset" (28 Feb 2013, 3735 Bytes) of archive /linux/misc/linuxha14-1.4.11-i486-1.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

!/usr/bin/perl -w

BEGIN { if(!exists($::ENV{LINUXHA_LIBS})) { $::ENV{LINUXHA_LIBS}=“/opt/linuxha14/lib/perl”; } push @INC,$::ENV{LINUXHA_LIBS}; }

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

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

sub usage { print “ Usage: clset –application app [–nodes Nodes] [–verbose] [–nochecksums]

The clset allows the list of valid nodes configuration currently for an application to be changed. This is typically called when an application is currently running to reset the list of valid nodes after a software induced fail-over.

–application The application to check. –verbose Show some additional information whilst setting nodes. –nodes The nodes to use - leaving out will assume both nodes. –nochecksums Continue to allow the command even if the cluster or application checksums are not consistent.

Written by Simon Edwards, © 2003-2013, www.linuxha.net “; 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];

$::iptype=‘4’; if(exists($xml->{global}->{iptype})) { $::iptype=$xml->{global}->{iptype}; }

#

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_connection2($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_args=encode_json({APP => $ARG_application, FORWARD => ‘yes’, NODES => $ARG_nodes}); $cmd=“SETVALIDNODES $cmd_args”; $resp=get_cldaemon_info($conn,$cmd); if(!defined($resp)) { errmsg(“No response from cldaemon - did it die?”,4); } chomp $resp; logmsg(“Valid nodes changed for application.”); exit 0;