while image can be null in templateBuilder, image will never be null in a template

This commit is contained in:
Adrian Cole 2012-05-10 17:19:29 -07:00
parent 59f2b6d171
commit 5340e947d3
2 changed files with 5 additions and 10 deletions

View File

@ -133,17 +133,8 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen
public Map<?, Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
// ensure we don't mutate the input template
Template mutableTemplate;
// ensure we don't mutate the input template, fromTemplate ignores imageId so
// build directly from imageId if we have it
if (template.getImage() != null && template.getImage().getId() != null) {
mutableTemplate = templateBuilderProvider.get().imageId(template.getImage().getId()).fromTemplate(template)
Template mutableTemplate = templateBuilderProvider.get().imageId(template.getImage().getId()).fromTemplate(template)
.build();
// otherwise build from generic parameters
} else {
mutableTemplate = templateBuilderProvider.get().fromTemplate(template).build();
}
Iterable<String> ips = allocateElasticIpsInRegion(count, template);

View File

@ -95,6 +95,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
strategy.autoAllocateElasticIps = true;
// setup expectations
expect(templateBuilder.imageId(region + "/" + imageId)).andReturn(templateBuilder);
expect(templateBuilder.fromTemplate(input.template)).andReturn(templateBuilder);
expect(templateBuilder.build()).andReturn(input.template);
expect(strategy.client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
@ -105,6 +106,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
expect(input.template.getLocation()).andReturn(input.location).atLeastOnce();
expect(input.template.getImage()).andReturn(input.image).atLeastOnce();
expect(input.image.getId()).andReturn(region + "/" + imageId).atLeastOnce();
expect(input.image.getProviderId()).andReturn(imageId).atLeastOnce();
// differences when ip allocation
@ -202,6 +204,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
"reservationId");
// setup expectations
expect(templateBuilder.imageId(region + "/" + imageId)).andReturn(templateBuilder);
expect(templateBuilder.fromTemplate(input.template)).andReturn(templateBuilder);
expect(templateBuilder.build()).andReturn(input.template);
expect(strategy.client.getInstanceServices()).andReturn(instanceClient).atLeastOnce();
@ -210,6 +213,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest {
.execute(region, input.tag, input.template)).andReturn(ec2Options);
expect(input.template.getLocation()).andReturn(input.location).atLeastOnce();
expect(input.template.getImage()).andReturn(input.image).atLeastOnce();
expect(input.image.getId()).andReturn(region + "/" + imageId).atLeastOnce();
expect(input.image.getProviderId()).andReturn(imageId).atLeastOnce();
expect(instanceClient.runInstancesInRegion(region, zone, imageId, 1, input.count, ec2Options)).andReturn(
Reservation.class.cast(reservation));