Forum Discussion
using perl iControl for system backups / archives
At my organization, we are trying to automate system backups of F5 LTM appliances. After considering many methods, I decided to use the iControl method mentioned.
http://devcentral.f5.com/wiki/default.aspx/iControl/PerlConfigSync.html
My only problem is I am trying to make the authentication fail and catch the authentication error. With the current code, when authentication fails the code simply aborts. Not being so knowledgeable about SOAP calls, I tried different things with no luck.
The reason I am after this is I am going to modify the script to handle more than one appliance and obviously we have non-standard logins (local auth) in our environment.
Any help would be greatly appreciated.
REgards,
Luke Yildirim
- Hamish
Cirrocumulus
Well. - Actually, the referenced sample includes some code I wrote to auto-insert the authentication headers in the first request.
$ConfigSync = SOAP::Lite -> uri('urn:iControl:System/ConfigSync') -> readable(1) -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi"); eval { $ConfigSync->transport->http_request->header ( 'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '') ); };
eval { $soap_response = $ConfigSync->get_configuration_list(); }; if ( $@ ) { print "ERROR: $@\n"; }
- Haluk_Yildirim_
Nimbostratus
Hello: - Anesh
Cirrostratus
Any update on this ?
- Anesh
Cirrostratus
Just tried the suggestion by Joe Pruitt and it works!!!
- Alexander_Hartm
Nimbostratus
Take a look at the BigIP::iControl module on CPAN. It does what F5 failed to do by putting all api calls into a module instead of a bunch of scripts.
- Alexander, we looked at putting the entire API library in a module but the complexities between all the parameter types for all 7000+ methods made it so we couldn't easily do it across the entire API hierarchy. The BIGIP::iControl module is a great use case for taking the APIs and pulling out a subset to make a useful library. If/When this gets to 100% coverage of the APIs, I'd be glad to take a look at getting the implementation built into our release distributions.
- Alexander_Hartm
Nimbostratus
Why was this no problem for e.g. the Python library? - The python library is dynamic in that it reads on the source WSDL and generates the proxy code on the fly. I consider myself a perl hack and honestly don't know the best way to package up all the APIs into a Perl module that makes sense with all the ways iControl uses parameters and return structures. I'd be game into looking at this is I can get guidance from a perl guru out there on how the package should be defined across all our interfaces and methods.
- wani_67522
Nimbostratus
Hello @nesh
I want to handle error HTTP401 when authenticatin failure occured. But I can't. Please show me how to work expectedly. I wrote below code,but still exits prematurely.So perl script ends with return code 0 regardless of authentication error.
use SOAP::Lite + trace => qw(method debug); use SOAP::Lite; use MIME::Base64; use Data::Dumper; my $sHost = $ARGV[0]; my $sUID = $ARGV[1]; my $sPWD = $ARGV[2]; my $sProtocol = "https"; my $sPort = 443; $SaveConfig = SOAP::Lite -> uri('urn:iControl:System/ConfigSync') -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi"); $SaveConfig->transport->http_request->header( 'Authorization' => 'Basic' . MIME::Base64::encode("$sUID:$sPWD",'') ); eval {$soap_response = $SaveConfig->get_configuration_list();}; if ($@) { print "ERROR: $@\n"; die "authentication error!!"; }
Best regards.
You need a space after "Basic" in the authentication header.
$SaveConfig->transport->http_request->header( 'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD",'') );
The correct format of the header should be
Authorization: Basic FADSFZDSAFDSAFDSAFDASF
Without the space it's coming through as
Authorization: BasicFDSFDSDFASAFDSAF
Not sure if this answers the catching of the exception question, but it should allow you to authenticate with correct credentials.
-Joe
- wani_67522
Nimbostratus
thanks Joe.
I did a type mistake when writing in this web form. I actually run script with space like 'Basic ' and can't catch the exception of invalid authentication bye eval command.
I can get valid authentication with correct user and password.
I wonder whether there are problem on environment with running SOAP script.
environment with running SOAP Script is below
AIX 5.3.0 and Perl 5.8.8
regards.
Recent Discussions
Related Content
* 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