Skip to content

Commit

Permalink
Remove manageiq-providers-openstack dependency
Browse files Browse the repository at this point in the history
Allows us to use vanilla `fog/openstack` for handling connection to
Swift, and avoids the need for requiring a provider library in
gems-pending.

Ideally, this code should live in the `mangeiq-providers-openstack`
repo, but that is a bit of a large re-arrange, so for now we will stick
with this.
  • Loading branch information
NickLaMuro committed Oct 9, 2018
1 parent 3c65a80 commit cd2beb7
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/gems/pending/util/object_storage/miq_swift_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,26 @@ def container

def swift
return @swift if @swift
require 'manageiq/providers/openstack/legacy/openstack_handle'
extra_options = {}
extra_options[:domain_id] = @domain_id
extra_options[:service] = "Compute"
require 'fog/openstack'

@osh ||= OpenstackHandle::Handle.new(@username, @password, @host, @port, @api_version, @security_protocol, extra_options)
@osh.connection_options = {:instrumentor => $fog_log}
begin
@swift ||= @osh.swift_service
rescue Excon::Errors::Unauthorized => err
logger.error("Access to Swift host #{@host} failed due to a bad username or password. #{err}")
msg = "Access to Swift host #{@host} failed due to a bad username or password. #{err}"
raise err, msg, err.backtrace
rescue => err
logger.error("Error connecting to Swift host #{@host}. #{err}")
msg = "Error connecting to Swift host #{@host}. #{err}"
raise err, msg, err.backtrace
end
auth_url = URI::Generic.build(
:scheme => @security_protocol == 'non-ssl' ? "http" : "https",
:host => @host,
:port => @port.to_i,
:path => "/#{@api_version}#{@api_version == "v3" ? "/auth" : ".0"}/tokens"
).to_s

connection_params = {
:openstack_auth_url => auth_url,
:openstack_username => @username,
:openstack_api_key => @password,
:openstack_project_domain_id => @domain_id,
:openstack_user_domain_id => @domain_id,
:openstack_region => @region,
:connection_options => { :debug_request => true }
}

swift = Fog::Storage::OpenStack.new(connection_params)
end

def create_container
Expand Down

0 comments on commit cd2beb7

Please sign in to comment.