2010-09-21 14:11:15 -04:00
|
|
|
class Terremark < Fog::Bin
|
2010-02-12 00:41:37 -05:00
|
|
|
class << self
|
|
|
|
|
2010-09-21 14:11:15 -04:00
|
|
|
def available?
|
|
|
|
Fog::Terremark::ECLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)} ||
|
|
|
|
Fog::Terremark::VCLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)}
|
|
|
|
end
|
2010-02-12 00:41:37 -05:00
|
|
|
|
2010-09-21 14:11:15 -04:00
|
|
|
def terremark_service(service)
|
|
|
|
case service
|
|
|
|
when :ecloud
|
|
|
|
Fog::Terremark::Ecloud
|
|
|
|
when :vcloud
|
|
|
|
Fog::Terremark::Vcloud
|
|
|
|
else
|
|
|
|
raise "Unsupported Terremark Service"
|
2010-04-18 19:27:22 -04:00
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
end
|
2010-04-18 19:27:22 -04:00
|
|
|
|
2010-09-21 14:11:15 -04:00
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
|
|
|
credentials = Fog.credentials.reject do |k,v|
|
|
|
|
case key
|
|
|
|
when :ecloud
|
|
|
|
!Fog::Terremark::ECLOUD_OPTIONS.include?(k)
|
|
|
|
when :vcloud
|
|
|
|
!Fog::Terremark::VCLOUD_OPTIONS.include?(k)
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
hash[key] = terremark_service(key).new(credentials)
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
@@connections[service]
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
end
|