1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/bin.rb

68 lines
1.7 KiB
Ruby
Raw Normal View History

module AWS
class << self
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
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
when :elb
Fog::AWS::ELB.new
when :simpledb
Fog::AWS::SimpleDB.new
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
end
end
@@connections[service]
end
def services
2010-09-08 17:40:02 -04:00
[:compute, :elb, :simpledb, :storage]
end
2010-09-08 17:40:02 -04:00
for collection in Fog::AWS::Compute.collections
module_eval <<-EOS, __FILE__, __LINE__
def #{collection}
2010-09-08 17:40:02 -04:00
self[:compute].#{collection}
end
EOS
end
2010-09-08 17:40:02 -04:00
for collection in Fog::AWS::Storage.collections
module_eval <<-EOS, __FILE__, __LINE__
def #{collection}
2010-09-08 17:40:02 -04:00
self[:storage].#{collection}
end
EOS
end
else
def initialized?
false
end
end
end
end