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