Skip to content

Commit

Permalink
Credential Verification and Cleanup
Browse files Browse the repository at this point in the history
Fix credentials verification.  Cleanup extra log messages.
  • Loading branch information
jerryk55 committed Oct 9, 2018
1 parent 5a8194d commit 6c20977
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 5 additions & 9 deletions app/models/file_depot_swift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ def self.validate_settings(settings)
end

def connect(options = {})
uri = options[:uri]
host = URI(uri).host
openstack_handle(options).connect(options)
rescue Excon::Errors::Unauthorized => err
logger.error("Access to Swift host #{host} failed due to a bad username or password. #{err}")
nil
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

def openstack_handle(options = {})
Expand Down Expand Up @@ -51,8 +42,13 @@ def openstack_handle(options = {})
end

def verify_credentials(auth_type = 'default', options = {})
host = URI(options[:uri]).host
options[:auth_type] = auth_type
connect(options.merge(:auth_type => auth_type))
rescue Excon::Errors::Unauthorized => err
msg = "Access to Swift host #{host} failed due to a bad username or password."
logger.error("Access to Swift host #{host} failed due to a bad username or password. #{err}")
raise msg
rescue => err
logger.error("Error connecting to Swift host #{host}. #{err}")
msg = "Error connecting to Swift host #{host}. #{err}"
Expand Down
1 change: 0 additions & 1 deletion app/models/miq_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ def verify_file_depot(params) # TODO: This logic belongs in the UI, not sure wh
depot.v3_domain_ident = params[:v3_domain_ident]
depot.security_protocol = params[:security_protocol]
depot.uri = api_port.blank? ? uri : depot.merged_uri(uri, api_port)
_log.debug("uri is [#{uri}]")
if params[:save]
file_depot.save!
file_depot.update_authentication(:default => {:userid => params[:username], :password => params[:password]}) if (params[:username] || params[:password]) && depot.class.requires_credentials?
Expand Down

0 comments on commit 6c20977

Please sign in to comment.