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

Merge pull request #1470 from rackspace/image_obj

[Rackspace|Compute] updated server.create_image to return Image Object
This commit is contained in:
Brad Gignac 2013-01-14 15:20:34 -08:00
commit 9bce631156
4 changed files with 20 additions and 4 deletions

View file

@ -125,7 +125,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

@ -38,6 +38,18 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server', ['rackspace']) do
@instance.reboot('HARD')
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
sleep 30 unless Fog.mocking?
@instance.wait_for(timeout=1500) { ready? }