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)
|
2011-08-02 11:58:18 -04:00
|
|
|
when :cloudstack
|
2011-09-07 10:25:08 -04:00
|
|
|
require 'fog/cloudstack/compute'
|
2011-08-02 11:58:18 -04:00
|
|
|
Fog::Compute::Cloudstack.new(attributes)
|
2011-09-30 17:46:05 -04:00
|
|
|
when :clodo
|
|
|
|
require 'fog/clodo/compute'
|
|
|
|
Fog::Compute::Clodo.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
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-06-15 02:10:54 -04:00
|
|
|
when :hp
|
|
|
|
require 'fog/hp/compute'
|
|
|
|
Fog::Compute::HP.new(attributes)
|
2012-01-10 17:20:56 -05:00
|
|
|
when :ibm
|
|
|
|
require 'fog/ibm/compute'
|
|
|
|
Fog::Compute::IBM.new(attributes)
|
2012-02-10 10:10:49 -05:00
|
|
|
when :joyent
|
|
|
|
require 'fog/joyent/compute'
|
|
|
|
Fog::Compute::Joyent.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)
|
2012-03-04 00:27:43 -05:00
|
|
|
when :new_servers
|
|
|
|
require 'fog/bare_metal_cloud/compute'
|
|
|
|
warn "[DEPRECATION] `new_servers` is deprecated. Please use `bare_metal_cloud` instead."
|
|
|
|
Fog::Compute::BareMetalCloud.new(attributes)
|
2012-03-01 21:54:49 -05:00
|
|
|
when :baremetalcloud
|
|
|
|
require 'fog/bare_metal_cloud/compute'
|
|
|
|
Fog::Compute::BareMetalCloud.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
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)
|
2011-09-26 02:41:54 -04:00
|
|
|
when :openstack
|
|
|
|
require 'fog/openstack/compute'
|
|
|
|
Fog::Compute::OpenStack.new(attributes)
|
2012-01-22 10:38:02 -05:00
|
|
|
when :ovirt
|
|
|
|
require 'fog/ovirt/compute'
|
|
|
|
Fog::Compute::Ovirt.new(attributes)
|
2011-06-16 19:28:54 -04:00
|
|
|
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 :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)
|
2012-04-02 07:25:03 -04:00
|
|
|
when :xenserver
|
|
|
|
require 'fog/xenserver/compute'
|
|
|
|
Fog::Compute::XenServer.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
|