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
|
2010-09-08 17:40:02 -04:00
|
|
|
when :compute
|
|
|
|
Fog::AWS::Compute.new
|
2010-02-12 00:41:37 -05:00
|
|
|
when :ec2
|
2010-09-08 17:40:02 -04:00
|
|
|
location = caller.first
|
|
|
|
warning = "[yellow][WARN] AWS[:ec2] is deprecated, use AWS[:compute] instead[/]"
|
|
|
|
warning << " [light_black](" << location << ")[/] "
|
|
|
|
Formatador.display_line(warning)
|
|
|
|
Fog::AWS::Compute.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-08 17:40:02 -04:00
|
|
|
location = caller.first
|
|
|
|
warning = "[yellow][WARN] AWS[:s3] is deprecated, use AWS[:storage] instead[/]"
|
|
|
|
warning << " [light_black](" << location << ")[/] "
|
|
|
|
Formatador.display_line(warning)
|
|
|
|
Fog::AWS::Storage.new
|
|
|
|
when :storage
|
|
|
|
Fog::AWS::Storage.new
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
2010-09-03 18:32:30 -04:00
|
|
|
def services
|
2010-09-08 17:40:02 -04:00
|
|
|
[:compute, :elb, :simpledb, :storage]
|
2010-09-03 18:32:30 -04:00
|
|
|
end
|
|
|
|
|
2010-09-08 17:40:02 -04:00
|
|
|
for collection in Fog::AWS::Compute.collections
|
2010-09-02 19:01:19 -04:00
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
2010-09-08 17:40:02 -04:00
|
|
|
self[:compute].#{collection}
|
2010-09-02 19:01:19 -04:00
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
|
2010-09-08 17:40:02 -04:00
|
|
|
for collection in Fog::AWS::Storage.collections
|
2010-09-02 19:01:19 -04:00
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
2010-09-08 17:40:02 -04:00
|
|
|
self[:storage].#{collection}
|
2010-09-02 19:01:19 -04:00
|
|
|
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
|