Forum Discussion
Mar 11, 2010
get_failover_mode returns a scalar, not an array. Here's some code that displays the failover state and mode.
!/usr/bin/perl
use SOAP::Lite + trace => qw(method debug);
use SOAP::Lite;
use MIME::Base64;
sub SOAP::Deserializer::typecast
{
my ($self, $value, $name, $attrs, $children, $type) = @_;
return $value;
}
----------------------------------------------------------------------------
Validate Arguments
----------------------------------------------------------------------------
my $sHost = $ARGV[0];
my $sUID = $ARGV[1];
my $sPWD = $ARGV[2];
my $sProtocol = "https";
if ( ($sHost eq "") or ($sUID eq "") or ($sPWD eq "") )
{
die ("Usage: SystemState.pl host port uid pwd\n");
}
----------------------------------------------------------------------------
Transport Information
----------------------------------------------------------------------------
sub SOAP::Transport::HTTP::Client::get_basic_credentials
{
return "$sUID" => "$sPWD";
}
$Failover = SOAP::Lite
-> uri('urn:iControl:System/Failover')
-> proxy("https://$sHost/iControl/iControlPortal.cgi");
eval { Failover->transport->http_request->header
(
'Authorization' =>
'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
); };
print "==========================================================\n";
&getSystemState();
&getFailoverMode();
print "==========================================================\n";
sub getSystemState()
{
$soapResponse = $Failover->get_failover_state();
if ( $soapResponse->fault )
{
print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
}
else
{
$FailoverState = $soapResponse->result;
print "System State : $FailoverState\n";
}
}
sub getFailoverMode()
{
$soapResponse = $Failover->get_failover_mode();
if ( $soapResponse->fault )
{
print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
}
else
{
$FailoverMode = $soapResponse->result;
print "Failover mode: $FailoverMode\n";
}
}
Hope that helps...