2010-10-29 16:24:34 -07:00
|
|
|
module Fog
|
2011-06-16 16:28:54 -07:00
|
|
|
module Compute
|
|
|
|
|
|
|
|
def self.[](provider)
|
|
|
|
self.new(:provider => provider)
|
|
|
|
end
|
2010-10-29 16:24:34 -07:00
|
|
|
|
|
|
|
def self.new(attributes)
|
2010-12-13 17:51:16 -08:00
|
|
|
attributes = attributes.dup # prevent delete from having side effects
|
2011-06-16 16:39:51 -07:00
|
|
|
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
2011-06-16 16:28:54 -07:00
|
|
|
when :aws
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/aws'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::AWS.new(attributes)
|
|
|
|
when :bluebox
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/bluebox'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Bluebox.new(attributes)
|
|
|
|
when :brightbox
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/brightbox'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Brightbox.new(attributes)
|
|
|
|
when :ecloud
|
2011-02-17 10:44:46 -08:00
|
|
|
require 'fog/compute/ecloud'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Ecloud.new(attributes)
|
|
|
|
when :gogrid
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/go_grid'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::GoGrid.new(attributes)
|
|
|
|
when :linode
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/linode'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Linode.new(attributes)
|
|
|
|
when :newservers
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/new_servers'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::NewServers.new(attributes)
|
|
|
|
when :ninefold
|
2011-04-17 10:43:30 +10:00
|
|
|
require 'fog/compute/ninefold'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Ninefold.new(attributes)
|
|
|
|
when :rackspace
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/rackspace'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Rackspace.new(attributes)
|
|
|
|
when :slicehost
|
2011-01-07 18:12:05 -08:00
|
|
|
require 'fog/compute/slicehost'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Slicehost.new(attributes)
|
|
|
|
when :stormondemand
|
2011-05-10 13:58:22 -07:00
|
|
|
require 'fog/compute/storm_on_demand'
|
2011-07-22 12:02:34 -05:00
|
|
|
Fog::Compute::StormOnDemand.new(attributes)
|
2011-07-11 19:50:16 +10:00
|
|
|
when :vcloud
|
2011-05-24 11:17:16 +10:00
|
|
|
require 'fog/compute/vcloud'
|
|
|
|
Fog::Vcloud::Compute.new(attributes)
|
|
|
|
when 'VirtualBox'
|
2011-03-09 17:03:15 -08:00
|
|
|
require 'fog/compute/virtual_box'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::VirtualBox.new(attributes)
|
|
|
|
when :voxel
|
2011-03-09 17:03:15 -08:00
|
|
|
require 'fog/compute/voxel'
|
2011-06-16 16:28:54 -07:00
|
|
|
Fog::Compute::Voxel.new(attributes)
|
2010-10-29 16:24:34 -07:00
|
|
|
else
|
2010-11-08 16:58:02 +00:00
|
|
|
raise ArgumentError.new("#{provider} is not a recognized compute provider")
|
2010-10-29 16:24:34 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-07-27 09:30:49 -05:00
|
|
|
def self.providers
|
|
|
|
Fog.services[:compute]
|
|
|
|
end
|
|
|
|
|
2011-06-16 16:28:54 -07:00
|
|
|
def self.servers
|
|
|
|
servers = []
|
2011-07-27 09:30:49 -05:00
|
|
|
for provider in self.providers
|
2011-06-16 16:28:54 -07:00
|
|
|
begin
|
|
|
|
servers.concat(self[provider].servers)
|
|
|
|
rescue # ignore any missing credentials/etc
|
|
|
|
end
|
|
|
|
end
|
|
|
|
servers
|
|
|
|
end
|
|
|
|
|
2010-10-29 16:24:34 -07:00
|
|
|
end
|
2011-01-07 16:52:09 -08:00
|
|
|
end
|