2010-02-12 05:41:37 +00:00
|
|
|
module Rackspace
|
|
|
|
class << self
|
|
|
|
if Fog.credentials[:rackspace_api_key] && Fog.credentials[:rackspace_username]
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
|
|
|
hash[key] = case key
|
|
|
|
when :files
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::Rackspace::Files.new
|
2010-02-12 05:41:37 +00:00
|
|
|
when :servers
|
2010-09-02 20:39:01 +00:00
|
|
|
Fog::Rackspace::Servers.new
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
2010-09-03 22:32:30 +00:00
|
|
|
def services
|
|
|
|
[:files, :servers]
|
|
|
|
end
|
|
|
|
|
2010-09-02 23:01:19 +00:00
|
|
|
for collection in Fog::Rackspace::Files.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:files].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
|
2010-09-02 23:01:19 +00:00
|
|
|
for collection in Fog::Rackspace::Servers.collections
|
|
|
|
module_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def #{collection}
|
|
|
|
self[:servers].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
2010-02-12 05:41:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|