2010-02-12 00:41:37 -05:00
|
|
|
module AWS
|
|
|
|
class << self
|
2010-09-07 18:39:38 -04:00
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
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 16:39:01 -04:00
|
|
|
Fog::AWS::EC2.new
|
2010-05-02 03:13:35 -04:00
|
|
|
when :elb
|
2010-09-02 16:39:01 -04:00
|
|
|
Fog::AWS::ELB.new
|
2010-04-29 13:16:49 -04:00
|
|
|
when :simpledb
|
2010-09-02 16:39:01 -04:00
|
|
|
Fog::AWS::SimpleDB.new
|
2010-02-12 00:41:37 -05:00
|
|
|
when :s3
|
2010-09-02 16:39:01 -04:00
|
|
|
Fog::AWS::S3.new
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
2010-09-03 18:32:30 -04:00
|
|
|
def services
|
|
|
|
[:ec2, :elb, :simpledb, :s3]
|
|
|
|
end
|
|
|
|
|
2010-09-02 19:01:19 -04:00
|
|
|
for collection in Fog::AWS::EC2.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:ec2].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
|
2010-09-02 19:01:19 -04:00
|
|
|
for collection in Fog::AWS::S3.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:s3].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2010-09-02 19:01:19 -04:00
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|