Forum Discussion
mariogolf_57851
Nimbostratus
Mar 11, 2010System::Failover cannot seem to extract result from response data
Using a standard approach to System::Failover and obtaining response data for example:
sub get_failover_mode()
{
$soapResponse = $Failover->get_failover_mode();
print Dumper ($soapResponse);
&checkResponse($soapResponse);
@Response = @{$soapResponse->result};
$i = 0;
foreach $Response (@Response)
{
print "$Response \n";
$i++;
}
return(0);
}
For get_failover_mode or get_failover_state I cannot obtain anything from $soapResponse->result.
here is a data dumper of the ... $soapResponse.
How to extract the ENUM for ACTIVE or STANDBY state/modes.
Thanks
$VAR1 = bless( {
'_content' => [
'E:Envelope',
{
'xmlns:y' => 'http://www.w3.org/2001/XMLSchema',
'E:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
'xmlns:E' => 'http://schemas.xmlsoap.org/soap/envelope/',
'xmlns:iControl' => 'urn:iControl',
'xmlns:A' => 'http://schemas.xmlsoap.org/soap/encoding/',
'xmlns:s' => 'http://www.w3.org/2001/XMLSchema-instance'
},
[
[
'E:Body',
{},
[
[
'm:get_failover_stateResponse',
{
'xmlns:m' => 'urn:iControl:System/Failover'
},
[
[
'return',
{
's:type' => 'iControl:System.Failover.FailoverState'
},
'FAILOVER_STATE_ACTIVE',
undef,
'FAILOVER_STATE_ACTIVE',
'return',
{
's:type' => 'iControl:System.Failover.FailoverState',
'{http://www.w3.org/2001/XMLSchema-instance}type' => '{urn:iControl}System.Failover.FailoverState'
}
]
],
undef,
{
'return' => 'FAILOVER_STATE_ACTIVE'
},
'{urn:iControl:System/Failover}get_failover_stateResponse',
{}
]
],
undef,
{
'get_failover_stateResponse' => $VAR1->{'_content'}[2][0][2][0][4]
},
'{http://schemas.xmlsoap.org/soap/envelope/}Body',
{}
]
],
undef,
{
'Body' => $VAR1->{'_content'}[2][0][4]
},
'{http://schemas.xmlsoap.org/soap/envelope/}Envelope',
{
'E:encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
'{http://schemas.xmlsoap.org/soap/envelope/}encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/'
}
],
'_current' => [
$VAR1->{'_content'}
]
}, 'SOAP::SOM' );
- 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"; } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects