Skip to content

Instantly share code, notes, and snippets.

@n1zyy
Created November 22, 2011 14:58
Show Gist options
  • Save n1zyy/1385851 to your computer and use it in GitHub Desktop.
Save n1zyy/1385851 to your computer and use it in GitHub Desktop.
Testing image import
# Import an imaginary image from mock
>> img = Aeolus::Image::Factory::Image.new(:target_identifier => 'ami-ahmee', :target_name => 'mock', :provider_name => 'mock', :image_descriptor => '<image><name>ami-amigo</name></image>')
=> #<Aeolus::Image::Factory::Image:0x7f1b83fca058 @prefix_options={}, @attributes={"target_identifier"=>"ami-ahmee", "target_name"=>"mock", "provider_name"=>"mock", "image_descriptor"=>"<image><name>ami-amigo</name></image>"}
# Save! the image to send Factory the build request
>> img.save!
=> true
# pp img
>> img
=> #<Aeolus::Image::Factory::Image:0x7f1b83fca058 @remote_errors=nil, @validation_context=nil, @prefix_options={}, @attributes={"href"=>"https://localhost:8075/imagefactory/images/a84931f0-8042-4d4a-ba41-d11177a893c4", "target_identifier"=>"ami-ahmee", "target_name"=>"mock", "build"=>#<Aeolus::Image::Factory::Build:0x7f1b83f38f18 @prefix_options={}, @attributes={"href"=>"https://localhost:8075/imagefactory/images/a84931f0-8042-4d4a-ba41-d11177a893c4/builds/5f1cd88b-a0f3-486f-a827-52e39a927e7a", "id"=>"5f1cd88b-a0f3-486f-a827-52e39a927e7a", "_type"=>"build", "target_images"=>[#<Aeolus::Image::Factory::TargetImage:0x7f1b83f35a98 @prefix_options={}, @attributes={"href"=>"https://localhost:8075/imagefactory/images/a84931f0-8042-4d4a-ba41-d11177a893c4/builds/5f1cd88b-a0f3-486f-a827-52e39a927e7a/target_images/0fb92097-e862-4d53-b573-da0454a37f0d", "id"=>"0fb92097-e862-4d53-b573-da0454a37f0d", "_type"=>"target_image", "provider_images"=>[#<Aeolus::Image::Factory::ProviderImage:0x7f1b83f34468 @prefix_options={}, @attributes={"href"=>"https://localhost:8075/imagefactory/images/a84931f0-8042-4d4a-ba41-d11177a893c4/builds/5f1cd88b-a0f3-486f-a827-52e39a927e7a/target_images/0fb92097-e862-4d53-b573-da0454a37f0d/provider_images/a7a2ff29-44c7-4188-858a-88c05f5d2d8c", "id"=>"a7a2ff29-44c7-4188-858a-88c05f5d2d8c", "_type"=>"provider_image"}>]}>]}>, "_type"=>"image", "id"=>"a84931f0-8042-4d4a-ba41-d11177a893c4", "provider_name"=>"mock", "image_descriptor"=>"<image><name>ami-amigo</name></image>"}, @errors=#<OrderedHash {}>>
# Just get the id:
>> img.id
=> "a84931f0-8042-4d4a-ba41-d11177a893c4"
# The href appears to indicate that the id is, in fact, an image ID
>> img.href
=> "https://localhost:8075/imagefactory/images/a84931f0-8042-4d4a-ba41-d11177a893c4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment