From bc4143ad9f72c2815541c68e35682af1355be983 Mon Sep 17 00:00:00 2001 From: Kyle Rames Date: Thu, 20 Dec 2012 14:00:13 -0600 Subject: [PATCH] updating Compute[:rackspace] to use v1 provider --- .../requests/compute/address_tests.rb | 20 ++++++----- .../requests/compute/flavor_tests.rb | 11 +++--- .../rackspace/requests/compute/image_tests.rb | 22 ++++++------ .../requests/compute/resize_tests.rb | 14 ++++---- .../requests/compute/server_tests.rb | 36 ++++++++++--------- 5 files changed, 56 insertions(+), 47 deletions(-) diff --git a/tests/rackspace/requests/compute/address_tests.rb b/tests/rackspace/requests/compute/address_tests.rb index 9a615155a..ef38c7008 100644 --- a/tests/rackspace/requests/compute/address_tests.rb +++ b/tests/rackspace/requests/compute/address_tests.rb @@ -1,19 +1,21 @@ Shindo.tests('Fog::Compute[:rackspace] | address requests', ['rackspace']) do + @service = Fog::Compute.new(:provider => :rackspace, :version => :v1) + tests('success') do - - @server = Fog::Compute[:rackspace].servers.create(:flavor_id => 1, :image_id => 19) + + @server = @service.servers.create(:flavor_id => 1, :image_id => 19) tests("#list_addresses(#{@server.id})").formats({'addresses' => {'private' => [String], 'public' => [String]}}) do - Fog::Compute[:rackspace].list_addresses(@server.id).body + @service.list_addresses(@server.id).body end tests("#list_private_addresses(#{@server.id})").formats({'private' => [String]}) do - Fog::Compute[:rackspace].list_private_addresses(@server.id).body + @service.list_private_addresses(@server.id).body end tests("#list_public_addresses(#{@server.id})").formats({'public' => [String]}) do - Fog::Compute[:rackspace].list_public_addresses(@server.id).body + @service.list_public_addresses(@server.id).body end @server.wait_for { ready? } @@ -22,17 +24,17 @@ Shindo.tests('Fog::Compute[:rackspace] | address requests', ['rackspace']) do end tests('failure') do - + tests('#list_addresses(0)').raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].list_addresses(0) + @service.list_addresses(0) end tests('#list_private_addresses(0)').raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].list_private_addresses(0) + @service.list_private_addresses(0) end tests('#list_public_addresses(0)').raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].list_public_addresses(0) + @service.list_public_addresses(0) end end diff --git a/tests/rackspace/requests/compute/flavor_tests.rb b/tests/rackspace/requests/compute/flavor_tests.rb index fa887bc09..59874a6fa 100644 --- a/tests/rackspace/requests/compute/flavor_tests.rb +++ b/tests/rackspace/requests/compute/flavor_tests.rb @@ -7,21 +7,22 @@ Shindo.tests('Fog::Compute[:rackspace] | flavor requests', ['rackspace']) do 'ram' => Integer } - tests('success') do + @service = Fog::Compute.new(:provider => :rackspace, :version => :v1) + tests('success') do tests('#get_flavor_details(1)').formats(@flavor_format) do pending if Fog.mocking? - Fog::Compute[:rackspace].get_flavor_details(1).body['flavor'] + @service.get_flavor_details(1).body['flavor'] end tests('#list_flavors').formats({'flavors' => [Rackspace::Compute::Formats::SUMMARY]}) do pending if Fog.mocking? - Fog::Compute[:rackspace].list_flavors.body + @service.list_flavors.body end tests('#list_flavors_detail').formats({'flavors' => [@flavor_format]}) do pending if Fog.mocking? - Fog::Compute[:rackspace].list_flavors_detail.body + @service.list_flavors_detail.body end end @@ -30,7 +31,7 @@ Shindo.tests('Fog::Compute[:rackspace] | flavor requests', ['rackspace']) do tests('#get_flavor_details(0)').raises(Fog::Compute::Rackspace::NotFound) do pending if Fog.mocking? - Fog::Compute[:rackspace].get_flavor_details(0) + @service.get_flavor_details(0) end end diff --git a/tests/rackspace/requests/compute/image_tests.rb b/tests/rackspace/requests/compute/image_tests.rb index 3ff94f313..5521ded2c 100644 --- a/tests/rackspace/requests/compute/image_tests.rb +++ b/tests/rackspace/requests/compute/image_tests.rb @@ -10,42 +10,44 @@ Shindo.tests('Fog::Compute[:rackspace] | image requests', ['rackspace']) do 'updated' => String } + @service = Fog::Compute.new(:provider => :rackspace, :version => :v1) + tests('success') do - @server = Fog::Compute[:rackspace].servers.create(:flavor_id => 1, :image_id => 19) + @server = @service.servers.create(:flavor_id => 1, :image_id => 19) @server.wait_for { ready? } @image_id = nil tests("#create_image(#{@server.id})").formats(@image_format) do - data = Fog::Compute[:rackspace].create_image(@server.id).body['image'] + data = @service.create_image(@server.id).body['image'] @image_id = data['id'] data end unless Fog.mocking? - Fog::Compute[:rackspace].images.get(@image_id).wait_for { ready? } + @service.images.get(@image_id).wait_for { ready? } end tests("#get_image_details(#{@image_id})").formats(@image_format) do pending if Fog.mocking? - Fog::Compute[:rackspace].get_image_details(@image_id).body['image'] + @service.get_image_details(@image_id).body['image'] end tests('#list_images').formats({'images' => [Rackspace::Compute::Formats::SUMMARY]}) do - Fog::Compute[:rackspace].list_images.body + @service.list_images.body end tests('#list_images_detail').formats({'images' => [@image_format]}) do - Fog::Compute[:rackspace].list_images_detail.body + @service.list_images_detail.body end unless Fog.mocking? - Fog::Compute[:rackspace].images.get(@image_id).wait_for { ready? } + @service.images.get(@image_id).wait_for { ready? } end tests("#delete_image(#{@image_id})").succeeds do pending if Fog.mocking? # because it will fail without the wait just above here, which won't work - Fog::Compute[:rackspace].delete_image(@image_id) + @service.delete_image(@image_id) end @server.destroy @@ -55,12 +57,12 @@ Shindo.tests('Fog::Compute[:rackspace] | image requests', ['rackspace']) do tests('failure') do tests('#delete_image(0)').raises(Excon::Errors::BadRequest) do - Fog::Compute[:rackspace].delete_image(0) + @service.delete_image(0) end tests('#get_image_details(0)').raises(Fog::Compute::Rackspace::NotFound) do pending if Fog.mocking? - Fog::Compute[:rackspace].get_image_details(0) + @service.get_image_details(0) end end diff --git a/tests/rackspace/requests/compute/resize_tests.rb b/tests/rackspace/requests/compute/resize_tests.rb index 800ee3a30..8212e39df 100644 --- a/tests/rackspace/requests/compute/resize_tests.rb +++ b/tests/rackspace/requests/compute/resize_tests.rb @@ -1,27 +1,29 @@ Shindo.tests('Fog::Compute[:rackspace] | resize request', ['rackspace']) do - @confirm_server = Fog::Compute[:rackspace].servers.create(:flavor_id => 1, :image_id => 19) + @service = Fog::Compute.new(:provider => :rackspace, :version => :v1) - @revert_server = Fog::Compute[:rackspace].servers.create(:flavor_id => 1, :image_id => 19) + @confirm_server = @service.servers.create(:flavor_id => 1, :image_id => 19) + + @revert_server = @service.servers.create(:flavor_id => 1, :image_id => 19) @confirm_server.wait_for { ready? } tests("#resize_server(#{@confirm_server.id}, 2) # to confirm").succeeds do - Fog::Compute[:rackspace].resize_server(@confirm_server.id, 2) + @service.resize_server(@confirm_server.id, 2) end @revert_server.wait_for { ready? } tests("#resize_server(#{@revert_server.id}, 2) # to revert").succeeds do - Fog::Compute[:rackspace].resize_server(@revert_server.id, 2) + @service.resize_server(@revert_server.id, 2) end @confirm_server.wait_for { state == 'VERIFY_RESIZE' } tests("#confirm_resized_server(#{@confirm_server.id})").succeeds do - Fog::Compute[:rackspace].confirm_resized_server(@confirm_server.id) + @service.confirm_resized_server(@confirm_server.id) end @revert_server.wait_for { state == 'VERIFY_RESIZE' } tests("#revert_resized_server(#{@revert_server.id})").succeeds do - Fog::Compute[:rackspace].revert_resized_server(@revert_server.id) + @service.revert_resized_server(@revert_server.id) end @confirm_server.wait_for { ready? } diff --git a/tests/rackspace/requests/compute/server_tests.rb b/tests/rackspace/requests/compute/server_tests.rb index 1fde8a280..4d6229748 100644 --- a/tests/rackspace/requests/compute/server_tests.rb +++ b/tests/rackspace/requests/compute/server_tests.rb @@ -14,6 +14,8 @@ Shindo.tests('Fog::Compute[:rackspace] | server requests', ['rackspace']) do 'progress' => Integer, 'status' => String } + + @service = Fog::Compute.new(:provider => :rackspace, :version => :v1) tests('success') do @@ -21,49 +23,49 @@ Shindo.tests('Fog::Compute[:rackspace] | server requests', ['rackspace']) do tests('#create_server(1, 19)').formats(@server_format.merge('adminPass' => String)) do # 1 => 256MB, 19 => Gentoo - data = Fog::Compute[:rackspace].create_server(1, 19).body['server'] + data = @service.create_server(1, 19).body['server'] @server_id = data['id'] data end - Fog::Compute[:rackspace].servers.get(@server_id).wait_for { ready? } + @service.servers.get(@server_id).wait_for { ready? } tests("#get_server_details(#{@server_id})").formats(@server_format) do - Fog::Compute[:rackspace].get_server_details(@server_id).body['server'] + @service.get_server_details(@server_id).body['server'] end tests('#list_servers').formats({'servers' => [Rackspace::Compute::Formats::SUMMARY]}) do - Fog::Compute[:rackspace].list_servers.body + @service.list_servers.body end tests('#list_servers_detail').formats({'servers' => [@server_format]}) do - Fog::Compute[:rackspace].list_servers_detail.body + @service.list_servers_detail.body end - Fog::Compute[:rackspace].servers.get(@server_id).wait_for { ready? } + @service.servers.get(@server_id).wait_for { ready? } tests("#update_server(#{@server_id}, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')").succeeds do - Fog::Compute[:rackspace].update_server(@server_id, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver') + @service.update_server(@server_id, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver') end - Fog::Compute[:rackspace].servers.get(@server_id).wait_for { ready? } + @service.servers.get(@server_id).wait_for { ready? } tests("#reboot_server(#{@server_id}, 'HARD')").succeeds do pending if Fog.mocking? - Fog::Compute[:rackspace].reboot_server(@server_id, 'HARD') + @service.reboot_server(@server_id, 'HARD') end - Fog::Compute[:rackspace].servers.get(@server_id).wait_for { ready? } + @service.servers.get(@server_id).wait_for { ready? } tests("#reboot_server(#{@server_id}, 'SOFT')").succeeds do pending if Fog.mocking? - Fog::Compute[:rackspace].reboot_server(@server_id, 'SOFT') + @service.reboot_server(@server_id, 'SOFT') end - Fog::Compute[:rackspace].servers.get(@server_id).wait_for { ready? } + @service.servers.get(@server_id).wait_for { ready? } tests("#delete_server(#{@server_id})").succeeds do - Fog::Compute[:rackspace].delete_server(@server_id) + @service.delete_server(@server_id) end end @@ -71,20 +73,20 @@ Shindo.tests('Fog::Compute[:rackspace] | server requests', ['rackspace']) do tests('failure') do tests('#delete_server(0)').raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].delete_server(0) + @service.delete_server(0) end tests('#get_server_details(0)').raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].get_server_details(0) + @service.get_server_details(0) end tests("#update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver')").raises(Fog::Compute::Rackspace::NotFound) do - Fog::Compute[:rackspace].update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver') + @service.update_server(0, :name => 'fogupdatedserver', :adminPass => 'fogupdatedserver') end tests('#reboot_server(0)').raises(Fog::Compute::Rackspace::NotFound) do pending if Fog.mocking? - Fog::Compute[:rackspace].reboot_server(0) + @service.reboot_server(0) end end