aeolus-incubator / tim

Web application for managing virtual images to be deployed in the cloud
www.aeolusproject.org
MIT License
3 stars 6 forks source link

Enforce equivilence for Target Images with same Image Version #85

Closed mtaylor closed 11 years ago

mtaylor commented 11 years ago

When creating a second target image for the same image version. We should pass in the factory base image id to be sure that factory uses the already built base image rather than creating a new one from the template.

This ensures that we have equivilence of Target Images across ImageVersions.

To see this working in factory.

1) Set up factory + tim 2) Open Console and Create 2 target images with the same image version

template_xml = "<template><name>mock</name><os><name>RHELMock</name><version>1</version><arch>x86_64</arch><install type=\"iso\"><iso>http://mockhost/RHELMock1-x86_64-DVD.iso</iso></install><rootpw>password</rootpw></os><description>Mock Template</description></template>"

template = Tim::Template.create(:xml => template_xml)

base_image = Tim::BaseImage.new(:name => "BaseImage")
base_image.template = template
base_image.save

image_version = Tim::ImageVersion.new
image_version.base_image = base_image
image_version.save

target_image1 = Tim::TargetImage.new(:target => "MockSphere")
target_image1.image_version = image_version
target_image1.save

target_image2 = Tim::TargetImage.new(:target => "MockSphere")
target_image2.image_version = image_version
target_image2.save

### Take note of the factory ids ###
# Factory Base Image ID
target_image1.image_version.factory_base_image_id

# Factory Target Image IDs
target_image1.factory_id
target_image2.factory_id

Inspect the Target Images response from factory. Look for the Base Image IDs

 curl http://localhost:8075/imagefactory/target_images/<target_image1_factory_id>
 curl http://localhost:8075/imagefactory/target_images/<target_image2_factory_id>

Both target images base image id (from factory) should match the output of:

target_image1.image_version.factory_base_image_id