2010-06-02 17:40:25 -04:00
|
|
|
require 'yaml'
|
2010-04-02 13:14:37 -04:00
|
|
|
module Fog
|
|
|
|
class << self
|
|
|
|
|
|
|
|
def credential=(new_credential)
|
|
|
|
@credential = new_credential
|
|
|
|
@credentials = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def credential
|
|
|
|
@credential || :default
|
|
|
|
end
|
|
|
|
|
2010-05-13 14:50:34 -04:00
|
|
|
def config_path
|
|
|
|
ENV["FOG_RC"] || '~/.fog'
|
|
|
|
end
|
|
|
|
|
2010-04-02 13:14:37 -04:00
|
|
|
def credentials
|
|
|
|
@credentials ||= begin
|
2010-05-13 14:50:34 -04:00
|
|
|
path = File.expand_path(config_path)
|
2010-04-02 13:14:37 -04:00
|
|
|
credentials = if File.exists?(path)
|
|
|
|
File.open(path) do |file|
|
|
|
|
YAML.load(file.read)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
unless credentials && credentials[credential]
|
2010-05-13 14:50:34 -04:00
|
|
|
print("\n To run as '#{credential}', add the following to #{config_path}\n")
|
2010-04-02 13:14:37 -04:00
|
|
|
yml = <<-YML
|
|
|
|
|
|
|
|
:#{credential}:
|
|
|
|
:aws_access_key_id: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
|
2010-06-02 00:40:46 -04:00
|
|
|
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
|
2010-06-02 12:06:26 -04:00
|
|
|
:bluebox_customer_id: INTENTIONALLY_LEFT_BLANK
|
2010-05-02 01:10:11 -04:00
|
|
|
:local_root: INTENTIONALLY_LEFT_BLANK
|
2010-06-23 16:22:20 -04:00
|
|
|
:new_servers_password: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:new_servers_username: INTENTIONALLY_LEFT_BLANK
|
2010-06-06 02:05:06 -04:00
|
|
|
:public_key_path: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:private_key_path: INTENTIONALLY_LEFT_BLANK
|
2010-04-02 13:14:37 -04:00
|
|
|
:rackspace_api_key: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:rackspace_username: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:slicehost_password: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:terremark_username: INTENTIONALLY_LEFT_BLANK
|
|
|
|
:terremark_password: INTENTIONALLY_LEFT_BLANK
|
|
|
|
YML
|
|
|
|
print(yml)
|
|
|
|
raise(ArgumentError.new("Missing Credentials"))
|
|
|
|
end
|
|
|
|
credentials[credential]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|