mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
(cherry picked from commit b3d0bb3604af57d008844499781d9baf3d8e8d78)
This commit is contained in:
parent
511adca379
commit
e2d1cd6e6a
@ -188,19 +188,16 @@ module OneProvision
|
||||
c_key = CREDENTIALS_FILE[template['provider']]
|
||||
c_file = template['connection'][c_key]
|
||||
|
||||
if base64?(c_file)
|
||||
credentials = c_file
|
||||
else
|
||||
unless File.exist?(c_file)
|
||||
return OpenNebula::Error.new(
|
||||
"Credentials file doesn't exist"
|
||||
)
|
||||
# Load credentials file if exists
|
||||
begin
|
||||
if File.exist?(c_file)
|
||||
c_file = Base64.strict_encode64(File.read(c_file))
|
||||
end
|
||||
|
||||
credentials = Base64.strict_encode64(File.read(c_file))
|
||||
rescue StandardError => e
|
||||
return OpenNebula::Error.new("Loading credentials: #{e}")
|
||||
end
|
||||
|
||||
document['connection'][c_key] = credentials
|
||||
document['connection'][c_key] = c_file
|
||||
end
|
||||
|
||||
template.each do |key, value|
|
||||
@ -212,16 +209,6 @@ module OneProvision
|
||||
document.to_json
|
||||
end
|
||||
|
||||
# Check if value is in Base64 form
|
||||
#
|
||||
# @param value [Object] Object to check
|
||||
#
|
||||
# @return [Boolean] True if it is in Base64, false otherwise
|
||||
def base64?(value)
|
||||
value.is_a?(String) &&
|
||||
Base64.strict_encode64(Base64.decode64(value)) == value
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user