# File lib/fog/voxel/compute.rb, line 75 def initialize(options = {}) require 'time' require 'digest/md5' @voxel_api_key = options[:voxel_api_key] @voxel_api_secret = options[:voxel_api_secret] @connection_options = options[:connection_options] || {} @host = options[:host] || "api.voxel.net" @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @persistent = options[:persistent] || false @connection_options[:ssl_verify_peer] = false @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end
# File lib/fog/voxel/compute.rb, line 118 def create_signature(secret, options) to_sign = options.keys.map { |k| k.to_s }.sort.map { |k| "#{k}#{options[k.to_sym]}" }.join("") Digest::MD5.hexdigest( secret + to_sign ) end
# File lib/fog/voxel/requests/compute/devices_list.rb, line 8 def devices_list(device_id = nil) options = { :parser => Fog::Parsers::Compute::Voxel::DevicesList.new, :verbosity => 'normal' } unless device_id.nil? options[:device_id] = device_id end request("voxel.devices.list", options) end
# File lib/fog/voxel/requests/compute/devices_power.rb, line 8 def devices_power(device_id, power_action) options = { :device_id => device_id, :parser => Fog::Parsers::Compute::Voxel::Basic.new, :power_action => power_action, :verbosity => 'normal' } request("voxel.devices.power", options) end
# File lib/fog/voxel/requests/compute/images_list.rb, line 8 def images_list(image_id = nil) options = { :parser => Fog::Parsers::Compute::Voxel::ImagesList.new, :verbosity => 'compact' } unless image_id.nil? options[:verbosity] = 'extended' options[:image_id] = image_id end data = request("voxel.images.list", options) if data.body['stat'] == "ok" data else raise Fog::Compute::Voxel::NotFound end end
# File lib/fog/voxel/compute.rb, line 93 def request(method_name, options = {}) begin parser = options.delete(:parser) options.merge!({ :method => method_name, :timestamp => Time.now.xmlschema, :key => @voxel_api_key }) options[:api_sig] = create_signature(@voxel_api_secret, options) data = @connection.request( :method => "POST", :query => options, :parser => parser, :path => "/version/1.0/" ) unless data.body['stat'] == 'ok' raise Fog::Compute::Voxel::Error, "#{data.body['err']['msg']}" end data rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::Voxel::NotFound.slurp(error) else error end end end
# File lib/fog/voxel/requests/compute/voxcloud_create.rb, line 8 def voxcloud_create(options) options[:parser] = Fog::Parsers::Compute::Voxel::VoxcloudCreate.new if options.has_key?(:password) options[:admin_password] = options[:password] options.delete(:password) end request("voxel.voxcloud.create", options) end
# File lib/fog/voxel/requests/compute/voxcloud_delete.rb, line 8 def voxcloud_delete(device_id) options = { :device_id => device_id, :parser => Fog::Parsers::Compute::Voxel::VoxcloudDelete.new } request("voxel.voxcloud.delete", options) end
# File lib/fog/voxel/requests/compute/voxcloud_status.rb, line 8 def voxcloud_status(device_id = nil) options = { :parser => Fog::Parsers::Compute::Voxel::VoxcloudStatus.new, :verbosity => 'compact' } unless device_id.nil? options[:device_id] = device_id end request("voxel.voxcloud.status", options) end
Generated with the Darkfish Rdoc Generator 2.