我正在尝试使用'ruby-openstack'宝石连接Openstack(devstack):
os = OpenStack::Connection.create({
:username => "admin",
:auth_method => 'password',
:api_key => "supersecret",
:auth_url => "http://192.168.52.162/" })
但我收到了这个错误:
URI::InvalidURIError: bad URI(is not URI?):
from /usr/lib/ruby/1.9.1/uri/common.rb:176:in 'split'
from /usr/lib/ruby/1.9.1/uri/common.rb:211:in 'parse'
from /usr/lib/ruby/1.9.1/uri/common.rb:747:in 'parse'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/connection.rb:399:in 'initialize'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/connection.rb:263:in 'new'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/connection.rb:263:in 'init'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/compute/connection.rb:12:in 'initialize'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/connection.rb:66:in 'new'
from /var/lib/gems/1.9.1/gems/openstack-1.1.2/lib/openstack/connection.rb:66:in 'create'
from (irb):58
from /usr/bin/irb:12:in '<main>'
我真的不明白为什么我的网址“http://192.168.52.162/”被解析为错误的URI。在使用Wireshark分析网络之后,当我看到GET请求和HTTP 200 OK响应时,似乎发送了HTTP请求。
为什么URI被认为是错误的,如果行中有错误,如何发送HTTP请求?
答案 0 :(得分:1)
看起来它不一定会抱怨你的网址,而是关于某种响应网址:
https://github.com/ruby-openstack/ruby-openstack/blob/v1.1.2/lib/openstack/connection.rb#L399
uri = URI.parse(response["x-server-management-url"])
您可以尝试在本地计算机上访问该gem的代码,并在响应对象中添加一些日志记录/调试,以便更好地处理错误。 (gem which openstack
应该为您提供路径)