2010-02-12 05:41:37 +00:00
|
|
|
module AWS
|
|
|
|
class << self
|
|
|
|
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
|
|
|
if Fog.credentials[:aws_access_key_id] && Fog.credentials[:aws_secret_access_key]
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
|
|
|
hash[key] = case key
|
|
|
|
when :ec2
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::AWS::EC2.new
|
2010-05-02 07:13:35 +00:00
|
|
|
when :elb
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::AWS::ELB.new
|
2010-04-29 17:16:49 +00:00
|
|
|
when :simpledb
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::AWS::SimpleDB.new
|
2010-02-12 05:41:37 +00:00
|
|
|
when :s3
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::AWS::S3.new
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
2010-09-03 22:32:30 +00:00
|
|
|
def services
|
|
|
|
[:ec2, :elb, :simpledb, :s3]
|
|
|
|
end
|
|
|
|
|
2010-09-02 23:01:19 +00:00
|
|
|
for collection in Fog::AWS::EC2.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:ec2].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
|
2010-09-02 23:01:19 +00:00
|
|
|
for collection in Fog::AWS::S3.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:s3].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2010-09-02 23:01:19 +00:00
|
|
|
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|