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

Initial add of voxel provider, framework in place for compute and image listing

This commit is contained in:
James W. Brinkerhoff 2011-01-19 15:47:35 -05:00 committed by geemus
parent 1a0afbc6ed
commit d1606e69cc
10 changed files with 146 additions and 0 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ doc/*
rdoc
pkg
spec/credentials.yml
*~

View file

@ -65,4 +65,5 @@ require 'fog/bin/new_servers'
require 'fog/bin/rackspace'
require 'fog/bin/slicehost'
require 'fog/bin/terremark'
require 'fog/bin/voxel'
require 'fog/bin/zerigo'

30
lib/fog/bin/voxel.rb Normal file
View file

@ -0,0 +1,30 @@
class Voxel < Fog::Bin
class << self
def class_for(key)
case key
when :compute
Fog::Voxel::Compute
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Compute.new(:provider => 'Voxel')
else
raise ArgumentError, "Unrecognized service: #{service}"
end
end
@@connections[service]
end
def services
[:compute]
end
end
end

View file

@ -28,6 +28,9 @@ module Fog
when 'Rackspace'
require 'fog/compute/rackspace'
Fog::Rackspace::Compute.new(attributes)
when 'Voxel'
require 'fog/compute/voxel'
Fog::Voxel::Compute.new(attributes)
when 'Slicehost'
require 'fog/compute/slicehost'
Fog::Slicehost::Compute.new(attributes)

View file

@ -0,0 +1,13 @@
require 'fog/core/model'
module Fog
module Voxel
class Compute
class Image < Fog::Model
identity :id
attribute :name
end
end
end
end

View file

@ -0,0 +1,28 @@
require 'fog/core/collection'
require 'fog/compute/models/voxel/image'
module Fog
module Voxel
class Compute
class Images < Fog::Collection
model Fog::Voxel::Compute::Image
def all
data = connection.images_list
load(data)
end
def get(image_id)
data = connection.images_list(image_id).body['image']
new(data)
rescue Fog::Voxel::Compute::NotFound
nil
end
end
end
end
end

View file

@ -0,0 +1,25 @@
module Fog
module Voxel
class Compute
class Real
def images_list( image_id = nil )
options = { :verbosity => 'compact' }
unless image_id.nil?
options[:verbosity] = 'extended'
options[:image_id] = image_id
end
data = request("voxel.images.list", options)
data['images']['image'].map { |i| { :id => i['id'], :name => i['summary'] } }
end
end
class Mock
def images_list
Fog::Mock.not_implemented
end
end
end
end
end

33
lib/fog/compute/voxel.rb Normal file
View file

@ -0,0 +1,33 @@
module Fog
module Voxel
class Compute < Fog::Service
requires :voxel_api_key, :voxel_api_secret
model_path 'fog/compute/models/voxel'
model :image
collection :images
request_path 'fog/compute/requests/voxel'
request :images_list
class Mock
include Collections
end
class Real
include Collections
def initialize(options = {})
require 'hapi'
@connection = HAPI.new( :authkey => { :key => options[:voxel_api_key], :secret => options[:voxel_api_secret] }, :default_format => :ruby )
end
def request(voxel_method_name, options = {})
STDERR.puts "Got called"
@connection.send(voxel_method_name, options)
end
end
end
end
end

View file

@ -75,6 +75,8 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
:slicehost_password:
:terremark_username:
:terremark_password:
:voxel_api_key:
:voxel_api_secret:
:zerigo_email:
:zerigo_token:
#

View file

@ -0,0 +1,10 @@
require 'fog/core'
module Fog
module Voxel
extend Fog::Provider
service(:compute, 'compute/rackspace')
end
end