fog-ecloud-0.1.1/0000755000004100000410000000000012545467241013577 5ustar www-datawww-datafog-ecloud-0.1.1/Rakefile0000644000004100000410000000057012545467241015246 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 namespace :test do mock = ENV['FOG_MOCK'] || 'true' task :travis do sh("export FOG_MOCK=#{mock} && bundle exec shindont") end end desc 'Default Task' task :default => [ :test, 'test:travis' ] fog-ecloud-0.1.1/Gemfile0000644000004100000410000000013712545467241015073 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in fog-ecloud.gemspec gemspec fog-ecloud-0.1.1/tests/0000755000004100000410000000000012545467241014741 5ustar www-datawww-datafog-ecloud-0.1.1/tests/helper.rb0000644000004100000410000000126512545467241016551 0ustar www-datawww-dataif ENV['COVERAGE'] require 'coveralls' require 'simplecov' SimpleCov.command_name 'Unit Tests' SimpleCov.start do add_filter '/spec/' add_filter '/test/' end end require 'fog/ecloud' if ENV['COVERAGE'] Coveralls.wear! end 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 fog-ecloud-0.1.1/tests/compute/0000755000004100000410000000000012545467241016415 5ustar www-datawww-datafog-ecloud-0.1.1/tests/compute/helper.rb0000644000004100000410000000151712545467241020225 0ustar www-datawww-datadef compute_providers { :ecloud => { :server_attributes => { :name => "VM4", :row => "Layout Row 1", :group => "Layout Group 1", :catalog_network_name => "bridged", :description => "blarg", :operating_system => { :name => "Red Hat Enterprise Linux 5 (64-bit)", :href => "/cloudapi/ecloud/operatingsystems/rhel5_64guest/computepools/963", }, :organization_uri => 'organizations/9284920' }.tap do |hash| [:template_href, :network_uri, :environment_name, :organization_uri].each do |k| key = "ecloud_#{k}".to_sym if Fog.credentials[key] hash[k]= Fog.credentials[key] end end end, :mocked => true, } } end fog-ecloud-0.1.1/tests/compute/models/0000755000004100000410000000000012545467241017700 5ustar www-datawww-datafog-ecloud-0.1.1/tests/compute/models/environment_tests.rb0000644000004100000410000000147112545467241024016 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | environments", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first tests('#all').succeeds do returns(false) { @organization.environments.all.empty? } end tests('#get').succeeds do environment = @organization.environments.all.first fetched_environment = connection.environments.get(environment.href) returns(true) { !fetched_environment.nil? } end tests("#organization").succeeds do environment = @organization.environments.all.first returns(false, "returns an organization") { environment.organization.nil? } returns(true, "returns correct organization") { environment.organization.href == @organization.href } end end fog-ecloud-0.1.1/tests/compute/models/template_tests.rb0000644000004100000410000000131112545467241023256 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | templates", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first @compute_pool = @environment.compute_pools.first tests('#all').succeeds do templates = @compute_pool.templates returns(false) { templates.empty? } end tests('#get').succeeds do templates = @compute_pool.templates template = templates.first returns(false) { @compute_pool.templates.get(template.href).nil? } end end fog-ecloud-0.1.1/tests/compute/models/server_tests.rb0000644000004100000410000000253212545467241022757 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | server", [provider.to_s, "attributes"]) do connection = Fog::Compute[provider] connection.base_path = '/cloudapi/spec' organization = connection.organizations.first environment = organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || organization.environments.first public_ip = environment.public_ips.first compute_pool = environment.compute_pools.first image_href = Fog.credentials[:ecloud_image_href] || compute_pool.templates.first.href ssh_key = organization.admin.ssh_keys.find { |key| key.name == "root" } @network = environment.networks.first options = config[:server_attributes].merge(:network_uri => @network.href, :ssh_key_uri => ssh_key.href) #if Fog.credentials[:ecloud_ssh_key_id] # options = options.merge(:ssh_key_uri => "/cloudapi/ecloud/admin/sshkeys/#{Fog.credentials[:ecloud_ssh_key_id]}") #end @server = compute_pool.servers.first || compute_pool.servers.create(image_href, options).tap{|s| s.wait_for { ready? }} tests('#ip_addresses').succeeds do returns(true, "is an array") { @server.ips.is_a?(Array) } returns(true, "contains an VirtualMachineAssignedIp") { @server.ips.all?{|ip| ip.is_a?(Fog::Compute::Ecloud::VirtualMachineAssignedIp) } } end end fog-ecloud-0.1.1/tests/compute/models/organization_tests.rb0000644000004100000410000000126412545467241024156 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | organizations", [provider.to_s]) do connection = Fog::Compute[provider] tests('#all').succeeds do returns(false) { connection.organizations.all.empty? } end tests('#get').succeeds do organization = connection.organizations.all.first fetched_organization = connection.organizations.get(organization.href) returns(true) { !fetched_organization.nil? } end tests("#admin").succeeds do organization = connection.organizations.all.first returns(true, "return AdminOrganization") { organization.admin.is_a?(Fog::Compute::Ecloud::AdminOrganization) } end end fog-ecloud-0.1.1/tests/compute/models/compute_pool_tests.rb0000644000004100000410000000111312545467241024150 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | compute_pools", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.first tests('#all').succeeds do returns(false) { @environment.compute_pools.all.empty? } end tests('#get').succeeds do compute_pool = @environment.compute_pools.all.first fetched_compute_pool = connection.compute_pools.get(compute_pool.href) returns(true) { !fetched_compute_pool.nil? } end end fog-ecloud-0.1.1/tests/compute/models/ip_address_tests.rb0000644000004100000410000000113712545467241023566 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | ip_addresses", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.first @network = @environment.networks.first @ip_addresses = @network.ips tests('#all').succeeds do returns(false) { @ip_addresses.all.empty? } end tests('#get').succeeds do address = @ip_addresses.first fetched_network = connection.ip_addresses.get(address.href) returns(false) { fetched_network.nil? } end end fog-ecloud-0.1.1/tests/compute/models/internet_service_tests.rb0000644000004100000410000000225412545467241025022 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | internet_services", [provider.to_s, "queries"]) do connection = Fog::Compute[provider] organization = connection.organizations.first environment = organization.environments.find { |e| e.name == config[:ecloud_environment_name] } || organization.environments.first public_ips = environment.public_ips public_ip = public_ips.find { |i| i.name == config[:ecloud_public_ip_name] } || public_ips.first @internet_services = public_ip.internet_services tests('#all').succeeds do returns(true, "is a collection") { @internet_services.is_a?(Fog::Compute::Ecloud::InternetServices) } if Fog.mocking? returns(false, "has services") { @internet_services.empty? } else true end end unless @internet_services.empty? tests('#get').succeeds do service = @internet_services.first fetched_service = connection.internet_services.get(service.href) returns(false, "service is not nil") { fetched_service.nil? } returns(true, "is an InternetService") { fetched_service.is_a?(Fog::Compute::Ecloud::InternetService) } end end end fog-ecloud-0.1.1/tests/compute/models/admin_organization_tests.rb0000644000004100000410000000114012545467241025317 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | admin_organizations", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @admin_organization = @organization.admin tests('#get').succeeds do fetched_admin_organization = connection.get_admin_organization(@admin_organization.href) returns(true) { !fetched_admin_organization.nil? } end tests('#ssh_keys').succeeds do returns(true, "a list of SshKeys") { @admin_organization.ssh_keys.is_a?(Fog::Compute::Ecloud::SshKeys) } end end fog-ecloud-0.1.1/tests/compute/models/public_ip_tests.rb0000644000004100000410000000124312545467241023415 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | ip_addresses", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.first @public_ips = @environment.public_ips tests('#all').succeeds do returns(false, "has ips") { @public_ips.all.empty? } end tests('#get').succeeds do address = @public_ips.first fetched_ip = connection.public_ips.get(address.href) returns(false, "ip is not nil") { fetched_ip.nil? } returns(true, "is a PublicIp") { fetched_ip.is_a?(Fog::Compute::Ecloud::PublicIp) } end end fog-ecloud-0.1.1/tests/compute/models/network_tests.rb0000644000004100000410000000104312545467241023136 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | networks", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.first tests('#all').succeeds do returns(false) { @environment.networks.all.empty? } end tests('#get').succeeds do network = @environment.networks.all.first fetched_network = connection.networks.get(network.href) returns(true) { !fetched_network.nil? } end end fog-ecloud-0.1.1/tests/compute/models/operating_system_tests.rb0000644000004100000410000000154512545467241025050 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | operating_system", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first @compute_pool = @environment.compute_pools.first tests('#all').succeeds do family = @compute_pool.operating_system_families.first operating_systems = family.operating_systems returns(false) { operating_systems.empty? } end tests('#get').succeeds do family = @compute_pool.operating_system_families.first operating_system = family.operating_systems.first returns(false) { family.operating_systems.get(operating_system.href).nil? } end end fog-ecloud-0.1.1/tests/compute/models/operating_system_families_tests.rb0000644000004100000410000000112712545467241026715 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | operating_system_families", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.find{|e| e.name == config[:server_attributes][:environment_name]} || @organization.environments.first @compute_pool = @environment.compute_pools.first tests('#all').succeeds do operating_system_families = @compute_pool.operating_system_families returns(false) { operating_system_families.empty? } end end fog-ecloud-0.1.1/tests/compute/models/detached_disk_tests.rb0000644000004100000410000000200112545467241024213 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | detached_disks", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @environment = @organization.environments.first @compute_pool = @environment.compute_pools.first @detached_disks = @compute_pool.detached_disks tests('#all').succeeds do if @detached_disks.is_a?(Fog::Compute::Ecloud::DetachedDisks) && @detached_disks.reload.empty? returns(true, "compute pool has no detached disks") { @detached_disks.all.empty? } else returns(false, "has detached disks") { @detached_disks.all.empty? } end end unless @detached_disks.empty? tests('#get') do disk = @detached_disks.first fetched_disk = connection.detached_disks.get(disk.href) returns(false, "disk is not nil") { fetched_disk.nil? } returns(true, "is a DetachedDisk") { fetched_disk.is_a?(Fog::Compute::Ecloud::DetachedDisk) } end end end fog-ecloud-0.1.1/tests/compute/models/ssh_key_tests.rb0000644000004100000410000000102612545467241023113 0ustar www-datawww-dataprovider, config = :ecloud, compute_providers[:ecloud] Shindo.tests("Fog::Compute[:#{provider}] | ssh_keys", [provider.to_s]) do connection = Fog::Compute[provider] @organization = connection.organizations.first @admin_organization = @organization.admin @admin_organization.reload @ssh_keys = @admin_organization.ssh_keys tests('#all').succeeds do returns(false) { @ssh_keys.empty? } end tests('#get').succeeds do ssh_key = @ssh_keys.first returns(false) { @ssh_keys.get(ssh_key.href).nil? } end end fog-ecloud-0.1.1/tests/helpers/0000755000004100000410000000000012545467241016403 5ustar www-datawww-datafog-ecloud-0.1.1/tests/helpers/responds_to_helper.rb0000644000004100000410000000037412545467241022632 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-ecloud-0.1.1/tests/helpers/formats_helper.rb0000644000004100000410000000705612545467241021752 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-ecloud-0.1.1/tests/helpers/succeeds_helper.rb0000644000004100000410000000020612545467241022063 0ustar www-datawww-datamodule Shindo class Tests def succeeds test('succeeds') do !!instance_eval(&Proc.new) end end end end fog-ecloud-0.1.1/tests/helpers/collection_helper.rb0000644000004100000410000000502712545467241022426 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-ecloud-0.1.1/tests/helpers/compute/0000755000004100000410000000000012545467241020057 5ustar www-datawww-datafog-ecloud-0.1.1/tests/helpers/compute/servers_helper.rb0000644000004100000410000000041012545467241023427 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-ecloud-0.1.1/tests/helpers/compute/server_helper.rb0000644000004100000410000000124612545467241023254 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-ecloud-0.1.1/tests/helpers/compute/flavors_helper.rb0000644000004100000410000000146312545467241023423 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-ecloud-0.1.1/tests/helpers/model_helper.rb0000644000004100000410000000141412545467241021367 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-ecloud-0.1.1/tests/helpers/formats_helper_tests.rb0000644000004100000410000000702012545467241023163 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-ecloud-0.1.1/tests/helpers/mock_helper.rb0000644000004100000410000001472412545467241021230 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', :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-ecloud-0.1.1/tests/helpers/schema_validator_tests.rb0000644000004100000410000000723112545467241023462 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-ecloud-0.1.1/fog-ecloud.gemspec0000644000004100000410000000254212545467241017173 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'fog/ecloud/version' Gem::Specification.new do |spec| spec.name = "fog-ecloud" spec.version = Fog::Ecloud::VERSION spec.authors = ["Paulo Henrique Lopes Ribeiro"] spec.email = ["plribeiro3000@gmail.com"] spec.summary = %q{Module for the 'fog' gem to support Terremark EnterpriseCloud.} spec.description = %q{This library can be used as a module for `fog` or as standalone provider to use the Terremark EnterpriseCloud in applications.} spec.homepage = "" spec.license = "MIT" files = `git ls-files -z`.split("\x0") files.delete(".hound.yml") spec.files = files 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 "shindo" spec.add_development_dependency "minitest" 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-ecloud-0.1.1/.ruby-version0000644000004100000410000000000612545467241016240 0ustar www-datawww-data2.1.5 fog-ecloud-0.1.1/CONTRIBUTORS.md0000644000004100000410000000131412545467241016055 0ustar www-datawww-data* Bryan Paxton * Edward Muller * Eugene Howe * Eugene Howe & Josh Lane * Frederick Cheung * James Herdman * Joe Rafaniello * Jesse Newland * Kyle Rames * Lance Ivy * Peter Meier * Sarah Vessels * Shai Rosenfeld * Paulo Henrique Lopes Ribeiro * Paul Thornthwaite * tipt0e * Todd Willey * Wesley Beary fog-ecloud-0.1.1/spec/0000755000004100000410000000000012545467241014531 5ustar www-datawww-datafog-ecloud-0.1.1/spec/minitest_helper.rb0000644000004100000410000000150112545467241020246 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/ecloud.rb') Coveralls.wear! if ENV['COVERAGE'] fog-ecloud-0.1.1/LICENSE.md0000644000004100000410000000217712545467241015212 0ustar www-datawww-dataThe MIT License (MIT) Copyright (c) 2014-2014 [CONTRIBUTORS.md](https://github.com/fog/fog-ecloud/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-ecloud-0.1.1/.travis.yml0000644000004100000410000000066212545467241015714 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-ecloud-0.1.1/lib/0000755000004100000410000000000012545467241014345 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/0000755000004100000410000000000012545467241015120 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/bin/0000755000004100000410000000000012545467241015670 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/bin/ecloud.rb0000644000004100000410000000161512545467241017473 0ustar www-datawww-dataclass Ecloud < Fog::Bin class << self def available? Fog::Ecloud::ECLOUD_OPTIONS.all? {|requirement| Fog.credentials.include?(requirement)} end def class_for(key) case key when :compute Fog::Compute::Ecloud 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("Ecloud[:compute] is not recommended, use Compute[:ecloud] for portability") Fog::Compute.new(:provider => "Ecloud") else raise ArgumentError, "Unrecognized service: #{key.inspect}" end end @@connections[service] end def services Fog::Ecloud.services end end end fog-ecloud-0.1.1/lib/fog/ecloud/0000755000004100000410000000000012545467241016373 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/ecloud/mock_data_classes.rb0000644000004100000410000004025712545467241022367 0ustar www-datawww-datamodule Fog module Ecloud module MockDataClasses class Base < Hash def self.base_url=(url) @base_url = url end self.base_url = "http://vcloud.example.com" def self.base_url @base_url end def first raise "Don't do this" end def last raise "Don't do this" end def initialize(data = {}, parent = nil) @parent = parent replace(data) end def _parent @parent end def base_url Base.base_url end def href [base_url, self.class.name.split("::").last, object_id].join("/") end def inspect "<#{self.class.name} #{object_id} data=#{super}>" end end class MockData < Base def versions @versions ||= [] end def organizations @organizations ||= [] end def organization_collection_from_href(href) find_href_in(href, all_organizations) end def all_organizations organizations.map(&:environments).flatten end def organization_from_href(href) find_href_in(href, all_organizations) end def all_vdcs organizations.map(&:environments).flatten end def vdc_from_href(href) find_href_in(href, all_vdcs) end def all_catalogs all_vdcs.map(&:catalog).flatten end def catalog_from_href(href) find_href_in(href, all_catalogs) end def all_catalog_items all_catalogs.map(&:items).flatten end def catalog_item_from_href(href) find_href_in(href, all_catalog_items) end def all_virtual_machines all_vdcs.map(&:virtual_machines).flatten end def virtual_machine_from_href(href) find_href_prefixed_in(href, all_virtual_machines) end def all_networks all_vdcs.map(&:networks).flatten end def network_from_href(href) find_href_in(href, all_networks) end def all_network_extensions all_networks.map(&:extensions).flatten end def network_extension_from_href(href) find_href_in(href, all_network_extensions) end def all_vdc_internet_service_collections all_vdcs.map(&:internet_service_collection).flatten end def vdc_internet_service_collection_from_href(href) find_href_in(href, all_vdc_internet_service_collections) end def all_backup_internet_services all_vdc_internet_service_collections.map(&:backup_internet_services).flatten end def backup_internet_service_from_href(href) find_href_in(href, all_backup_internet_services) end def all_public_ip_collections all_vdcs.map {|v| v.public_ip_collection }.flatten end def public_ip_collection_from_href(href) find_href_in(href, all_public_ip_collections) end def all_public_ips all_public_ip_collections.map(&:items).flatten end def public_ip_from_href(href) find_href_in(href, all_public_ips) end def all_public_ip_internet_service_collections all_public_ips.map(&:internet_service_collection).flatten end def public_ip_internet_service_collection_from_href(href) find_href_in(href, all_public_ip_internet_service_collections) end def all_public_ip_internet_services all_public_ip_internet_service_collections.map(&:items).flatten end def public_ip_internet_service_from_href(href) find_href_in(href, all_public_ip_internet_services) end def all_public_ip_internet_service_node_collections all_public_ip_internet_services.map(&:node_collection).flatten end def public_ip_internet_service_node_collection_from_href(href) find_href_in(href, all_public_ip_internet_service_node_collections) end def all_public_ip_internet_service_nodes all_public_ip_internet_service_node_collections.map(&:items).flatten end def public_ip_internet_service_node_from_href(href) find_href_in(href, all_public_ip_internet_service_nodes) end def all_network_ip_collections all_networks.map(&:ip_collection) end def network_ip_collection_from_href(href) find_href_in(href, all_network_ip_collections) end def all_network_ips all_network_ip_collections.map {|c| c.items.values }.flatten end def network_ip_from_href(href) find_href_in(href, all_network_ips) end private def find_href_in(href, objects) objects.find {|o| o.href == href } end def find_href_prefixed_in(href, objects) objects.find {|o| href =~ %r{^#{o.href}($|/)} } end end class MockVersion < Base def version self[:version] end def supported !!self[:supported] end def login_url href end end class MockOrganization < Base def name self[:name] end def environments @vdcs ||= [] end end class MockVdc < Base def name self[:name] end def storage_allocated self[:storage_allocated] || 200 end def storage_used self[:storage_used] || 105 end def cpu_allocated self[:cpu_allocated] || 10000 end def memory_allocated self[:memory_allocated] || 20480 end def catalog @catalog ||= MockCatalog.new({}, self) end def networks @networks ||= [] end def virtual_machines @virtual_machines ||= [] end def task_list @task_list ||= MockTaskList.new({}, self) end # for TM eCloud, should probably be subclassed def public_ip_collection @public_ip_collection ||= MockPublicIps.new({}, self) end def internet_service_collection @internet_service_collection ||= MockVdcInternetServices.new({}, self) end def firewall_acls @firewall_acls ||= MockFirewallAcls.new({}, self) end end class MockTaskList < Base def name self[:name] || "Tasks List" end end class MockCatalog < Base def name self[:name] || "Catalog" end def items @items ||= [] end end class MockCatalogItem < Base def name self[:name] end def disks @disks ||= MockVirtualMachineDisks.new(self) end def customization @customization ||= MockCatalogItemCustomization.new({}, self) end def vapp_template @vapp_template ||= MockCatalogItemVappTemplate.new({ :name => name }, self) end end class MockCatalogItemCustomization < Base def name self[:name] || "Customization Options" end end class MockCatalogItemVappTemplate < Base def name self[:name] end end class MockNetwork < Base def name self[:name] || subnet end def subnet self[:subnet] end def gateway self[:gateway] || subnet_ips[1] end def netmask self[:netmask] || subnet_ipaddr.mask_string end def dns "8.8.8.8" end def features [ { :type => :FenceMode, :value => "isolated" } ] end def ip_collection @ip_collection ||= MockNetworkIps.new({}, self) end def extensions @extensions ||= MockNetworkExtensions.new({}, self) end def random_ip usable_subnet_ips[rand(usable_subnet_ips.length)] end # for TM eCloud. should probably be a subclass def rnat self[:rnat] end def usable_subnet_ips subnet_ips[3..-2] end def address subnet_ips.first end def broadcast subnet_ips.last end private def subnet_ipaddr @ipaddr ||= IPAddr.new(subnet) end def subnet_ips subnet_ipaddr.to_range.to_a.map(&:to_s) end end class MockNetworkIps < Base def items @items ||= _parent.usable_subnet_ips.reduce({}) do |out, subnet_ip| out.update(subnet_ip => MockNetworkIp.new({ :ip => subnet_ip }, self)) end end def ordered_ips items.values.sort_by {|i| i.ip.split(".").map(&:to_i) } end def name "IP Addresses" end end class MockNetworkIp < Base def name self[:name] || ip end def ip self[:ip] end def used_by self[:used_by] || _parent._parent._parent.virtual_machines.find {|v| v.ip == ip } end def status if used_by "Assigned" else "Available" end end def rnat self[:rnat] || _parent._parent.rnat end def rnat_set? !!self[:rnat] end end class MockNetworkExtensions < Base def name _parent.name end def gateway _parent.gateway end def broadcast _parent.broadcast end def address _parent.address end def rnat _parent.rnat end def type self[:type] || "DMZ" end def vlan object_id.to_s end def friendly_name "#{name} (#{type}_#{object_id})" end end class MockVirtualMachine < Base def name self[:name] end def ip self[:ip] end def cpus self[:cpus] || 1 end def memory self[:memory] || 1024 end def disks @disks ||= MockVirtualMachineDisks.new(self) end def status self[:status] || 2 end def power_off! self[:status] = 2 end def power_on! self[:status] = 4 end def size disks.reduce(0) {|s, d| s + d.vcloud_size } end def network_ip if network = _parent.networks.find {|n| n.ip_collection.items[ip] } network.ip_collection.items[ip] end end # from fog ecloud server's _compose_vapp_data def to_configure_vapp_hash { :name => name, :cpus => cpus, :memory => memory, :disks => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } } } end def href(purpose = :base) case purpose when :base super() when :power_on super() + "/power/action/powerOn" when :power_off super() + "/power/action/powerOff" end end end class MockVirtualMachineDisks < Array def initialize(parent = nil) @parent = parent end def _parent @parent end def <<(disk) next_address = 0 disk_with_max_address = max {|a, b| a[:address] <=> b[:address] } disk_with_max_address && next_address = disk_with_max_address.address + 1 disk[:address] ||= next_address super(disk) if (addresses = map {|d| d.address }).uniq.size != size raise "Duplicate disk address in: #{addresses.inspect} (#{size})" end sort! {|a, b| a.address <=> b.address } self end def at_address(address) find {|d| d.address == address } end end class MockVirtualMachineDisk < Base def size self[:size].to_i end def vcloud_size # kilobytes size * 1024 end def address self[:address].to_i end end # for Terremark eCloud class MockVdcInternetServices < Base def href _parent.href + "/internetServices" end def name "Internet Services" end def items public_ip_internet_services + backup_internet_services end def public_ip_internet_services _parent.public_ip_collection.items.reduce([]) do |services, public_ip| services + public_ip.internet_service_collection.items end end def backup_internet_services @backup_internet_services ||= [] end end class MockBackupInternetService < Base def name self[:name] || "Backup Internet Service #{object_id}" end def protocol self[:protocol] end def port 0 end def enabled self[:enabled].to_s.downcase != "false" end def timeout self[:timeout] || 2 end def description self[:description] || "Description for Backup Service #{name}" end def redirect_url nil end def node_collection @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) end end class MockFirewallAcls < Base def name "Firewall Access List" end end class MockPublicIps < Base def name self[:name] || "Public IPs" end def items @items ||= [] end end class MockPublicIp < Base def name self[:name] end def internet_service_collection @internet_service_collection ||= MockPublicIpInternetServices.new({}, self) end end class MockPublicIpInternetServices < Base def href _parent.href + "/internetServices" end def items @items ||= [] end end class MockPublicIpInternetService < Base def name self[:name] || "Public IP Service #{object_id}" end def description self[:description] || "Description for Public IP Service #{name}" end def protocol self[:protocol] end def port self[:port] end def enabled !!self[:enabled] end def redirect_url self[:redirect_url] end def timeout self[:timeout] || 2 end def node_collection @node_collection ||= MockPublicIpInternetServiceNodes.new({}, self) end def monitor nil end def backup_service self[:backup_service] end end class MockPublicIpInternetServiceNodes < Base def href _parent.href + "/nodeServices" end def items @items ||= [].tap do |node_array| node_array.instance_variable_set("@default_port", _parent.port) def node_array.<<(node) node[:port] ||= @default_port super end end end end class MockPublicIpInternetServiceNode < Base def ip_address self[:ip_address] end def name self[:name] || "Public IP Service Node #{object_id}" end def description self[:description] || "Description for Public IP Service Node #{name}" end def port self[:port] end def enabled self[:enabled].to_s.downcase != "false" end def enabled=(new_value) self[:enabled] = new_value end end end end end fog-ecloud-0.1.1/lib/fog/ecloud/version.rb0000644000004100000410000000007312545467241020405 0ustar www-datawww-datamodule Fog module Ecloud VERSION = "0.1.1" end end fog-ecloud-0.1.1/lib/fog/ecloud/ipaddr.rb0000644000004100000410000000010412545467241020156 0ustar www-datawww-dataclass IPAddr def mask_string _to_string(@mask_addr) end end fog-ecloud-0.1.1/lib/fog/ecloud/compute.rb0000644000004100000410000000005112545467241020370 0ustar www-datawww-data# This file was intentionally left blank fog-ecloud-0.1.1/lib/fog/ecloud.rb0000644000004100000410000000166112545467241016724 0ustar www-datawww-datarequire "fog/core" require "fog/xml" require "builder" require File.expand_path("../ecloud/version", __FILE__) require File.expand_path("../ecloud/ipaddr", __FILE__) module Fog module Compute autoload :Ecloud, File.expand_path("../compute/ecloud", __FILE__) end module Ecloud ECLOUD_OPTIONS = [:ecloud_authentication_method] autoload :MockDataClasses, File.expand_path("../ecloud/mock_data_classes", __FILE__) extend Fog::Provider service(:compute, "Compute") def self.keep(hash, *keys) {}.tap do |kept| keys.each{ |k| kept[k] = hash[k] if hash.key?(k) } end end def self.slice(hash, *keys) hash.dup.tap do |sliced| keys.each{ |k| sliced.delete(k) } end end def self.ip_address 4.times.map { Fog::Mock.random_numbers(3) }.join(".") end def self.mac_address 6.times.map { Fog::Mock.random_numbers(2) }.join(":") end end end fog-ecloud-0.1.1/lib/fog/compute/0000755000004100000410000000000012545467241016574 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/compute/ecloud/0000755000004100000410000000000012545467241020047 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/0000755000004100000410000000000012545467241021722 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_organization.rb0000644000004100000410000000115212545467241025611 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_organization end class Mock def get_organization(uri) organization_id = id_from_uri(uri) organization = self.data[:organizations][organization_id] body = { :xmlns_i => "http://www.w3.org/2001/XMLSchema-instance", :href => "/cloudapi/ecloud/organizations/", :type => "application/vnd.tmrk.cloud.organization; type=collection" }.merge(organization) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb0000644000004100000410000000454512545467241033242 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real def virtual_machine_edit_hardware_configuration(vm_uri, data) validate_data([:cpus, :memory, :disks, :nics], data) body = build_request_body_edit_hardware_configuration(data) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => vm_uri, :parse => true ) end def build_request_body_edit_hardware_configuration(data) xml = Builder::XmlMarkup.new xml.HardwareConfiguration do xml.ProcessorCount data[:cpus] xml.Memory do xml.Unit "MB" xml.Value data[:memory] end xml.Disks do data[:disks].each do |disk| xml.Disk do xml.Index disk[:Index] xml.Size do xml.Unit "GB" xml.Value disk[:Size][:Value] end end end end xml.Nics do data[:nics].each do |nic| xml.Nic do xml.UnitNumber nic[:UnitNumber] xml.MacAddress nic[:MacAddress] xml.Network(:href => nic[:Network][:href], :name => nic[:Network][:name], :type => "application/vnd.tmrk.cloud.network") do end end end end end end end class Mock def virtual_machine_edit_hardware_configuration(vm_uri, data) server_id = vm_uri.match(/(\d+)/)[1] server = self.data[:servers][server_id.to_i] task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Configure Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_location.rb0000644000004100000410000000017612545467241024722 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_location end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/node_service_delete.rb0000644000004100000410000000177512545467241026250 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :node_service_delete, 202, "DELETE" end class Mock def node_service_delete(uri) service_id = id_from_uri(uri) service = self.data[:node_services][service_id].dup self.data[:node_services].delete(service_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Node Service", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_edit_assigned_ips.rb0000644000004100000410000000515112545467241031160 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def build_request_body_edit_assigned_ips(networks) xml = Builder::XmlMarkup.new xml.AssignedIpAddresses do xml.Networks do networks.each do |network| xml.Network(:href => network[:href], :type => network[:type]) do xml.IpAddresses do network[:ips].each do |ip| xml.IpAddress ip end end end end end end end end class Real def virtual_machine_edit_assigned_ips(href, options) body = build_request_body_edit_assigned_ips(options) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => href, :parse => true ) end end class Mock def virtual_machine_edit_assigned_ips(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] options.each do |network| network_id = id_from_uri(network[:href]) network = self.data[:networks][network_id] options.each.each do |net| net[:ips].each do |ip| ip = network[:IpAddresses][:IpAddress].find { |iph| iph[:name] == ip } ip[:Host] = { :href => "/clouapi/ecloud/networkhosts/#{server_id}", :name => server[:name], :type => "application/vnd.tmrk.cloud.networkHost" } ip[:DetectedOn] = { :href => "/clouapi/ecloud/networkhosts/#{server_id}", :name => server[:name], :type => "application/vnd.tmrk.cloud.networkHost" } end end end task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_catalog_configuration.rb0000644000004100000410000000021312545467241027443 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_catalog_configuration end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_process.rb0000644000004100000410000000017512545467241024567 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_process end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_import.rb0000644000004100000410000001461312545467241027020 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_import_server_options(template_uri, options) required_opts = [:name, :cpus, :memory, :row, :group, :network_uri, :catalog_network_name] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end options[:network_uri] = [*options[:network_uri]] options[:template_uri] = template_uri options end def build_request_body_import(options) xml = Builder::XmlMarkup.new xml.ImportVirtualMachine(:name => options[:name]) do xml.ProcessorCount options[:cpus] xml.Memory do xml.Unit "MB" xml.Value options[:memory] end xml.Layout do xml.NewRow options[:row] xml.NewGroup options[:group] end xml.Description options[:description] if options[:tags] xml.Tags do options[:tags].each do |tag| xml.Tag tag end end end xml.CatalogEntry(:href => options[:template_uri]) xml.NetworkMappings do xml.NetworkMapping(:name => options[:catalog_network_name]) do xml.Network(:href => options[:network_uri][0]) end end if options[:operating_system] xml.OperatingSystem(:href => options[:operating_system][:href], :name => options[:operating_system][:name], :type => "application/vnd.tmrk.cloud.operatingSystem") end end end end class Real def virtual_machine_import(template_uri, options) options = validate_import_server_options(template_uri, options) request( :expects => 201, :method => "POST", :body => build_request_body_import(options), :uri => options[:uri], :parse => true ) end end class Mock def virtual_machine_import(template_uri, options) options = validate_import_server_options(template_uri, options) compute_pool_id = options[:uri].match(/computePools\/(\d+)/)[1].to_i compute_pool = self.data[:compute_pools][compute_pool_id].dup environment = self.data[:environments][compute_pool[:environment_id]] networks = options[:network_uri].map{|nuri| self.data[:networks][id_from_uri(nuri)].dup} server_id = Fog::Mock.random_numbers(6).to_i row_id = Fog::Mock.random_numbers(6).to_i group_id = Fog::Mock.random_numbers(6).to_i nics = networks.each_with_index.map do |network, i| { :UnitNumber => i.to_s, :Name => "Network adapter #{i}", :MacAddress => Fog::Ecloud.mac_address, :Network => Fog::Ecloud.keep(network, :name, :href, :type) } end links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)] networks.each{|network| links << Fog::Ecloud.keep(network, :name, :href, :type)} server = { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :Description => options[:description], :Status => "Deployed", :PoweredOn => "false", :HardwareConfiguration => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration", :type => "application/vnd.tmrk.cloud.virtualMachineHardware", :Links => { :Link => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :rel => "up" } }, :ProcessorCount => options[:cpus], :Memory => { :Unit => "MB", :Value => options[:memory], }, :Disks => { # Default drive :Disk => [{ :Index => "0", :Name => "Hard Disk 1", :Size => { :Unit => "GB", :Value => "25" }, }], }, :Nics => { :Nic => nics, }, }, :Links => { :Link => links }, } row = { :id => row_id, :name => options[:row], :href => "/cloudapi/ecloud/layoutrows/#{row_id}", :type => "application/vnd.tmrk.cloud.layoutRow", :Links => { :Link => [ Fog::Ecloud.keep(environment, :name, :href, :type) ], }, :Index => 0, :Groups => { :Group => [ ], }, :environment_id => environment[:id], } group = { :id => group_id, :name => options[:group], :href => "/cloudapi/ecloud/layoutgroups/#{group_id}", :type => "application/vnd.tmrk.cloud.layoutGroup", :Links => { :Link => [ Fog::Ecloud.keep(row, :name, :href, :type), ], }, :Index => 0, :VirtualMachines => { :VirtualMachine => [ server, ], }, :row_id => row_id, } row[:Groups][:Group].push(group) layout[:Rows][:Row].push(row) server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system] server_response = response(:body => server) server.merge!(:compute_pool_id => compute_pool_id) self.data[:servers][server_id] = server self.data[:rows][row_id] = row self.data[:groups][group_id] = group server_response end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_api_key.rb0000644000004100000410000000017512545467241024532 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_api_key end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_attach_disk.rb0000644000004100000410000000430112545467241027755 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def build_request_body_attach_disk(options) xml = Builder::XmlMarkup.new xml.AttachDisks(:name => options[:name]) do xml.DetachedDisks do xml.DetachedDisk(:href => options[:href], :name => options[:name], :type => "application/vnd.tmrk.cloud.detachedDisk") end end end end class Real def virtual_machine_attach_disk(href, options) body = build_request_body_attach_disk(options) request( :expects => 202, :method => "POST", :headers => {}, :body => body, :uri => href, :parse => true ) end end class Mock def virtual_machine_attach_disk(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] compute_pool_id = server[:compute_pool_id] compute_pool = self.data[:compute_pools][compute_pool_id] detached_disk_id = options[:href].match(/(\d+)/)[1].to_i detached_disk = self.data[:detached_disks][detached_disk_id] new_index = (server[:HardwareConfiguration][:Disks][:Disk].map { |h| h[:Index].to_i }.sort.last + 1).to_s detached_disk[:Index] = new_index server[:HardwareConfiguration][:Disks][:Disk] << Fog::Ecloud.keep(detached_disk, :Index, :Size, :Name) self.data[:detached_disks].delete(detached_disk_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Attach Disk", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_admin_organization.rb0000644000004100000410000000105012545467241026756 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_admin_organization end class Mock def get_admin_organization(uri) organization_id = id_from_uri(uri) admin_organization = self.data[:admin_organizations][organization_id] if admin_organization body = Fog::Ecloud.slice(admin_organization, :id, :organization_id) response(:body => body) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/node_service_edit.rb0000644000004100000410000000213512545467241025722 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_edit_node_service_options(options) required_opts = [:name, :enabled] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end end def build_node_service_body_edit(options) xml = Builder::XmlMarkup.new xml.NodeService(:name => options[:name]) do xml.Enabled options[:enabled] if options[:description] xml.Description options[:description] end end end end class Real def node_service_edit(options) validate_edit_node_service_options(options) body = build_node_service_body_edit(options) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => options[:uri], :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_storage_usage_detail.rb0000644000004100000410000000021212545467241027253 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_storage_usage_detail end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_task.rb0000644000004100000410000000027312545467241024052 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_task end class Mock def get_task(uri) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_internet_services.rb0000644000004100000410000000061212545467241026640 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_internet_services end class Mock def get_internet_services(uri) public_ip_id = id_from_uri(uri) public_ip = self.data[:public_ips][public_ip_id] response(:body => Fog::Ecloud.slice(public_ip, :environment_id)) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_user.rb0000644000004100000410000000017212545467241024064 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_user end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_support_ticket.rb0000644000004100000410000000020412545467241026161 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_support_ticket end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/internet_service_edit.rb0000644000004100000410000000432412545467241026627 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_edit_internet_service_options(options) required_opts = [:name, :enabled, :persistence] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end raise ArgumentError.new("Required data missing: #{:persistence[:type]}") unless options[:persistence][:type] end def build_node_service_body_edit(options) xml = Builder::XmlMarkup.new xml.InternetService(:name => options[:name]) do xml.Enabled options[:enabled] if options[:description] xml.Description options[:description] end xml.Persistence do xml.Type options[:persistence][:type] if options[:persistence][:timeout] xml.Timeout options[:persistence][:timeout] end end if options[:redirect_url] xml.RedirectUrl options[:redirect_url] end if options[:trusted_network_group] xml.TrustedNetworkGroup(:href => options[:trusted_network_group][:href], :name => service_data[:trusted_network_group][:name], :type => "application/vnd.tmrk.cloud.trustedNetworkGroup") end if options[:backup_internet_service] xml.BackupInternetService(:href => options[:backup_internet_service][:href], :name => service_data[:backup_internet_service][:name], :type => "application/vnd.tmrk.cloud.backupInternetService") end if options[:load_balancing_method] xml.LoadBalancingMethod options[:load_balancing_method] end end end end class Real def node_service_edit(options) validate_edit_node_service_options(options) body = build_node_service_body_edit(options) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => options[:uri], :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_physical_device.rb0000644000004100000410000000020512545467241026236 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_physical_device end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_associations.rb0000644000004100000410000000020212545467241025577 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_associations end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb0000644000004100000410000000200212545467241027756 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_upload_file_options(options) required_opts = [:file, :path, :credentials] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(', ')}") end end end class Real def virtual_machine_upload_file(vm_uri, options) validate_upload_file_options(options) request( :expects => 204, :method => "POST", :headers => { "Content-Type" => "application/octet-stream", "X-Guest-User" => options[:credentials][:user], "X-Guest-Password" => options[:credentials][:password], "Content-Range" => "0-#{options[:file].bytesize - 1}/#{options[:file].bytesize}" }, :body => options[:file], :uri => vm_uri + "?path=#{options[:path]}", :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_ip_address.rb0000644000004100000410000000107012545467241025221 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_ip_address end class Mock def get_ip_address(uri) network_id, ip_address_id = uri.match(/\/networks\/(\d+)\/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/).captures ip_address = self.data[:networks][network_id.to_i][:IpAddresses][:IpAddress].find{|ip| ip[:name] == ip_address_id }.dup if ip_address response(:body => ip_address) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/public_ip_activate.rb0000644000004100000410000000022112545467241026070 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :public_ip_activate, 201, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_physical_devices.rb0000644000004100000410000000020612545467241026422 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_physical_devices end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/admin_disable_support_access.rb0000644000004100000410000000023312545467241030135 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :admin_disable_support_access, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rnat_associations_create_device.rb0000644000004100000410000000143612545467241030640 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def rnat_associations_create_device(data) validate_data([:host_ip_href, :public_ip_href], data) request( :body => generate_rnat_associations_create_device_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_rnat_associations_create_device_request(data) xml = Builder::XmlMarkup.new xml.CreateRnatAssociation do xml.PublicIp(:href => data[:public_ip_href]) xml.IpAddress(:href => data[:host_ip_href]) end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/node_service_create.rb0000644000004100000410000000632312545467241026243 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_node_service_data(service_data) required_opts = [:name, :port, :enabled, :ip_address] unless required_opts.all? { |opt| service_data.key?(opt) } raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") end end end class Real include Shared def node_service_create(service_data) validate_node_service_data(service_data) request( :body => generate_node_service_request(service_data), :expects => 201, :method => "POST", :headers => {}, :uri => service_data[:uri], :parse => true ) end private def generate_node_service_request(service_data) xml = Builder::XmlMarkup.new xml.CreateNodeService(:name => service_data[:name]) do xml.IpAddress(:href => service_data[:ip_address], :name => service_data[:ip_address].scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0]) xml.Port service_data[:port] xml.Enabled service_data[:enabled] if service_data[:description] xml.Description service_data[:description] end end end end class Mock def node_service_create(service_data) validate_node_service_data(service_data) internet_service_id = service_data[:uri].match(/(\d+)/)[1] internet_service = self.data[:internet_services][internet_service_id.to_i].dup network_id, ip_address_name = service_data[:ip_address].match(/\/(\d+)\/(.*)$/).captures network = self.data[:networks][network_id.to_i] ip_addresses = network[:IpAddresses][:IpAddress] ip_addresses = ip_addresses.is_a?(Array) ? ip_addresses : [ip_addresses] ip_address = ip_addresses.find { |ip| ip[:name] == ip_address_name } service_id = Fog::Mock.random_numbers(6).to_i service = { :href => "/cloudapi/ecloud/nodeservices/#{service_id}", :name => service_data[:name], :type => "application/vnd.tmrk.cloud.nodeService", :Links => { :Link => [ Fog::Ecloud.keep(internet_service, :href, :name, :type), ], }, :Protocol => service_data[:protocol], :Port => service_data[:port], :Enabled => service_data[:enabled], :Description => service_data[:description], :IpAddress => { :href => ip_address[:href], :name => ip_address[:name], :type => ip_address[:type], :Network => { :href => network[:href], :name => network[:name], :type => network[:type], }, }, } node_service_response = response(:body => service) service.merge!(:internet_service => internet_service) self.data[:node_services][service_id] = service node_service_response end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_environment.rb0000644000004100000410000000153012545467241025451 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_environment end class Mock def get_environment(uri) environment_id = id_from_uri(uri) organizations = self.data[:organizations].values environment = nil catch(:found) do organizations.each do |organization| organization[:Locations][:Location].each do |location| environment = location[:Environments][:Environment].find{|e| e[:id] == environment_id} throw :found if environment end end end if environment body = environment.dup body.delete(:id) response(:body => body) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/trusted_network_groups_create.rb0000644000004100000410000000255112545467241030437 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def trusted_network_groups_create(data) validate_data([:name], data) unless (data[:hosts] || data[:networks]) raise ArgumentError.new("Required data missing: Either hosts or networks must be present") end request( :body => generate_create_trusted_network_groups_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_create_trusted_network_groups_request(data) xml = Builder::XmlMarkup.new xml.CreateTrustedNetworkGroup(:name => data[:name]) do if data[:hosts] xml.Hosts do data[:hosts].each do |ip| xml.IpAddress ip end end end if data[:networks] xml.Networks do data[:networks].each do |network| address, subnet = network.split("/") xml.Network do xml.Address address xml.Size subnet end end end end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_support_tickets.rb0000644000004100000410000000020512545467241026345 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_support_tickets end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_monitors.rb0000644000004100000410000000017612545467241024764 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_monitors end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_create_http.rb0000644000004100000410000000226512545467241026510 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_create_http(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :request_uri, :response_codes], data) request( :body => generate_http_monitor_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_http_monitor_request(data) xml = Builder::XmlMarkup.new xml.CreateHttpMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] xml.RequestUri data[:request_uri] if data[:http_headers] xml.HttpHeaders data[:http_headers] end xml.ResponseCodes do data[:response_codes].each do |c| xml.ResponseCode c end end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_edit_http.rb0000644000004100000410000000224212545467241026165 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_edit_http(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :request_uri, :response_codes], data) request( :body => generate_edit_http_request(data), :expects => 200, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_edit_http_request(data) xml = Builder::XmlMarkup.new xml.HttpMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] xml.RequestUri data[:request_uri] if xml[:httpheaders] xml.HttpHeaders xml[:http_headers] end xml.ResponseCodes do xml[:response_codes].each do |c| xml.ResponseCode c end end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_server.rb0000644000004100000410000000076712545467241024426 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_server end class Mock def get_server(uri) server_id = uri.match(/(\d+)/) server_id = server_id.nil? ? nil : server_id[1].to_i server = self.data[:servers][server_id] if server response(:body => Fog::Ecloud.slice(server, :id, :compute_pool_id)) else raise Fog::Errors::NotFound end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_processes.rb0000644000004100000410000000017712545467241025121 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_processes end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_memory_usage_detail_summary.rb0000644000004100000410000000022112545467241030674 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_memory_usage_detail_summary end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rows_create.rb0000644000004100000410000000112712545467241024565 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def rows_create(data) validate_data([:name], data) request( :body => generate_rows_create_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_rows_create_request(data) xml = Builder::XmlMarkup.new xml.CreateLayoutRow(:name => data[:name]) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rows_delete.rb0000644000004100000410000000073112545467241024564 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :rows_delete, 204, "DELETE" end class Mock def rows_delete(uri) row_id = id_from_uri(uri) self.data[:rows].delete(row_id) self.data[:layouts].values.each do |layout| layout[:Rows][:Row].delete_if { |r| r[:id] == row_id } end response(:body => nil, :status => 204) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_server_configuration_option.rb0000644000004100000410000000022112545467241030726 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_server_configuration_option end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_node.rb0000644000004100000410000000074312545467241024037 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_node end class Mock def get_node(uri) node_service_id = id_from_uri(uri) node_service = self.data[:node_services][node_service_id.to_i] if node_service response(:body => Fog::Ecloud.slice(node_service, :id, :internet_service_id)) else raise Fog::Errors::NotFound end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/firewall_acls_create.rb0000644000004100000410000000550112545467241026402 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def firewall_acls_create(data) validate_data([:permission, :protocol, :source, :destination], data) raise ArgumentError.new("Required data missing: source[:type] is required") unless data[:source][:type] raise ArgumentError.new("Required data missing: destination[:type] is required") unless data[:destination][:type] request( :body => generate_create_firewall_acls_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_create_firewall_acls_request(data) xml = Builder::XmlMarkup.new xml.CreateFirewallAcl do xml.Permission data[:permission] xml.Protocol data[:protocol] xml.Source do xml.Type data[:source][:type] if data[:source][:external_ip_address] xml.ExternalIpAddress data[:external_ip_address] end if data[:source][:external_network] xml.ExternalNetwork do xml.Address data[:source][:external_network][:address] xml.Size data[:source][:external_network][:size] end end if data[:source][:ip_address] xml.IpAddress(:href => data[:source][:ip_address]) end if data[:source][:network] xml.Network(:href => data[:source][:network][:href], :name => data[:source][:network][:name]) end end xml.Destination do xml.Type data[:destination][:type] if data[:destination][:external_ip_address] xml.ExternalIpAddress data[:external_ip_address] end if data[:destination][:external_network] xml.ExternalNetwork do xml.Address data[:destination][:external_network][:address] xml.Size data[:destination][:external_network][:size] end end if data[:destination][:ip_address] xml.IpAddress(:href => data[:destination][:ip_address]) end if data[:destination][:network] xml.Network(:href => data[:destination][:network][:href], :name => data[:destination][:network][:name]) end end xml.PortRange do if data[:port_range][:start] xml.Start data[:port_range][:start] end if data[:port_range][:end] xml.End data[:port_range][:end] end end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_servers.rb0000644000004100000410000000274512545467241024607 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_servers end class Mock def get_servers(uri) if uri =~ /layoutgroups/i group_id = id_from_uri(uri) group = self.data[:groups][group_id] servers = group[:VirtualMachines][:VirtualMachine] compute_pool_id = servers.first[:compute_pool_id] unless servers.empty? compute_pool = self.data[:compute_pools][compute_pool_id] unless compute_pool_id.nil? elsif uri =~ /computepool/i compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] servers = self.data[:servers].values.select{|cp| cp[:compute_pool_id] == compute_pool_id} servers = servers.map{|server| Fog::Ecloud.slice(server, :id, :compute_pool_id)} end links = if compute_pool.nil? [] else [Fog::Ecloud.keep(compute_pool, :name, :href, :type),] end server_response = {:VirtualMachine => (servers.size > 1 ? servers : servers.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.virtualMachine; type=collection", :Links => { :Link => links } }.merge(server_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_operating_system.rb0000644000004100000410000000140412545467241026501 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_operating_system end class Mock def get_operating_system(uri) os_name, compute_pool_id = uri.match(/operatingsystems\/(.*)\/computepools\/(\d+)$/).captures compute_pool_id = compute_pool_id.to_i operating_systems = self.data[:operating_systems].values.select{|os| os[:compute_pool_id] == compute_pool_id} operating_system = operating_systems.find{|os| os[:short_name] == os_name} if operating_system response(:body => Fog::Ecloud.slice(operating_system, :id, :compute_pool_id, :short_name)) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/power_off.rb0000644000004100000410000000021012545467241024226 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :power_off, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/admin_edit_authentication_levels.rb0000644000004100000410000000145612545467241031023 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real def authentication_levels_edit(data) validate_data([:basic, :sha1, :sha256, :sha512], data) body = build_authentication_levels_edit(data) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => data[:uri], :parse => true ) end private def build_authentication_levels_edit(data) xml = Builder::XmlMarkup.new xml.AuthenticationLevels do xml.BasicEnabled data[:basic] xml.SHA1Enabled data[:sha1] xml.SHA256Enabled data[:sha256] xml.SHA512Enabled data[:sha512] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb0000644000004100000410000000443512545467241027751 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def build_request_body_detach_disk(options) xml = Builder::XmlMarkup.new xml.DetachDisk(:name => options[:name]) do xml.Description options[:description] xml.Disk do xml.Index options[:disk][:Index] end end end end class Real def virtual_machine_detach_disk(href, options) body = build_request_body_detach_disk(options) request( :expects => 201, :method => "POST", :headers => {}, :body => body, :uri => href, :parse => true ) end end class Mock def virtual_machine_detach_disk(href, options) server_id = href.match(/(\d+)/)[1].to_i server = self.data[:servers][server_id] compute_pool_id = server[:compute_pool_id] compute_pool = self.data[:compute_pools][compute_pool_id] detached_disk_id = Fog::Mock.random_numbers(6).to_i detached_disk = { :id => detached_disk_id, :href => "/cloudapi/ecloud/detacheddisks/#{detached_disk_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.detachedDisk", :Links => { :Link => [ Fog::Ecloud.keep(compute_pool, :href, :name, :type), ], }, :Description => options[:description], :LastKnownVirtualMachineConfiguration => Fog::Ecloud.keep(server, :name, :ProcessorCount, :Memory, :OperatingSystem), :Type => "Data", :Size => { :Unit => "GB", :Value => options[:disk][:Size][:Value], }, :Status => "Available", } server[:HardwareConfiguration][:Disks][:Disk].delete_if { |disk| disk[:Index] == options[:disk][:Index] } detached_disk_response = response(:body => detached_disk) detached_disk.merge!(:compute_pool_id => compute_pool_id) self.data[:detached_disks][detached_disk_id] = detached_disk detached_disk_response end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_backup_internet_services.rb0000644000004100000410000000021612545467241030165 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_backup_internet_services end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_guest_processes.rb0000644000004100000410000000020512545467241026320 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_guest_processes end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_edit_ecv.rb0000644000004100000410000000210012545467241025754 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_edit_ecv(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :send_string, :receive_string], data) request( :body => generate_edit_ecv_request(data), :expects => 200, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_edit_ecv_request(data) xml = Builder::XmlMarkup.new xml.EcvMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] xml.SendString data[:send_string] if data[:http_headers] xml.HttpHeaders data[:http_headers] end xml.ReceiveString data[:receive_string] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_public_ip.rb0000644000004100000410000000072112545467241025054 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_public_ip end class Mock def get_public_ip(uri) public_ip_id = id_from_uri(uri) public_ip = self.data[:public_ips][public_ip_id] if public_ip response(:body => Fog::Ecloud.slice(public_ip, :id, :environment_id)) else raise Fog::Errors::NotFound end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_users.rb0000644000004100000410000000017312545467241024250 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_users end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/admin_edit_password_complexity_rules.rb0000644000004100000410000000646012545467241031763 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real def password_complexity_rules_edit(data) validate_data([:rule_type], data) if data[:rule_type] == "Custom" raise ArgumentError.new("Required data missing: custom_rules") unless data[:custom_rules] end validate_data([:minimum_characters, :minimum_uppercase_characters, :minimum_lowercase_characters, :minimum_numeric_characters, :minimum_special_characters, :maximum_consecutive_characters_from_prior_passwords, :minimum_lifetime_restriction, :minimum_generations_before_reuse], data[:custom_rules]) body = build_password_complexity_rules_edit(data) request( :expects => 202, :method => "PUT", :headers => {}, :body => body, :uri => data[:uri], :parse => true ) end private def build_password_complexity_rules_edit(data) xml = Builder::XmlMarkup.new xml.PasswordComplexityRules do xml.RuleType data[:rule_type] if data[:rule_type] == "Custom" xml.CustomRules do xml.MinimumCharacters do xml.Enabled data[:custom_rules][:minimum_characters][:enabled] xml.Value data[:custom_rules][:minimum_characters][:value] end xml.MinimumUpperCaseCharacters do xml.Enabled data[:custom_rules][:minimum_uppercase_characters][:enabled] xml.Value data[:custom_rules][:minimum_uppercase_characters][:value] end xml.MinimumLowerCaseCharacters do xml.Enabled data[:custom_rules][:minimum_lowercase_characters][:enabled] xml.Value data[:custom_rules][:minimum_lowercase_characters][:value] end xml.MinimumNumericCharacters do xml.Enabled data[:custom_rules][:minimum_numeric_characters][:enabled] xml.Value data[:custom_rules][:minimum_numeric_characters][:value] end xml.MinimumSpecialCharacters do xml.Enabled data[:custom_rules][:minimum_special_characters][:enabled] xml.Value data[:custom_rules][:minimum_special_characters][:value] end xml.MaximumConsecutiveCharactersFromPriorPasswords do xml.Enabled data[:custom_rules][:maximum_consecutive_characters_from_prior_passwords][:enabled] xml.Value data[:custom_rules][:maximum_consecutive_characters_from_prior_passwords][:value] end xml.MinimumLifetimeRestriction do xml.Enabled data[:custom_rules][:minimum_lifetime_restriction][:enabled] xml.Value data[:custom_rules][:minimum_lifetime_restriction][:value] end xml.MinimumGenerationsBeforeReuse do xml.Enabled data[:custom_rules][:minimum_generations_before_reuse][:enabled] xml.Value data[:custom_rules][:minimum_generations_before_reuse][:value] end end end if data[:description] xml.Description data[:description] end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_network.rb0000644000004100000410000000070612545467241024602 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_network end class Mock def get_network(uri) network_id = id_from_uri(uri) network = self.data[:networks][network_id].dup if network response(:body => Fog::Ecloud.slice(network, :id, :environment_id)) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_rnats.rb0000644000004100000410000000017312545467241024236 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_rnats end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_environments.rb0000644000004100000410000000000012545467241025623 0ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_compute_pool.rb0000644000004100000410000000074412545467241025620 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_compute_pool end class Mock def get_compute_pool(uri) compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] if compute_pool response(:body => Fog::Ecloud.slice(compute_pool, :id, :environment)) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_authentication_level.rb0000644000004100000410000000021212545467241027307 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_authentication_level end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_edit_ping.rb0000644000004100000410000000153612545467241026150 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_edit_ping(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled], data) request( :body => generate_edit_ping_request(data), :expects => 200, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_edit_ping_request(data) xml = Builder::XmlMarkup.new xml.PingMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/power_shutdown.rb0000644000004100000410000000021512545467241025334 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :power_shutdown, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/backup_internet_service_create.rb0000644000004100000410000000247612545467241030500 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def backup_internet_service_create(data) validate_data([:name, :protocol, :enabled, :persistence], data) unless data[:persistence][:type] raise ArgumentError.new("Required data missing: :persistence[:type]") end request( :body => generate_backup_internet_service_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_backup_internet_service_request(data) xml = Builder::XmlMarkup.new xml.CreateBackupInternetService(:name => data[:name]) do xml.Protocol data[:protocol] xml.Enabled data[:enabled] if data[:description] xml.Description data[:description] end xml.Persistence do xml.Type data[:persistence][:type] if data[:persistence][:timeout] xml.Timeout data[:persistence][:timeout] end end if data[:redirect_url] xml.RedirectUrl data[:redirect_url] end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/compute_pool_edit.rb0000644000004100000410000000170012545467241025757 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_edit_compute_pool_options(options) required_opts = [:name] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end end def build_compute_pool_body_edit(options) xml = Builder::XmlMarkup.new xml.ComputePool(:name => options[:name]) do end end end class Real def compute_pool_edit(options) validate_edit_compute_pool_options(options) body = build_compute_pool_body_edit(options) request( :expects => 200, :method => "PUT", :headers => {}, :body => body, :uri => options[:uri], :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/groups_movedown.rb0000644000004100000410000000021612545467241025503 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :groups_movedown, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_server_configuration_options.rb0000644000004100000410000000022212545467241031112 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_server_configuration_options end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_groups.rb0000644000004100000410000000046012545467241024425 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_groups end class Mock def get_groups(uri) row_id = id_from_uri(uri) row = self.data[:rows][row_id] response(:body => row) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/firewall_acls_delete.rb0000644000004100000410000000022512545467241026377 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :firewall_acls_delete, 202, "DELETE" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_copy.rb0000644000004100000410000001063612545467241026461 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_create_server_options_copy(template_uri, options) required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri, :source] if options[:customization] == :windows required_opts.push(:windows_password) else required_opts.push(:ssh_key_uri) end unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] options[:network_uri].map! do |uri| network = get_network(uri).body if options[:ips] ip = options[:ips][options[:network_uri].index(uri)] end {:href => uri, :name => network[:name], :ip => ip} end options end def build_request_body_copy(options) xml = Builder::XmlMarkup.new xml.CopyVirtualMachine(:name => options[:name]) do xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine") xml.ProcessorCount options[:cpus] xml.Memory do xml.Unit "MB" xml.Value options[:memory] end xml.Layout do xml.NewRow options[:row] xml.NewGroup options[:group] end if options[:customization] == :windows xml.WindowsCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do options[:network_uri].each do |uri| xml.NetworkAdapter do xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") xml.IpAddress uri[:ip] end end end if options[:dns_settings] xml.DnsSettings do xml.PrimaryDns options[:dns_settings][:primary_dns] if options[:dns_settings][:secondary_dns] xml.SecondaryDns options[:dns_settings][:secondary_dns] end end end end xml.Password options[:windows_password] if options[:windows_license_key] xml.LicenseKey options[:windows_license_key] end end else xml.LinuxCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] options[:network_uri].each do |uri| xml.NetworkAdapter do xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") xml.IpAddress uri[:ip] end end end if options[:dns_settings] xml.DnsSettings do xml.PrimaryDns options[:dns_settings][:primary_dns] if options[:dns_settings][:secondary_dns] xml.SecondaryDns options[:dns_settings][:secondary_dns] end end end end end xml.SshKey(:href => options[:ssh_key_uri]) end xml.Description options[:description] xml.Tags do options[:tags].each do |tag| xml.Tag tag end end xml.PoweredOn options[:powered_on] end end end class Real def virtual_machine_copy(template_uri, options) options = validate_create_server_options_copy(template_uri, options) body = build_request_body_copy(options) request( :expects => 201, :method => "POST", :headers => {}, :body => body, :uri => template_uri, :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_layout.rb0000644000004100000410000000051112545467241024420 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_layout end class Mock def get_layout(uri) environment_id = id_from_uri(uri) layout = self.data[:layouts][environment_id] response(:body => layout) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/trusted_network_groups_delete.rb0000644000004100000410000000023612545467241030434 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :trusted_network_groups_delete, 202, "DELETE" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rnat_associations_edit_network.rb0000644000004100000410000000126112545467241030550 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def rnat_associations_edit_network(data) validate_data([:href], data) request( :body => generate_rnat_associations_edit_network_request(data), :expects => 202, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_rnat_associations_edit_network_request(data) xml = Builder::XmlMarkup.new xml.NetworkRnat do xml.Rnat(:href => data[:href]) end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_detached_disks.rb0000644000004100000410000000173012545467241026045 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_detached_disks end class Mock def get_detached_disks(uri) compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] detached_disks = self.data[:detached_disks].values.select{|cp| cp[:compute_pool_id] == compute_pool_id} detached_disks = detached_disks.map{|dd| Fog::Ecloud.slice(dd, :id, :compute_pool_id)} detached_disk_response = {:DetachedDisk => (detached_disks.size > 1 ? detached_disks : detached_disks.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.detachedDisk; type=collection", :Links => { :Link => Fog::Ecloud.keep(compute_pool, :name, :href, :type), } }.merge(detached_disk_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/groups_moveup.rb0000644000004100000410000000021412545467241025156 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :groups_moveup, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/groups_delete.rb0000644000004100000410000000125212545467241025110 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :groups_delete, 204, "DELETE" end class Mock def groups_delete(uri) group_id = id_from_uri(uri) self.data[:groups].delete(group_id) self.data[:rows].values.each do |row| row[:Groups][:Group].delete_if { |g| g[:id] == group_id } end self.data[:layouts].values.each do |layout| layout[:Rows][:Row].each do |row| row[:Groups][:Group].delete_if { |g| g[:id] == group_id } end end response(:body => nil, :status => 204) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_api_keys.rb0000644000004100000410000000017612545467241024716 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_api_keys end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_roles.rb0000644000004100000410000000017312545467241024233 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_roles end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_trusted_network_group.rb0000644000004100000410000000021312545467241027561 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_trusted_network_group end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_ssh_key.rb0000644000004100000410000000072012545467241024552 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_ssh_key end class Mock def get_ssh_key(uri) ssh_key_id = id_from_uri(uri).to_i ssh_key = self.data[:ssh_keys][ssh_key_id.to_i] if ssh_key response(:body => Fog::Ecloud.slice(ssh_key, :id, :admin_organization)) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_row.rb0000644000004100000410000000045212545467241023716 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_row end class Mock def get_row(uri) row_id = id_from_uri(uri) row = self.data[:rows][row_id] response(:body => row) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rows_movedown.rb0000644000004100000410000000021412545467241025154 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :rows_movedown, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_public_ips.rb0000644000004100000410000000156512545467241025246 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_public_ips end class Mock def get_public_ips(uri) environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] public_ips = self.data[:public_ips].values.select{|cp| cp[:environment_id] == environment_id} public_ips = public_ips.map{|pi| Fog::Ecloud.slice(pi, :id, :environment_id)} public_ip_response = {:PublicIp => (public_ips.size > 1 ? public_ips : public_ips.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.publicIp; type=collection", :Links => { :Link => environment, } }.merge(public_ip_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_role.rb0000644000004100000410000000017212545467241024047 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_role end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_catalog_configurations.rb0000644000004100000410000000021412545467241027627 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_catalog_configurations end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_password_complexity_rules.rb0000644000004100000410000000021712545467241030437 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_password_complexity_rules end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_locations.rb0000644000004100000410000000017712545467241025106 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_locations end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_template.rb0000644000004100000410000000076212545467241024726 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_template end class Mock def get_template(uri) template_id, compute_pool_id = uri.match(/(\d+).*\/(\d+)$/).captures template = self.data[:templates][template_id.to_i] if template response(:body => Fog::Ecloud.slice(template, :id, :environment)) else response(:status => 404) # ? end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_create_ping.rb0000644000004100000410000000155512545467241026467 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_create_ping(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled], data) request( :body => generate_ping_monitor_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_ping_monitor_request(data) xml = Builder::XmlMarkup.new xml.CreatePingMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_operating_system_families.rb0000644000004100000410000000214312545467241030353 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_operating_system_families end class Mock def get_operating_system_families(uri) compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] operating_system_families = self.data[:operating_system_families].values.select{|osf| osf[:compute_pool_id] == compute_pool_id} operating_system_families = operating_system_families.map{|osf| Fog::Ecloud.slice(osf, :id, :compute_pool_id)}.map{|osf| osf[:OperatingSystemFamily]} operating_system_family_response = {:OperatingSystemFamily => (operating_system_families.size > 1 ? operating_system_families : operating_system_families.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.operatingSystemFamily; type=collection", :Links => { :Link => compute_pool, } }.merge(operating_system_family_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_trusted_network_groups.rb0000644000004100000410000000021412545467241027745 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_trusted_network_groups end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_templates.rb0000644000004100000410000000272412545467241025111 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_templates end class Mock def get_templates(uri) # /cloudapi/ecloud/computepools/compute_pools/534 compute_pool_id = id_from_uri(uri) compute_pool = self.data[:compute_pools][compute_pool_id] templates = self.data[:templates].values.select{|template| template[:compute_pool_id] == compute_pool_id} templates = templates.map{|template| Fog::Ecloud.slice(template, :id, :compute_pool)} template_response = {:Template => (templates.size > 1 ? templates : templates.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.template; type=collection", :Links => { :Link => compute_pool, }, :Families => { :Family => { :Name => "Standard Templates", :Categories => { :Category => [ { :Name => "OS Only", :OperatingSystems => { :OperatingSystem => { :Name => "Linux", :Templates => template_response, } } } ] } } } } response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rnat_associations_delete.rb0000644000004100000410000000023112545467241027310 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :rnat_associations_delete, 202, "DELETE" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_storage_usage_detail_summary.rb0000644000004100000410000000022212545467241031031 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_storage_usage_detail_summary end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/backup_internet_service_delete.rb0000644000004100000410000000023712545467241030470 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :backup_internet_service_delete, 202, "DELETE" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/groups_create.rb0000644000004100000410000000134512545467241025114 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def groups_create(data) validate_data([:name], data) request( :body => generate_groups_create_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_groups_create_request(data) xml = Builder::XmlMarkup.new xml.CreateLayoutGroup(:name => data[:name]) do xml.Row(:href => data[:href], :name => data[:row_name], :type => "application/vnd.tmrk.cloud.layoutRow") end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_detached_disk.rb0000644000004100000410000000076212545467241025666 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_detached_disk end class Mock def get_detached_disk(uri) detached_disk_id = id_from_uri(uri) detached_disk = self.data[:detached_disks][detached_disk_id] if detached_disk response(:body => Fog::Ecloud.slice(detached_disk, :id, :compute_pool_id)) else raise Fog::Errors::NotFound end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/internet_service_delete.rb0000644000004100000410000000201012545467241027132 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :internet_service_delete, 202, "DELETE" end class Mock def internet_service_delete(uri) service_id = id_from_uri(uri) service = self.data[:internet_services][service_id].dup self.data[:internet_services].delete(service_id) task_id = Fog::Mock.random_numbers(10).to_i task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Service", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(service, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/power_reset.rb0000644000004100000410000000021212545467241024600 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :power_reset, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_internet_service.rb0000644000004100000410000000101112545467241026447 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_internet_service end class Mock def get_internet_service(uri) internet_service_id = id_from_uri(uri) internet_service = self.data[:internet_services][internet_service_id.to_i] if internet_service response(:body => Fog::Ecloud.slice(internet_service, :id, :public_ip)) else raise Fog::Errors::NotFound end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_edit.rb0000644000004100000410000000233112545467241026425 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_edit_server_options(options) required_opts = [:name] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end end def build_request_body_edit(options) xml = Builder::XmlMarkup.new xml.VirtualMachine(:name => options[:name]) do if options[:description] xml.Description options[:description] end if options[:tags] xml.Tags do options[:tags].each do |tag| xml.Tag tag end end end end end end class Real def virtual_machine_edit(vm_uri, options) validate_edit_server_options(options) body = build_request_body_edit(options) request( :expects => [202,204], :method => "PUT", :headers => {}, :body => body, :uri => vm_uri, :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/admin_edit_login_banner.rb0000644000004100000410000000124012545467241027056 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real def login_banner_edit(data) validate_data([:display], data) body = build_login_banner_edit(data) request( :expects => 200, :method => "PUT", :headers => {}, :body => body, :uri => data[:uri], :parse => true ) end private def build_login_banner_edit(data) xml = Builder::XmlMarkup.new xml.LoginBanner do xml.Display data[:display] xml.Text data[:text] if data[:text] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/internet_service_create.rb0000644000004100000410000001007212545467241027142 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_internet_service_data(service_data) required_opts = [:name, :protocol, :port, :description, :enabled, :persistence] unless required_opts.all? { |opt| service_data.key?(opt) } raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}") end if service_data[:trusted_network_group] raise ArgumentError.new("Required Trusted Network Group data missing: #{([:name, :href] - service_data[:trusted_network_group].keys).map(&:inspect).join(", ")}") end if service_data[:backup_internet_service] raise ArgumentError.new("Required Backup Internet Service data missing: #{([:name, :href] - service_data[:backup_internet_service].keys).map(&:inspect).join(", ")}") end end end class Real include Shared def internet_service_create(service_data) validate_internet_service_data(service_data) request( :body => generate_internet_service_request(service_data), :expects => 201, :method => "POST", :headers => {}, :uri => service_data[:uri], :parse => true ) end private def generate_internet_service_request(service_data) xml = Builder::XmlMarkup.new xml.CreateInternetService(:name => service_data[:name]) do xml.Protocol service_data[:protocol] xml.Port service_data[:port] xml.Enabled service_data[:enabled] xml.Description service_data[:description] xml.Persistence do xml.Type service_data[:persistence][:type] if service_data[:persistence][:timeout] xml.Timeout service_data[:persistence][:timeout] end end if service_data[:redirect_url] xml.RedirectUrl service_data[:redirect_url] end if service_data[:trusted_network_group] xml.TrustedNetworkGroup(:href => service_data[:trusted_network_group][:href], :name => service_data[:trusted_network_group][:name], :type => "application/vnd.tmrk.cloud.trustedNetworkGroup") end if service_data[:backup_internet_service] xml.BackupInternetService(:href => service_data[:backup_internet_service][:href], :name => service_data[:backup_internet_service][:name], :type => "application/vnd.tmrk.cloud.backupInternetService") end if service_data[:load_balancing_method] xml.LoadBalancingMethod service_data[:load_balancing_method] end end end end class Mock def internet_service_create(service_data) validate_internet_service_data(service_data) public_ip_id = service_data[:uri].match(/(\d+)/)[1] public_ip = self.data[:public_ips][public_ip_id.to_i].dup service_id = Fog::Mock.random_numbers(6).to_i service = { :href => "/cloudapi/ecloud/internetServices/#{service_id}", :name => service_data[:name], :type => "application/vnd.tmrk.cloud.internetService", :Links => { :Link => [ Fog::Ecloud.keep(public_ip, :href, :name, :type), ], }, :Protocol => service_data[:protocol], :Port => service_data[:port], :Enabled => service_data[:enabled], :Description => service_data[:description], :PublicIp => Fog::Ecloud.keep(public_ip, :href, :name, :type), :Persistence => { :Type => service_data[:persistence][:type], }, } internet_service_response = response(:body => service) service.merge!(:public_ip => public_ip) self.data[:internet_services][service_id] = service internet_service_response end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_networks.rb0000644000004100000410000000151512545467241024764 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_networks end class Mock def get_networks(uri) environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id}.dup networks = networks.map{|n| Fog::Ecloud.slice(n, :environment, :id)} body = { :href => uri, :type => "application/vnd.tmrk.cloud.network; type=collection", :Links => { :Link => Fog::Ecloud.keep(environment, :name, :href, :type) }, :Network => (networks.size > 1 ? networks : networks.first), } response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_catalog.rb0000644000004100000410000000017512545467241024523 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_catalog end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb0000644000004100000410000000253412545467241030122 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def trusted_network_groups_edit(data) validate_data([:name], data) unless (data[:hosts] || data[:networks]) raise ArgumentError.new("Required data missing: Either hosts or networks must be present") end request( :body => generate_edit_trusted_network_groups_request(data), :expects => 202, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_edit_trusted_network_groups_request(data) xml = Builder::XmlMarkup.new xml.TrustedNetworkGroup(:name => data[:name]) do if data[:hosts] xml.Hosts do data[:hosts].each do |ip| xml.IpAddress ip end end end if data[:networks] xml.Networks do data[:networks].each do |network| address, subnet = network.split("/") xml.Network do xml.Address address xml.Size subnet end end end end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_nodes.rb0000644000004100000410000000056112545467241024220 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_nodes end class Mock def get_nodes(uri) internet_service_id = id_from_uri(uri) internet_service = self.data[:internet_services][internet_service_id] response(:body => internet_service) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_firewall_acls.rb0000644000004100000410000000020312545467241025710 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_firewall_acls end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_layouts.rb0000644000004100000410000000051312545467241024605 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_layouts end class Mock def get_layouts(uri) environment_id = id_from_uri(uri) layout = self.data[:layouts][environment_id] response(:body => layout) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_hardware_configurations.rb0000644000004100000410000000034212545467241030014 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_hardware_configurations end class Mock def get_hardware_configurations(uri) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_rows.rb0000644000004100000410000000022612545467241024100 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_rows end class Mock end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_disable.rb0000644000004100000410000000021712545467241025604 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :monitors_disable, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_enable.rb0000644000004100000410000000021612545467241025426 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :monitors_enable, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_organizations.rb0000644000004100000410000000126412545467241026000 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_organizations end # Real class Mock def get_organizations(uri) organizations = self.data[:organizations].values.dup organizations.each{|org| org.delete(:id)} body = { :xmlns_i => "http://www.w3.org/2001/XMLSchema-instance", :href => "/cloudapi/ecloud/organizations/", :type => "application/vnd.tmrk.cloud.organization; type=collection" }.merge(:Organization => (organizations.size > 1 ? organizations : organizations.first)) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_guest_process.rb0000644000004100000410000000020312545467241025766 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_guest_process end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_create_ecv.rb0000644000004100000410000000211712545467241026302 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def monitors_create_ecv(data) validate_data([:interval, :response_timeout, :retries, :downtime, :enabled, :send_string, :receive_string], data) request( :body => generate_ecv_monitor_request(data), :expects => 201, :method => "POST", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_ecv_monitor_request(data) xml = Builder::XmlMarkup.new xml.CreateEcvMonitor do xml.Interval data[:interval] xml.ResponseTimeout data[:response_timeout] xml.Retries data[:retries] xml.Downtime data[:downtime] xml.Enabled data[:enabled] xml.SendString data[:send_string] if data[:http_headers] xml.HttpHeaders data[:http_headers] end xml.ReceiveString data[:receive_string] end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_compute_pools.rb0000644000004100000410000000171512545467241026002 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_compute_pools end class Mock def get_compute_pools(uri) # /cloudapi/ecloud/computepools/environments/534 environment_id = id_from_uri(uri) environment = self.data[:environments][environment_id] compute_pools = self.data[:compute_pools].values.select{|cp| cp[:environment_id] == environment_id} compute_pools = compute_pools.map{|cp| Fog::Ecloud.slice(cp, :id, :environment_id)} compute_pool_response = {:ComputePool => (compute_pools.size > 1 ? compute_pools : compute_pools.first)} # GAH body = { :href => uri, :type => "application/vnd.tmrk.cloud.computePool; type=collection", :Links => { :Link => environment, } }.merge(compute_pool_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_login_banner.rb0000644000004100000410000000020212545467241025535 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_login_banner end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_password_complexity_rule.rb0000644000004100000410000000021612545467241030253 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_password_complexity_rule end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_delete.rb0000644000004100000410000000304012545467241026740 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :virtual_machine_delete, 202, "DELETE" end class Mock def virtual_machine_delete(uri) server_id = id_from_uri(uri) server = self.data[:servers][server_id] self.data[:servers].delete(server_id) self.data[:groups].values.each do |group| group[:VirtualMachines][:VirtualMachine].delete_if { |s| s[:name] == server[:name] } end self.data[:networks].values.each do |network| network[:IpAddresses][:IpAddress].each do |ip| unless ip[:Host].nil? ip[:Host] = nil if ip[:Host][:name] == server[:name] end unless ip[:DetectedOn].nil? ip[:DetectedOn] = nil if ip[:DetectedOn][:name] == server[:name] end end end task_id = Fog::Mock.random_numbers(10) task = { :id => task_id, :href => "/cloudapi/ecloud/tasks/#{task_id}", :type => "application/vnd.tmrk.cloud.task", :Operation => "Delete Server", :Status => "Complete", :ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type), :StartTime => Time.now.iso8601, :CompletedTime => Time.now.iso8601, :InitiatedBy => {}, } self.data[:tasks][task_id] = task response(:body => task) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_cpu_usage_detail_summary.rb0000644000004100000410000000021612545467241030157 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_cpu_usage_detail_summary end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rows_moveup.rb0000644000004100000410000000021212545467241024627 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :rows_moveup, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_tags.rb0000644000004100000410000000017212545467241024044 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_tags end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/groups_edit.rb0000644000004100000410000000112312545467241024570 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def groups_edit(data) validate_data([:name], data) request( :body => generate_groups_edit_request(data), :expects => 204, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => false ) end private def generate_groups_edit_request(data) xml = Builder::XmlMarkup.new xml.LayoutGroup(:name => data[:name]) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_login_banners.rb0000644000004100000410000000020312545467241025721 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_login_banners end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_backup_internet_service.rb0000644000004100000410000000021512545467241030001 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_backup_internet_service end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_group.rb0000644000004100000410000000047012545467241024243 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_group end class Mock def get_group(uri) group_id = id_from_uri(uri) group = self.data[:groups][group_id] response(:body => group) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_copy_identical.rb0000644000004100000410000000253512545467241030474 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_create_server_options_identical(template_uri, options) required_opts = [:name, :row, :group, :source] unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end options end def build_request_body_identical(options) xml = Builder::XmlMarkup.new xml.CopyIdenticalVirtualMachine(:name => options[:name]) do xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine") xml.Layout do xml.NewRow options[:row] xml.NewGroup options[:group] end xml.Description options[:description] end end end class Real def virtual_machine_copy_identical(template_uri, options) options = validate_create_server_options_identical(template_uri, options) body = build_request_body_identical(options) request( :expects => 201, :method => "POST", :headers => {}, :body => body, :uri => template_uri, :parse => true ) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_hardware_configuration.rb0000644000004100000410000000170312545467241027633 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_hardware_configuration end class Mock def get_hardware_configuration(uri) server_id = uri.match(/(\d+)/)[1] server = self.data[:servers][server_id.to_i] server_hardware_configuration = server[:HardwareConfiguration] new_hardware_configuration = { :href => server_hardware_configuration[:href], :type => server_hardware_configuration[:type], :ProcessorCount => server_hardware_configuration[:ProcessorCount], :Memory => server_hardware_configuration[:Memory], :Disks => server_hardware_configuration[:Disks], :Nics => server_hardware_configuration[:Nics], } response(:body => {:HardwareConfiguration => new_hardware_configuration}) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_monitor.rb0000644000004100000410000000017512545467241024600 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_monitor end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_association.rb0000644000004100000410000000020112545467241025413 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_association end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_virtual_machine_assigned_ips.rb0000644000004100000410000000272612545467241031017 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real def get_virtual_machine_assigned_ips(virtual_machine_id) request( :uri => "#{base_path}/virtualmachines/#{virtual_machine_id}/assignedips", :parse => true ) end end class Mock def get_virtual_machine_assigned_ips(virtual_machine_id) server = self.data[:servers][virtual_machine_id.to_i] compute_pool = self.data[:compute_pools][server[:compute_pool_id]] environment_id = compute_pool[:environment_id] environment = self.data[:environments][environment_id] networks = self.data[:networks].values.select{|n| n[:environment_id] == environment_id} networks = networks.map{|n| deep_copy(Fog::Ecloud.slice(n, :environment, :id))} networks.each do |network| address = network[:IpAddresses][:IpAddress].map{|ia| ia[:name]} network[:IpAddresses][:IpAddress] = address.first end body = { :href => "/cloudapi/ecloud/virtualMachines/#{virtual_machine_id}/assignedIps", :type => "application/vnd.tmrk.cloud.network", :Links => { :Link => Fog::Ecloud.keep(environment, :name, :href, :type) }, :Networks => {:Network => (networks.size > 1 ? networks : networks.first)}, } response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/power_on.rb0000644000004100000410000000020712545467241024076 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :power_on, 202, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_authentication_levels.rb0000644000004100000410000000021312545467241027473 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_authentication_levels end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_memory_usage_detail.rb0000644000004100000410000000021112545467241027116 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_memory_usage_detail end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/backup_internet_service_edit.rb0000644000004100000410000000246512545467241030160 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def backup_internet_service_edit(data) validate_data([:name, :protocol, :enabled, :persistence], data) unless data[:persistence][:type] raise ArgumentError.new("Required data missing: :persistence[:type]") end request( :body => generate_backup_internet_service_request(data), :expects => 202, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => true ) end private def generate_backup_internet_service_request(data) xml = Builder::XmlMarkup.new xml.BackupInternetService(:name => data[:name]) do xml.Protocol data[:protocol] xml.Enabled data[:enabled] if data[:description] xml.Description data[:description] end xml.Persistence do xml.Type data[:persistence][:type] if data[:persistence][:timeout] xml.Timeout data[:persistence][:timeout] end end if data[:redirect_url] xml.RedirectUrl data[:redirect_url] end end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_firewall_acl.rb0000644000004100000410000000020212545467241025524 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_firewall_acl end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_tasks.rb0000644000004100000410000000017312545467241024234 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_tasks end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_create_loopback.rb0000644000004100000410000000022712545467241027317 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :monitors_create_loopback, 201, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/rows_edit.rb0000644000004100000410000000111312545467241024242 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real include Shared def rows_edit(data) validate_data([:name], data) request( :body => generate_rows_edit_request(data), :expects => 204, :method => "PUT", :headers => {}, :uri => data[:uri], :parse => false ) end private def generate_rows_edit_request(data) xml = Builder::XmlMarkup.new xml.LayoutRow(:name => data[:name]) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_cpu_usage_detail.rb0000644000004100000410000000020612545467241026401 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_cpu_usage_detail end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.rb0000644000004100000410000002304212545467241031663 0ustar www-datawww-datamodule Fog module Compute class Ecloud module Shared def validate_create_server_options(template_uri, options) required_opts = [:name, :cpus, :memory, :row, :group, :customization, :network_uri] if options[:customization] == :windows required_opts.push(:windows_password) else required_opts.push(:ssh_key_uri) end unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}") end options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] options[:network_uri].map! do |uri| network = get_network(uri).body if options[:ips] ip = options[:ips][options[:network_uri].index(uri)] end {:href => uri, :name => network[:name], :ip => ip} end options[:template_uri] = template_uri options end def build_request_body(options) xml = Builder::XmlMarkup.new xml.CreateVirtualMachine(:name => options[:name]) do xml.ProcessorCount options[:cpus] xml.Memory do xml.Unit "MB" xml.Value options[:memory] end xml.Layout do xml.NewRow options[:row] xml.NewGroup options[:group] end xml.Description options[:description] xml.Tags do options[:tags].each do |tag| xml.Tag tag end end if options[:customization] == :windows xml.WindowsCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do options[:network_uri].each do |uri| xml.NetworkAdapter do xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") xml.IpAddress uri[:ip] end end end if options[:dns_settings] xml.DnsSettings do xml.PrimaryDns options[:dns_settings][:primary_dns] if options[:dns_settings][:secondary_dns] xml.SecondaryDns options[:dns_settings][:secondary_dns] end end end end xml.Password options[:windows_password] if options[:windows_license_key] xml.LicenseKey options[:windows_license_key] end end else xml.LinuxCustomization do xml.NetworkSettings do xml.NetworkAdapterSettings do options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] options[:network_uri].each do |uri| xml.NetworkAdapter do xml.Network(:href => uri[:href], :name => uri[:name], :type => "application/vnd.tmrk.cloud.network") xml.IpAddress uri[:ip] end end end if options[:dns_settings] xml.DnsSettings do xml.PrimaryDns options[:dns_settings][:primary_dns] if options[:dns_settings][:secondary_dns] xml.SecondaryDns options[:dns_settings][:secondary_dns] end end end end xml.SshKey(:href => options[:ssh_key_uri]) end end xml.PoweredOn options[:powered_on] xml.Template(:href => options[:template_uri], :type => options[:template_type]) end end end class Real def virtual_machine_create_from_template(template_uri, options) options = validate_create_server_options(template_uri, options) request( :expects => 201, :method => "POST", :body => build_request_body(options), :uri => options[:uri], :parse => true ) end end class Mock def virtual_machine_create_from_template(template_uri, options) options = validate_create_server_options(template_uri, options) server_id = Fog::Mock.random_numbers(7).to_i row_id = Fog::Mock.random_numbers(6).to_i group_id = Fog::Mock.random_numbers(6).to_i template_id, compute_pool_id = template_uri.match(/\/templates\/(\d+)\/computepools\/(\d+)$/).captures compute_pool = self.data[:compute_pools][compute_pool_id.to_i].dup environment = self.data[:environments][compute_pool[:environment_id]] layout = self.data[:layouts][environment[:id]] networks = options[:network_uri] nics = networks.each_with_index.map do |network, i| { :UnitNumber => i.to_s, :Name => "Network adapter #{i}", :MacAddress => Fog::Ecloud.mac_address, :Network => Fog::Ecloud.keep(network, :name, :href, :type), } end links = [Fog::Ecloud.keep(compute_pool, :name, :href, :type), Fog::Ecloud.keep(environment, :name, :href, :type)] networks.each do |network| links << Fog::Ecloud.keep(network, :name, :href, :type) network_id = id_from_uri(network[:href]) ip = self.data[:networks][network_id][:IpAddresses][:IpAddress].find { |ip| ip[:id] = network[:ip] } ip[:DetectedOn] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"} ip[:Host] = {:href => "/cloudapi/ecloud/networkhosts/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.networkHost"} end server = { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :Description => options[:description], :Status => "Deployed", :HardwareConfiguration => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}/hardwareconfiguration", :type => "application/vnd.tmrk.cloud.virtualMachineHardware", :Links => { :Link => { :href => "/cloudapi/ecloud/virtualmachines/#{server_id}", :name => options[:name], :type => "application/vnd.tmrk.cloud.virtualMachine", :rel => "up", } }, :ProcessorCount => options[:cpus], :Memory => { :Unit => "MB", :Value => options[:memory], }, :Disks => { :Disk => [{ :Index => "0", :Name => "Hard Disk 1", :Size => { :Unit => "GB", :Value => "25", }, }], }, :Nics => { :Nic => nics, }, }, :IpAddresses => { :AssignedIpAddresses => { :Networks => { :Network => self.data[:networks].dup.values, } } }, :Links => { :Link => links }, } row = { :id => row_id, :name => options[:row], :href => "/cloudapi/ecloud/layoutrows/#{row_id}", :type => "application/vnd.tmrk.cloud.layoutRow", :Links => { :Link => [ Fog::Ecloud.keep(environment, :name, :href, :type) ], }, :Index => 0, :Groups => { :Group => [ ], }, :environment_id => environment[:id], } group = { :id => group_id, :name => options[:group], :href => "/cloudapi/ecloud/layoutgroups/#{group_id}", :type => "application/vnd.tmrk.cloud.layoutGroup", :Links => { :Link => [ Fog::Ecloud.keep(row, :name, :href, :type), ], }, :Index => 0, :VirtualMachines => { :VirtualMachine => [ server, ], }, :row_id => row_id, } row[:Groups][:Group].push(group) layout[:Rows][:Row].push(row) server.merge!(:OperatingSystem => options[:operating_system].merge(:type => "application/vnd.tmrk.cloud.operatingSystem")) if options[:operating_system] server_response = response(:body => server) server.merge!(:compute_pool_id => compute_pool[:id]) self.data[:servers][server_id] = server self.data[:rows][row_id] = row self.data[:groups][group_id] = group server_response end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_rnat.rb0000644000004100000410000000017212545467241024052 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_rnat end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_network_summary.rb0000644000004100000410000000020512545467241026351 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_network_summary end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_ssh_keys.rb0000644000004100000410000000165512545467241024745 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_ssh_keys end class Mock def get_ssh_keys(uri) organization_id = id_from_uri(uri) organization = self.data[:organizations][organization_id] ssh_keys = self.data[:ssh_keys].values.select{|key| key[:admin_organization_id] == organization_id} ssh_keys = ssh_keys.map{|key| Fog::Ecloud.slice(key, :id, :admin_organization)} ssh_key_response = {:SshKey => (ssh_keys.size > 1 ? ssh_keys : ssh_keys.first)} # GAH body = { :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}/sshKeys", :type => "application/vnd.tmrk.cloud.sshKey; type=collection", :Links => { :Link => organization, }, }.merge(ssh_key_response) response(:body => body) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/admin_enable_support_access.rb0000644000004100000410000000023212545467241027757 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :admin_enable_support_access, 204, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_tag.rb0000644000004100000410000000017112545467241023660 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_tag end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/monitors_create_default.rb0000644000004100000410000000022612545467241027150 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :monitors_create_default, 201, "POST" end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/get_catalog_item.rb0000644000004100000410000000020212545467241025530 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Real basic_request :get_catalog_item end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/0000755000004100000410000000000012545467241021332 5ustar www-datawww-datafog-ecloud-0.1.1/lib/fog/compute/ecloud/models/task.rb0000644000004100000410000000125612545467241022625 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Task < Fog::Ecloud::Model identity :href attribute :type , :aliases => :Type attribute :operation, :aliases => :Operation attribute :status, :aliases => :Status attribute :impacted_item, :aliases => :ImpactedItem attribute :start_time, :aliases => :StartTime attribute :completed_time, :aliases => :CompletedTime attribute :notes, :aliases => :Notes attribute :error_message, :aliases => :ErrorMessage attribute :initiated_by, :aliases => :InitiatedBy def ready? !self.completed_time.nil? end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/model.rb0000644000004100000410000000050512545467241022757 0ustar www-datawww-datamodule Fog module Ecloud class Model < Fog::Model attr_accessor :loaded alias_method :loaded?, :loaded def reload instance = super @loaded = true instance end def load_unless_loaded! unless @loaded reload end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/location.rb0000644000004100000410000000110012545467241023457 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Location < Fog::Ecloud::Model identity :href ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i attribute :name, :aliases => :Name attribute :type, :aliases => :Type def catalog(org_href) @catalog ||= Fog::Compute::Ecloud::Catalog.new(:service => service, :href => "#{service.base_path}/admin/catalog/organizations/#{org_href.scan(/\d+/)[0]}/locations/#{id}") end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/detached_disk.rb0000644000004100000410000000114512545467241024433 0ustar www-datawww-datamodule Fog module Compute class Ecloud class DetachedDisk < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :status, :aliases => :Status attribute :size, :aliases => :Size def ready? unless status =~ /AttachInProgress|DetachInProgress/ true else false end end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/password_complexity_rules.rb0000644000004100000410000000111512545467241027206 0ustar www-datawww-datarequire File.expand_path("../password_complexity_rule", __FILE__) module Fog module Compute class Ecloud class PasswordComplexityRules < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::PasswordComplexityRule def all data = service.get_password_complexity_rules(href).body load(data) end def get(uri) if data = service.get_password_complexity_rule(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/monitors.rb0000644000004100000410000000107112545467241023530 0ustar www-datawww-datarequire File.expand_path("../monitor", __FILE__) module Fog module Compute class Ecloud class Monitors < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Monitor def all data = service.get_monitors(href).body load(data) end def get(uri) if data = service.get_monitor(uri) new(data.body) end rescue Fog::Errors::NotFound nil end def from_data(data) new(data) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/ip_address.rb0000644000004100000410000000234312545467241023776 0ustar www-datawww-datamodule Fog module Compute class Ecloud class IpAddress < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links, :squash => :Link attribute :host, :aliases => :Host attribute :detected_on, :aliases => :DetectedOn attribute :rnat, :aliases => :RnatAddress attribute :reserved, :aliases => :Reserved, :type => :boolean def status (detected_on || host) ? "Assigned" : "Available" end def id href.match(/((\d+{1,3}\.){3}(\d+{1,3}))$/)[1] end def server @server ||= begin reload unless other_links server_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.virtualMachine"} self.service.servers.get(server_link[:href]) end end def network reload if other_links.nil? network_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href] network = self.service.networks.get(network_href) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/rnats.rb0000644000004100000410000000077412545467241023016 0ustar www-datawww-datarequire File.expand_path("../rnat", __FILE__) module Fog module Compute class Ecloud class Rnats < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Rnat def all data = service.get_rnats(href).body[:Rnats][:Rnat] load(data) end def get(uri) if data = service.get_rnat(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/organization.rb0000644000004100000410000000576312545467241024376 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Organization < Fog::Ecloud::Model identity :href ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links, :squash => :Link def locations @locations ||= Fog::Compute::Ecloud::Locations.new( :service => service, :href => href ) end def environments @environments ||= self.service.environments(:href => href) end def tags @tags ||= self.service.tags(:href => "#{service.base_path}/deviceTags/organizations/#{id}") end def admin @admin ||= self.service.admin_organizations.new(:href => "#{service.base_path}/admin/organizations/#{id}") end def users @users ||= self.service.users(:href => "#{service.base_path}/admin/users/organizations/#{id}") end def support_tickets(type = :open) case type when :open @support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:service => service, :href => "#{service.base_path}/admin/tickets/organizations/#{id}/active") when :closed @support_tickets ||= Fog::Compute::Ecloud::SupportTickets.new(:service => service, :href => "#{service.base_path}/admin/tickets/organizations/#{id}/closed") end end def edit_authentication_levels(options = {}) options[:uri] = "#{service.base_path}/admin/organizations/#{id}/authenticationLevels" data = service.admin_edit_authentication_levels(options).body level = Fog::Compute::Ecloud::AdminOrganizations.new(:service => service, :href => data[:href])[0] end def edit_password_complexity_rules(options = {}) options[:uri] = "#{service.base_path}/admin/organizations/#{id}/passwordComplexityRules" data = service.admin_edit_password_complexity_rules(options).body level = Fog::Compute::Ecloud::PasswordComplexityRules.new(:service => service, :href => data[:href])[0] end def edit_login_banner(options = {}) options[:uri] = "#{service.base_path}/admin/organizations/#{id}/loginBanner" data = service.admin_edit_login_banner(options).body banner = Fog::Compute::Ecloud::LoginBanners.new(:service => service, :href => data[:href])[0] end def enable_support_access(options = {}) options[:uri] = "#{service.base_path}/admin/organizations/#{id}/action/enableSupportAccess" service.admin_enable_support_access(options[:uri]) end def disable_support_access(options = {}) options[:uri] = "#{service.base_path}/admin/organizations/#{id}/action/disableSupportAccess" service.admin_disable_support_access(options[:uri]) end def id href.scan(/\d+/)[0] end alias_method :vdcs, :environments end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/catalog_configurations.rb0000644000004100000410000000110012545467241026373 0ustar www-datawww-datarequire File.expand_path("../catalog_configuration", __FILE__) module Fog module Compute class Ecloud class CatalogConfigurations < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::CatalogConfiguration def all data = service.get_catalog_configurations(href).body load(data) end def get(uri) if data = service.get_catalog_configuration(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/guest_process.rb0000644000004100000410000000037712545467241024553 0ustar www-datawww-datamodule Fog module Compute class Ecloud class GuestProcess < Fog::Ecloud::Model identity :name attribute :process_id, :aliases => :ProcessId def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/servers.rb0000644000004100000410000000366112545467241023356 0ustar www-datawww-datarequire File.expand_path("../server", __FILE__) module Fog module Compute class Ecloud class Servers < Fog::Ecloud::Collection model Fog::Compute::Ecloud::Server identity :href def all data = service.get_servers(href).body if data.keys.include?(:VirtualMachines) data = data[:VirtualMachines][:VirtualMachine] elsif data[:VirtualMachine] data = data[:VirtualMachine] else data = [] end load(data) end def get(uri) data = service.get_server(uri).body new(data) rescue Fog::Errors::NotFound nil end def from_data(data) new(data) end def create( template_uri, options ) options[:cpus] ||= 1 options[:memory] ||= 512 options[:description] ||= "" options[:tags] ||= [] if template_uri =~ /\/templates\/\d+/ options[:uri] = href + "/action/createVirtualMachine" options[:customization] ||= :linux options[:powered_on] ||= false if options[:ips] options[:ips] = [*options[:ips]] else [*options[:network_uri]].each do |uri| index = options[:network_uri].index(uri) ip = self.service.ip_addresses(:href => uri).find { |i| i.host == nil && i.detected_on.nil? }.name options[:ips] ||= [] options[:ips][index] = ip end end data = service.virtual_machine_create_from_template( template_uri, options ).body else options[:uri] = href + "/action/importVirtualMachine" data = service.virtual_machine_import( template_uri, options ).body end object = self.service.servers.new(data) object end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/memory_usage_detail_summary.rb0000644000004100000410000000116012545467241027450 0ustar www-datawww-datarequire File.expand_path("../memory_usage_detail", __FILE__) module Fog module Compute class Ecloud class MemoryUsageDetailSummary < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::MemoryUsageDetail def all data = service.get_memory_usage_detail_summary(href).body[:MemoryUsageDetailSummary][:MemoryUsageDetail] load(data) end def get(uri) if data = service.get_memory_usage_detail(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/hardware_configurations.rb0000644000004100000410000000106412545467241026567 0ustar www-datawww-datarequire File.expand_path("../hardware_configuration", __FILE__) module Fog module Compute class Ecloud class HardwareConfigurations < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::HardwareConfiguration def all data = service.get_server(href).body load(data) end def get(uri) if data = service.get_hardware_configuration(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/roles.rb0000644000004100000410000000160412545467241023004 0ustar www-datawww-datarequire File.expand_path("../role", __FILE__) module Fog module Compute class Ecloud class Roles < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Role def all data = service.get_roles(href).body if data[:OrganizationRole] load(data[:OrganizationRole]) else r_data = [] data[:EnvironmentRoles][:EnvironmentRole].each do |d| d[:Environment][:EnvironmentName] = d[:Environment][:name] d[:Environment] = d[:Environment].merge(d[:Role]) if d[:Role] r_data << d[:Environment] end load(r_data) end end def get(uri) if data = service.get_role(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/cpu_usage_detail_summary.rb0000644000004100000410000000113312545467241026727 0ustar www-datawww-datarequire File.expand_path("../cpu_usage_detail", __FILE__) module Fog module Compute class Ecloud class CpuUsageDetailSummary < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::CpuUsageDetail def all data = service.get_cpu_usage_detail_summary(href).body[:CpuUsageDetailSummary][:CpuUsageDetail] load(data) end def get(uri) if data = service.get_cpu_usage_detail(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/trusted_network_group.rb0000644000004100000410000000171212545467241026337 0ustar www-datawww-datamodule Fog module Compute class Ecloud class TrustedNetworkGroup < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :hosts, :aliases => :Hosts def internet_services @internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href) end def edit(options) options[:uri] = href data = service.trusted_network_groups_edit(options).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def delete data = service.trusted_network_groups_delete(href).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/authentication_levels.rb0000644000004100000410000000107312545467241026251 0ustar www-datawww-datarequire File.expand_path("../authentication_level", __FILE__) module Fog module Compute class Ecloud class AuthenticationLevels < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::AuthenticationLevel def all data = service.get_authentication_levels(href).body load(data) end def get(uri) if data = service.get_authentication_level(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/memory_usage_detail.rb0000644000004100000410000000044612545467241025701 0ustar www-datawww-datamodule Fog module Compute class Ecloud class MemoryUsageDetail < Fog::Ecloud::Model identity :href attribute :time, :aliases => :Time attribute :value, :aliases => :Value def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/role.rb0000644000004100000410000000130212545467241022614 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Role < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :environment_name, :aliases => :EnvironmentName attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :role_type, :aliases => :RoleType attribute :active, :aliases => :Active, :type => :boolean attribute :category, :aliases => :Category attribute :is_admin, :aliases => :IsAdmin, :type => :boolean attribute :business_operations, :aliases => :BusinessOperations def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/guest_processes.rb0000644000004100000410000000105112545467241025071 0ustar www-datawww-datarequire File.expand_path("../guest_process", __FILE__) module Fog module Compute class Ecloud class GuestProcesses < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::GuestProcess def all data = service.get_guest_processes(href).body[:GuestProcess] load(data) end def get(uri) if data = service.get_guest_process(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/environments.rb0000644000004100000410000000164312545467241024412 0ustar www-datawww-datarequire File.expand_path("../environment", __FILE__) module Fog module Compute class Ecloud class Environments < Fog::Ecloud::Collection model Fog::Compute::Ecloud::Environment undef_method :create identity :href def all data = [] service.get_organization(href).body[:Locations][:Location].each do |d| environments = d[:Environments] next unless environments if environments[:Environment].is_a?(Array) environments[:Environment].each { |e| data << e } else data << environments[:Environment] end end load(data) end def get(uri) if data = service.get_environment(uri) new(data.body) end rescue Fog::Errors::NotFound nil end Vdcs = Environments end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/compute_pools.rb0000644000004100000410000000136412545467241024553 0ustar www-datawww-datarequire File.expand_path("../compute_pool", __FILE__) module Fog module Compute class Ecloud class ComputePools < Fog::Ecloud::Collection undef_method :create attribute :href, :aliases => :Href model Fog::Compute::Ecloud::ComputePool def all check_href!(:message => "the Compute Pool href of the Environment you want to enumerate") data = service.get_compute_pools(href).body[:ComputePool] load(data) end def get(uri) if data = service.get_compute_pool(uri) new(data.body) end rescue Fog::Errors::NotFound nil end def from_data(data) new(data) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/password_complexity_rule.rb0000644000004100000410000000234112545467241027025 0ustar www-datawww-datamodule Fog module Compute class Ecloud class PasswordComplexityRule < Fog::Ecloud::Model identity :href attribute :rule_type, :aliases => :RuleType attribute :custom_rules, :aliases => :CustomRules attribute :description, :aliases => :Description def minimum_characters custom_rules[:MinimumCharacters] end def minimum_upper_case_characters custom_rules[:MinimumUpperCaseCharacters] end def minimum_lower_case_characters custom_rules[:MinimumLowerCaseCharacters] end def minimum_numeric_characters custom_rules[:MinimumNumericCharacters] end def minimum_special_characters custom_rules[:MinimumSpecialCharacters] end def maximum_consecutive_characters_from_prior_password custom_rules[:MaximumConsecutiveCharactersFromPriorPassword] end def minimum_lifetime_restriction custom_rules[:MinimumLifetimeRestriction] end def minimum_generations_before_reuse custom_rules[:MinimumGenerationsBeforeReuse] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/network.rb0000644000004100000410000000300412545467241023345 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Network < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links, :squash => :Link attribute :address, :aliases => :Address attribute :network_type, :aliases => :NetworkType attribute :broadcast_address, :aliases => :BroadcastAddress attribute :gateway_address, :aliases => :GatewayAddress attribute :rnat_address, :aliases => :RnatAddress def rnats @rnats ||= Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/networks/#{id}") end def ips @ips ||= Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => href) end def edit_rnat_association(options) options[:uri] = href data = service.rnat_associations_edit_network(options).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def id href.scan(/\d+/)[0] end def environment reload if other_links.nil? environment_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href] self.service.environments.get(environment_href) end def location environment.id end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/login_banners.rb0000644000004100000410000000102312545467241024473 0ustar www-datawww-datarequire File.expand_path("../login_banner", __FILE__) module Fog module Compute class Ecloud class LoginBanners < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::LoginBanner def all data = service.get_login_banners(href).body load(data) end def get(uri) if data = service.get_login_banner(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/catalog.rb0000644000004100000410000000215112545467241023270 0ustar www-datawww-datarequire File.expand_path("../catalog_item", __FILE__) module Fog module Compute class Ecloud class Catalog < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::CatalogItem def all data = service.get_catalog(href).body#[:Locations][:Location][:Catalog][:CatalogEntry] if data[:Locations][:Location].is_a?(Hash) data = [] if data[:Locations][:Location][:Catalog].is_a?(String) && data[:Locations][:Location][:Catalog].empty? load(data) elsif data[:Locations][:Location].is_a?(Array) r_data = [] data[:Locations][:Location].each do |d| unless d[:Catalog].is_a?(String) && d[:Catalog].empty? d[:Catalog][:CatalogEntry].each do |c| r_data << c end end end load(r_data) end end def get(uri) if data = service.get_catalog_item(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/firewall_acls.rb0000644000004100000410000000112312545467241024463 0ustar www-datawww-datarequire File.expand_path("../firewall_acl", __FILE__) module Fog module Compute class Ecloud class FirewallAcls < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::FirewallAcl def all data = service.get_firewall_acls(href).body data = data[:FirewallAcl] ? data[:FirewallAcl] : data load(data) end def get(uri) if data = service.get_firewall_acl(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/association.rb0000644000004100000410000000107412545467241024175 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Association < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :ip_address, :aliases => :IpAddress def delete data = service.rnat_associations_delete(href).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => href)[0] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/ssh_key.rb0000644000004100000410000000071212545467241023324 0ustar www-datawww-datamodule Fog module Compute class Ecloud class SshKey < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :default, :aliases => :Default, :type => :boolean attribute :finger_print, :aliases => :FingerPrint def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/locations.rb0000644000004100000410000000107112545467241023651 0ustar www-datawww-datarequire File.expand_path("../location", __FILE__) module Fog module Compute class Ecloud class Locations < Fog::Ecloud::Collection model Fog::Compute::Ecloud::Location undef_method :create identity :href def all data = service.get_organization(href).body[:Locations][:Location] load(data) end def get(uri) if data = service.get_location(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/virtual_machine_assigned_ips.rb0000644000004100000410000000117312545467241027563 0ustar www-datawww-datarequire File.expand_path("../virtual_machine_assigned_ip", __FILE__) module Fog module Compute class Ecloud class VirtualMachineAssignedIps < Fog::Ecloud::Collection identity :virtual_machine_id model Fog::Compute::Ecloud::VirtualMachineAssignedIp def all data = service.get_virtual_machine_assigned_ips(self.identity).body load(data) end def get(uri) if data = service.get_virtual_machine_assigned_ip(self.identity) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/compute_pool.rb0000644000004100000410000000554212545467241024372 0ustar www-datawww-datamodule Fog module Compute class Ecloud class ComputePool < Fog::Ecloud::Model identity :href attribute :href, :aliases => :Href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links, :squash => :Link attribute :all_servers, :aliases => :VirtualMachines attribute :purchased, :aliases => :Purchased attribute :cpu_burst, :aliases => :CpuBurst attribute :memory_burst, :aliases => :MemoryBurst def servers @servers ||= Fog::Compute::Ecloud::Servers.new( :service => service, :href => "#{service.base_path}/virtualMachines/computePools/#{id}" ) end def layout @layout ||= Fog::Compute::Ecloud::Layouts.new(:service => service, :href => "#{service.base_path}/layout/computePools/#{id}").first end def cpu_usage # time ? query = "/details?time=#{Time.parse(time).utc.strftime("%Y-%m-%dT%H:%M:%SZ")}" : query = "" @cpu_usage ||= Fog::Compute::Ecloud::CpuUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/cpu") end def memory_usage # time ? query = "/details?time=#{Time.parse(time).utc.strftime("%Y-%m-%dT%H:%M:%SZ")}" : query = "" @memory_usage ||= Fog::Compute::Ecloud::MemoryUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/memory") end def storage_usage @storage_usage ||= Fog::Compute::Ecloud::StorageUsageDetailSummary.new(:service => service, :href => "#{service.base_path}/computePools/#{id}/usage/storage") end def operating_system_families @operating_system_families ||= Fog::Compute::Ecloud::OperatingSystemFamilies.new(:service => service, :href => "#{service.base_path}/operatingSystemFamilies/computePools/#{id}") end def templates @templates ||= self.service.templates(:href => "#{service.base_path}/templates/computePools/#{id}") end def detached_disks @detached_disks ||= self.service.detached_disks(:href => "#{service.base_path}/detacheddisks/computepools/#{id}") end def environment @environment ||= begin reload unless other_links environment_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.environment"} self.service.environments.get(environment_link[:href]) end end def edit(options) options[:uri] = href data = service.compute_pool_edit(options).body pool = collection.from_data(data) end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/rows.rb0000644000004100000410000000153212545467241022652 0ustar www-datawww-datarequire File.expand_path("../row", __FILE__) module Fog module Compute class Ecloud class Rows < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Row def all data = service.get_layout(href).body[:Rows][:Row] load(data) end def get(uri) data = service.get_row(uri).body if data == "" nil else new(data) end rescue Excon::Errors::NotFound nil end def create(options = {}) options[:uri] = "#{service.base_path}/layoutRows/environments/#{environment_id}/action/createLayoutRow" data = service.rows_create(options).body new(data) end def environment_id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/server_configuration_options.rb0000644000004100000410000000113412545467241027666 0ustar www-datawww-datarequire File.expand_path("../server_configuration_option", __FILE__) module Fog module Compute class Ecloud class ServerConfigurationOptions < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::ServerConfigurationOption def all data = service.get_server_configuration_options(href).body load(data) end def get(uri) if data = service.get_server_configuration_option(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/user.rb0000644000004100000410000000255712545467241022646 0ustar www-datawww-datamodule Fog module Compute class Ecloud class User < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :first_name, :aliases => :FirstName attribute :last_name, :aliases => :LastName attribute :email, :aliases => :Email attribute :status, :aliases => :Status attribute :last_login, :aliases => :LastLogin attribute :multifactor_authentication, :aliases => :MultifactorAuthentication attribute :is_administrator, :aliases => :IsAdministrator, :type => :boolean attribute :is_api_user, :aliases => :IsApiUser, :type => :boolean attribute :is_alert_notification_enabled, :aliases => :IsAlertNotificationEnabled, :type => :boolean attribute :is_multifactor_authentication_enabled, :aliases => :IsMultifactorAuthenticationEnabled, :type => :boolean def roles @roles = Fog::Compute::Ecloud::Roles.new(:service => service, :href => "#{service.base_path}/admin/roles/users/#{id}") end def api_keys @api_keys = Fog::Compute::Ecloud::ApiKeys.new(:service => service, :href => "#{service.base_path}/admin/apiKeys/users/#{id}") end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/admin_organizations.rb0000644000004100000410000000070312545467241025716 0ustar www-datawww-datarequire File.expand_path("../admin_organization", __FILE__) module Fog module Compute class Ecloud class AdminOrganizations < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::AdminOrganization def get(uri) if data = service.get_admin_organization(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/catalog_configuration.rb0000644000004100000410000000126712545467241026226 0ustar www-datawww-datamodule Fog module Compute class Ecloud class CatalogConfiguration < Fog::Ecloud::Model identity :href attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :processor_count, :aliases => :ProcessorCount, :type => :integer attribute :memory, :aliases => :Memory attribute :operating_system, :aliases => :OperatingSystem attribute :disks, :aliases => :Disks attribute :network_adapters, :aliases => :NetworkAdapters, :type => :integer attribute :network_mappings, :aliases => :NetworkMappings def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/monitor.rb0000644000004100000410000000330212545467241023344 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Monitor < Fog::Ecloud::Model identity :href attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :interval, :aliases => :Interval, :type => :integer attribute :response_timeout, :aliases => :ResponseTimeout, :type => :integer attribute :retries, :aliases => :Retries, :type => :integer attribute :downtime, :aliases => :Downtime, :type => :integer attribute :enabled, :aliases => :Enabled, :type => :boolean attribute :request_uri, :aliases => :RequestUri attribute :http_headers, :aliases => :HttpHeaders attribute :response_codes, :aliases => :ResponseCodes attribute :send_string, :aliases => :SendString attribute :receive_string, :aliases => :ReceiveString def edit(options = {}) href = "#{service.base_path}/internetServices/#{internet_service_id}/monitor?type=" case type when "application/vnd.tmrk.cloud.pingMonitor" options[:uri] = href + "ping" data = service.monitors_edit_ping(options).body when "application/vnd.tmrk.cloud.httpMonitor" options[:uri] = href + "http" data = service.monitors_edit_http(options).body when "application/vnd.tmrk.cloud.ecvMonitor" options[:uri] = href + "ecv" data = service.monitors_edit_ecv(options).body end object = collection.from_data(data) end def internet_service_id other_links[:Link][:href].scan(/\d+/)[0] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/hardware_configuration.rb0000644000004100000410000000105312545467241026402 0ustar www-datawww-datamodule Fog module Compute class Ecloud class HardwareConfiguration < Fog::Ecloud::Model identity :href attribute :processor_count, :aliases => :ProcessorCount, :type => :integer attribute :memory, :aliases => :Memory, :squash => :Value # {:Memory => {:Value => 15}} attribute :storage, :aliases => :Disks, :squash => :Disk attribute :network_cards, :aliases => :Nics, :squash => :Nic def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/operating_system_families.rb0000644000004100000410000000113312545467241027122 0ustar www-datawww-datarequire File.expand_path("../operating_system_family", __FILE__) module Fog module Compute class Ecloud class OperatingSystemFamilies < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::OperatingSystemFamily def all data = service.get_operating_system_families(href).body[:OperatingSystemFamily] load(data) end def get(uri) if data = service.get_operating_system(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/server_configuration_option.rb0000644000004100000410000000047612545467241027513 0ustar www-datawww-datamodule Fog module Compute class Ecloud class ServerConfigurationOption < Fog::Ecloud::Model identity :href attribute :disk, :aliases => :Disk attribute :customization, :aliases => :Customization def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/support_tickets.rb0000644000004100000410000000105712545467241025124 0ustar www-datawww-datarequire File.expand_path("../support_ticket", __FILE__) module Fog module Compute class Ecloud class SupportTickets < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::SupportTicket def all data = service.get_support_tickets(href).body[:TicketReference] load(data) end def get(uri) if data = service.get_support_ticket(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/ip_addresses.rb0000644000004100000410000000131112545467241024320 0ustar www-datawww-datarequire File.expand_path("../ip_address", __FILE__) module Fog module Compute class Ecloud class IpAddresses < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::IpAddress def all data = service.get_network(href).body data = if data[:IpAddresses] data[:IpAddresses][:IpAddress] else data end data = data.nil? ? [] : data load(data) end def get(uri) if data = service.get_ip_address(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/layout.rb0000644000004100000410000000056412545467241023201 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Layout < Fog::Ecloud::Model identity :href attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links def rows @rows ||= self.service.rows(:href => href) end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/public_ips.rb0000644000004100000410000000140212545467241024005 0ustar www-datawww-datarequire File.expand_path("../public_ip", __FILE__) module Fog module Compute class Ecloud class PublicIps < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::PublicIp def all data = service.get_public_ips(href).body data = data[:PublicIp] ? data[:PublicIp] : data load(data) end def get(uri) data = service.get_public_ip(uri).body new(data) rescue Fog::Errors::NotFound nil end def activate data = service.public_ip_activate(href + "/action/activatePublicIp").body ip = Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => data[:href])[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/storage_usage_detail.rb0000644000004100000410000000047212545467241026034 0ustar www-datawww-datamodule Fog module Compute class Ecloud class StorageUsageDetail < Fog::Ecloud::Model identity :href attribute :disk_count, :aliases => :DiskCount attribute :allocated, :aliases => :Allocated def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/physical_device.rb0000644000004100000410000000104112545467241025006 0ustar www-datawww-datamodule Fog module Compute class Ecloud class PhysicalDevice < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :tags, :aliases => :Tags attribute :layout, :aliases => :Layout attribute :network_host, :aliases => :NetworkHost attribute :classification, :aliases => :Classification attribute :model, :aliases => :Model def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/tag.rb0000644000004100000410000000027712545467241022440 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Tag < Fog::Ecloud::Model identity :name def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/virtual_machine_assigned_ip.rb0000644000004100000410000000156012545467241027400 0ustar www-datawww-datamodule Fog module Compute class Ecloud class VirtualMachineAssignedIp < Fog::Ecloud::Model identity :href attribute :network, :aliases => :Networks attribute :address def id href.scan(/\d+/)[0] end def network=(network) network = network.dup network_address = network[:Network] @network = self.service.networks.new(network_address) network_id = @network.href.match(/(\d+)$/)[1] address_ip = network_address[:IpAddresses][:IpAddress] @address = self.service.ip_addresses.new( :href => "#{service.base_path}/ipaddresses/networks/#{network_id}/#{address_ip}", :name => address_ip ) end attr_reader :network def address=(address); end attr_reader :address end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/tags.rb0000644000004100000410000000076412545467241022624 0ustar www-datawww-datarequire File.expand_path("../tag", __FILE__) module Fog module Compute class Ecloud class Tags < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Tag def all data = service.get_tags(href).body[:DeviceTag] load(data) end def get(uri) if data = service.get_tag(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/admin_organization.rb0000644000004100000410000000341212545467241025533 0ustar www-datawww-datamodule Fog module Compute class Ecloud class AdminOrganization < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links, :squash => :Link attribute :multifactor_summary, :aliases => :MultifactorSummary attribute :support_access, :aliases => :SupportAccess def ssh_keys @ssh_keys = Fog::Compute::Ecloud::SshKeys.new(:service => service, :href => "#{service.base_path}/admin/sshKeys/organizations/#{organization.id}") end def password_complexity_rules @password_complexity_rules = Fog::Compute::Ecloud::PasswordComplexityRules.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/passwordComplexityRules") end def login_banner @login_banner = Fog::Compute::Ecloud::LoginBanner.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/loginBanner") end def authentication_levels @authentication_levels = Fog::Compute::Ecloud::AuthenticationLevels.new(:service => service, :href => "#{service.base_path}/admin/organizations/#{organization.id}/authenticationLevels") end def id href.scan(/\d+/)[0] end def organization @organization ||= begin reload unless other_links organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"} self.service.organizations.new(organization_link) end end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/group.rb0000644000004100000410000000160112545467241023011 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Group < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :index, :aliases => :Index def servers @servers = Fog::Compute::Ecloud::Servers.new(:service => service, :href => href) end def edit(options = {}) options[:uri] = href data = service.groups_edit(options).body end def move_up service.groups_moveup(href).body end def move_down service.groups_movedown(href).body end def delete service.groups_delete(href).body end def id href.scan(/\d+/)[0] end alias_method :destroy, :delete end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/rnat.rb0000644000004100000410000000131412545467241022622 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Rnat < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :default, :aliases => :Default, :type => :boolean attribute :public_ip, :aliases => :PublicIp def networks @networks = Fog::Compute::Ecloud::Networks.new(:service => service, :href => href) end def associations @associations = Fog::Compute::Ecloud::Associations.new(:service => service, :href => href) end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/associations.rb0000644000004100000410000000141212545467241024354 0ustar www-datawww-datarequire File.expand_path("../association", __FILE__) module Fog module Compute class Ecloud class Associations < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Association def all data = service.get_associations(href).body if data[:Associations] data = data[:Associations] if data.is_a?(String) && data.empty? data = [] elsif data.is_a?(Hash) data = data[:Association] end end load(data) end def get(uri) if data = service.get_association(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/layouts.rb0000644000004100000410000000076712545467241023371 0ustar www-datawww-datarequire File.expand_path("../layout", __FILE__) module Fog module Compute class Ecloud class Layouts < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Layout def all data = service.get_layouts(href).body load(data) end def get(uri) if data = service.get_layout(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/backup_internet_services.rb0000644000004100000410000000167212545467241026745 0ustar www-datawww-datarequire File.expand_path("../backup_internet_service", __FILE__) module Fog module Compute class Ecloud class BackupInternetServices < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::BackupInternetService def all data = service.get_backup_internet_services(href).body load(data) end def get(uri) if data = service.get_backup_internet_service(uri) new(data.body) end rescue Fog::Errors::NotFound nil end def from_data(data) new(data) end def create(options) options[:uri] = href + "/action/createBackupInternetService" options[:enabled] ||= true data = service.backup_internet_service_create(options) new(data) end def internet_service_id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/ssh_keys.rb0000644000004100000410000000100312545467241023501 0ustar www-datawww-datarequire File.expand_path("../ssh_key", __FILE__) module Fog module Compute class Ecloud class SshKeys < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::SshKey def all data = service.get_ssh_keys(href).body[:SshKey] load(data) end def get(uri) if data = service.get_ssh_key(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/groups.rb0000644000004100000410000000153612545467241023203 0ustar www-datawww-datarequire File.expand_path("../group", __FILE__) module Fog module Compute class Ecloud class Groups < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Group def all data = service.get_groups(href).body data = if data == "" "" else data[:Groups] ? data[:Groups][:Group] : data end if data == "" || !data.is_a?(Array) && data[:type] == "application/vnd.tmrk.cloud.layoutRow" nil else load(data) end end def get(uri) data = service.get_group(uri).body if data == "" nil else new(data) end rescue Excon::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/operating_systems.rb0000644000004100000410000000075512545467241025445 0ustar www-datawww-datarequire File.expand_path("../operating_system", __FILE__) module Fog module Compute class Ecloud class OperatingSystems < Fog::Ecloud::Collection model Fog::Compute::Ecloud::OperatingSystem identity :data def all load(data) end def get(uri) if data = service.get_operating_system(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/collection.rb0000644000004100000410000000130012545467241024004 0ustar www-datawww-datamodule Fog module Ecloud class Collection < Fog::Collection def load(objects) objects = [ objects ] if objects.is_a?(Hash) super end def check_href!(opts = {}) unless href opts = { :parent => opts } if opts.is_a?(String) msg = ":href missing, call with a :href pointing to #{if opts[:message] opts[:message] elsif opts[:parent] "the #{opts[:parent]} whos #{self.class.to_s.split('::').last.downcase} you want to enumerate" else "the resource" end}" raise Fog::Errors::Error.new(msg) end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/support_ticket.rb0000644000004100000410000000162112545467241024736 0ustar www-datawww-datamodule Fog module Compute class Ecloud class SupportTicket < Fog::Ecloud::Model identity :href attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :date, :aliases => :Date attribute :status, :aliases => :Status attribute :category, :aliases => :Category attribute :detected_by, :aliases => :DetectedBy attribute :severity, :aliases => :Severity attribute :device, :aliases => :Device attribute :classification, :aliases => :Classification attribute :owner, :aliases => :Owner attribute :description, :aliases => :Description attribute :information, :aliases => :Information attribute :solution, :aliases => :Solution attribute :history, :aliases => :History def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/environment.rb0000644000004100000410000001030112545467241024216 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Environment < Fog::Ecloud::Model identity :href ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd attribute :name attribute :type attribute :other_links, :aliases => :Links, :squash => :Link def public_ips @public_ips ||= Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => "#{service.base_path}/publicIps/environments/#{id}") end def internet_services @internet_services ||= Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => "#{service.base_path}/networkSummary/environments/#{id}") end def node_services @node_services ||= Fog::Compute::Ecloud::Nodes.new(:service => service, :href => "#{service.base_path}/networkSummary/environments/#{id}") end def backup_internet_services @backup_internet_services ||= Fog::Compute::Ecloud::BackupInternetServices.new(:service => service, :href => "#{service.base_path}/backupInternetServices/environments/#{id}") end def networks @networks ||= self.service.networks(:href => "#{service.base_path}/networks/environments/#{id}") end def servers @servers = nil pools = compute_pools pools.each do |c| if pools.index(c) == 0 @servers = c.servers else c.servers.each { |s| @servers << s } end end @servers end def layout @layout ||= self.service.layouts(:href => "#{service.base_path}/layout/environments/#{id}").first end def rows @rows ||= layout.rows end def tasks @tasks ||= Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/environments/#{id}") end def firewall_acls @firewall_acls ||= Fog::Compute::Ecloud::FirewallAcls.new(:service => service, :href => "#{service.base_path}/firewallAcls/environments/#{id}") end def compute_pools @compute_pools ||= Fog::Compute::Ecloud::ComputePools.new(:service => service, :href => "#{service.base_path}/computePools/environments/#{id}") end def physical_devices @physical_devices ||= Fog::Compute::Ecloud::PhysicalDevices.new(:service => service, :href => "#{service.base_path}/physicalDevices/environments/#{id}") end def trusted_network_groups @trusted_network_groups ||= Fog::Compute::Ecloud::TrustedNetworkGroups.new(:service => service, :href => "#{service.base_path}/trustedNetworkGroups/environments/#{id}") end def catalog @catalog = service.catalog(:href => "#{service.base_path}/admin/catalog/organizations/#{organization.id}") end def rnats @rnats ||= Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/environments/#{id}") end def create_trusted_network_group(options = {}) options[:uri] = "#{service.base_path}/trustedNetworkGroups/environments/#{id}/action/createTrustedNetworkGroup" data = service.trusted_network_groups_create(options).body tng = Fog::Compute::Ecloud::TrustedNetworkGroups.new(:service => service, :href => data[:href])[0] end def create_firewall_acl(options = {}) options[:uri] = "#{service.base_path}/firewallAcls/environments/#{id}/action/createFirewallAcl" options[:permission] ||= "deny" options[:protocol] ||= "any" data = service.firewall_acls_create(options).body acl = Fog::Compute::Ecloud::FirewallAcls.new(:service => service, :href => data[:href])[0] end def id href.scan(/\d+/)[0] end def organization @organization ||= begin reload unless other_links organization_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.organization"} self.service.organizations.new(organization_link) end end end Vdc = Environment end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/operating_system.rb0000644000004100000410000000044212545467241025253 0ustar www-datawww-datamodule Fog module Compute class Ecloud class OperatingSystem < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/catalog_item.rb0000644000004100000410000000124612545467241024312 0ustar www-datawww-datamodule Fog module Compute class Ecloud class CatalogItem < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :status, :aliases => :Status attribute :alerts, :aliases => :Alerts attribute :files, :aliases => :Files def configuration @configuration = Fog::Compute::Ecloud::CatalogConfigurations.new(:service => service, :href => "#{service.base_path}/admin/catalog/#{id}/configuration") end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/trusted_network_groups.rb0000644000004100000410000000121612545467241026521 0ustar www-datawww-datarequire File.expand_path("../trusted_network_group", __FILE__) module Fog module Compute class Ecloud class TrustedNetworkGroups < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::TrustedNetworkGroup def all data = service.get_trusted_network_groups(href).body data = data[:TrustedNetworkGroup] ? data[:TrustedNetworkGroup] : data load(data) end def get(uri) if data = service.get_trusted_network_group(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/operating_system_family.rb0000644000004100000410000000102112545467241026606 0ustar www-datawww-datamodule Fog module Compute class Ecloud class OperatingSystemFamily < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :operating_system_family, :aliases => :OperatingSystems def operating_systems @operating_systems ||= self.service.operating_systems(:data => operating_system_family[:OperatingSystem]) end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/firewall_acl.rb0000644000004100000410000000146212545467241024306 0ustar www-datawww-datamodule Fog module Compute class Ecloud class FirewallAcl < Fog::Ecloud::Model identity :href attribute :type, :aliases => :Type attribute :links, :aliases => :Links attribute :permission, :aliases => :Permission attribute :acl_type, :aliases => :AclType attribute :port_type, :aliases => :PortType attribute :protocol, :aliases => :Protocol attribute :source, :aliases => :Source attribute :destination, :aliases => :Destination attribute :port_range, :aliases => :PortRange def tasks @tasks = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/virtualMachines/#{id}") end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/users.rb0000644000004100000410000000076412545467241023027 0ustar www-datawww-datarequire File.expand_path("../user", __FILE__) module Fog module Compute class Ecloud class Users < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::User def all data = service.get_users(href).body[:User] load(data) end def get(uri) if data = service.get_user(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/internet_services.rb0000644000004100000410000000233712545467241025417 0ustar www-datawww-datarequire File.expand_path("../internet_service", __FILE__) module Fog module Compute class Ecloud class InternetServices < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::InternetService def all data = service.get_internet_services(href).body[:InternetServices] if data.is_a?(Hash) load(data[:InternetService]) elsif data.is_a?(String) && data.empty? load([]) end end def get(uri) data = service.get_internet_service(uri).body new(data) rescue Fog::Errors::NotFound nil end def create(options) options[:uri] = "#{service.base_path}/internetServices/publicIps/#{public_ip_id}/action/createInternetService" options[:protocol] ||= "TCP" options[:enabled] ||= true options[:description] ||= "" options[:persistence] ||= {} options[:persistence][:type] ||= "None" data = service.internet_service_create(options).body object = new(data) end def public_ip_id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/internet_service.rb0000644000004100000410000000715612545467241025240 0ustar www-datawww-datamodule Fog module Compute class Ecloud class InternetService < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :actions, :aliases => :Actions attribute :protocol, :aliases => :Protocol attribute :port, :aliases => :Port, :type => :integer attribute :enabled, :aliases => :Enabled, :type => :boolean attribute :description, :aliases => :Description attribute :public_ip, :aliases => :PublicIp attribute :persistence, :aliases => :Persistence attribute :redirect_url, :aliases => :RedirectUrl attribute :trusted_network_group, :aliases => :TrustedNetworkGroup attribute :backup_internet_service, :aliases => :BackupInternetService def ready? !self.port.nil? end def nodes @nodes ||= Fog::Compute::Ecloud::Nodes.new(:service => service, :href => href) end def monitors @monitors ||= Fog::Compute::Ecloud::Monitors.new(:service => service, :href => "#{service.base_path}/internetServices/#{id}/monitor") end def save unless persisted? result = service.internet_service_create( collection.href, _compose_service_data ) merge_attributes(result.body) else service.configure_internet_service( href, _compose_service_data, _compose_ip_data ) end end def edit(options) options[:uri] = href data = service.internet_service_edit(options).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def delete data = service.internet_service_delete(href).body self.service.tasks.new(data) end def create_monitor(options = {}) options = {:type => :default}.merge(options) case options[:type] when :default data = service.monitors_create_default(href + "/action/createDefaultMonitor").body when :ping options[:enabled] ||= true options[:uri] = href + "/action/createPingMonitor" data = service.monitors_create_ping(options).body when :http options[:uri] = href + "/action/createHttpMonitor" data = service.monitors_create_http(options).body when :ecv options[:uri] = href + "/action/createEcvMonitor" data = service.monitors_create_ecv(options).body when :loopback data = service.monitors_create_loopback(href).body end monitor = Fog::Compute::Ecloud::Monitors.new(:service => service, :href => data[:href]) end def disable_monitor data = service.monitors_disable(href + "/action/disableMonitor").body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href]) end def id href.scan(/\d+/)[0] end private def _compose_service_data #For some reason inject didn't work service_data = {} self.class.attributes.select{ |attribute| attribute != :backup_service_data }.each { |attribute| service_data[attribute] = send(attribute) } service_data.reject! {|k, v| v.nil? } service_data end alias_method :destroy, :delete end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/authentication_level.rb0000644000004100000410000000142512545467241026067 0ustar www-datawww-datamodule Fog module Compute class Ecloud class AuthenticationLevel < Fog::Ecloud::Model identity :href attribute :basic_enabled, :aliases => :BasicEnabled, :type => :boolean attribute :sha1_enabled, :aliases => :SHA1Enabled, :type => :boolean attribute :Sha256_enabled, :aliases => :SHA256Enabled, :type => :boolean attribute :Sha512_enabled, :aliases => :SHA512Enabled, :type => :boolean attribute :hmacsha1_enabled, :aliases => :HMACSHA1Enabled, :type => :boolean attribute :hmacsha256_enabled, :aliases => :HMACSHA256Enabled, :type => :boolean attribute :hmacsha512_enabled, :aliases => :HMACSHA512Enabled, :type => :boolean def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/templates.rb0000644000004100000410000000233412545467241023657 0ustar www-datawww-datarequire File.expand_path("../template", __FILE__) module Fog module Compute class Ecloud class Templates < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Template def all r_data = [] data = service.get_templates(href).body[:Families] data[:Family].is_a?(Hash) ? data = [data[:Family]] : data = data[:Family] data.each do |d| cats = d[:Categories][:Category] cats = [cats] if cats.is_a?(Hash) cats.each do |cat| cat[:OperatingSystems][:OperatingSystem].is_a?(Hash) ? cat = [cat[:OperatingSystems][:OperatingSystem]] : cat = cat[:OperatingSystems][:OperatingSystem] cat.each do |os| os[:Templates][:Template].is_a?(Hash) ? os = [os[:Templates][:Template]] : os = os[:Templates][:Template] os.each do |template| r_data << template end end end end load(r_data) end def get(uri) if data = service.get_template(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/physical_devices.rb0000644000004100000410000000107112545467241025174 0ustar www-datawww-datarequire File.expand_path("../physical_device", __FILE__) module Fog module Compute class Ecloud class PhysicalDevices < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::PhysicalDevice def all data = service.get_physical_devices(href).body[:PhysicalDevice] || [] load(data) end def get(uri) if data = service.get_physical_device(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/node.rb0000644000004100000410000000245512545467241022612 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Node < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :ip_address, :aliases => :IpAddress attribute :protocol, :aliases => :Protocol attribute :port, :aliases => :Port, :type => :integer attribute :enabled, :aliases => :Enabled, :type => :boolean attribute :description, :aliases => :Description def ready? !self.name.nil? end def tasks @tasks ||= Fog::Compute::Ecloud::Tasks.new(:service => service, :href => "#{service.base_path}/tasks/virtualMachines/#{id}") end def delete data = service.node_service_delete(href).body self.service.tasks.new(data) end def edit(options) options[:uri] = href options[:description] ||= "" options = {:name => name}.merge(options) data = service.node_service_edit(options).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def id href.scan(/\d+/)[0] end alias_method :destroy, :delete end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/cpu_usage_detail.rb0000644000004100000410000000044312545467241025155 0ustar www-datawww-datamodule Fog module Compute class Ecloud class CpuUsageDetail < Fog::Ecloud::Model identity :href attribute :time, :aliases => :Time attribute :value, :aliases => :Value def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/row.rb0000644000004100000410000000262712545467241022475 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Row < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :index, :aliases => :Index def groups @groups = self.service.groups(:href => href) end def edit(options) options[:uri] = href service.rows_edit(options).body end def move_up(options) options[:uri] = href + "/action/moveup" service.rows_moveup(options).body end def move_down(options) options[:uri] = href + "/action/movedown" service.rows_movedown(options).body end def delete service.rows_delete(href).body end def create_group(options = {}) options[:uri] = "#{service.base_path}/layoutGroups/environments/#{environment_id}/action/createLayoutGroup" options[:row_name] = name options[:href] = href data = service.groups_create(options).body group = self.service.groups.new(data) end def environment_id reload if other_links.nil? other_links[:Link][:href].scan(/\d+/)[0] end def id href.scan(/\d+/)[0] end alias_method :destroy, :delete end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/login_banner.rb0000644000004100000410000000046712545467241024323 0ustar www-datawww-datamodule Fog module Compute class Ecloud class LoginBanner < Fog::Ecloud::Model identity :href attribute :display, :aliases => :Display, :type => :boolean attribute :text, :aliases => :Text def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/public_ip.rb0000644000004100000410000000126412545467241023630 0ustar www-datawww-datamodule Fog module Compute class Ecloud class PublicIp < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :ip_type, :aliases => :IpType def internet_services @internet_services = Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href) end def environment_id other_links[:Link].find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/storage_usage_detail_summary.rb0000644000004100000410000000115112545467241027604 0ustar www-datawww-datarequire File.expand_path("../storage_usage_detail", __FILE__) module Fog module Compute class Ecloud class StorageUsageDetailSummary < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::StorageUsageDetail def all data = service.get_storage_usage_detail_summary(href).body[:VirtualMachines][:VirtualMachine] load(data) end def get(uri) if data = service.get_storage_usage_detail(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/api_key.rb0000644000004100000410000000075112545467241023303 0ustar www-datawww-datamodule Fog module Compute class Ecloud class ApiKey < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :access_key, :aliases => :AccessKey attribute :status, :aliases => :Status attribute :private_key, :aliases => :PrivateKey def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/backup_internet_service.rb0000644000004100000410000000262412545467241026560 0ustar www-datawww-datamodule Fog module Compute class Ecloud class BackupInternetService < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :protocol, :aliases => :Protocol attribute :enabled, :aliases => :Enabled, :type => :boolean attribute :description, :aliases => :Description attribute :persistence, :aliases => :Persistence attribute :redirect_url, :aliases => :RedirectUrl def tasks @tasks = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => href) end def internet_services @internet_services = Fog::Compute::Ecloud::InternetServices.new(:service => service, :href => href) end def node_services @node_services = Fog::Compute::Ecloud::NodeServices.new(:service => service, :href => href) end def edit(options) options[:uri] = href data = service.backup_internet_service_edit(options).body object = collection.from_data(data) end def delete data = service.backup_internet_service_delete(href).body task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/api_keys.rb0000644000004100000410000000077212545467241023471 0ustar www-datawww-datarequire File.expand_path("../api_key", __FILE__) module Fog module Compute class Ecloud class ApiKeys < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::ApiKey def all data = service.get_api_keys(href).body load(data) end def get(uri) if data = service.get_api_key(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/server.rb0000644000004100000410000003067212545467241023175 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Server < Fog::Ecloud::Model extend Forwardable identity :href attribute :description, :aliases => :Description attribute :hardware_configuration, :aliases => :HardwareConfiguration attribute :ip_addresses, :aliases => :IpAddresses, :squash => :AssignedIpAddresses attribute :layout, :aliases => :Layout attribute :name, :aliases => :Name attribute :operating_system, :aliases => :OperatingSystem attribute :other_links, :aliases => :Links, :squash => :Link attribute :powered_on, :aliases => :PoweredOn, :type => :boolean attribute :status, :aliases => :Status attribute :tags, :aliases => :Tags attribute :tools_status, :aliases => :ToolsStatus attribute :type, :aliases => :Type def cpus hardware_configuration.processor_count end def memory # always in MB hardware_configuration.memory.to_i end def location end def flavor_id {:ram => hardware_configuration.memory.to_i, :cpus => hardware_configuration.processor_count} end def storage hardware_configuration.storage[:Disk] end def tasks @tasks ||= self.service.tasks(:href => "#{service.base_path}/tasks/virtualMachines/#{id}") end def processes @processes ||= Fog::Compute::Ecloud::GuestProcesses.new(:service, service, :href => "#{service.base_path}/virtualMachines/#{id}/guest/processes") end def hardware_configuration=(hardware_configuration) @hardware_configuration = self.service.hardware_configurations.new(hardware_configuration) end def hardware_configuration @hardware_configuration ||= self.service.hardware_configurations.new(:href => "#{service.base_path}/virtualMachines/#{id}/hardwareConfiguration") @hardware_configuration.reload end def configuration @configuration ||= Fog::Compute::Ecloud::ServerConfigurationOptions.new(:service => service, :href => "#{service.base_path}/virtualMachines/#{id}/configurationOptions")[0] end def ips @ips = self.service.virtual_machine_assigned_ips(:virtual_machine_id => self.id) end def networks @networks ||= self.service.networks(:href => "#{service.base_path}/virtualMachines/#{id}/assignedIps") end def power_on power_operation( :power_on => :powerOn ) end def power_off power_operation( :power_off => :powerOff ) end def shutdown power_operation( :power_shutdown => :shutdown ) end def power_reset power_operation( :power_reset => :reboot ) end def delete data = service.virtual_machine_delete(href).body self.service.tasks.new(data) end def copy(options = {}) options = {:type => :copy}.merge(options) options[:source] ||= href if options[:type] == :copy options[:cpus] ||= 1 options[:memory] ||= 512 options[:customization] ||= :linux options[:tags] ||= [] options[:powered_on] ||= false if options[:ips] options[:ips] = options[:ips].is_a?(String) ? [options[:ips]] : options[:ips] else options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri] options[:network_uri].each do |uri| index = options[:network_uri].index(uri) ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).find { |i| i.host == nil }.name options[:ips] ||= [] options[:ips][index] = ip end end data = service.virtual_machine_copy("#{service.base_path}/virtualMachines/computePools/#{compute_pool_id}/action/copyVirtualMachine", options).body elsif options[:type] == :identical data = service.virtual_machine_copy_identical("#{service.base_path}/virtualMachines/computePools/#{compute_pool_id}/action/copyIdenticalVirtualMachine", options).body end vm = collection.from_data(data) vm end def rnats rnats = Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/environments/#{environment_id}") associations = nil rnats.each do |rnat| if rnats.index(rnat) == 0 associations = rnat.associations.select do |association| ips.any? do |ip| association.name == ip.name end end else rnat.associations.select do |association| ips.each do |ip| if ip.name == association.name associations << association end end end end end associations end def edit(options = {}) data = service.virtual_machine_edit(href, options).body if data[:type] == "application/vnd.tmrk.cloud.task" task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0] end end def create_rnat(options) options[:host_ip_href] ||= ips.first.href options[:uri] = "#{service.base_path}/rnats/environments/#{environment_id}/action/createAssociation" data = service.rnat_associations_create_device(options).body rnat = Fog::Compute::Ecloud::Associations.new(:service => service, :href => data[:href])[0] end def disks c = hardware_configuration.reload.storage c = c.is_a?(Hash) ? [c] : c @disks = c end def add_disk(size) index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1 vm_disks = disks << {:Index => index.to_s, :Size=>{:Unit => "GB", :Value => size.to_s}, :Name => "Hard Disk #{index + 1}"} data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body task = self.service.tasks.new(data) end def detach_disk(index) options = {} options[:disk] = disks.find { |disk_hash| disk_hash[:Index] == index.to_s } options[:name] = self.name options[:description] = self.description data = service.virtual_machine_detach_disk(href + "/hardwareconfiguration/disks/actions/detach", options).body detached_disk = self.service.detached_disks.new(data) end def attach_disk(detached_disk) options = {} options[:name] = detached_disk.name options[:href] = detached_disk.href data = service.virtual_machine_attach_disk(href + "/hardwareconfiguration/disks/actions/attach", options).body task = self.service.tasks.new(data) end def delete_disk(index) vm_disks = disks.delete_if { |h| h[:Index] == index.to_s } data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareconfiguration", _configuration_data(:disks => vm_disks)).body task = self.service.tasks.new(data) end def nics c = hardware_configuration.network_cards c = c.is_a?(Hash) ? [c] : c @nics = c end def add_nic(network) unit_number = nics.map { |n| n[:UnitNumber].to_i }.sort[-1] + 1 vm_nics = nics << {:UnitNumber => unit_number, :Network => {:href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network"}} data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body task = self.service.tasks.new(:href => data[:href])[0] end def add_ip(options) slice_ips = begin ips rescue [] end slice_networks = if slice_ips.empty? [] else ips.map { |ip| { :href => ip.network.href, :name => ip.network.name.split(" ")[0], :type => ip.network.type} }.push(:href => options[:href], :name => options[:network_name], :type => "application/vnd.tmrk.cloud.network").uniq end slice_ips = slice_ips.map { |i| { :name => i.address.name, :network_name => i.network.name } }.push(:name => options[:ip], :network_name => options[:network_name]).uniq slice_ips.each do |ip| slice_networks.each do |network| if network[:name] == ip[:network_name] network[:ips] ||= [] network[:ips].push(ip[:name]) end end end data = service.virtual_machine_edit_assigned_ips(href + "/assignedIps", slice_networks).body task = self.service.tasks.new(data) end def delete_ip(options) slice_ips = begin ips rescue [] end slice_networks = if slice_ips.empty? [] else ips.map do |ip| { :href => ip.network.href, :name => ip.network.name.split(" ")[0], :type => ip.network.type, } end # .delete_if { |ip| ip[:href] == options[:href] && ip[:name] == options[:network_name] } end slice_ips.map! { |i| {:name => i.address.name, :network_name => i.network.name } }.delete_if { |ip| ip[:name] == options[:ip] } slice_ips.each do |ip| slice_networks.each do |network| if network[:name] == ip[:network_name] network[:ips].delete(ip[:name]) end end end data = service.virtual_machine_edit_assigned_ips(href + "/assignedips", slice_networks).body task = self.service.tasks.new(data) end def upload_file(options) service.virtual_machine_upload_file(href + "/guest/action/files", options) true end def storage_size vm_disks = disks disks.map! { |d| d[:Size][:Value].to_i }.reduce(0){|sum,item| sum + item} * 1024 * 1024 end def ready? load_unless_loaded! unless status =~ /NotDeployed|Orphaned|TaskInProgress|CopyInProgress/ true else false end end def on? powered_on == true end def off? powered_on == false end def compute_pool_id other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0] end def compute_pool reload if other_links.nil? @compute_pool = self.service.compute_pools.new(:href => other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href]) end def environment_id other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0] end def id href.scan(/\d+/)[0] end private def _configuration_data(options = {}) {:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.memory), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)} end def power_operation(op) requires :href begin service.send(op.keys.first, href + "/action/#{op.values.first}" ) rescue Excon::Errors::Conflict => e #Frankly we shouldn't get here ... raise e unless e.to_s =~ /because it is already powered o(n|ff)/ end true end alias_method :destroy, :delete end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/organizations.rb0000644000004100000410000000147612545467241024556 0ustar www-datawww-datarequire File.expand_path("../organization", __FILE__) module Fog module Compute class Ecloud class Organizations < Fog::Ecloud::Collection model Fog::Compute::Ecloud::Organization undef_method :create identity :href def all data = service.get_organizations(organization_uri).body load(data[:Organization]) end def get(uri) if data = service.get_organization(uri) new(data.body) end rescue Fog::Errors::NotFound nil end def organization_uri @organization_uri ||= service.default_organization_uri end private def organization_uri=(new_organization_uri) @organization_uri = new_organization_uri end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/detached_disks.rb0000644000004100000410000000106012545467241024612 0ustar www-datawww-datarequire File.expand_path("../detached_disk", __FILE__) module Fog module Compute class Ecloud class DetachedDisks < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::DetachedDisk def all data = service.get_detached_disks(href).body[:DetachedDisk] data = [] if data.nil? load(data) end def get(uri) data = service.get_detached_disk(uri).body new(data) rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/tasks.rb0000644000004100000410000000121212545467241023000 0ustar www-datawww-datarequire File.expand_path("../task", __FILE__) module Fog module Compute class Ecloud class Tasks < Fog::Ecloud::Collection model Fog::Compute::Ecloud::Task identity :href attribute :other_links, :aliases => :Links attribute :total_count, :aliases => :TotalCount def all data = service.get_tasks(href).body data = data[:Task] ? data[:Task] : data load(data) end def get(uri) if data = service.get_task(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/template.rb0000644000004100000410000000136312545467241023475 0ustar www-datawww-datamodule Fog module Compute class Ecloud class Template < Fog::Ecloud::Model identity :href attribute :name, :aliases => :Name attribute :type, :aliases => :Type attribute :other_links, :aliases => :Links attribute :operating_system, :aliases => :OperatingSystem attribute :description, :aliases => :Description attribute :storage, :aliases => :Storage attribute :network_adapters, :aliases => :NetworkAdapters attribute :customization, :aliases => :Customization attribute :licensed_software, :aliases => :LicensedSoftware def id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/nodes.rb0000644000004100000410000000201212545467241022762 0ustar www-datawww-datarequire File.expand_path("../node", __FILE__) module Fog module Compute class Ecloud class Nodes < Fog::Ecloud::Collection identity :href model Fog::Compute::Ecloud::Node def all data = service.get_nodes(href).body if data[:NodeServices] load(data[:NodeServices][:NodeService]) else load([]) end end def get(uri) data = service.get_node(uri).body new(data) rescue Fog::Errors::NotFound nil end def create(options) options[:uri] = "#{service.base_path}/nodeServices/internetServices/#{internet_service_id}/action/createNodeService" options[:protocol] ||= "TCP" options[:enabled] ||= true options[:description] ||= "" data = service.node_service_create(options).body object = new(data) end def internet_service_id href.scan(/\d+/)[0] end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud/models/networks.rb0000644000004100000410000000140712545467241023535 0ustar www-datawww-datarequire File.expand_path("../network", __FILE__) module Fog module Compute class Ecloud class Networks < Fog::Ecloud::Collection attribute :href, :aliases => :Href model Fog::Compute::Ecloud::Network def all body = service.get_networks(self.href).body body = body[:Networks] ? body[:Networks][:Network] : body[:Network] data = case body when NilClass then [] when Array then body when Hash then [body] end load(data) end def get(uri) if data = service.get_network(uri) new(data.body) end rescue Fog::Errors::NotFound nil end end end end end fog-ecloud-0.1.1/lib/fog/compute/ecloud.rb0000644000004100000410000010765512545467241020412 0ustar www-datawww-datarequire File.expand_path("../ecloud/models/model", __FILE__) require File.expand_path("../ecloud/models/collection", __FILE__) module Fog module Compute class Ecloud < Fog::Service API_URL = "https://services.enterprisecloud.terremark.com" attr_reader :authentication_method, :version #### Credentials # requires recognizes :ecloud_username, :ecloud_password, :ecloud_version, :ecloud_access_key, :ecloud_private_key, :ecloud_authentication_method, :base_path #### Models model_path "fog/compute/ecloud/models/" model :organization collection :organizations model :location collection :locations model :catalog_item collection :catalog model :catalog_configuration collection :catalog_configurations model :environment collection :environments model :task collection :tasks model :compute_pool collection :compute_pools model :server collection :servers model :virtual_machine_assigned_ip collection :virtual_machine_assigned_ips model :hardware_configuration collection :hardware_configurations model :server_configuration_option collection :server_configuration_options model :guest_process collection :guest_processes model :layout collection :layouts model :row collection :rows model :group collection :groups model :internet_service collection :internet_services model :node collection :nodes model :monitor collection :monitors model :cpu_usage_detail collection :cpu_usage_detail_summary model :memory_usage_detail collection :memory_usage_detail_summary model :storage_usage_detail collection :storage_usage_detail_summary model :operating_system_family collection :operating_system_families model :operating_system collection :operating_systems model :template collection :templates model :firewall_acl collection :firewall_acls model :network collection :networks model :ip_address collection :ip_addresses model :physical_device collection :physical_devices model :public_ip collection :public_ips model :trusted_network_group collection :trusted_network_groups model :backup_internet_service collection :backup_internet_services model :rnat collection :rnats model :association collection :associations model :tag collection :tags model :admin_organization collection :admin_organizations model :ssh_key collection :ssh_keys model :password_complexity_rule collection :password_complexity_rules model :authentication_level collection :authentication_levels model :login_banner collection :login_banners model :user collection :users model :role collection :roles model :ssh_key collection :ssh_keys model :support_ticket collection :support_tickets model :detached_disk collection :detached_disks #### Requests request_path "fog/compute/ecloud/requests/" request :backup_internet_service_create request :backup_internet_service_delete request :backup_internet_service_edit request :compute_pool_edit request :firewall_acls_create request :firewall_acls_delete request :get_admin_organization request :get_api_key request :get_api_keys request :get_association request :get_associations request :get_authentication_level request :get_authentication_levels request :get_backup_internet_service request :get_backup_internet_services request :get_catalog request :get_catalog_configuration request :get_catalog_configurations request :get_catalog_item request :get_compute_pool request :get_compute_pools request :get_cpu_usage_detail request :get_cpu_usage_detail_summary request :get_environment request :get_firewall_acl request :get_firewall_acls request :get_group request :get_groups request :get_guest_process request :get_guest_processes request :get_hardware_configuration request :get_internet_service request :get_internet_services request :get_ip_address request :get_layout request :get_layouts request :get_location request :get_locations request :get_login_banner request :get_login_banners request :get_memory_usage_detail request :get_memory_usage_detail_summary request :get_monitor request :get_monitors request :get_network request :get_network_summary request :get_networks request :get_node request :get_nodes request :get_operating_system request :get_operating_system_families request :get_organization request :get_organizations request :get_password_complexity_rule request :get_password_complexity_rules request :get_physical_device request :get_physical_devices request :get_public_ip request :get_public_ips request :get_rnat request :get_rnats request :get_role request :get_roles request :get_row request :get_rows request :get_server request :get_server_configuration_option request :get_server_configuration_options request :get_servers request :get_ssh_key request :get_ssh_keys request :get_storage_usage_detail request :get_storage_usage_detail_summary request :get_support_ticket request :get_support_tickets request :get_tag request :get_tags request :get_task request :get_tasks request :get_template request :get_templates request :get_trusted_network_group request :get_trusted_network_groups request :get_user request :get_users request :get_virtual_machine_assigned_ips request :get_detached_disks request :get_detached_disk request :groups_create request :groups_delete request :groups_edit request :groups_movedown request :groups_moveup request :internet_service_create request :internet_service_delete request :internet_service_edit request :monitors_create_default request :monitors_create_ecv request :monitors_create_http request :monitors_create_loopback request :monitors_create_ping request :monitors_disable request :monitors_edit_ecv request :monitors_edit_http request :monitors_edit_ping request :monitors_enable request :node_service_create request :node_service_delete request :node_service_edit request :power_off request :power_on request :power_reset request :power_shutdown request :public_ip_activate request :rnat_associations_create_device request :rnat_associations_delete request :rnat_associations_edit_network request :rows_create request :rows_delete request :rows_edit request :rows_movedown request :rows_moveup request :trusted_network_groups_create request :trusted_network_groups_delete request :trusted_network_groups_edit request :virtual_machine_edit_assigned_ips request :virtual_machine_copy request :virtual_machine_copy_identical request :virtual_machine_create_from_template request :virtual_machine_delete request :virtual_machine_edit request :virtual_machine_edit_hardware_configuration request :virtual_machine_import request :virtual_machine_upload_file request :virtual_machine_detach_disk request :virtual_machine_attach_disk module Shared attr_accessor :base_path attr_reader :versions_uri def validate_data(required_opts = [], options = {}) unless required_opts.all? { |opt| options.key?(opt) } raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(', ')}") end end def id_from_uri(uri) uri.match(/(\d+)$/)[1].to_i end def default_organization_uri "#{@base_path}/organizations" end end class Real include Shared class << self def basic_request(name, expects = [200], method = :get, headers = {}, body = "") define_method(name) do |uri| request( :expects => expects, :method => method, :headers => headers, :body => body, :parse => true, :uri => uri ) end end end def initialize(options = {}) @base_path = options[:base_path] || "/cloudapi/ecloud" @connections = {} @connection_options = options[:connection_options] || {} @host = options[:ecloud_host] || API_URL @persistent = options[:persistent] || false @version = options[:ecloud_version] || "2013-06-01" @authentication_method = options[:ecloud_authentication_method] || :cloud_api_auth @access_key = options[:ecloud_access_key] @private_key = options[:ecloud_private_key] if @private_key.nil? || @authentication_method == :basic_auth @authentication_method = :basic_auth @username = options[:ecloud_username] @password = options[:ecloud_password] if @username.nil? || @password.nil? raise ArgumentError, "No credentials (cloud auth, or basic auth) passed!" end else @hmac = Fog::HMAC.new("sha256", @private_key) end end def request(params) # Convert the uri to a URI if it's a string. if params[:uri].is_a?(String) params[:uri] = URI.parse(@host + params[:uri]) end host_url = "#{params[:uri].scheme}://#{params[:uri].host}#{params[:uri].port ? ':#{params[:uri].port}' : ''}" # Hash connections on the host_url ... There"s nothing to say we won"t get URI"s that go to # different hosts. @connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options) # Set headers to an empty hash if none are set. headers = set_extra_headers_for(params) || set_extra_headers_for({}) # Make the request options = { :expects => (params[:expects] || 200), :method => params[:method] || "GET", :path => params[:uri].path + "#{"?#{params[:uri].query}" if params[:uri].query}", :headers => headers } unless params[:body].nil? || params[:body].empty? options.merge!(:body => params[:body]) end response = @connections[host_url].request(options) # Parse the response body into a hash unless response.body.empty? if params[:parse] document = Fog::ToHashDocument.new parser = Nokogiri::XML::SAX::PushParser.new(document) parser << response.body parser.finish response.body = document.body end end response end private # if Authorization and x-tmrk-authorization are used, the x-tmrk-authorization takes precendence. def set_extra_headers_for(params) params[:headers] = { "x-tmrk-version" => @version, "Date" => Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S GMT"), }.merge(params[:headers] || {}) if params[:method] == "POST" || params[:method] == "PUT" params[:headers].merge!("Content-Type" => "application/xml") unless params[:headers]["Content-Type"] params[:headers].merge!("Accept" => "application/xml") end unless params[:body].nil? || params[:body].empty? params[:headers].merge!("x-tmrk-contenthash" => "Sha256 #{Base64.encode64(Digest::SHA2.digest(params[:body].to_s)).chomp}") end if @authentication_method == :basic_auth params[:headers].merge!("Authorization" => "Basic #{Base64.encode64(@username + ":" + @password).delete("\r\n")}") elsif @authentication_method == :cloud_api_auth signature = cloud_api_signature(params) params[:headers].merge!( "x-tmrk-authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"}, "Authorization" => %{CloudApi AccessKey="#{@access_key}" SignatureType="HmacSha256" Signature="#{signature}"} ) end params[:headers] end def cloud_api_signature(params) verb = params[:method].upcase headers = params[:headers] path = params[:uri].path canonicalized_headers = canonicalize_headers(headers) canonicalized_resource = canonicalize_resource(path) string = [ verb, headers["Content-Length"].to_s, headers["Content-Type"].to_s, headers["Date"].to_s, canonicalized_headers, canonicalized_resource + "\n" ].join("\n") Base64.encode64(@hmac.sign(string)).chomp end # section 5.6.3.2 in the ~1000 page pdf spec def canonicalize_headers(headers) tmp = headers.inject({}) do |ret, h| ret[h.first.downcase] = h.last if h.first.match(/^x-tmrk/i) ret end tmp.reject! { |k, _v| k == "x-tmrk-authorization" } tmp = tmp.sort.map { |e| "#{e.first}:#{e.last}" }.join("\n") tmp end # section 5.6.3.3 in the ~1000 page pdf spec def canonicalize_resource(path) uri, query_string = path.split("?") return uri if query_string.nil? query_string_pairs = query_string.split("&").sort.map { |e| e.split("=") } tm_query_string = query_string_pairs.map { |x| "#{x.first.downcase}:#{x.last}" }.join("\n") "#{uri.downcase}\n#{tm_query_string}\n" end end class Mock include Shared def self.data @data ||= Hash.new do |hash, key| hash[key] = begin compute_pool_id = Fog.credentials[:ecloud_compute_pool_id] || Fog::Mock.random_numbers(3).to_i environment_id = Fog.credentials[:ecloud_environment_id] || Fog::Mock.random_numbers(3).to_i public_ip_id = Fog.credentials[:ecloud_public_ip_id] || Fog::Mock.random_numbers(6).to_i internet_service_id = Fog::Mock.random_numbers(6).to_i node_service_id = Fog::Mock.random_numbers(6).to_i environment_name = Fog.credentials[:ecloud_environment_name] || Fog::Mock.random_letters(12) location_id = Fog::Mock.random_numbers(4).to_i network_id = Fog.credentials[:ecloud_network_id] || Fog::Mock.random_numbers(6).to_i network_ip = Fog::Ecloud.ip_address public_ip = Fog.credentials[:ecloud_public_ip_name] || Fog::Ecloud.ip_address ip_address_id = Fog::Ecloud.ip_address ip_address2_id = Fog::Ecloud.ip_address operating_system_id = Fog::Mock.random_numbers(7).to_i operating_system_family_id = Fog::Mock.random_numbers(7).to_i organization_id = Fog::Mock.random_numbers(7).to_i organization_name = Fog::Mock.random_letters(7) template_id = Fog.credentials[:ecloud_template_id] || Fog::Mock.random_numbers(7).to_i ssh_key_id = Fog.credentials[:ecloud_ssh_key_id] || Fog::Mock.random_numbers(4).to_i ssh_key_name = Fog.credentials[:ecloud_ssh_key_name] || "root" environment = { :id => environment_id, :href => "/cloudapi/ecloud/environments/#{environment_id}", :name => environment_name, :type => "application/vnd.tmrk.cloud.environment" } organization = { :href => "/cloudapi/ecloud/organizations/#{organization_id}", :type => "application/vnd.tmrk.cloud.organization", :name => organization_name, :Links => { :Link => [ Fog::Ecloud.keep(environment, :href, :name, :type), { :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}", :name => organization_name, :type => "application/vnd.tmrk.cloud.admin.organization", :rel => "alternate", }, { :href => "/cloudapi/ecloud/devicetags/organizations/#{organization_id}", :type => "application/vnd.tmrk.cloud.deviceTag; type=collection", :rel => "down", }, { :href => "/cloudapi/ecloud/alerts/organizations/#{organization_id}", :type => "application/vnd.tmrk.cloud.alertLog", :rel => "down", }, ], }, :Locations => { :Location => [ { :href => "/cloudapi/ecloud/locations/#{location_id}", :name => organization_name, :Catalog => { :href => "/cloudapi/ecloud/admin/catalog/organizations/#{organization_id}/locations/#{location_id}", :type => "application/vnd.tmrk.cloud.admin.catalogEntry; type=collection" }, :Environments => { :Environment => [environment] } } ] } } environment.merge!( :Links => { :Link => [Fog::Ecloud.keep(organization, :href, :name, :type)] } ) admin_organization = { :id => organization_id, :href => "/cloudapi/ecloud/admin/organizations/#{organization_id}", :type => "application/vnd.tmrk.cloud.admin.organization", :name => organization_name, :Links => { :Link => [ Fog::Ecloud.keep(organization, :href, :type, :name) ], }, :organization_id => organization_id, } compute_pool = { :id => compute_pool_id, :href => "/cloudapi/ecloud/computepools/#{compute_pool_id}", :name => Fog::Mock.random_letters(12), :type => "application/vnd.tmrk.cloud.computePool", :environment_id => environment_id, :Links => { :Link => [ Fog::Ecloud.keep(organization, :href, :name, :type), Fog::Ecloud.keep(environment, :href, :name, :type), ] } } public_ip = { :id => public_ip_id, :href => "/cloudapi/ecloud/publicips/#{public_ip_id}", :name => public_ip, :type => "application/vnd.tmrk.cloud.publicIp", :IpType => "none", :environment_id => environment_id, :Links => { :Link => [ Fog::Ecloud.keep(environment, :href, :name, :type), ], }, :InternetServices => { :InternetService => [ ], }, } internet_service = { :id => internet_service_id, :href => "/cloudapi/ecloud/internetservices/#{internet_service_id}", :name => Fog::Mock.random_letters(6), :type => "application/vnd.tmrk.cloud.internetService", :public_ip_id => public_ip_id, :Links => { :Link => [ Fog::Ecloud.keep(public_ip, :href, :name, :type), ], }, :NodeServices => { :NodeService => [ ] }, } node_service = { :id => node_service_id, :href => "/cloudapi/ecloud/nodeservices/#{node_service_id}", :name => Fog::Mock.random_letters(6), :type => "application/vnd.tmrk.cloud.nodeService", :internet_service_id => internet_service_id, :Links => { :Link => [ Fog::Ecloud.keep(internet_service, :href, :name, :type) ], }, } internet_service[:NodeServices][:NodeService].push(node_service) public_ip[:InternetServices][:InternetService].push(internet_service) network = { :id => network_id, :href => "/cloudapi/ecloud/networks/#{network_id}", :name => "#{network_ip}/#{Fog::Mock.random_numbers(2)}", :type => "application/vnd.tmrk.cloud.network", :Address => network_ip, :NetworkType => "Dmz", :BroadcastAddress => network_ip, :GatewayAddress => network_ip, :environment_id => environment_id, :Links => { :Link => [ Fog::Ecloud.keep(environment, :href, :name, :type), ] }, :IpAddresses => { :IpAddress => [], }, } ip_address = { :id => ip_address_id, :href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address_id}", :name => ip_address_id, :type => "application/vnd.tmrk.cloud.ipAddress", :network_id => network_id, :Links => { :Link => [Fog::Ecloud.keep(network, :href, :name, :type)] }, :Reserved => "false", :Host => nil, :DetectedOn => nil } ip_address2 = ip_address.dup.merge(:id => ip_address2_id, :href => "/cloudapi/ecloud/ipaddresses/networks/#{network_id}/#{ip_address2_id}", :name => ip_address2_id) network[:IpAddresses][:IpAddress].push(ip_address).push(ip_address2) short_name = "solaris10_64guest" operating_system = { :short_name => short_name, :compute_pool_id => compute_pool_id, :href => "/cloudapi/ecloud/operatingsystems/#{short_name}/computepools/#{compute_pool_id}", :name => "Sun Solaris 10 (64-bit)", :type => "application/vnd.tmrk.cloud.operatingSystem", :FamilyName => "Solaris", :Links => { :Link => Fog::Ecloud.keep(compute_pool, :href, :name, :type), }, :ConfigurationOptions => { :Processor => { :Minimum => "1", :Maximum => "8", :StepFactor => "1" }, :Memory => { :MinimumSize => { :Unit => "MB", :Value => "800" }, :MaximumSize => { :Unit => "MB", :Value => "16384" }, :StepFactor => { :Unit => "MB", :Value => "4" } }, :Disk => { :Minimum => "1", :Maximum => "15", :SystemDisk => { :ResourceCapacityRange => { :MinimumSize => { :Unit => "GB", :Value => "1" }, :MaximumSize => { :Unit => "GB", :Value => "512" }, :StepFactor => { :Unit => "GB", :Value => "1" } }, :MonthlyCost => "0" }, :DataDisk => { :ResourceCapacityRange => { :MinimumSize => { :Unit => "GB", :Value => "1" }, :MaximumSize => { :Unit => "GB", :Value => "512" }, :StepFactor => { :Unit => "GB", :Value => "1" } }, :MonthlyCost => "0" } }, :NetworkAdapter => { :Minimum => "1", :Maximum => "4", :StepFactor => "1" } } } template = { :id => template_id, :href => "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}", :type => "application/vnd.tmrk.cloud.template", :name => "Sun Solaris 10 (x64)", :compute_pool_id => compute_pool_id, :OperatingSystem => Fog::Ecloud.keep(operating_system, :href, :name, :type), :Memory => { :MinimumSize => { :Unit => "MB", :Value => "800" }, :MaximumSize => { :Unit => "MB", :Value => "16384" }, :StepFactor => { :Unit => "MB", :Value => "4" } }, :Storage => { :Size => { :Unit => "GB", :Value => "7" } }, :NetworkAdapters => "1", :Links => { :Link => [ Fog::Ecloud.keep(compute_pool, :href, :name, :type), ] } } operating_system_family = { :id => operating_system_family_id, :compute_pool_id => compute_pool_id, :OperatingSystemFamily => { :Name => "Linux", :OperatingSystems => { :OperatingSystem => [Fog::Ecloud.keep(operating_system, :href, :name, :type)], } }, :Links => { :Link => [ Fog::Ecloud.keep(compute_pool, :href, :name, :type), ] } } ssh_key = { :id => ssh_key_id, :href => "/cloudapi/ecloud/admin/sshKeys/#{ssh_key_id}", :name => ssh_key_name, :admin_organization_id => organization_id, :Links => { :Link => [ Fog::Ecloud.keep(admin_organization, :href, :name, :type), Fog::Ecloud.keep(organization, :href, :name, :type), ] }, :Default => "true", :FingerPrint => Fog::Ecloud.mac_address } layout = { :id => environment_id, :href => "/cloudapi/ecloud/layout/environments/#{environment_id}", :type => "application/vnd.tmrk.cloud.deviceLayout", :Links => { :Link => [ Fog::Ecloud.keep(environment, :name, :href, :type), ], }, :Rows => { :Row => [ ], }, :environment_id => environment_id } { :compute_pools => { compute_pool_id => compute_pool }, :environments => { environment_id => environment }, :public_ips => { public_ip_id => public_ip }, :internet_services => { internet_service_id => internet_service }, :node_services => { node_service_id => node_service }, :networks => { network_id => network }, :organizations => { organization_id => organization }, :admin_organizations => { organization_id => admin_organization }, :operating_systems => { operating_system_id => operating_system }, :operating_system_families => { operating_system_family_id => operating_system_family }, :servers => {}, :tasks => {}, :templates => { template_id => template }, :ssh_keys => { ssh_key_id => ssh_key }, :detached_disks => {}, :template_href => (Fog.credentials[:ecloud_template_href] || "/cloudapi/ecloud/templates/#{template_id}/computepools/#{compute_pool_id}"), :rows => {}, :groups => {}, :layouts => { environment_id => layout } } end end end def self.reset @data = nil end def initialize(options = {}) @base_path = "/cloudapi/ecloud" @ecloud_api_key = options[:ecloud] end def data self.class.data[@ecloud_api_key] end def reset_data self.class.data.delete(@ecloud_api_key) end def response(params = {}) body = params[:body] headers = { "Content-Type" => "application/xml" }.merge(params[:headers] || {}) status = params[:status] || 200 response = Excon::Response.new(:body => body, :headers => headers, :status => status) if params.key?(:expects) && ![*params[:expects]].include?(response.status) raise(Excon::Errors.status_error(params, response)) else response end end def deep_copy(o) Marshal.load(Marshal.dump(o)) end end end end end fog-ecloud-0.1.1/gemfiles/0000755000004100000410000000000012545467241015372 5ustar www-datawww-datafog-ecloud-0.1.1/gemfiles/Gemfile.1.9.2-0000644000004100000410000000021012545467241017401 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-ecloud-0.1.1/gemfiles/Gemfile.1.9.3+0000644000004100000410000000016712545467241017413 0ustar www-datawww-datasource :rubygems gem 'activesupport', '>= 3.0', '< 4' gem 'mime-types', '< 2.0' gem 'fog-core' gemspec :path => '../'fog-ecloud-0.1.1/.rubocop.yml0000644000004100000410000000060512545467241016052 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 Style/ExtraSpacing: Enabled: false Metrics/AbcSize: Enabled: false fog-ecloud-0.1.1/metadata.yml0000644000004100000410000004411412545467241016106 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: fog-ecloud version: !ruby/object:Gem::Version version: 0.1.1 platform: ruby authors: - Paulo Henrique Lopes Ribeiro autorequire: bindir: bin cert_chain: [] date: 2015-04-06 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: 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: 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: 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 Terremark EnterpriseCloud 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-ecloud.gemspec - gemfiles/Gemfile.1.9.2- - gemfiles/Gemfile.1.9.3+ - lib/fog/bin/ecloud.rb - lib/fog/compute/ecloud.rb - lib/fog/compute/ecloud/models/admin_organization.rb - lib/fog/compute/ecloud/models/admin_organizations.rb - lib/fog/compute/ecloud/models/api_key.rb - lib/fog/compute/ecloud/models/api_keys.rb - lib/fog/compute/ecloud/models/association.rb - lib/fog/compute/ecloud/models/associations.rb - lib/fog/compute/ecloud/models/authentication_level.rb - lib/fog/compute/ecloud/models/authentication_levels.rb - lib/fog/compute/ecloud/models/backup_internet_service.rb - lib/fog/compute/ecloud/models/backup_internet_services.rb - lib/fog/compute/ecloud/models/catalog.rb - lib/fog/compute/ecloud/models/catalog_configuration.rb - lib/fog/compute/ecloud/models/catalog_configurations.rb - lib/fog/compute/ecloud/models/catalog_item.rb - lib/fog/compute/ecloud/models/collection.rb - lib/fog/compute/ecloud/models/compute_pool.rb - lib/fog/compute/ecloud/models/compute_pools.rb - lib/fog/compute/ecloud/models/cpu_usage_detail.rb - lib/fog/compute/ecloud/models/cpu_usage_detail_summary.rb - lib/fog/compute/ecloud/models/detached_disk.rb - lib/fog/compute/ecloud/models/detached_disks.rb - lib/fog/compute/ecloud/models/environment.rb - lib/fog/compute/ecloud/models/environments.rb - lib/fog/compute/ecloud/models/firewall_acl.rb - lib/fog/compute/ecloud/models/firewall_acls.rb - lib/fog/compute/ecloud/models/group.rb - lib/fog/compute/ecloud/models/groups.rb - lib/fog/compute/ecloud/models/guest_process.rb - lib/fog/compute/ecloud/models/guest_processes.rb - lib/fog/compute/ecloud/models/hardware_configuration.rb - lib/fog/compute/ecloud/models/hardware_configurations.rb - lib/fog/compute/ecloud/models/internet_service.rb - lib/fog/compute/ecloud/models/internet_services.rb - lib/fog/compute/ecloud/models/ip_address.rb - lib/fog/compute/ecloud/models/ip_addresses.rb - lib/fog/compute/ecloud/models/layout.rb - lib/fog/compute/ecloud/models/layouts.rb - lib/fog/compute/ecloud/models/location.rb - lib/fog/compute/ecloud/models/locations.rb - lib/fog/compute/ecloud/models/login_banner.rb - lib/fog/compute/ecloud/models/login_banners.rb - lib/fog/compute/ecloud/models/memory_usage_detail.rb - lib/fog/compute/ecloud/models/memory_usage_detail_summary.rb - lib/fog/compute/ecloud/models/model.rb - lib/fog/compute/ecloud/models/monitor.rb - lib/fog/compute/ecloud/models/monitors.rb - lib/fog/compute/ecloud/models/network.rb - lib/fog/compute/ecloud/models/networks.rb - lib/fog/compute/ecloud/models/node.rb - lib/fog/compute/ecloud/models/nodes.rb - lib/fog/compute/ecloud/models/operating_system.rb - lib/fog/compute/ecloud/models/operating_system_families.rb - lib/fog/compute/ecloud/models/operating_system_family.rb - lib/fog/compute/ecloud/models/operating_systems.rb - lib/fog/compute/ecloud/models/organization.rb - lib/fog/compute/ecloud/models/organizations.rb - lib/fog/compute/ecloud/models/password_complexity_rule.rb - lib/fog/compute/ecloud/models/password_complexity_rules.rb - lib/fog/compute/ecloud/models/physical_device.rb - lib/fog/compute/ecloud/models/physical_devices.rb - lib/fog/compute/ecloud/models/public_ip.rb - lib/fog/compute/ecloud/models/public_ips.rb - lib/fog/compute/ecloud/models/rnat.rb - lib/fog/compute/ecloud/models/rnats.rb - lib/fog/compute/ecloud/models/role.rb - lib/fog/compute/ecloud/models/roles.rb - lib/fog/compute/ecloud/models/row.rb - lib/fog/compute/ecloud/models/rows.rb - lib/fog/compute/ecloud/models/server.rb - lib/fog/compute/ecloud/models/server_configuration_option.rb - lib/fog/compute/ecloud/models/server_configuration_options.rb - lib/fog/compute/ecloud/models/servers.rb - lib/fog/compute/ecloud/models/ssh_key.rb - lib/fog/compute/ecloud/models/ssh_keys.rb - lib/fog/compute/ecloud/models/storage_usage_detail.rb - lib/fog/compute/ecloud/models/storage_usage_detail_summary.rb - lib/fog/compute/ecloud/models/support_ticket.rb - lib/fog/compute/ecloud/models/support_tickets.rb - lib/fog/compute/ecloud/models/tag.rb - lib/fog/compute/ecloud/models/tags.rb - lib/fog/compute/ecloud/models/task.rb - lib/fog/compute/ecloud/models/tasks.rb - lib/fog/compute/ecloud/models/template.rb - lib/fog/compute/ecloud/models/templates.rb - lib/fog/compute/ecloud/models/trusted_network_group.rb - lib/fog/compute/ecloud/models/trusted_network_groups.rb - lib/fog/compute/ecloud/models/user.rb - lib/fog/compute/ecloud/models/users.rb - lib/fog/compute/ecloud/models/virtual_machine_assigned_ip.rb - lib/fog/compute/ecloud/models/virtual_machine_assigned_ips.rb - lib/fog/compute/ecloud/requests/admin_disable_support_access.rb - lib/fog/compute/ecloud/requests/admin_edit_authentication_levels.rb - lib/fog/compute/ecloud/requests/admin_edit_login_banner.rb - lib/fog/compute/ecloud/requests/admin_edit_password_complexity_rules.rb - lib/fog/compute/ecloud/requests/admin_enable_support_access.rb - lib/fog/compute/ecloud/requests/backup_internet_service_create.rb - lib/fog/compute/ecloud/requests/backup_internet_service_delete.rb - lib/fog/compute/ecloud/requests/backup_internet_service_edit.rb - lib/fog/compute/ecloud/requests/compute_pool_edit.rb - lib/fog/compute/ecloud/requests/firewall_acls_create.rb - lib/fog/compute/ecloud/requests/firewall_acls_delete.rb - lib/fog/compute/ecloud/requests/get_admin_organization.rb - lib/fog/compute/ecloud/requests/get_api_key.rb - lib/fog/compute/ecloud/requests/get_api_keys.rb - lib/fog/compute/ecloud/requests/get_association.rb - lib/fog/compute/ecloud/requests/get_associations.rb - lib/fog/compute/ecloud/requests/get_authentication_level.rb - lib/fog/compute/ecloud/requests/get_authentication_levels.rb - lib/fog/compute/ecloud/requests/get_backup_internet_service.rb - lib/fog/compute/ecloud/requests/get_backup_internet_services.rb - lib/fog/compute/ecloud/requests/get_catalog.rb - lib/fog/compute/ecloud/requests/get_catalog_configuration.rb - lib/fog/compute/ecloud/requests/get_catalog_configurations.rb - lib/fog/compute/ecloud/requests/get_catalog_item.rb - lib/fog/compute/ecloud/requests/get_compute_pool.rb - lib/fog/compute/ecloud/requests/get_compute_pools.rb - lib/fog/compute/ecloud/requests/get_cpu_usage_detail.rb - lib/fog/compute/ecloud/requests/get_cpu_usage_detail_summary.rb - lib/fog/compute/ecloud/requests/get_detached_disk.rb - lib/fog/compute/ecloud/requests/get_detached_disks.rb - lib/fog/compute/ecloud/requests/get_environment.rb - lib/fog/compute/ecloud/requests/get_environments.rb - lib/fog/compute/ecloud/requests/get_firewall_acl.rb - lib/fog/compute/ecloud/requests/get_firewall_acls.rb - lib/fog/compute/ecloud/requests/get_group.rb - lib/fog/compute/ecloud/requests/get_groups.rb - lib/fog/compute/ecloud/requests/get_guest_process.rb - lib/fog/compute/ecloud/requests/get_guest_processes.rb - lib/fog/compute/ecloud/requests/get_hardware_configuration.rb - lib/fog/compute/ecloud/requests/get_hardware_configurations.rb - lib/fog/compute/ecloud/requests/get_internet_service.rb - lib/fog/compute/ecloud/requests/get_internet_services.rb - lib/fog/compute/ecloud/requests/get_ip_address.rb - lib/fog/compute/ecloud/requests/get_layout.rb - lib/fog/compute/ecloud/requests/get_layouts.rb - lib/fog/compute/ecloud/requests/get_location.rb - lib/fog/compute/ecloud/requests/get_locations.rb - lib/fog/compute/ecloud/requests/get_login_banner.rb - lib/fog/compute/ecloud/requests/get_login_banners.rb - lib/fog/compute/ecloud/requests/get_memory_usage_detail.rb - lib/fog/compute/ecloud/requests/get_memory_usage_detail_summary.rb - lib/fog/compute/ecloud/requests/get_monitor.rb - lib/fog/compute/ecloud/requests/get_monitors.rb - lib/fog/compute/ecloud/requests/get_network.rb - lib/fog/compute/ecloud/requests/get_network_summary.rb - lib/fog/compute/ecloud/requests/get_networks.rb - lib/fog/compute/ecloud/requests/get_node.rb - lib/fog/compute/ecloud/requests/get_nodes.rb - lib/fog/compute/ecloud/requests/get_operating_system.rb - lib/fog/compute/ecloud/requests/get_operating_system_families.rb - lib/fog/compute/ecloud/requests/get_organization.rb - lib/fog/compute/ecloud/requests/get_organizations.rb - lib/fog/compute/ecloud/requests/get_password_complexity_rule.rb - lib/fog/compute/ecloud/requests/get_password_complexity_rules.rb - lib/fog/compute/ecloud/requests/get_physical_device.rb - lib/fog/compute/ecloud/requests/get_physical_devices.rb - lib/fog/compute/ecloud/requests/get_process.rb - lib/fog/compute/ecloud/requests/get_processes.rb - lib/fog/compute/ecloud/requests/get_public_ip.rb - lib/fog/compute/ecloud/requests/get_public_ips.rb - lib/fog/compute/ecloud/requests/get_rnat.rb - lib/fog/compute/ecloud/requests/get_rnats.rb - lib/fog/compute/ecloud/requests/get_role.rb - lib/fog/compute/ecloud/requests/get_roles.rb - lib/fog/compute/ecloud/requests/get_row.rb - lib/fog/compute/ecloud/requests/get_rows.rb - lib/fog/compute/ecloud/requests/get_server.rb - lib/fog/compute/ecloud/requests/get_server_configuration_option.rb - lib/fog/compute/ecloud/requests/get_server_configuration_options.rb - lib/fog/compute/ecloud/requests/get_servers.rb - lib/fog/compute/ecloud/requests/get_ssh_key.rb - lib/fog/compute/ecloud/requests/get_ssh_keys.rb - lib/fog/compute/ecloud/requests/get_storage_usage_detail.rb - lib/fog/compute/ecloud/requests/get_storage_usage_detail_summary.rb - lib/fog/compute/ecloud/requests/get_support_ticket.rb - lib/fog/compute/ecloud/requests/get_support_tickets.rb - lib/fog/compute/ecloud/requests/get_tag.rb - lib/fog/compute/ecloud/requests/get_tags.rb - lib/fog/compute/ecloud/requests/get_task.rb - lib/fog/compute/ecloud/requests/get_tasks.rb - lib/fog/compute/ecloud/requests/get_template.rb - lib/fog/compute/ecloud/requests/get_templates.rb - lib/fog/compute/ecloud/requests/get_trusted_network_group.rb - lib/fog/compute/ecloud/requests/get_trusted_network_groups.rb - lib/fog/compute/ecloud/requests/get_user.rb - lib/fog/compute/ecloud/requests/get_users.rb - lib/fog/compute/ecloud/requests/get_virtual_machine_assigned_ips.rb - lib/fog/compute/ecloud/requests/groups_create.rb - lib/fog/compute/ecloud/requests/groups_delete.rb - lib/fog/compute/ecloud/requests/groups_edit.rb - lib/fog/compute/ecloud/requests/groups_movedown.rb - lib/fog/compute/ecloud/requests/groups_moveup.rb - lib/fog/compute/ecloud/requests/internet_service_create.rb - lib/fog/compute/ecloud/requests/internet_service_delete.rb - lib/fog/compute/ecloud/requests/internet_service_edit.rb - lib/fog/compute/ecloud/requests/monitors_create_default.rb - lib/fog/compute/ecloud/requests/monitors_create_ecv.rb - lib/fog/compute/ecloud/requests/monitors_create_http.rb - lib/fog/compute/ecloud/requests/monitors_create_loopback.rb - lib/fog/compute/ecloud/requests/monitors_create_ping.rb - lib/fog/compute/ecloud/requests/monitors_disable.rb - lib/fog/compute/ecloud/requests/monitors_edit_ecv.rb - lib/fog/compute/ecloud/requests/monitors_edit_http.rb - lib/fog/compute/ecloud/requests/monitors_edit_ping.rb - lib/fog/compute/ecloud/requests/monitors_enable.rb - lib/fog/compute/ecloud/requests/node_service_create.rb - lib/fog/compute/ecloud/requests/node_service_delete.rb - lib/fog/compute/ecloud/requests/node_service_edit.rb - lib/fog/compute/ecloud/requests/power_off.rb - lib/fog/compute/ecloud/requests/power_on.rb - lib/fog/compute/ecloud/requests/power_reset.rb - lib/fog/compute/ecloud/requests/power_shutdown.rb - lib/fog/compute/ecloud/requests/public_ip_activate.rb - lib/fog/compute/ecloud/requests/rnat_associations_create_device.rb - lib/fog/compute/ecloud/requests/rnat_associations_delete.rb - lib/fog/compute/ecloud/requests/rnat_associations_edit_network.rb - lib/fog/compute/ecloud/requests/rows_create.rb - lib/fog/compute/ecloud/requests/rows_delete.rb - lib/fog/compute/ecloud/requests/rows_edit.rb - lib/fog/compute/ecloud/requests/rows_movedown.rb - lib/fog/compute/ecloud/requests/rows_moveup.rb - lib/fog/compute/ecloud/requests/trusted_network_groups_create.rb - lib/fog/compute/ecloud/requests/trusted_network_groups_delete.rb - lib/fog/compute/ecloud/requests/trusted_network_groups_edit.rb - lib/fog/compute/ecloud/requests/virtual_machine_attach_disk.rb - lib/fog/compute/ecloud/requests/virtual_machine_copy.rb - lib/fog/compute/ecloud/requests/virtual_machine_copy_identical.rb - lib/fog/compute/ecloud/requests/virtual_machine_create_from_template.rb - lib/fog/compute/ecloud/requests/virtual_machine_delete.rb - lib/fog/compute/ecloud/requests/virtual_machine_detach_disk.rb - lib/fog/compute/ecloud/requests/virtual_machine_edit.rb - lib/fog/compute/ecloud/requests/virtual_machine_edit_assigned_ips.rb - lib/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb - lib/fog/compute/ecloud/requests/virtual_machine_import.rb - lib/fog/compute/ecloud/requests/virtual_machine_upload_file.rb - lib/fog/ecloud.rb - lib/fog/ecloud/compute.rb - lib/fog/ecloud/ipaddr.rb - lib/fog/ecloud/mock_data_classes.rb - lib/fog/ecloud/version.rb - spec/minitest_helper.rb - tests/compute/helper.rb - tests/compute/models/admin_organization_tests.rb - tests/compute/models/compute_pool_tests.rb - tests/compute/models/detached_disk_tests.rb - tests/compute/models/environment_tests.rb - tests/compute/models/internet_service_tests.rb - tests/compute/models/ip_address_tests.rb - tests/compute/models/network_tests.rb - tests/compute/models/operating_system_families_tests.rb - tests/compute/models/operating_system_tests.rb - tests/compute/models/organization_tests.rb - tests/compute/models/public_ip_tests.rb - tests/compute/models/server_tests.rb - tests/compute/models/ssh_key_tests.rb - tests/compute/models/template_tests.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 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.3 signing_key: specification_version: 4 summary: Module for the 'fog' gem to support Terremark EnterpriseCloud. test_files: - spec/minitest_helper.rb fog-ecloud-0.1.1/.gitignore0000644000004100000410000000031012545467241015561 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-ecloud-0.1.1/CONTRIBUTING.md0000644000004100000410000000154112545467241016031 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-ecloud/pulls). * Review open [issues](https://github.com/fog/fog-ecloud/issues) for things to help on. * [Create an issue](https://github.com/fog/fog-ecloud/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-ecloud` to ensure everything is up to date. * [Submit a pull request](https://github.com/fog/fog-ecloud/compare/) ### Non-Coding * Offer feedback on open [issues](https://github.com/fog/fog-ecloud/issues). * Organize or volunteer at events.fog-ecloud-0.1.1/.ruby-gemset0000644000004100000410000000001212545467241016034 0ustar www-datawww-datafog-ecloudfog-ecloud-0.1.1/README.md0000644000004100000410000000240212545467241015054 0ustar www-datawww-data# Fog::Ecloud ![Gem Version](https://badge.fury.io/rb/fog-ecloud.svg) [![Build Status](https://travis-ci.org/fog/fog-ecloud.svg?branch=master)](https://travis-ci.org/fog/fog-ecloud) [![Dependency Status](https://gemnasium.com/fog/fog-ecloud.svg)](https://gemnasium.com/fog/fog-ecloud) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-ecloud.svg)](https://coveralls.io/r/fog/fog-ecloud?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-ecloud.png)](https://codeclimate.com/github/fog/fog-ecloud) Module for the 'fog' gem to support Terremark EnterpriseCloud ## 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-ecloud' ``` And then execute: $ bundle Or install it yourself as: $ gem install fog-ecloud ## Usage TODO: Write usage instructions here ## Contributing 1. Fork it ( https://github.com/fog/fog-ecloud/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