softlayer / softlayer-ruby

http://softlayer.github.io/softlayer-ruby/
MIT License
54 stars 35 forks source link

Ruby API Bug #70

Closed MiguelHigorre closed 9 years ago

MiguelHigorre commented 9 years ago

A customer reported the following issue related to ruby client (this is the ticket internal 15654742)

I can reproduce this on the current code base:

[2] pry(main)> SoftLayer::VERSION => "3.0.0"

This matches the current repo (and gem update gives nothing for it)

https://github.com/softlayer/softlayer-ruby/blob/33eebb44839a2a781c080c18f66364ad7e99b9fe/lib/softlayer/base.rb

VERSION = "3.0.0" # version history in the CHANGELOG.textile file at the root of the source

The problem is ConfigParser pulls the timeout value as a string but XMLRPC::Client expects an integer, and this never gets translated anywhere along the way.

Line 98 in lib/softlayer/Config.rb result[:timeout] = softlayer_section['timeout'] if softlayer_section['timeout']

line 91 in lib/softlayer/Client.rb @network_timeout = settings[:timeout] if settings.has_key?(:timeout)

line 288 in lib/softlayer/Service.rb @xmlrpc_client = XMLRPC::Client.new2(URI.join(@client.endpoint_url,@service_name).to_s, nil, @client.network_timeout)

This is the line that causes the error since @client.network_timeout is a string

[4] pry(main)> SoftLayer::Service.new('Account').client.network_timeout.class => String

And when passed to XMLRPC::Client.new2, produces (this is just standard XMLRPC code, the same XMLRPC library is used with XenServer):

[16] pry(main)> XMLRPC::Client.new2('http://10.80.9.148', nil, "40").call('session.login_with_password','a','b') NoMethodError: undefined method zero?' for "40":String from /home/main/.rbenv/versions/2.1.1/lib/ruby/2.1.0/timeout.rb:76:intimeout'

Ideally that should be casted to int as soon as it's parsed, but the safest bet would be to ensure the timeout is passed as an int directly to the XMLRPC client.

SLsthompson commented 9 years ago

OK. This looks like a fairly easy thing to fix. Let me see what I can do.

SLsthompson commented 9 years ago

The head of the project now contains a fix for this issue. I will look at putting together a 3.1.0 release with this fix and issue #64