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-07-22 13:02:34 -04:00
|
|
|
Fog::Compute::StormOnDemand.new(attributes)
|
2011-07-11 05:50:16 -04:00
|
|
|
when :vcloud
|
2011-08-24 21:11:42 -04:00
|
|
|
require 'fog/vcloud/compute'
|
2011-05-23 21:17:16 -04:00
|
|
|
Fog::Vcloud::Compute.new(attributes)
|
2011-08-14 10:20:26 -04:00
|
|
|
when :virtualbox
|
2011-08-24 21:07:28 -04:00
|
|
|
require 'fog/virtual_box/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::VirtualBox.new(attributes)
|
|
|
|
when :voxel
|
2011-08-24 21:04:55 -04:00
|
|
|
require 'fog/voxel/compute'
|
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-07-27 10:30:49 -04:00
|
|
|
def self.providers
|
|
|
|
Fog.services[:compute]
|
|
|
|
end
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
def self.servers
|
|
|
|
servers = []
|
2011-07-27 10:30:49 -04:00
|
|
|
for provider in self.providers
|
2011-06-16 19:28:54 -04:00
|
|
|
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
|