Getting Started With Ruby and iControl
Here on DevCentral we’ve released libraries for a number of the big languages from Java and Perl to Powershell. Up until now there has not been much love for Ruby. Well, that’s all about to ...
Published Jan 07, 2011
Version 1.0George_Watkins_
Historic F5 Account
Joined September 17, 2008
George_Watkins_
Historic F5 Account
Joined September 17, 2008
Sven_80544
Jun 13, 2012Nimbostratus
I had to patch the file lib/f5-icontrol.rb in order to make it work for me:
- It lacked the usage of the http_proxy I configured in my env, fixed by:
----------------------
@proxy = ENV['https_proxy'] in initialize()
----------------------
- The endpoint_url wasn't constructed the right way:
https://213.71.15.10//iControl/iControlPortal.cgi
makes the F5 do respond with a 302 (redirect) to the location "/tmui/login.jsp" which results in this error:
----------------------
/usr/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/util.rb:117:in `https?': undefined method `downcase' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:738:in `connect'
----------------------
This diff addresses both problems:
----------------------
--- /tmp/f5/lib/f5-icontrol.rb 1970-01-01 01:00:00.000000000 +0100
+++ lib/f5-icontrol.rb 2012-06-13 12:20:11.369138428 +0200
@@ -14,6 +14,7 @@
@wsdls = wsdls
@endpoint = '/iControl/iControlPortal.cgi'
@interfaces = {}
+ @proxy = ENV['https_proxy']
end
def get_interfaces
@@ -25,10 +26,11 @@
@interfaces[wsdl] = SOAP::WSDLDriverFactory.new('file://' + wsdl_path).create_rpc_driver
@interfaces[wsdl].options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE
@interfaces[wsdl].options['protocol.http.ssl_config.verify_callback'] = lambda{ |arg1, arg2| true }
+ @interfaces[wsdl].options['protocol.http.proxy'] = @proxy if !@proxy.nil?
- @interfaces[wsdl].options['protocol.http.basic_auth'] << ['https://' + @hostname + '/' + @endpoint, @username, @password]
- @interfaces[wsdl].endpoint_url = 'https://' + @hostname + '/' + @endpoint
+ @interfaces[wsdl].options['protocol.http.basic_auth'] << ['https://' + @hostname + @endpoint, @username, @password]
+ @interfaces[wsdl].endpoint_url = 'https://' + @hostname + @endpoint
end
end
----------------------