fog-openstack icon indicating copy to clipboard operation
fog-openstack copied to clipboard

When i use fog-openstack v0.1.17,i cannot connect to the glance and cinder service on my openstack environment.

Open zhoutiekui opened this issue 8 years ago • 3 comments
trafficstars

The codes:

require 'fog/openstack' require 'test/unit' require 'yaml' require 'fog/workflow/openstack/v2'

class NovaServersTest < Test::Unit::TestCase def setup @service = Fog::Volume::OpenStack.new({ :openstack_auth_url => 'https://iam.eu-de.otc.t-systems.com/v3/auth/tokens', # OpenStack Keystone endpoint :openstack_username => "jiangyaqun", # Your OpenStack Username :openstack_domain_id => "f88101e613dc440a80000813da0aedc0", # Your tenant id :openstack_api_key => "Jiang.yaqun", # Your OpenStack Password :openstack_project_name => "eu-de", :connection_options => {:ssl_verify_peer => false} # Optional }) end

def test_print
	p @service.volumes
end

end

The Error log: : test_print(NovaServersTest): NoMethodError: undefined method []' for nil :NilClass C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/openstack.rb :329:in authenticate_v3' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/openstack.rb :137:in authenticate' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/openstack/co re.rb:139:in authenticate' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/volume/opens tack/v2.rb:165:in initialize' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:1 15:in new' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:1 15:in new' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/volume/opens tack.rb:24:in new' C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/fog-openstack-0.1.17/lib/fog/volume/opens tack.rb:22:in `new'

And i found that there is a code assign the openstack_endpoint_type as adminURL,but on my openstack ,the adminurl is not be expolored to users,when i change it to "publicURL",it is ok.

def initialize(options = {})             initialize_identity options

            @openstack_service_type  = options[:openstack_service_type] || ['volumev2']             @openstack_service_name  = options[:openstack_service_name]             @openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'

            @connection_options = options[:connection_options] || {}

            authenticate             set_api_path

            @persistent = options[:persistent] || false             @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)           end

I think the adminURL maybe always not been authorized to users to access,so i suggest to change the adminURL definetion to publicURL, thanks.

zhoutiekui avatar Nov 23 '16 07:11 zhoutiekui

Hi @zhoutiekui,

We've made this configurable since accessibility is down to the individual cloud operator.

Just add :openstack_endpoint_type => 'publicURL' to your connection options and you should be fine.

seanhandley avatar Nov 24 '16 15:11 seanhandley

Hi @seanhandley
Thank you very much ,i use the method you provided and it is ok. Will the publicURL be set to the default value in the future fog-openstack versions? i think there are more Scenes using the public URL,thanks.

zhoutiekui avatar Nov 29 '16 08:11 zhoutiekui

I don't think so @zhoutiekui

The documentation makes the distinction that the internalURL is used internally by OpenStack services, the publicURL is used externally by users and the adminURL is used externally by users who may want to perform admin actions on the platform.

If you consider that, by default it makes sense to target the adminURL as default so that API calls made via Fog are able to call admin functions if the user account has the correct role assigned in Keystone. If we defaulted to publicURL then a lot of client code could suddenly start failing due to authorization errors.

seanhandley avatar Nov 29 '16 12:11 seanhandley