Author: adriancole
Date: Fri Aug 17 18:43:46 2012
New Revision: 1374393

URL: http://svn.apache.org/viewvc?rev=1374393&view=rev
Log:
WHIRR-593: Upgrade to jclouds 1.5.0-beta.10

Removed:
    
whirr/trunk/core/src/main/java/org/apache/whirr/service/jclouds/TemplateBuilderStrategy.java
    
whirr/trunk/core/src/test/java/org/apache/whirr/service/TemplateBuilderStrategyTest.java
Modified:
    whirr/trunk/CHANGES.txt
    
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
    whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
    whirr/trunk/core/src/main/java/org/apache/whirr/InstanceTemplate.java
    
whirr/trunk/core/src/main/java/org/apache/whirr/actions/BootstrapClusterAction.java
    
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ByonClusterAction.java
    
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java
    
whirr/trunk/core/src/main/java/org/apache/whirr/compute/BootstrapTemplate.java
    
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterActionEvent.java
    whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
    whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java
    whirr/trunk/core/src/main/java/org/apache/whirr/util/BlobCache.java
    whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java
    whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
    
whirr/trunk/core/src/test/java/org/apache/whirr/actions/BootstrapClusterActionTest.java
    
whirr/trunk/core/src/test/java/org/apache/whirr/compute/BootstrapTemplateTest.java
    
whirr/trunk/core/src/test/java/org/apache/whirr/util/integration/BlobCacheTest.java
    whirr/trunk/pom.xml
    whirr/trunk/src/site/xdoc/configuration-guide.xml

Modified: whirr/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Fri Aug 17 18:43:46 2012
@@ -115,6 +115,8 @@ Trunk (unreleased changes)
 
     WHIRR-630. Add endpoint and blobstore-endpoint configuration for private 
clouds (adriancole)
 
+    WHIRR-593. Upgrade to jclouds 1.5.0 (adriancole)
+
   BUG FIXES
 
     WHIRR-612. CDH4 can be installed on Ubuntu now as well as CentOS. (abayer)

Modified: 
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
 (original)
+++ 
whirr/trunk/cli/src/test/java/org/apache/whirr/cli/command/LaunchClusterCommandTest.java
 Fri Aug 17 18:43:46 2012
@@ -136,6 +136,7 @@ public class LaunchClusterCommandTest ex
     assertThat(rc, is(0));
 
     Configuration conf = new PropertiesConfiguration();
+    conf.addProperty("whirr.provider", "aws-ec2");
     conf.addProperty("whirr.version", "version-string");
     conf.addProperty("whirr.instance-templates-max-percent-failure", "60 
hadoop-datanode+hadoop-tasktracker");
 
@@ -147,7 +148,6 @@ public class LaunchClusterCommandTest ex
         .roles("hadoop-datanode", "hadoop-tasktracker").build()
     ));
     expectedClusterSpec.setServiceName("hadoop");
-    expectedClusterSpec.setProvider("aws-ec2");
     expectedClusterSpec.setIdentity("myusername");
     expectedClusterSpec.setCredential("mypassword");
     expectedClusterSpec.setClusterName("test-cluster");

Modified: whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/ClusterSpec.java Fri Aug 17 
18:43:46 2012
@@ -39,12 +39,17 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.ConfigurationUtils;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.io.IOUtils;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
+import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.predicates.validators.DnsNameValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
 import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -68,9 +73,6 @@ public class ClusterSpec {
     SERVICE_NAME(String.class, false, "(optional) The name of the " +
       "service to use. E.g. hadoop."),
 
-    BOOTSTRAP_USER(String.class, false,  "Override the default login user "+
-      "used to bootstrap whirr. E.g. ubuntu or myuser:mypass."),
-
     CLUSTER_USER(String.class, false, "The name of the user that Whirr " +
             "will create on all the cluster instances. You have to use " +
             "this user to login to nodes."),
@@ -137,7 +139,15 @@ public class ClusterSpec {
       "Valid only for the blob state store. Defaults to whirr-<cluster-name>"),
 
     AWS_EC2_SPOT_PRICE(Float.class, false, "Spot instance price (aws-ec2 
specific option)"),
-      
+    
+    TEMPLATE(String.class, true, "The specification of requirements for 
instances in jclouds "+
+       "TemplateBuilderSpec format.  default. 
\"osFamily=UBUNTU,osVersionMatches=10.04,minRam=1024\". "+
+       "Note that this is a an alternative not compatible with the following 
properties: "+
+       "image-id, hardware-id, location-id, hardware-min-ram, 
bootstrap-user."),
+
+    BOOTSTRAP_USER(String.class, false,  "Override the default login user "+
+      "used to bootstrap whirr. E.g. ubuntu or myuser:mypass."),
+       
     IMAGE_ID(String.class, false, "The ID of the image to use for " + 
       "instances. If not specified then a vanilla Linux image is " + 
       "chosen."),
@@ -254,7 +264,6 @@ public class ClusterSpec {
   private String serviceName;
 
   private String clusterUser;
-  private String bootstrapUser;
 
   private List<InstanceTemplate> instanceTemplates;
   private int maxStartupRetries;
@@ -274,19 +283,15 @@ public class ClusterSpec {
   private String stateStoreContainer;
   private String stateStoreBlob;
 
-  private float awsEc2SpotPrice;
+  private Float awsEc2SpotPrice;
 
   private String privateKey;
   private File privateKeyFile;
   private String publicKey;
 
-  private String locationId;
   private String blobStoreLocationId;
 
-  private String imageId;
-
-  private String hardwareId;
-  private int hardwareMinRam;
+  private TemplateBuilderSpec template;
 
   private List<String> clientCidrs;
   private Map<String, List<String>> firewallRules;
@@ -327,7 +332,6 @@ public class ClusterSpec {
     setClusterName(getString(Property.CLUSTER_NAME));
     setServiceName(getString(Property.SERVICE_NAME));
 
-    setBootstrapUser(getBootstrapUserOrDeprecatedLoginUser());
     setClusterUser(getString(Property.CLUSTER_USER));
 
     setInstanceTemplates(InstanceTemplate.parse(config));
@@ -351,15 +355,39 @@ public class ClusterSpec {
     setStateStoreContainer(getString(Property.STATE_STORE_CONTAINER));
     setStateStoreBlob(getString(Property.STATE_STORE_BLOB));
 
-    setAwsEc2SpotPrice(getFloat(Property.AWS_EC2_SPOT_PRICE, -1));
+    setAwsEc2SpotPrice(getFloat(Property.AWS_EC2_SPOT_PRICE, (Float) null));
 
     checkAndSetKeyPair();
-
-    setImageId(getString(Property.IMAGE_ID));
-    setHardwareId(getString(Property.HARDWARE_ID));
-    setHardwareMinRam(getInt(Property.HARDWARE_MIN_RAM, 1024));
-
-    setLocationId(getString(Property.LOCATION_ID));
+    
+    if (getList(Property.TEMPLATE).size() > 0) {
+       this.template = 
TemplateBuilderSpec.parse(Joiner.on(',').join(getList(Property.TEMPLATE)));
+    } else {
+       // until TemplateBuilderSpec has type-safe builder
+       Builder<String, String> template = ImmutableMap.<String, 
String>builder();
+       if (getString(Property.IMAGE_ID) != null) {
+          template.put("imageId", getString(Property.IMAGE_ID));
+       } else {
+          template.put("osFamily", "UBUNTU");
+          template.put("osVersionMatches", "10.04");
+          // canonical images, but not testing ones
+          if ("aws-ec2".equals(getProvider()))
+             template.put("osDescriptionMatches", 
"^(?!.*(daily|testing)).*ubuntu-images.*$");
+       }
+       if (getString(Property.HARDWARE_ID) != null) {
+          template.put("hardwareId", getString(Property.HARDWARE_ID));
+       } else {
+          template.put("minRam", 
Integer.toString(getInt(Property.HARDWARE_MIN_RAM, 1024)));
+       }
+       if (getString(Property.LOCATION_ID) != null) {
+          template.put("locationId", getString(Property.LOCATION_ID));
+       }
+       String bootstrapUser = getBootstrapUserOrDeprecatedLoginUser();
+       if (bootstrapUser != null) {
+          template.put("loginUser", bootstrapUser);
+       }
+       this.template = 
TemplateBuilderSpec.parse(Joiner.on(',').withKeyValueSeparator("=").join(template.build()));
+    }
+    
     setBlobStoreLocationId(getString(Property.BLOBSTORE_LOCATION_ID));
     setClientCidrs(getList(Property.CLIENT_CIDRS));
     
@@ -404,7 +432,6 @@ public class ClusterSpec {
     r.setClusterName(getClusterName());
     r.setServiceName(getServiceName());
 
-    r.setBootstrapUser(getBootstrapUser());
     r.setClusterUser(getClusterUser());
 
     r.setInstanceTemplates(Lists.newLinkedList(getInstanceTemplates()));
@@ -428,11 +455,8 @@ public class ClusterSpec {
     r.setPrivateKey(getPrivateKey());
     r.setPublicKey(getPublicKey());
 
-    r.setImageId(getImageId());
-    r.setHardwareId(getHardwareId());
-    r.setHardwareMinRam(getHardwareMinRam());
+    r.setTemplate(getTemplate());
 
-    r.setLocationId(getLocationId());
     r.setBlobStoreLocationId(getBlobStoreLocationId());
     r.setClientCidrs(getClientCidrs());
 
@@ -460,7 +484,11 @@ public class ClusterSpec {
   private float getFloat(Property key, float defaultValue) {
     return config.getFloat(key.getConfigName(), defaultValue);
   }
-
+  
+  private Float getFloat(Property key, Float defaultValue) {
+    return config.getFloat(key.getConfigName(), defaultValue);
+  }
+  
   private List<String> getList(Property key) {
     return config.getList(key.getConfigName());
   }
@@ -638,7 +666,8 @@ public class ClusterSpec {
     return stateStoreBlob;
   }
 
-  public float getAwsEc2SpotPrice() {
+  @Nullable
+  public Float getAwsEc2SpotPrice() {
     return awsEc2SpotPrice;
   }
 
@@ -658,20 +687,12 @@ public class ClusterSpec {
     return publicKey;
   }
 
-  public String getImageId() {
-    return imageId;
-  }
-
-  public String getHardwareId() {
-    return hardwareId;
-  }
-
-  public int getHardwareMinRam() {
-    return hardwareMinRam;
-  }
-
-  public String getLocationId() {
-    return locationId;
+  /**
+   * Parameters that define how an instance is built, including hardware, 
image, and login information.
+   * 
+   */
+  public TemplateBuilderSpec getTemplate() {
+    return template;
   }
 
   public List<String> getClientCidrs() {
@@ -694,15 +715,6 @@ public class ClusterSpec {
     return clusterUser;
   }
 
-  public String getBootstrapUser() {
-    return bootstrapUser;
-  }
-
-  @Deprecated
-  public String getLoginUser() {
-    return getBootstrapUser();
-  }
-
   public void setInstanceTemplates(List<InstanceTemplate> instanceTemplates) {
     this.instanceTemplates = instanceTemplates;
   }
@@ -795,7 +807,7 @@ public class ClusterSpec {
     this.stateStoreBlob = blob;
   }
 
-  public void setAwsEc2SpotPrice(float value) {
+  public void setAwsEc2SpotPrice(@Nullable Float value) {
     this.awsEc2SpotPrice = value;
   }
 
@@ -897,23 +909,11 @@ public class ClusterSpec {
         .startsWith("-----BEGIN RSA PRIVATE KEY-----"),
         "key should start with -----BEGIN RSA PRIVATE KEY-----");
   }
-
-  public void setImageId(String imageId) {
-    this.imageId = imageId;
-  }
   
-  public void setHardwareId(String hardwareId) {
-    this.hardwareId = hardwareId;
+  public void setTemplate(TemplateBuilderSpec template) {
+     this.template = template;
   }
 
-  public void setHardwareMinRam(int minRam) {
-    this.hardwareMinRam = minRam;
-  }
-  
-  public void setLocationId(String locationId) {
-    this.locationId = locationId;
-  }
-  
   public void setClientCidrs(List<String> clientCidrs) {
     this.clientCidrs = clientCidrs;
   }
@@ -935,15 +935,6 @@ public class ClusterSpec {
     this.clusterUser = user;
   }
 
-  public void setBootstrapUser(String bootstrapUser) {
-    this.bootstrapUser = bootstrapUser;
-  }
-
-  @Deprecated
-  public void setLoginUser(String user) {
-    setBootstrapUser(user);
-  }
-
   public Configuration getConfiguration() {
     return config;
   }
@@ -997,13 +988,9 @@ public class ClusterSpec {
         && Objects.equal(getClusterName(), that.getClusterName())
         && Objects.equal(getServiceName(), that.getServiceName())
         && Objects.equal(getClusterUser(), that.getClusterUser())
-        && Objects.equal(getBootstrapUser(), that.getBootstrapUser())
         && Objects.equal(getPublicKey(), that.getPublicKey())
         && Objects.equal(getPrivateKey(), that.getPrivateKey())
-        && Objects.equal(getImageId(), that.getImageId())
-        && Objects.equal(getHardwareId(), that.getHardwareId())
-        && Objects.equal(getHardwareMinRam(), that.getHardwareMinRam())
-        && Objects.equal(getLocationId(), that.getLocationId())
+        && Objects.equal(getTemplate(), that.getTemplate())
         && Objects.equal(getBlobStoreLocationId(), 
that.getBlobStoreLocationId())
         && Objects.equal(getClientCidrs(), that.getClientCidrs())
         && Objects.equal(getVersion(), that.getVersion())
@@ -1036,13 +1023,9 @@ public class ClusterSpec {
         getClusterName(),
         getServiceName(),
         getClusterUser(),
-        getBootstrapUser(),
         getPublicKey(),
         getPrivateKey(),
-        getImageId(),
-        getHardwareId(),
-        getHardwareMinRam(),
-        getLocationId(),
+        getTemplate(),
         getBlobStoreLocationId(),
         getClientCidrs(),
         getVersion(),
@@ -1073,13 +1056,9 @@ public class ClusterSpec {
       .add("clusterName", getClusterName())
       .add("serviceName", getServiceName())
       .add("clusterUser", getClusterUser())
-      .add("bootstrapUser", getBootstrapUser())
       .add("publicKey", getPublicKey())
       .add("privateKey", getPrivateKey())
-      .add("imageId", getImageId())
-      .add("hardwareId", getHardwareId())
-      .add("hardwareMinRam", getHardwareMinRam())
-      .add("locationId", getLocationId())
+      .add("template", getTemplate())
       .add("blobStoreLocationId", getBlobStoreLocationId())
       .add("clientCidrs", getClientCidrs())
       .add("version", getVersion())

Modified: whirr/trunk/core/src/main/java/org/apache/whirr/InstanceTemplate.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/InstanceTemplate.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/InstanceTemplate.java 
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/InstanceTemplate.java Fri 
Aug 17 18:43:46 2012
@@ -31,10 +31,14 @@ import java.util.regex.Pattern;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.lang.StringUtils;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
+import org.jclouds.javax.annotation.Nullable;
 
 import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -52,9 +56,8 @@ public class InstanceTemplate {
   public static class Builder {
     private int numberOfInstances = -1;
     private int minNumberOfInstances = -1;
-    private String hardwareId;
-    private String imageId;
-    private float awsEc2SpotPrice = 0;
+    private TemplateBuilderSpec template;
+    private Float awsEc2SpotPrice;
     private Set<String> roles;
 
     public Builder numberOfInstance(int numberOfInstances) {
@@ -67,17 +70,12 @@ public class InstanceTemplate {
       return this;
     }
 
-    public Builder hardwareId(String hardwareId) {
-      this.hardwareId = hardwareId;
+    public Builder template(@Nullable TemplateBuilderSpec template) {
+      this.template = template;
       return this;
     }
-
-    public Builder imageId(String imageId) {
-      this.imageId = imageId;
-      return this;
-    }
-
-    public Builder awsEc2SpotPrice(float awsEc2SpotPrice) {
+    
+    public Builder awsEc2SpotPrice(@Nullable Float awsEc2SpotPrice) {
       this.awsEc2SpotPrice = awsEc2SpotPrice;
       return this;
     }
@@ -97,20 +95,19 @@ public class InstanceTemplate {
         minNumberOfInstances = numberOfInstances;
       }
       return new InstanceTemplate(numberOfInstances, minNumberOfInstances, 
roles,
-        hardwareId, imageId, awsEc2SpotPrice);
+        template, awsEc2SpotPrice);
     }
   }
 
   private int numberOfInstances;
   private int minNumberOfInstances;  // some instances may fail, at least a 
minimum number is required
-  private String hardwareId;
-  private String imageId;
-  private float awsEc2SpotPrice;
+  private TemplateBuilderSpec template;
+  private Float awsEc2SpotPrice;
   private Set<String> roles;
 
 
   private InstanceTemplate(int numberOfInstances, int minNumberOfInstances,
-      Set<String> roles, String hardwareId, String imageId, float 
awsEc2SpotPrice) {
+      Set<String> roles, TemplateBuilderSpec template, Float awsEc2SpotPrice) {
     for (String role : roles) {
       checkArgument(!StringUtils.contains(role, " "),
         "Role '%s' may not contain space characters.", role);
@@ -118,8 +115,7 @@ public class InstanceTemplate {
 
     this.numberOfInstances = numberOfInstances;
     this.minNumberOfInstances = minNumberOfInstances;
-    this.hardwareId = hardwareId;
-    this.imageId = imageId;
+    this.template = template;
     this.awsEc2SpotPrice = awsEc2SpotPrice;
     this.roles = roles;
   }
@@ -136,15 +132,13 @@ public class InstanceTemplate {
     return minNumberOfInstances;
   }
 
-  public String getHardwareId() {
-    return hardwareId;
-  }
-
-  public String getImageId() {
-    return imageId;
+  @Nullable
+  public TemplateBuilderSpec getTemplate() {
+    return template;
   }
 
-  public float getAwsEc2SpotPrice() {
+  @Nullable
+  public Float getAwsEc2SpotPrice() {
     return awsEc2SpotPrice;
   }
 
@@ -153,8 +147,7 @@ public class InstanceTemplate {
       InstanceTemplate that = (InstanceTemplate) o;
       return numberOfInstances == that.numberOfInstances
         && minNumberOfInstances == that.minNumberOfInstances
-        && Objects.equal(hardwareId, that.hardwareId)
-        && Objects.equal(imageId, that.imageId)
+        && Objects.equal(template, that.template)
         && awsEc2SpotPrice == that.awsEc2SpotPrice
         && Objects.equal(roles, that.roles);
     }
@@ -163,15 +156,14 @@ public class InstanceTemplate {
 
   public int hashCode() {
     return Objects.hashCode(numberOfInstances, minNumberOfInstances,
-      hardwareId, imageId, awsEc2SpotPrice, roles);
+             template, awsEc2SpotPrice, roles);
   }
 
   public String toString() {
-    return Objects.toStringHelper(this)
+    return Objects.toStringHelper(this).omitNullValues()
       .add("numberOfInstances", numberOfInstances)
       .add("minNumberOfInstances", minNumberOfInstances)
-      .add("hardwareId", hardwareId)
-      .add("imageId", imageId)
+      .add("template", template)
       .add("awsEc2SpotPrice", awsEc2SpotPrice)
       .add("roles", roles)
       .toString();
@@ -219,19 +211,26 @@ public class InstanceTemplate {
     return templates;
   }
 
-  private static void parseInstanceTemplateGroupOverrides(
-    Configuration configuration, String templateGroup, Builder templateBuilder
-  ) {
-
-    String hardwareId = configuration.getString(
-      "whirr.templates." + templateGroup + ".hardware-id", null);
-    String imageId = configuration.getString(
-      "whirr.templates." + templateGroup + ".image-id", null);
-    float awsEc2SpotPrice = configuration.getFloat(
-      "whirr.templates." + templateGroup + ".aws-ec2-spot-price", 0);
-
-    templateBuilder.hardwareId(hardwareId).imageId(imageId)
-      .awsEc2SpotPrice(awsEc2SpotPrice);
+  private static void parseInstanceTemplateGroupOverrides(Configuration 
configuration, String templateGroup,
+        Builder templateBuilder) {
+    if (configuration.getList("whirr.templates." + templateGroup + 
".template").size() > 0) {
+      String specString = 
Joiner.on(',').join(configuration.getList("whirr.templates." + templateGroup + 
".template"));
+      templateBuilder.template(TemplateBuilderSpec.parse(specString));
+    } else {
+      // until TemplateBuilderSpec has type-safe builder
+      ImmutableMap.Builder<String, String> templateParamsBuilder = 
ImmutableMap.<String, String> builder();
+      for (String resource : ImmutableSet.of("image", "hardware")) {
+        String key = String.format("whirr.templates.%s.%s-id", templateGroup, 
resource);
+        if (configuration.getString(key) != null) {
+          templateParamsBuilder.put(resource + "Id", 
configuration.getString(key));
+        }
+      }
+      Map<String, String> templateParams = templateParamsBuilder.build();
+      if (templateParams.size() > 0)
+        
templateBuilder.template(TemplateBuilderSpec.parse(Joiner.on(',').withKeyValueSeparator("=")
+              .join(templateParams)));
+    }
+    templateBuilder.awsEc2SpotPrice(configuration.getFloat("whirr.templates." 
+ templateGroup + ".aws-ec2-spot-price", null));
   }
 
   private static int parseMinNumberOfInstances(

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/BootstrapClusterAction.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/actions/BootstrapClusterAction.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/BootstrapClusterAction.java
 (original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/BootstrapClusterAction.java
 Fri Aug 17 18:43:46 2012
@@ -99,7 +99,7 @@ public class BootstrapClusterAction exte
         computeServiceContext.getComputeService();
 
       final Template template = BootstrapTemplate.build(clusterSpec, 
computeService,
-        statementBuilder, entry.getValue().getTemplateBuilderStrategy(), 
entry.getKey());
+        statementBuilder, entry.getKey());
 
       Future<Set<? extends NodeMetadata>> nodesFuture = executorService.submit(
           new StartupProcess(

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ByonClusterAction.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/actions/ByonClusterAction.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ByonClusterAction.java 
(original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ByonClusterAction.java 
Fri Aug 17 18:43:46 2012
@@ -57,6 +57,7 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 import com.google.common.cache.LoadingCache;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
@@ -118,7 +119,16 @@ public class ByonClusterAction extends S
 
       int num = entry.getKey().getNumberOfInstances();
       Predicate<NodeMetadata> unused = not(in(usedNodes));
-      Predicate<NodeMetadata> instancePredicate = new 
TagsPredicate(StringUtils.split(entry.getKey().getHardwareId()));      
+      
+      // TODO: This seems very fragile and a bug.  It is not required that 
someone passes a hardware id, 
+      // so this is likely to break badly. Even if there was, why do we assume 
it is splittable?!
+      // this logic should be refactored or removed ASAP
+      Predicate<NodeMetadata> instancePredicate = Predicates.alwaysTrue();
+      if (entry.getKey().getTemplate() != null) {
+        String hardwareId = entry.getKey().getTemplate().getHardwareId();
+        if (hardwareId != null)
+          instancePredicate = new 
TagsPredicate(StringUtils.split(hardwareId)); 
+      }
 
       List<NodeMetadata> templateNodes = Lists.newArrayList(filter(nodes, 
and(unused, instancePredicate)));
       if (templateNodes.size() < num) {

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java
 (original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java
 Fri Aug 17 18:43:46 2012
@@ -38,7 +38,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-import javax.annotation.Nullable;
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.whirr.Cluster;
 import static org.apache.whirr.Cluster.Instance;
@@ -211,7 +210,7 @@ public abstract class ScriptBasedCluster
     return Joiner.on(", ").join(
         Iterables.transform(instances, new Function<Instance, String>() {
           @Override
-          public String apply(@Nullable Instance instance) {
+          public String apply(Instance instance) {
             return instance == null ? "<null>" : instance.getId();
           }
         }));
@@ -250,7 +249,7 @@ public abstract class ScriptBasedCluster
   private boolean containsNoneOf(Set<String> querySet, final Set<String> 
target) {
     return !Iterables.any(querySet, new Predicate<String>() {
       @Override
-      public boolean apply(@Nullable String role) {
+      public boolean apply(String role) {
         return target.contains(role);
       }
     });

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/compute/BootstrapTemplate.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/compute/BootstrapTemplate.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/compute/BootstrapTemplate.java 
(original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/compute/BootstrapTemplate.java 
Fri Aug 17 18:43:46 2012
@@ -29,7 +29,6 @@ import static org.jclouds.scriptbuilder.
 import org.apache.whirr.ClusterSpec;
 import org.apache.whirr.InstanceTemplate;
 import org.apache.whirr.service.jclouds.StatementBuilder;
-import org.apache.whirr.service.jclouds.TemplateBuilderStrategy;
 import org.jclouds.aws.ec2.AWSEC2ApiMetadata;
 import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
 import org.jclouds.ec2.EC2ApiMetadata;
@@ -58,7 +57,6 @@ public class BootstrapTemplate {
     final ClusterSpec clusterSpec,
     ComputeService computeService,
     StatementBuilder statementBuilder,
-    TemplateBuilderStrategy strategy,
     InstanceTemplate instanceTemplate
   ) {
     String name = "bootstrap-" + 
Joiner.on('_').join(instanceTemplate.getRoles());
@@ -74,9 +72,10 @@ public class BootstrapTemplate {
       LOG.debug("Running script {}:\n{}", name, 
bootstrap.render(OsFamily.UNIX));
     }
 
-    TemplateBuilder templateBuilder = computeService.templateBuilder()
-      .options(runScript(bootstrap));
-    strategy.configureTemplateBuilder(clusterSpec, templateBuilder, 
instanceTemplate);
+    TemplateBuilder templateBuilder = computeService.templateBuilder().from(
+        instanceTemplate.getTemplate() != null ? 
instanceTemplate.getTemplate() :
+        clusterSpec.getTemplate());
+    templateBuilder.options(runScript(bootstrap));
     return setSpotInstancePriceIfSpecified(
       computeService.getContext(), clusterSpec, templateBuilder.build(), 
instanceTemplate
     );
@@ -102,14 +101,9 @@ public class BootstrapTemplate {
   ) {
 
     if 
(AWSEC2ApiMetadata.CONTEXT_TOKEN.isAssignableFrom(context.getBackendType())) {
-      float spotPrice = firstPositiveOrDefault(
-        0,  /* by default use regular instances */
-        instanceTemplate.getAwsEc2SpotPrice(),
-        spec.getAwsEc2SpotPrice()
-      );
-      if (spotPrice > 0) {
-        
template.getOptions().as(AWSEC2TemplateOptions.class).spotPrice(spotPrice);
-      }
+      template.getOptions().as(AWSEC2TemplateOptions.class)
+            .spotPrice(instanceTemplate.getAwsEc2SpotPrice() != null ? 
instanceTemplate.getAwsEc2SpotPrice() :
+                                                                       
spec.getAwsEc2SpotPrice());
     }
 
     return mapEphemeralIfImageIsEBSBacked(context, spec, template, 
instanceTemplate);
@@ -143,13 +137,6 @@ public class BootstrapTemplate {
 
         return template;
     }
-                                                                               
      
-  private static float firstPositiveOrDefault(float defaultValue, float... 
listOfValues) {
-    for(float value : listOfValues) {
-      if (value > 0) return value;
-    }
-    return defaultValue;
-  }
 
   // must be used inside InitBuilder, as this sets the shell variables used in 
this statement
   private static Statement ensureUserExistsWithPublicAndPrivateKey(String 
username,

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterActionEvent.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterActionEvent.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterActionEvent.java 
(original)
+++ 
whirr/trunk/core/src/main/java/org/apache/whirr/service/ClusterActionEvent.java 
Fri Aug 17 18:43:46 2012
@@ -24,7 +24,6 @@ import org.apache.whirr.Cluster;
 import org.apache.whirr.ClusterSpec;
 import org.apache.whirr.InstanceTemplate;
 import org.apache.whirr.service.jclouds.StatementBuilder;
-import org.apache.whirr.service.jclouds.TemplateBuilderStrategy;
 import org.jclouds.compute.ComputeServiceContext;
 
 import com.google.common.base.Function;
@@ -39,8 +38,6 @@ public class ClusterActionEvent {
   private InstanceTemplate instanceTemplate;
   private Cluster cluster;
   private StatementBuilder statementBuilder;
-  private TemplateBuilderStrategy templateBuilderStrategy =
-    new TemplateBuilderStrategy();
   private FirewallManager firewallManager;
   private Function<ClusterSpec, ComputeServiceContext> getCompute;
   private VelocityEngine velocityEngine;
@@ -94,15 +91,6 @@ public class ClusterActionEvent {
     return statementBuilder;
   }
 
-  public TemplateBuilderStrategy getTemplateBuilderStrategy() {
-    return templateBuilderStrategy;
-  }
-
-  public void setTemplateBuilderStrategy(
-      TemplateBuilderStrategy templateBuilderStrategy) {
-    this.templateBuilderStrategy = templateBuilderStrategy;
-  }
-  
   public FirewallManager getFirewallManager() {
     return firewallManager;
   }

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java 
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/ComputeCache.java 
Fri Aug 17 18:43:46 2012
@@ -271,11 +271,8 @@ public enum ComputeCache implements Func
         }
       }
       overrides = ConfigurationConverter.getProperties(jcloudsConfig);
-      if (spec.getBootstrapUser() != null) {
-         overrides.put(provider + ".image.login-user", 
spec.getBootstrapUser());
-      }
 
-      if ("aws-ec2".equals(spec.getProvider()) && spec.getImageId() != null) {
+      if ("aws-ec2".equals(spec.getProvider()) && 
spec.getTemplate().getImageId() != null) {
         enableAWSEC2LazyImageFetching(spec);
       }
 
@@ -297,7 +294,7 @@ public enum ComputeCache implements Func
       overrides.setProperty(PROPERTY_EC2_AMI_QUERY, "");
       overrides.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
 
-      String[] parts = StringUtils.split(spec.getImageId(), '/');
+      String[] parts = StringUtils.split(spec.getTemplate().getImageId(), '/');
       checkArgument(parts.length == 2, "Expected to find image-id = 
region/ami-id");
 
       overrides.setProperty(PROPERTY_REGION, parts[0]);

Modified: 
whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java 
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java 
Fri Aug 17 18:43:46 2012
@@ -33,7 +33,6 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import javax.annotation.Nullable;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 
@@ -131,7 +130,7 @@ public class DryRunModule extends Abstra
     private final Credentials creds;
     private final NodeMetadata node;
 
-    Key(HostAndPort socket, Credentials creds, @Nullable NodeMetadata node) {
+    Key(HostAndPort socket, Credentials creds, NodeMetadata node) {
       this.socket = socket;
       this.creds = creds;
       this.node = node;

Modified: whirr/trunk/core/src/main/java/org/apache/whirr/util/BlobCache.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/util/BlobCache.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/util/BlobCache.java 
(original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/util/BlobCache.java Fri Aug 
17 18:43:46 2012
@@ -119,20 +119,20 @@ public class BlobCache {
         LOG.warn("No blob store location found with this ID '{}'. " +
           "Using default location.", spec.getBlobStoreLocationId());
       }
-    } else if (spec.getLocationId() != null) {
+    } else if (spec.getTemplate().getLocationId() != null) {
       /* find the closest location to the compute nodes */
       ComputeServiceContext compute = getCompute.apply(spec);
 
       Set<String> computeIsoCodes = null;
       for(Location loc : 
compute.getComputeService().listAssignableLocations()) {
-        if (loc.getId().equals(spec.getLocationId())) {
+        if (loc.getId().equals(spec.getTemplate().getLocationId())) {
           computeIsoCodes = loc.getIso3166Codes();
           break;
         }
       }
       if (computeIsoCodes == null) {
         LOG.warn("Invalid compute location ID '{}'. " +
-          "Using default blob store location.", spec.getLocationId());
+          "Using default blob store location.", 
spec.getTemplate().getLocationId());
       } else {
         for (Location loc : context.getBlobStore().listAssignableLocations()) {
           if (containsAny(loc.getIso3166Codes(), computeIsoCodes)) {

Modified: whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/util/Utils.java Fri Aug 17 
18:43:46 2012
@@ -50,7 +50,7 @@ public class Utils {
     out.println("\nYou can log into instances using the following ssh 
commands:");
 
     String user = clusterSpec.getClusterUser() != null ? clusterSpec
-      .getClusterUser() : clusterSpec.getBootstrapUser();
+      .getClusterUser() : clusterSpec.getTemplate().getLoginUser();
 
     String pkFile = clusterSpec.getPrivateKeyFile().getAbsolutePath();
 

Modified: whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java 
(original)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/ClusterSpecTest.java Fri 
Aug 17 18:43:46 2012
@@ -38,6 +38,7 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.io.IOUtils;
 import org.apache.whirr.util.KeyPair;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -69,7 +70,23 @@ public class ClusterSpecTest {
     assertThat(spec.getRunUrlBase(), is("http://example.org";));
   }
   
-
+  @Test
+  public void testAwsEc2SpotPrice() throws ConfigurationException {
+    assertEquals(ClusterSpec.withNoDefaults(new 
PropertiesConfiguration()).getAwsEc2SpotPrice(), null);
+    Configuration conf = new PropertiesConfiguration();
+    conf.setProperty(ClusterSpec.Property.AWS_EC2_SPOT_PRICE.getConfigName(), 
"0.30");
+    ClusterSpec spec = ClusterSpec.withNoDefaults(conf);
+    assertEquals(spec.getAwsEc2SpotPrice(), new Float(0.3));
+  }
+  
+  @Test
+  public void testTemplate() throws ConfigurationException {
+    Configuration conf = new PropertiesConfiguration();
+    conf.setProperty(ClusterSpec.Property.TEMPLATE.getConfigName(), 
"osFamily=UBUNTU,os64Bit=true,minRam=2048");
+    ClusterSpec spec = ClusterSpec.withNoDefaults(conf);
+    assertEquals(spec.getTemplate(), 
TemplateBuilderSpec.parse("osFamily=UBUNTU,os64Bit=true,minRam=2048"));
+  }
+  
   @Test
   public void testEndpoint() throws ConfigurationException {
     Configuration conf = new PropertiesConfiguration();
@@ -354,7 +371,7 @@ public class ClusterSpecTest {
   public void testCopySpec() throws Exception {
     ClusterSpec spec = ClusterSpec.withTemporaryKeys(
       new PropertiesConfiguration("whirr-core-test.properties"));
-    spec.setLocationId("random-location");
+    spec.setTemplate(TemplateBuilderSpec.parse("locationId=random-location"));
 
     /* check the copy is the same as the original */
     assertThat(spec.copy(), is(spec));
@@ -376,32 +393,40 @@ public class ClusterSpecTest {
   @Test
   public void testHardwareIdPerInstanceTemplate() throws Exception {
     PropertiesConfiguration conf = new 
PropertiesConfiguration("whirr-core-test.properties");
-    conf.setProperty("whirr.instance-templates", "2 noop, 1 role1+role2, 1 
role1, 3 spots");
+    conf.setProperty("whirr.instance-templates", "2 noop, 1 role1+role2, 1 
role1, 3 spots, 1 spec");
     conf.setProperty("whirr.hardware-id", "c1.xlarge");
 
     conf.setProperty("whirr.templates.noop.hardware-id", "m1.large");
     conf.setProperty("whirr.templates.role1+role2.hardware-id", "t1.micro");
     conf.setProperty("whirr.templates.role1+role2.image-id", 
"us-east-1/ami-123324");
     conf.setProperty("whirr.templates.spots.aws-ec2-spot-price", 0.5f);
+    conf.setProperty("whirr.templates.spec.template", 
"osFamily=UBUNTU,os64Bit=true,minRam=2048");
 
     ClusterSpec spec = ClusterSpec.withTemporaryKeys(conf);
     List<InstanceTemplate> templates = spec.getInstanceTemplates();
 
     InstanceTemplate noops = get(templates, 0);
     assert noops.getRoles().contains("noop");
-    assertEquals(noops.getHardwareId(), "m1.large");
-    assertEquals(noops.getImageId(), null);
+    assertEquals(noops.getTemplate().getHardwareId(), "m1.large");
+    assertEquals(noops.getTemplate().getImageId(), null);
+    assertEquals(noops.getAwsEc2SpotPrice(), null);
 
     InstanceTemplate second = get(templates, 1);
-    assertEquals(second.getHardwareId(), "t1.micro");
-    assertEquals(second.getImageId(), "us-east-1/ami-123324");
+    assertEquals(second.getTemplate().getHardwareId(), "t1.micro");
+    assertEquals(second.getTemplate().getImageId(), "us-east-1/ami-123324");
+    assertEquals(second.getAwsEc2SpotPrice(), null);
 
     InstanceTemplate third = get(templates, 2);
-    assertEquals(third.getHardwareId(), null);
-    assertEquals(third.getImageId(), null);
+    assertEquals(third.getTemplate(), null);
+    assertEquals(third.getAwsEc2SpotPrice(), null);
 
     InstanceTemplate spots = get(templates, 3);
-    assertEquals(spots.getAwsEc2SpotPrice(), 0.5f, 0.001);
+    assertEquals(spots.getAwsEc2SpotPrice(), new Float(0.5f), 0.001);
+
+    InstanceTemplate template = get(templates, 4);
+    assertEquals(template.getTemplate(), 
TemplateBuilderSpec.parse("osFamily=UBUNTU,os64Bit=true,minRam=2048"));
+    assertEquals(template.getAwsEc2SpotPrice(), null);
+
   }
 
   @Test(expected = ConfigurationException.class)

Modified: 
whirr/trunk/core/src/test/java/org/apache/whirr/actions/BootstrapClusterActionTest.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/BootstrapClusterActionTest.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/test/java/org/apache/whirr/actions/BootstrapClusterActionTest.java
 (original)
+++ 
whirr/trunk/core/src/test/java/org/apache/whirr/actions/BootstrapClusterActionTest.java
 Fri Aug 17 18:43:46 2012
@@ -56,6 +56,7 @@ import org.jclouds.compute.domain.NodeMe
 import org.jclouds.compute.domain.OperatingSystem;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
 import org.jclouds.compute.domain.internal.TemplateImpl;
 import org.jclouds.compute.options.TemplateOptions;
 import org.jclouds.domain.Location;
@@ -124,6 +125,7 @@ public class BootstrapClusterActionTest 
     when(computeService.getContext()).thenReturn(serviceContext);
     
when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
     when(computeService.templateBuilder()).thenReturn(templateBuilder);
+    when(templateBuilder.from((TemplateBuilderSpec) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.options((TemplateOptions) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.build()).thenReturn(template);
     
@@ -193,6 +195,7 @@ public class BootstrapClusterActionTest 
     when(computeService.getContext()).thenReturn(serviceContext);
     
when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
     when(computeService.templateBuilder()).thenReturn(templateBuilder);
+    when(templateBuilder.from((TemplateBuilderSpec) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.options((TemplateOptions) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.build()).thenReturn(template);
     
@@ -370,6 +373,7 @@ public class BootstrapClusterActionTest 
     when(computeService.getContext()).thenReturn(serviceContext);
     
when(serviceContext.getBackendType()).thenReturn(TypeToken.class.cast(TypeToken.of(Context.class)));
     when(computeService.templateBuilder()).thenReturn(templateBuilder);
+    when(templateBuilder.from((TemplateBuilderSpec) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.options((TemplateOptions) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.build()).thenReturn(template);
     
@@ -431,6 +435,7 @@ public class BootstrapClusterActionTest 
     when(getCompute.apply(clusterSpec)).thenReturn(serviceContext);
     when(serviceContext.getComputeService()).thenReturn(computeService);
     when(computeService.templateBuilder()).thenReturn(templateBuilder);
+    when(templateBuilder.from((TemplateBuilderSpec) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.options((TemplateOptions) 
any())).thenReturn(templateBuilder);
     when(templateBuilder.build()).thenReturn(template);
     

Modified: 
whirr/trunk/core/src/test/java/org/apache/whirr/compute/BootstrapTemplateTest.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/compute/BootstrapTemplateTest.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/test/java/org/apache/whirr/compute/BootstrapTemplateTest.java
 (original)
+++ 
whirr/trunk/core/src/test/java/org/apache/whirr/compute/BootstrapTemplateTest.java
 Fri Aug 17 18:43:46 2012
@@ -32,7 +32,6 @@ import org.apache.commons.configuration.
 import org.apache.whirr.ClusterSpec;
 import org.apache.whirr.InstanceTemplate;
 import org.apache.whirr.service.jclouds.StatementBuilder;
-import org.apache.whirr.service.jclouds.TemplateBuilderStrategy;
 import org.jclouds.aws.ec2.AWSEC2ApiMetadata;
 import org.jclouds.aws.ec2.compute.AWSEC2ComputeService;
 import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions;
@@ -41,6 +40,7 @@ import org.jclouds.compute.ComputeServic
 import org.jclouds.compute.domain.Image;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
 import org.jclouds.compute.options.TemplateOptions;
 import org.junit.Before;
 import org.junit.Test;
@@ -53,12 +53,10 @@ import com.google.common.reflect.TypeTok
 public class BootstrapTemplateTest {
 
   private StatementBuilder statementBuilder;
-  private TemplateBuilderStrategy templateBuilderStrategy;
 
   @Before
   public void setUp() throws Exception {
     statementBuilder = new StatementBuilder();
-    templateBuilderStrategy = new TemplateBuilderStrategy();
   }
 
   @Test
@@ -124,6 +122,7 @@ private void assertSpotPriceIs(
 
     TemplateBuilder templateBuilder = mock(TemplateBuilder.class);
     when(computeService.templateBuilder()).thenReturn(templateBuilder);
+    
when(templateBuilder.from((TemplateBuilderSpec)any())).thenReturn(templateBuilder);
     
when(templateBuilder.options((TemplateOptions)any())).thenReturn(templateBuilder);
 
     Template template = mock(Template.class);
@@ -137,7 +136,7 @@ private void assertSpotPriceIs(
     when(options.as((Class<TemplateOptions>) 
any())).thenReturn(awsEec2TemplateOptions);
 
     BootstrapTemplate.build(clusterSpec, computeService,
-      statementBuilder, templateBuilderStrategy, instanceTemplate);
+      statementBuilder, instanceTemplate);
 
     verify(awsEec2TemplateOptions).spotPrice(spotPrice);
   }

Modified: 
whirr/trunk/core/src/test/java/org/apache/whirr/util/integration/BlobCacheTest.java
URL: 
http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/util/integration/BlobCacheTest.java?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- 
whirr/trunk/core/src/test/java/org/apache/whirr/util/integration/BlobCacheTest.java
 (original)
+++ 
whirr/trunk/core/src/test/java/org/apache/whirr/util/integration/BlobCacheTest.java
 Fri Aug 17 18:43:46 2012
@@ -41,6 +41,7 @@ import org.apache.whirr.service.BlobStor
 import org.apache.whirr.service.ComputeCache;
 import org.apache.whirr.util.BlobCache;
 import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.scriptbuilder.domain.OsFamily;
 import org.junit.Test;
@@ -99,7 +100,7 @@ public class BlobCacheTest {
       return; // this test can be executed only on amazon but the internal
       // location selection mechanism should work for any cloud provider
     }
-    spec.setLocationId("eu-west-1");
+    spec.setTemplate(TemplateBuilderSpec.parse("locationId=eu-west-1"));
 
     BlobCache cache = BlobCache.getInstance(ComputeCache.INSTANCE, spec);
     assertThat(cache.getLocation().getId(), is("EU"));

Modified: whirr/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/whirr/trunk/pom.xml?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/pom.xml (original)
+++ whirr/trunk/pom.xml Fri Aug 17 18:43:46 2012
@@ -49,7 +49,6 @@
     <module>services/yarn</module>
     <module>services/zookeeper</module>
     <module>services/hbase</module>
-    <module>services/hbase-oldtests</module>
     <module>services/elasticsearch</module>
     <module>services/hama</module>
     <module>services/puppet</module>
@@ -67,13 +66,13 @@
     <commons.io.version>1.4</commons.io.version>
     <common-ssl.version>0.3.11</common-ssl.version>
     <dnsjava.version>2.1.1</dnsjava.version>
-    <guava.version>12.0</guava.version>
+    <guava.version>13.0</guava.version>
     <hadoop.version>0.20.205.0</hadoop.version>
     <hamcrest.version>1.1</hamcrest.version>
     <hama.version>0.4.0-incubating</hama.version>
     <hbase.version>0.92.0</hbase.version>
     <jackson.version>1.5.2</jackson.version>
-    <jclouds.version>1.5.0-beta.9</jclouds.version>
+    <jclouds.version>1.5.0-beta.10</jclouds.version>
     <jdom.version>1.1</jdom.version>
     <jopt.simple.version>4.3</jopt.simple.version>
     <jsch.version>0.1.48</jsch.version>

Modified: whirr/trunk/src/site/xdoc/configuration-guide.xml
URL: 
http://svn.apache.org/viewvc/whirr/trunk/src/site/xdoc/configuration-guide.xml?rev=1374393&r1=1374392&r2=1374393&view=diff
==============================================================================
--- whirr/trunk/src/site/xdoc/configuration-guide.xml (original)
+++ whirr/trunk/src/site/xdoc/configuration-guide.xml Fri Aug 17 18:43:46 2012
@@ -518,6 +518,16 @@ xsi:schemaLocation="http://maven.apache.
       </tr>
       <tr valign="top">
         <td>
+          <tt>whirr.template</tt>
+        </td>
+        <td>
+          <tt>--template</tt>
+        </td>
+        <td>osFamily=UBUNTU,osVersionMatches=10.04,minRam=1024</td>
+        <td>The specification of requirements for instances in jclouds <a 
href="https://github.com/jclouds/jclouds/blob/1.5.x/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilderSpec.java";>TemplateBuilderSpec</a>
 format. For example, this can control the ram, cores, os, and login user 
details.</td>
+      </tr>
+      <tr valign="top">
+        <td>
           <tt>whirr.image-id</tt>
         </td>
         <td>


Reply via email to