1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

updating Compute[:rackspace] to use v1 provider

This commit is contained in:
Kyle Rames 2012-12-20 14:00:13 -06:00
parent fde1ee532a
commit bc4143ad9f
5 changed files with 56 additions and 47 deletions

View file

@ -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? }
@ -24,15 +26,15 @@ Shindo.tests('Fog::Compute[:rackspace] | address requests', ['rackspace']) do
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

View file

@ -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

View file

@ -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

View file

@ -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? }

View file

@ -15,55 +15,57 @@ Shindo.tests('Fog::Compute[:rackspace] | server requests', ['rackspace']) do
'status' => String
}
@service = Fog::Compute.new(:provider => :rackspace, :version => :v1)
tests('success') do
@server_id = nil
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