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:
parent
1a0afbc6ed
commit
d1606e69cc
10 changed files with 146 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ doc/*
|
|||
rdoc
|
||||
pkg
|
||||
spec/credentials.yml
|
||||
*~
|
||||
|
|
|
@ -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
30
lib/fog/bin/voxel.rb
Normal 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
|
|
@ -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)
|
||||
|
|
13
lib/fog/compute/models/voxel/image.rb
Normal file
13
lib/fog/compute/models/voxel/image.rb
Normal 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
|
28
lib/fog/compute/models/voxel/images.rb
Normal file
28
lib/fog/compute/models/voxel/images.rb
Normal 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
|
25
lib/fog/compute/requests/voxel/images_list.rb
Normal file
25
lib/fog/compute/requests/voxel/images_list.rb
Normal 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
33
lib/fog/compute/voxel.rb
Normal 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
|
|
@ -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:
|
||||
#
|
||||
|
|
10
lib/fog/providers/voxel.rb
Normal file
10
lib/fog/providers/voxel.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
require 'fog/core'
|
||||
|
||||
module Fog
|
||||
module Voxel
|
||||
|
||||
extend Fog::Provider
|
||||
|
||||
service(:compute, 'compute/rackspace')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue