2010-02-12 00:41:37 -05:00
|
|
|
module Terremark
|
|
|
|
class << self
|
2010-04-16 03:20:02 -04:00
|
|
|
if (Fog::Terremark::ECLOUD_OPTIONS.all? { |option| Fog.credentials.has_key?(option) } ) ||
|
|
|
|
(Fog::Terremark::VCLOUD_OPTIONS.all? { |option| Fog.credentials.has_key?(option) } )
|
2010-02-12 00:41:37 -05:00
|
|
|
|
|
|
|
def initialized?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2010-04-16 03:20:02 -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
|
|
|
|
end
|
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
|
|
|
credentials = Fog.credentials.reject do |k,v|
|
2010-04-16 03:20:02 -04:00
|
|
|
case key
|
|
|
|
when :ecloud
|
|
|
|
!Fog::Terremark::ECLOUD_OPTIONS.include?(k)
|
|
|
|
when :vcloud
|
|
|
|
!Fog::Terremark::VCLOUD_OPTIONS.include?(k)
|
|
|
|
end
|
|
|
|
end
|
2010-04-30 00:48:24 -04:00
|
|
|
hash[key] = terremark_service(key).new(credentials)
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
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
|