2010-02-12 00:41:37 -05: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|
|
|
|
|
credentials = Fog.credentials.reject do |k, v|
|
|
|
|
![:aws_access_key_id, :aws_secret_access_key].include?(k)
|
|
|
|
end
|
|
|
|
hash[key] = case key
|
|
|
|
when :ec2
|
|
|
|
Fog::AWS::EC2.new(credentials)
|
2010-05-02 03:13:35 -04:00
|
|
|
when :elb
|
|
|
|
Fog::AWS::ELB.new(credentials)
|
2010-04-29 13:16:49 -04:00
|
|
|
when :simpledb
|
|
|
|
Fog::AWS::SimpleDB.new(credentials)
|
2010-02-12 00:41:37 -05:00
|
|
|
when :s3
|
|
|
|
Fog::AWS::S3.new(credentials)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
|
|
|
def addresses
|
|
|
|
self[:ec2].addresses
|
|
|
|
end
|
|
|
|
|
|
|
|
def directories
|
|
|
|
self[:s3].directories
|
|
|
|
end
|
|
|
|
|
|
|
|
def flavors
|
|
|
|
self[:ec2].flavors
|
|
|
|
end
|
|
|
|
|
|
|
|
def images
|
|
|
|
self[:ec2].images
|
|
|
|
end
|
|
|
|
|
|
|
|
def servers
|
|
|
|
self[:ec2].servers
|
|
|
|
end
|
|
|
|
|
|
|
|
def key_pairs
|
|
|
|
self[:ec2].key_pairs
|
|
|
|
end
|
|
|
|
|
|
|
|
def security_groups
|
|
|
|
self[:ec2].security_groups
|
|
|
|
end
|
|
|
|
|
|
|
|
def snapshots
|
|
|
|
self[:ec2].snapshots
|
|
|
|
end
|
|
|
|
|
|
|
|
def volumes
|
|
|
|
self[:ec2].volumes
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|