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-08-24 21:37:00 -04:00
|
|
|
require 'fog/aws/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::AWS.new(attributes)
|
|
|
|
when :bluebox
|
2011-08-24 21:32:51 -04:00
|
|
|
require 'fog/bluebox/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Bluebox.new(attributes)
|
|
|
|
when :brightbox
|
2011-09-05 04:02:33 -04:00
|
|
|
require 'fog/brightbox/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Brightbox.new(attributes)
|
|
|
|
when :ecloud
|
2011-08-24 21:29:14 -04:00
|
|
|
require 'fog/ecloud/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Ecloud.new(attributes)
|
2011-08-10 09:03:51 -04:00
|
|
|
when :glesys
|
2011-09-08 17:07:04 -04:00
|
|
|
require 'fog/glesys/compute'
|
2011-08-10 09:03:51 -04:00
|
|
|
Fog::Compute::Glesys.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
when :gogrid
|
2011-08-24 21:27:03 -04:00
|
|
|
require 'fog/go_grid/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::GoGrid.new(attributes)
|
2011-08-29 11:24:39 -04:00
|
|
|
when :libvirt
|
|
|
|
require 'fog/libvirt/compute'
|
|
|
|
Fog::Compute::Libvirt.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
when :linode
|
2011-08-24 21:24:45 -04:00
|
|
|
require 'fog/linode/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Linode.new(attributes)
|
|
|
|
when :newservers
|
2011-08-24 21:21:21 -04:00
|
|
|
require 'fog/new_servers/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::NewServers.new(attributes)
|
|
|
|
when :ninefold
|
2011-08-24 21:19:14 -04:00
|
|
|
require 'fog/ninefold/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Ninefold.new(attributes)
|
|
|
|
when :rackspace
|
2011-08-24 21:16:01 -04:00
|
|
|
require 'fog/rackspace/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Rackspace.new(attributes)
|
|
|
|
when :slicehost
|
2011-08-24 21:35:05 -04:00
|
|
|
require 'fog/slicehost/compute'
|
2011-06-16 19:28:54 -04:00
|
|
|
Fog::Compute::Slicehost.new(attributes)
|
|
|
|
when :stormondemand
|
2011-08-24 21:14:00 -04:00
|
|
|
require 'fog/storm_on_demand/compute'
|
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)
|
2011-09-16 08:57:00 -04:00
|
|
|
when :vmfusion
|
|
|
|
require 'fog/vmfusion/compute'
|
|
|
|
Fog::Compute::Vmfusion.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
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)
|
2011-08-29 23:04:04 -04:00
|
|
|
when :vsphere
|
|
|
|
require 'fog/vsphere/compute'
|
|
|
|
Fog::Compute::Vsphere.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
|