Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: add openstack_storage_url option #454

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions lib/fog/openstack/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Core
attr_reader :openstack_project_id
attr_reader :openstack_project_domain_id
attr_reader :openstack_identity_api_version
attr_reader :openstack_storage_url

# fallback
def self.not_found_class
Expand Down Expand Up @@ -212,15 +213,7 @@ def authenticate

token = Fog::OpenStack::Auth::Token.build(openstack_options, @connection_options)

@openstack_management_url = if token.catalog && !token.catalog.payload.empty?
token.catalog.get_endpoint_url(
@openstack_service_type,
@openstack_endpoint_type,
@openstack_region
)
else
@openstack_auth_url
end
@openstack_management_url = management_url(token)

@current_user = token.user['name']
@current_user_id = token.user['id']
Expand All @@ -246,6 +239,20 @@ def authenticate!
@openstack_must_reauthenticate = true
authenticate
end

private

def management_url(token)
if token.catalog && !token.catalog.payload.empty?
token.catalog.get_endpoint_url(
@openstack_service_type,
@openstack_endpoint_type,
@openstack_region
)
else
@openstack_auth_url
end
end
end
end
end
17 changes: 12 additions & 5 deletions lib/fog/openstack/storage.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


module Fog
module OpenStack
class Storage < Fog::Service
Expand All @@ -13,7 +11,7 @@ class Storage < Fog::Service
:openstack_project_name, :openstack_project_id, :openstack_cache_ttl,
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
:openstack_identity_api_version, :openstack_temp_url_key
:openstack_identity_api_version, :openstack_temp_url_key, :openstack_storage_url

model_path 'fog/openstack/storage/models'
model :directory
Expand Down Expand Up @@ -55,7 +53,16 @@ def require_mime_types
Fog::Logger.warning("'mime-types' missing, please install and try again.")
exit(1)
end
end
end

def setup(options)
@openstack_storage_url = options[:openstack_storage_url]
super
end

def management_url(token)
@openstack_storage_url || super
end
end

class Mock
Expand Down Expand Up @@ -101,8 +108,8 @@ def reset_account_name
end

class Real
include Utils
include Fog::OpenStack::Core
include Utils

def self.not_found_class
Fog::OpenStack::Storage::NotFound
Expand Down