aeolus-incubator/tim — pull request #85 by mtaylor (2012-12-16 14:49:16+00:00)
Title: Enforce equivilence for Target Images with same Image Version

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 = 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/
curl http://localhost:8075/imagefactory/target_images/
```

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

```
target_image1.image_version.factory_base_image_id
```