2010-02-12 00:41:37 -05:00
|
|
|
module Terremark
|
|
|
|
class << self
|
|
|
|
if Fog.credentials[:terremark_password] && Fog.credentials[:terremark_username]
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-04-18 19:27:22 -04:00
|
|
|
def terremark_service
|
|
|
|
@terremark_service ||= begin
|
|
|
|
Fog.credentials[:terremark_service] || :vcloud
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
|
|
|
credentials = Fog.credentials.reject do |k,v|
|
|
|
|
![:terremark_username, :terremark_password].include?(k)
|
|
|
|
end
|
2010-04-18 19:27:22 -04:00
|
|
|
hash[key] = Fog::Terremark.new(credentials.merge(:terremark_service => terremark_service))
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
|
2010-04-18 19:27:22 -04:00
|
|
|
def servers
|
|
|
|
self[terremark_service].servers
|
|
|
|
end
|
|
|
|
|
|
|
|
def tasks
|
|
|
|
self[terremark_service].tasks
|
|
|
|
end
|
|
|
|
|
2010-02-15 20:15:56 -05:00
|
|
|
else
|
|
|
|
|
|
|
|
def initialized?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|