From 15eb069195f67978c70b219f87c95886201a0f3b Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Thu, 28 Feb 2013 17:46:54 +0530 Subject: [PATCH 01/68] Use strict base encoding otherwise breaks for very large org names. --- lib/fog/vcloud/compute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb index 168c60eec..edaa58960 100644 --- a/lib/fog/vcloud/compute.rb +++ b/lib/fog/vcloud/compute.rb @@ -300,7 +300,7 @@ module Fog # Use this to set the Authorization header for login def authorization_header - "Basic #{Base64.encode64("#{@username}:#{@password}").chomp!}" + "Basic #{Base64.strict_encode64("#{@username}:#{@password}")}" end # Actually do the request From de29bfcee8bec547f88b0fb2b9f93c20b3b54016 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Thu, 28 Feb 2013 18:07:02 +0530 Subject: [PATCH 02/68] revert typo --- lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb b/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb index 5023deabd..86de2ec81 100644 --- a/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb +++ b/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb @@ -71,7 +71,7 @@ module Fog include Shared def instantiate_vapp_template options = {} - validate_instantiate_vapp_template_options optionsgi + validate_instantiate_vapp_template_options options request( :body => generate_instantiate_vapp_template_request(options), :expects => 201, From 2a2ea3588666c195ae67bb0cd590f3955672e537 Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Thu, 28 Feb 2013 08:46:57 -0600 Subject: [PATCH 03/68] [rackspace|compute_v2] compute_v2 tests were failing because the flavor used in the tests was too small for the image selected. I updating tests to use the an Ubuntu image in hopes of making the tests less brittle. --- lib/fog/rackspace/mock_data.rb | 1 + tests/rackspace/helper.rb | 9 +++++++++ tests/rackspace/models/compute_v2/image_tests.rb | 6 ++---- tests/rackspace/models/compute_v2/metadata_tests.rb | 8 +++++--- tests/rackspace/models/compute_v2/server_tests.rb | 10 +++------- tests/rackspace/models/compute_v2/servers_tests.rb | 12 +++++------- tests/rackspace/requests/compute_v2/image_tests.rb | 8 ++++---- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/fog/rackspace/mock_data.rb b/lib/fog/rackspace/mock_data.rb index 008e180f4..a1d4986ca 100644 --- a/lib/fog/rackspace/mock_data.rb +++ b/lib/fog/rackspace/mock_data.rb @@ -38,6 +38,7 @@ module Fog "OS-DCF:diskConfig" => "AUTO", "created" => "2012-02-28T19:38:57Z", "id" => image_id, + "name" => "Ubuntu", "links" => [ { "href" => "https://dfw.servers.api.rackspacecloud.com/v2/010101/images/#{image_id}", diff --git a/tests/rackspace/helper.rb b/tests/rackspace/helper.rb index 7f095df6a..054d0f3a3 100644 --- a/tests/rackspace/helper.rb +++ b/tests/rackspace/helper.rb @@ -36,5 +36,14 @@ module Shindo sleep 30 unless Fog.mocking? end + def rackspace_test_image_id(service) + # I chose to use the first Ubuntu because it will work with the smallest flavor and it doesn't require a license + @image_id ||= Fog.credentials[:rackspace_image_id] || service.images.find {|img| img.name =~ /Ubuntu/ }.id + end + + def rackspace_test_flavor_id(service) + @flavor_id ||= Fog.credentials[:rackspace_flavor_id] || service.flavors.first.id + end + end end diff --git a/tests/rackspace/models/compute_v2/image_tests.rb b/tests/rackspace/models/compute_v2/image_tests.rb index d0791a01f..b36e80610 100644 --- a/tests/rackspace/models/compute_v2/image_tests.rb +++ b/tests/rackspace/models/compute_v2/image_tests.rb @@ -1,13 +1,11 @@ Shindo.tests('Fog::Compute::RackspaceV2 | image', ['rackspace']) do service = Fog::Compute::RackspaceV2.new - flavor_id = Fog.credentials[:rackspace_flavor_id] || service.flavors.first.id - image_id = Fog.credentials[:rackspace_image_id] || service.images.first.id test_time = Time.now.to_i.to_s options = { :name => "fog_server_#{test_time}", - :flavor_id => flavor_id, - :image_id => image_id + :flavor_id => rackspace_test_flavor_id(service), + :image_id => rackspace_test_image_id(service) } tests("success") do diff --git a/tests/rackspace/models/compute_v2/metadata_tests.rb b/tests/rackspace/models/compute_v2/metadata_tests.rb index 9b6c4c1de..d4a0f9018 100644 --- a/tests/rackspace/models/compute_v2/metadata_tests.rb +++ b/tests/rackspace/models/compute_v2/metadata_tests.rb @@ -7,7 +7,10 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do tests('success') do begin - @server = service.servers.create(:name => "fog_server_#{test_time}", :flavor_id => 2, :image_id => "3afe97b2-26dc-49c5-a2cc-a2fc8d80c001") + @server = service.servers.create(:name => "fog_server_#{test_time}", + :flavor_id => rackspace_test_flavor_id(service), + :image_id => rackspace_test_image_id(service)) + @server.wait_for(timeout=1500) { ready? } tests('server') do @@ -17,8 +20,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | metadata', ['rackspace']) do end tests('image') do - image_id = @server.create_image("fog_image_#{test_time}", :metadata => {:my_key => 'my_value'}) - @image = service.images.get image_id + @image = @server.create_image("fog_image_#{test_time}", :metadata => {:my_key => 'my_value'}) @image.wait_for(timeout = 1500) { ready? } tests("#all").succeeds do pending if Fog.mocking? && !mocks_implemented diff --git a/tests/rackspace/models/compute_v2/server_tests.rb b/tests/rackspace/models/compute_v2/server_tests.rb index 0e297cff6..f8657d32e 100644 --- a/tests/rackspace/models/compute_v2/server_tests.rb +++ b/tests/rackspace/models/compute_v2/server_tests.rb @@ -2,14 +2,10 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do service = Fog::Compute::RackspaceV2.new cbs_service = Fog::Rackspace::BlockStorage.new - flavor_id = Fog.credentials[:rackspace_flavor_id] || service.flavors.first.id - image_id = Fog.credentials[:rackspace_image_id] || service.images.first.id - image_id ||= Fog.mocking? ? service.images.first.id : service.images.find {|image| image.name =~ /Ubuntu/}.id # use the first Ubuntu image - options = { :name => "fog_server_#{Time.now.to_i.to_s}", - :flavor_id => flavor_id, - :image_id => image_id, + :flavor_id => rackspace_test_flavor_id(service), + :image_id => rackspace_test_image_id(service), :metadata => { 'fog_test' => 'true' } } @@ -59,7 +55,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do @instance.wait_for(timeout=1500) { ready? } sleep 60 unless Fog.mocking? tests('#rebuild').succeeds do - @instance.rebuild(image_id) + @instance.rebuild rackspace_test_image_id(service) returns('REBUILD') { @instance.state } end diff --git a/tests/rackspace/models/compute_v2/servers_tests.rb b/tests/rackspace/models/compute_v2/servers_tests.rb index 7831f24a1..53edb2635 100644 --- a/tests/rackspace/models/compute_v2/servers_tests.rb +++ b/tests/rackspace/models/compute_v2/servers_tests.rb @@ -1,20 +1,18 @@ Shindo.tests('Fog::Compute::RackspaceV2 | servers', ['rackspace']) do - connection = Fog::Compute::RackspaceV2.new - flavor_id = Fog.credentials[:rackspace_flavor_id] || connection.flavors.first.id - image_id = Fog.credentials[:rackspace_image_id] || connection.images.first.id + service = Fog::Compute::RackspaceV2.new options = { :name => "fog_server_#{Time.now.to_i.to_s}", - :flavor_id => flavor_id, - :image_id => image_id + :flavor_id => rackspace_test_flavor_id(service), + :image_id => rackspace_test_image_id(service) } - collection_tests(connection.servers, options, true) do + collection_tests(service.servers, options, true) do @instance.wait_for { ready? } end tests("#bootstrap").succeeds do pending if Fog.mocking? - @server = connection.servers.bootstrap(options) + @server = service.servers.bootstrap(options) end if @server diff --git a/tests/rackspace/requests/compute_v2/image_tests.rb b/tests/rackspace/requests/compute_v2/image_tests.rb index 4fe6ec5d2..1bdba2013 100644 --- a/tests/rackspace/requests/compute_v2/image_tests.rb +++ b/tests/rackspace/requests/compute_v2/image_tests.rb @@ -1,8 +1,6 @@ Shindo.tests('Fog::Compute::RackspaceV2 | image_tests', ['rackspace']) do service = Fog::Compute.new(:provider => 'Rackspace', :version => 'V2') - flavor_id = Fog.credentials[:rackspace_flavor_id] || service.flavors.first.id - image_id = Fog.credentials[:rackspace_image_id] || service.images.first.id - + image_format = { 'id' => String, 'name' => String, @@ -33,7 +31,9 @@ Shindo.tests('Fog::Compute::RackspaceV2 | image_tests', ['rackspace']) do begin test_time = Time.now.to_i.to_s - @server = service.servers.create(:name => "fog-image-tests_#{test_time}", :flavor_id => flavor_id, :image_id => image_id) + @server = service.servers.create(:name => "fog-image-tests_#{test_time}", + :flavor_id => rackspace_test_flavor_id(service), + :image_id => rackspace_test_image_id(service)) @server.wait_for { ready? } @image_id = nil From 6356018af03839364dfc7f032421a2323a67c234 Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Thu, 28 Feb 2013 09:02:05 -0600 Subject: [PATCH 04/68] [rackspace|storage] added the ability to determine meta prefixes from Class objects as well as Fog object. This addresses issue in Files#get method. --- lib/fog/rackspace/models/storage/files.rb | 2 +- lib/fog/rackspace/models/storage/metadata.rb | 35 ++++++++++---- .../models/storage/metadata_tests.rb | 47 +++++++++++++++++++ 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/lib/fog/rackspace/models/storage/files.rb b/lib/fog/rackspace/models/storage/files.rb index 560731c74..4c875d1cf 100644 --- a/lib/fog/rackspace/models/storage/files.rb +++ b/lib/fog/rackspace/models/storage/files.rb @@ -55,7 +55,7 @@ module Fog def get(key, &block) requires :directory data = service.get_object(directory.key, key, &block) - metadata = Metadata.from_headers(data.headers) + metadata = Metadata.from_headers(self, data.headers) file_data = data.headers.merge({ :body => data.body, :key => key, diff --git a/lib/fog/rackspace/models/storage/metadata.rb b/lib/fog/rackspace/models/storage/metadata.rb index b6b97d9ae..f6b06eeee 100644 --- a/lib/fog/rackspace/models/storage/metadata.rb +++ b/lib/fog/rackspace/models/storage/metadata.rb @@ -1,3 +1,8 @@ +require 'fog/rackspace/models/storage/directory' +require 'fog/rackspace/models/storage/file' +require 'fog/rackspace/models/storage/directories' +require 'fog/rackspace/models/storage/files' + module Fog module Storage class Rackspace @@ -60,33 +65,45 @@ module Fog private + def directory? + [Fog::Storage::Rackspace::Directory, Fog::Storage::Rackspace::Directories].include? parent_class + end + + def file? + [Fog::Storage::Rackspace::File, Fog::Storage::Rackspace::Files].include? parent_class + end + + def parent_class + parent.is_a?(Class) ? parent : parent.class + end + def meta_prefix - if parent.is_a? Fog::Storage::Rackspace::Directory + if directory? CONTAINER_META_PREFIX - elsif parent.is_a? Fog::Storage::Rackspace::File + elsif file? OBJECT_META_PREFIX else - raise "Metadata prefix is unknown for #{parent.class}" + raise "Metadata prefix is unknown for #{parent_class}" end end def remove_meta_prefix - if parent.is_a? Fog::Storage::Rackspace::Directory + if directory? CONTAINER_REMOVE_META_PREFIX - elsif parent.is_a? Fog::Storage::Rackspace::File + elsif file? OBJECT_REMOVE_META_PREFIX else - raise "Remove Metadata prefix is unknown for #{parent.class}" + raise "Remove Metadata prefix is unknown for #{parent_class}" end end def meta_prefix_regex - if parent.is_a? Fog::Storage::Rackspace::Directory + if directory? CONTAINER_KEY_REGEX - elsif parent.is_a? Fog::Storage::Rackspace::File + elsif file? OBJECT_KEY_REGEX else - raise "Metadata prefix is unknown for #{parent.class}" + raise "Metadata prefix is unknown for #{parent_class}" end end diff --git a/tests/rackspace/models/storage/metadata_tests.rb b/tests/rackspace/models/storage/metadata_tests.rb index 73e2cbe0d..492bcbf27 100644 --- a/tests/rackspace/models/storage/metadata_tests.rb +++ b/tests/rackspace/models/storage/metadata_tests.rb @@ -2,7 +2,19 @@ require 'fog/rackspace/models/storage/metadata' require 'fog/rackspace/models/storage/directory' require 'fog/rackspace/models/storage/file' + Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do + + def assert_directory(obj, assert_value) + metadata = Fog::Storage::Rackspace::Metadata.new obj + returns(assert_value) { metadata.send :directory? } + end + + def assert_file(obj, assert_value) + metadata = Fog::Storage::Rackspace::Metadata.new obj + returns(assert_value) { metadata.send :file? } + end + tests('Directory') do @directory = Fog::Storage::Rackspace::Directory.new tests('#to_key') do @@ -124,4 +136,39 @@ Shindo.tests('Fog::Rackspace::Storage | metadata', ['rackspace']) do metadata[:test] = true metadata[:test] end + + tests('#directory?') do + assert_directory Fog::Storage::Rackspace::Directories, true + assert_directory Fog::Storage::Rackspace::Directory, true + assert_directory Fog::Storage::Rackspace::Directory.new, true + + assert_directory nil, false + assert_directory Fog::Storage::Rackspace::Files, false + assert_directory Fog::Storage::Rackspace::File, false + assert_directory Fog::Storage::Rackspace::File.new, false + assert_directory "I am a string!", false + end + + tests('#file?') do + assert_file Fog::Storage::Rackspace::Directories, false + assert_file Fog::Storage::Rackspace::Directory, false + assert_file Fog::Storage::Rackspace::Directory.new, false + + assert_file nil, false + assert_file Fog::Storage::Rackspace::Files, true + assert_file Fog::Storage::Rackspace::File, true + assert_file Fog::Storage::Rackspace::File.new, true + assert_file "I am a string!", false + end + + tests('#parent_class') do + tests('Fog::Storage::Rackspace::Directory object') do + metadata = Fog::Storage::Rackspace::Metadata.new Fog::Storage::Rackspace::Directory.new + returns(Fog::Storage::Rackspace::Directory) { metadata.send :parent_class } + end + tests('Fog::Storage::Rackspace::Directory class') do + metadata = Fog::Storage::Rackspace::Metadata.new Fog::Storage::Rackspace::Directory + returns(Fog::Storage::Rackspace::Directory) { metadata.send :parent_class } + end + end end \ No newline at end of file From 5a3332236153390694ab30950330b5784a1f4d41 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Thu, 28 Feb 2013 21:40:33 +0530 Subject: [PATCH 05/68] Fix the base encoding issue with Ruby 1.8.7 Compliance --- lib/fog/vcloud/compute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb index b3eb58714..c6a6110ed 100644 --- a/lib/fog/vcloud/compute.rb +++ b/lib/fog/vcloud/compute.rb @@ -301,7 +301,7 @@ module Fog # Use this to set the Authorization header for login def authorization_header - "Basic #{Base64.strict_encode64("#{@username}:#{@password}")}" + "Basic #{Base64.encode64("#{@username}:#{@password}").delete("\n")}" end # Actually do the request From 25019b402ac714bf82cf2d8a55abdcc867f73ad1 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:26:32 -0700 Subject: [PATCH 06/68] Fix Mock#allocate_address method arity --- lib/fog/openstack/requests/compute/allocate_address.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/allocate_address.rb b/lib/fog/openstack/requests/compute/allocate_address.rb index c07034363..a86f25662 100644 --- a/lib/fog/openstack/requests/compute/allocate_address.rb +++ b/lib/fog/openstack/requests/compute/allocate_address.rb @@ -16,7 +16,7 @@ module Fog end class Mock - def allocate_address + def allocate_address(pool = nil) response = Excon::Response.new response.status = 200 response.headers = { From 6d4925a83bd1190f29b7330e68d3d29b93099441 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:30:21 -0700 Subject: [PATCH 07/68] Fix Mock#get_snapshot_details argument --- lib/fog/openstack/requests/compute/get_snapshot_details.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/get_snapshot_details.rb b/lib/fog/openstack/requests/compute/get_snapshot_details.rb index 5e4355dd1..45e854274 100644 --- a/lib/fog/openstack/requests/compute/get_snapshot_details.rb +++ b/lib/fog/openstack/requests/compute/get_snapshot_details.rb @@ -16,7 +16,7 @@ module Fog class Mock - def get_snapshot_details(detailed=true) + def get_snapshot_details(snapshot_id) response = Excon::Response.new response.status = 200 response.body = { From 4d85d4fbfc74c62c3a252bb33d81031b9e02f557 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:30:53 -0700 Subject: [PATCH 08/68] Fix Mock#get_volume_details argument --- lib/fog/openstack/requests/compute/get_volume_details.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/get_volume_details.rb b/lib/fog/openstack/requests/compute/get_volume_details.rb index 9ca085ed5..bbeff4839 100644 --- a/lib/fog/openstack/requests/compute/get_volume_details.rb +++ b/lib/fog/openstack/requests/compute/get_volume_details.rb @@ -16,7 +16,7 @@ module Fog class Mock - def get_volume_details(detailed=true) + def get_volume_details(volume_id) response = Excon::Response.new response.status = 200 response.body = { From bdba2d696d01fa00ea93f3f6184e772a028950fc Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:32:14 -0700 Subject: [PATCH 09/68] Fix Mock#list_servers method arity --- lib/fog/openstack/requests/compute/list_servers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/list_servers.rb b/lib/fog/openstack/requests/compute/list_servers.rb index 3fb3f2cfe..9d19dc61b 100644 --- a/lib/fog/openstack/requests/compute/list_servers.rb +++ b/lib/fog/openstack/requests/compute/list_servers.rb @@ -19,7 +19,7 @@ module Fog class Mock - def list_servers + def list_servers(options = {}) response = Excon::Response.new data = list_servers_detail.body['servers'] servers = [] From 41914afe0827bb5f51dba5723e71bed5a575c537 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:34:02 -0700 Subject: [PATCH 10/68] Fix Mock#remove_fixed_ip arguments --- lib/fog/openstack/requests/compute/remove_fixed_ip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/remove_fixed_ip.rb b/lib/fog/openstack/requests/compute/remove_fixed_ip.rb index 7af1d3ad0..2fa12e0c8 100644 --- a/lib/fog/openstack/requests/compute/remove_fixed_ip.rb +++ b/lib/fog/openstack/requests/compute/remove_fixed_ip.rb @@ -20,7 +20,7 @@ module Fog end # class Real class Mock - def remove_fixed_ip(server_id, network_id) + def remove_fixed_ip(server_id, address) true end # def remove_fixed_ip end # class Mock From 692740d093e27ffb054aface486554df37300478 Mon Sep 17 00:00:00 2001 From: Mike Moore Date: Thu, 28 Feb 2013 18:35:24 -0700 Subject: [PATCH 11/68] Fix Mock#update_server arguments --- lib/fog/openstack/requests/compute/update_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/update_server.rb b/lib/fog/openstack/requests/compute/update_server.rb index a93cb9466..dbf0b9bc9 100644 --- a/lib/fog/openstack/requests/compute/update_server.rb +++ b/lib/fog/openstack/requests/compute/update_server.rb @@ -16,7 +16,7 @@ module Fog class Mock - def update_server(server_id, options) + def update_server(server_id, options = {}) response = Excon::Response.new if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id} if options['name'] From 9e8bb10684b3ab35e42d7e8a140019a934b348d4 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Fri, 1 Mar 2013 13:17:39 +0530 Subject: [PATCH 12/68] Delete \r also --- lib/fog/vcloud/compute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb index c6a6110ed..4cc393460 100644 --- a/lib/fog/vcloud/compute.rb +++ b/lib/fog/vcloud/compute.rb @@ -301,7 +301,7 @@ module Fog # Use this to set the Authorization header for login def authorization_header - "Basic #{Base64.encode64("#{@username}:#{@password}").delete("\n")}" + "Basic #{Base64.encode64("#{@username}:#{@password}").delete("\r\n")}" end # Actually do the request From ebf75f43def64d87821a60db5933f74e81e2136e Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Fri, 1 Mar 2013 10:26:47 -0600 Subject: [PATCH 13/68] [rackspace|databases] removed trailing stash from hard coded endpoints; added accept header --- lib/fog/rackspace/databases.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fog/rackspace/databases.rb b/lib/fog/rackspace/databases.rb index 6873f85c4..cb42fa580 100644 --- a/lib/fog/rackspace/databases.rb +++ b/lib/fog/rackspace/databases.rb @@ -8,9 +8,9 @@ module Fog class InternalServerError < Fog::Rackspace::Errors::InternalServerError; end class BadRequest < Fog::Rackspace::Errors::BadRequest; end - DFW_ENDPOINT = 'https://dfw.databases.api.rackspacecloud.com/v1.0/' - LON_ENDPOINT = 'https://lon.databases.api.rackspacecloud.com/v1.0/' - ORD_ENDPOINT = 'https://ord.databases.api.rackspacecloud.com/v1.0/' + DFW_ENDPOINT = 'https://dfw.databases.api.rackspacecloud.com/v1.0' + LON_ENDPOINT = 'https://lon.databases.api.rackspacecloud.com/v1.0' + ORD_ENDPOINT = 'https://ord.databases.api.rackspacecloud.com/v1.0' requires :rackspace_api_key, :rackspace_username recognizes :rackspace_auth_url @@ -82,6 +82,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept:' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, From e438f21e68c84e3685f3c6a1effc640c60f253c9 Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Fri, 1 Mar 2013 10:52:56 -0600 Subject: [PATCH 14/68] [rackspace] adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage --- lib/fog/rackspace/block_storage.rb | 1 + lib/fog/rackspace/cdn.rb | 1 + lib/fog/rackspace/compute_v2.rb | 1 + lib/fog/rackspace/databases.rb | 2 +- lib/fog/rackspace/identity.rb | 1 + lib/fog/rackspace/load_balancers.rb | 1 + lib/fog/rackspace/storage.rb | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fog/rackspace/block_storage.rb b/lib/fog/rackspace/block_storage.rb index 8614283d1..100d3a0a2 100644 --- a/lib/fog/rackspace/block_storage.rb +++ b/lib/fog/rackspace/block_storage.rb @@ -94,6 +94,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/cdn.rb b/lib/fog/rackspace/cdn.rb index 2abf220d7..bec7562a4 100644 --- a/lib/fog/rackspace/cdn.rb +++ b/lib/fog/rackspace/cdn.rb @@ -128,6 +128,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/compute_v2.rb b/lib/fog/rackspace/compute_v2.rb index adaa2246e..aa1fb557c 100644 --- a/lib/fog/rackspace/compute_v2.rb +++ b/lib/fog/rackspace/compute_v2.rb @@ -120,6 +120,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/databases.rb b/lib/fog/rackspace/databases.rb index cb42fa580..d88d1b48c 100644 --- a/lib/fog/rackspace/databases.rb +++ b/lib/fog/rackspace/databases.rb @@ -82,7 +82,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept:' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/identity.rb b/lib/fog/rackspace/identity.rb index 911c7b86a..b1b46cc46 100644 --- a/lib/fog/rackspace/identity.rb +++ b/lib/fog/rackspace/identity.rb @@ -61,6 +61,7 @@ module Fog parameters = params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }, :host => @host, diff --git a/lib/fog/rackspace/load_balancers.rb b/lib/fog/rackspace/load_balancers.rb index 69d013f04..2666acebe 100644 --- a/lib/fog/rackspace/load_balancers.rb +++ b/lib/fog/rackspace/load_balancers.rb @@ -125,6 +125,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/storage.rb b/lib/fog/rackspace/storage.rb index 072c3c83a..f6eec775a 100644 --- a/lib/fog/rackspace/storage.rb +++ b/lib/fog/rackspace/storage.rb @@ -118,6 +118,7 @@ module Fog response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, From 5e6435b7971d70c950209e6f9f9c5a4a1957262c Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 1 Mar 2013 20:12:45 +0100 Subject: [PATCH 15/68] Switch gem source to https://rubygems.org --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c80ee3697..b4e2a20bb 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ -source "http://rubygems.org" +source "https://rubygems.org" gemspec From f64e312e92b88e5c5459a97e02064b643facafc5 Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Fri, 1 Mar 2013 16:48:16 -0600 Subject: [PATCH 16/68] Revert "[rackspace] adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage" This reverts commit e438f21e68c84e3685f3c6a1effc640c60f253c9. --- lib/fog/rackspace/block_storage.rb | 1 - lib/fog/rackspace/cdn.rb | 1 - lib/fog/rackspace/compute_v2.rb | 1 - lib/fog/rackspace/databases.rb | 2 +- lib/fog/rackspace/identity.rb | 1 - lib/fog/rackspace/load_balancers.rb | 1 - lib/fog/rackspace/storage.rb | 1 - 7 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/fog/rackspace/block_storage.rb b/lib/fog/rackspace/block_storage.rb index 100d3a0a2..8614283d1 100644 --- a/lib/fog/rackspace/block_storage.rb +++ b/lib/fog/rackspace/block_storage.rb @@ -94,7 +94,6 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/cdn.rb b/lib/fog/rackspace/cdn.rb index bec7562a4..2abf220d7 100644 --- a/lib/fog/rackspace/cdn.rb +++ b/lib/fog/rackspace/cdn.rb @@ -128,7 +128,6 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/compute_v2.rb b/lib/fog/rackspace/compute_v2.rb index aa1fb557c..adaa2246e 100644 --- a/lib/fog/rackspace/compute_v2.rb +++ b/lib/fog/rackspace/compute_v2.rb @@ -120,7 +120,6 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/databases.rb b/lib/fog/rackspace/databases.rb index d88d1b48c..cb42fa580 100644 --- a/lib/fog/rackspace/databases.rb +++ b/lib/fog/rackspace/databases.rb @@ -82,7 +82,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept:' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/identity.rb b/lib/fog/rackspace/identity.rb index b1b46cc46..911c7b86a 100644 --- a/lib/fog/rackspace/identity.rb +++ b/lib/fog/rackspace/identity.rb @@ -61,7 +61,6 @@ module Fog parameters = params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }, :host => @host, diff --git a/lib/fog/rackspace/load_balancers.rb b/lib/fog/rackspace/load_balancers.rb index 2666acebe..69d013f04 100644 --- a/lib/fog/rackspace/load_balancers.rb +++ b/lib/fog/rackspace/load_balancers.rb @@ -125,7 +125,6 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/storage.rb b/lib/fog/rackspace/storage.rb index f6eec775a..072c3c83a 100644 --- a/lib/fog/rackspace/storage.rb +++ b/lib/fog/rackspace/storage.rb @@ -118,7 +118,6 @@ module Fog response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, From 06fa83820438980bf2686e91696b56e67a04be0c Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Fri, 1 Mar 2013 16:59:59 -0600 Subject: [PATCH 17/68] Revert "Revert "[rackspace] adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage"" This reverts commit f64e312e92b88e5c5459a97e02064b643facafc5. --- lib/fog/rackspace/block_storage.rb | 1 + lib/fog/rackspace/cdn.rb | 1 + lib/fog/rackspace/compute_v2.rb | 1 + lib/fog/rackspace/databases.rb | 2 +- lib/fog/rackspace/identity.rb | 1 + lib/fog/rackspace/load_balancers.rb | 1 + lib/fog/rackspace/storage.rb | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fog/rackspace/block_storage.rb b/lib/fog/rackspace/block_storage.rb index 8614283d1..100d3a0a2 100644 --- a/lib/fog/rackspace/block_storage.rb +++ b/lib/fog/rackspace/block_storage.rb @@ -94,6 +94,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/cdn.rb b/lib/fog/rackspace/cdn.rb index 2abf220d7..bec7562a4 100644 --- a/lib/fog/rackspace/cdn.rb +++ b/lib/fog/rackspace/cdn.rb @@ -128,6 +128,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/compute_v2.rb b/lib/fog/rackspace/compute_v2.rb index adaa2246e..aa1fb557c 100644 --- a/lib/fog/rackspace/compute_v2.rb +++ b/lib/fog/rackspace/compute_v2.rb @@ -120,6 +120,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/databases.rb b/lib/fog/rackspace/databases.rb index cb42fa580..d88d1b48c 100644 --- a/lib/fog/rackspace/databases.rb +++ b/lib/fog/rackspace/databases.rb @@ -82,7 +82,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept:' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/identity.rb b/lib/fog/rackspace/identity.rb index 911c7b86a..b1b46cc46 100644 --- a/lib/fog/rackspace/identity.rb +++ b/lib/fog/rackspace/identity.rb @@ -61,6 +61,7 @@ module Fog parameters = params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }, :host => @host, diff --git a/lib/fog/rackspace/load_balancers.rb b/lib/fog/rackspace/load_balancers.rb index 69d013f04..2666acebe 100644 --- a/lib/fog/rackspace/load_balancers.rb +++ b/lib/fog/rackspace/load_balancers.rb @@ -125,6 +125,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/rackspace/storage.rb b/lib/fog/rackspace/storage.rb index 072c3c83a..f6eec775a 100644 --- a/lib/fog/rackspace/storage.rb +++ b/lib/fog/rackspace/storage.rb @@ -118,6 +118,7 @@ module Fog response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, From 29e51626caa211573577e0632825750d296433da Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Fri, 1 Mar 2013 17:02:54 -0600 Subject: [PATCH 18/68] [rackspace|database] remove extraneous colon --- lib/fog/rackspace/databases.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/rackspace/databases.rb b/lib/fog/rackspace/databases.rb index cb42fa580..b1d6819e8 100644 --- a/lib/fog/rackspace/databases.rb +++ b/lib/fog/rackspace/databases.rb @@ -82,7 +82,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', - 'Accept:' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, From 8542e93b242f39892423dcd1f7cbcc9802a11f9c Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 2 Mar 2013 21:15:40 -0500 Subject: [PATCH 19/68] OpenStack: base64 encode personality in rebuild Updates the rebuild_server action so that it base64's the personality just like we do in create_server. --- lib/fog/openstack/requests/compute/rebuild_server.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/fog/openstack/requests/compute/rebuild_server.rb b/lib/fog/openstack/requests/compute/rebuild_server.rb index c4f23e6b1..77f744659 100644 --- a/lib/fog/openstack/requests/compute/rebuild_server.rb +++ b/lib/fog/openstack/requests/compute/rebuild_server.rb @@ -11,7 +11,15 @@ module Fog }} body['rebuild']['adminPass'] = admin_pass if admin_pass body['rebuild']['metadata'] = metadata if metadata - body['rebuild']['personality'] = personality if personality + if personality + body['rebuild']['personality'] = [] + for file in personality + body['rebuild']['personality'] << { + 'contents' => Base64.encode64(file['contents']), + 'path' => file['path'] + } + end + end server_action(server_id, body, 202) end From 2381ed38be35fb3b9f09d99b62157ed5959285f6 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 4 Mar 2013 16:47:40 +0100 Subject: [PATCH 20/68] [openstack|identity] user model tests fixes - update_tenant expects a tenant model or a tenant_id - update_enabled expects a boolean --- tests/openstack/models/identity/user_tests.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/openstack/models/identity/user_tests.rb b/tests/openstack/models/identity/user_tests.rb index 9ace034a6..63e50179e 100644 --- a/tests/openstack/models/identity/user_tests.rb +++ b/tests/openstack/models/identity/user_tests.rb @@ -26,11 +26,11 @@ Shindo.tests("Fog::Identity[:openstack] | user", ['openstack']) do end tests('#update_tenant').returns(true) do - @instance.update_tenant('swordfish') + @instance.update_tenant(tenant_id) end tests('#update_enabled').returns(true) do - @instance.update_enabled('swordfish') + @instance.update_enabled(true) end tests('#destroy').returns(true) do From 3cbb6f26225d9ed5f44c22aeee5175f73619ccbe Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 4 Mar 2013 16:56:36 +0100 Subject: [PATCH 21/68] [openstack|identity] cleanup the test role when no longer in use --- tests/openstack/models/identity/roles_tests.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/openstack/models/identity/roles_tests.rb b/tests/openstack/models/identity/roles_tests.rb index 1b42177a3..6e0dc1f85 100644 --- a/tests/openstack/models/identity/roles_tests.rb +++ b/tests/openstack/models/identity/roles_tests.rb @@ -14,6 +14,7 @@ Shindo.tests("Fog::Identity[:openstack] | roles", ['openstack']) do end end + @role.destroy @user.destroy @tenant.destroy end From 8bb3e60aea4fc99262f19b445255f19e6c7dd989 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 4 Mar 2013 18:54:18 +0100 Subject: [PATCH 22/68] [openstack|compute] images collection should not return nil for #all Fog::Compute[:openstack].images.all returns nil without the patch. The patch should bring the images collection behaviour in-line with other collections I think. The added test should expose the issue. --- lib/fog/openstack/models/compute/images.rb | 3 ++- tests/openstack/models/compute/images_tests.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/openstack/models/compute/images_tests.rb diff --git a/lib/fog/openstack/models/compute/images.rb b/lib/fog/openstack/models/compute/images.rb index a5815c734..e560ba55f 100644 --- a/lib/fog/openstack/models/compute/images.rb +++ b/lib/fog/openstack/models/compute/images.rb @@ -13,10 +13,11 @@ module Fog def all data = service.list_images_detail.body['images'] - load(data) + images = load(data) if server self.replace(self.select {|image| image.server_id == server.id}) end + images end def get(image_id) diff --git a/tests/openstack/models/compute/images_tests.rb b/tests/openstack/models/compute/images_tests.rb new file mode 100644 index 000000000..b2dd3712f --- /dev/null +++ b/tests/openstack/models/compute/images_tests.rb @@ -0,0 +1,14 @@ +Shindo.tests("Fog::Compute[:openstack] | images collection", ['openstack']) do + + tests('success') do + + tests('#all').succeeds do + fog = Fog::Compute[:openstack] + test 'not nil' do + fog.images.all.is_a? Array + end + end + + end +end + From c151e9a5da8928c87464a0bc9119d564aaeadf67 Mon Sep 17 00:00:00 2001 From: dJason Date: Mon, 4 Mar 2013 14:20:27 -0700 Subject: [PATCH 23/68] Typo in instantiate_vapp_template.rb Remove typo in instantiate_vapp_template() --- lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb b/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb index 5023deabd..86de2ec81 100644 --- a/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb +++ b/lib/fog/vcloud/requests/compute/instantiate_vapp_template.rb @@ -71,7 +71,7 @@ module Fog include Shared def instantiate_vapp_template options = {} - validate_instantiate_vapp_template_options optionsgi + validate_instantiate_vapp_template_options options request( :body => generate_instantiate_vapp_template_request(options), :expects => 201, From 8d19c989d47b22486cef486094a2c66945f29957 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 Mar 2013 19:31:59 -0500 Subject: [PATCH 24/68] [virtualbox] Removed VirtualBox since it has many problems and the gem it's based on is no longer maintained. Fixes #1621: Remove VirtualBox support --- fog.gemspec | 1 - lib/fog/bin.rb | 1 - lib/fog/bin/virtual_box.rb | 57 ----- lib/fog/compute.rb | 3 - lib/fog/providers.rb | 1 - lib/fog/virtual_box.rb | 11 - lib/fog/virtual_box/compute.rb | 59 ------ lib/fog/virtual_box/models/compute/medium.rb | 87 -------- .../models/compute/medium_format.rb | 34 --- lib/fog/virtual_box/models/compute/mediums.rb | 32 --- .../virtual_box/models/compute/nat_engine.rb | 65 ------ .../models/compute/nat_redirect.rb | 91 -------- .../models/compute/nat_redirects.rb | 41 ---- .../models/compute/network_adapter.rb | 82 -------- .../models/compute/network_adapters.rb | 42 ---- lib/fog/virtual_box/models/compute/server.rb | 199 ------------------ lib/fog/virtual_box/models/compute/servers.rb | 41 ---- .../models/compute/storage_controller.rb | 83 -------- .../models/compute/storage_controllers.rb | 38 ---- tests/helper.rb | 2 +- 20 files changed, 1 insertion(+), 969 deletions(-) delete mode 100644 lib/fog/bin/virtual_box.rb delete mode 100644 lib/fog/virtual_box.rb delete mode 100644 lib/fog/virtual_box/compute.rb delete mode 100644 lib/fog/virtual_box/models/compute/medium.rb delete mode 100644 lib/fog/virtual_box/models/compute/medium_format.rb delete mode 100644 lib/fog/virtual_box/models/compute/mediums.rb delete mode 100644 lib/fog/virtual_box/models/compute/nat_engine.rb delete mode 100644 lib/fog/virtual_box/models/compute/nat_redirect.rb delete mode 100644 lib/fog/virtual_box/models/compute/nat_redirects.rb delete mode 100644 lib/fog/virtual_box/models/compute/network_adapter.rb delete mode 100644 lib/fog/virtual_box/models/compute/network_adapters.rb delete mode 100644 lib/fog/virtual_box/models/compute/server.rb delete mode 100644 lib/fog/virtual_box/models/compute/servers.rb delete mode 100644 lib/fog/virtual_box/models/compute/storage_controller.rb delete mode 100644 lib/fog/virtual_box/models/compute/storage_controllers.rb diff --git a/fog.gemspec b/fog.gemspec index d20713c61..734b67a64 100644 --- a/fog.gemspec +++ b/fog.gemspec @@ -60,7 +60,6 @@ Gem::Specification.new do |s| s.add_development_dependency('rspec', '~>1.3.1') s.add_development_dependency('rbovirt', '>=0.0.11') s.add_development_dependency('shindo', '~>0.3.4') - s.add_development_dependency('virtualbox', '~>0.9.1') s.add_development_dependency('fission') s.add_development_dependency('pry') # s.add_development_dependency('ruby-libvirt','~>0.4.0') diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index 8b7303a87..1b0c1c8e8 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -87,7 +87,6 @@ require 'fog/bin/serverlove' require 'fog/bin/stormondemand' require 'fog/bin/terremark' require 'fog/bin/vcloud' -require 'fog/bin/virtual_box' require 'fog/bin/vmfusion' require 'fog/bin/vsphere' require 'fog/bin/voxel' diff --git a/lib/fog/bin/virtual_box.rb b/lib/fog/bin/virtual_box.rb deleted file mode 100644 index 9197b8254..000000000 --- a/lib/fog/bin/virtual_box.rb +++ /dev/null @@ -1,57 +0,0 @@ -module VirtualBox # deviates from other bin stuff to accomodate gem - class << self - - def class_for(key) - case key - when :compute - Fog::Compute::VirtualBox - 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("VirtualBox[:compute] is not recommended, use Compute[:virtualbox] for portability") - Fog::Compute.new(:provider => 'VirtualBox') - else - raise ArgumentError, "Unrecognized service: #{key.inspect}" - end - end - @@connections[service] - end - - def available? - availability = if Gem::Specification.respond_to?(:find_all_by_name) - !Gem::Specification.find_all_by_name('virtualbox').empty? # newest rubygems - else - !Gem.source_index.find_name('virtualbox').empty? # legacy - end - if availability - for service in services - for collection in self.class_for(service).collections - unless self.respond_to?(collection) - self.class_eval <<-EOS, __FILE__, __LINE__ - def self.#{collection} - self[:#{service}].#{collection} - end - EOS - end - end - end - end - availability - end - - def collections - services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s} - end - - def services - Fog::VirtualBox.services - end - - end -end diff --git a/lib/fog/compute.rb b/lib/fog/compute.rb index a6a23471a..4243d96da 100644 --- a/lib/fog/compute.rb +++ b/lib/fog/compute.rb @@ -35,9 +35,6 @@ module Fog when :stormondemand require 'fog/storm_on_demand/compute' Fog::Compute::StormOnDemand.new(attributes) - when :virtualbox - require 'fog/virtual_box/compute' - Fog::Compute::VirtualBox.new(attributes) else if self.providers.include?(provider) require "fog/#{provider}/compute" diff --git a/lib/fog/providers.rb b/lib/fog/providers.rb index 3a353a6ea..0ac5f52e4 100644 --- a/lib/fog/providers.rb +++ b/lib/fog/providers.rb @@ -27,7 +27,6 @@ require 'fog/ovirt' require 'fog/serverlove' require 'fog/storm_on_demand' require 'fog/vcloud' -require 'fog/virtual_box' require 'fog/vmfusion' require 'fog/vsphere' require 'fog/voxel' diff --git a/lib/fog/virtual_box.rb b/lib/fog/virtual_box.rb deleted file mode 100644 index 44ca85682..000000000 --- a/lib/fog/virtual_box.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'fog/core' - -module Fog - module VirtualBox - - extend Fog::Provider - - service(:compute, 'virtual_box/compute', 'Compute') - - end -end diff --git a/lib/fog/virtual_box/compute.rb b/lib/fog/virtual_box/compute.rb deleted file mode 100644 index ebc3c2587..000000000 --- a/lib/fog/virtual_box/compute.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'fog/virtual_box' -require 'fog/compute' - -module Fog - module Compute - class VirtualBox < Fog::Service - - model_path 'fog/virtual_box/models/compute' - model :medium - collection :mediums - model :medium_format - model :nat_engine - model :nat_redirect - collection :nat_redirects - model :network_adapter - collection :network_adapters - model :server - collection :servers - model :storage_controller - collection :storage_controllers - - class Mock - - def initialize(options={}) - Fog::Mock.not_implemented - end - - end - - class Real - - def initialize(options={}) - begin - require 'virtualbox' - rescue LoadError => e - retry if require('rubygems') - raise e.message - end - - @service = ::VirtualBox::Global.global.lib.virtualbox - end - - def respond_to?(method, *) - super or @service.respond_to? method - end - - # hack to provide 'requests' - def method_missing(method_sym, *arguments, &block) - if @service.respond_to?(method_sym) - @service.send(method_sym, *arguments) - else - super - end - end - - end - end - end -end diff --git a/lib/fog/virtual_box/models/compute/medium.rb b/lib/fog/virtual_box/models/compute/medium.rb deleted file mode 100644 index f6b4ba2fe..000000000 --- a/lib/fog/virtual_box/models/compute/medium.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'fog/core/model' -require 'fog/virtual_box/models/compute/medium_format' - -module Fog - module Compute - class VirtualBox - - class Medium < Fog::Model - - identity :id - - attribute :auto_reset - attribute :base - attribute :children - attribute :description - attribute :device_type - attribute :format - attribute :host_drive - attribute :id - attribute :last_access_error - attribute :location - attribute :logical_size - attribute :machine_ids - attribute :medium_format - attribute :name - attribute :parent - attribute :read_only - attribute :size - attribute :state - attribute :type - attribute :variant - - def destroy - requires :raw - raw.close - true - end - - undef_method :medium_format - def medium_format - Fog::Compute::VirtualBox::MediumFormat.new( - :service => service, - :raw => raw.medium_format - ) - end - - def save - requires :device_type, :location, :read_only - - if File.exists?(location) - - access_mode = if read_only - :access_mode_read_only - else - :access_mode_read_write - end - - self.raw = service.open_medium(location, device_type, access_mode) - - else - - raise Fog::Errors::Error.new('Creating a new medium is not yet implemented. Contributions welcome!') - - end - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - for key in [:auto_reset, :base, :children, :description, :device_type, :format, :host_drive, :id, :last_access_error, :location, :logical_size, :machine_ids, :medium_format, :name, :parent, :read_only, :size, :state, :type, :variant] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/medium_format.rb b/lib/fog/virtual_box/models/compute/medium_format.rb deleted file mode 100644 index 501ab8021..000000000 --- a/lib/fog/virtual_box/models/compute/medium_format.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'fog/core/model' - -module Fog - module Compute - class VirtualBox - - class MediumFormat < Fog::Model - - identity :id - - # attribute :capabilities - attribute :name - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - for key in [:id, :name] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/mediums.rb b/lib/fog/virtual_box/models/compute/mediums.rb deleted file mode 100644 index 59b0658e0..000000000 --- a/lib/fog/virtual_box/models/compute/mediums.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'fog/core/collection' -require 'fog/virtual_box/models/compute/medium' - -module Fog - module Compute - class VirtualBox - - class Mediums < Fog::Collection - - model Fog::Compute::VirtualBox::Medium - - def all - data = [] - data.concat(service.dvd_images) - data.concat(service.floppy_images) - data.concat(service.hard_disks) - data = data.map do |medium| - {:raw => medium} - end - load(data) - end - - def get(medium_identity) - data = service.find_medium(medium_identity) - new(:raw => data) - end - - end - - end - end -end diff --git a/lib/fog/virtual_box/models/compute/nat_engine.rb b/lib/fog/virtual_box/models/compute/nat_engine.rb deleted file mode 100644 index 753b335ac..000000000 --- a/lib/fog/virtual_box/models/compute/nat_engine.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'fog/core/model' - -module Fog - module Compute - class VirtualBox - - class NATEngine < Fog::Model - - # identity :? - - attribute :alias_mode - attribute :dns_pass_domain - attribute :dns_proxy - attribute :dns_use_host_resolver - attribute :host_ip - attribute :network - attribute :redirects - attribute :tftp_boot_file - attribute :tftp_next_server - attribute :tftp_prefix - - attr_accessor :machine, :network_adapter - - # def save - # unless identity - # requires :identity, :bus, :machine - # with_session do |session| - # self.raw = session.machine.add_storage_controller(identity, bus) - # end - # true - # else - # raise Fog::Errors::Error.new('Updating an existing storage_controller is not yet implemented. Contributions welcome!') - # end - # end - - undef_method :redirects - def redirects - Fog::Compute::VirtualBox::NATRedirects.new( - :service => service, - :machine => machine, - :nat_engine => self - ) - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - for key in [:alias_mode, :dns_pass_domain, :dns_proxy, :dns_use_host_resolver, :host_ip, :network, :redirects, :tftp_boot_file, :tftp_next_server, :tftp_prefix] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/nat_redirect.rb b/lib/fog/virtual_box/models/compute/nat_redirect.rb deleted file mode 100644 index 815452246..000000000 --- a/lib/fog/virtual_box/models/compute/nat_redirect.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'fog/core/model' - -module Fog - module Compute - class VirtualBox - - class NATRedirect < Fog::Model - - identity :name - - attribute :name - attribute :protocol - attribute :host_ip - attribute :host_port - attribute :guest_ip - attribute :guest_port - - attr_accessor :machine, :nat_engine - - def destroy - requires :nat_engine, :name - with_session do |session| - raw_network_adapter = session.machine.get_network_adapter(nat_engine.network_adapter.slot) - raw_nat_engine = raw_network_adapter.nat_driver - raw_nat_engine.remove_redirect(name) - session.machine.save_settings - end - true - end - - def initialize(attributes = {}) - self.name = '' - self.protocol = :tcp - self.host_ip = '' - self.guest_ip = '' - super - end - - undef_method :protocol= - def protocol=(new_protocol) - attributes[:protocol] = case new_protocol - when '0' - :udp - when '1' - :tcp - else - new_protocol - end - end - - def save - requires :nat_engine, :name, :protocol, :host_ip, :host_port, :guest_ip, :guest_port - with_session do |session| - raw_network_adapter = session.machine.get_network_adapter(nat_engine.network_adapter.slot) - raw_nat_engine = raw_network_adapter.nat_driver - raw_nat_engine.add_redirect(name, protocol, host_ip, host_port, guest_ip, guest_port) - session.machine.save_settings - end - true - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - name, protocol, host_ip, host_port, guest_ip, guest_port = new_raw.split(',') - raw_attributes = {:name => name, :protocol => protocol, :host_ip => host_ip, :host_port => host_port, :guest_ip => guest_ip, :guest_port => guest_port} - merge_attributes(raw_attributes) - end - - def session - ::VirtualBox::Lib.lib.session - end - - def with_session - raw_machine = machine.instance_variable_get(:@raw) - raw_machine.lock_machine(session, :write) - yield session - session.unlock_machine - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/nat_redirects.rb b/lib/fog/virtual_box/models/compute/nat_redirects.rb deleted file mode 100644 index 3fdd6f167..000000000 --- a/lib/fog/virtual_box/models/compute/nat_redirects.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'fog/core/collection' -require 'fog/virtual_box/models/compute/nat_redirect' - -module Fog - module Compute - class VirtualBox - - class NATRedirects < Fog::Collection - - model Fog::Compute::VirtualBox::NATRedirect - - attr_accessor :machine, :nat_engine - - def all - requires :machine, :nat_engine - data = nat_engine.instance_variable_get(:@raw).redirects.map do |nat_redirect| - { - :machine => machine, - :raw => nat_redirect - } - end - load(data) - end - - def get(nat_redirect_name) - requires :machine, :nat_engine - all.detect do |nat_redirect| - nat_redirect.name == nat_redirect_name - end - end - - def new(attributes = {}) - requires :machine, :nat_engine - super({:machine => machine, :nat_engine => nat_engine}.merge!(attributes)) - end - - end - - end - end -end diff --git a/lib/fog/virtual_box/models/compute/network_adapter.rb b/lib/fog/virtual_box/models/compute/network_adapter.rb deleted file mode 100644 index cb7befa81..000000000 --- a/lib/fog/virtual_box/models/compute/network_adapter.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'fog/core/model' -require 'fog/virtual_box/models/compute/nat_engine' - -module Fog - module Compute - class VirtualBox - - class NetworkAdapter < Fog::Model - - identity :slot - - attribute :adapter_type - attribute :attachment_type - attribute :bandwidth_limit - attribute :boot_priority - attribute :cable_connected - attribute :enabled - attribute :host_interface - attribute :internal_network - attribute :line_speed - attribute :mac_address - attribute :nat_driver - attribute :nat_network - attribute :trace_enabled - attribute :trace_file - attribute :vde_network - - attr_accessor :machine - - def save - with_session do |session| - session_raw = session.machine.get_network_adapter(slot) - # for attribute in [:adapter_type, :bandwidth_limit, :boot_priority, :cable_connected, :enabled, :host_interface, :internal_network, :line_speed, :mac_address, :nat_network, :trace_enabled, :trace_file] - # session_raw.send("#{attribute}=", attributes[attribute]) - # end - session_raw.mac_address = mac_address - session.machine.save_settings - end - end - - undef_method :nat_driver - def nat_driver - Fog::Compute::VirtualBox::NATEngine.new( - :service => service, - :machine => machine, - :network_adapter => self, - :raw => raw.nat_driver - ) - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - for key in [:adapter_type, :attachment_type, :bandwidth_limit, :boot_priority, :cable_connected, :enabled, :host_interface, :internal_network, :line_speed, :mac_address, :nat_driver, :nat_network, :slot, :trace_enabled, :trace_file] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - def session - ::VirtualBox::Lib.lib.session - end - - def with_session - raw_machine = machine.instance_variable_get(:@raw) - raw_machine.lock_machine(session, :write) - yield session - session.unlock_machine - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/network_adapters.rb b/lib/fog/virtual_box/models/compute/network_adapters.rb deleted file mode 100644 index ea5144d5c..000000000 --- a/lib/fog/virtual_box/models/compute/network_adapters.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'fog/core/collection' -require 'fog/virtual_box/models/compute/network_adapter' - -module Fog - module Compute - class VirtualBox - - class NetworkAdapters < Fog::Collection - - model Fog::Compute::VirtualBox::NetworkAdapter - - attr_accessor :machine - - def all - requires :machine - data = [] - raw_machine = machine.instance_variable_get(:@raw) - service.system_properties.network_adapter_count.times do |index| - data << { - :raw => raw_machine.get_network_adapter(index) - } - end - load(data) - end - - def get(network_adapter_slot) - requires :machine - raw_machine = machine.instance_variable_get(:@raw) - network_adapter = raw_machine.get_network_adapter(network_adapter_slot) - new(:raw => network_adapter) - end - - def new(attributes = {}) - requires :machine - super({ :machine => machine }.merge!(attributes)) - end - - end - - end - end -end diff --git a/lib/fog/virtual_box/models/compute/server.rb b/lib/fog/virtual_box/models/compute/server.rb deleted file mode 100644 index 7bcf91061..000000000 --- a/lib/fog/virtual_box/models/compute/server.rb +++ /dev/null @@ -1,199 +0,0 @@ -require 'fog/compute/models/server' - -module Fog - module Compute - class VirtualBox - - class Server < Fog::Compute::Server - - identity :id - - attribute :description - attribute :memory_size - attribute :name - attribute :os, :aliases => :os_type_id - attribute :rtc_use_utc - attribute :session_state - attribute :status, :aliases => :state - attribute :vram_size - - # property :accelerate_2d_video_enabled, T_BOOL - # property :accelerate_3d_enabled, T_BOOL - # property :access_error, :VirtualBoxErrorInfo, :readonly => true - # property :accessible, T_BOOL, :readonly => true - # property :audio_adapter, :AudioAdapter, :readonly => true - # property :bandwidth_control, :BandwidthControl, :readonly => true - # property :bios_settings, :BIOSSettings, :readonly => true - # property :chipset_type, :ChipsetType - # property :clipboard_mode, :ClipboardMode - # property :cpu_count, T_UINT32 - # property :cpu_execution_cap, T_UINT64 - # property :cpu_hot_plug_enabled, T_BOOL - # property :current_snapshot, :Snapshot, :readonly => true - # property :current_state_modified, T_BOOL, :readonly => true - # property :fault_tolerance_address, WSTRING - # property :fault_tolerance_password, WSTRING - # property :fault_tolerance_port, T_UINT64 - # property :fault_tolerance_state, :FaultToleranceState - # property :fault_tolerance_sync_interval, T_UINT64 - # property :firmware_type, :FirmwareType - # property :guest_property_notification_patterns, WSTRING - # property :hardware_uuid, WSTRING - # property :hardware_version, WSTRING - # property :hpet_enabled, T_BOOL - # property :io_cache_enabled, T_BOOL - # property :io_cache_size, T_UINT32 - # property :keyboard_hid_type, T_UINT32 - # property :last_state_change, T_INT64, :readonly => true - # property :log_folder, WSTRING, :readonly => true - # property :medium_attachments, [:MediumAttachment], :readonly => true - # property :memory_balloon_size, T_UINT64 - # property :monitor_count, T_UINT64 - # property :page_fusion_enabled, T_BOOL - # property :parent, :VirtualBox, :readonly => true - # property :pci_device_assignments, [:PciDeviceAttachment], :readonly => true - # property :pointing_hid_type, T_UINT32 - # property :session_pid, T_UINT64, :readonly => true - # property :session_type, WSTRING, :readonly => true - # property :settings_file_path, WSTRING, :readonly => true - # property :settings_modified, T_BOOL, :readonly => true - # property :shared_folders, [:SharedFolder], :readonly => true - # property :snapshot_count, T_UINT32, :readonly => true - # property :snapshot_folder, WSTRING - # property :state_file_path, WSTRING, :readonly => true - # property :storage_controllers, [:StorageController], :readonly => true - # property :teleporter_address, WSTRING - # property :teleporter_enabled, T_BOOL - # property :teleporter_password, WSTRING - # property :teleporter_port, T_UINT32 - # property :usb_controller, :USBController, :readonly => true - # property :vrde_server, :VRDEServer, :readonly => true - - def initialize(attributes={}) - self.memory_size = 256 - self.rtc_use_utc = true - self.vram_size = 8 - super - end - - def destroy - requires :name, :raw - unless raw.state == :powered_off - stop - wait_for { raw.session_state == :closed } - end - raw.unregister(:full) - config_file = service.compose_machine_filename(name) - config_directory = config_file.split(File::SEPARATOR)[0...-1].join(File::SEPARATOR) - FileUtils.rm_rf(config_directory) - true - end - - def network_adapters - Fog::Compute::VirtualBox::NetworkAdapters.new( - :service => service, - :machine => self - ) - end - - def private_ip_address - nil - end - - def public_ip_address - nil - end - - def ready? - status == :running - end - - def reboot - requires :raw - session.console.reset - true - end - - def save - unless identity - requires :name, :os - self.raw = service.create_machine(nil, name, os) - service.register_machine(raw) - with_session do |session| - for attribute in [:description, :memory_size, :rtc_use_utc, :vram_size] - session.machine.send(:"#{attribute}=", attributes[attribute]) - end - session.machine.save_settings - end - true - else - raise Fog::Errors::Error.new('Updating an existing server is not yet implemented. Contributions welcome!') - end - end - - def setup(credentials = {}) - raise 'Not Implemented' - # requires :addresses, :identity, :public_key, :username - # Fog::SSH.new(addresses['public'].first, username, credentials).run([ - # %{mkdir .ssh}, - # %{echo "#{public_key}" >> ~/.ssh/authorized_keys}, - # %{passwd -l #{username}}, - # %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}, - # %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json} - # ]) - # rescue Errno::ECONNREFUSED - # sleep(1) - # retry - end - - def start(type = 'headless') - requires :raw - # session, type in ['gui', 'headless'], key[=value]\n env variables - raw.launch_vm_process(session, type, '').wait - true - end - - def stop - requires :raw - session.console.power_down.wait - true - end - - def storage_controllers - Fog::Compute::VirtualBox::StorageControllers.new( - :service => service, - :machine => self - ) - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - for key in [:id, :description, :memory_size, :name, :os_type_id, :state] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - def session - ::VirtualBox::Lib.lib.session - end - - def with_session - raw.lock_machine(session, :write) - yield session - session.unlock_machine - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/servers.rb b/lib/fog/virtual_box/models/compute/servers.rb deleted file mode 100644 index 43bb2816d..000000000 --- a/lib/fog/virtual_box/models/compute/servers.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'fog/core/collection' -require 'fog/virtual_box/models/compute/server' - -module Fog - module Compute - class VirtualBox - - class Servers < Fog::Collection - - model Fog::Compute::VirtualBox::Server - - def all - data = service.machines.map do |machine| - { - :raw => machine - } - end - load(data) - end - - def bootstrap(new_attributes = {}) - raise 'Not Implemented' - # server = create(new_attributes) - # server.start - # server.wait_for { ready? } - # server.setup(:password => server.password) - # server - end - - def get(server_id) - machine = service.find_machine(server_id) - new(:raw => machine) - rescue ::VirtualBox::Exceptions::ObjectNotFoundException - nil - end - - end - - end - end -end diff --git a/lib/fog/virtual_box/models/compute/storage_controller.rb b/lib/fog/virtual_box/models/compute/storage_controller.rb deleted file mode 100644 index d20cc147f..000000000 --- a/lib/fog/virtual_box/models/compute/storage_controller.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'fog/core/model' - -module Fog - module Compute - class VirtualBox - - class StorageController < Fog::Model - - identity :name - - attribute :bootable - attribute :bus - attribute :controller_type - attribute :instance - attribute :max_devices_per_port_count - attribute :max_port_count - attribute :min_port_count - attribute :port_count - attribute :use_host_io_cache - - attr_accessor :machine - - def attach(medium, port, device = 0) - requires :identity, :machine - with_session do |session| - session.machine.attach_device(identity, port, device, medium.device_type, medium.instance_variable_get(:@raw)) - session.machine.save_settings - end - true - end - - def destroy - requires :identity, :machine - with_session do |session| - session.machine.remove_storage_controller(identity) - session.machine.save_settings - end - true - end - - def save - requires :bus, :identity, :machine - with_session do |session| - self.raw = session.machine.add_storage_controller(identity, bus) - raw.port_count = 1 - session.machine.save_settings - end - true - end - - private - - def raw - @raw - end - - def raw=(new_raw) - @raw = new_raw - raw_attributes = {} - # TODO: pending my patches being accepted :bootable, - for key in [:bus, :controller_type, :instance, :max_devices_per_port_count, :max_port_count, :min_port_count, :port_count, :use_host_io_cache] - raw_attributes[key] = @raw.send(key) - end - merge_attributes(raw_attributes) - end - - def session - ::VirtualBox::Lib.lib.session - end - - def with_session - raw_machine = machine.instance_variable_get(:@raw) - raw_machine.lock_machine(session, :write) - yield session - session.unlock_machine - end - - end - - end - end - -end diff --git a/lib/fog/virtual_box/models/compute/storage_controllers.rb b/lib/fog/virtual_box/models/compute/storage_controllers.rb deleted file mode 100644 index 12e023e9b..000000000 --- a/lib/fog/virtual_box/models/compute/storage_controllers.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'fog/core/collection' -require 'fog/virtual_box/models/compute/storage_controller' - -module Fog - module Compute - class VirtualBox - - class StorageControllers < Fog::Collection - - model Fog::Compute::VirtualBox::StorageController - - attr_accessor :machine - - def all - requires :machine - data = machine.instance_variable_get(:@raw).storage_controllers.map do |storage_controller| - {:raw => storage_controller} - end - load(data) - end - - def get(storage_controller_name) - requires :machine - all.detect do |storage_controller| - storage_controller.name == storage_controller_name - end - end - - def new(attributes = {}) - requires :machine - super({ :machine => machine }.merge!(attributes)) - end - - end - - end - end -end diff --git a/tests/helper.rb b/tests/helper.rb index 1d59c9a39..b5b67e615 100644 --- a/tests/helper.rb +++ b/tests/helper.rb @@ -18,7 +18,7 @@ end all_providers = Fog.registered_providers.map {|provider| provider.downcase} # Manually remove these providers since they are local applications, not lacking credentials -all_providers = all_providers - ["libvirt", "virtualbox", "vmfusion"] +all_providers = all_providers - ["libvirt", "vmfusion"] available_providers = Fog.available_providers.map {|provider| provider.downcase} From 9342298844d0067f5ffebea99be9173e31415bd4 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Sun, 17 Feb 2013 15:14:17 -0800 Subject: [PATCH 25/68] copy & paste to get Blocks LB API working --- lib/fog/bluebox/blb.rb | 77 +++++++++++++++++++ lib/fog/bluebox/models/blb/lb_application.rb | 21 +++++ lib/fog/bluebox/models/blb/lb_applications.rb | 32 ++++++++ lib/fog/bluebox/models/blb/lb_backend.rb | 22 ++++++ lib/fog/bluebox/models/blb/lb_backends.rb | 32 ++++++++ lib/fog/bluebox/models/blb/lb_service.rb | 24 ++++++ lib/fog/bluebox/models/blb/lb_services.rb | 32 ++++++++ .../requests/blb/get_lb_application.rb | 29 +++++++ .../requests/blb/get_lb_applications.rb | 29 +++++++ .../bluebox/requests/blb/get_lb_backend.rb | 30 ++++++++ .../bluebox/requests/blb/get_lb_backends.rb | 32 ++++++++ .../bluebox/requests/blb/get_lb_service.rb | 30 ++++++++ .../bluebox/requests/blb/get_lb_services.rb | 27 +++++++ 13 files changed, 417 insertions(+) create mode 100644 lib/fog/bluebox/blb.rb create mode 100644 lib/fog/bluebox/models/blb/lb_application.rb create mode 100644 lib/fog/bluebox/models/blb/lb_applications.rb create mode 100644 lib/fog/bluebox/models/blb/lb_backend.rb create mode 100644 lib/fog/bluebox/models/blb/lb_backends.rb create mode 100644 lib/fog/bluebox/models/blb/lb_service.rb create mode 100644 lib/fog/bluebox/models/blb/lb_services.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_application.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_applications.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_backend.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_backends.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_service.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_services.rb diff --git a/lib/fog/bluebox/blb.rb b/lib/fog/bluebox/blb.rb new file mode 100644 index 000000000..20a5d15f4 --- /dev/null +++ b/lib/fog/bluebox/blb.rb @@ -0,0 +1,77 @@ +require 'fog/bluebox' + +module Fog + module Bluebox + class BLB < Fog::Service + + requires :bluebox_api_key, :bluebox_customer_id + recognizes :bluebox_host, :bluebox_port, :bluebox_scheme, :persistent + + model_path 'fog/bluebox/models/blb' + + model :lb_application + collection :lb_applications + + model :lb_service + collection :lb_services + + model :lb_backend + collection :lb_backends + + + request_path 'fog/bluebox/requests/blb' + + request :get_lb_application + request :get_lb_applications + + request :get_lb_service + request :get_lb_services + + request :get_lb_backend + request :get_lb_backends + + class Mock + end + + class Real + def initialize(options={}) + @bluebox_api_key = options[:bluebox_api_key] + @bluebox_customer_id = options[:bluebox_customer_id] + @connection_options = options[:connection_options] || {} + @host = options[:bluebox_host] || "boxpanel.bluebox.net" + @persistent = options[:persistent] || false + @port = options[:bluebox_port] || 443 + @scheme = options[:bluebox_scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) + end + + def reload + @connection.reset + end + + def request(params) + params[:headers] ||= {} + params[:headers].merge!({ + 'Authorization' => "Basic #{Base64.encode64([@bluebox_customer_id, @bluebox_api_key].join(':')).delete("\r\n")}" + }) + + begin + response = @connection.request(params.merge!({:host => @host})) + rescue Excon::Errors::HTTPStatusError => error + raise case error + when Excon::Errors::NotFound + Fog::Compute::Bluebox::NotFound.slurp(error) + else + error + end + end + unless response.body.empty? + response.body = Fog::JSON.decode(response.body) + end + response + end + + end + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb new file mode 100644 index 000000000..bfc1b2199 --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -0,0 +1,21 @@ +require 'fog/core/model' + +module Fog + module Bluebox + class BLB + + class Application < Fog::Model + identity :id + + attribute :name + attribute :ip_v4 + attribute :ip_v6 + attribute :services + attribute :description + attribute :created, :aliases => 'created_at' + + end + + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb new file mode 100644 index 000000000..356de008a --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -0,0 +1,32 @@ +require 'fog/core/collection' + +module Fog + module Bluebox + class BLB + class Applications < Fog::Collection + + def all + data = service.get_blocks.body + load(data) + end + + def bootstrap(new_attributes = {}) + server = create(new_attributes) + server.wait_for { ready? } + server.setup(:key_data => [server.private_key]) + server + end + + def get(server_id) + if server_id && server = service.get_block(server_id).body + new(server) + end + rescue Fog::Compute::Bluebox::NotFound + nil + end + + end + + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_backend.rb b/lib/fog/bluebox/models/blb/lb_backend.rb new file mode 100644 index 000000000..8d07bbd39 --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_backend.rb @@ -0,0 +1,22 @@ +require 'fog/core/model' + +module Fog + module Bluebox + class BLB + + class Backend < Fog::Model + identity :id + + attribute :name + attribute :machines + attribute :monitoring_url + attribute :monitoring_url_hostname + attribute :acl_name + attribute :acl_rule + attribute :check_interval + + end + + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_backends.rb b/lib/fog/bluebox/models/blb/lb_backends.rb new file mode 100644 index 000000000..356de008a --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_backends.rb @@ -0,0 +1,32 @@ +require 'fog/core/collection' + +module Fog + module Bluebox + class BLB + class Applications < Fog::Collection + + def all + data = service.get_blocks.body + load(data) + end + + def bootstrap(new_attributes = {}) + server = create(new_attributes) + server.wait_for { ready? } + server.setup(:key_data => [server.private_key]) + server + end + + def get(server_id) + if server_id && server = service.get_block(server_id).body + new(server) + end + rescue Fog::Compute::Bluebox::NotFound + nil + end + + end + + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_service.rb b/lib/fog/bluebox/models/blb/lb_service.rb new file mode 100644 index 000000000..2a7031948 --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_service.rb @@ -0,0 +1,24 @@ +require 'fog/core/model' + +module Fog + module Bluebox + class BLB + + class Service < Fog::Model + identity :id + + attribute :name + attribute :port + attribute :backends + attribute :private + + attribute :status_url + attribute :status_username + attribute :status_password + attribute :created, :aliases => 'created_at' + + end + + end + end +end diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb new file mode 100644 index 000000000..356de008a --- /dev/null +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -0,0 +1,32 @@ +require 'fog/core/collection' + +module Fog + module Bluebox + class BLB + class Applications < Fog::Collection + + def all + data = service.get_blocks.body + load(data) + end + + def bootstrap(new_attributes = {}) + server = create(new_attributes) + server.wait_for { ready? } + server.setup(:key_data => [server.private_key]) + server + end + + def get(server_id) + if server_id && server = service.get_block(server_id).body + new(server) + end + rescue Fog::Compute::Bluebox::NotFound + nil + end + + end + + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_application.rb b/lib/fog/bluebox/requests/blb/get_lb_application.rb new file mode 100644 index 000000000..d38f57d91 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_application.rb @@ -0,0 +1,29 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get details of a lb_application. + # + # ==== Parameters + # * lb_application_id<~Integer> - Id of block to lookup + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # TODO + def get_lb_application(lb_application_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_applications/#{lb_application_id}.json" + ) + end + + end + + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_applications.rb b/lib/fog/bluebox/requests/blb/get_lb_applications.rb new file mode 100644 index 000000000..d81c2af05 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_applications.rb @@ -0,0 +1,29 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get list of blocks + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'ip-v4'<~Array> - Ip addresses + # * 'ip-v6'<~String> - IP v6 address + # * 'name'<~String> - The hostname + # * 'source-ip-v4'<~String> - Where traffic comes from + # * 'services'<~Array> - Listening services + def get_lb_applications + request( + :expects => 200, + :method => 'GET', + :path => 'api/lb_applications.json' + ) + end + + end + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_backend.rb b/lib/fog/bluebox/requests/blb/get_lb_backend.rb new file mode 100644 index 000000000..dcb78df1a --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_backend.rb @@ -0,0 +1,30 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get details of a lb_backend. + # + # ==== Parameters + # * lb_service_id - service backend belongs to + # * lb_backend_id<~Integer> - backend to look up + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # TODO + def get_lb_backend(lb_service_id, lb_backend_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_services/#{lb_service_id}/lb_backends/#{lb_backend_id}.json" + ) + end + + end + + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_backends.rb b/lib/fog/bluebox/requests/blb/get_lb_backends.rb new file mode 100644 index 000000000..ad423a05b --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_backends.rb @@ -0,0 +1,32 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get list of backends + # + # ==== Parameters + # * lb_service_id - service containing backends + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * 'ip-v4'<~Array> - Ip addresses + # * 'ip-v6'<~String> - IP v6 address + # * 'name'<~String> - The hostname + # * 'source-ip-v4'<~String> - Where traffic comes from + # * 'services'<~Array> - Listening services + def get_lb_backends(lb_service_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_services/#{lb_service_id}/lb_backends.json" + ) + end + + end + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_service.rb b/lib/fog/bluebox/requests/blb/get_lb_service.rb new file mode 100644 index 000000000..95bba6251 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_service.rb @@ -0,0 +1,30 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get details of a lb_service. + # + # ==== Parameters + # * lb_application_id<~String> - Id of application the service is in + # * lb_service_id<~String> - Id of service to lookup + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # TODO + def get_lb_service(lb_application_id, lb_service_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_applications/#{lb_application_id}/lb_services/#{lb_service_id}.json" + ) + end + + end + + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_services.rb b/lib/fog/bluebox/requests/blb/get_lb_services.rb new file mode 100644 index 000000000..f0db9d9fc --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_services.rb @@ -0,0 +1,27 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get list of load balancing services + # + # ==== Parameters + # * lb_application_id<~String> - Id of application services to list + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + def get_lb_services(lb_application_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_applications/#{lb_application_id}/lb_services.json" + ) + end + + end + class Mock + end + end + end +end From 129945dcb5d70bfa21fa1d0fe7a2ec8cb12b73e0 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Sun, 17 Feb 2013 15:14:48 -0800 Subject: [PATCH 26/68] register blb feature --- lib/fog/bin/bluebox.rb | 2 ++ lib/fog/bluebox.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/fog/bin/bluebox.rb b/lib/fog/bin/bluebox.rb index 9a28d2a43..0207e4581 100644 --- a/lib/fog/bin/bluebox.rb +++ b/lib/fog/bin/bluebox.rb @@ -7,6 +7,8 @@ class Bluebox < Fog::Bin Fog::Compute::Bluebox when :dns Fog::DNS::Bluebox + when :blb + Fog::Bluebox::BLB else raise ArgumentError, "Unsupported #{self} service: #{key}" end diff --git a/lib/fog/bluebox.rb b/lib/fog/bluebox.rb index 7ad96f535..fd731457b 100644 --- a/lib/fog/bluebox.rb +++ b/lib/fog/bluebox.rb @@ -5,6 +5,7 @@ module Fog extend Fog::Provider + service(:blb, 'bluebox/blb', 'BLB') service(:compute, 'bluebox/compute', 'Compute') service(:dns, 'bluebox/dns', 'DNS') From 16eba31509c213c65e3bb3a45d8f0be9d987c786 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 11:54:47 -0800 Subject: [PATCH 27/68] [bluebox|blb] clean up, define types returned --- .../requests/blb/get_lb_application.rb | 11 ++++++++--- .../requests/blb/get_lb_applications.rb | 18 ++++++++++-------- .../bluebox/requests/blb/get_lb_backend.rb | 17 ++++++++++++----- .../bluebox/requests/blb/get_lb_backends.rb | 19 ++++++++++++------- .../bluebox/requests/blb/get_lb_service.rb | 15 +++++++++++---- .../bluebox/requests/blb/get_lb_services.rb | 12 +++++++++++- 6 files changed, 64 insertions(+), 28 deletions(-) diff --git a/lib/fog/bluebox/requests/blb/get_lb_application.rb b/lib/fog/bluebox/requests/blb/get_lb_application.rb index d38f57d91..a505e329b 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_application.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_application.rb @@ -6,12 +6,17 @@ module Fog # Get details of a lb_application. # # ==== Parameters - # * lb_application_id<~Integer> - Id of block to lookup + # * lb_application_id<~Integer> - ID of application # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: - # TODO + # * 'id'<~String> - UUID of application + # * 'ip_v4'<~Array> - IPv4 addresses + # * 'ip_v6'<~String> - IPv6 address + # * 'name'<~String> - The hostname + # * 'lb_services'<~Array> - Listening services + # * 'source_ip_v4'<~String> - address that application connects to pool members from (v1 only) def get_lb_application(lb_application_id) request( :expects => 200, @@ -19,11 +24,11 @@ module Fog :path => "api/lb_applications/#{lb_application_id}.json" ) end - end class Mock end + end end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_applications.rb b/lib/fog/bluebox/requests/blb/get_lb_applications.rb index d81c2af05..5da65eef5 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_applications.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_applications.rb @@ -2,17 +2,18 @@ module Fog module Bluebox class BLB class Real - - # Get list of blocks + # Get list of applications # # ==== Returns # * response<~Excon::Response>: # * body<~Array>: - # * 'ip-v4'<~Array> - Ip addresses - # * 'ip-v6'<~String> - IP v6 address - # * 'name'<~String> - The hostname - # * 'source-ip-v4'<~String> - Where traffic comes from - # * 'services'<~Array> - Listening services + # * 'application'<~Hash>: + # * 'id'<~String> - UUID of application + # * 'ip_v4'<~Array> - IPv4 addresses + # * 'ip_v6'<~String> - IPv6 address + # * 'name'<~String> - The hostname + # * 'lb_services'<~Array> - Listening services + # * 'source_ip_v4'<~String> - address that application connects to pool members from (v1 only) def get_lb_applications request( :expects => 200, @@ -20,10 +21,11 @@ module Fog :path => 'api/lb_applications.json' ) end - end + class Mock end + end end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_backend.rb b/lib/fog/bluebox/requests/blb/get_lb_backend.rb index dcb78df1a..d89d610d1 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_backend.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_backend.rb @@ -3,16 +3,23 @@ module Fog class BLB class Real - # Get details of a lb_backend. + # Get details of an lb_backend. # # ==== Parameters - # * lb_service_id - service backend belongs to - # * lb_backend_id<~Integer> - backend to look up + # * lb_service_id<~String> - service backend belongs to + # * lb_backend_id<~String> - backend to look up # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: - # TODO + # * id<~String> - backend ID + # * backend_name<~String> + # * lb_machines<~Array> - array of backend members + # * acl_name<~String> - name of ACL for this backend + # * acl_rule<~String> + # * monitoring_url_hostname<~String> - HTTP host header for health check + # * monitoring_url<~String> - URL for health check + # * check_interval<~Integer> - time between checks, in milliseconds def get_lb_backend(lb_service_id, lb_backend_id) request( :expects => 200, @@ -20,11 +27,11 @@ module Fog :path => "api/lb_services/#{lb_service_id}/lb_backends/#{lb_backend_id}.json" ) end - end class Mock end + end end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_backends.rb b/lib/fog/bluebox/requests/blb/get_lb_backends.rb index ad423a05b..30f356ef5 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_backends.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_backends.rb @@ -6,16 +6,20 @@ module Fog # Get list of backends # # ==== Parameters - # * lb_service_id - service containing backends + # * lb_service_id<~String> - service containing backends # # ==== Returns # * response<~Excon::Response>: # * body<~Array>: - # * 'ip-v4'<~Array> - Ip addresses - # * 'ip-v6'<~String> - IP v6 address - # * 'name'<~String> - The hostname - # * 'source-ip-v4'<~String> - Where traffic comes from - # * 'services'<~Array> - Listening services + # * backend<~Hash>: + # * id<~String> - backend ID + # * backend_name<~String> + # * lb_machines<~Array> - array of backend members + # * acl_name<~String> - name of ACL for this backend + # * acl_rule<~String> + # * monitoring_url_hostname<~String> - HTTP host header for health check + # * monitoring_url<~String> - URL for health check + # * check_interval<~Integer> - time between checks, in milliseconds def get_lb_backends(lb_service_id) request( :expects => 200, @@ -23,10 +27,11 @@ module Fog :path => "api/lb_services/#{lb_service_id}/lb_backends.json" ) end - end + class Mock end + end end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_service.rb b/lib/fog/bluebox/requests/blb/get_lb_service.rb index 95bba6251..73ba39ccb 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_service.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_service.rb @@ -6,13 +6,20 @@ module Fog # Get details of a lb_service. # # ==== Parameters - # * lb_application_id<~String> - Id of application the service is in - # * lb_service_id<~String> - Id of service to lookup + # * lb_application_id<~String> - ID of application the service belongs to + # * lb_service_id<~String> - ID of service to look up # # ==== Returns # * response<~Excon::Response>: # * body<~Hash>: - # TODO + # * name<~String> - service name + # * port<~Integer> - port of load balanced service + # * private<~Boolean> - whether service is only available internally + # * status_username<~String> - HTTP basic auth username + # * status_password<~String> - HTTP basic auth password + # * status_url<~String> - URL of stats page + # * service_type<~String> - proto being load balanced (e.g. 'http', 'tcp') + # * created<~DateTime> - when service was created def get_lb_service(lb_application_id, lb_service_id) request( :expects => 200, @@ -20,11 +27,11 @@ module Fog :path => "api/lb_applications/#{lb_application_id}/lb_services/#{lb_service_id}.json" ) end - end class Mock end + end end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_services.rb b/lib/fog/bluebox/requests/blb/get_lb_services.rb index f0db9d9fc..99b8ba39f 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_services.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_services.rb @@ -11,6 +11,15 @@ module Fog # ==== Returns # * response<~Excon::Response>: # * body<~Array>: + # * backend<~Hash>: + # * name<~String> - service name + # * port<~Integer> - port of load balanced service + # * private<~Boolean> - whether service is only available internally + # * status_username<~String> - HTTP basic auth username + # * status_password<~String> - HTTP basic auth password + # * status_url<~String> - URL of stats page + # * service_type<~String> - proto being load balanced (e.g. 'http', 'tcp') + # * created<~DateTime> - when service was created def get_lb_services(lb_application_id) request( :expects => 200, @@ -18,10 +27,11 @@ module Fog :path => "api/lb_applications/#{lb_application_id}/lb_services.json" ) end - end + class Mock end + end end end From 95c1bad8673267aaf2f8dea9a0547f9b52a46790 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 14:29:58 -0800 Subject: [PATCH 28/68] [bluebox|blb] some cleanup of model stubs --- lib/fog/bluebox/models/blb/lb_application.rb | 2 +- lib/fog/bluebox/models/blb/lb_applications.rb | 11 ++--------- lib/fog/bluebox/models/blb/lb_service.rb | 2 +- lib/fog/bluebox/models/blb/lb_services.rb | 11 ++--------- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index bfc1b2199..75877da11 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -4,7 +4,7 @@ module Fog module Bluebox class BLB - class Application < Fog::Model + class LbApplication < Fog::Model identity :id attribute :name diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb index 356de008a..25f469168 100644 --- a/lib/fog/bluebox/models/blb/lb_applications.rb +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -3,20 +3,13 @@ require 'fog/core/collection' module Fog module Bluebox class BLB - class Applications < Fog::Collection + class LbApplications < Fog::Collection def all - data = service.get_blocks.body + data = service.get_lb_applications.body load(data) end - def bootstrap(new_attributes = {}) - server = create(new_attributes) - server.wait_for { ready? } - server.setup(:key_data => [server.private_key]) - server - end - def get(server_id) if server_id && server = service.get_block(server_id).body new(server) diff --git a/lib/fog/bluebox/models/blb/lb_service.rb b/lib/fog/bluebox/models/blb/lb_service.rb index 2a7031948..7d6e74302 100644 --- a/lib/fog/bluebox/models/blb/lb_service.rb +++ b/lib/fog/bluebox/models/blb/lb_service.rb @@ -4,7 +4,7 @@ module Fog module Bluebox class BLB - class Service < Fog::Model + class LbService < Fog::Model identity :id attribute :name diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 356de008a..882191509 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -3,20 +3,13 @@ require 'fog/core/collection' module Fog module Bluebox class BLB - class Applications < Fog::Collection + class LbServices < Fog::Collection def all - data = service.get_blocks.body + data = service.get_lb_services.body load(data) end - def bootstrap(new_attributes = {}) - server = create(new_attributes) - server.wait_for { ready? } - server.setup(:key_data => [server.private_key]) - server - end - def get(server_id) if server_id && server = service.get_block(server_id).body new(server) From d2b6cb2156b97951ad7531a00a6be6eae5192fe0 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 14:45:02 -0800 Subject: [PATCH 29/68] [bluebox|blb] add model to application and server collections --- lib/fog/bluebox/models/blb/lb_applications.rb | 1 + lib/fog/bluebox/models/blb/lb_services.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb index 25f469168..538daf25b 100644 --- a/lib/fog/bluebox/models/blb/lb_applications.rb +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -4,6 +4,7 @@ module Fog module Bluebox class BLB class LbApplications < Fog::Collection + model Fog::Bluebox::BLB::LbApplication def all data = service.get_lb_applications.body diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 882191509..43ef3d49a 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -4,6 +4,7 @@ module Fog module Bluebox class BLB class LbServices < Fog::Collection + model Fog::Bluebox::BLB::LbService def all data = service.get_lb_services.body From 66394634f51f3e91b0b37dabf04bac73d9f20f37 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 14:48:34 -0800 Subject: [PATCH 30/68] [bluebox|blb] require model --- lib/fog/bluebox/models/blb/lb_applications.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb index 538daf25b..7df6ff267 100644 --- a/lib/fog/bluebox/models/blb/lb_applications.rb +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -1,4 +1,5 @@ require 'fog/core/collection' +require 'fog/bluebox/models/blb/lb_application' module Fog module Bluebox From 86903bc1808f491c763fddeea817abac1f1e4196 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 14:52:42 -0800 Subject: [PATCH 31/68] [bluebox|blb] require model --- lib/fog/bluebox/models/blb/lb_services.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 43ef3d49a..403b95b79 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -1,4 +1,5 @@ require 'fog/core/collection' +require 'fog/bluebox/models/blb/lb_service' module Fog module Bluebox From 4ad8a92073532dfeb3ab091441b4dd36d9c89c59 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 15:47:46 -0800 Subject: [PATCH 32/68] [bluebox|blb] fix more stub/copypaste inanity --- lib/fog/bluebox/models/blb/lb_application.rb | 5 +++++ lib/fog/bluebox/models/blb/lb_applications.rb | 8 ++++---- lib/fog/bluebox/models/blb/lb_services.rb | 6 +++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index 75877da11..948521acb 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -14,6 +14,11 @@ module Fog attribute :description attribute :created, :aliases => 'created_at' + def services + requires :id + service.get_lb_services(id).body + end + end end diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb index 7df6ff267..9bb1d4e84 100644 --- a/lib/fog/bluebox/models/blb/lb_applications.rb +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -12,11 +12,11 @@ module Fog load(data) end - def get(server_id) - if server_id && server = service.get_block(server_id).body - new(server) + def get(application_id) + if application_id && application = service.get_lb_application(application_id).body + new(application) end - rescue Fog::Compute::Bluebox::NotFound + rescue Fog::Bluebox::BLB::NotFound nil end diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 403b95b79..5d2dd58e5 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -12,11 +12,11 @@ module Fog load(data) end - def get(server_id) - if server_id && server = service.get_block(server_id).body + def get(application_id, service_id) + if service_id && service = service.get_lb_services(service_id).body new(server) end - rescue Fog::Compute::Bluebox::NotFound + rescue Fog::Bluebox::BLB::NotFound nil end From d3c0dc2195449a2288c46657d1103ee91c0b9cc4 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 17:09:51 -0800 Subject: [PATCH 33/68] [bluebox|blb] lb_service collection implementation --- lib/fog/bluebox/models/blb/lb_application.rb | 8 ++++---- lib/fog/bluebox/models/blb/lb_service.rb | 4 ++++ lib/fog/bluebox/models/blb/lb_services.rb | 11 ++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index 948521acb..dd0800a0a 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -10,13 +10,13 @@ module Fog attribute :name attribute :ip_v4 attribute :ip_v6 - attribute :services attribute :description attribute :created, :aliases => 'created_at' - def services - requires :id - service.get_lb_services(id).body + def lb_services + Fog::Bluebox::BLB::LbServices.new({ + :lb_application => self + }) end end diff --git a/lib/fog/bluebox/models/blb/lb_service.rb b/lib/fog/bluebox/models/blb/lb_service.rb index 7d6e74302..d02db9f2a 100644 --- a/lib/fog/bluebox/models/blb/lb_service.rb +++ b/lib/fog/bluebox/models/blb/lb_service.rb @@ -19,6 +19,10 @@ module Fog end + def lb_application + collection.lb_application + end + end end end diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 5d2dd58e5..2fd6983b5 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -7,15 +7,16 @@ module Fog class LbServices < Fog::Collection model Fog::Bluebox::BLB::LbService + attr_accessor :data, :lb_application + def all - data = service.get_lb_services.body + data = service.get_lb_services(lb_application.id).body load(data) end - def get(application_id, service_id) - if service_id && service = service.get_lb_services(service_id).body - new(server) - end + def get(lb_service_id) + lb_service = service.get_lb_service(lb_application.id, lb_service_id).body + new(lb_service) rescue Fog::Bluebox::BLB::NotFound nil end From fa526b947e4f2efbd79765507c1bc2cf1dae8845 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 17:33:54 -0800 Subject: [PATCH 34/68] [bluebox|blb] service must be passed from caller --- lib/fog/bluebox/models/blb/lb_application.rb | 1 + lib/fog/bluebox/models/blb/lb_applications.rb | 1 - lib/fog/bluebox/models/blb/lb_services.rb | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index dd0800a0a..a9472efc1 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -15,6 +15,7 @@ module Fog def lb_services Fog::Bluebox::BLB::LbServices.new({ + :service => service, :lb_application => self }) end diff --git a/lib/fog/bluebox/models/blb/lb_applications.rb b/lib/fog/bluebox/models/blb/lb_applications.rb index 9bb1d4e84..7599ad2c8 100644 --- a/lib/fog/bluebox/models/blb/lb_applications.rb +++ b/lib/fog/bluebox/models/blb/lb_applications.rb @@ -1,4 +1,3 @@ -require 'fog/core/collection' require 'fog/bluebox/models/blb/lb_application' module Fog diff --git a/lib/fog/bluebox/models/blb/lb_services.rb b/lib/fog/bluebox/models/blb/lb_services.rb index 2fd6983b5..71ef06c42 100644 --- a/lib/fog/bluebox/models/blb/lb_services.rb +++ b/lib/fog/bluebox/models/blb/lb_services.rb @@ -7,7 +7,7 @@ module Fog class LbServices < Fog::Collection model Fog::Bluebox::BLB::LbService - attr_accessor :data, :lb_application + attr_accessor :lb_application def all data = service.get_lb_services(lb_application.id).body @@ -15,8 +15,9 @@ module Fog end def get(lb_service_id) - lb_service = service.get_lb_service(lb_application.id, lb_service_id).body - new(lb_service) + if lb_service = service.get_lb_service(lb_application.id, lb_service_id).body + new(lb_service) + end rescue Fog::Bluebox::BLB::NotFound nil end From d6cc6090e21a709bf4c0d7f632459b72d68a9121 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 18 Feb 2013 18:09:19 -0800 Subject: [PATCH 35/68] [bluebox|blb] atone for additional sins in the lb service and backend models --- lib/fog/bluebox/models/blb/lb_backend.rb | 4 ++-- lib/fog/bluebox/models/blb/lb_backends.rb | 22 ++++++++++------------ lib/fog/bluebox/models/blb/lb_service.rb | 17 ++++++++++++----- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/fog/bluebox/models/blb/lb_backend.rb b/lib/fog/bluebox/models/blb/lb_backend.rb index 8d07bbd39..3951a4143 100644 --- a/lib/fog/bluebox/models/blb/lb_backend.rb +++ b/lib/fog/bluebox/models/blb/lb_backend.rb @@ -4,11 +4,11 @@ module Fog module Bluebox class BLB - class Backend < Fog::Model + class LbBackend < Fog::Model identity :id attribute :name - attribute :machines + attribute :lb_machines attribute :monitoring_url attribute :monitoring_url_hostname attribute :acl_name diff --git a/lib/fog/bluebox/models/blb/lb_backends.rb b/lib/fog/bluebox/models/blb/lb_backends.rb index 356de008a..d111c83d6 100644 --- a/lib/fog/bluebox/models/blb/lb_backends.rb +++ b/lib/fog/bluebox/models/blb/lb_backends.rb @@ -1,25 +1,23 @@ require 'fog/core/collection' +require 'fog/bluebox/models/blb/lb_backend' module Fog module Bluebox class BLB - class Applications < Fog::Collection + class LbBackends < Fog::Collection + + model Fog::Bluebox::BLB::LbBackend + + attr_accessor :lb_service def all - data = service.get_blocks.body + data = service.get_lb_backends(lb_service.id).body load(data) end - def bootstrap(new_attributes = {}) - server = create(new_attributes) - server.wait_for { ready? } - server.setup(:key_data => [server.private_key]) - server - end - - def get(server_id) - if server_id && server = service.get_block(server_id).body - new(server) + def get(lb_backend_id) + if lb_backend = service.get_lb_backend(lb_service.id, lb_backend_id).body + new(lb_backend) end rescue Fog::Compute::Bluebox::NotFound nil diff --git a/lib/fog/bluebox/models/blb/lb_service.rb b/lib/fog/bluebox/models/blb/lb_service.rb index d02db9f2a..5d2ef9fa8 100644 --- a/lib/fog/bluebox/models/blb/lb_service.rb +++ b/lib/fog/bluebox/models/blb/lb_service.rb @@ -9,7 +9,7 @@ module Fog attribute :name attribute :port - attribute :backends + attribute :service_type attribute :private attribute :status_url @@ -17,12 +17,19 @@ module Fog attribute :status_password attribute :created, :aliases => 'created_at' - end - def lb_application - collection.lb_application - end + def lb_application + collection.lb_application + end + def lb_backends + Fog::Bluebox::BLB::LbBackends.new({ + :service => service, + :lb_service => self + }) + end + + end end end end From 1536a29b7352ac9baeb5108871923dea07380445 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Sun, 24 Feb 2013 16:43:21 -0800 Subject: [PATCH 36/68] [bluebox|blb] add last set of index requests for lb_machines --- .../bluebox/requests/blb/get_lb_machine.rb | 36 +++++++++++++++++++ .../bluebox/requests/blb/get_lb_machines.rb | 36 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 lib/fog/bluebox/requests/blb/get_lb_machine.rb create mode 100644 lib/fog/bluebox/requests/blb/get_lb_machines.rb diff --git a/lib/fog/bluebox/requests/blb/get_lb_machine.rb b/lib/fog/bluebox/requests/blb/get_lb_machine.rb new file mode 100644 index 000000000..56ef51ef6 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_machine.rb @@ -0,0 +1,36 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get details of an lb_machine. + # + # ==== Parameters + # * lb_backend_id<~String> - backend machine belongs to + # * lb_machine_id<~String> - machine to look up + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Hash>: + # * id<~String> - machine ID + # * ip<~String> - machine IP address for this member (v4 or v6) + # * port<~Integer> - service port for this member + # * hostname<~String> - name as registered with Box Panel + # * acl_name<~String> - name of ACL for this machine + # * created<~DateTime> - when machine was added to load balancer backend + # * maxconn<~Integer> - maximum concurrent connections for this member (BLBv2 only) + def get_lb_machine(lb_backend_id, lb_machine_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}.json" + ) + end + end + + class Mock + end + + end + end +end diff --git a/lib/fog/bluebox/requests/blb/get_lb_machines.rb b/lib/fog/bluebox/requests/blb/get_lb_machines.rb new file mode 100644 index 000000000..54c4d30a0 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/get_lb_machines.rb @@ -0,0 +1,36 @@ +module Fog + module Bluebox + class BLB + class Real + + # Get list of machines + # + # ==== Parameters + # * lb_backend_id<~String> - backend containing machines + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~Array>: + # * machine<~Hash>: + # * id<~String> - machine ID + # * ip<~String> - machine IP address for this member (v4 or v6) + # * port<~Integer> - service port for this member + # * hostname<~String> - name as registered with Box Panel + # * acl_name<~String> - name of ACL for this machine + # * created<~DateTime> - when machine was added to load balancer backend + # * maxconn<~Integer> - maximum concurrent connections for this member (BLBv2 only) + def get_lb_machines(lb_backend_id) + request( + :expects => 200, + :method => 'GET', + :path => "api/lb_backends/#{lb_backend_id}/lb_machines.json" + ) + end + end + + class Mock + end + + end + end +end From 17f6dc89f4f5d043e86f42550b53237b67a1d448 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Thu, 28 Feb 2013 18:24:11 -0800 Subject: [PATCH 37/68] [bluebox|blb] add_machine --- lib/fog/bluebox/blb.rb | 8 +++++ lib/fog/bluebox/models/blb/lb_application.rb | 5 +++ .../blb/add_machine_to_application.rb | 34 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 lib/fog/bluebox/requests/blb/add_machine_to_application.rb diff --git a/lib/fog/bluebox/blb.rb b/lib/fog/bluebox/blb.rb index 20a5d15f4..f54fe26ee 100644 --- a/lib/fog/bluebox/blb.rb +++ b/lib/fog/bluebox/blb.rb @@ -30,6 +30,14 @@ module Fog request :get_lb_backend request :get_lb_backends + request :add_machine_to_application + + request :add_machine_to_backend + + request :remove_machine_from_backend + + request :update_machine + class Mock end diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index a9472efc1..079f22696 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -13,6 +13,11 @@ module Fog attribute :description attribute :created, :aliases => 'created_at' + def add_machine(lb_machine_id, options) + requires :id + service.add_machine_to_application(id, lb_machine_id, options) + end + def lb_services Fog::Bluebox::BLB::LbServices.new({ :service => service, diff --git a/lib/fog/bluebox/requests/blb/add_machine_to_application.rb b/lib/fog/bluebox/requests/blb/add_machine_to_application.rb new file mode 100644 index 000000000..90440dafb --- /dev/null +++ b/lib/fog/bluebox/requests/blb/add_machine_to_application.rb @@ -0,0 +1,34 @@ +module Fog + module Bluebox + class BLB + class Real + # Add machine to default lb_backend for each lb_service + # in the application. + # + # === Parameters + # * lb_application_id<~String> - ID of application + # * lb_machine_id<~String> - ID of machine + # * options<~Hash>: + # * port<~Integer> - port machine listens on; defaults to service listening port + # * maxconn<~Integer> - maximum number of connections server can be sent + # * backup<~Boolean> - only send traffic to machine if all others are down + # + def add_machine_to_application(lb_application_id, lb_machine_id, options = {}) + # convert to CGI array args + body = Hash[options.map {|k,v| ["lb_options[#{k}]", v] }] + body['lb_machine'] = lb_machine_id + request( + :expects => 200, + :method => 'POST', + :path => "/api/lb_applications/add_machine/#{lb_application_id}.json", + :body => body.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') + ) + + end + end + + class Mock + end + end + end +end From 03f8dc77964f943460163afd8d5750c408b9a002 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Thu, 28 Feb 2013 19:05:38 -0800 Subject: [PATCH 38/68] [bluebox|blb] rename for consistency --- lib/fog/bluebox/blb.rb | 8 ++++---- lib/fog/bluebox/models/blb/lb_application.rb | 2 +- ...to_application.rb => add_machine_to_lb_application.rb} | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename lib/fog/bluebox/requests/blb/{add_machine_to_application.rb => add_machine_to_lb_application.rb} (92%) diff --git a/lib/fog/bluebox/blb.rb b/lib/fog/bluebox/blb.rb index f54fe26ee..d64e50f34 100644 --- a/lib/fog/bluebox/blb.rb +++ b/lib/fog/bluebox/blb.rb @@ -30,13 +30,13 @@ module Fog request :get_lb_backend request :get_lb_backends - request :add_machine_to_application + request :add_machine_to_lb_application - request :add_machine_to_backend + request :add_machine_to_lb_backend - request :remove_machine_from_backend + request :remove_machine_from_lb_backend - request :update_machine + request :update_lb_backend_machine class Mock end diff --git a/lib/fog/bluebox/models/blb/lb_application.rb b/lib/fog/bluebox/models/blb/lb_application.rb index 079f22696..4700c8cb6 100644 --- a/lib/fog/bluebox/models/blb/lb_application.rb +++ b/lib/fog/bluebox/models/blb/lb_application.rb @@ -15,7 +15,7 @@ module Fog def add_machine(lb_machine_id, options) requires :id - service.add_machine_to_application(id, lb_machine_id, options) + service.add_machine_to_lb_application(id, lb_machine_id, options) end def lb_services diff --git a/lib/fog/bluebox/requests/blb/add_machine_to_application.rb b/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb similarity index 92% rename from lib/fog/bluebox/requests/blb/add_machine_to_application.rb rename to lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb index 90440dafb..6fcb1ce2f 100644 --- a/lib/fog/bluebox/requests/blb/add_machine_to_application.rb +++ b/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb @@ -13,7 +13,7 @@ module Fog # * maxconn<~Integer> - maximum number of connections server can be sent # * backup<~Boolean> - only send traffic to machine if all others are down # - def add_machine_to_application(lb_application_id, lb_machine_id, options = {}) + def add_machine_to_lb_application(lb_application_id, lb_machine_id, options = {}) # convert to CGI array args body = Hash[options.map {|k,v| ["lb_options[#{k}]", v] }] body['lb_machine'] = lb_machine_id From 3c5fd770187946cd1625355de52fd54dac68cde6 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 10:35:12 -0800 Subject: [PATCH 39/68] [bluebox|blb] typo, whitespace --- lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_application.rb | 3 +-- lib/fog/bluebox/requests/blb/get_lb_backend.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_backends.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_machine.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_machines.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_service.rb | 1 - lib/fog/bluebox/requests/blb/get_lb_services.rb | 1 - 8 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb b/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb index 6fcb1ce2f..ed3f9b712 100644 --- a/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb +++ b/lib/fog/bluebox/requests/blb/add_machine_to_lb_application.rb @@ -23,7 +23,6 @@ module Fog :path => "/api/lb_applications/add_machine/#{lb_application_id}.json", :body => body.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') ) - end end diff --git a/lib/fog/bluebox/requests/blb/get_lb_application.rb b/lib/fog/bluebox/requests/blb/get_lb_application.rb index a505e329b..f37ff1916 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_application.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_application.rb @@ -2,8 +2,7 @@ module Fog module Bluebox class BLB class Real - - # Get details of a lb_application. + # Get details of an lb_application. # # ==== Parameters # * lb_application_id<~Integer> - ID of application diff --git a/lib/fog/bluebox/requests/blb/get_lb_backend.rb b/lib/fog/bluebox/requests/blb/get_lb_backend.rb index d89d610d1..7f2020446 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_backend.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_backend.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get details of an lb_backend. # # ==== Parameters diff --git a/lib/fog/bluebox/requests/blb/get_lb_backends.rb b/lib/fog/bluebox/requests/blb/get_lb_backends.rb index 30f356ef5..12a8ab812 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_backends.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_backends.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get list of backends # # ==== Parameters diff --git a/lib/fog/bluebox/requests/blb/get_lb_machine.rb b/lib/fog/bluebox/requests/blb/get_lb_machine.rb index 56ef51ef6..cebed3d45 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_machine.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_machine.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get details of an lb_machine. # # ==== Parameters diff --git a/lib/fog/bluebox/requests/blb/get_lb_machines.rb b/lib/fog/bluebox/requests/blb/get_lb_machines.rb index 54c4d30a0..716c981c9 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_machines.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_machines.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get list of machines # # ==== Parameters diff --git a/lib/fog/bluebox/requests/blb/get_lb_service.rb b/lib/fog/bluebox/requests/blb/get_lb_service.rb index 73ba39ccb..43d1984ef 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_service.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_service.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get details of a lb_service. # # ==== Parameters diff --git a/lib/fog/bluebox/requests/blb/get_lb_services.rb b/lib/fog/bluebox/requests/blb/get_lb_services.rb index 99b8ba39f..d5d36fdf4 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_services.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_services.rb @@ -2,7 +2,6 @@ module Fog module Bluebox class BLB class Real - # Get list of load balancing services # # ==== Parameters From e6313cafe262e3abb59a1671db44f8dd2e3b21e0 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 10:37:11 -0800 Subject: [PATCH 40/68] [bluebox|blb] lb_machine API coverage --- .../requests/blb/add_machine_to_lb_backend.rb | 30 +++++++++++++++++++ .../blb/remove_machine_from_lb_backend.rb | 27 +++++++++++++++++ .../requests/blb/update_lb_backend_machine.rb | 29 ++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb create mode 100644 lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb create mode 100644 lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb diff --git a/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb b/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb new file mode 100644 index 000000000..9a20a0c51 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb @@ -0,0 +1,30 @@ +module Fog + module Bluebox + class BLB + class Real + # Add machine to specified lb_backend + # + # === Parameters + # * lb_backend_id<~String> - ID of backend + # * lb_machine_id<~String> - ID of machine + # * options<~Hash>: + # * port<~Integer> - port machine listens on; defaults to service listening port + # * maxconn<~Integer> - maximum number of connections server can be sent + # * backup<~Boolean> - only send traffic to machine if all others are down + def add_machine_to_lb_backend(lb_backend_id, lb_machine_id, options = {}) + # convert to CGI array args + body = Hash[options.map {|k,v| ["lb_options[#{k}]", v] }] + body['lb_machine'] = lb_machine_id + request( + :expects => 200, + :method => 'POST', + :path => "/api/lb_backends/#{lb_backend_id}/lb_machines.json", + :body => body.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') + ) + end + + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb b/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb new file mode 100644 index 000000000..d2d8269d5 --- /dev/null +++ b/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb @@ -0,0 +1,27 @@ +module Fog + module Bluebox + class BLB + class Real + # remove machine from single backend + # + # === Parameters + # * lb_backend_id<~String> - ID of backend + # * lb_machine_id<~String> - ID of machine + # + # ==== Returns + # * response<~Excon::Response>: + # * body<~String> - success or failure message + def remove_machine_from_lb_backend(lb_backend_id, lb_machine_id) + request( + :expects => 200, + :method => 'DELETE', + :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}" + ) + end + end + + class Mock + end + end + end +end diff --git a/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb new file mode 100644 index 000000000..57ff90b6d --- /dev/null +++ b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb @@ -0,0 +1,29 @@ +module Fog + module Bluebox + class BLB + class Real + # change machine attributes (port &c) in a single backend + # + # === Parameters + # * lb_backend_id<~String> - ID of backend + # * lb_machine_id<~String> - ID of machine + # * options<~Hash>: + # * port<~Integer> - port machine listens on + # * maxconn<~Integer> - maximum number of connections server can be sent + # * backup<~Boolean> - only send traffic to machine if all others are down + def update_lb_backend_machine(lb_backend_id, lb_machine_id, options = {}) + # inconsistent, no? + request( + :expects => 200, + :method => 'PUT', + :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}" + :body => options.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') + ) + end + end + + class Mock + end + end + end +end From 1cee25c8868f68a3d3d6a9947c20714dfc0c36c1 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 13:10:30 -0800 Subject: [PATCH 41/68] [bluebox|blb] missing end --- lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb b/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb index 9a20a0c51..2ab46bea3 100644 --- a/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb +++ b/lib/fog/bluebox/requests/blb/add_machine_to_lb_backend.rb @@ -21,6 +21,7 @@ module Fog :path => "/api/lb_backends/#{lb_backend_id}/lb_machines.json", :body => body.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') ) + end end class Mock From a5e2542db4bdd287fb9a083048e2d98fdb0adddb Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 14:34:33 -0800 Subject: [PATCH 42/68] [bluebox|blb] testing stubs --- tests/bluebox/requests/blb/helper.rb | 21 +++++++++++++++++++++ tests/bluebox/requests/blb/lb_test.rb | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/bluebox/requests/blb/helper.rb create mode 100644 tests/bluebox/requests/blb/lb_test.rb diff --git a/tests/bluebox/requests/blb/helper.rb b/tests/bluebox/requests/blb/helper.rb new file mode 100644 index 000000000..86e078eaf --- /dev/null +++ b/tests/bluebox/requests/blb/helper.rb @@ -0,0 +1,21 @@ +class Bluebox + module BLB + module Formats + LB_APPLICATION = { + 'id' => String, + 'ip_v4' => String, + 'ip_v6' => String, + 'name' => String, + 'lb_services' => Array, + 'source_ip_v4' => Fog::Nullable::String, + } + + ADD_MACHINE_TO_LB = { + 'status' => String, + 'text' => String, + } + + REMOVE_MACHINE_FROM_BACKEND = 'Record Removed.' + end + end +end diff --git a/tests/bluebox/requests/blb/lb_test.rb b/tests/bluebox/requests/blb/lb_test.rb new file mode 100644 index 000000000..7dfbf3400 --- /dev/null +++ b/tests/bluebox/requests/blb/lb_test.rb @@ -0,0 +1,9 @@ +Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do + pending if Fog.mocking? + + tests('success') do + end + + tests('failure') do + end +end From f837f6f644bc474f278222c3e155dbccbeee4fec Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 15:44:17 -0800 Subject: [PATCH 43/68] [bluebox|blb] rename to tests, plural --- tests/bluebox/requests/blb/{lb_test.rb => lb_tests.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/bluebox/requests/blb/{lb_test.rb => lb_tests.rb} (100%) diff --git a/tests/bluebox/requests/blb/lb_test.rb b/tests/bluebox/requests/blb/lb_tests.rb similarity index 100% rename from tests/bluebox/requests/blb/lb_test.rb rename to tests/bluebox/requests/blb/lb_tests.rb From 44ac2274d58c5c0e96b8648b062955f774913eaf Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 16:21:37 -0800 Subject: [PATCH 44/68] [bluebox|blb] more request tests, missing comma --- .../bluebox/requests/blb/get_lb_service.rb | 1 + .../requests/blb/update_lb_backend_machine.rb | 2 +- tests/bluebox/requests/blb/helper.rb | 17 ++++++++++ tests/bluebox/requests/blb/lb_tests.rb | 34 +++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/fog/bluebox/requests/blb/get_lb_service.rb b/lib/fog/bluebox/requests/blb/get_lb_service.rb index 43d1984ef..af70ffe04 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_service.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_service.rb @@ -24,6 +24,7 @@ module Fog :expects => 200, :method => 'GET', :path => "api/lb_applications/#{lb_application_id}/lb_services/#{lb_service_id}.json" + :parser => Fog::Parsers::Bluebox::BLB::LbService.new ) end end diff --git a/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb index 57ff90b6d..81bfb6a01 100644 --- a/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb +++ b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb @@ -16,7 +16,7 @@ module Fog request( :expects => 200, :method => 'PUT', - :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}" + :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}", :body => options.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') ) end diff --git a/tests/bluebox/requests/blb/helper.rb b/tests/bluebox/requests/blb/helper.rb index 86e078eaf..0e845722b 100644 --- a/tests/bluebox/requests/blb/helper.rb +++ b/tests/bluebox/requests/blb/helper.rb @@ -10,6 +10,23 @@ class Bluebox 'source_ip_v4' => Fog::Nullable::String, } + LB_APPLICATIONS = [LB_APPLICATION] + + LB_SERVICE = { + 'name' => String, + 'port' => Integer, + 'private' => Fog::Boolean, + 'status_username' => String, + 'status_password' => String, + 'status_url' => String, + 'service_type' => String, + 'created' => DateTime, + 'lb_backends' => Array, + 'pem_file_uploaded?' => Fog::Nullable::Boolean, + } + + LB_SERVICES = [LB_SERVICE] + ADD_MACHINE_TO_LB = { 'status' => String, 'text' => String, diff --git a/tests/bluebox/requests/blb/lb_tests.rb b/tests/bluebox/requests/blb/lb_tests.rb index 7dfbf3400..79fb687bb 100644 --- a/tests/bluebox/requests/blb/lb_tests.rb +++ b/tests/bluebox/requests/blb/lb_tests.rb @@ -1,7 +1,41 @@ +require 'securerandom' + Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do pending if Fog.mocking? tests('success') do + @flavor_id = compute_providers[:bluebox][:server_attributes][:flavor_id] + @image_id = compute_providers[:bluebox][:server_attributes][:image_id] + @location_id = compute_providers[:bluebox][:server_attributes][:location_id] + @password = SecureRandom.base64(18) + + @lb_applications = nil + + tests("get_lb_applications").formats(Bluebox::BLB::Formats::LB_APPLICATIONS) do + @lb_applications = Fog::Bluebox[:blb].get_lb_applications.body + end + + tests("get_lb_application").formats(Bluebox::BLB::Formats::LB_APPLICATION) do + Fog::Bluebox[:blb].get_lb_application(@lb_applications.first['id']).body + end + + tests("get_lb_services").formats(Bluebox::BLB::Formats::LB_SERVICES) do + @lb_services = Fog::Bluebox[:blb].get_lb_services(@lb_applications.first['id']).body + end + + tests("get_lb_service").formats(Bluebox::BLB::Formats::LB_SERVICE) do + Fog::Bluebox[:blb].get_lb_service(@lb_applications.first['id'], @lb_services.first['id']).body + end + + tests("get_lb_backends").formats(Bluebox::BLB::Formats::LB_BACKEND) do + end + + tests("get_lb_backend").formats(Bluebox::BLB::Formats::LB_BACKEND) do + end + #data = Fog::Compute[:bluebox].create_block(@flavor_id, @image_id, @location_id, {'password' => @password}).body + #@block_id = data['id'] + #Fog::Compute[:bluebox].servers.get(@block_id).wait_for { ready? } + #Fog::Compute[:bluebox].destroy_block(@block_id).body end tests('failure') do From c240aadc85cc109aed6913b0c888e3b55cf142fe Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 16:33:47 -0800 Subject: [PATCH 45/68] [bluebox|blb] parsing is hard, let's go shopping --- lib/fog/bluebox/requests/blb/get_lb_service.rb | 3 +-- tests/bluebox/requests/blb/helper.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fog/bluebox/requests/blb/get_lb_service.rb b/lib/fog/bluebox/requests/blb/get_lb_service.rb index af70ffe04..082d2f466 100644 --- a/lib/fog/bluebox/requests/blb/get_lb_service.rb +++ b/lib/fog/bluebox/requests/blb/get_lb_service.rb @@ -23,8 +23,7 @@ module Fog request( :expects => 200, :method => 'GET', - :path => "api/lb_applications/#{lb_application_id}/lb_services/#{lb_service_id}.json" - :parser => Fog::Parsers::Bluebox::BLB::LbService.new + :path => "api/lb_applications/#{lb_application_id}/lb_services/#{lb_service_id}.json", ) end end diff --git a/tests/bluebox/requests/blb/helper.rb b/tests/bluebox/requests/blb/helper.rb index 0e845722b..ea1358c0b 100644 --- a/tests/bluebox/requests/blb/helper.rb +++ b/tests/bluebox/requests/blb/helper.rb @@ -20,7 +20,7 @@ class Bluebox 'status_password' => String, 'status_url' => String, 'service_type' => String, - 'created' => DateTime, + 'created' => String, 'lb_backends' => Array, 'pem_file_uploaded?' => Fog::Nullable::Boolean, } From 29e118619e5e8801fc0890db91c38c5774f41219 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 18:53:19 -0800 Subject: [PATCH 46/68] [bluebox|blb] account for text/plain endpoint --- lib/fog/bluebox/blb.rb | 2 +- lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fog/bluebox/blb.rb b/lib/fog/bluebox/blb.rb index d64e50f34..c6f9de499 100644 --- a/lib/fog/bluebox/blb.rb +++ b/lib/fog/bluebox/blb.rb @@ -73,7 +73,7 @@ module Fog error end end - unless response.body.empty? + unless response.body.empty? || params[:headers]['Accept'] == 'text/plain' response.body = Fog::JSON.decode(response.body) end response diff --git a/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb b/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb index d2d8269d5..b80fb602a 100644 --- a/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb +++ b/lib/fog/bluebox/requests/blb/remove_machine_from_lb_backend.rb @@ -15,7 +15,8 @@ module Fog request( :expects => 200, :method => 'DELETE', - :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}" + :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}", + :headers => {"Accept" => "text/plain"}, ) end end From 6a819ce0e397436822d9cf5786c1be1108a6730c Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Mon, 4 Mar 2013 18:54:04 -0800 Subject: [PATCH 47/68] [bluebox|blb] update tests --- .../requests/blb/update_lb_backend_machine.rb | 2 +- tests/bluebox/requests/blb/helper.rb | 32 +++++++++++-- tests/bluebox/requests/blb/lb_tests.rb | 46 ++++++++++++++++--- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb index 81bfb6a01..65f2001a7 100644 --- a/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb +++ b/lib/fog/bluebox/requests/blb/update_lb_backend_machine.rb @@ -14,7 +14,7 @@ module Fog def update_lb_backend_machine(lb_backend_id, lb_machine_id, options = {}) # inconsistent, no? request( - :expects => 200, + :expects => 202, :method => 'PUT', :path => "/api/lb_backends/#{lb_backend_id}/lb_machines/#{lb_machine_id}", :body => options.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v.to_s)}"}.join('&') diff --git a/tests/bluebox/requests/blb/helper.rb b/tests/bluebox/requests/blb/helper.rb index ea1358c0b..18dfd9054 100644 --- a/tests/bluebox/requests/blb/helper.rb +++ b/tests/bluebox/requests/blb/helper.rb @@ -27,11 +27,37 @@ class Bluebox LB_SERVICES = [LB_SERVICE] - ADD_MACHINE_TO_LB = { - 'status' => String, - 'text' => String, + LB_BACKEND = { + 'id' => String, + 'backend_name' => String, + 'lb_machines' => Array, + 'acl_name' => String, + 'acl_name' => String, + 'monitoring_url_hostname' => String, + 'monitoring_url' => String, + 'monitoring_url_hostname' => String, + 'check_interval' => Integer, + 'rise' => Fog::Nullable::Integer, + 'order' => Fog::Nullable::Integer, + 'fall' => Fog::Nullable::Integer, } + LB_BACKENDS = [LB_BACKEND] + + LB_MACHINE = { + 'port' => Integer, + 'id' => String, + 'ip' => String, + 'maxconn' => Integer, + 'hostname' => String, + 'created' => String, + } + + ADD_MACHINE_TO_LB = [ + { 'text' => String }, + { 'status' => String }, + ] + REMOVE_MACHINE_FROM_BACKEND = 'Record Removed.' end end diff --git a/tests/bluebox/requests/blb/lb_tests.rb b/tests/bluebox/requests/blb/lb_tests.rb index 79fb687bb..eabc28cde 100644 --- a/tests/bluebox/requests/blb/lb_tests.rb +++ b/tests/bluebox/requests/blb/lb_tests.rb @@ -9,8 +9,6 @@ Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do @location_id = compute_providers[:bluebox][:server_attributes][:location_id] @password = SecureRandom.base64(18) - @lb_applications = nil - tests("get_lb_applications").formats(Bluebox::BLB::Formats::LB_APPLICATIONS) do @lb_applications = Fog::Bluebox[:blb].get_lb_applications.body end @@ -27,17 +25,51 @@ Shindo.tests('Bluebox::BLB | lb_tests', ['bluebox']) do Fog::Bluebox[:blb].get_lb_service(@lb_applications.first['id'], @lb_services.first['id']).body end - tests("get_lb_backends").formats(Bluebox::BLB::Formats::LB_BACKEND) do + tests("get_lb_backends").formats(Bluebox::BLB::Formats::LB_BACKENDS) do + @lb_backends = Fog::Bluebox[:blb].get_lb_backends(@lb_services.first['id']).body end tests("get_lb_backend").formats(Bluebox::BLB::Formats::LB_BACKEND) do + Fog::Bluebox[:blb].get_lb_backend(@lb_services.first['id'], @lb_backends.first['id']).body end - #data = Fog::Compute[:bluebox].create_block(@flavor_id, @image_id, @location_id, {'password' => @password}).body - #@block_id = data['id'] - #Fog::Compute[:bluebox].servers.get(@block_id).wait_for { ready? } - #Fog::Compute[:bluebox].destroy_block(@block_id).body + + # create block + data = Fog::Compute[:bluebox].create_block(@flavor_id, @image_id, @location_id, {'password' => @password}).body + @block_id = data['id'] + Fog::Compute[:bluebox].servers.get(@block_id).wait_for { ready? } + + tests("add_machine_to_lb_application").formats(Bluebox::BLB::Formats::ADD_MACHINE_TO_LB) do + Fog::Bluebox[:blb].add_machine_to_lb_application(@lb_applications.first['id'], @block_id).body + end + + @default_backend = @lb_backends.select { |x| x['backend_name'] == 'default' }.first + @id_in_backend = @default_backend['lb_machines'].last['id'] + @machine_opts = { 'port' => 4361, 'backup' => true }; + tests("update_lb_backend_machine(#{@lb_backends.first['id']}, #{@id_in_backend}, #{@machine_opts})").formats(Bluebox::BLB::Formats::LB_MACHINE) do + Fog::Bluebox[:blb].update_lb_backend_machine(@lb_backends.first['id'], @id_in_backend, @machine_opts).body + end + + tests("remove_machine_from_lb_backend(#{@default_backend['id']}, #{@id_in_backend})").formats(Bluebox::BLB::Formats::REMOVE_MACHINE_FROM_BACKEND) do + Fog::Bluebox[:blb].remove_machine_from_lb_backend(@default_backend['id'], @id_in_backend).body + end + + tests("add_machine_to_lb_backend(#{@default_backend['id']}, #{@block_id})").formats(Bluebox::BLB::Formats::ADD_MACHINE_TO_LB) do + Fog::Bluebox[:blb].add_machine_to_lb_backend(@default_backend['id'], @block_id).body + end + + Fog::Compute[:bluebox].destroy_block(@block_id).body + end tests('failure') do + tests('get_lb_application').raises(Fog::Compute::Bluebox::NotFound) do + Fog::Bluebox[:blb].get_lb_application('00000000-0000-0000-0000-000000000000') + end + tests('get_lb_service').raises(Fog::Compute::Bluebox::NotFound) do + Fog::Bluebox[:blb].get_lb_service('00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000') + end + tests('get_lb_backend').raises(Fog::Compute::Bluebox::NotFound) do + Fog::Bluebox[:blb].get_lb_backend('00000000-0000-0000-0000-000000000000','00000000-0000-0000-0000-000000000000') + end end end From 09b505768d786ae875c7bd746c253cbe4ed432a2 Mon Sep 17 00:00:00 2001 From: Ferran Rodenas Date: Tue, 5 Mar 2013 12:51:06 +0100 Subject: [PATCH 48/68] [openstack|network] Add endpoint_type option --- lib/fog/openstack/network.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fog/openstack/network.rb b/lib/fog/openstack/network.rb index 2d84c0574..35cf4d979 100644 --- a/lib/fog/openstack/network.rb +++ b/lib/fog/openstack/network.rb @@ -7,7 +7,7 @@ module Fog requires :openstack_auth_url recognizes :openstack_auth_token, :openstack_management_url, :persistent, :openstack_service_type, :openstack_service_name, :openstack_tenant, - :openstack_api_key, :openstack_username, + :openstack_api_key, :openstack_username, :openstack_endpoint_type, :current_user, :current_tenant ## MODELS @@ -120,6 +120,7 @@ module Fog @openstack_must_reauthenticate = false @openstack_service_type = options[:openstack_service_type] || ['network'] @openstack_service_name = options[:openstack_service_name] + @openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL' @connection_options = options[:connection_options] || {} @@ -192,7 +193,7 @@ module Fog :openstack_auth_token => @openstack_auth_token, :openstack_service_type => @openstack_service_type, :openstack_service_name => @openstack_service_name, - :openstack_endpoint_type => 'adminURL' + :openstack_endpoint_type => @openstack_endpoint_type } credentials = Fog::OpenStack.authenticate_v2(options, @connection_options) From b52d8912f9d7174d0ec09e9608893484a40fa51f Mon Sep 17 00:00:00 2001 From: Ferran Rodenas Date: Tue, 5 Mar 2013 13:16:38 +0100 Subject: [PATCH 49/68] [openstack|image] Check for glance version (fog only supports v1) --- lib/fog/openstack/image.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/fog/openstack/image.rb b/lib/fog/openstack/image.rb index 76c7a2a1e..74eec7f07 100644 --- a/lib/fog/openstack/image.rb +++ b/lib/fog/openstack/image.rb @@ -206,6 +206,10 @@ module Fog @host = uri.host @path = uri.path @path.sub!(/\/$/, '') + unless @path.match(/v1(\.1)*/) + raise Fog::OpenStack::Errors::ServiceUnavailable.new( + "OpenStack binding only supports version 1.1 (a.k.a. 1)") + end @port = uri.port @scheme = uri.scheme true From d9da7964ac761386be6fca69f5a2b3521af00b85 Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 5 Mar 2013 11:25:39 -0600 Subject: [PATCH 50/68] Release 1.10.0 --- changelog.txt | 743 +++++++++++++++++++++++++++++++++++++++++++++ fog.gemspec | 4 +- lib/fog/version.rb | 2 +- 3 files changed, 746 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8c019384f..f92603dad 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,746 @@ +1.10.0 03/05/2013 2f30de2ab357a5bbdb505b94ada8aa637ba936f5 +========================================================== + +Stats! { 'collaborators' => 45, 'downloads' => 1813647, 'forks' => 720, 'open_issues' => 117, 'watchers' => 2386 } + +MVP! Rupak Ganguly + +[Brightbox] + Adds update firewall request. thanks Paul Thornthwaite + Adds compatibility mode to template. thanks Paul Thornthwaite + Updates to requests. thanks Paul Thornthwaite + +[Glesys] + Template list request does not take options. thanks Simon Gate + Only make one request when fetching templates. thanks Simon Gate + Fix template attributes, now they work. thanks Simon Gate + Attribute :keepip removed from server model. thanks Simon Gate + Clean up attributes on server model. thanks Simon Gate + Add public_ip_method to server model. thanks Simon Gate + Add setup method to copy fog ssh keys to server. thanks Simon Gate + Wrap ssh method to use rootpassword if present. thanks Simon Gate + +[HP] + Add BlockStorage provider and add volumes and snapshots support. Add support for bootable volumes, persistent server, cross-tenant acls and temp urls. Add support for Windows instances. Merge the latest code from fog 1.9.0 release. thanks Rupak Ganguly + +[HP|storage] + Fix generate_object_temp_url to use signer that is backward compatible to 1.8.7. thanks Rupak Ganguly + +[Rackspace|Compute] + fixed issue with bootstrap method where server was ready, but it had not received an ipv4 address yet. Added check for ip address in server ready block as well as a timeout parameter. thanks Kyle Rames + +[Rackspace|Storage] + This tests consistently fails on either ruby 1.8.7 or ruby 1.9.3 because hash order is indeterminate. I believe the spirt of this test is to ensure that only one header value is generated and thus I have updated the test to reflect that. thanks Kyle Rames + +[aws] + Fixes typo in fetching credentials error. thanks Paul Thornthwaite + Fixes security group template. thanks Paul Thornthwaite + +[aws|compute] + Fixes schema in image tests. thanks Paul Thornthwaite + +[aws|dynamodb] + fix port to match https default closes #1531. thanks geemus + +[aws|rds] + remove some superfluous reloads, hopefully help with travis test timing issues. thanks geemus + +[aws|storage] + Fixes Yard tags. thanks Paul Thornthwaite + +[bluebox|blb] + clean up, define types returned. thanks Josh Yotty + some cleanup of model stubs. thanks Josh Yotty + add model to application and server collections. thanks Josh Yotty + require model. thanks Josh Yotty + require model. thanks Josh Yotty + fix more stub/copypaste inanity. thanks Josh Yotty + lb_service collection implementation. thanks Josh Yotty + service must be passed from caller. thanks Josh Yotty + atone for additional sins in the lb service and backend models. thanks Josh Yotty + add last set of index requests for lb_machines. thanks Josh Yotty + add_machine. thanks Josh Yotty + rename for consistency. thanks Josh Yotty + typo, whitespace. thanks Josh Yotty + lb_machine API coverage. thanks Josh Yotty + missing end. thanks Josh Yotty + testing stubs. thanks Josh Yotty + rename to tests, plural. thanks Josh Yotty + more request tests, missing comma. thanks Josh Yotty + parsing is hard, let's go shopping. thanks Josh Yotty + account for text/plain endpoint. thanks Josh Yotty + update tests. thanks Josh Yotty + +[core] + Uses Logger deprecation for Compute.new. thanks Paul Thornthwaite + Fix display_stdout to process multiple lines output. thanks Rupak Ganguly + +[dreamhost|dns] + remove connection deprecation notices. thanks Sergio Rubio + Use the new fog-dream.com domain for testing. thanks Sergio Rubio + remove silly debugging code. thanks Sergio Rubio + do not delete the do-not-delete record when testing. thanks Sergio Rubio + added test helpers. thanks Sergio Rubio + Added README.md file documenting testing procedure. thanks Sergio Rubio + Removed get_record request. thanks Sergio Rubio + refactor dns requests tests. thanks Sergio Rubio + added Record model tests, fix Record.save. thanks Sergio Rubio + record tests fixes. thanks Sergio Rubio + Emulate zone model and collection, added tests. thanks Sergio Rubio + Do not add duplicated zones to the Zones collection. thanks Sergio Rubio + Moved getting started guide to examples/dns. thanks Sergio Rubio + Zone.records: list only records matching the current zone. thanks Sergio Rubio + Updated testing documentation. thanks Sergio Rubio + Updated Dreamhost/DNS getting started guide. thanks Sergio Rubio + drop uuid gem requirements, not needed. thanks Sergio Rubio + drop uuid gem dep from fog.gemspec. thanks Sergio Rubio + Add dreamhost to the list of providers. thanks Sergio Rubio + +[dreamhost|docs] + Added getting started guide, initial release. thanks Sergio Rubio + +[dremhost|dns] + added DNS service tests. thanks Sergio Rubio + +[ecloud] + fixed object returns in mock. thanks Eugene Howe + +[fog] + Typo fixed in identity. thanks Anshul Khandelwal + Cleanup: Use the service registry for requiring libs where possible. thanks Anshul Khandelwal + +[glesys] + Add description to server model. thanks Simon Gate + Ability to pass in options to server details. thanks Simon Gate + Consistent naming of attributes. thanks Simon Gate + ip details should be ip details, not listfree. thanks Simon Gate + Fix ip model name to match nameing convention. thanks Simon Gate + Fix ip attributes, they didn't work. thanks Simon Gate + Return nil if there isn't any public ip address. thanks Simon Gate + Refactor the ip interface, did not work earlier. thanks Simon Gate + add take method to ip model. thanks Simon Gate + Fix error in ip tests. thanks Simon Gate + Make compute test pass. thanks Simon Gate + Attributes were overwritten when getting server details. thanks Simon Gate + Fix bug when trying to attach a ip to a server. thanks Simon Gate + Platform methods to templates. thanks Simon Gate + Rename template model to match Fog convention. thanks Simon Gate + Remove unused features from template model. thanks Simon Gate + +[hp/openstack|compute] + remove erroneous block argument to get_object; fixes issue #1588 for OpenStack and HP. thanks Kyle Rames + +[libvirt|volume] + Fix typo in image_suffix. thanks David Wittman + +[misc] + Enable ebs-optimized spot instance requests. thanks Adam Bozanich + test spot instance request parser. thanks Adam Bozanich + add internet_archive to fog providers, bin, storage. thanks Andrew Kuklewicz + and internet_archive code, tests. thanks Andrew Kuklewicz + fix testing mock. thanks Andrew Kuklewicz + set defaults to be scheme http, port 80, as that is what internet_archive supports. thanks Andrew Kuklewicz + Pass the management URI if no public endpoint. thanks BK Box + Need to check for management variable as well. thanks BK Box + Add support for pulling out virtualization type when parsing AWS Describe Instances results. thanks Brad Heller + Ignore tags. thanks Brad Heller + NextMarker => NextToken. Maybe that's what it used to be...?. thanks Brad Heller + Fix Params related to network configuration. thanks Chirag Jog + Support to Configure the VM network. thanks Chirag Jog + Ability to track vApp level status of readiness. thanks Chirag Jog + Fix Params related to network configuration. thanks Chirag Jog + Support to Configure the VM network. thanks Chirag Jog + Ability to track vApp level status of readiness. thanks Chirag Jog + Remove extraneous print. thanks Chirag Jog + Remove existing (unused) parser module and introduce a TerremarkParser - which extends the base parser with the ability to extract relevant attributes. thanks Chirag Jog + Use the TerremarkParser to extract relevant attributes. thanks Chirag Jog + Minor Fix to delete the internet service. thanks Chirag Jog + OpenStack: update used limits tests. thanks Dan Prince + OpenStack: update tenant_list tests. thanks Dan Prince + OpenStack: get identity tests passing in real mode. thanks Dan Prince + Drop 'extras' from tenant test validations. thanks Dan Prince + Openstack: fix bin/openstack.rb errors. thanks Dan Prince + OpenStack Compute: Fix server model metadata. thanks Dan Prince + OpenStack: Add missing metadatum requests. thanks Dan Prince + vsphere: Support multiple NIC backings. thanks Ewoud Kohl van Wijngaarden + vsphere: Allow listing virtual port groups. thanks Ewoud Kohl van Wijngaarden + Add a zones.find(substring) method to return only zones whose name matches that substring. thanks H. Wade Minter + Add initial support for pulling in >100 zones via Zones.each. thanks H. Wade Minter + Get rid of the extra load() calls. thanks H. Wade Minter + copy & paste to get Blocks LB API working. thanks Josh Yotty + register blb feature. thanks Josh Yotty + Rudimentary CRUD for AWS Data Pipeline. thanks Keith Barrette + Simple model tests. thanks Keith Barrette + Simple request tests. thanks Keith Barrette + Fix failing model tests. thanks Keith Barrette + Mark data pipeline tests pending if mocked. thanks Keith Barrette + Make compatible with Ruby 1.8.7. thanks Keith Barrette + Finished initial draft of Cloud Server docs. thanks Kyle Rames + updating Rackspace Cloud Server Documentation. thanks Kyle Rames + moving documents to another branch. thanks Kyle Rames + adding white space to force travis build. thanks Kyle Rames + refined examples; moved samples into cloud_servers sub directory. thanks Kyle Rames + moving examples; added readme. thanks Kyle Rames + tweaking example readme file. thanks Kyle Rames + tweaking examples document. thanks Kyle Rames + merging with latest master. thanks Kyle Rames + Adding Rackspace getting started and compute documents back in. thanks Kyle Rames + apply edits to Rackspace compute documents. thanks Kyle Rames + fixing links to anchors in Rackspace Compute doc. thanks Kyle Rames + fixing links to anchors in Rackspace Compute doc one more time. thanks Kyle Rames + fixing links to anchors in Rackspace Compute doc AGAIN. thanks Kyle Rames + fixing merge conflicts. thanks Kyle Rames + added 30 second timeout for SSH and SCP connect. thanks Kyle Rames + moved cloud servers examples to lib/fog/rackspace/examples/compute_v2; renamed cloud_servers.md to compute_v2.md. thanks Kyle Rames + rebased with master. thanks Kyle Rames + merging with the latest file_metadata. thanks Kyle Rames + rebasing cdn branch with latest master. thanks Kyle Rames + rebasing with master. thanks Kyle Rames + rebasing with master. thanks Kyle Rames + rebasing with master. thanks Kyle Rames + fixing broken tests. thanks Kyle Rames + Revert "[rackspace] adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage". thanks Kyle Rames + Revert "Revert "[rackspace] adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage"". thanks Kyle Rames + Follow redirection from response even if response is a Hash. thanks Marc G Gauthier + Set the User-Agent as Fog, to help differentiate from HP's CLI tools that have a vendored 'hpfog'. thanks Matt Ray + Make sure no requests are ever sent to the wrong endpoint by default. thanks Matt Sanders + Bump release to 0.0.7. thanks Matt Sanders + Remove matt as contact. thanks Matt Sanders + Bumped net-scp dependency to ~>1.1. thanks Michael D. Hall + remove unneeded url param. thanks Michał Krzyżanowski + Fix Mock#allocate_address method arity. thanks Mike Moore + Fix Mock#get_snapshot_details argument. thanks Mike Moore + Fix Mock#get_volume_details argument. thanks Mike Moore + Fix Mock#list_servers method arity. thanks Mike Moore + Fix Mock#remove_fixed_ip arguments. thanks Mike Moore + Fix Mock#update_server arguments. thanks Mike Moore + Removes docs since they are in wrong repo. thanks Paul Thornthwaite + Adds new Code Climate badge to README. thanks Paul Thornthwaite + Disables tests with race conditions affecting CI. thanks Paul Thornthwaite + Update gitignore and add a rvmrc file. thanks Rupak Ganguly + Add a new HP provider. thanks Rupak Ganguly + Add a case for the new HP provider. thanks Rupak Ganguly + Add a new HP provider. thanks Rupak Ganguly + Add a storage service implementation to the HP provider. thanks Rupak Ganguly + Add #get_containers, #get_container, #put_container and #delete_container methods to the storage service. thanks Rupak Ganguly + Add #head_containers and #head_container methods. thanks Rupak Ganguly + Enable #get, #put, #head and #delete object methods. thanks Rupak Ganguly + Add implementation for #get_object method. thanks Rupak Ganguly + Add implementation for #put_object method. thanks Rupak Ganguly + Add implementation for #head_object method. thanks Rupak Ganguly + Add implementation for #delete_object method. thanks Rupak Ganguly + Enable models layer methods and return nil from cdn call. thanks Rupak Ganguly + Add the directories model implementation. thanks Rupak Ganguly + Add the directory model implementation. thanks Rupak Ganguly + Add the files model implementation. thanks Rupak Ganguly + Add the file model implementation. thanks Rupak Ganguly + Add an implementation of copy method to copy files between containers. thanks Rupak Ganguly + Require HP provider for the fog binary. thanks Rupak Ganguly + Add a HP provider class for the fog binary. thanks Rupak Ganguly + Enable compute service with HP provider. Refactor hp_auth_url into hp_host, hp_port and hp_auth_path to enable flexibility in specifying the host, port and auth path separately. thanks Rupak Ganguly + Add the new hp_host, hp_port and hp_auth_path attributes and remove hp_auth_url. thanks Rupak Ganguly + Add a new HP provider for compute service. Note the new hp_host, hp_port and hp_auth_path attributes. thanks Rupak Ganguly + Add a case for the new HP provider for compute service. thanks Rupak Ganguly + Add the #list_servers method. thanks Rupak Ganguly + Enable #create_server, #list_servers and #list_servers_detail services for Nova. thanks Rupak Ganguly + Add implementation for #list_servers_detail. thanks Rupak Ganguly + Enable #list_images and #list_images_detail services. thanks Rupak Ganguly + Add implementation for #list_images service. thanks Rupak Ganguly + Add implementation for #list_images_detail service. thanks Rupak Ganguly + Enable #list_flavors and #list_flavors_detail services for Nova. thanks Rupak Ganguly + Add implementation for #list_flavors service. thanks Rupak Ganguly + Add implementation for #list_flavors_detail service. thanks Rupak Ganguly + Add implementation for #get_server_details service. thanks Rupak Ganguly + Add implementation for #get_image_details service. thanks Rupak Ganguly + Add implementation for #get_flavor_details service. thanks Rupak Ganguly + Enable #get_server_details, #get_image_details and #get_flavor_details services for Nova. thanks Rupak Ganguly + Add implementation for #create_server service. thanks Rupak Ganguly + Enable #create_image and #delete_image services. thanks Rupak Ganguly + Add implementation for #create_image service. thanks Rupak Ganguly + Add implementation for #delete_image service. thanks Rupak Ganguly + Enable the #create_server, #update_server and #delete_server services for Nova. thanks Rupak Ganguly + Update code with differences from Rackspace API and OS, to make it work with the Nova instance. thanks Rupak Ganguly + Add the implementation for #update_server services. thanks Rupak Ganguly + Add the implementation for #delete_server services. thanks Rupak Ganguly + Enable #list_addresses, #list_public_addresses and #list_private_addresses services for Nova. thanks Rupak Ganguly + Add implementation for #list_addresses service. thanks Rupak Ganguly + Add implementation for #list_public_addresses service. thanks Rupak Ganguly + Add implementation for #list_private_addresses service. thanks Rupak Ganguly + Enable #server_action, #reboot_server, #resize_server, #confirm_resized_server and #revert_resized services for Nova. thanks Rupak Ganguly + Add implementation for #server_action, #reboot_server, #resize_server, #confirm_resized_server and #revert_resized services. thanks Rupak Ganguly + Enable flavors and flavor models. thanks Rupak Ganguly + Add implementation for flavors and flavor model layer. thanks Rupak Ganguly + Enable images and image models. thanks Rupak Ganguly + Add implementation for images and image model layers. thanks Rupak Ganguly + Enable models for servers and server for Nova services. thanks Rupak Ganguly + Add implementaion for servers model. thanks Rupak Ganguly + Add implementaion for server model. thanks Rupak Ganguly + Refactor connection parameters to accept a single endpoint and credentials. thanks Rupak Ganguly + Refactor Nova connection parameters to accept a single endpoint and credentials. thanks Rupak Ganguly + Add a options hash so that headers can be passed in to set acls. thanks Rupak Ganguly + Fix public_url property to generate a url when cdn is not enabled. Also, create a new url method that returns the full url. thanks Rupak Ganguly + Add a helper method to convert a acl string to a header name/value pair that Swift understands. thanks Rupak Ganguly + Add an acl property that will allow setting of acls strings. Also, add fix the public property to now toggle the appropriate acl string. thanks Rupak Ganguly + Remove Content-Length header incase Transfer-Encoding header is present. This was done to get the streaming for PUT working. thanks Rupak Ganguly + Fix a JSON parse error for Nova service methods like reboot. The server returns plain text instead of JSON text and hence JSON.parse barfs. thanks Rupak Ganguly + Revise fog gemspec to reflect hpfog name and tag it with v0.0.6. thanks Rupak Ganguly + Add mocking support to Swift HP provider calls. thanks Rupak Ganguly + Add a public? method to query a directory's state. thanks Rupak Ganguly + Add header_to_acl helper method to convert an acl header into corresponding acl strings. thanks Rupak Ganguly + Retrieve acl headers if present and set the acl string on a directory. thanks Rupak Ganguly + Add a check to see if acl string is nil and if so set it to 'private'. thanks Rupak Ganguly + Change serverRef to serverId. This was a change from Rackspace API but has been sync'd upon now. thanks Rupak Ganguly + Change flavorRef to flavorId and imageRef to imageId. This was a change from Rackspace API but has been sync'd upon now. thanks Rupak Ganguly + Fix DEVEX-634: Remove services that our out of scope. thanks Rupak Ganguly + Add CHANGELOG for HP specific fog extensions. thanks Rupak Ganguly + Add README with documentation for HP specific fog extensions. thanks Rupak Ganguly + Bump version. thanks Rupak Ganguly + Fix differences that were there in OS API. thanks Rupak Ganguly + Add special char. support including '?' in container and object names. thanks Rupak Ganguly + Add a helper method to expose some base info. for clients. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Fix bug DEVEX-1296. Encode container and object names for public_url. thanks Rupak Ganguly + Update changelog. thanks Rupak Ganguly + Update date for release. thanks Rupak Ganguly + Change flavorId to flavorRef and imageId to imageRef as the specs changed. Also, change expected status to be 202 instead of 200. thanks Rupak Ganguly + Change expected status to be 204 instead of 202. thanks Rupak Ganguly + Change expected status to be 204 instead of 200. thanks Rupak Ganguly + Update date for fog merge with upstream milestone. thanks Rupak Ganguly + Add connection options param to the HP provider for Storage and Compute services that can be used to customize various connection related timeouts and other options. thanks Rupak Ganguly + Remove deprecated provider recognize clause. thanks Rupak Ganguly + Enable HP CDN provider. thanks Rupak Ganguly + Integrate HP CDN service with storage service. thanks Rupak Ganguly + Fix small bug with returning public url in the case when cdn is used. thanks Rupak Ganguly + Add initial implementation for cdn services i.e. GET, PUT, POST, HEAD and DELETE. thanks Rupak Ganguly + Hardcode X-Storage-Url as service is returning wrong url. thanks Rupak Ganguly + Assign hp_auth_uri to an instance var. so that CDN can use it. thanks Rupak Ganguly + Enable delete_container on the CDN service. thanks Rupak Ganguly + Add fix for special chars. in CDN-enabled container names. thanks Rupak Ganguly + Catch new exception that is being thrown. thanks Rupak Ganguly + Update code to call delete_container if CDN is enabled. thanks Rupak Ganguly + Make headers camel cased in public_url and remove manipulation of public_url in save method. Use delete_container in CDN context instead of out_container. thanks Rupak Ganguly + Remove CDN integration from within Storage service, till CDN service is more mature. thanks Rupak Ganguly + Update image and images model, and create_image call now uses server_action. Behavior change in Diablo 4. thanks Rupak Ganguly + Add new request layer method for rebuild_server and enable it for compute services. Behavior added in Diablo 4. thanks Rupak Ganguly + Enable new compute services. thanks Rupak Ganguly + Add name, accessIPv4 and accessIPv6 as properties. Change create_server signature to include the now required name param. Breaking change due to OS API. thanks Rupak Ganguly + Add new attributes, update flavor and image attributes and add corresponding accessors for them. Add new methods for rebuild, resize, revert_resize, confirm_resize, and create_image. Update save method to use new attributes. Update create_server call to pass in name param. thanks Rupak Ganguly + Remove resize related calls as they are not fully functional yet. thanks Rupak Ganguly + Update changelog for 0.0.10 tagged version. thanks Rupak Ganguly + Add a new option for CDN endpoint url and build the CDN mgmt url. thanks Rupak Ganguly + Add a new cdn uri to the Storage service to enable a CDN service from within the Storage service. thanks Rupak Ganguly + Update destroy and save methods to call appropriate CDN counterparts when CDN service is available and enabled. thanks Rupak Ganguly + Add some new attributes. Fix image_id and flavor_id getters. thanks Rupak Ganguly + Add request and model methods for change_password_server, and enable it for compute. thanks Rupak Ganguly + Add list_key_pairs compute request layer method, and mocks for it as well. thanks Rupak Ganguly + Add some mocking helper methods. thanks Rupak Ganguly + Fix issue with list in mock mode. thanks Rupak Ganguly + Enable create_key_pair service for compute. Add key_pairs array for mocking support. thanks Rupak Ganguly + Add implementation for creating keypair and also provide mocking support. thanks Rupak Ganguly + Remove a debug message. thanks Rupak Ganguly + Fix param name. thanks Rupak Ganguly + Enable delete_key_pair request method and implement it, along with mocking support. thanks Rupak Ganguly + Enable and implement key pairs model layer for compute service. thanks Rupak Ganguly + Add implementation for list_security_groups request layer method and enable it for compute services. Add mocking support as well. thanks Rupak Ganguly + Fix a small typo in mocks. thanks Rupak Ganguly + Enable and implemented create_security_groups method for request layer for compute services. thanks Rupak Ganguly + Fix code to remove from last modified hash afetr delete in mock code. thanks Rupak Ganguly + Use id instead of name to index the security groups hash in mock data structure. thanks Rupak Ganguly + Enable and implemented delete_security_groups method in requets layer for compute services. thanks Rupak Ganguly + Enable and implement create, get and delete security group methods for compute service. thanks Rupak Ganguly + Enable and add the security groups model layer implementation for the compute services. thanks Rupak Ganguly + Enable and add implementation for create security group rules for compute service. thanks Rupak Ganguly + Fix bugs in mocking support. thanks Rupak Ganguly + Small fix in mocks. thanks Rupak Ganguly + Enable and implement delete security group rules for compute service. thanks Rupak Ganguly + Add security group rule methods to security group model. thanks Rupak Ganguly + Fix create_rule to return response instead of boolean. thanks Rupak Ganguly + Add helper methods for mocking. thanks Rupak Ganguly + Enable and implement allocate address with mocking support for compute services. thanks Rupak Ganguly + Add options for keyname, security group and availability zone. thanks Rupak Ganguly + Enable and add implementation for release address for request layer for the compute service. thanks Rupak Ganguly + Fix documentation. thanks Rupak Ganguly + Enable and implement get address for request layer along with mocking support for the compute service. thanks Rupak Ganguly + Rename these to add a server prefix as they pertain to server addresses. thanks Rupak Ganguly + Enable and implement list addresses for request layer for the compute service. thanks Rupak Ganguly + Enable and implement the address model layer for the compute service. thanks Rupak Ganguly + Fix the documentation. thanks Rupak Ganguly + Enable and add associating and disassociating addresses to a server instance in the request layer for the compute service. thanks Rupak Ganguly + Add new attributes and revise addresses hash structure for the mock. thanks Rupak Ganguly + Fix doc, and status. thanks Rupak Ganguly + Revise implementation for returning private and public ip addresses for a given server, along with mocking support. thanks Rupak Ganguly + Revise mocking support to manage ip address collection in servers. thanks Rupak Ganguly + Add server attribute to associate and disassociate a server to an address. thanks Rupak Ganguly + Remove some attributes from object. thanks Rupak Ganguly + Add support for passing in key pairs, security groups, availability zone and min/max count to the create server request layer method. thanks Rupak Ganguly + Update the server model to support passing in keypairs and security groups. thanks Rupak Ganguly + Fix some verbiage and update some links. thanks Rupak Ganguly + Remove instance_id as an accessor. thanks Rupak Ganguly + Add vcpus as an attribute. thanks Rupak Ganguly + Add back some attributes. thanks Rupak Ganguly + Update inline docs to add some params. thanks Rupak Ganguly + Update changelog with changes for this version release. thanks Rupak Ganguly + Bump version to 0.0.11. thanks Rupak Ganguly + Update HP provider with the new CS authentication method and also refactor the legacy authentication method. Also, update HP Storage provider to use the CS authentication scheme. thanks Rupak Ganguly + Retrofit HP Storage provider to work with both legacy and CS authentication schemes. thanks Rupak Ganguly + Refactor code to get endpoints from service catalog for v1 and v2 auths. thanks Rupak Ganguly + Update Storage provider to work with v1 and v2 auths. thanks Rupak Ganguly + Update CDN provider to work with v1 and v2 auths. Also, patch code for incorrect endpoint via CS catalog. thanks Rupak Ganguly + Update for cdn endpoint fix in place. thanks Rupak Ganguly + Update inline docs as per real responses. thanks Rupak Ganguly + Update CDN integration with Storage with respect to CS authentication. thanks Rupak Ganguly + Update HP Compute provider to use CS authentication and retrofit code to use v1 auth as well. thanks Rupak Ganguly + Add cdn_enabled?, cdn_enable= and cdn_public_url for directory model. Also, add cdn_public_url for file model. thanks Rupak Ganguly + Add connection_options for AWS Compute provider. thanks Rupak Ganguly + Refactor to remove service_type param from provider call. thanks Rupak Ganguly + Update inline documentation. thanks Rupak Ganguly + Escape the key in the call. thanks Rupak Ganguly + Remove bits and cores from flavor. thanks Rupak Ganguly + Add cores as an attribute to alias vcpus. thanks Rupak Ganguly + Add some attributes that are implemented as methods. thanks Rupak Ganguly + Add copyright message for HP extensions for fog. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Update copyright notice. thanks Rupak Ganguly + Update inline documentation. thanks Rupak Ganguly + Fix for auth uri using Identity service. thanks Rupak Ganguly + Add parameter :hp_avl_zone to access the az2 availability zone to the HP Compute provider. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Add key_pair get/set methods for server model. thanks Rupak Ganguly + Hack to fix public_ip_address. thanks Rupak Ganguly + Fix for Fog::HP::CDN::NotFound exception. thanks Rupak Ganguly + Update public_ip_address method to return first public ip address. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Add an Errors module for handling HP provider specific exceptions. thanks Rupak Ganguly + Refactor escape method for container and object names and move it to the HP provider from individual namespaces. thanks Rupak Ganguly + Remove obsolete method. thanks Rupak Ganguly + Remove bad service. thanks Rupak Ganguly + Fix mock to return integer value for count. thanks Rupak Ganguly + Raise the correct exception in the mock. thanks Rupak Ganguly + Add HP provider and credentials to support testing with mocks. thanks Rupak Ganguly + Fix mocks to match real implementation. thanks Rupak Ganguly + Add object tests for storage. thanks Rupak Ganguly + Add mocking support for copy operation using puut object. thanks Rupak Ganguly + Add more tests for containers and objects. thanks Rupak Ganguly + Fix an issue in copy mocking portion. thanks Rupak Ganguly + Add test for copy objects. thanks Rupak Ganguly + Add test for copying from one container to another. thanks Rupak Ganguly + Fix format of flavors in mocks. thanks Rupak Ganguly + Add tests for flavor. thanks Rupak Ganguly + Add implementation for mocks. thanks Rupak Ganguly + Add mocking support. thanks Rupak Ganguly + Minor fix for mocks. thanks Rupak Ganguly + Add tests for images. thanks Rupak Ganguly + Update mocking support. thanks Rupak Ganguly + Add tests for server requests. thanks Rupak Ganguly + Update mocking support. thanks Rupak Ganguly + Add tests for addresses and floating ips. thanks Rupak Ganguly + Fix minor things in tests. thanks Rupak Ganguly + Update mocking support. thanks Rupak Ganguly + Add tests for keypairs. thanks Rupak Ganguly + Update mocking support for security groups. thanks Rupak Ganguly + Add tests for security groups. thanks Rupak Ganguly + Update mocking support for security groups and security group rules. thanks Rupak Ganguly + Add tests for security group rules. thanks Rupak Ganguly + Fix mocks for create_key_pair. thanks Rupak Ganguly + Fix mocks for list_key_pairs. thanks Rupak Ganguly + Fix format for list_key_pairs. thanks Rupak Ganguly + Add tests for address model and addresses collection. thanks Rupak Ganguly + Add HP provider in the helper. thanks Rupak Ganguly + Add tests for key_pair model and key_pairs collection. thanks Rupak Ganguly + Add tests for security group model and collection. thanks Rupak Ganguly + Add HP credential params. thanks Rupak Ganguly + Add HP credential params for mocking support. thanks Rupak Ganguly + Add mocking support for HP CDN provider. thanks Rupak Ganguly + Add tests for CDN containers. thanks Rupak Ganguly + Update mocks to simulate real results in containers. thanks Rupak Ganguly + Update tests and mocks based on real pro data. thanks Rupak Ganguly + Update tests and mock formats based on real pro data. thanks Rupak Ganguly + Update mocks to simulate real behavior. thanks Rupak Ganguly + Update key pair tests to work with real pro results. thanks Rupak Ganguly + Update mocks to simulate real results. thanks Rupak Ganguly + Update mocks and tests to simulate real results. thanks Rupak Ganguly + Update mocks and tests to simulate real results. thanks Rupak Ganguly + Update mocks and tests for flavor to simulate real results. thanks Rupak Ganguly + Update mocks and tests to simulate real calls in pro. thanks Rupak Ganguly + Update mocks for address in create_server and corresponding tests. thanks Rupak Ganguly + Add hp_tenant_id as a required param for connection to HP providers. thanks Rupak Ganguly + Update default scheme from http to https in the v1 auth. thanks Rupak Ganguly + Add uuid and links atrributes to the list servers mock. thanks Rupak Ganguly + Pass connection_options hash to the cdn connection in the storage provider. thanks Rupak Ganguly + Fix a bug where cdn state was not preserved. thanks Rupak Ganguly + Add helper method for cdn public ssl url and remove check for hp_cdn_ssl flag. thanks Rupak Ganguly + Add helper method for cdn public url for file. thanks Rupak Ganguly + Add helper method to get cdn ssl url for the files collection. thanks Rupak Ganguly + Add and enable get_console_output request method and add server method console_output. Add test for get_console_output. thanks Rupak Ganguly + Add avl zone as required param. Update endpoint retrieving logic from catalog to allow future avl zones. Fix minor error in tests. thanks Rupak Ganguly + Add avl zone as required param. Update endpoint retrieving logic from catalog to allow future avl zones. Fix minor error in tests. thanks Rupak Ganguly + Add availability zone required parameter for storage and cdn services. thanks Rupak Ganguly + Add availability zone required parameter for storage and cdn services. thanks Rupak Ganguly + Minor fix. thanks Rupak Ganguly + Add security_groups attribute to the server model. thanks Rupak Ganguly + Change hp_service_type to check for 'name' in the service catalog rather than 'type'. thanks Rupak Ganguly + Update tests to reflect addition of security_groups attribute to server model. thanks Rupak Ganguly + Update to not raise exception if service is not active or not present. thanks Rupak Ganguly + Upgrade to excon version 0.13.0 to take advantage of the ssl_verify_peer and ssl_ca_file params via the connection_options hash. Also, remove the use of :hp_servicenet setting for ssl for storage and compute providers. thanks Rupak Ganguly + Add request layer code for metadata. thanks Rupak Ganguly + Update mocking support for metadata to match real responses. thanks Rupak Ganguly + Add tests for metadata requests methods. thanks Rupak Ganguly + Minor fix to mocks. thanks Rupak Ganguly + Add metadata models support. Also, include metadata attribute in server and image models, to manage metadata. thanks Rupak Ganguly + Add some more metadata requests tests. thanks Rupak Ganguly + Minor fix and add a destroy method. thanks Rupak Ganguly + Add metadata tests for servers and images. thanks Rupak Ganguly + Fix code to metadata to the create image call. thanks Rupak Ganguly + Add an attribute for network_name to make it easy to switch. thanks Rupak Ganguly + Add a multi_json require so that json parsing is available. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Update call to include response_block rather than passing a block, to conform to excon deprecation message. thanks Rupak Ganguly + Add attributes to image model by extracting them from metadata. thanks Rupak Ganguly + Add a BlockStorage service to the HP provider. thanks Rupak Ganguly + Add list_volumes for block storage. thanks Rupak Ganguly + Add get_volume_details request method for block storage. thanks Rupak Ganguly + Add delete_volumes request method for block storage. thanks Rupak Ganguly + Add create_volume request method for block storage service. thanks Rupak Ganguly + Add ability to send in metadata to create_volume request method. thanks Rupak Ganguly + Fix mock for tests. thanks Rupak Ganguly + Fix typo in service folder. thanks Rupak Ganguly + Add the block storage service to the binary. thanks Rupak Ganguly + Fix mock for tests. thanks Rupak Ganguly + Add shindo tests for requests methods for block storage. thanks Rupak Ganguly + Add server attach block storage request methods. thanks Rupak Ganguly + Add list_server_volumes request method for block storage service. thanks Rupak Ganguly + Add attach_volume request method for block storage service. thanks Rupak Ganguly + Add detach_volume request method for block storage service. thanks Rupak Ganguly + Add shindo tests for server volume request methdos for block storage service. thanks Rupak Ganguly + Add volume model and volumes collection for block storage service. thanks Rupak Ganguly + Add shindo tests for volume models and collection. thanks Rupak Ganguly + Fix mock to provide correct status after creation. thanks Rupak Ganguly + Add a compute service attribute to peek into the compute service from within the block_storage service. thanks Rupak Ganguly + Add attach and detach methods to the volume model using the compute service attribute. thanks Rupak Ganguly + Add shindo tests for attach and detach. thanks Rupak Ganguly + Fix mock. Fix tests for mocking and real modes. thanks Rupak Ganguly + Add a head method for the directories collection. thanks Rupak Ganguly + Upgrade to excon 0.14.0 to take advantage of the new StandardInstrumentor for debug use. thanks Rupak Ganguly + Capture hp_auth_uri for passing down to compute provider. thanks Rupak Ganguly + Add a list_snapshot request method, a corresponding mock, and add support for it in the block storage provider. thanks Rupak Ganguly + Add a create_snapshot request method, a corresponding mock, and add support for it in the block storage provider. thanks Rupak Ganguly + Minor fix to the inline help. thanks Rupak Ganguly + Add a get_snapshot_details request method, a corresponding mock, and add support for it in the block storage provider. thanks Rupak Ganguly + Add a delete_snapshot request method, a corresponding mock, and add support for it in the block storage provider. thanks Rupak Ganguly + Add shindo tests for snapshots request layer methods. thanks Rupak Ganguly + Minor update to inline help. thanks Rupak Ganguly + Add snapshot model and collection to bloack storage provider. thanks Rupak Ganguly + Add snapshot model/collection and corresponding tests. thanks Rupak Ganguly + Add user_agent string to the core fog connection with corresponding tests. thanks Rupak Ganguly + Add customised user_agent string for HP providers. Also, enable passing a custom user_agent string from calling clients. Add corresponding tests. thanks Rupak Ganguly + Add volume_attachments to server model. thanks Rupak Ganguly + Bump version to 0.0.16 and update changelog. thanks Rupak Ganguly + Removed 'server' attribute from server model, and fixed 'all' method. thanks Rupak Ganguly + Removed 'images' attribute from server model. thanks Rupak Ganguly + Fix version info. that is used by user-agent. thanks Rupak Ganguly + Add object temp url generation capability with mock support. thanks Rupak Ganguly + Add object temp url functionality to file model layer. thanks Rupak Ganguly + Add request layer tests for object_temp_url functionality. thanks Rupak Ganguly + Add tenant_id to the mix to tighten security for the temp_url generation. thanks Rupak Ganguly + Update mock for tenp_url. thanks Rupak Ganguly + Call the request layer method instead of the generic util method. thanks Rupak Ganguly + Add model tests for storage service. thanks Rupak Ganguly + Add the request layer method to extract the windows password from the console log in case of a windows instance. thanks Rupak Ganguly + Update the server model with a method to retrieve the windows password. thanks Rupak Ganguly + Update the get_windows_password to return the encrypted password instead of the decrypted one. thanks Rupak Ganguly + Add grant, revoke and list methods for cross tenant object acls implementation. thanks Rupak Ganguly + Add request layer methods for shared container and shared object access. thanks Rupak Ganguly + Bump version and update changelog. thanks Rupak Ganguly + Fix response status for mocks. thanks Rupak Ganguly + Add mocks for shared container and objects calls. thanks Rupak Ganguly + Add a new exception class and handled exceptions in exception messages. thanks Rupak Ganguly + Add request method for put_shared_object. Add model and collection for shared_directory and shared_file. thanks Rupak Ganguly + Refactor common code into separate method. thanks Rupak Ganguly + Fix mock for put_container to reflect new acl changes. thanks Rupak Ganguly + Fix head call to return an empty body. thanks Rupak Ganguly + Removed comment. thanks Rupak Ganguly + Minor fix to allow options on save to pass in metadata. thanks Rupak Ganguly + Add method all. thanks Rupak Ganguly + Add methods for destroy and save. thanks Rupak Ganguly + Add method for destroy. thanks Rupak Ganguly + Add request layer method for put_shared_container. thanks Rupak Ganguly + Minor bug fix when acls are nil. Also, added support for specifying list of users for grant and revoke as a comma-separated list. thanks Rupak Ganguly + Allow the models to raise exception when there is insufficient access. thanks Rupak Ganguly + Add delete_shared_object and corresponding model support. thanks Rupak Ganguly + Update inline documentation. thanks Rupak Ganguly + Update method to remove availability_zone as input data parameter. thanks Rupak Ganguly + Allows creation of bootable volumes by passing in single part images. thanks Rupak Ganguly + Allows creation of server instances that use a bootable volume rather than an image as its base. This gives us persistant instances. thanks Rupak Ganguly + Fix failing shindo tests. thanks Rupak Ganguly + Fix some null checks. thanks Rupak Ganguly + Add request layer methods for listing and getting bootable volumes. thanks Rupak Ganguly + Update volume model and collection to handle bootable volumes as well. thanks Rupak Ganguly + Add code to accept config_drive and block_device_mapping parameters while creating a server instance. thanks Rupak Ganguly + Move CHANGELOG.hp under hp folder. thanks Rupak Ganguly + Bump the version and update the changelog. thanks Rupak Ganguly + Fix public_key attribute to be visible in table. thanks Rupak Ganguly + Add create_persistent_server request layer method to compute service. Add mocks and tests as well. thanks Rupak Ganguly + Remove block_device_mapping param from create_server request method call. thanks Rupak Ganguly + Add capability of creating regular and persistent servers via the server model. Make image_id an optional parameter for creating servers. thanks Rupak Ganguly + Add bootable_volumes collection for managing only bootable volumes. thanks Rupak Ganguly + Remove bootable volumes list and get methods and moved them under the bootable_volumes collection. thanks Rupak Ganguly + Update changelog and release date. thanks Rupak Ganguly + Updated the BlockStorage namespace to be Fog::HP::BlockStorage. thanks Rupak Ganguly + Updated the tests to reflect the BlockStorage namespace changes. thanks Rupak Ganguly + Fix case where invalid CDN endpoint was causing issues. thanks Rupak Ganguly + Update to new code and tests based on changes from upstream fog. thanks Rupak Ganguly + Deprecate hp_account_id to use hp_access_key instead. thanks Rupak Ganguly + Fix fog.gemspec. thanks Rupak Ganguly + * [dreamhost|dns] initial import. thanks Sergio Rubio + Switch gem source to https://rubygems.org. thanks Sergio Rubio + A whitespace fix :v:. thanks Simon Gate + add install.txt. thanks Terry Howe + remove file. thanks Terry Howe + Update put_object to accept blocks, and remove deprecation message. thanks Terry Howe + Fix warning. thanks William Lawson + version. thanks William Lawson + reverse version change. thanks William Lawson + joyent resize smartmachine incorrect class type. thanks angus + Typo in instantiate_vapp_template.rb. thanks dJason + fix for user agent tests excon usage. thanks geemus + fixed bug, quantum api need no underscore valiable name. (ex floatingips. thanks kanetann + Update lib/fog/ecloud/requests/compute/virtual_machine_create_from_template.rb. thanks tipt0e + Fog::Vsphere::Compute - misspelled method 'get_vm_by_ref' in vm_reconfig_hardware. thanks tipt0e + +[openstack] + Register the image service. thanks Anshul Khandelwal + string interpolation problem image create fixes #1493. thanks Ruben Koster + +[openstack|compute] + fix get_metadata call. thanks Ben Bleything + rename meta_hash to to_hash; make it public. thanks Ben Bleything + adds methods to retireve floating & fixed ip addresses. thanks Ohad Levy + ensures we clear ipaddresses cache upload reload. thanks Ohad Levy + configurable :openstack_endpoint_type. thanks Sergio Rubio + images collection should not return nil for #all. thanks Sergio Rubio + +[openstack|identity] + Marks test as pending. thanks Paul Thornthwaite + Configurable :openstack_endpoint_type. thanks Sergio Rubio + user model tests fixes. thanks Sergio Rubio + cleanup the test role when no longer in use. thanks Sergio Rubio + +[openstack|network] + Added missing Network model attributes. thanks Sergio Rubio + +[openstack|storage] + intial import. thanks Sergio Rubio + added OpenStack Storage to lib/fog/storage.rb. thanks Sergio Rubio + Added OpenStack.escape utility method. thanks Sergio Rubio + Added storage service to lib/fog/bin/openstack.rb. thanks Sergio Rubio + Added OpenStack Storage service tests. thanks Sergio Rubio + configurable service_type and service_name. thanks Sergio Rubio + added openstack_tenant and openstack_region params. thanks Sergio Rubio + replace 'object_store' service type with 'object-store'. thanks Sergio Rubio + +[openstack|volume] + Configurable :openstack_endpoint_type. thanks Sergio Rubio + remove extra comma. thanks Sergio Rubio + Added missing service declaration. thanks Sergio Rubio + +[ovirt] + Add support for reading the oVirt api version. thanks Amos Benari + Added support for oVirt volume status. thanks Amos Benari + Updated the blocking start logic to fit oVirt 3.1 api. thanks Amos Benari + +[rackspace] + adding accept headers to block_storage, cdn, compute_v2, databases, identity, load_balancers, storage. thanks Kyle Rames + fixing merge. thanks Kyle Rames + +[rackspace|cdn] + implemented purge object from CDN; added CDN tests and mocks. thanks Kyle Rames + more refactoring. thanks Kyle Rames + more refactoring of cdn. thanks Kyle Rames + +[rackspace|compute] + Fix typo in attachments model. thanks Brad Gignac + Handle malformed API responses. thanks Brad Gignac + Update server to use default networks. thanks Brad Gignac + Allow custom network on server. thanks Brad Gignac + this should address a metadata issue discovered in chef http://tickets.opscode.com/browse/KNIFE-217. thanks Kyle Rames + this should address a metadata issue discovered in chef http://tickets.opscode.com/browse/KNIFE-217(cherry picked from commit a859b9ecf550469ac43ea35402785dad59d7c7f2). thanks Kyle Rames + added create server example. thanks Kyle Rames + Adding more cloud server examples. thanks Kyle Rames + tweaking examples. thanks Kyle Rames + fixing typo in metadata class. thanks Kyle Rames + fixing connection deprecation warnings. thanks Kyle Rames + Adding API documentation. thanks Kyle Rames + updated to check for public_ip_address instead of ip4_address as setup uses the public_ip_address. thanks Kyle Rames + removed timeout from bootstrap method signature and hard coded it in method per geemus. thanks Kyle Rames + added test for put_container with an optional parameter. thanks Kyle Rames + updated mocking framework to support any flavor or image. thanks Kyle Rames + remove erroneous block argument to get_object fixes #1588. thanks geemus + +[rackspace|compute_v2] + fixing merge issues; added metadata test for servers. thanks Kyle Rames + Added note indicating that RackConnect users should use Server personalization rather than the bootstrap method. thanks Kyle Rames + fixing bootstrap example. thanks Kyle Rames + compute_v2 tests were failing because the flavor used in the tests was too small for the image selected. I updating tests to use the an Ubuntu image in hopes of making the tests less brittle. thanks Kyle Rames + +[rackspace|database] + remove extraneous colon. thanks Kyle Rames + +[rackspace|databases] + removed trailing stash from hard coded endpoints; added accept header. thanks Kyle Rames + +[rackspace|dns] + added tests for zones.find. thanks Brian Hartsock + fix issue in zones.find where results with no links throw exception. thanks Brian Hartsock + +[rackspace|identity] + Correctly populate model from request data. thanks Brad Gignac + Remove unused get_credentials request. thanks Brad Gignac + +[rackspace|lb] + fixed issue where double paths cause API errors. thanks Brian Hartsock + removed puts. thanks Brian Hartsock + +[rackspace|networks] + Add Cloud Networks requests. thanks Brad Gignac + Add networks model and collection. thanks Brad Gignac + Add mock responses. thanks Brad Gignac + +[rackspace|storage] + refactored storage/cdn. thanks Kyle Rames + fixed issue in ruby 1.8.7 where metadata was not being deleted when set to nil. thanks Kyle Rames + tweaked directory implementation; added directory model tests. thanks Kyle Rames + updating to return true after saving directory. thanks Kyle Rames + added support for container metadata; added directory tests. thanks Kyle Rames + Cloud Files will not process a header without a value so I added a stand in value for nil. thanks Kyle Rames + added delete method to metadata. thanks Kyle Rames + removing test of dubious distinction per geemus. thanks Kyle Rames + updated file class to use the same metadata implementation as the directory class. thanks Kyle Rames + added test to check for metadata on object creation; tweaked metadata on object creation test. thanks Kyle Rames + updated metadata class to decode incoming header values using FOG::JSON. thanks Kyle Rames + fixing Metadata#respond_to? method. thanks Kyle Rames + updated directory to lazy load metadata when necessary. thanks Kyle Rames + added tests for metadata class; fixed bug with method missing. thanks Kyle Rames + updated file class to use the same metadata implementation as the directory class. thanks Kyle Rames + added test to check for metadata on object creation; tweaked metadata on object creation test. thanks Kyle Rames + updated metadata class to decode incoming header values using FOG::JSON. thanks Kyle Rames + rebased with dir_metadata branch - https://github.com/fog/fog/pull/1563. thanks Kyle Rames + added ios_url and streaming_url methods to directory and file; added more tests. thanks Kyle Rames + added account model. thanks Kyle Rames + removing type conversion for metadata per https://github.com/fog/fog/pull/1587. thanks Kyle Rames + added the ability to determine meta prefixes from Class objects as well as Fog object. This addresses issue in Files#get method. thanks Kyle Rames + +[tests] + Updates format tests. thanks Paul Thornthwaite + Changes to format testing helper. thanks Paul Thornthwaite + Extracts schema validator to class. thanks Paul Thornthwaite + Fixes schema validator for arrays. thanks Paul Thornthwaite + +[virtualbox] + Removed VirtualBox since it has many problems and the gem it's based on is no longer maintained. thanks Kevin Menard + + 1.9.0 01/19/2013 0283cac581edc36fe58681c51d6fa2a5d2db3f41 ========================================================= diff --git a/fog.gemspec b/fog.gemspec index 734b67a64..229d4eb36 100644 --- a/fog.gemspec +++ b/fog.gemspec @@ -6,8 +6,8 @@ Gem::Specification.new do |s| ## If your rubyforge_project name is different, then edit it and comment out ## the sub! line in the Rakefile s.name = 'fog' - s.version = '1.9.0' - s.date = '2013-01-19' + s.version = '1.10.0' + s.date = '2013-03-05' s.rubyforge_project = 'fog' ## Make sure your summary is short. The description may be as long diff --git a/lib/fog/version.rb b/lib/fog/version.rb index 2bc9874ad..0cdb1cefa 100644 --- a/lib/fog/version.rb +++ b/lib/fog/version.rb @@ -1,3 +1,3 @@ module Fog - VERSION = '1.9.0' + VERSION = '1.10.0' end From c861455c913c7eb56ea91399858ba15ca181b225 Mon Sep 17 00:00:00 2001 From: geemus Date: Tue, 5 Mar 2013 11:27:28 -0600 Subject: [PATCH 51/68] add Rupak Ganguly to MVP exclusion list --- lib/tasks/changelog_task.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/changelog_task.rb b/lib/tasks/changelog_task.rb index 5f4141904..01c2ec37b 100644 --- a/lib/tasks/changelog_task.rb +++ b/lib/tasks/changelog_task.rb @@ -68,6 +68,7 @@ module Fog 'nightshade427', 'Patrick Debois', 'Paul Thornthwaite', + 'Rupak Ganguly', 'Stepan G. Fedorov', 'Wesley Beary' ].include?(committer) From 017ce23a256baad9ba8870509c0740e59e75823b Mon Sep 17 00:00:00 2001 From: Joachim Nolten Date: Wed, 6 Mar 2013 15:29:22 +0100 Subject: [PATCH 52/68] First attempt at an S3 path_style flag --- lib/fog/aws/storage.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb index 0307ccdaa..6403c53e0 100644 --- a/lib/fog/aws/storage.rb +++ b/lib/fog/aws/storage.rb @@ -7,7 +7,7 @@ module Fog extend Fog::AWS::CredentialFetcher::ServiceMethods requires :aws_access_key_id, :aws_secret_access_key - recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at + recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :use_iam_profile, :aws_session_token, :aws_credentials_expire_at, :path_style secrets :aws_secret_access_key, :hmac @@ -294,6 +294,7 @@ module Fog @persistent = options.fetch(:persistent, false) @port = options[:port] || 443 @scheme = options[:scheme] || 'https' + @path_style = options[:path_style] || false end @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) end @@ -324,11 +325,12 @@ DATA string_to_sign << canonical_amz_headers subdomain = params[:host].split(".#{@host}").first - unless subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/ - Fog::Logger.warning("fog: the specified s3 bucket name(#{subdomain}) is not a valid dns name, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html") + valid_dns = !!(subdomain =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/) + if !valid_dns || @path_style + Fog::Logger.warning("fog: the specified s3 bucket name(#{subdomain}) is not a valid dns name, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html") unless valid_dns params[:host] = params[:host].split("#{subdomain}.")[-1] if params[:path] - params[:path] = "#{subdomain}/#{params[:path]}" + params[:path] = "#{subdomain}/#{params[:path]}" unless subdomain == @host else params[:path] = subdomain end From 7c7b308b383ec5381968775cafb86bb4c16236a6 Mon Sep 17 00:00:00 2001 From: Anshul Khandelwal Date: Wed, 6 Mar 2013 22:01:16 +0530 Subject: [PATCH 53/68] sshable should take the same options as ssh --- lib/fog/compute/models/server.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fog/compute/models/server.rb b/lib/fog/compute/models/server.rb index a66c20208..4522d99a1 100644 --- a/lib/fog/compute/models/server.rb +++ b/lib/fog/compute/models/server.rb @@ -62,8 +62,8 @@ module Fog 22 end - def sshable? - ready? && !public_ip_address.nil? && !!Timeout::timeout(8) { ssh 'pwd' } + def sshable?(options={}) + ready? && !public_ip_address.nil? && !!Timeout::timeout(8) { ssh('pwd', options) } rescue SystemCallError, Net::SSH::AuthenticationFailed, Timeout::Error false end From e4884d8f51f36a37d6f219de315ffae6e16d1e88 Mon Sep 17 00:00:00 2001 From: Anshul Khandelwal Date: Wed, 6 Mar 2013 22:11:34 +0530 Subject: [PATCH 54/68] [aws][glesys] Pass credentials to sshable --- lib/fog/aws/models/compute/server.rb | 2 +- lib/fog/glesys/models/compute/server.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fog/aws/models/compute/server.rb b/lib/fog/aws/models/compute/server.rb index 4d68be397..9bbf6123e 100644 --- a/lib/fog/aws/models/compute/server.rb +++ b/lib/fog/aws/models/compute/server.rb @@ -202,7 +202,7 @@ module Fog end # wait for aws to be ready - wait_for { sshable? } + wait_for { sshable?(credentials) } Fog::SSH.new(public_ip_address, username, credentials).run(commands) end diff --git a/lib/fog/glesys/models/compute/server.rb b/lib/fog/glesys/models/compute/server.rb index f1b5edb3a..3e1e141c1 100644 --- a/lib/fog/glesys/models/compute/server.rb +++ b/lib/fog/glesys/models/compute/server.rb @@ -87,13 +87,13 @@ module Fog commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys} end - # wait for aws to be ready - wait_for { sshable? } - if credentials[:password].nil? && !rootpassword.nil? credentials[:password] = rootpassword end + # wait for glesys to be ready + wait_for { sshable?(credentials) } + Fog::SSH.new(public_ip_address, username, credentials).run(commands) end From d24d9c510c53178b159b3e64169a16fdcb06cc71 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 6 Mar 2013 12:27:23 -0800 Subject: [PATCH 55/68] Support optional `snapshot_id` key when creating volumes --- lib/fog/rackspace/requests/block_storage/create_volume.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fog/rackspace/requests/block_storage/create_volume.rb b/lib/fog/rackspace/requests/block_storage/create_volume.rb index 989b2232d..918d4fc93 100644 --- a/lib/fog/rackspace/requests/block_storage/create_volume.rb +++ b/lib/fog/rackspace/requests/block_storage/create_volume.rb @@ -13,6 +13,7 @@ module Fog data['volume']['display_description'] = options[:display_description] unless options[:display_description].nil? data['volume']['volume_type'] = options[:volume_type] unless options[:volume_type].nil? data['volume']['availability_zone'] = options[:availability_zone] unless options[:availability_zone].nil? + data['volume']['snapshot_id'] = options[:snapshot_id] unless options[:snapshot_id].nil? request( :body => Fog::JSON.encode(data), From e1770354c9be10cf863c4f9371d851efc077a462 Mon Sep 17 00:00:00 2001 From: Dave Ungerer Date: Thu, 7 Mar 2013 17:22:37 +0200 Subject: [PATCH 56/68] Update file.rb Clarified documentation --- lib/fog/aws/models/storage/file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/aws/models/storage/file.rb b/lib/fog/aws/models/storage/file.rb index 1be0cb7f5..8efec8ba3 100644 --- a/lib/fog/aws/models/storage/file.rb +++ b/lib/fog/aws/models/storage/file.rb @@ -223,7 +223,7 @@ module Fog # # required attributes: key # - # @param expires [String] number of seconds before url expires + # @param expires [String] number of seconds (since 1970-01-01 00:00) before url expires # @param options [Hash] # @return [String] url # From 2bb490c17640bc1ff17e85d55d2d886a62d10214 Mon Sep 17 00:00:00 2001 From: dJason Date: Thu, 7 Mar 2013 14:49:42 -0700 Subject: [PATCH 57/68] Add Vcloud support back to Fog::Compute Vcloud does not work with the new cleanup code for generic provider compute support. Would return: NameError: uninitialized constant Fog::Compute::Vcloud from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/fog-1.10.0/lib/fog/compute.rb:41:in `const_get' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/fog-1.10.0/lib/fog/compute.rb:41:in `new' --- lib/fog/compute.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fog/compute.rb b/lib/fog/compute.rb index 4243d96da..a8e27e93b 100644 --- a/lib/fog/compute.rb +++ b/lib/fog/compute.rb @@ -35,6 +35,9 @@ module Fog when :stormondemand require 'fog/storm_on_demand/compute' Fog::Compute::StormOnDemand.new(attributes) + when :vcloud + require 'fog/vcloud/compute' + Fog::Vcloud::Compute.new(attributes) else if self.providers.include?(provider) require "fog/#{provider}/compute" From 651ef39d00c210f58da3dcf2f7e879fd7d12f23f Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Thu, 7 Mar 2013 15:56:31 -0600 Subject: [PATCH 58/68] [rackspace|compute_v2] fixing yard doc --- lib/fog/rackspace/models/compute_v2/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/rackspace/models/compute_v2/server.rb b/lib/fog/rackspace/models/compute_v2/server.rb index 6468f6cfc..a682c3e2e 100644 --- a/lib/fog/rackspace/models/compute_v2/server.rb +++ b/lib/fog/rackspace/models/compute_v2/server.rb @@ -351,7 +351,7 @@ module Fog end # Resize existing server to a different flavor, in essence, scaling the server up or down. The original server is saved for a period of time to allow rollback if there is a problem. All resizes should be tested and explicitly confirmed, at which time the original server is removed. All resizes are automatically confirmed after 24 hours if they are not confirmed or reverted. - # @param [String] flavor to resize + # @param [String] flavor_id to resize # @return [Boolean] returns true if resize is in process # @note All resizes are automatically confirmed after 24 hours if you do not explicitly confirm or revert the resize. # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Resize_Server-d1e3707.html From 6663e05d29d1c86b6c0abbbfb1cadd6a1863159b Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Thu, 7 Mar 2013 16:01:42 -0600 Subject: [PATCH 59/68] [rackspace|storage] adding Storage yard docs --- lib/fog/rackspace/models/storage/account.rb | 18 +++++ .../rackspace/models/storage/directories.rb | 16 +++- lib/fog/rackspace/models/storage/directory.rb | 62 +++++++++++++-- lib/fog/rackspace/models/storage/file.rb | 75 ++++++++++++++++++- lib/fog/rackspace/models/storage/files.rb | 58 ++++++++++++++ lib/fog/rackspace/models/storage/metadata.rb | 33 ++++++-- lib/fog/rackspace/storage.rb | 6 ++ 7 files changed, 253 insertions(+), 15 deletions(-) diff --git a/lib/fog/rackspace/models/storage/account.rb b/lib/fog/rackspace/models/storage/account.rb index c98fac8f4..2316ac250 100644 --- a/lib/fog/rackspace/models/storage/account.rb +++ b/lib/fog/rackspace/models/storage/account.rb @@ -4,16 +4,34 @@ module Fog module Storage class Rackspace class Account < Fog::Model + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View_Account_Info-d1e11995.html + + # @!attribute [rw] meta_temp_url_key is used to generate temporary access to files + # @return [String] The temporary URL key + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html attribute :meta_temp_url_key, :aliases => 'X-Account-Meta-Temp-Url-Key' + + # @!attribute [r] container_count + # @return [Integer] The number of containers in account attribute :container_count, :aliases => 'X-Account-Container-Count', :type => :integer + + # @!attribute [r] bytes_used + # @return [Integer] The total number of bytes used by the account attribute :bytes_used, :aliases => 'X-Account-Bytes-Used', :type => :integer + + # @!attribute [r] object_count + # @return [Integer] The total number of objects in the account attribute :object_count, :aliases => 'X-Account-Object-Count', :type => :integer + # Saves account settings (meta_temp_url_key) + # @return [Boolean] returns true if successfully updated def save service.post_set_meta_temp_url_key meta_temp_url_key true end + # Reload account with latest data from Cloud Files + # @return [Fog::Storage::Rackspace::Account] returns itself def reload response = service.head_containers merge_attributes response.headers diff --git a/lib/fog/rackspace/models/storage/directories.rb b/lib/fog/rackspace/models/storage/directories.rb index f36ebca3d..dedf2607d 100644 --- a/lib/fog/rackspace/models/storage/directories.rb +++ b/lib/fog/rackspace/models/storage/directories.rb @@ -9,15 +9,25 @@ module Fog model Fog::Storage::Rackspace::Directory + # Returns list of directories + # @return [Array] Retrieves a list directories. + # @note Fog's current implementation only returns 10,000 directories + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View_List_of_Containers-d1e1100.html def all data = service.get_containers.body load(data) end - # Supply the :cdn_cname option to use the Rackspace CDN CNAME functionality on the public_url. + # Retrieves directory + # @param [String] key of directory + # @param options [Hash]: + # @option options [String] cdn_cname CDN CNAME used when calling Directory#public_url + # @return [Fog::Storage::Rackspace:Directory] + # @example + # fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url # - # > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url - # => 'http://cdn.lunenburg.org/hayley-dancing.mov' + # @see Directory#public_url + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View-Container_Info-d1e1285.html def get(key, options = {}) data = service.get_container(key, options) directory = new(:key => key, :cdn_cname => options[:cdn_cname]) diff --git a/lib/fog/rackspace/models/storage/directory.rb b/lib/fog/rackspace/models/storage/directory.rb index d0065cb78..d4ca21071 100644 --- a/lib/fog/rackspace/models/storage/directory.rb +++ b/lib/fog/rackspace/models/storage/directory.rb @@ -8,14 +8,35 @@ module Fog class Directory < Fog::Model + # @!attribute [r] key + # @return [String] The name of the directory identity :key, :aliases => 'name' + # @!attribute [r] bytes + # @return [Integer] The number of bytes used by the directory attribute :bytes, :aliases => 'X-Container-Bytes-Used', :type => :integer + + # @!attribute [r] count + # @return [Integer] The number of objects in the directory attribute :count, :aliases => 'X-Container-Object-Count', :type => :integer + + # @!attribute [rw] cdn_name + # @return [String] The CDN CNAME to be used instead of the default CDN directory URI. The CDN CNAME will need to be setup setup in DNS and + # point to the default CDN directory URI. + # @note This value does not persist and will need to be specified each time a directory is created or retrieved + # @see Directories#get attribute :cdn_cname - attr_writer :public, :public_url + # @!attribute [w] public + # Required for compatibility with other Fog providers. Not Used. + attr_writer :public + # @!attribute [w] public_url + # Required for compatibility with other Fog providers. Not Used. + attr_writer :public_url + + # Set directory metadata + # @param [Hash,Fog::Storage::Rackspace::Metadata] hash contains key value pairs def metadata=(hash) if hash.is_a? Fog::Storage::Rackspace::Metadata attributes[:metadata] = hash @@ -25,6 +46,8 @@ module Fog attributes[:metadata] end + # Retrieve directory metadata + # @return [Fog::Storage::Rackspace::Metadata] metadata key value pairs. def metadata unless attributes[:metadata] response = service.head_container(key) @@ -33,6 +56,10 @@ module Fog attributes[:metadata] end + # Destroy the directory and remove it from CDN + # @return [Boolean] returns true if directory was deleted + # @note Directory must be empty before it is destroyed. + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Delete_Container-d1e1765.html def destroy requires :key service.delete_container(key) @@ -42,6 +69,8 @@ module Fog false end + # Returns collection of files in directory + # @return [Fog::Storage::Rackspace::Files] collection of files in directory def files @files ||= begin Fog::Storage::Rackspace::Files.new( @@ -51,6 +80,8 @@ module Fog end end + # Is directory published to CDN + # @return [Boolean] return true if published to CDN def public? if @public.nil? @public ||= (key && public_url) ? true : false @@ -58,6 +89,8 @@ module Fog @public end + # Reload directory with latest data from Cloud Files + # @return [Fog::Storage::Rackspace::Directory] returns itself def reload @public = nil @urls = nil @@ -65,23 +98,42 @@ module Fog super end - def public_url + # Returns the public url for the directory. + # If the directory has not been published to the CDN, this method will return nil as it is not publically accessable. This method will return the approprate + # url in the following order: + # + # 1. If the service used to access this directory was created with the option :rackspace_cdn_ssl => true, this method will return the SSL-secured URL. + # 2. If the cdn_cname attribute is populated this method will return the cname. + # 3. return the default CDN url. + # + # @return [String] public url for directory + def public_url return nil if urls.empty? - return urls[:ssl_uri] if service.ssl? + return urls[:ssl_uri] if service.ssl? cdn_cname || urls[:uri] end + # URL used to stream video to iOS devices. Cloud Files will auto convert to the approprate format. + # @return [String] iOS URL + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/iOS-Streaming-d1f3725.html def ios_url urls[:ios_uri] end + # URL used to stream resources + # @return [String] streaming url + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Streaming-CDN-Enabled_Containers-d1f3721.html def streaming_url urls[:streaming_uri] end + # Create or update directory and associated metadata + # @return [Boolean] returns true if directory was saved + # @note If public attribute is true, directory will be CDN enabled + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_Container-d1e1694.html def save requires :key - create_container + create_or_update_container raise Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided") if public? && !cdn_enabled? @urls = service.cdn.publish_container(self, public?) true @@ -99,7 +151,7 @@ module Fog @urls ||= service.cdn.urls(self) end - def create_container + def create_or_update_container headers = attributes[:metadata].nil? ? {} : metadata.to_headers service.put_container(key, headers) end diff --git a/lib/fog/rackspace/models/storage/file.rb b/lib/fog/rackspace/models/storage/file.rb index c07c86bad..a1ff67499 100644 --- a/lib/fog/rackspace/models/storage/file.rb +++ b/lib/fog/rackspace/models/storage/file.rb @@ -6,20 +6,52 @@ module Fog class File < Fog::Model + # @!attribute [r] key + # @return [String] The name of the file identity :key, :aliases => 'name' + # @!attribute [r] content_length + # @return [Integer] The content length of the file attribute :content_length, :aliases => ['bytes', 'Content-Length'], :type => :integer + + # @!attribute [rw] content_type + # @return [String] The MIME Media Type of the file + # @see http://www.iana.org/assignments/media-types attribute :content_type, :aliases => ['content_type', 'Content-Type'] + + # @!attribute [rw] etag + # The MD5 checksum of file. If included file creation request, will ensure integrity of the file. + # @return [String] MD5 checksum of file. attribute :etag, :aliases => ['hash', 'Etag'] + + # @!attribute [r] last_modified + # The last time the file was modified + # @return [Time] The last time the file was modified attribute :last_modified, :aliases => ['last_modified', 'Last-Modified'], :type => :time + + # @!attribute [rw] access_control_allow_origin + # A space delimited list of URLs allowed to make Cross Origin Requests. Format is http://www.example.com. An asterisk (*) allows all. + # @return [String] string containing a list of space delimited URLs + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/CORS_Container_Header-d1e1300.html attribute :access_control_allow_origin, :aliases => ['Access-Control-Allow-Origin'] - attribute :origin, :aliases => ['Origin'] - attr_writer :public + # @!attribute [rw] origin + # @return [String] The origin is the URI of the object's host. + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/CORS_Container_Header-d1e1300.html + attribute :origin, :aliases => ['Origin'] + # @!attribute [r] directory + # @return [Fog::Storage::Rackspace::Directory] directory containing file attr_accessor :directory + + # @!attribute [w] public + # @note Required for compatibility with other Fog providers. Not Used. attr_writer :public + # Returns the body/contents of file + # @example Retrieve and download contents of Cloud Files object to file system + # file_object = directory.files.get('germany.jpg') + # File.open('germany.jpg', 'w') {|f| f.write(file_object.body) } def body attributes[:body] ||= if last_modified collection.get(identity).body @@ -28,10 +60,17 @@ module Fog end end + # Sets the body/contents of file + # @param [String,File] new_body contents of file def body=(new_body) attributes[:body] = new_body end + # Copy file to another directory or directory + # @param [String] target_directory_key + # @param [String] target_file_key + # @param options [Hash] used to pass in file attributes + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Copy_Object-d1e2241.html def copy(target_directory_key, target_file_key, options={}) requires :directory, :key options['Content-Type'] ||= content_type if content_type @@ -42,12 +81,18 @@ module Fog target_directory.files.get(target_file_key) end + # Destroy the file + # @return [Boolean] returns true if file is destroyed + # @note Directory must be empty before destroying directory + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Delete_Object-d1e2264.html def destroy requires :directory, :key service.delete_object(directory.key, key) true end + # Set file metadata + # @param [Hash,Fog::Storage::Rackspace::Metadata] hash contains key value pairs def metadata=(hash) if hash.is_a? Fog::Storage::Rackspace::Metadata attributes[:metadata] = hash @@ -57,10 +102,13 @@ module Fog attributes[:metadata] end + # File metadata + # @return [Fog::Storage::Rackspace::Metadata] metadata key value pairs. def metadata attributes[:metadata] ||= Fog::Storage::Rackspace::Metadata.new(self) end + # Required for compatibility with other Fog providers. Not Used. def owner=(new_owner) if new_owner attributes[:owner] = { @@ -70,22 +118,42 @@ module Fog end end + # Is file published to CDN + # @return [Boolean] return true if published to CDN def public? directory.public? end + # Returns the public url for the file. + # If the file has not been published to the CDN, this method will return nil as it is not publically accessable. This method will return the approprate + # url in the following order: + # + # 1. If the service used to access this file was created with the option :rackspace_cdn_ssl => true, this method will return the SSL-secured URL. + # 2. If the directory's cdn_cname attribute is populated this method will return the cname. + # 3. return the default CDN url. + # + # @return [String] public url for file def public_url Files::file_url directory.public_url, key end + # URL used to stream video to iOS devices without needing to convert your video + # @return [String] iOS URL + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/iOS-Streaming-d1f3725.html def ios_url Files::file_url directory.ios_url, key end + # URL used to stream resources + # return [String] streaming url + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Streaming-CDN-Enabled_Containers-d1f3721.html def streaming_url Files::file_url directory.streaming_url, key end + # Immediately purge file from the CDN network + # @note You may only PURGE up to 25 objects per day. Any attempt to purge more than this will result in a 498 status code error (Rate Limited). + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Purge_CDN-Enabled_Objects-d1e3858.html def purge_from_cdn if public? service.cdn.purge(self) @@ -94,6 +162,9 @@ module Fog end end + # Create or updates file and associated metadata + # @param options [Hash] additional parameters to pass to Cloud Files + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_Update_Object-d1e1965.html def save(options = {}) requires :body, :directory, :key options['Content-Type'] = content_type if content_type diff --git a/lib/fog/rackspace/models/storage/files.rb b/lib/fog/rackspace/models/storage/files.rb index 4c875d1cf..9ce90013d 100644 --- a/lib/fog/rackspace/models/storage/files.rb +++ b/lib/fog/rackspace/models/storage/files.rb @@ -7,14 +7,35 @@ module Fog class Files < Fog::Collection + # @!attribute [rw] directory + # @return [String] The name of the directory + # @note Methods in this class require this attribute to be set attribute :directory + + # @!attribute [rw] limit + # @return [Integer] For an integer value n, limits the number of results to at most n values. + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html attribute :limit + + # @!attribute [rw] marker + # @return [String] Given a string value x, return object names greater in value than the specified marker. + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Large_Number_of_Objects-d1e1521.html attribute :marker + + # @!attribute [rw] path + # @return [String] For a string value x, return the object names nested in the pseudo path. + # Equivalent to setting delimiter to '/' and prefix to the path with a '/' on the end. attribute :path + + # @!attribute [rw] prefix + # @return [String] For a string value x, causes the results to be limited to object names beginning with the substring x. attribute :prefix model Fog::Storage::Rackspace::File + # Returns list of files + # @return [Array] Retrieves a list files. + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/List_Objects-d1e1284.html def all(options = {}) requires :directory options = { @@ -35,6 +56,10 @@ module Fog end end + # Calls block for each file in the directory + # @yieldparam [[Fog::Storage::Rackspace::File] + # @return [Fog::Storage::Rackspace::Directory] returns itself + # @note This method retrieves files in pages. Page size is defined by the limit attribute alias :each_file_this_page :each def each if !block_given? @@ -52,6 +77,24 @@ module Fog end end + # Retrieves file + # @param [String] key of file + # @yield get yields to block after chunk of data has been received (Optional) + # @yieldparam [String] data + # @yieldparam [Integer] remaining + # @yieldparam [Integer] content_length + # @return [Fog::Storage::Rackspace:File] + # @note If a block is provided, the body attribute will be empty. By default Chunk size is 1 MB. This value can be changed by passing the parameter :chunk_size + # into the :connection_options hash in the service constructor. + # @example Download an image from Cloud Files and save it to file + # + # File.open('download.jpg', 'w') do | f | + # my_directory.files.get("europe.jpg") do |data, remaing, content_length| + # f.syswrite data + # end + # end + # + # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Retrieve_Object-d1e1856.html def get(key, &block) requires :directory data = service.get_object(directory.key, key, &block) @@ -67,6 +110,10 @@ module Fog nil end + # Returns the public_url for the given object key + # @param key of the object + # @return [String] url for object + # @see Directory#public_url def get_url(key) requires :directory if self.directory.public_url @@ -74,6 +121,10 @@ module Fog end end + # View directory detail without loading file contents + # @param key - key of the object + # @param options Required for compatibility with other Fog providers. Not Used. + # @return [Fog::Storage::Rackspace::File] def head(key, options = {}) requires :directory data = service.head_object(directory.key, key) @@ -85,11 +136,18 @@ module Fog nil end + # Create a new file object + # @param [Hash] attributes of object + # @return [Fog::Storage::Rackspace::File] def new(attributes = {}) requires :directory super({ :directory => directory }.merge!(attributes)) end + # Returns an escaped object url + # @param [String] path of the url + # @param [String] key of the object + # @return [String] escaped file url def self.file_url(path, key) return nil unless path "#{path}/#{Fog::Rackspace.escape(key, '/')}" diff --git a/lib/fog/rackspace/models/storage/metadata.rb b/lib/fog/rackspace/models/storage/metadata.rb index f6b06eeee..9857938bb 100644 --- a/lib/fog/rackspace/models/storage/metadata.rb +++ b/lib/fog/rackspace/models/storage/metadata.rb @@ -20,20 +20,36 @@ module Fog CONTAINER_KEY_REGEX = /^#{CONTAINER_META_PREFIX}(.*)/ OBJECT_KEY_REGEX = /^#{OBJECT_META_PREFIX}(.*)/ + + # @!attribute [rw] data + # @return [Hash] underlying data store for metadata class + attr_reader :data + + # @!attribute [rw] parent + # @return [Fog::Storage::Rackspace::Directory,Fog::Storage::Rackspace::File] the parent object of the metadata + attr_reader :parent - attr_reader :data, :parent - + # Initialize + # @param [Fog::Storage::Rackspace::Directory,Fog::Storage::Rackspace::File] parent object of the metadata + # @param [Hash] hash containing initial metadata values def initialize(parent, hash={}) @data = hash || {} @deleted_hash = {} @parent = parent end - + + + # Delete key value pair from metadata + # @param [String] key to be deleted + # @return [Object] returns value for key + # @note Metadata must be deleted using this method in order to properly remove it from Cloud Files def delete(key) data.delete(key) @deleted_hash[key] = nil end - + + # Returns metadata in a format expected by Cloud Files + # @return [Hash] Metadata in a format expected by Cloud Files def to_headers headers = {} h = data.merge(@deleted_hash) @@ -45,6 +61,9 @@ module Fog headers end + # Creates metadata object from Cloud File Headers + # @param [Fog::Storage::Rackspace::Directory,Fog::Storage::Rackspace::File] parent object of the metadata + # @param [Hash] headers Cloud File headers def self.from_headers(parent, headers) metadata = Metadata.new(parent) headers.each_pair do |k, v| @@ -55,10 +74,14 @@ module Fog metadata end + # Returns true if method is implemented by Metadata class + # @param [Symbol] method_sym + # @param [Boolean] include_private def respond_to?(method_sym, include_private = false) super(method_sym, include_private) || data.respond_to?(method_sym, include_private) end - + + # Invoked by Ruby when obj is sent a message it cannot handle. def method_missing(method, *args, &block) data.send(method, *args, &block) end diff --git a/lib/fog/rackspace/storage.rb b/lib/fog/rackspace/storage.rb index 072c3c83a..52b661fb2 100644 --- a/lib/fog/rackspace/storage.rb +++ b/lib/fog/rackspace/storage.rb @@ -100,15 +100,21 @@ module Fog @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end + # Return Account Details + # @return [Fog::Storage::Rackspace::Account] account details object def account account = Fog::Storage::Rackspace::Account.new(:service => self) account.reload end + # Using SSL? + # @return [Boolean] return true if service is returning SSL-Secured URLs in public_url methods + # @see Directory#public_url def ssl? !rackspace_cdn_ssl.nil? end + # Resets presistent service connections def reload @connection.reset end From 8c56814d508253319679c3de4dd940f277afead3 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Fri, 8 Mar 2013 21:28:08 +0530 Subject: [PATCH 60/68] Minor fix: Ensure to send a valid Content-Type --- lib/fog/vcloud/requests/compute/configure_vm_network.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vcloud/requests/compute/configure_vm_network.rb b/lib/fog/vcloud/requests/compute/configure_vm_network.rb index e51e5b2c2..8d657c043 100644 --- a/lib/fog/vcloud/requests/compute/configure_vm_network.rb +++ b/lib/fog/vcloud/requests/compute/configure_vm_network.rb @@ -23,7 +23,7 @@ EOF request( :body => body, :expects => 202, - :headers => {'Content-Type' => network_info[:"vcloud_type"] }, + :headers => {'Content-Type' => network_info[:"type"] }, :method => 'PUT', :uri => "#{edit_uri}", :parse => true From 269e4e7ebac6b524bd505fca9dc12ff941ff4b32 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Fri, 8 Mar 2013 21:31:31 +0530 Subject: [PATCH 61/68] Check if a template requires a password or not --- lib/fog/vcloud/models/compute/catalog_item.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/fog/vcloud/models/compute/catalog_item.rb b/lib/fog/vcloud/models/compute/catalog_item.rb index a1b236993..da0fb0935 100644 --- a/lib/fog/vcloud/models/compute/catalog_item.rb +++ b/lib/fog/vcloud/models/compute/catalog_item.rb @@ -23,6 +23,14 @@ module Fog end end + def password_enabled? + load_unless_loaded! + customization_options = service.get_vapp_template(self.entity[:href]).body[:Children][:Vm][:GuestCustomizationSection] + return false if customization_options[:AdminPasswordEnabled] == "false" + return true if customization_options[:AdminPasswordEnabled] == "true" \ + and customization_options[:AdminPasswordAuto] == "false" \ + and ( options[:password].nil? or options[:password].empty? ) + end end end end From 13e1567a8dc961ff7f8ebf33d6fa6997b360ba65 Mon Sep 17 00:00:00 2001 From: Christopher Meiklejohn Date: Wed, 28 Mar 2012 17:34:50 -0400 Subject: [PATCH 62/68] Add Riak CS provider in Fog. --- lib/fog/aws/requests/storage/get_object.rb | 8 +- lib/fog/bin.rb | 1 + lib/fog/bin/riakcs.rb | 27 +++ lib/fog/core/errors.rb | 2 + lib/fog/providers.rb | 1 + lib/fog/riakcs.rb | 122 ++++++++++++ lib/fog/riakcs/provisioning.rb | 100 ++++++++++ .../requests/provisioning/create_user.rb | 77 ++++++++ .../requests/provisioning/disable_user.rb | 23 +++ .../requests/provisioning/enable_user.rb | 23 +++ .../riakcs/requests/provisioning/get_user.rb | 41 +++++ .../requests/provisioning/list_users.rb | 43 +++++ .../requests/provisioning/regrant_secret.rb | 23 +++ .../requests/provisioning/update_user.rb | 23 +++ lib/fog/riakcs/requests/usage/get_usage.rb | 68 +++++++ lib/fog/riakcs/usage.rb | 66 +++++++ tests/helpers/mock_helper.rb | 2 + .../provisioning/provisioning_tests.rb | 174 ++++++++++++++++++ tests/riakcs/requests/usage/usage_tests.rb | 29 +++ 19 files changed, 851 insertions(+), 2 deletions(-) create mode 100644 lib/fog/bin/riakcs.rb create mode 100644 lib/fog/riakcs.rb create mode 100644 lib/fog/riakcs/provisioning.rb create mode 100644 lib/fog/riakcs/requests/provisioning/create_user.rb create mode 100644 lib/fog/riakcs/requests/provisioning/disable_user.rb create mode 100644 lib/fog/riakcs/requests/provisioning/enable_user.rb create mode 100644 lib/fog/riakcs/requests/provisioning/get_user.rb create mode 100644 lib/fog/riakcs/requests/provisioning/list_users.rb create mode 100644 lib/fog/riakcs/requests/provisioning/regrant_secret.rb create mode 100644 lib/fog/riakcs/requests/provisioning/update_user.rb create mode 100644 lib/fog/riakcs/requests/usage/get_usage.rb create mode 100644 lib/fog/riakcs/usage.rb create mode 100644 tests/riakcs/requests/provisioning/provisioning_tests.rb create mode 100644 tests/riakcs/requests/usage/usage_tests.rb diff --git a/lib/fog/aws/requests/storage/get_object.rb b/lib/fog/aws/requests/storage/get_object.rb index 7843d8a00..7ad8bb3b7 100644 --- a/lib/fog/aws/requests/storage/get_object.rb +++ b/lib/fog/aws/requests/storage/get_object.rb @@ -14,6 +14,7 @@ module Fog # @option options If-Unmodified-Since [Time] Returns object only if it has not been modified since this time, otherwise returns 412 (Precodition Failed). # @option options Range [String] Range of object to download # @option options versionId [String] specify a particular version to retrieve + # @option options query[Hash] specify additional query string # # @return [Excon::Response] response: # * body [String]- Contents of object @@ -34,8 +35,11 @@ module Fog end params = { :headers => {} } + + params[:query] = options.delete('query') || {} + if version_id = options.delete('versionId') - params[:query] = {'versionId' => version_id} + params[:query] = params[:query].merge({'versionId' => version_id}) end params[:headers].merge!(options) if options['If-Modified-Since'] @@ -54,7 +58,7 @@ module Fog :host => "#{bucket_name}.#{@host}", :idempotent => true, :method => 'GET', - :path => CGI.escape(object_name), + :path => CGI.escape(object_name) })) end diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index 1b0c1c8e8..423f5f6d6 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -81,6 +81,7 @@ require 'fog/bin/local' require 'fog/bin/bare_metal_cloud' require 'fog/bin/ninefold' require 'fog/bin/rackspace' +require 'fog/bin/riakcs' require 'fog/bin/openstack' require 'fog/bin/ovirt' require 'fog/bin/serverlove' diff --git a/lib/fog/bin/riakcs.rb b/lib/fog/bin/riakcs.rb new file mode 100644 index 000000000..ee64bea43 --- /dev/null +++ b/lib/fog/bin/riakcs.rb @@ -0,0 +1,27 @@ +class RiakCS < Fog::Bin + class << self + + def class_for(key) + case key + when :provisioning + Fog::RiakCS::Provisioning + when :usage + Fog::RiakCS::Usage + else + raise ArgumentError, "Unrecognized service: #{key}" + end + end + + def [](service) + @@connections ||= Hash.new do |hash, key| + hash[key] = class_for(key) + end + @@connections[service] + end + + def services + Fog::RiakCS.services + end + + end +end diff --git a/lib/fog/core/errors.rb b/lib/fog/core/errors.rb index 4f26bb076..927c23254 100644 --- a/lib/fog/core/errors.rb +++ b/lib/fog/core/errors.rb @@ -71,6 +71,8 @@ An alternate file may be used by placing its path in the FOG_RC environment vari :rackspace_username: :rackspace_servicenet: :rackspace_cdn_ssl: + :riakcs_access_key_id: + :riakcs_secret_access_key: :stormondemand_username: :stormondemand_password: :terremark_username: diff --git a/lib/fog/providers.rb b/lib/fog/providers.rb index 0ac5f52e4..21327ac12 100644 --- a/lib/fog/providers.rb +++ b/lib/fog/providers.rb @@ -22,6 +22,7 @@ require 'fog/local' require 'fog/bare_metal_cloud' require 'fog/ninefold' require 'fog/rackspace' +require 'fog/riakcs' require 'fog/openstack' require 'fog/ovirt' require 'fog/serverlove' diff --git a/lib/fog/riakcs.rb b/lib/fog/riakcs.rb new file mode 100644 index 000000000..a98305dd9 --- /dev/null +++ b/lib/fog/riakcs.rb @@ -0,0 +1,122 @@ +require(File.expand_path(File.join(File.dirname(__FILE__), 'core'))) + +module Fog + module RiakCS + + module MultipartUtils + require 'net/http' + + class Headers + include Net::HTTPHeader + + def initialize + initialize_http_header({}) + end + + # Parse a single header line into its key and value + # @param [String] chunk a single header line + def self.parse(chunk) + line = chunk.strip + # thanks Net::HTTPResponse + return [nil,nil] if chunk =~ /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in + m = /\A([^:]+):\s*/.match(line) + [m[1], m.post_match] rescue [nil, nil] + end + + # Parses a header line and adds it to the header collection + # @param [String] chunk a single header line + def parse(chunk) + key, value = self.class.parse(chunk) + add_field(key, value) if key && value + end + end + + def parse(data, boundary) + contents = data.match(end_boundary_regex(boundary)).pre_match rescue "" + contents.split(inner_boundary_regex(boundary)).reject(&:empty?).map do |part| + parse_multipart_section(part) + end.compact + end + + def extract_boundary(header_string) + $1 if header_string =~ /boundary=([A-Za-z0-9\'()+_,-.\/:=?]+)/ + end + + private + def end_boundary_regex(boundary) + /\r?\n--#{Regexp.escape(boundary)}--\r?\n?/ + end + + def inner_boundary_regex(boundary) + /\r?\n--#{Regexp.escape(boundary)}\r?\n/ + end + + def parse_multipart_section(part) + headers = Headers.new + if md = part.match(/\r?\n\r?\n/) + body = md.post_match + md.pre_match.split(/\r?\n/).each do |line| + headers.parse(line) + end + + if headers["content-type"] =~ /multipart\/mixed/ + boundary = extract_boundary(headers.to_hash["content-type"].first) + parse(body, boundary) + else + {:headers => headers.to_hash, :body => body} + end + end + end + end + + module UserUtils + def update_riakcs_user(key_id, user) + response = @s3_connection.put_object('riak-cs', "user/#{key_id}", MultiJson.encode(user), { 'Content-Type' => 'application/json' }) + if !response.body.empty? + response.body = MultiJson.decode(response.body) + end + response + end + + def update_mock_user(key_id, user) + if data[key_id] + if status = user[:status] + data[key_id][:status] = status + end + + if regrant = user[:new_key_secret] + data[key_id][:key_secret] = rand(100).to_s + end + + Excon::Response.new.tap do |response| + response.status = 200 + response.body = data[key_id] + end + else + Excon::Response.new.tap do |response| + response.status = 403 + end + end + end + end + + module Utils + def configure_uri_options(options = {}) + @host = options[:host] || 'localhost' + @persistent = options[:persistent] || true + @port = options[:port] || 8080 + @scheme = options[:scheme] || 'http' + end + + def riakcs_uri + "#{@scheme}://#{@host}:#{@port}" + end + end + + extend Fog::Provider + + service(:provisioning, 'riakcs/provisioning', 'Provisioning') + service(:usage, 'riakcs/usage', 'Usage') + + end +end diff --git a/lib/fog/riakcs/provisioning.rb b/lib/fog/riakcs/provisioning.rb new file mode 100644 index 000000000..88765c54b --- /dev/null +++ b/lib/fog/riakcs/provisioning.rb @@ -0,0 +1,100 @@ +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'riakcs')) + +module Fog + module RiakCS + class Provisioning < Fog::Service + + class UserAlreadyExists < Fog::RiakCS::Provisioning::Error; end + class ServiceUnavailable < Fog::RiakCS::Provisioning::Error; end + + requires :riakcs_access_key_id, :riakcs_secret_access_key + recognizes :host, :path, :port, :scheme, :persistent + + request_path 'fog/riakcs/requests/provisioning' + request :create_user + request :update_user + request :disable_user + request :enable_user + request :list_users + request :get_user + request :regrant_secret + + class Mock + include Utils + + def self.data + @data ||= Hash.new({}) + end + + def self.reset + @data = nil + end + + def initialize(options = {}) + configure_uri_options(options) + end + + def data + self.class.data[riakcs_uri] + end + + def reset_data + self.class.data.delete(riakcs_uri) + end + end + + class Real + include Utils + + def initialize(options = {}) + require 'mime/types' + require 'multi_json' + + configure_uri_options(options) + @riakcs_access_key_id = options[:riakcs_access_key_id] + @riakcs_secret_access_key = options[:riakcs_secret_access_key] + @connection_options = options[:connection_options] || {} + @persistent = options[:persistent] || false + + @raw_connection = Fog::Connection.new(riakcs_uri, @persistent, @connection_options) + + @s3_connection = Fog::Storage.new( + :provider => 'AWS', + :aws_access_key_id => @riakcs_access_key_id, + :aws_secret_access_key => @riakcs_secret_access_key, + :host => @host, + :port => @port, + :scheme => @scheme + ) + end + + def request(params, parse_response = true, &block) + begin + response = @raw_connection.request(params.merge({ + :host => @host, + :path => "#{@path}/#{params[:path]}", + }), &block) + rescue Excon::Errors::HTTPStatusError => error + if match = error.message.match(/(.*?)<\/Code>(?:.*(.*?)<\/Message>)?/m) + case match[1] + when 'UserAlreadyExists' + raise Fog::RiakCS::Provisioning.const_get(match[1]).new + when 'ServiceUnavailable' + raise Fog::RiakCS::Provisioning.const_get(match[1]).new + else + raise error + end + else + raise error + end + end + if !response.body.empty? && parse_response + response.body = MultiJson.decode(response.body) + end + response + end + end + + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/create_user.rb b/lib/fog/riakcs/requests/provisioning/create_user.rb new file mode 100644 index 000000000..b98fd9dc3 --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/create_user.rb @@ -0,0 +1,77 @@ +module Fog + module RiakCS + class Provisioning + class Real + def create_user(email, name, options = {}) + payload = MultiJson.encode({ :email => email, :name => name }) + headers = { 'Content-Type' => 'application/json' } + + if(options[:anonymous]) + request( + :expects => [201], + :method => 'POST', + :path => 'user', + :body => payload, + :headers => headers + ) + else + begin + response = @s3_connection.put_object('riak-cs', 'user', payload, headers) + if !response.body.empty? + case response.headers['Content-Type'] + when 'application/json' + response.body = MultiJson.decode(response.body) + end + end + response + rescue Excon::Errors::Conflict => e + raise Fog::RiakCS::Provisioning::UserAlreadyExists.new + rescue Excon::Errors::BadRequest => e + raise Fog::RiakCS::Provisioning::ServiceUnavailable.new + end + end + end + end + + class Mock + def invalid_email?(email) + !email.include?('@') + end + + def user_exists?(email) + data.detect do |key, value| + value[:email] == email + end + end + + def create_user(email, name, options = {}) + if invalid_email?(email) + raise Fog::RiakCS::Provisioning::ServiceUnavailable, "The email address you provided is not a valid." + end + + if user_exists?(email) + raise Fog::RiakCS::Provisioning::UserAlreadyExists, "User with email #{email} already exists." + end + + key_id = rand(1000).to_s + key_secret = rand(1000).to_s + data[key_id] = { :email => email, :name => name, :status => 'enabled', :key_secret => key_secret } + + Excon::Response.new.tap do |response| + response.status = 200 + response.headers['Content-Type'] = 'application/json' + response.body = { + "email" => data[:email], + "display_name" => data[:name], + "name" => "user123", + "key_id" => key_id, + "key_secret" => key_secret, + "id" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "status" => "enabled" + } + end + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/disable_user.rb b/lib/fog/riakcs/requests/provisioning/disable_user.rb new file mode 100644 index 000000000..1ed7705a4 --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/disable_user.rb @@ -0,0 +1,23 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include UserUtils + include MultipartUtils + + def disable_user(key_id) + update_riakcs_user(key_id, { :status => 'disabled' }) + end + end + + class Mock + include UserUtils + + def disable_user(key_id) + update_mock_user(key_id, { :status => 'disabled' }) + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/enable_user.rb b/lib/fog/riakcs/requests/provisioning/enable_user.rb new file mode 100644 index 000000000..d2556e3bc --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/enable_user.rb @@ -0,0 +1,23 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include UserUtils + include MultipartUtils + + def enable_user(key_id) + update_riakcs_user(key_id, { :status => 'enabled' }) + end + end + + class Mock + include UserUtils + + def enable_user(key_id) + update_mock_user(key_id, { :status => 'enabled' }) + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/get_user.rb b/lib/fog/riakcs/requests/provisioning/get_user.rb new file mode 100644 index 000000000..793dca95a --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/get_user.rb @@ -0,0 +1,41 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include MultipartUtils + + def get_user(key_id) + response = @s3_connection.get_object('riak-cs', "user/#{key_id}", { 'Accept' => 'application/json' }) + response.body = MultiJson.decode(response.body) + response + end + end + + class Mock + def get_user(key_id) + if user = data[key_id] + Excon::Response.new.tap do |response| + response.status = 200 + response.headers['Content-Type'] = 'application/json' + response.body = { + "email" => user[:email], + "display_name" => user[:name], + "name" => "user123", + "key_id" => "XXXXXXXXXXXXXXXXXXXX", + "key_secret" => user[:key_secret], + "id" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "status" => user[:status] + } + end + else + Excon::Response.new.tap do |response| + response.status = 404 + response.headers['Content-Type'] = 'application/json' + end + end + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/list_users.rb b/lib/fog/riakcs/requests/provisioning/list_users.rb new file mode 100644 index 000000000..c747b8b2d --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/list_users.rb @@ -0,0 +1,43 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include MultipartUtils + + def list_users(options = {}) + response = @s3_connection.get_object('riak-cs', 'users', { 'Accept' => 'application/json', 'query' => options }) + + boundary = extract_boundary(response.headers['Content-Type']) + parts = parse(response.body, boundary) + decoded = parts.map { |part| MultiJson.decode(part[:body]) } + + response.body = decoded.flatten + + response + end + end + + class Mock + def list_users(options = {}) + filtered_data = options[:status] ? data.select { |key, value| value[:status] == options[:status] } : data + + Excon::Response.new.tap do |response| + response.status = 200 + response.body = filtered_data.map do |key, value| + { + "email" => value[:email], + "display_name" => value[:name], + "name" => "user123", + "key_id" => key, + "key_secret" => value[:key_secret], + "id" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + "status" => value[:status] + } + end.compact + end + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/regrant_secret.rb b/lib/fog/riakcs/requests/provisioning/regrant_secret.rb new file mode 100644 index 000000000..a04fff8cf --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/regrant_secret.rb @@ -0,0 +1,23 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include UserUtils + include MultipartUtils + + def regrant_secret(key_id) + update_riakcs_user(key_id, { :new_key_secret => true }) + end + end + + class Mock + include UserUtils + + def regrant_secret(key_id) + update_mock_user(key_id, { :new_key_secret => true }) + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/provisioning/update_user.rb b/lib/fog/riakcs/requests/provisioning/update_user.rb new file mode 100644 index 000000000..40abb0fdf --- /dev/null +++ b/lib/fog/riakcs/requests/provisioning/update_user.rb @@ -0,0 +1,23 @@ +module Fog + module RiakCS + class Provisioning + class Real + include Utils + include UserUtils + include MultipartUtils + + def update_user(key_id, user) + update_riakcs_user(key_id, user) + end + end + + class Mock + include UserUtils + + def update_user(key_id, user) + update_mock_user(key_id, user) + end + end + end + end +end diff --git a/lib/fog/riakcs/requests/usage/get_usage.rb b/lib/fog/riakcs/requests/usage/get_usage.rb new file mode 100644 index 000000000..ee35357ed --- /dev/null +++ b/lib/fog/riakcs/requests/usage/get_usage.rb @@ -0,0 +1,68 @@ +module Fog + module RiakCS + class Usage + module Utils + TYPES_TO_STRING = { :access => 'a', :storage => 'b' } + DEFAULT_TYPES = TYPES_TO_STRING.keys + DEFAULT_FORMAT = :json + + def sanitize_and_convert_time(time) + time.utc.iso8601.gsub(/[:-]/, '') + end + + def format_and_types_to_path(format, types) + format_character = format.to_s.split('').first + type_characters = types.map { |t| TYPES_TO_STRING[t] }.compact + + [type_characters, format_character].flatten.compact.join + end + + def request_uri(access_key_id, options) + format = DEFAULT_FORMAT + types = options[:types] || DEFAULT_TYPES + start_time = options[:start_time] || Time.now.utc - 86400 + end_time = options[:end_time] || Time.now.utc + + [access_key_id, + format_and_types_to_path(format, types), + sanitize_and_convert_time(start_time), + sanitize_and_convert_time(end_time)].join('.') + end + end + + class Real + include Utils + + def get_usage(access_key_id, options = {}) + response = @connection.get_object('riak-cs', ["usage", request_uri(access_key_id, options)].join("/")) + + if !response.body.empty? + response.body = MultiJson.decode(response.body) + end + response + end + end + + class Mock + include Utils + + def get_usage(access_key, options = {}) + Excon::Response.new.tap do |response| + response.status = 200 + response.headers['Content-Type'] = 'application/json' + response.body = { + 'Access' => { + 'Nodes' => [], + 'Errors' => [] + }, + 'Storage' => { + 'Samples' => [], + 'Errors' => [] + } + } + end + end + end + end + end +end diff --git a/lib/fog/riakcs/usage.rb b/lib/fog/riakcs/usage.rb new file mode 100644 index 000000000..51df897f0 --- /dev/null +++ b/lib/fog/riakcs/usage.rb @@ -0,0 +1,66 @@ +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'riakcs')) +require 'time' + +module Fog + module RiakCS + class Usage < Fog::Service + + requires :riakcs_access_key_id, :riakcs_secret_access_key + recognizes :host, :path, :port, :scheme, :persistent + + request_path 'fog/riakcs/requests/usage' + request :get_usage + + class Mock + include Utils + + def self.data + @data ||= Hash.new do |hash, key| + hash[key] = {} + end + end + + def self.reset + @data = nil + end + + def initialize(options = {}) + configure_uri_options(options) + end + + def data + self.class.data[riakcs_uri] + end + + def reset_data + self.class.data.delete(riakcs_uri) + end + end + + class Real + include Utils + + def initialize(options = {}) + require 'mime/types' + require 'multi_json' + + configure_uri_options(options) + @riakcs_access_key_id = options[:riakcs_access_key_id] + @riakcs_secret_access_key = options[:riakcs_secret_access_key] + @connection_options = options[:connection_options] || {} + @persistent = options[:persistent] || false + + @connection = Fog::Storage.new( + :provider => 'AWS', + :aws_access_key_id => @riakcs_access_key_id, + :aws_secret_access_key => @riakcs_secret_access_key, + :host => @host, + :port => @port, + :scheme => @scheme + ) + end + end + + end + end +end diff --git a/tests/helpers/mock_helper.rb b/tests/helpers/mock_helper.rb index 9b6e0f11a..de354d2a6 100644 --- a/tests/helpers/mock_helper.rb +++ b/tests/helpers/mock_helper.rb @@ -69,6 +69,8 @@ if Fog.mock? :libvirt_uri => 'qemu://libvirt/system', :rackspace_api_key => 'rackspace_api_key', :rackspace_username => 'rackspace_username', + :riakcs_access_key_id => 'riakcs_access_key_id', + :riakcs_secret_access_key => 'riakcs_secret_access_key', :storm_on_demand_username => 'storm_on_demand_username', :storm_on_demand_password => 'storm_on_demand_password', :vcloud_host => 'vcloud_host', diff --git a/tests/riakcs/requests/provisioning/provisioning_tests.rb b/tests/riakcs/requests/provisioning/provisioning_tests.rb new file mode 100644 index 000000000..43d6dfabc --- /dev/null +++ b/tests/riakcs/requests/provisioning/provisioning_tests.rb @@ -0,0 +1,174 @@ +Shindo.tests('RiakCS::Provisioning | provisioning requests', ['riakcs']) do + + current_timestamp = Time.now.to_i + + user_format = { + 'email' => String, + 'display_name' => String, + 'name' => String, + 'key_id' => String, + 'key_secret' => String, + 'id' => String, + 'status' => String, + } + + tests('User creation') do + + tests('is successful').returns(String) do + + # Create a user. + # + email, name = "successful_user_creation_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + key_id.class + + end + + tests('is successful anonymously').returns(String) do + + # Create a user. + # + email, name = "successful_anonymous_user_creation_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name, :anonymous => true).body['key_id'] + key_id.class + + end + + tests('fails if duplicate').raises(Fog::RiakCS::Provisioning::UserAlreadyExists) do + 2.times do + email, name = "failed_duplicate_user_creation_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + end + end + + tests('fails if invalid email').raises(Fog::RiakCS::Provisioning::ServiceUnavailable) do + email, name = "failed_duplicate_user_creation_test_#{current_timestamp}", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + end + + end + + tests('User disable') do + + tests('is successful').returns(200) do + + # Create a user. + # + email, name = "successful_user_disable_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + Fog::RiakCS[:provisioning].disable_user(key_id).status + + end + + end + + tests('User enable') do + + tests('is successful').returns(200) do + + # Create a user. + # + email, name = "successful_user_disable_enable_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + Fog::RiakCS[:provisioning].disable_user(key_id).status + Fog::RiakCS[:provisioning].enable_user(key_id).status + + end + + end + + tests('User granted new key secret') do + + tests('is successful').returns(true) do + + # Create a user. + # + email, name = "successful_user_regrant_test_#{current_timestamp}@example.com", "Fog User" + user = Fog::RiakCS[:provisioning].create_user(email, name).body + key_id, key_secret = user['key_id'], user['key_secret'] + + Fog::RiakCS[:provisioning].regrant_secret(key_id).status + + # Verify new secret. + # + new_key_secret = Fog::RiakCS[:provisioning].get_user(key_id).body['key_secret'] + new_key_secret != key_secret + + end + + end + + tests('User retrieval') do + + tests('is successful').formats(user_format) do + + # Create a user. + # + email, name = "user_retrieval_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + # Get user details. + # + Fog::RiakCS[:provisioning].get_user(key_id).body + + end + + end + + tests('User listing') do + + tests('sucessfully lists users').formats(user_format) do + + # Create a user. + # + email, name = "user_listing_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + # Ensure the list users response contains the user that we just + # created. + # + Fog::RiakCS[:provisioning].list_users.body.select { |x| x['email'] == email }.first + + end + + tests('successfully lists users containing no disabled users').returns(nil) do + + # Create a user. + # + email, name = "user_listing_without_disabled_users_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + # Disable that user. + # + Fog::RiakCS[:provisioning].disable_user(key_id) + + # Ensure the list users response does not contain the user that we + # just created and disabled. + # + Fog::RiakCS[:provisioning].list_users(:status => :enabled).body.select { |x| x['Email'] == email }.first + + end + + tests('successfully lists users containing disabled users').formats(user_format) do + + # Create a user. + # + email, name = "user_listing_with_disabled_users_test_#{current_timestamp}@example.com", "Fog User" + key_id = Fog::RiakCS[:provisioning].create_user(email, name).body['key_id'] + + # Disable that user. + # + Fog::RiakCS[:provisioning].disable_user(key_id) + + # Ensure the list users response contains the user that we just + # created and disabled. + # + Fog::RiakCS[:provisioning].list_users.body.select { |x| x['email'] == email }.first + + end + + end + +end diff --git a/tests/riakcs/requests/usage/usage_tests.rb b/tests/riakcs/requests/usage/usage_tests.rb new file mode 100644 index 000000000..f46b3e0b1 --- /dev/null +++ b/tests/riakcs/requests/usage/usage_tests.rb @@ -0,0 +1,29 @@ +Shindo.tests('RiakCS::Usage | usage requests', ['riakcs']) do + + @blank_usage_format = { + 'Access' => { + 'Nodes' => [], + 'Errors' => [] + }, + 'Storage' => { + 'Samples' => [], + 'Errors' => [] + } + } + + tests('Statistics retrieval with no data returned') do + + start_time = Time.now.utc + 86400 + end_time = start_time + 86400 + + tests('via JSON').returns(@blank_usage_format) do + + Fog::RiakCS[:usage].get_usage(Fog.credentials[:riakcs_access_key_id], + :types => [:access, :storage], + :start_time => start_time, + :end_time => end_time).body + + end + end + +end From c63ba09b88eb28edfc1fa4f6d5b14f4a27ac727f Mon Sep 17 00:00:00 2001 From: althras Date: Sat, 9 Mar 2013 23:48:39 +0800 Subject: [PATCH 63/68] Changed GoogleAccessKeyId to GoogleAccessId I struggled with this for four hours today. Finally found this: https://groups.google.com/forum/?fromgroups=#!topic/gs-discussion/iahTA7C2nmE which led me to this: https://developers.google.com/storage/docs/accesscontrol#Signed-URLs Tested that it works, but don't want to do gsubs for this in every URL generated by Carrierwave + fog in my app. --- lib/fog/google/storage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/google/storage.rb b/lib/fog/google/storage.rb index c64ec56b7..23a969905 100644 --- a/lib/fog/google/storage.rb +++ b/lib/fog/google/storage.rb @@ -55,7 +55,7 @@ module Fog params[:headers]['Date'] = expires.to_i params[:path] = CGI.escape(params[:path]).gsub('%2F', '/') query = [params[:query]].compact - query << "GoogleAccessKeyId=#{@google_storage_access_key_id}" + query << "GoogleAccessId=#{@google_storage_access_key_id}" query << "Signature=#{CGI.escape(signature(params))}" query << "Expires=#{params[:headers]['Date']}" "#{params[:host]}/#{params[:path]}?#{query.join('&')}" From c3a69ad29e63f25c70742a9f86fa6cd1c53ef1ca Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Sat, 9 Mar 2013 14:29:33 -0500 Subject: [PATCH 64/68] 1620: Try to add some guards around possible nil objects based on associations in VPCs. --- .../aws/requests/compute/associate_address.rb | 22 ++++++++++++------- tests/aws/requests/compute/address_tests.rb | 4 ++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/fog/aws/requests/compute/associate_address.rb b/lib/fog/aws/requests/compute/associate_address.rb index 86ee02aac..605fb56e3 100644 --- a/lib/fog/aws/requests/compute/associate_address.rb +++ b/lib/fog/aws/requests/compute/associate_address.rb @@ -48,19 +48,25 @@ module Fog address = public_ip.nil? ? nil : self.data[:addresses][public_ip] if ((instance && address) || (instance && !allocation_id.nil?) || (!allocation_id.nil? && !network_interface_id.nil?)) if !allocation_id.nil? - allocation_ip = describe_addresses( 'allocation-id' => "#{allocation_id}").body['addressesSet'] - public_ip = allocation_ip['publicIp'] + allocation_ip = describe_addresses( 'allocation-id' => "#{allocation_id}").body['addressesSet'].first + if !allocation_ip.nil? + public_ip = allocation_ip['publicIp'] + end end - if current_instance = self.data[:instances][address['instanceId']] - current_instance['ipAddress'] = current_instance['originalIpAddress'] - end - address['instanceId'] = instance_id + if !address.nil? + if current_instance = self.data[:instances][address['instanceId']] + current_instance['ipAddress'] = current_instance['originalIpAddress'] + end + address['instanceId'] = instance_id + end # detach other address (if any) if self.data[:addresses][instance['ipAddress']] self.data[:addresses][instance['ipAddress']]['instanceId'] = nil end - instance['ipAddress'] = public_ip - instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip) + if !public_ip.nil? + instance['ipAddress'] = public_ip + instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip) + end response.status = 200 if !instance_id.nil? && !public_ip.nil? response.body = { diff --git a/tests/aws/requests/compute/address_tests.rb b/tests/aws/requests/compute/address_tests.rb index 114e34b8b..4a99b1793 100644 --- a/tests/aws/requests/compute/address_tests.rb +++ b/tests/aws/requests/compute/address_tests.rb @@ -49,6 +49,10 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do Fog::Compute[:aws].disassociate_address(@public_ip).body end + tests("#associate_addresses('#{@server.id}', nil, nil, '#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do + Fog::Compute[:aws].associate_address(@server.id, nil, nil, @vpc_allocation_id).body + end + tests("#release_address('#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do Fog::Compute[:aws].release_address(@public_ip).body end From e0f88c9c759324061bfca9e238d1078ce6925eae Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Sat, 9 Mar 2013 14:29:33 -0500 Subject: [PATCH 65/68] 1620: Try to add some guards around possible nil objects based on associations in VPCs. --- .../aws/requests/compute/associate_address.rb | 20 ++++++++++++------- tests/aws/requests/compute/address_tests.rb | 4 ++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/fog/aws/requests/compute/associate_address.rb b/lib/fog/aws/requests/compute/associate_address.rb index 86ee02aac..49b6f2cd0 100644 --- a/lib/fog/aws/requests/compute/associate_address.rb +++ b/lib/fog/aws/requests/compute/associate_address.rb @@ -48,19 +48,25 @@ module Fog address = public_ip.nil? ? nil : self.data[:addresses][public_ip] if ((instance && address) || (instance && !allocation_id.nil?) || (!allocation_id.nil? && !network_interface_id.nil?)) if !allocation_id.nil? - allocation_ip = describe_addresses( 'allocation-id' => "#{allocation_id}").body['addressesSet'] - public_ip = allocation_ip['publicIp'] + allocation_ip = describe_addresses( 'allocation-id' => "#{allocation_id}").body['addressesSet'].first + if !allocation_ip.nil? + public_ip = allocation_ip['publicIp'] + end end - if current_instance = self.data[:instances][address['instanceId']] - current_instance['ipAddress'] = current_instance['originalIpAddress'] + if !address.nil? + if current_instance = self.data[:instances][address['instanceId']] + current_instance['ipAddress'] = current_instance['originalIpAddress'] + end + address['instanceId'] = instance_id end - address['instanceId'] = instance_id # detach other address (if any) if self.data[:addresses][instance['ipAddress']] self.data[:addresses][instance['ipAddress']]['instanceId'] = nil end - instance['ipAddress'] = public_ip - instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip) + if !public_ip.nil? + instance['ipAddress'] = public_ip + instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip) + end response.status = 200 if !instance_id.nil? && !public_ip.nil? response.body = { diff --git a/tests/aws/requests/compute/address_tests.rb b/tests/aws/requests/compute/address_tests.rb index 114e34b8b..4a99b1793 100644 --- a/tests/aws/requests/compute/address_tests.rb +++ b/tests/aws/requests/compute/address_tests.rb @@ -49,6 +49,10 @@ Shindo.tests('Fog::Compute[:aws] | address requests', ['aws']) do Fog::Compute[:aws].disassociate_address(@public_ip).body end + tests("#associate_addresses('#{@server.id}', nil, nil, '#{@vpc_allocation_id}')").formats(AWS::Compute::Formats::BASIC) do + Fog::Compute[:aws].associate_address(@server.id, nil, nil, @vpc_allocation_id).body + end + tests("#release_address('#{@public_ip}')").formats(AWS::Compute::Formats::BASIC) do Fog::Compute[:aws].release_address(@public_ip).body end From c306b7c5a28f5d5e1e65c3b4f7f4c8b5c6ef82c4 Mon Sep 17 00:00:00 2001 From: Weston Platter Date: Sun, 10 Mar 2013 17:14:57 -0500 Subject: [PATCH 66/68] [docs::was::cdn] reformatted in YARD format. no content changes, just format changes. --- .../aws/requests/cdn/delete_distribution.rb | 12 ++- .../cdn/delete_streaming_distribution.rb | 12 ++- lib/fog/aws/requests/cdn/get_distribution.rb | 59 +++++++------ .../aws/requests/cdn/get_distribution_list.rb | 62 +++++++------- lib/fog/aws/requests/cdn/get_invalidation.rb | 28 ++++--- .../aws/requests/cdn/get_invalidation_list.rb | 32 ++++--- .../cdn/get_streaming_distribution.rb | 49 +++++------ .../cdn/get_streaming_distribution_list.rb | 62 +++++++------- lib/fog/aws/requests/cdn/post_distribution.rb | 82 +++++++++--------- lib/fog/aws/requests/cdn/post_invalidation.rb | 32 ++++--- .../cdn/post_streaming_distribution.rb | 58 +++++++------ .../requests/cdn/put_distribution_config.rb | 84 +++++++++---------- .../cdn/put_streaming_distribution_config.rb | 64 +++++++------- 13 files changed, 303 insertions(+), 333 deletions(-) diff --git a/lib/fog/aws/requests/cdn/delete_distribution.rb b/lib/fog/aws/requests/cdn/delete_distribution.rb index 389b94008..43f7501db 100644 --- a/lib/fog/aws/requests/cdn/delete_distribution.rb +++ b/lib/fog/aws/requests/cdn/delete_distribution.rb @@ -3,15 +3,13 @@ module Fog class AWS class Real - # Delete a distribution from CloudFront + # Delete a distribution from CloudFront. # - # ==== Parameters - # * distribution_id<~String> - Id of distribution to delete - # * etag<~String> - etag of that distribution from earlier get or put + # @param distribution_id [String] Id of distribution to delete. + # @param etag [String] etag of that distribution from earlier get or put # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteDistribution.html + def delete_distribution(distribution_id, etag) request({ :expects => 204, diff --git a/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb b/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb index 36ccf8c08..e5def6876 100644 --- a/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb +++ b/lib/fog/aws/requests/cdn/delete_streaming_distribution.rb @@ -3,15 +3,13 @@ module Fog class AWS class Real - # Delete a streaming distribution from CloudFront + # Delete a streaming distribution from CloudFront. # - # ==== Parameters - # * distribution_id<~String> - Id of distribution to delete - # * etag<~String> - etag of that distribution from earlier get or put + # @param distribution_id [String] Id of distribution to delete. + # @parma etag [String] Etag of that distribution from earlier get or put # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteStreamingDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/DeleteStreamingDistribution.html + def delete_streaming_distribution(distribution_id, etag) request({ :expects => 204, diff --git a/lib/fog/aws/requests/cdn/get_distribution.rb b/lib/fog/aws/requests/cdn/get_distribution.rb index e9c4e0f7c..61f423659 100644 --- a/lib/fog/aws/requests/cdn/get_distribution.rb +++ b/lib/fog/aws/requests/cdn/get_distribution.rb @@ -5,42 +5,39 @@ module Fog require 'fog/aws/parsers/cdn/distribution' - # Get information about a distribution from CloudFront + # Get information about a distribution from CloudFront. # - # ==== Parameters - # * distribution_id<~String> - id of distribution + # @param distribution_id [String] Id of distribution. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content + # @return [Excon::Response] + # * body [Hash]: + # * S3Origin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] - Optional: Used when serving private content. # or - # * 'CustomOrigin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'www.example.com' - # * 'HTTPPort'<~Integer> - HTTP port of origin, in [80, 443] or (1024...65535) - # * 'HTTPSPort'<~Integer> - HTTPS port of origin, in [80, 443] or (1024...65535) - # * 'OriginProtocolPolicy'<~String> - Policy on using http vs https, in ['http-only', 'match-viewer'] + # * CustomOrigin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'. + # * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535). + # * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535). + # * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer']. # - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Status'<~String> - Status of distribution - # * 'DistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'InProgressInvalidationBatches'<~Integer> - number of invalidation batches in progress - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with - # * 'Origin'<~String> - s3 origin bucket - # * 'TrustedSigners'<~Array> - trusted signers + # * Id [String] Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Status [String] - Status of distribution. + # * DistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * InProgressInvalidationBatches [Integer] - Number of invalidation batches in progress. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. + # * Origin [String] - S3 origin bucket. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetDistribution.html + def get_distribution(distribution_id) request({ :expects => 200, diff --git a/lib/fog/aws/requests/cdn/get_distribution_list.rb b/lib/fog/aws/requests/cdn/get_distribution_list.rb index de8aee9a6..570008f03 100644 --- a/lib/fog/aws/requests/cdn/get_distribution_list.rb +++ b/lib/fog/aws/requests/cdn/get_distribution_list.rb @@ -5,43 +5,39 @@ module Fog require 'fog/aws/parsers/cdn/get_distribution_list' - # List information about distributions in CloudFront + # List information about distributions in CloudFront. # - # ==== Parameters - # * options<~Hash> - config arguments for list. Defaults to {}. - # * 'Marker'<~String> - limits object keys to only those that appear - # lexicographically after its value. - # * 'MaxItems'<~Integer> - limits number of object keys returned + # @param options [Hash] Config arguments for list. + # @option options Marker [String] Limits object keys to only those that appear lexicographically after its value. + # @option options MaxItems [Integer] Limits number of object keys returned. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated - # * 'Marker'<~String> - Marker specified for query - # * 'MaxItems'<~Integer> - Maximum number of keys specified for query - # * 'NextMarker'<~String> - Marker to specify for next page (id of last result of current page) - # * 'DistributionSummary'<~Array>: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content + # @return [Excon::Response] + # * body [Hash]: + # * IsTruncated [Boolean] - Whether or not the listing is truncated. + # * Marker [String] Marker specified for query. + # * MaxItems [Integer] - Maximum number of keys specified for query. + # * NextMarker [String] - Marker to specify for next page (id of last result of current page). + # * DistributionSummary [Array]: + # * S3Origin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] - Optional: Used when serving private content. # or - # * 'CustomOrigin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'www.example.com' - # * 'HTTPPort'<~Integer> - HTTP port of origin, in [80, 443] or (1024...65535) - # * 'HTTPSPort'<~Integer> - HTTPS port of origin, in [80, 443] or (1024...65535) - # * 'OriginProtocolPolicy'<~String> - Policy on using http vs https, in ['http-only', 'match-viewer'] - # * 'Comment'<~String> - comment associated with distribution - # * 'CNAME'<~Array> - array of associated cnames - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Origin'<~String> - s3 origin bucket - # * 'Status'<~String> - Status of distribution - # * 'TrustedSigners'<~Array> - trusted signers + # * CustomOrigin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'. + # * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535). + # * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535). + # * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer']. + # * Comment [String] - Comment associated with distribution. + # * CNAME [Array] - Array of associated cnames. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Origin [String] - S3 origin bucket. + # * Status [String] - Status of distribution. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListDistributions.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListDistributions.html + # def get_distribution_list(options = {}) request({ :expects => 200, diff --git a/lib/fog/aws/requests/cdn/get_invalidation.rb b/lib/fog/aws/requests/cdn/get_invalidation.rb index 97beeb043..57e242ff5 100644 --- a/lib/fog/aws/requests/cdn/get_invalidation.rb +++ b/lib/fog/aws/requests/cdn/get_invalidation.rb @@ -5,19 +5,21 @@ module Fog require 'fog/aws/parsers/cdn/get_invalidation' - # ==== Parameters - # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'Id'<~String> - Invalidation id - # * 'Status'<~String> - # * 'CreateTime'<~String> - # * 'InvalidationBatch'<~Array>: - # * 'Path'<~String> - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/2010-11-01/APIReference/GetInvalidation.html - + # Get invalidation. + # + # @param distribution_id [String] Distribution id. + # @param invalidation_id [String] Invalidation id. + # + # @return [Excon::Response] + # * body [Hash]: + # * Id [String] - Invalidation id. + # * Status [String] + # * CreateTime [String] + # * InvalidationBatch [Array]: + # * Path [String] + # + # @see http://docs.amazonwebservices.com/AmazonCloudFront/2010-11-01/APIReference/GetInvalidation.html + def get_invalidation(distribution_id, invalidation_id) request({ :expects => 200, diff --git a/lib/fog/aws/requests/cdn/get_invalidation_list.rb b/lib/fog/aws/requests/cdn/get_invalidation_list.rb index a662d37e7..52ce4adde 100644 --- a/lib/fog/aws/requests/cdn/get_invalidation_list.rb +++ b/lib/fog/aws/requests/cdn/get_invalidation_list.rb @@ -5,25 +5,23 @@ module Fog require 'fog/aws/parsers/cdn/get_invalidation_list' - # ==== Parameters - # * options<~Hash> - config arguments for list. Defaults to {}. - # * 'Marker'<~String> - limits object keys to only those that appear - # lexicographically after its value. - # * 'MaxItems'<~Integer> - limits number of object keys returned + # Get invalidation list. + # + # @param options [Hash] Config arguments for list. + # @option options Marker [String] Limits object keys to only those that appear lexicographically after its value. + # @option options MaxItems [Integer] Limits number of object keys returned. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated - # * 'Marker'<~String> - Marker specified for query - # * 'MaxItems'<~Integer> - Maximum number of keys specified for query - # * 'NextMarker'<~String> - Marker to specify for next page (id of last result of current page) - # * 'InvalidationSummary'<~Array>: - # * 'Id'<~String>: - # * 'Status'<~String>: + # @return [Excon::Response] + # * body [Hash]: + # * IsTruncated [Boolean] - Whether or not the listing is truncated. + # * Marker [String] - Marker specified for query. + # * MaxItems [Integer] - Maximum number of keys specified for query. + # * NextMarker [String] - Marker to specify for next page (id of last result of current page). + # * InvalidationSummary [Array]: + # * Id [String] + # * Status [String] # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListInvalidation.html + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListInvalidation.html def get_invalidation_list(distribution_id, options = {}) request({ diff --git a/lib/fog/aws/requests/cdn/get_streaming_distribution.rb b/lib/fog/aws/requests/cdn/get_streaming_distribution.rb index 96572c431..d7f9ebd30 100644 --- a/lib/fog/aws/requests/cdn/get_streaming_distribution.rb +++ b/lib/fog/aws/requests/cdn/get_streaming_distribution.rb @@ -5,35 +5,32 @@ module Fog require 'fog/aws/parsers/cdn/streaming_distribution' - # Get information about a streaming distribution from CloudFront + # Get information about a streaming distribution from CloudFront. # - # ==== Parameters - # * distribution_id<~String> - id of distribution + # @param distribution_id [String] Id of distribution. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Status'<~String> - Status of distribution - # * 'StreamingDistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'InProgressInvalidationBatches'<~Integer> - number of invalidation batches in progress - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with - # * 'Origin'<~String> - s3 origin bucket - # * 'TrustedSigners'<~Array> - trusted signers + # @return [Excon::Response] + # * body [Hash]: + # * S3Origin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] - Optional: Used when serving private content. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Status [String] - Status of distribution. + # * StreamingDistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * InProgressInvalidationBatches [Integer] - Number of invalidation batches in progress. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. + # * Origin [String] - S3 origin bucket. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetStreamingDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/GetStreamingDistribution.html + def get_streaming_distribution(distribution_id) request({ :expects => 200, diff --git a/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb b/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb index fe7ed399c..dd9aa0e35 100644 --- a/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb +++ b/lib/fog/aws/requests/cdn/get_streaming_distribution_list.rb @@ -5,43 +5,39 @@ module Fog require 'fog/aws/parsers/cdn/get_streaming_distribution_list' - # List information about distributions in CloudFront + # List information about distributions in CloudFront. # - # ==== Parameters - # * options<~Hash> - config arguments for list. Defaults to {}. - # * 'Marker'<~String> - limits object keys to only those that appear - # lexicographically after its value. - # * 'MaxItems'<~Integer> - limits number of object keys returned + # @param options [Hash] Config arguments for list. + # @option options Marker [String] Limits object keys to only those that appear lexicographically after its value. + # @option options MaxItems [Integer] Limits number of object keys returned. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'IsTruncated'<~Boolean> - Whether or not the listing is truncated - # * 'Marker'<~String> - Marker specified for query - # * 'MaxItems'<~Integer> - Maximum number of keys specified for query - # * 'NextMarker'<~String> - Marker to specify for next page (id of last result of current page) - # * 'StreamingDistributionSummary'<~Array>: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content + # @return [Excon::Response] + # * body [Hash]: + # * IsTruncated [Boolean] - Whether or not the listing is truncated. + # * Marker [String] - Marker specified for query. + # * MaxItems [Integer] - Maximum number of keys specified for query. + # * NextMarker [String] - Marker to specify for next page (id of last result of current page). + # * StreamingDistributionSummary [Array]: + # * S3Origin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] - Optional: Used when serving private content. # or - # * 'CustomOrigin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'www.example.com' - # * 'HTTPPort'<~Integer> - HTTP port of origin, in [80, 443] or (1024...65535) - # * 'HTTPSPort'<~Integer> - HTTPS port of origin, in [80, 443] or (1024...65535) - # * 'OriginProtocolPolicy'<~String> - Policy on using http vs https, in ['http-only', 'match-viewer'] - # * 'Comment'<~String> - comment associated with distribution - # * 'CNAME'<~Array> - array of associated cnames - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Origin'<~String> - s3 origin bucket - # * 'Status'<~String> - Status of distribution - # * 'TrustedSigners'<~Array> - trusted signers + # * CustomOrigin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'. + # * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535). + # * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535). + # * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer']. + # * Comment [String] - Comment associated with distribution. + # * CNAME [Array] - Array of associated cnames. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Origin [String] - S3 origin bucket. + # * Status [String] - Status of distribution. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListStreamingDistributions.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/ListStreamingDistributions.html + def get_streaming_distribution_list(options = {}) request({ :expects => 200, diff --git a/lib/fog/aws/requests/cdn/post_distribution.rb b/lib/fog/aws/requests/cdn/post_distribution.rb index db86c1f38..a995addfc 100644 --- a/lib/fog/aws/requests/cdn/post_distribution.rb +++ b/lib/fog/aws/requests/cdn/post_distribution.rb @@ -5,54 +5,52 @@ module Fog require 'fog/aws/parsers/cdn/distribution' - # create a new distribution in CloudFront + # Create a new distribution in CloudFront. # - # ==== Parameters - # * options<~Hash> - config for distribution. Defaults to {}. + # @param options [Hash] Config for distribution. + # # REQUIRED: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content + # * S3Origin [Hash]: + # * DNSName [String] Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] Optional: used when serving private content. # or - # * 'CustomOrigin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'www.example.com' - # * 'HTTPPort'<~Integer> - Optional HTTP port of origin, in [80, 443] or (1024...65535), defaults to 80 - # * 'HTTPSPort'<~Integer> - Optional HTTPS port of origin, in [80, 443] or (1024...65535), defaults to 443 - # * 'OriginProtocolPolicy'<~String> - Policy on using http vs https, in ['http-only', 'match-viewer'] + # * CustomOrigin [Hash]: + # * DNSName [String] Origin to associate with distribution, ie 'www.example.com'. + # * HTTPPort [Integer] Optional HTTP port of origin, in [80, 443] or (1024...65535), defaults to 80. + # * HTTPSPort [Integer] Optional HTTPS port of origin, in [80, 443] or (1024...65535), defaults to 443. + # * OriginProtocolPolicy [String] Policy on using http vs https, in ['http-only', 'match-viewer']. # OPTIONAL: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'Comment'<~String> - Optional comment about distribution - # * 'CNAME'<~Array> - Optional array of strings to set as CNAMEs - # * 'DefaultRootObject'<~String> - Optional default object to return for '/' - # * 'Enabled'<~Boolean> - Whether or not distribution should accept requests, defaults to true - # * 'Logging'<~Hash>: Optional logging config - # * 'Bucket'<~String> - Bucket to store logs in, ie 'mylogs.s3.amazonaws.com' - # * 'Prefix'<~String> - Optional prefix for log filenames, ie 'myprefix/' - # * 'OriginAccessIdentity'<~String> - Used for serving private content, in format 'origin-access-identity/cloudfront/ID' - # * 'RequiredProtocols'<~String> - Optional, set to 'https' to force https connections - # * 'TrustedSigners'<~Array> - Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either 'Self' for your own account or an AWS Account Number + # * CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s. + # * Comment [String] Optional comment about distribution. + # * CNAME [Array] Optional array of strings to set as CNAMEs. + # * DefaultRootObject [String] Optional default object to return for '/'. + # * Enabled [Boolean] Whether or not distribution should accept requests, defaults to true. + # * Logging [Hash]: Optional logging config. + # * Bucket [String] Bucket to store logs in, ie 'mylogs.s3.amazonaws.com'. + # * Prefix [String] Optional prefix for log filenames, ie 'myprefix/'. + # * OriginAccessIdentity [String] Used for serving private content, in format 'origin-access-identity/cloudfront/ID'. + # * RequiredProtocols [String] Optional, set to 'https' to force https connections. + # * TrustedSigners [Array] Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either 'Self' for your own account or an AWS Account Number. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'DomainName'<~String>: Domain name of distribution - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Status'<~String> - Status of distribution - # * 'DistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with - # * 'Origin'<~String> - s3 origin bucket - # * 'TrustedSigners'<~Array> - trusted signers + # @return [Excon::Response] + # * body [Hash]: + # * DomainName [String] - Domain name of distribution. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Status [String] - Status of distribution. + # * DistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. + # * Origin [String] - S3 origin bucket. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html + def post_distribution(options = {}) options['CallerReference'] = Time.now.to_i.to_s data = '' diff --git a/lib/fog/aws/requests/cdn/post_invalidation.rb b/lib/fog/aws/requests/cdn/post_invalidation.rb index 4ec436750..9bcda0f86 100644 --- a/lib/fog/aws/requests/cdn/post_invalidation.rb +++ b/lib/fog/aws/requests/cdn/post_invalidation.rb @@ -5,27 +5,23 @@ module Fog require 'fog/aws/parsers/cdn/post_invalidation' - # List information about distributions in CloudFront + # List information about distributions in CloudFront. # - # ==== Parameters - # * distribution_id<~String> - Id of distribution for invalidations - # * paths<~Array> - Array of string paths to objects to invalidate - # * caller_reference<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s + # @param distribution_id [String] Id of distribution for invalidations. + # @param paths [Array] Array of string paths to objects to invalidate. + # @param caller_reference [String] Used to prevent replay, defaults to Time.now.to_i.to_s. # + # @return [Excon::Response] + # * body [Hash]: + # * Id [String] - Id of invalidation. + # * Status [String] - Status of invalidation. + # * CreateTime [Integer] - Time of invalidation creation. + # * InvalidationBatch [Array]: + # * Path [Array] - Array of strings of objects to invalidate. + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'Id'<~String> - Id of invalidation - # * 'Status'<~String> - Status of invalidation - # * 'CreateTime'<~Integer> - Time of invalidation creation - # * 'InvalidationBatch'<~Array>: - # * 'Path'<~Array> - Array of strings of objects to invalidate - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateInvalidation.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateInvalidation.html + def post_invalidation(distribution_id, paths, caller_reference = Time.now.to_i.to_s) body = '' body << "" diff --git a/lib/fog/aws/requests/cdn/post_streaming_distribution.rb b/lib/fog/aws/requests/cdn/post_streaming_distribution.rb index ff8e9a9e0..6b7aeca43 100644 --- a/lib/fog/aws/requests/cdn/post_streaming_distribution.rb +++ b/lib/fog/aws/requests/cdn/post_streaming_distribution.rb @@ -5,41 +5,39 @@ module Fog require 'fog/aws/parsers/cdn/streaming_distribution' - # create a new streaming distribution in CloudFront + # Create a new streaming distribution in CloudFront. # - # ==== Parameters - # * options<~Hash> - config for distribution. Defaults to {}. + # @param options [Hash] Config for distribution. + # # REQUIRED: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' + # * S3Origin [Hash]: + # * DNSName [String] Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. # OPTIONAL: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'Comment'<~String> - Optional comment about distribution - # * 'CNAME'<~Array> - Optional array of strings to set as CNAMEs - # * 'Enabled'<~Boolean> - Whether or not distribution should accept requests, defaults to true - # * 'Logging'<~Hash>: Optional logging config - # * 'Bucket'<~String> - Bucket to store logs in, ie 'mylogs.s3.amazonaws.com' - # * 'Prefix'<~String> - Optional prefix for log filenames, ie 'myprefix/' + # * CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s. + # * Comment [String] Optional comment about distribution. + # * CNAME [Array] Optional array of strings to set as CNAMEs. + # * Enabled [Boolean] Whether or not distribution should accept requests, defaults to true. + # * Logging [Hash]: Optional logging config. + # * Bucket [String] Bucket to store logs in, ie 'mylogs.s3.amazonaws.com'. + # * Prefix [String] Optional prefix for log filenames, ie 'myprefix/'. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'Id'<~String> - Id of distribution - # * 'Status'<~String> - Status of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'DomainName'<~String>: Domain name of distribution - # * 'StreamingDistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with + # @return [Excon::Response] + # * body[Hash]: + # * Id [String] - Id of distribution. + # * Status'[String] - Status of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * DomainName [String] - Domain name of distribution. + # * StreamingDistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateStreamingDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateStreamingDistribution.html + def post_streaming_distribution(options = {}) options['CallerReference'] = Time.now.to_i.to_s data = '' diff --git a/lib/fog/aws/requests/cdn/put_distribution_config.rb b/lib/fog/aws/requests/cdn/put_distribution_config.rb index daa897da9..6794b7351 100644 --- a/lib/fog/aws/requests/cdn/put_distribution_config.rb +++ b/lib/fog/aws/requests/cdn/put_distribution_config.rb @@ -5,55 +5,53 @@ module Fog require 'fog/aws/parsers/cdn/distribution' - # update a distribution in CloudFront + # Update a distribution in CloudFront. # - # ==== Parameters - # * distribution_id<~String> - Id of distribution to update config for - # * options<~Hash> - config for distribution. Defaults to {}. + # @parm distribution_id [String] Id of distribution to update config for. + # @param options [Hash] Config for distribution. + # # REQUIRED: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' - # * 'OriginAccessIdentity'<~String> - Optional: Used when serving private content + # * S3Origin [Hash]: + # * DNSName [String] - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. + # * OriginAccessIdentity [String] - Optional: Used when serving private content. # or - # * 'CustomOrigin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'www.example.com' - # * 'HTTPPort'<~Integer> - HTTP port of origin, in [80, 443] or (1024...65535) - # * 'HTTPSPort'<~Integer> - HTTPS port of origin, in [80, 443] or (1024...65535) - # * 'OriginProtocolPolicy'<~String> - Policy on using http vs https, in ['http-only', 'match-viewer'] + # * CustomOrigin [Hash]: + # * DNSName [String] - Origin to associate with distribution, ie 'www.example.com'. + # * HTTPPort [Integer] - HTTP port of origin, in [80, 443] or (1024...65535). + # * HTTPSPort [Integer] - HTTPS port of origin, in [80, 443] or (1024...65535). + # * OriginProtocolPolicy [String] - Policy on using http vs https, in ['http-only', 'match-viewer']. # OPTIONAL: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'Comment'<~String> - Optional comment about distribution - # * 'CNAME'<~Array> - Optional array of strings to set as CNAMEs - # * 'DefaultRootObject'<~String> - Optional default object to return for '/' - # * 'Enabled'<~Boolean> - Whether or not distribution should accept requests, defaults to true - # * 'Logging'<~Hash>: Optional logging config - # * 'Bucket'<~String> - Bucket to store logs in, ie 'mylogs.s3.amazonaws.com' - # * 'Prefix'<~String> - Optional prefix for log filenames, ie 'myprefix/' - # * 'OriginAccessIdentity'<~String> - Used for serving private content, in format 'origin-access-identity/cloudfront/ID' - # * 'RequiredProtocols'<~String> - Optional, set to 'https' to force https connections - # * 'TrustedSigners'<~Array> - Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either 'Self' for your own account or an AWS Account Number + # * CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s. + # * Comment [String] Optional comment about distribution. + # * CNAME [Array] Optional array of strings to set as CNAMEs. + # * DefaultRootObject [String] Optional default object to return for '/'. + # * Enabled [Boolean] Whether or not distribution should accept requests, defaults to true. + # * Logging [Hash]: Optional logging config. + # * Bucket [String] Bucket to store logs in, ie 'mylogs.s3.amazonaws.com'. + # * Prefix [String] Optional prefix for log filenames, ie 'myprefix/'. + # * OriginAccessIdentity [String] Used for serving private content, in format 'origin-access-identity/cloudfront/ID'. + # * RequiredProtocols [String] Optional, set to 'https' to force https connections. + # * TrustedSigners [Array] Optional grant of rights to up to 5 aws accounts to generate signed URLs for private content, elements are either 'Self' for your own account or an AWS Account Number. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'DomainName'<~String>: Domain name of distribution - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Status'<~String> - Status of distribution - # * 'DistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with - # * 'Origin'<~String> - s3 origin bucket - # * 'TrustedSigners'<~Array> - trusted signers + # @return [Excon::Response] + # * body [Hash]: + # * DomainName [String]: Domain name of distribution. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Status [String] - Status of distribution. + # * DistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. + # * Origin [String] - S3 origin bucket. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/CreateDistribution.html + def put_distribution_config(distribution_id, etag, options = {}) data = '' data << "" diff --git a/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb b/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb index 77dde681c..952cd502d 100644 --- a/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb +++ b/lib/fog/aws/requests/cdn/put_streaming_distribution_config.rb @@ -5,44 +5,42 @@ module Fog require 'fog/aws/parsers/cdn/streaming_distribution' - # update a streaming distribution in CloudFront + # Update a streaming distribution in CloudFront. # - # ==== Parameters - # * distribution_id<~String> - Id of distribution to update config for - # * options<~Hash> - config for distribution. Defaults to {}. + # @param distribution_id [String] - Id of distribution to update config for. + # @param options [Hash] - Config for distribution. + # # REQUIRED: - # * 'S3Origin'<~Hash>: - # * 'DNSName'<~String> - origin to associate with distribution, ie 'mybucket.s3.amazonaws.com' + # * S3Origin [Hash]: + # * DNSName [String] Origin to associate with distribution, ie 'mybucket.s3.amazonaws.com'. # OPTIONAL: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'Comment'<~String> - Optional comment about distribution - # * 'CNAME'<~Array> - Optional array of strings to set as CNAMEs - # * 'Enabled'<~Boolean> - Whether or not distribution should accept requests, defaults to true - # * 'Logging'<~Hash>: Optional logging config - # * 'Bucket'<~String> - Bucket to store logs in, ie 'mylogs.s3.amazonaws.com' - # * 'Prefix'<~String> - Optional prefix for log filenames, ie 'myprefix/' + # @option options CallerReference [String] Used to prevent replay, defaults to Time.now.to_i.to_s + # @option options Comment [String] Optional comment about distribution + # @option options CNAME [Array] Optional array of strings to set as CNAMEs + # @option options Enabled [Boolean] Whether or not distribution should accept requests, defaults to true + # @option options Logging [Hash]: Optional logging config + # * Bucket [String] Bucket to store logs in, ie 'mylogs.s3.amazonaws.com' + # * Prefix String] Optional prefix for log filenames, ie 'myprefix/' # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'DomainName'<~String>: Domain name of distribution - # * 'Id'<~String> - Id of distribution - # * 'LastModifiedTime'<~String> - Timestamp of last modification of distribution - # * 'Status'<~String> - Status of distribution - # * 'StreamingDistributionConfig'<~Array>: - # * 'CallerReference'<~String> - Used to prevent replay, defaults to Time.now.to_i.to_s - # * 'CNAME'<~Array> - array of associated cnames - # * 'Comment'<~String> - comment associated with distribution - # * 'Enabled'<~Boolean> - whether or not distribution is enabled - # * 'Logging'<~Hash>: - # * 'Bucket'<~String> - bucket logs are stored in - # * 'Prefix'<~String> - prefix logs are stored with - # * 'Origin'<~String> - s3 origin bucket - # * 'TrustedSigners'<~Array> - trusted signers + # @return [Excon::Response] + # * body [Hash]: + # * DomainName [String] - Domain name of distribution. + # * Id [String] - Id of distribution. + # * LastModifiedTime [String] - Timestamp of last modification of distribution. + # * Status [String] - Status of distribution. + # * StreamingDistributionConfig [Array]: + # * CallerReference [String] - Used to prevent replay, defaults to Time.now.to_i.to_s. + # * CNAME [Array] - Array of associated cnames. + # * Comment [String] - Comment associated with distribution. + # * Enabled [Boolean] - Whether or not distribution is enabled. + # * Logging [Hash]: + # * Bucket [String] - Bucket logs are stored in. + # * Prefix [String] - Prefix logs are stored with. + # * Origin [String] - S3 origin bucket. + # * TrustedSigners [Array] - Trusted signers. # - # ==== See Also - # http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/PutStreamingDistribution.html - + # @see http://docs.amazonwebservices.com/AmazonCloudFront/latest/APIReference/PutStreamingDistribution.html + def put_streaming_distribution_config(distribution_id, etag, options = {}) data = '' data << "" From eb9b31e8345bb283e4008ca35ba9c640506d7230 Mon Sep 17 00:00:00 2001 From: Weston Platter Date: Sun, 10 Mar 2013 17:17:56 -0500 Subject: [PATCH 67/68] [docs::aws::cloudformation] reformatted in YARD format. no content changes, just format changes. --- .../requests/cloud_formation/create_stack.rb | 36 ++++++++-------- .../requests/cloud_formation/delete_stack.rb | 13 +++--- .../cloud_formation/describe_stack_events.rb | 41 +++++++++---------- .../describe_stack_resources.rb | 39 ++++++++---------- .../cloud_formation/describe_stacks.rb | 39 ++++++++---------- .../requests/cloud_formation/get_template.rb | 17 ++++---- .../requests/cloud_formation/update_stack.rb | 28 ++++++------- .../cloud_formation/validate_template.rb | 21 ++++------ 8 files changed, 104 insertions(+), 130 deletions(-) diff --git a/lib/fog/aws/requests/cloud_formation/create_stack.rb b/lib/fog/aws/requests/cloud_formation/create_stack.rb index 7166b07e3..f569e8a66 100644 --- a/lib/fog/aws/requests/cloud_formation/create_stack.rb +++ b/lib/fog/aws/requests/cloud_formation/create_stack.rb @@ -5,29 +5,25 @@ module Fog require 'fog/aws/parsers/cloud_formation/create_stack' - # Create a stack - # - # ==== Parameters - # * stack_name<~String>: name of the stack to create - # * options<~Hash>: - # * TemplateBody<~String>: structure containing the template body + # Create a stack. + # + # * stack_name [String] Name of the stack to create. + # * options [Hash]: + # * TemplateBody [String] Structure containing the template body. # or (one of the two Template parameters is required) - # * TemplateURL<~String>: URL of file containing the template body - # * DisableRollback<~Boolean>: Controls rollback on stack creation failure, defaults to false - # * NotificationARNs<~Array>: List of SNS topics to publish events to - # * Parameters<~Hash>: Hash of providers to supply to template - # * TimeoutInMinutes<~Integer>: Minutes to wait before status is set to CREATE_FAILED - # * Capabilities<~Array>: List of capabilties the stack is granted. Currently CAPABILITY_IAM - # for allowing the creation of IAM resources + # * TemplateURL [String] URL of file containing the template body. + # * DisableRollback [Boolean] Controls rollback on stack creation failure, defaults to false. + # * NotificationARNs [Array] List of SNS topics to publish events to. + # * Parameters [Hash] Hash of providers to supply to template + # * TimeoutInMinutes [Integer] Minutes to wait before status is set to CREATE_FAILED + # * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'StackId'<~String> - Id of the new stack - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html + # @return [Excon::Response]: + # * body [Hash: + # * StackId [String] - Id of the new stack # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html + def create_stack(stack_name, options = {}) params = { 'StackName' => stack_name, diff --git a/lib/fog/aws/requests/cloud_formation/delete_stack.rb b/lib/fog/aws/requests/cloud_formation/delete_stack.rb index 85251a682..45da22bca 100644 --- a/lib/fog/aws/requests/cloud_formation/delete_stack.rb +++ b/lib/fog/aws/requests/cloud_formation/delete_stack.rb @@ -5,17 +5,14 @@ module Fog require 'fog/aws/parsers/cloud_formation/basic' - # Delete a stack + # Delete a stack. # - # ==== Parameters - # * stack_name<~String>: name of the stack to create + # @param stack_name String] Name of the stack to create. # - # ==== Returns - # * response<~Excon::Response>: - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteStack.html + # @return [Excon::Response] # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteStack.html + def delete_stack(stack_name) request( 'Action' => 'DeleteStack', diff --git a/lib/fog/aws/requests/cloud_formation/describe_stack_events.rb b/lib/fog/aws/requests/cloud_formation/describe_stack_events.rb index 58040ab46..9331a1330 100644 --- a/lib/fog/aws/requests/cloud_formation/describe_stack_events.rb +++ b/lib/fog/aws/requests/cloud_formation/describe_stack_events.rb @@ -5,31 +5,28 @@ module Fog require 'fog/aws/parsers/cloud_formation/describe_stack_events' - # Describe stack events + # Describe stack events. # - # ==== Parameters - # * stack_name<~String>: stack name to return events for - # * options<~Hash>: - # * NextToken<~String>: identifies the start of the next list of events, if there is one + # @param stack_name [String] stack name to return events for. + # @param options [Hash] + # @option options NextToken [String] Identifies the start of the next list of events, if there is one. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'StackEvents'<~Array> - Matching resources - # * event<~Hash>: - # * 'EventId'<~String> - - # * 'StackId'<~String> - - # * 'StackName'<~String> - - # * 'LogicalResourceId'<~String> - - # * 'PhysicalResourceId'<~String> - - # * 'ResourceType'<~String> - - # * 'Timestamp'<~Time> - - # * 'ResourceStatus'<~String> - - # * 'ResourceStatusReason'<~String> - - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackEvents.html + # @return [Excon::Response] + # * body [Hash]: + # * StackEvents [Array] - Matching resources + # * event [Hash]: + # * EventId [String] - + # * StackId [String] - + # * StackName [String] - + # * LogicalResourceId [String] - + # * PhysicalResourceId [String] - + # * ResourceType [String] - + # * Timestamp [Time] - + # * ResourceStatus [String] - + # * ResourceStatusReason [String] - # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackEvents.html + def describe_stack_events(stack_name, options = {}) request({ 'Action' => 'DescribeStackEvents', diff --git a/lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb b/lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb index 439874618..c501b919e 100644 --- a/lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb +++ b/lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb @@ -5,31 +5,28 @@ module Fog require 'fog/aws/parsers/cloud_formation/describe_stack_resources' - # Describe stack resources + # Describe stack resources. # - # ==== Parameters - # * options<~Hash>: - # * 'PhysicalResourceId'<~String>: name or unique identifier that corresponds to a physical instance ID + # @param options Hash]: + # * PhysicalResourceId [String] name or unique identifier that corresponds to a physical instance ID # or (one of PhysicalResourceId and StackName is required) - # * 'StackName'<~String>: only return events related to this stack name - # * 'LogicalResourceId'<~String>: logical name of the resource as specified in the template + # * StackName [String] Only return events related to this stack name + # * LogicalResourceId [String] Logical name of the resource as specified in the template # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'StackResources'<~Array> - Matching resources - # * resource<~Hash>: - # * 'StackId'<~String> - - # * 'StackName'<~String> - - # * 'LogicalResourceId'<~String> - - # * 'PhysicalResourceId'<~String> - - # * 'ResourceType'<~String> - - # * 'Timestamp'<~Time> - - # * 'ResourceStatus'<~String> - - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackResources.html + # @return [Excon::Response] + # * body [Hash]: + # * StackResources [Array] - Matching resources + # * resource [Hash]: + # * StackId [String] - + # * StackName [String] - + # * LogicalResourceId [String] - + # * PhysicalResourceId [String] - + # * ResourceType [String] - + # * Timestamp [Time] - + # * ResourceStatus [String] - # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackResources.html + def describe_stack_resources(options = {}) request({ 'Action' => 'DescribeStackResources', diff --git a/lib/fog/aws/requests/cloud_formation/describe_stacks.rb b/lib/fog/aws/requests/cloud_formation/describe_stacks.rb index 20176bdfb..bb44a0f85 100644 --- a/lib/fog/aws/requests/cloud_formation/describe_stacks.rb +++ b/lib/fog/aws/requests/cloud_formation/describe_stacks.rb @@ -5,30 +5,27 @@ module Fog require 'fog/aws/parsers/cloud_formation/describe_stacks' - # Describe stacks + # Describe stacks. # - # ==== Parameters - # * options<~Hash>: - # * 'StackName'<~String>: name of the stack to describe + # @param options [Hash] + # @option options StackName [String] Name of the stack to describe. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'Stacks'<~Array> - Matching stacks - # * stack<~Hash>: - # * 'StackName'<~String> - - # * 'StackId'<~String> - - # * 'CreationTime'<~String> - - # * 'StackStatus'<~String> - - # * 'DisableRollback'<~String> - - # * 'Outputs'<~Array> - - # * output<~Hash>: - # * 'OutputKey'<~String> - - # * 'OutputValue'<~String> - - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStacks.html + # @return [Excon::Response] + # * body [Hash]: + # * Stacks [Array] - Matching stacks + # * stack [Hash]: + # * StackName [String] - + # * StackId [String] - + # * CreationTime [String] - + # * StackStatus [String] - + # * DisableRollback [String] - + # * Outputs [Array] - + # * output [Hash]: + # * OutputKey [String] - + # * OutputValue [String] - # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStacks.html + def describe_stacks(options = {}) request({ 'Action' => 'DescribeStacks', diff --git a/lib/fog/aws/requests/cloud_formation/get_template.rb b/lib/fog/aws/requests/cloud_formation/get_template.rb index 18e235248..4bb074f5f 100644 --- a/lib/fog/aws/requests/cloud_formation/get_template.rb +++ b/lib/fog/aws/requests/cloud_formation/get_template.rb @@ -5,19 +5,16 @@ module Fog require 'fog/aws/parsers/cloud_formation/get_template' - # Describe stacks + # Describe stacks. # - # ==== Parameters - # * stack_name<~String> - stack name to get template from + # @param stack_name [String] stack name to get template from # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'TemplateBody'<~String> - structure containing the template body (json) - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_GetTemplate.html + # @return [Excon::Response] + # * body [Hash]: + # * TemplateBody [String] - structure containing the template body (json) # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_GetTemplate.html + def get_template(stack_name) request( 'Action' => 'GetTemplate', diff --git a/lib/fog/aws/requests/cloud_formation/update_stack.rb b/lib/fog/aws/requests/cloud_formation/update_stack.rb index d54473cbb..0950b6a8c 100644 --- a/lib/fog/aws/requests/cloud_formation/update_stack.rb +++ b/lib/fog/aws/requests/cloud_formation/update_stack.rb @@ -5,26 +5,22 @@ module Fog require 'fog/aws/parsers/cloud_formation/update_stack' - # Update a stack + # Update a stack. # - # ==== Parameters - # * stack_name<~String>: name of the stack to update - # * options<~Hash>: - # * TemplateBody<~String>: structure containing the template body + # @parm stack_name [String] Name of the stack to update. + # @parm options [Hash] + # * TemplateBody [String] Structure containing the template body. # or (one of the two Template parameters is required) - # * TemplateURL<~String>: URL of file containing the template body - # * Parameters<~Hash>: Hash of providers to supply to template - # * Capabilities<~Array>: List of capabilties the stack is granted. Currently CAPABILITY_IAM - # for allowing the creation of IAM resources + # * TemplateURL [String] URL of file containing the template body. + # * Parameters [Hash] Hash of providers to supply to template. + # * Capabilities [Array] List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources. # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'StackId'<~String> - Id of the stack being updated - # - # ==== See Also - # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html + # @return [Excon::Response] + # * body [Hash]: + # * StackId [String] - Id of the stack being updated # + # @see http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html + def update_stack(stack_name, options = {}) params = { 'StackName' => stack_name, diff --git a/lib/fog/aws/requests/cloud_formation/validate_template.rb b/lib/fog/aws/requests/cloud_formation/validate_template.rb index 70414f7f5..2a59b98f1 100644 --- a/lib/fog/aws/requests/cloud_formation/validate_template.rb +++ b/lib/fog/aws/requests/cloud_formation/validate_template.rb @@ -5,22 +5,19 @@ module Fog require 'fog/aws/parsers/cloud_formation/validate_template' - # Describe stacks + # Describe stacks. # - # ==== Parameters - # * options<~Hash>: - # * 'TemplateBody'<~String> - template structure - # * 'TemplateURL'<~String> - template url + # @para options [Hash] + # @option options TemplateBody [String] template structure + # @option options TemplateURL [String] template url # - # ==== Returns - # * response<~Excon::Response>: - # * body<~Hash>: - # * 'Description'<~String> - description found within the template - # * 'Parameters'<~String> - list of template parameter structures + # @return [Excon::Response] + # * body [Hash]: + # * Description [String] - description found within the template + # * Parameters [String] - list of template parameter structures # - # ==== See Also # http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_ValidateTemplate.html - # + def validate_template(options = {}) request({ 'Action' => 'ValidateTemplate', From 588bf4a3d2c421e026357ec69040074c4db6cf6d Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Mon, 11 Mar 2013 10:05:23 -0500 Subject: [PATCH 68/68] [rackspace] fixing yard warnings --- lib/fog/rackspace/models/storage/account.rb | 4 ++-- lib/fog/rackspace/models/storage/directories.rb | 6 ++++-- lib/fog/rackspace/models/storage/directory.rb | 2 +- lib/fog/rackspace/models/storage/file.rb | 6 +++--- lib/fog/rackspace/models/storage/files.rb | 4 ++-- lib/fog/rackspace/requests/compute_v2/create_server.rb | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/fog/rackspace/models/storage/account.rb b/lib/fog/rackspace/models/storage/account.rb index 2316ac250..8d6e92c66 100644 --- a/lib/fog/rackspace/models/storage/account.rb +++ b/lib/fog/rackspace/models/storage/account.rb @@ -6,8 +6,8 @@ module Fog class Account < Fog::Model # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View_Account_Info-d1e11995.html - # @!attribute [rw] meta_temp_url_key is used to generate temporary access to files - # @return [String] The temporary URL key + # @!attribute [rw] meta_temp_url_key + # @return [String] The temporary URL key used to generate temporary access to files # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html attribute :meta_temp_url_key, :aliases => 'X-Account-Meta-Temp-Url-Key' diff --git a/lib/fog/rackspace/models/storage/directories.rb b/lib/fog/rackspace/models/storage/directories.rb index dedf2607d..f3d5457a6 100644 --- a/lib/fog/rackspace/models/storage/directories.rb +++ b/lib/fog/rackspace/models/storage/directories.rb @@ -22,9 +22,11 @@ module Fog # @param [String] key of directory # @param options [Hash]: # @option options [String] cdn_cname CDN CNAME used when calling Directory#public_url - # @return [Fog::Storage::Rackspace:Directory] + # @return [Fog::Storage::Rackspace::Directory] # @example - # fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url + # directory = fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org') + # files = directory.files + # files.first.public_url # # @see Directory#public_url # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/View-Container_Info-d1e1285.html diff --git a/lib/fog/rackspace/models/storage/directory.rb b/lib/fog/rackspace/models/storage/directory.rb index d4ca21071..8f04bfc61 100644 --- a/lib/fog/rackspace/models/storage/directory.rb +++ b/lib/fog/rackspace/models/storage/directory.rb @@ -99,7 +99,7 @@ module Fog end # Returns the public url for the directory. - # If the directory has not been published to the CDN, this method will return nil as it is not publically accessable. This method will return the approprate + # If the directory has not been published to the CDN, this method will return nil as it is not publically accessible. This method will return the approprate # url in the following order: # # 1. If the service used to access this directory was created with the option :rackspace_cdn_ssl => true, this method will return the SSL-secured URL. diff --git a/lib/fog/rackspace/models/storage/file.rb b/lib/fog/rackspace/models/storage/file.rb index a1ff67499..ab24a5f8d 100644 --- a/lib/fog/rackspace/models/storage/file.rb +++ b/lib/fog/rackspace/models/storage/file.rb @@ -52,6 +52,7 @@ module Fog # @example Retrieve and download contents of Cloud Files object to file system # file_object = directory.files.get('germany.jpg') # File.open('germany.jpg', 'w') {|f| f.write(file_object.body) } + # @see Fog::Storage::Rackspace:Files#get def body attributes[:body] ||= if last_modified collection.get(identity).body @@ -83,7 +84,6 @@ module Fog # Destroy the file # @return [Boolean] returns true if file is destroyed - # @note Directory must be empty before destroying directory # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Delete_Object-d1e2264.html def destroy requires :directory, :key @@ -125,7 +125,7 @@ module Fog end # Returns the public url for the file. - # If the file has not been published to the CDN, this method will return nil as it is not publically accessable. This method will return the approprate + # If the file has not been published to the CDN, this method will return nil as it is not publically accessible. This method will return the approprate # url in the following order: # # 1. If the service used to access this file was created with the option :rackspace_cdn_ssl => true, this method will return the SSL-secured URL. @@ -145,7 +145,7 @@ module Fog end # URL used to stream resources - # return [String] streaming url + # @return [String] streaming url # @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Streaming-CDN-Enabled_Containers-d1f3721.html def streaming_url Files::file_url directory.streaming_url, key diff --git a/lib/fog/rackspace/models/storage/files.rb b/lib/fog/rackspace/models/storage/files.rb index 9ce90013d..fe220f3f4 100644 --- a/lib/fog/rackspace/models/storage/files.rb +++ b/lib/fog/rackspace/models/storage/files.rb @@ -84,7 +84,7 @@ module Fog # @yieldparam [Integer] remaining # @yieldparam [Integer] content_length # @return [Fog::Storage::Rackspace:File] - # @note If a block is provided, the body attribute will be empty. By default Chunk size is 1 MB. This value can be changed by passing the parameter :chunk_size + # @note If a block is provided, the body attribute will be empty. By default chunk size is 1 MB. This value can be changed by passing the parameter :chunk_size # into the :connection_options hash in the service constructor. # @example Download an image from Cloud Files and save it to file # @@ -122,7 +122,7 @@ module Fog end # View directory detail without loading file contents - # @param key - key of the object + # @param key of the object # @param options Required for compatibility with other Fog providers. Not Used. # @return [Fog::Storage::Rackspace::File] def head(key, options = {}) diff --git a/lib/fog/rackspace/requests/compute_v2/create_server.rb b/lib/fog/rackspace/requests/compute_v2/create_server.rb index 122f885e2..26c72205f 100644 --- a/lib/fog/rackspace/requests/compute_v2/create_server.rb +++ b/lib/fog/rackspace/requests/compute_v2/create_server.rb @@ -4,7 +4,7 @@ module Fog class Real # Create server # @param [String] name name of server - # @param [String] image_id id of the image used to create server + # @param [String] image_id of the image used to create server # @param [String] flavor_id id of the flavor of the image # @param [String] min_count # @param [String] max_count