fog-voxel-0.0.2/0000755000004100000410000000000012460371247013455 5ustar www-datawww-datafog-voxel-0.0.2/Rakefile0000644000004100000410000000056712460371246015131 0ustar www-datawww-datarequire 'bundler/gem_tasks' require 'rake/testtask' Rake::TestTask.new do |t| t.libs.push %w(spec) t.test_files = FileList['spec/**/*_spec.rb'] t.verbose = true end desc 'Default Task' task :default => [ :test, 'test:travis' ] namespace :test do mock = ENV['FOG_MOCK'] || 'true' task :travis do sh("export FOG_MOCK=#{mock} && bundle exec shindont") end endfog-voxel-0.0.2/Gemfile0000644000004100000410000000013612460371246014747 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in fog-voxel.gemspec gemspec fog-voxel-0.0.2/tests/0000755000004100000410000000000012460371246014616 5ustar www-datawww-datafog-voxel-0.0.2/tests/helper.rb0000644000004100000410000000157012460371246016425 0ustar www-datawww-datarequire 'excon' if ENV['COVERAGE'] require 'coveralls' require 'simplecov' SimpleCov.start do add_filter '/spec/' add_filter '/test/' end end require File.expand_path(File.join(File.dirname(__FILE__), '../lib/fog/voxel')) Coveralls.wear! if ENV['COVERAGE'] Excon.defaults.merge!(:debug_request => true, :debug_response => true) require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper')) # This overrides the default 600 seconds timeout during live test runs if Fog.mocking? FOG_TESTING_TIMEOUT = ENV['FOG_TEST_TIMEOUT'] || 2000 Fog.timeout = 2000 Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds" else FOG_TESTING_TIMEOUT = Fog.timeout end def lorem_file File.open(File.dirname(__FILE__) + '/lorem.txt', 'r') end def array_differences(array_a, array_b) (array_a - array_b) | (array_b - array_a) endfog-voxel-0.0.2/tests/requests/0000755000004100000410000000000012460371246016471 5ustar www-datawww-datafog-voxel-0.0.2/tests/requests/compute/0000755000004100000410000000000012460371246020145 5ustar www-datawww-datafog-voxel-0.0.2/tests/requests/compute/image_tests.rb0000644000004100000410000000234712460371246023004 0ustar www-datawww-dataShindo.tests('Fog::Compute[:voxel] | image requests', ['voxel']) do @images_format = { 'images' => [{ 'id' => Integer, 'summary' => String }], 'stat' => String } @image_format = { 'images' => [{ 'description' => String, 'id' => Integer, 'filesystem' => { 'size' => Integer, 'type' => String, 'units' => String, }, 'operating_system' => { 'admin_username' => String, 'architecture' => Integer, 'family' => String, 'product_family' => String, 'product_version' => String, 'version' => String }, 'summary' => String }], 'stat' => String } tests('success') do tests('#images_list').formats(@images_format) do pending if Fog.mocking? Fog::Compute[:voxel].images_list.body end tests('#images_list(1)').formats(@image_format) do pending if Fog.mocking? Fog::Compute[:voxel].images_list(1).body end end tests('failure') do tests('#images_list(0)').raises(Fog::Compute::Voxel::Error) do pending if Fog.mocking? Fog::Compute[:voxel].images_list(0).body end end end fog-voxel-0.0.2/tests/requests/compute/server_tests.rb0000644000004100000410000000644012460371246023226 0ustar www-datawww-dataShindo.tests('Fog::Compute[:voxel] | server requests', ['voxel']) do @server_format = { 'device' => { 'id' => String, 'last_update' => Time }, 'stat' => String } @devices_format = { 'devices' => [{ 'access_methods' => [], 'description' => String, 'drives' => [{ 'position' => Fog::Nullable::String, 'size' => Integer }], 'id' => String, 'ipassignments' => [{ 'description' => String, 'id' => String, 'type' => String, 'value' => String }], 'label' => String, 'location' => { 'cage' => { 'id' => String, 'value' => String }, 'facility' => { 'code' => String, 'id' => String, 'value' => String }, 'position' => Fog::Nullable::String, 'rack' => { 'id' => String, 'value' => String }, 'row' => { 'id' => String, 'value' => String }, 'zone' => { 'id' => String, 'value' => String } }, 'memory' => { 'size' => Integer }, 'model' => { 'id' => String, 'value' => String }, 'operating_system' => { 'architecture' => Integer, 'name' => String }, 'power_consumption' => String, 'processor' => { 'cores' => Integer }, 'status' => String, 'type' => { 'id' => String, 'value' => String }, }], 'stat' => String, } tests('success') do @server_id = nil @name = "fog.#{Time.now.to_i}" tests("#voxcloud_create( :hostname => '#{@name}', :disk_size => 10, :processing_cores => 1, :image_id => 55, :facility => 'LDJ1' )").formats(@server_format) do pending if Fog.mocking? data = Fog::Compute[:voxel].voxcloud_create( :hostname => @name, :disk_size => 10, :processing_cores => 1, :image_id => 55, :facility => "LDJ1" ).body @server_id = data['device']['id'] data end unless Fog.mocking? Fog::Compute[:voxel].servers.get(@server_id).wait_for { ready? } end tests('#devices_list').formats(@devices_format) do pending if Fog.mocking? Fog::Compute[:voxel].devices_list.body end tests('#devices_list(@server_id)').formats(@devices_format) do pending if Fog.mocking? Fog::Compute[:voxel].devices_list(@server_id).body end tests("#voxcloud_delete(#{@server_id})").succeeds do pending if Fog.mocking? Fog::Compute[:voxel].voxcloud_delete(@server_id) end end tests('failure') do tests('#voxcloud_delete(0)').raises(Fog::Compute::Voxel::Error) do pending if Fog.mocking? Fog::Compute[:voxel].voxcloud_delete(0) end tests('#voxcloud_status(0)').raises(Fog::Compute::Voxel::Error) do pending if Fog.mocking? Fog::Compute[:voxel].voxcloud_status(0) end tests('#devices_list(0)').raises(Fog::Compute::Voxel::Error) do pending if Fog.mocking? Fog::Compute[:voxel].devices_list(0) end end end fog-voxel-0.0.2/tests/helpers/0000755000004100000410000000000012460371246016260 5ustar www-datawww-datafog-voxel-0.0.2/tests/helpers/responds_to_helper.rb0000644000004100000410000000037412460371246022507 0ustar www-datawww-datamodule Shindo class Tests def responds_to(method_names) for method_name in [*method_names] tests("#respond_to?(:#{method_name})").returns(true) do @instance.respond_to?(method_name) end end end end end fog-voxel-0.0.2/tests/helpers/formats_helper.rb0000644000004100000410000000705612460371246021627 0ustar www-datawww-datarequire "fog/schema/data_validator" # format related hackery # allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean) # allows both nil.is_a?(Fog::Nullable::String) and ''.is_a?(Fog::Nullable::String) module Fog module Boolean; end module Nullable module Boolean; end module Integer; end module String; end module Time; end module Float; end module Hash; end module Array; end end end [FalseClass, TrueClass].each {|klass| klass.send(:include, Fog::Boolean)} [FalseClass, TrueClass, NilClass, Fog::Boolean].each {|klass| klass.send(:include, Fog::Nullable::Boolean)} [NilClass, String].each {|klass| klass.send(:include, Fog::Nullable::String)} [NilClass, Time].each {|klass| klass.send(:include, Fog::Nullable::Time)} [Integer, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Integer)} [Float, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Float)} [Hash, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Hash)} [Array, NilClass].each {|klass| klass.send(:include, Fog::Nullable::Array)} module Shindo class Tests # Generates a Shindo test that compares a hash schema to the result # of the passed in block returning true if they match. # # The schema that is passed in is a Hash or Array of hashes that # have Classes in place of values. When checking the schema the # value should match the Class. # # Strict mode will fail if the data has additional keys. Setting # +strict+ to +false+ will allow additional keys to appear. # # @param [Hash] schema A Hash schema # @param [Hash] options Options to change validation rules # @option options [Boolean] :allow_extra_keys # If +true+ does not fail when keys are in the data that are # not specified in the schema. This allows new values to # appear in API output without breaking the check. # @option options [Boolean] :allow_optional_rules # If +true+ does not fail if extra keys are in the schema # that do not match the data. Not recommended! # @yield Data to check with schema # # @example Using in a test # Shindo.tests("comparing welcome data against schema") do # data = {:welcome => "Hello" } # data_matches_schema(:welcome => String) { data } # end # # comparing welcome data against schema # + data matches schema # # @example Example schema # { # "id" => String, # "ram" => Integer, # "disks" => [ # { # "size" => Float # } # ], # "dns_name" => Fog::Nullable::String, # "active" => Fog::Boolean, # "created" => DateTime # } # # @return [Boolean] def data_matches_schema(schema, options = {}) test('data matches schema') do validator = Fog::Schema::DataValidator.new valid = validator.validate(yield, schema, options) @message = validator.message unless valid valid end end # @deprecated #formats is deprecated. Use #data_matches_schema instead def formats(format, strict = true) test('has proper format') do if strict options = {:allow_extra_keys => false, :allow_optional_rules => true} else options = {:allow_extra_keys => true, :allow_optional_rules => true} end validator = Fog::Schema::DataValidator.new valid = validator.validate(yield, format, options) @message = validator.message unless valid valid end end end end fog-voxel-0.0.2/tests/helpers/succeeds_helper.rb0000644000004100000410000000020612460371246021740 0ustar www-datawww-datamodule Shindo class Tests def succeeds test('succeeds') do !!instance_eval(&Proc.new) end end end end fog-voxel-0.0.2/tests/helpers/collection_helper.rb0000644000004100000410000000502712460371246022303 0ustar www-datawww-datadef collection_tests(collection, params = {}, mocks_implemented = true) tests('success') do tests("#new(#{params.inspect})").succeeds do pending if Fog.mocking? && !mocks_implemented collection.new(params) end tests("#create(#{params.inspect})").succeeds do pending if Fog.mocking? && !mocks_implemented @instance = collection.create(params) end # FIXME: work around for timing issue on AWS describe_instances mocks if Fog.mocking? && @instance.respond_to?(:ready?) @instance.wait_for { ready? } end tests("#all").succeeds do pending if Fog.mocking? && !mocks_implemented collection.all end if !Fog.mocking? || mocks_implemented @identity = @instance.identity end tests("#get(#{@identity})").succeeds do pending if Fog.mocking? && !mocks_implemented collection.get(@identity) end tests('Enumerable') do pending if Fog.mocking? && !mocks_implemented methods = [ 'all?', 'any?', 'find', 'detect', 'collect', 'map', 'find_index', 'flat_map', 'collect_concat', 'group_by', 'none?', 'one?' ] # JRuby 1.7.5+ issue causes a SystemStackError: stack level too deep # https://github.com/jruby/jruby/issues/1265 if RUBY_PLATFORM == "java" and JRUBY_VERSION =~ /1\.7\.[5-8]/ methods.delete('all?') end methods.each do |enum_method| if collection.respond_to?(enum_method) tests("##{enum_method}").succeeds do block_called = false collection.send(enum_method) {|x| block_called = true } block_called end end end [ 'max_by','min_by' ].each do |enum_method| if collection.respond_to?(enum_method) tests("##{enum_method}").succeeds do block_called = false collection.send(enum_method) {|x| block_called = true; 0 } block_called end end end end if block_given? yield(@instance) end if !Fog.mocking? || mocks_implemented @instance.destroy end end tests('failure') do if !Fog.mocking? || mocks_implemented @identity = @identity.to_s @identity = @identity.gsub(/[a-zA-Z]/) { Fog::Mock.random_letters(1) } @identity = @identity.gsub(/\d/) { Fog::Mock.random_numbers(1) } @identity end tests("#get('#{@identity}')").returns(nil) do pending if Fog.mocking? && !mocks_implemented collection.get(@identity) end end end fog-voxel-0.0.2/tests/helpers/compute/0000755000004100000410000000000012460371246017734 5ustar www-datawww-datafog-voxel-0.0.2/tests/helpers/compute/servers_helper.rb0000644000004100000410000000041012460371246023304 0ustar www-datawww-datadef servers_tests(connection, params = {}, mocks_implemented = true) collection_tests(connection.servers, params, mocks_implemented) do if !Fog.mocking? || mocks_implemented @instance.wait_for { ready? } yield if block_given? end end end fog-voxel-0.0.2/tests/helpers/compute/server_helper.rb0000644000004100000410000000124612460371246023131 0ustar www-datawww-datadef server_tests(connection, params = {}, mocks_implemented = true) model_tests(connection.servers, params, mocks_implemented) do tests('#reload').returns(true) do pending if Fog.mocking? && !mocks_implemented @instance.wait_for { ready? } identity = @instance.identity !identity.nil? && identity == @instance.reload.identity end responds_to([:ready?, :state]) yield if block_given? tests('#reboot').succeeds do pending if Fog.mocking? && !mocks_implemented @instance.wait_for { ready? } @instance.reboot end if !Fog.mocking? || mocks_implemented @instance.wait_for { ready? } end end end fog-voxel-0.0.2/tests/helpers/compute/flavors_helper.rb0000644000004100000410000000146312460371246023300 0ustar www-datawww-datadef flavors_tests(connection, params = {}, mocks_implemented = true) tests('success') do tests("#all").succeeds do pending if Fog.mocking? && !mocks_implemented connection.flavors.all end if !Fog.mocking? || mocks_implemented @identity = connection.flavors.first.identity end tests("#get('#{@identity}')").succeeds do pending if Fog.mocking? && !mocks_implemented connection.flavors.get(@identity) end end tests('failure') do if !Fog.mocking? || mocks_implemented invalid_flavor_identity = connection.flavors.first.identity.to_s.gsub(/\w/, '0') end tests("#get('#{invalid_flavor_identity}')").returns(nil) do pending if Fog.mocking? && !mocks_implemented connection.flavors.get(invalid_flavor_identity) end end end fog-voxel-0.0.2/tests/helpers/model_helper.rb0000644000004100000410000000141412460371246021244 0ustar www-datawww-datadef model_tests(collection, params = {}, mocks_implemented = true) tests('success') do @instance = collection.new(params) tests("#save").succeeds do pending if Fog.mocking? && !mocks_implemented @instance.save end if block_given? yield(@instance) end tests("#destroy").succeeds do pending if Fog.mocking? && !mocks_implemented @instance.destroy end end end # Generates a unique identifier with a random differentiator. # Useful when rapidly re-running tests, so we don't have to wait # serveral minutes for deleted objects to disappear from the API # E.g. 'fog-test-1234' def uniq_id(base_name = 'fog-test') # random_differentiator suffix = rand(65536).to_s(16).rjust(4, '0') [base_name, suffix] * '-' end fog-voxel-0.0.2/tests/helpers/formats_helper_tests.rb0000644000004100000410000000702012460371246023040 0ustar www-datawww-dataShindo.tests('test_helper', 'meta') do tests('comparing welcome data against schema') do data = {:welcome => "Hello" } data_matches_schema(:welcome => String) { data } end tests('#data_matches_schema') do tests('when value matches schema expectation') do data_matches_schema({"key" => String}) { {"key" => "Value"} } end tests('when values within an array all match schema expectation') do data_matches_schema({"key" => [Integer]}) { {"key" => [1, 2]} } end tests('when nested values match schema expectation') do data_matches_schema({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} } end tests('when collection of values all match schema expectation') do data_matches_schema([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] } end tests('when collection is empty although schema covers optional members') do data_matches_schema([{"key" => String}], {:allow_optional_rules => true}) { [] } end tests('when additional keys are passed and not strict') do data_matches_schema({"key" => String}, {:allow_extra_keys => true}) { {"key" => "Value", :extra => "Bonus"} } end tests('when value is nil and schema expects NilClass') do data_matches_schema({"key" => NilClass}) { {"key" => nil} } end tests('when value and schema match as hashes') do data_matches_schema({}) { {} } end tests('when value and schema match as arrays') do data_matches_schema([]) { [] } end tests('when value is a Time') do data_matches_schema({"time" => Time}) { {"time" => Time.now} } end tests('when key is missing but value should be NilClass (#1477)') do data_matches_schema({"key" => NilClass}, {:allow_optional_rules => true}) { {} } end tests('when key is missing but value is nullable (#1477)') do data_matches_schema({"key" => Fog::Nullable::String}, {:allow_optional_rules => true}) { {} } end end tests('#formats backwards compatible changes') do tests('when value matches schema expectation') do formats({"key" => String}) { {"key" => "Value"} } end tests('when values within an array all match schema expectation') do formats({"key" => [Integer]}) { {"key" => [1, 2]} } end tests('when nested values match schema expectation') do formats({"key" => {:nested_key => String}}) { {"key" => {:nested_key => "Value"}} } end tests('when collection of values all match schema expectation') do formats([{"key" => String}]) { [{"key" => "Value"}, {"key" => "Value"}] } end tests('when collection is empty although schema covers optional members') do formats([{"key" => String}]) { [] } end tests('when additional keys are passed and not strict') do formats({"key" => String}, false) { {"key" => "Value", :extra => "Bonus"} } end tests('when value is nil and schema expects NilClass') do formats({"key" => NilClass}) { {"key" => nil} } end tests('when value and schema match as hashes') do formats({}) { {} } end tests('when value and schema match as arrays') do formats([]) { [] } end tests('when value is a Time') do formats({"time" => Time}) { {"time" => Time.now} } end tests('when key is missing but value should be NilClass (#1477)') do formats({"key" => NilClass}) { {} } end tests('when key is missing but value is nullable (#1477)') do formats({"key" => Fog::Nullable::String}) { {} } end end end fog-voxel-0.0.2/tests/helpers/mock_helper.rb0000644000004100000410000001511312460371246021076 0ustar www-datawww-data# Use so you can run in mock mode from the command line # # FOG_MOCK=true fog if ENV["FOG_MOCK"] == "true" Fog.mock! end # if in mocked mode, fill in some fake credentials for us if Fog.mock? Fog.credentials = { :aws_access_key_id => 'aws_access_key_id', :aws_secret_access_key => 'aws_secret_access_key', :ia_access_key_id => 'aws_access_key_id', :ia_secret_access_key => 'aws_secret_access_key', :atmos_storage_token => 'atmos_token', :atmos_storage_secret => 'atmos_secret', :atmos_storage_endpoint => 'http://atmos.is.cool:1000/test1.0', :bluebox_api_key => 'bluebox_api_key', :bluebox_customer_id => 'bluebox_customer_id', :brightbox_client_id => 'brightbox_client_id', :brightbox_secret => 'brightbox_secret', :cloudstack_disk_offering_id => '', :cloudstack_host => 'http://cloudstack.example.org', :cloudstack_network_ids => '', :cloudstack_service_offering_id => '4437ac6c-9fe3-477a-57ec-60a5a45896a4', :cloudstack_template_id => '8a31cf9c-f248-0588-256e-9dbf58785216', :cloudstack_zone_id => 'c554c592-e09c-9df5-7688-4a32754a4305', :clodo_api_key => 'clodo_api_key', :clodo_username => 'clodo_username', :digitalocean_api_key => 'digitalocean_api_key', :digitalocean_client_id => 'digitalocean_client_id', :dnsimple_email => 'dnsimple_email', :dnsimple_password => 'dnsimple_password', :dnsmadeeasy_api_key => 'dnsmadeeasy_api_key', :dnsmadeeasy_secret_key => 'dnsmadeeasy_secret_key', :ecloud_username => 'ecloud_username', :ecloud_password => 'ecloud_password', :ecloud_versions_uri => 'http://ecloud.versions.uri', :glesys_username => 'glesys_username', :glesys_api_key => 'glesys_api_key', :go_grid_api_key => 'go_grid_api_key', :go_grid_shared_secret => 'go_grid_shared_secret', :google_storage_access_key_id => 'google_storage_access_key_id', :google_storage_secret_access_key => 'google_storage_secret_access_key', :google_project => 'google_project_name', :google_client_email => 'fake@developer.gserviceaccount.com', :google_key_location => '~/fake.p12', :hp_access_key => 'hp_access_key', :hp_secret_key => 'hp_secret_key', :hp_tenant_id => 'hp_tenant_id', :hp_avl_zone => 'hp_avl_zone', :os_account_meta_temp_url_key => 'os_account_meta_temp_url_key', :ibm_username => 'ibm_username', :ibm_password => 'ibm_password', :joyent_username => "joyentuser", :joyent_password => "joyentpass", :linode_api_key => 'linode_api_key', :local_root => '~/.fog', :bare_metal_cloud_password => 'bare_metal_cloud_password', :bare_metal_cloud_username => 'bare_metal_cloud_username', :ninefold_compute_key => 'ninefold_compute_key', :ninefold_compute_secret => 'ninefold_compute_secret', :ninefold_storage_secret => 'ninefold_storage_secret', :ninefold_storage_token => 'ninefold_storage_token', # :public_key_path => '~/.ssh/id_rsa.pub', # :private_key_path => '~/.ssh/id_rsa', :opennebula_endpoint => 'http://opennebula:2633/RPC2', :opennebula_username => 'oneadmin', :opennebula_password => 'oneadmin', :openstack_api_key => 'openstack_api_key', :openstack_username => 'openstack_username', :openstack_tenant => 'openstack_tenant', :openstack_auth_url => 'http://openstack:35357/v2.0/tokens', :ovirt_url => 'http://ovirt:8080/api', :ovirt_username => 'admin@internal', :ovirt_password => '123123', :profitbricks_username => 'profitbricks_username', :profitbricks_password => 'profitbricks_password', :libvirt_uri => 'qemu://libvirt/system', :rackspace_api_key => 'rackspace_api_key', :rackspace_region => 'dfw', :rackspace_username => 'rackspace_username', :riakcs_access_key_id => 'riakcs_access_key_id', :riakcs_secret_access_key => 'riakcs_secret_access_key', :sakuracloud_api_token => 'sakuracloud_api_token', :sakuracloud_api_token_secret => 'sakuracloud_api_token_secret', :storm_on_demand_username => 'storm_on_demand_username', :storm_on_demand_password => 'storm_on_demand_password', :vcloud_host => 'vcloud_host', :vcloud_password => 'vcloud_password', :vcloud_username => 'vcloud_username', :vcloud_director_host => 'vcloud-director-host', :vcloud_director_password => 'vcloud_director_password', :vcloud_director_username => 'vcd_user@vcd_org_name', :voxel_api_key => 'voxel_api_key', :voxel_api_secret => 'voxel_api_secret', :zerigo_email => 'zerigo_email', :zerigo_token => 'zerigo_token', :dynect_customer => 'dynect_customer', :dynect_username => 'dynect_username', :dynect_password => 'dynect_password', :vsphere_server => 'virtualcenter.lan', :vsphere_username => 'apiuser', :vsphere_password => 'apipassword', :vsphere_expected_pubkey_hash => 'abcdef1234567890', :libvirt_uri => 'qemu:///system', :libvirt_username => 'root', :libvirt_password => 'password', :cloudsigma_username => 'csuname', :cloudsigma_password => 'cspass', :docker_username => 'docker-fan', :docker_password => 'i<3docker', :docker_email => 'dockerfan@gmail.com', :docker_url => 'unix://var/run/docker.sock' }.merge(Fog.credentials) end fog-voxel-0.0.2/tests/helpers/schema_validator_tests.rb0000644000004100000410000000723112460371246023337 0ustar www-datawww-dataShindo.tests('Fog::Schema::DataValidator', 'meta') do validator = Fog::Schema::DataValidator.new tests('#validate') do tests('returns true') do returns(true, 'when value matches schema expectation') do validator.validate({"key" => "Value"}, {"key" => String}) end returns(true, 'when values within an array all match schema expectation') do validator.validate({"key" => [1, 2]}, {"key" => [Integer]}) end returns(true, 'when nested values match schema expectation') do validator.validate({"key" => {:nested_key => "Value"}}, {"key" => {:nested_key => String}}) end returns(true, 'when collection of values all match schema expectation') do validator.validate([{"key" => "Value"}, {"key" => "Value"}], [{"key" => String}]) end returns(true, 'when collection is empty although schema covers optional members') do validator.validate([], [{"key" => String}]) end returns(true, 'when additional keys are passed and not strict') do validator.validate({"key" => "Value", :extra => "Bonus"}, {"key" => String}, {:allow_extra_keys => true}) end returns(true, 'when value is nil and schema expects NilClass') do validator.validate({"key" => nil}, {"key" => NilClass}) end returns(true, 'when value and schema match as hashes') do validator.validate({}, {}) end returns(true, 'when value and schema match as arrays') do validator.validate([], []) end returns(true, 'when value is a Time') do validator.validate({"time" => Time.now}, {"time" => Time}) end returns(true, 'when key is missing but value should be NilClass (#1477)') do validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => true}) end returns(true, 'when key is missing but value is nullable (#1477)') do validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => true}) end end tests('returns false') do returns(false, 'when value does not match schema expectation') do validator.validate({"key" => nil}, {"key" => String}) end returns(false, 'when key formats do not match') do validator.validate({"key" => "Value"}, {:key => String}) end returns(false, 'when additional keys are passed and strict') do validator.validate({"key" => "Missing"}, {}) end returns(false, 'when some keys do not appear') do validator.validate({}, {"key" => String}) end returns(false, 'when collection contains a member that does not match schema') do validator.validate([{"key" => "Value"}, {"key" => 5}], [{"key" => String}]) end returns(false, 'when collection has multiple schema patterns') do validator.validate([{"key" => "Value"}], [{"key" => Integer}, {"key" => String}]) end returns(false, 'when hash and array are compared') do validator.validate({}, []) end returns(false, 'when array and hash are compared') do validator.validate([], {}) end returns(false, 'when a hash is expected but another data type is found') do validator.validate({"key" => {:nested_key => []}}, {"key" => {:nested_key => {}}}) end returns(false, 'when key is missing but value should be NilClass (#1477)') do validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => false}) end returns(false, 'when key is missing but value is nullable (#1477)') do validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => false}) end end end end fog-voxel-0.0.2/.ruby-version0000644000004100000410000000000512460371246016114 0ustar www-datawww-data2.1.4fog-voxel-0.0.2/CONTRIBUTORS.md0000644000004100000410000000031512460371246015732 0ustar www-datawww-data* Lance Ivy * James Herdman * Paul Thornthwaite * Paulo Henrique Lopes Ribeiro * Wesley Beary fog-voxel-0.0.2/spec/0000755000004100000410000000000012460371246014406 5ustar www-datawww-datafog-voxel-0.0.2/spec/minitest_helper.rb0000644000004100000410000000150312460371246020125 0ustar www-datawww-datarequire 'minitest/spec' require 'minitest/autorun' require 'turn' Turn.config do |c| # use one of output formats: # :outline - turn's original case/test outline mode [default] # :progress - indicates progress with progress bar # :dotted - test/unit's traditional dot-progress mode # :pretty - new pretty reporter # :marshal - dump output as YAML (normal run mode only) # :cue - interactive testing # c.format = :outline # turn on invoke/execute tracing, enable full backtrace c.trace = 20 # use humanized test names (works only with :outline format) c.natural = true end if ENV['COVERAGE'] require 'coveralls' require 'simplecov' SimpleCov.start do add_filter '/spec/' end end require File.join(File.dirname(__FILE__), '../lib/fog/exoscale.rb') Coveralls.wear! if ENV['COVERAGE'] fog-voxel-0.0.2/LICENSE.md0000644000004100000410000000217612460371246015066 0ustar www-datawww-dataThe MIT License (MIT) Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-voxel/blob/master/CONTRIBUTORS.md) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.fog-voxel-0.0.2/.travis.yml0000644000004100000410000000066212460371246015571 0ustar www-datawww-datamatrix: include: - rvm: 1.8.7 gemfile: gemfiles/Gemfile.1.9.2- - rvm: 1.9.2 gemfile: gemfiles/Gemfile.1.9.2- - rvm: 1.9.3 gemfile: gemfiles/Gemfile.1.9.3+ - rvm: 2.0.0 gemfile: gemfiles/Gemfile.1.9.3+ - rvm: 2.1.4 gemfile: gemfiles/Gemfile.1.9.3+ env: COVERAGE=true - rvm: ree gemfile: gemfiles/Gemfile.1.9.2- - rvm: jruby gemfile: gemfiles/Gemfile.1.9.3+ fog-voxel-0.0.2/lib/0000755000004100000410000000000012460371246014222 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/0000755000004100000410000000000012460371246014775 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/bin/0000755000004100000410000000000012460371246015545 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/bin/voxel.rb0000644000004100000410000000141612460371246017231 0ustar www-datawww-dataclass Voxel < Fog::Bin class << self def class_for(key) case key when :compute Fog::Compute::Voxel else raise ArgumentError, "Unrecognized service: #{key}" end end def [](service) @@connections ||= Hash.new do |hash, key| hash[key] = case key when :compute Fog::Logger.warning("Voxel[:compute] is not recommended, use Compute[:voxel] for portability") Fog::Compute.new(:provider => 'Voxel') else raise ArgumentError, "Unrecognized service: #{key.inspect}" end end @@connections[service] end def services Fog::Voxel.services end end end fog-voxel-0.0.2/lib/fog/voxel/0000755000004100000410000000000012460371246016132 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/voxel/version.rb0000644000004100000410000000007212460371246020143 0ustar www-datawww-datamodule Fog module Voxel VERSION = "0.0.2" end end fog-voxel-0.0.2/lib/fog/voxel/compute.rb0000644000004100000410000000000012460371246020121 0ustar www-datawww-datafog-voxel-0.0.2/lib/fog/voxel.rb0000644000004100000410000000101112460371246016450 0ustar www-datawww-datarequire 'fog/voxel/version' require 'fog/core' require 'fog/xml' require 'digest/md5' module Fog module Voxel extend Fog::Provider service(:compute, 'Compute') def self.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 end module Compute autoload :Voxel, 'fog/compute/voxel' end module Parsers autoload :Compute, 'fog/parsers/compute' end end fog-voxel-0.0.2/lib/fog/parsers/0000755000004100000410000000000012460371246016454 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/parsers/compute/0000755000004100000410000000000012460371246020130 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/parsers/compute/voxel/0000755000004100000410000000000012460371246021265 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/parsers/compute/voxel/devices_list.rb0000644000004100000410000000746312460371246024301 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class DevicesList < Fog::Parsers::Base def reset @device = {} @response = { 'devices' => [] } @in_storage = false end def start_element(name, attrs = []) super case name when 'accessmethod' @access_method = { 'type' => attr_value('type', attrs) } when 'accessmethods' @device['access_methods'] = [] when 'device' @device = { 'id' => attr_value('id', attrs), 'label' => attr_value('label', attrs), 'status' => attr_value('status', attrs) } when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'cage', 'facility', 'rack', 'row', 'zone' @device['location'][name] = { 'id' => attr_value('id', attrs) } if code = attr_value('code', attrs) @device['location'][name]['code'] = code end when 'drive' @drive = { 'position' => attr_value('position', attrs) } when 'ipassignment' type = attr_value('type', attrs) @device['ipassignments'] = [] @device['ipassignments'] << { 'id' => attr_value('id', attrs), 'type' => attr_value('type', attrs), 'description' => attr_value('description', attrs), } when 'ipassignments' @device['ipassignments'] = {} when 'location' @device['location'] = {} when 'memory' @device['memory'] = { 'size' => attr_value('size', attrs).to_i } when 'model', 'type' @device[name] = { 'id' => attr_value('id', attrs) } when 'operating_system' @device['operating_system'] = {} when 'power_consumption' @device[name] = attr_value('unit', attrs) when 'processor' @device['processor'] = {} when 'rsp' @response['stat'] = attr_value('stat', attrs) when 'storage' @device['drives'] = [] end end def end_element(name) case name when 'access_method' @device['access_methods'] << @access_method when 'architecture' @device['operating_system'][name] = value.to_i when 'cage', 'facility', 'rack', 'row', 'zone' @device['location'][name]['value'] = value when 'cores' @device['processor'][name] = value.to_i when 'description' @device[name] = value when 'device' @response['devices'] << @device @device = {} when 'drive' @device['drives'] << @drive @drive = {} when 'cores' @device['processing_cores'] = value.to_i when 'ipassignment' @device['ipassignments'].last['value'] = value when 'model', 'type' @device[name]['value'] = value when 'name' @device['operating_system'][name] = value when 'position' @device['location'][name] = value when 'power_consumption' @device[name] = [value, @device[name]].join(' ') when 'size' @drive[name] = value.to_i when 'host', 'password', 'protocol', 'username' @access_method[name] = value end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel/images_list.rb0000644000004100000410000000313312460371246024112 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class ImagesList < Fog::Parsers::Base def reset @image = {} @response = { 'images' => [] } end def start_element(name, attrs = []) super case name when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'size' @image['filesystem']['units'] = attr_value('units', attrs) when 'image' @image = { 'id' => attr_value('id', attrs).to_i, 'summary' => attr_value('summary', attrs) } when 'filesystem', 'operating_system' @image[name] = {} when 'rsp' @response['stat'] = attr_value('stat', attrs) end end def end_element(name) case name when 'architecture' @image['operating_system'][name] = value.to_i when 'admin_username', 'family', 'product_family', 'product_version', 'version' @image['operating_system'][name] = value when 'description' @image[name] = value when 'image' @response['images'] << @image @image = {} when 'size' @image['filesystem'][name] = value.to_i when 'type' @image['filesystem'][name] = value end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel/voxcloud_delete.rb0000644000004100000410000000112612460371246024777 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class VoxcloudDelete < Fog::Parsers::Base def reset @response = {} end def start_element(name, attrs = []) super case name when 'rsp' @response['stat'] = attr_value('stat', attrs) when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel/voxcloud_status.rb0000644000004100000410000000200212460371246025052 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class VoxcloudStatus < Fog::Parsers::Base def reset @response = { 'devices' => [] } @device = {} end def start_element(name, attrs = []) super case name when 'rsp' @response['stat'] = attr_value('stat', attrs) when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'device' @device = {} end end def end_element(name) case name when 'device' @response['devices'] << @device @device = {} when 'id', 'status' @device[name] = value when 'last_update' @device[name] = Time.at(value.to_i) end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel/basic.rb0000644000004100000410000000111512460371246022671 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class Basic < Fog::Parsers::Base def reset @response = {} end def start_element(name, attrs = []) super case name when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'rsp' @response['stat'] = attr_value('stat', attrs) end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel/voxcloud_create.rb0000644000004100000410000000153612460371246025005 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel class VoxcloudCreate < Fog::Parsers::Base def reset @response = { 'device' => {} } end def start_element(name, attrs = []) super case name when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'rsp' @response['stat'] = attr_value('stat', attrs) end end def end_element(name) case name when 'id' @response['device'][name] = value when 'last_update' @response['device'][name] = Time.at(value.to_i) end end end end end end end fog-voxel-0.0.2/lib/fog/parsers/compute/voxel.rb0000644000004100000410000000102112460371246021604 0ustar www-datawww-datamodule Fog module Parsers module Compute module Voxel autoload :Basic, 'fog/parsers/compute/voxel/basic' autoload :DevicesList, 'fog/parsers/compute/voxel/devices_list' autoload :ImagesList, 'fog/parsers/compute/voxel/images_list' autoload :VoxcloudCreate, 'fog/parsers/compute/voxel/voxcloud_create' autoload :VoxcloudDelete, 'fog/parsers/compute/voxel/voxcloud_delete' autoload :Voxcloudstatus, 'fog/parsers/compute/voxel/voxcloud_status' end end end end fog-voxel-0.0.2/lib/fog/parsers/compute.rb0000644000004100000410000000016412460371246020456 0ustar www-datawww-datamodule Fog module Parsers module Compute autoload :Voxel, 'fog/parsers/compute/voxel' end end end fog-voxel-0.0.2/lib/fog/compute/0000755000004100000410000000000012460371246016451 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/compute/voxel/0000755000004100000410000000000012460371246017606 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/compute/voxel/images.rb0000644000004100000410000000070412460371246021401 0ustar www-datawww-datamodule Fog module Compute class Voxel class Images < Fog::Collection model Fog::Compute::Voxel::Image def all data = service.images_list.body['images'] load(data) end def get(image_id) data = service.images_list(image_id).body['images'] if data.empty? nil else new(data.first) end end end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/servers.rb0000644000004100000410000000124212460371246021623 0ustar www-datawww-datamodule Fog module Compute class Voxel class Servers < Fog::Collection model Fog::Compute::Voxel::Server def all data = service.devices_list.body['devices'].select {|device| device['type']['id'] == '3'} load(data) end def get(device_id) if device_id && server = service.devices_list(device_id).body['devices'] new(server.first) end rescue Fog::Service::Error => error if error.message == "The device_id passed in can't be matched to a valid device." nil else raise error end end end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real.rb0000644000004100000410000000043512460371246021060 0ustar www-datawww-datarequire 'fog/compute/voxel/real/devices_list' require 'fog/compute/voxel/real/devices_power' require 'fog/compute/voxel/real/images_list' require 'fog/compute/voxel/real/voxcloud_create' require 'fog/compute/voxel/real/voxcloud_delete' require 'fog/compute/voxel/real/voxcloud_status' fog-voxel-0.0.2/lib/fog/compute/voxel/real/0000755000004100000410000000000012460371246020531 5ustar www-datawww-datafog-voxel-0.0.2/lib/fog/compute/voxel/real/devices_list.rb0000644000004100000410000000074412460371246023540 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/devices_list' 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 end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real/devices_power.rb0000644000004100000410000000073512460371246023721 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/basic' 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 end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real/images_list.rb0000644000004100000410000000122712460371246023360 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/images_list' 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 end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real/voxcloud_delete.rb0000644000004100000410000000062012460371246024241 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/voxcloud_delete' def voxcloud_delete(device_id) options = { :device_id => device_id, :parser => Fog::Parsers::Compute::Voxel::VoxcloudDelete.new } request("voxel.voxcloud.delete", options) end end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real/voxcloud_status.rb0000644000004100000410000000076112460371246024330 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/voxcloud_status' 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 end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/real/voxcloud_create.rb0000644000004100000410000000073412460371246024250 0ustar www-datawww-datamodule Fog module Compute class Voxel class Real require 'fog/voxel/parsers/voxel/voxcloud_create' def voxcloud_create(options) options[:parser] = Fog::Parsers::Compute::Voxel::VoxcloudCreate.new if options.key?(:password) options[:admin_password] = options[:password] options.delete(:password) end request("voxel.voxcloud.create", options) end end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/server.rb0000644000004100000410000000335012460371246021442 0ustar www-datawww-datamodule Fog module Compute class Voxel class Server < Fog::Compute::Server identity :id attribute :name attribute :processing_cores attribute :image_id attribute :facility attribute :disk_size attribute :ip_assignments, :aliases => 'ipassignments' def initialize(attributes={}) self.image_id ||= '55' # Ubuntu 10.04 LTS 64bit super end def destroy requires :id service.voxcloud_delete(id) true end def image requires :image_id service.images.get(image_id) end def ready? self.state == 'SUCCEEDED' end def private_ip_address ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'internal'}.first end def public_ip_address ip_assignments.select {|ip_assignment| ip_assignment['type'] == 'external'}.first end def reboot requires :id service.devices_power(id, :reboot) true end def state @state ||= service.voxcloud_status(id).body['devices'].first['status'] end def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :name, :image_id, :processing_cores, :facility, :disk_size data = service.voxcloud_create({ :disk_size => disk_size, :facility => facility, :hostname => name, :image_id => image_id, :processing_cores => processing_cores }).body merge_attributes(data['device']) true end end end end end fog-voxel-0.0.2/lib/fog/compute/voxel/image.rb0000644000004100000410000000023012460371246021210 0ustar www-datawww-datamodule Fog module Compute class Voxel class Image < Fog::Model identity :id attribute :summary end end end end fog-voxel-0.0.2/lib/fog/compute/voxel.rb0000644000004100000410000001115612460371246020137 0ustar www-datawww-datarequire 'fog/voxel' module Fog module Compute class Voxel < Fog::Service autoload :Image, 'fog/compute/voxel/image' autoload :Images, 'fog/compute/voxel/images' autoload :Server, 'fog/compute/voxel/server' autoload :Servers, 'fog/compute/voxel/servers' requires :voxel_api_key, :voxel_api_secret recognizes :host, :port, :scheme, :persistent model_path 'fog/compute/voxel' model :image collection :images model :server collection :servers request_path 'fog/compute/voxel/real' request :images_list request :devices_list request :devices_power request :voxcloud_create request :voxcloud_status request :voxcloud_delete class Mock include Collections def self.data @data ||= Hash.new do |hash, key| hash[key] = { :last_modified => { :servers => {}, :statuses => {}, :images => {} }, :servers => [], :statuses => {}, :images => [ {'id' => 1, 'name' => "CentOS 4, 32-bit, base install"}, {'id' => 2, 'name' => "CentOS 4, 64-bit, base install"}, {'id' => 3, 'name' => "CentOS 5, 32-bit, base install"}, {'id' => 4, 'name' => "CentOS 5, 64-bit, base install"}, {'id' => 7, 'name' => "Fedora 10, 32-bit, base install"}, {'id' => 8, 'name' => "Fedora 10, 64-bit, base install"}, {'id' => 10, 'name' => "OpenSUSE 11, 64-bit, base install"}, {'id' => 11, 'name' => "Debian 5.0 \"lenny\", 32-bit, base install"}, {'id' => 12, 'name' => "Debian 5.0 \"lenny\", 64-bit, base install"}, {'id' => 13, 'name' => "Ubuntu 8.04 \"Hardy\", 32-bit, base install"}, {'id' => 14, 'name' => "Ubuntu 8.04 \"Hardy\", 64-bit, base install"}, {'id' => 15, 'name' => "Voxel Server Environment (VSE), 32-bit, base install"}, {'id' => 16, 'name' => "Voxel Server Environment (VSE), 64-bit, base install"}, {'id' => 32, 'name' => "Pantheon Official Mercury Stack for Drupal (based on VSE/64)"}, {'id' => 55, 'name' => "Ubuntu 10.04 \"Lucid\", 64-bit, base install"} ] } end end def self.reset @data = nil end def initialize(options={}) @voxel_api_key = options[:voxel_api_key] end def data self.class.data[@voxel_api_key] end def reset_data self.class.data.delete(@voxel_api_key) end end class Real include Collections 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::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end 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 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 end end end end fog-voxel-0.0.2/gemfiles/0000755000004100000410000000000012460371246015247 5ustar www-datawww-datafog-voxel-0.0.2/gemfiles/Gemfile.1.9.2-0000644000004100000410000000021012460371246017256 0ustar www-datawww-datasource :rubygems gem 'mime-types', '< 2.0' gem 'nokogiri', '< 1.6' gem 'rest-client', '~> 1.6.8' gem 'fog-core' gemspec :path => '../'fog-voxel-0.0.2/gemfiles/Gemfile.1.9.3+0000644000004100000410000000016712460371246017270 0ustar www-datawww-datasource :rubygems gem 'activesupport', '>= 3.0', '< 4' gem 'mime-types', '< 2.0' gem 'fog-core' gemspec :path => '../'fog-voxel-0.0.2/.rubocop.yml0000644000004100000410000000047412460371246015733 0ustar www-datawww-dataMetrics/LineLength: Enabled: false Style/EachWithObject: Enabled: false Style/Encoding: EnforcedStyle: when_needed Style/FormatString: Enabled: false Style/HashSyntax: EnforcedStyle: hash_rockets Style/SignalException: EnforcedStyle: only_raise Style/StringLiterals: EnforcedStyle: double_quotes fog-voxel-0.0.2/metadata.yml0000644000004100000410000001351712460371247015767 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: fog-voxel version: !ruby/object:Gem::Version version: 0.0.2 platform: ruby authors: - Paulo Henrique Lopes Ribeiro autorequire: bindir: bin cert_chain: [] date: 2014-12-01 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: fog-core requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: fog-xml requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: minitest requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: shindo requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: turn requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: pry requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: coveralls requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rubocop requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: |- This library can be used as a module for `fog` or as standalone provider to use the Voxel in applications. email: plribeiro3000@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".rubocop.yml" - ".ruby-gemset" - ".ruby-version" - ".travis.yml" - CONTRIBUTING.md - CONTRIBUTORS.md - Gemfile - LICENSE.md - README.md - Rakefile - fog-voxel.gemspec - gemfiles/Gemfile.1.9.2- - gemfiles/Gemfile.1.9.3+ - lib/fog/bin/voxel.rb - lib/fog/compute/voxel.rb - lib/fog/compute/voxel/image.rb - lib/fog/compute/voxel/images.rb - lib/fog/compute/voxel/real.rb - lib/fog/compute/voxel/real/devices_list.rb - lib/fog/compute/voxel/real/devices_power.rb - lib/fog/compute/voxel/real/images_list.rb - lib/fog/compute/voxel/real/voxcloud_create.rb - lib/fog/compute/voxel/real/voxcloud_delete.rb - lib/fog/compute/voxel/real/voxcloud_status.rb - lib/fog/compute/voxel/server.rb - lib/fog/compute/voxel/servers.rb - lib/fog/parsers/compute.rb - lib/fog/parsers/compute/voxel.rb - lib/fog/parsers/compute/voxel/basic.rb - lib/fog/parsers/compute/voxel/devices_list.rb - lib/fog/parsers/compute/voxel/images_list.rb - lib/fog/parsers/compute/voxel/voxcloud_create.rb - lib/fog/parsers/compute/voxel/voxcloud_delete.rb - lib/fog/parsers/compute/voxel/voxcloud_status.rb - lib/fog/voxel.rb - lib/fog/voxel/compute.rb - lib/fog/voxel/version.rb - spec/minitest_helper.rb - tests/helper.rb - tests/helpers/collection_helper.rb - tests/helpers/compute/flavors_helper.rb - tests/helpers/compute/server_helper.rb - tests/helpers/compute/servers_helper.rb - tests/helpers/formats_helper.rb - tests/helpers/formats_helper_tests.rb - tests/helpers/mock_helper.rb - tests/helpers/model_helper.rb - tests/helpers/responds_to_helper.rb - tests/helpers/schema_validator_tests.rb - tests/helpers/succeeds_helper.rb - tests/requests/compute/image_tests.rb - tests/requests/compute/server_tests.rb homepage: '' licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.2 signing_key: specification_version: 4 summary: Module for the 'fog' gem to support Voxel. test_files: - spec/minitest_helper.rb fog-voxel-0.0.2/.gitignore0000644000004100000410000000031012460371246015436 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp *.bundle *.so *.o *.a mkmf.log gemfiles/*.lockfog-voxel-0.0.2/CONTRIBUTING.md0000644000004100000410000000153312460371246015707 0ustar www-datawww-data## Getting Involved New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. ### Coding * Pick a task: * Offer feedback on open [pull requests](https://github.com/fog/fog-voxel/pulls). * Review open [issues](https://github.com/fog/fog-voxel/issues) for things to help on. * [Create an issue](https://github.com/fog/fog-voxel/issues/new) to start a discussion on additions or features. * Fork the project, add your changes and tests to cover them in a topic branch. * Commit your changes and rebase against `fog/fog-voxel` to ensure everything is up to date. * [Submit a pull request](https://github.com/fog/fog-voxel/compare/) ### Non-Coding * Offer feedback on open [issues](https://github.com/fog/fog-voxel/issues). * Organize or volunteer at events.fog-voxel-0.0.2/.ruby-gemset0000644000004100000410000000001112460371246015710 0ustar www-datawww-datafog-voxelfog-voxel-0.0.2/fog-voxel.gemspec0000644000004100000410000000240412460371246016727 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "fog/voxel/version" Gem::Specification.new do |spec| spec.name = "fog-voxel" spec.version = Fog::Voxel::VERSION spec.authors = %q(Paulo Henrique Lopes Ribeiro) spec.email = %q(plribeiro3000@gmail.com) spec.summary = %q{Module for the 'fog' gem to support Voxel.} spec.description = %q{This library can be used as a module for `fog` or as standalone provider to use the Voxel in applications.} spec.homepage = "" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_dependency "fog-core" spec.add_dependency "fog-xml" spec.add_development_dependency "rake" spec.add_development_dependency "minitest" spec.add_development_dependency "shindo" spec.add_development_dependency "turn" spec.add_development_dependency "pry" if RUBY_VERSION.to_f > 1.9 spec.add_development_dependency "coveralls" spec.add_development_dependency "rubocop" end end fog-voxel-0.0.2/README.md0000644000004100000410000000232712460371246014737 0ustar www-datawww-data# Fog::Voxel [![Gem Version](https://badge.fury.io/rb/fog-voxel.svg)](http://badge.fury.io/rb/fog-voxel) [![Build Status](https://travis-ci.org/fog/fog-voxel.svg?branch=master)](https://travis-ci.org/fog/fog-voxel) [![Dependency Status](https://gemnasium.com/fog/fog-voxel.svg)](https://gemnasium.com/fog/fog-voxel) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-voxel.svg)](https://coveralls.io/r/fog/fog-voxel?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-voxel.png)](https://codeclimate.com/github/fog/fog-voxel) Module for the 'fog' gem to support Voxel ## Help Needed This gem needs a maintainer. If you want to work on it, please contact [@geemus](mailto:geemus@gmail.com) or [@plribeiro3000](mailto:plribeiro3000@gmail.com) ## Installation Add this line to your application's Gemfile: ```ruby gem 'fog-voxel' ``` And then execute: $ bundle Or install it yourself as: $ gem install fog-voxel ## Contributing 1. Fork it ( https://github.com/fog/fog-voxel/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request