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

[Rackspace|Compute] updated create_image to return an image object instead of the object id

This commit is contained in:
Kyle Rames 2013-01-14 16:50:50 -06:00
parent 840aa52306
commit 57a021547e
4 changed files with 20 additions and 4 deletions

View file

@ -113,7 +113,12 @@ module Fog
def create_image(name, options = {})
requires :identity
response = service.create_image(identity, name, options)
response.headers["Location"].match(/\/([^\/]+$)/)[1] rescue nil
begin
image_id = response.headers["Location"].match(/\/([^\/]+$)/)[1]
Fog::Compute::RackspaceV2::Image.new(:collection => service.images, :service => service, :id => image_id)
rescue
nil
end
end
def attachments

View file

@ -72,7 +72,7 @@ module Fog
"minRam" => 256,
"name" => "Ubuntu 11.10",
"progress" => 100,
"status" => "ACTIVE",
"status" => "SAVING",
"updated" => "2012-02-28T19:39:05Z"
}

View file

@ -15,8 +15,7 @@ Shindo.tests('Fog::Compute::RackspaceV2 | image', ['rackspace']) do
begin
server = service.servers.create(options)
server.wait_for { ready? }
image_id = server.create_image("fog_image_#{test_time}")
image = service.images.get(image_id)
image = server.create_image("fog_image_#{test_time}")
tests("destroy").succeeds do
image.destroy

View file

@ -24,6 +24,18 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
returns('HARD_REBOOT') { @instance.state }
end
@instance.wait_for(timeout=1500) { ready? }
@test_image = nil
begin
tests('#create_image').succeeds do
@test_image = @instance.create_image('fog-test-image')
@test_image.reload
returns('SAVING') { @test_image.state }
end
ensure
@test_image.destroy unless @test_image.nil? || Fog.mocking?
end
@instance.wait_for(timeout=1500) { ready? }
tests('#rebuild').succeeds do
@instance.rebuild('5cebb13a-f783-4f8c-8058-c4182c724ccd')