1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/compute.rb

71 lines
2.2 KiB
Ruby
Raw Normal View History

2010-10-29 19:24:34 -04:00
module Fog
module Compute
def self.[](provider)
self.new(:provider => provider)
end
2010-10-29 19:24:34 -04:00
def self.new(attributes)
attributes = attributes.dup # prevent delete from having side effects
case provider = attributes.delete(:provider).to_s.downcase.to_sym
when :aws
2011-01-07 21:12:05 -05:00
require 'fog/compute/aws'
Fog::Compute::AWS.new(attributes)
when :bluebox
2011-01-07 21:12:05 -05:00
require 'fog/compute/bluebox'
Fog::Compute::Bluebox.new(attributes)
when :brightbox
2011-01-07 21:12:05 -05:00
require 'fog/compute/brightbox'
Fog::Compute::Brightbox.new(attributes)
when :ecloud
require 'fog/compute/ecloud'
Fog::Compute::Ecloud.new(attributes)
when :gogrid
2011-01-07 21:12:05 -05:00
require 'fog/compute/go_grid'
Fog::Compute::GoGrid.new(attributes)
when :linode
2011-01-07 21:12:05 -05:00
require 'fog/compute/linode'
Fog::Compute::Linode.new(attributes)
when :newservers
2011-01-07 21:12:05 -05:00
require 'fog/compute/new_servers'
Fog::Compute::NewServers.new(attributes)
when :ninefold
require 'fog/compute/ninefold'
Fog::Compute::Ninefold.new(attributes)
when :rackspace
2011-01-07 21:12:05 -05:00
require 'fog/compute/rackspace'
Fog::Compute::Rackspace.new(attributes)
when :slicehost
2011-01-07 21:12:05 -05:00
require 'fog/compute/slicehost'
Fog::Compute::Slicehost.new(attributes)
when :stormondemand
2011-05-10 16:58:22 -04:00
require 'fog/compute/storm_on_demand'
Fog::StormOnDemand::Compute.new(attributes)
when :vcloud
require 'fog/compute/vcloud'
Fog::Vcloud::Compute.new(attributes)
when 'VirtualBox'
require 'fog/compute/virtual_box'
Fog::Compute::VirtualBox.new(attributes)
when :voxel
require 'fog/compute/voxel'
Fog::Compute::Voxel.new(attributes)
2010-10-29 19:24:34 -04:00
else
raise ArgumentError.new("#{provider} is not a recognized compute provider")
2010-10-29 19:24:34 -04:00
end
end
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