Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[Rackspace|Compute] updated server.create_image to return Image Object #1470

Merged
merged 1 commit into from

3 participants

@krames
Owner

Updated create_image method on Fog::Compute::RackspaceV2::Server to return Image object instead of the object id.

The current Fog release does not contain this method and I wanted to make this change before a release was cut.

@bradgignac
Collaborator

Looks great. Will merge after the build passes.

@bradgignac bradgignac merged commit 9bce631 into fog:master
@geemus
Owner

Thanks!

@alanthing alanthing referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 14, 2013
  1. [Rackspace|Compute] updated create_image to return an image object in…

    Kyle Rames authored
    …stead of the object id
This page is out of date. Refresh to see the latest.
View
7 lib/fog/rackspace/models/compute_v2/server.rb
@@ -113,7 +113,12 @@ def image
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
2  lib/fog/rackspace/requests/compute_v2/create_image.rb
@@ -72,7 +72,7 @@ def create_image(server_id, name, options = {})
"minRam" => 256,
"name" => "Ubuntu 11.10",
"progress" => 100,
- "status" => "ACTIVE",
+ "status" => "SAVING",
"updated" => "2012-02-28T19:39:05Z"
}
View
3  tests/rackspace/models/compute_v2/image_tests.rb
@@ -15,8 +15,7 @@
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
12 tests/rackspace/models/compute_v2/server_tests.rb
@@ -23,6 +23,18 @@
@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
@instance.wait_for(timeout=1500) { ready? }
tests('#rebuild').succeeds do
Something went wrong with that request. Please try again.