From 190c768d0291f2911e3bc8447c2a6e4bcde64a7d Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 4 Apr 2010 22:57:03 -0700 Subject: [PATCH] Issue 221: made sure default template always works on all cloud providers --- .../EC2ComputeServiceContextModule.java | 10 +++ .../compute/EC2ComputeServiceLiveTest.java | 15 ++-- .../src/main/clojure/org/jclouds/compute.clj | 58 ++++++++++++--- .../compute/domain/TemplateBuilder.java | 25 +++---- .../compute/internal/TemplateBuilderImpl.java | 47 ++++++++---- .../compute/BaseComputeServiceLiveTest.java | 49 +++++++++---- .../internal/TemplateBuilderImplTest.java | 72 +++++++++++++++++++ .../GoGridComputeServiceContextModule.java | 19 +++-- .../gogrid/GoGridComputeServiceLiveTest.java | 29 +++----- ...oudServersComputeServiceContextModule.java | 11 +++ .../CloudServersComputeServiceLiveTest.java | 14 ++-- ...imuHostingComputeServiceContextModule.java | 11 +++ .../rimuhosting/miro/domain/Image.java | 2 +- .../RimuHostingComputeServiceLiveTest.java | 15 ++-- ...LockVCloudComputeServiceContextModule.java | 1 - .../BlueLockVCloudComputeServiceLiveTest.java | 48 ++++++++----- .../VCloudComputeServiceContextModule.java | 10 +++ .../compute/VCloudComputeServiceLiveTest.java | 8 --- ...tComVCloudComputeServiceContextModule.java | 19 +++++ ...ingDotComVCloudComputeServiceLiveTest.java | 15 ++-- ...markVCloudComputeServiceContextModule.java | 14 ++++ ...TerremarkVCloudComputeServiceLiveTest.java | 14 ++++ 22 files changed, 387 insertions(+), 119 deletions(-) create mode 100644 compute/src/test/java/org/jclouds/compute/internal/TemplateBuilderImplTest.java diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java index 161a4fd187..3269eea0a1 100755 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -20,6 +20,7 @@ package org.jclouds.aws.ec2.compute.config; import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.ownedBy; import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; import java.net.URI; import java.util.Map; @@ -58,7 +59,9 @@ import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Size; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.compute.predicates.RunScriptRunning; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.DestroyNodeStrategy; @@ -102,6 +105,13 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule { bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class); } + @Provides + TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU); + } + @Singleton public static class EC2ListNodesStrategy implements ListNodesStrategy { private final InstanceClient client; diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java index 11e31e938a..76076e9099 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EC2ComputeServiceLiveTest.java @@ -18,12 +18,12 @@ */ package org.jclouds.aws.ec2.compute; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; +import static org.testng.Assert.assertEquals; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,13 +40,18 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { service = "ec2"; } - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(UBUNTU).smallest().architecture(Architecture.X86_32).build(); + @Test + public void testTemplateBuilderCanUseImageId() { + client.templateBuilder().imageId("ami-d57f93bc").build(); } @Test public void testTemplateBuilder() { - client.templateBuilder().imageId("ami-d57f93bc").build(); + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_32); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getLocation().getId(), "us-east-1"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } @Override diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index 777e4759b5..22ac570da4 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -9,18 +9,28 @@ Here's an example of getting some compute configuration from rackspace: (use 'org.jclouds.compute) (use 'clojure.contrib.pprint) + (def provider \"cloudservers\") (def user \"username\") (def password \"password\") - (def compute-name \"cloudservers\") - (def compute (compute-context compute-name user password)) + ; create a compute service + (def compute + (compute-service provider user password)) (with-compute-service [compute] (pprint (locations)) (pprint (images)) (pprint (nodes)) (pprint (sizes))) - + +Here's an example of creating and running a small linux node with the tag webserver: + + ; create a compute service using ssh and log4j extensions + (def compute + (compute-service provider user password :ssh :log4j)) + + (run-node \"webserver\" compute) + See http://code.google.com/p/jclouds for details." (:use org.jclouds.core clojure.contrib.duck-streams @@ -107,8 +117,6 @@ See http://code.google.com/p/jclouds for details." ([] (default-template *compute*)) ([#^ComputeService compute] (.. compute (templateBuilder) - (osFamily OsFamily/UBUNTU) - smallest (options (org.jclouds.compute.options.TemplateOptions$Builder/authorizePublicKey (slurp (str (. System getProperty "user.home") "/.ssh/id_rsa.pub")))) @@ -116,7 +124,26 @@ See http://code.google.com/p/jclouds for details." (defn run-nodes "Create the specified number of nodes using the default or specified - template." + template. + + ; simplest way to add 2 small linux nodes to the group webserver is to run + (run-nodes \"webserver\" 2 compute) + + ; which is the same as wrapping the run-nodes command with an implicit compute service + ; note that this will actually add another 2 nodes to the set called \"webserver\" + (with-compute-service [compute] + (run-nodes \"webserver\" 2 )) + + ; which is the same as specifying the default template + (with-compute-service [compute] + (run-nodes \"webserver\" 2 (default-template))) + + ; which, on gogrid, is the same as constructing the smallest centos template that has no layered software + (with-compute-service [compute] + (run-nodes \"webserver\" 2 + (build-template service :centos :smallest :image-name-matches \".*w/ None.*\"))) + +" ([tag count] (run-nodes tag count (default-template *compute*) *compute*)) ([tag count compute-or-template] @@ -129,7 +156,17 @@ See http://code.google.com/p/jclouds for details." (.runNodesWithTag compute tag count template)))) (defn run-node - "Create a node using the default or specified template." + "Create a node using the default or specified template. + + ; simplest way to add a small linux node to the group webserver is to run + (run-node \"webserver\" compute) + + ; which is the same as wrapping the run-node command with an implicit compute service + ; note that this will actually add another node to the set called \"webserver\" + (with-compute-service [compute] + (run-node \"webserver\" )) + +" ([tag] (run-nodes tag 1 (default-template *compute*) *compute*)) ([tag compute-or-template] @@ -298,7 +335,12 @@ See http://code.google.com/p/jclouds for details." (f builder value) (println "Unknown option" option)))) -(defn build-template [#^ComputeService compute option & options] +(defn build-template + "Creates a template that can be used to run nodes. + +There are many options to use for the default template + " + [#^ComputeService compute option & options] (let [builder (.. compute (templateBuilder))] (loop [option option remaining options] diff --git a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java index b1e6a491fd..544e9d1f1d 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/TemplateBuilder.java @@ -1,24 +1,19 @@ /** * - * Copyright (C) 2009 Global Cloud Specialists, Inc. + * Copyright (C) 2009 Cloud Conscious, LLC. * * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * ==================================================================== */ package org.jclouds.compute.domain; diff --git a/compute/src/main/java/org/jclouds/compute/internal/TemplateBuilderImpl.java b/compute/src/main/java/org/jclouds/compute/internal/TemplateBuilderImpl.java index f57be120a2..8a2227c500 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/TemplateBuilderImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/TemplateBuilderImpl.java @@ -41,6 +41,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; import org.jclouds.logging.Logger; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ComparisonChain; @@ -63,21 +64,35 @@ public class TemplateBuilderImpl implements TemplateBuilder { private final Map images; private final Map sizes; private final Map locations; - private OsFamily os; - private Architecture arch; - private String locationId; - private String imageId; - private String sizeId; - private String osDescription; - private String imageVersion; - private String imageName; - private String imageDescription; + @VisibleForTesting + OsFamily os; + @VisibleForTesting + Architecture arch; + @VisibleForTesting + String locationId; + @VisibleForTesting + String imageId; + @VisibleForTesting + String sizeId; + @VisibleForTesting + String osDescription; + @VisibleForTesting + String imageVersion; - private double minCores; - private int minRam; + @VisibleForTesting + String imageName; + @VisibleForTesting + String imageDescription; - private boolean biggest; - private boolean fastest; + @VisibleForTesting + double minCores; + @VisibleForTesting + int minRam; + + @VisibleForTesting + boolean biggest; + @VisibleForTesting + boolean fastest; private TemplateOptions options = TemplateOptions.NONE; @@ -411,6 +426,12 @@ public class TemplateBuilderImpl implements TemplateBuilder { @Override public TemplateBuilder imageId(String imageId) { this.imageId = imageId; + this.imageName = null; + this.imageDescription = null; + this.imageVersion = null; + this.arch = null; + this.os = null; + this.osDescription = null; return this; } diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index a2afdfc34a..68225f0b9b 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -39,6 +39,7 @@ import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; @@ -139,7 +140,8 @@ public abstract class BaseComputeServiceLiveTest { template = buildTemplate(client.templateBuilder()); template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey( - keyPair.get("public")).runScript(buildScript().getBytes()); + keyPair.get("public")).runScript( + buildScript(template.getImage().getOsFamily()).getBytes()); nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 2, template).values()); assertEquals(nodes.size(), 2); checkNodes(); @@ -172,19 +174,40 @@ public abstract class BaseComputeServiceLiveTest { } } - protected abstract Template buildTemplate(TemplateBuilder templateBuilder); + protected Template buildTemplate(TemplateBuilder templateBuilder) { + return templateBuilder.build(); + } - protected String buildScript() { - return new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// - .append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")// - .append( - "sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")// - .append("apt-get update\n")// - .append("apt-get install -f -y --force-yes openjdk-6-jdk\n")// - .append("wget -qO/usr/bin/runurl run.alestic.com/runurl\n")// - .append("chmod 755 /usr/bin/runurl\n")// - .toString(); + protected String buildScript(OsFamily osFamily) { + switch (osFamily) { + case JEOS: + case UBUNTU: + return new StringBuilder()// + .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// + .append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")// + .append( + "sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")// + .append("apt-get update\n")// + .append("apt-get install -f -y --force-yes openjdk-6-jdk\n")// + .append("wget -qO/usr/bin/runurl run.alestic.com/runurl\n")// + .append("chmod 755 /usr/bin/runurl\n")// + .toString(); + case CENTOS: + case RHEL: + return new StringBuilder() + .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") + .append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + .append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + .append( + "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + .append("yum --nogpgcheck -y install java-1.6.0-openjdk\n") + .append( + "echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n") + .toString(); + default: + throw new IllegalArgumentException(osFamily.toString()); + } } @Test(enabled = true, dependsOnMethods = "testCreate") diff --git a/compute/src/test/java/org/jclouds/compute/internal/TemplateBuilderImplTest.java b/compute/src/test/java/org/jclouds/compute/internal/TemplateBuilderImplTest.java new file mode 100644 index 0000000000..9ab1740177 --- /dev/null +++ b/compute/src/test/java/org/jclouds/compute/internal/TemplateBuilderImplTest.java @@ -0,0 +1,72 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.compute.internal; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Size; +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; +import org.jclouds.domain.internal.LocationImpl; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class TemplateBuilderImplTest { + + @Test + public void testImageIdNullsEverythingElse() { + TemplateBuilderImpl template = new TemplateBuilderImpl(ImmutableMap. of(), + ImmutableMap. of(), ImmutableMap. of(), + new LocationImpl(LocationScope.REGION, " id", "description", null, true)); + template.architecture(Architecture.X86_32); + template.imageDescriptionMatches("imageDescriptionMatches"); + template.imageNameMatches("imageNameMatches"); + template.imageVersionMatches("imageVersionMatches"); + template.osDescriptionMatches("osDescriptionMatches"); + template.osFamily(OsFamily.CENTOS); + + assertEquals(template.arch, Architecture.X86_32); + assertEquals(template.imageDescription, "imageDescriptionMatches"); + assertEquals(template.imageName, "imageNameMatches"); + assertEquals(template.imageVersion, "imageVersionMatches"); + assertEquals(template.osDescription, "osDescriptionMatches"); + assertEquals(template.os, OsFamily.CENTOS); + assertEquals(template.imageId, null); + + template.imageId("myid"); + assertEquals(template.arch, null); + assertEquals(template.imageDescription, null); + assertEquals(template.imageName, null); + assertEquals(template.imageVersion, null); + assertEquals(template.osDescription, null); + assertEquals(template.os, null); + assertEquals(template.imageId, "myid"); + + } + +} diff --git a/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridComputeServiceContextModule.java b/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridComputeServiceContextModule.java index 1203753496..cb585296fb 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridComputeServiceContextModule.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridComputeServiceContextModule.java @@ -19,6 +19,7 @@ package org.jclouds.gogrid.config; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.compute.domain.OsFamily.CENTOS; import java.net.InetAddress; import java.net.UnknownHostException; @@ -45,10 +46,12 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.ImageImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.SizeImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.compute.predicates.RunScriptRunning; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; @@ -106,6 +109,14 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { bind(DestroyNodeStrategy.class).to(GoGridDestroyNodeStrategy.class); } + @Provides + TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS) + .imageNameMatches(".*w/ None.*"); + } + @Provides @Named("NAMING_CONVENTION") @Singleton @@ -140,7 +151,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { int numOfRetries = 20; // lock-free consumption of a shared resource: IP address pool while (notStarted) { // TODO: replace with Predicate-based thread collision avoidance for - // simplicity + // simplicity Set availableIps = client.getIpServices().getIpList( new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC)); if (availableIps.size() == 0) @@ -316,6 +327,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { private final Function stringIpToInetAddress; private final GoGridClient client; + @SuppressWarnings("unused") @Inject ServerToNodeMetadata(Map serverStateToNodeState, Function stringIpToInetAddress, GoGridClient client) { @@ -337,7 +349,6 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null, ImmutableMap. of(), tag, state, ipSet, ImmutableList . of(), ImmutableMap. of(), creds); - } } @@ -447,8 +458,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule { holder.logger.debug("<< didn't match os(%s)", matchedOs); } - images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(), null, - ImmutableMap. of(), from.getDescription(), version, os, + images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(), + null, ImmutableMap. of(), from.getDescription(), version, os, osDescription, arch)); } holder.logger.debug("<< images(%d)", images.size()); diff --git a/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java index ed77be3ea7..27543bf229 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.gogrid; -import static org.jclouds.compute.domain.OsFamily.CENTOS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -27,11 +26,12 @@ import java.util.Map; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.Architecture; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rest.RestContext; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; @@ -52,24 +52,13 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { service = "gogrid"; } - @Override - public String buildScript() { - return new StringBuilder() - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") - .append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - .append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - .append( - "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - .append("yum --nogpgcheck -y install java-1.6.0-openjdk\n") - .append( - "echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n") - .toString(); - } - - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(CENTOS).imageDescriptionMatches(".*w/ None.*").smallest() - .build(); + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS); + assertEquals(defaultTemplate.getLocation().getId(), "SANFRANCISCO"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } @Override diff --git a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index 9ca9b2b7db..c3b7a3fdab 100755 --- a/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/rackspace/src/main/java/org/jclouds/rackspace/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -18,6 +18,8 @@ */ package org.jclouds.rackspace.cloudservers.compute.config; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; + import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; @@ -43,11 +45,13 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.ImageImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.SizeImpl; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.compute.predicates.RunScriptRunning; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; @@ -104,6 +108,13 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext bind(DestroyNodeStrategy.class).to(CloudServersDestroyNodeStrategy.class); } + @Provides + TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU); + } + @Provides @Named("NAMING_CONVENTION") @Singleton diff --git a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java index 729cf12a52..2e9d50ba37 100644 --- a/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/rackspace/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -19,12 +19,13 @@ package org.jclouds.rackspace.cloudservers.compute; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; +import static org.testng.Assert.assertEquals; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient; import org.jclouds.rackspace.cloudservers.CloudServersClient; import org.jclouds.rest.RestContext; @@ -47,8 +48,13 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe service = "cloudservers"; } - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(UBUNTU).osDescriptionMatches(".*9.10.*").smallest().build(); + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getLocation().getId(), "DALLAS"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } @Override diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java index 3cc5ec003d..2029235a8b 100755 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java @@ -19,6 +19,7 @@ package org.jclouds.rimuhosting.miro.compute.config; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; import java.net.InetAddress; import java.net.UnknownHostException; @@ -47,10 +48,12 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.ImageImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.SizeImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.compute.predicates.RunScriptRunning; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; @@ -108,6 +111,14 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo bind(DestroyNodeStrategy.class).to(RimuHostingDestroyNodeStrategy.class); } + @Provides + TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).sizeId("MIRO1B") + .osFamily(UBUNTU); + } + @Provides @Named("NAMING_CONVENTION") @Singleton diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java index 6ac4e8cc77..548f570a89 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/domain/Image.java @@ -28,7 +28,7 @@ import com.google.gson.annotations.SerializedName; public class Image implements Comparable { @SerializedName("distro_code") private String id; - @SerializedName("distro_desciption") + @SerializedName("distro_description") private String description; @Override diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index a18d48d7b0..2dd30cf903 100755 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -18,11 +18,12 @@ */ package org.jclouds.rimuhosting.miro.compute; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; +import static org.testng.Assert.assertEquals; import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -39,8 +40,14 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes tag = "rimuhosting.jclouds"; } - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(UBUNTU).sizeId("MIRO1B").build(); + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getLocation().getId(), "DCDALLAS"); + assertEquals(defaultTemplate.getSize().getId(), "MIRO1B"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } @Override diff --git a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java index 110c98928a..3574be1cc6 100644 --- a/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java +++ b/vcloud/bluelock/src/main/java/org/jclouds/vcloud/bluelock/compute/config/BlueLockVCloudComputeServiceContextModule.java @@ -34,7 +34,6 @@ public class BlueLockVCloudComputeServiceContextModule extends VCloudComputeServ protected void configure() { super.configure(); bind(VCloudComputeClient.class).to(BlueLockVCloudComputeClient.class); - } } diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java index 29d86e55a9..7d3bf619d6 100644 --- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudComputeServiceLiveTest.java @@ -23,7 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Map; +import org.jclouds.compute.domain.Architecture; import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; import org.jclouds.http.HttpResponseException; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudMediaType; @@ -56,24 +59,33 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi // TODO verify parsing works } -// // https://forums.bluelock.com/showthread.php?p=353#post353 -// @Override -// @Test(enabled = false) -// public void testCreate() throws Exception { -// super.testCreate(); -// } -// -// @Override -// @Test(enabled = false) -// public void testGet() throws Exception { -// super.testGet(); -// } -// -// @Override -// @Test(enabled = false) -// public void testReboot() throws Exception { -// super.testReboot(); -// } + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getLocation().getId(), "133"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); + } + + // // https://forums.bluelock.com/showthread.php?p=353#post353 + // @Override + // @Test(enabled = false) + // public void testCreate() throws Exception { + // super.testCreate(); + // } + // + // @Override + // @Test(enabled = false) + // public void testGet() throws Exception { + // super.testGet(); + // } + // + // @Override + // @Test(enabled = false) + // public void testReboot() throws Exception { + // super.testReboot(); + // } @Test public void testExample() throws Exception { diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index fbef007ede..0ba62f03fa 100755 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.compute.config; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; import java.util.Map; import java.util.Set; @@ -46,10 +47,12 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.ImageImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.SizeImpl; import org.jclouds.compute.internal.ComputeServiceContextImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.compute.predicates.RunScriptRunning; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; @@ -110,6 +113,13 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule { VAppStatus.UNRESOLVED, NodeState.PENDING).build(); } + @Provides + protected TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU); + } + @Override protected void configure() { super.configure(); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index f62af447c9..979ea4729f 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -1,7 +1,6 @@ package org.jclouds.vcloud.compute; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; import static org.testng.Assert.assertEquals; import java.util.Map.Entry; @@ -11,8 +10,6 @@ import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.rest.RestContext; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.VCloudAsyncClient; @@ -36,11 +33,6 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { service = "vcloud"; } - @Override - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(UBUNTU).smallest().build(); - } - @Override protected JschSshClientModule getSshModule() { return new JschSshClientModule(); diff --git a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java index 072b11d30b..96262f5777 100755 --- a/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java +++ b/vcloud/hostingdotcom/src/main/java/org/jclouds/vcloud/hostingdotcom/compute/config/HostingDotComVCloudComputeServiceContextModule.java @@ -18,10 +18,21 @@ */ package org.jclouds.vcloud.hostingdotcom.compute.config; +import static org.jclouds.compute.domain.OsFamily.CENTOS; + +import java.util.Map; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.Size; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.internal.TemplateBuilderImpl; +import org.jclouds.domain.Location; import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient; +import com.google.inject.Provides; + /** * Configures the {@link HostingDotComVCloudComputeServiceContext}; requires * {@link HostingDotComVCloudComputeClient} bound. @@ -37,4 +48,12 @@ public class HostingDotComVCloudComputeServiceContextModule extends bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class); } + @Override + @Provides + protected TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS); + } + } diff --git a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java index 0987f81796..97e98d0262 100644 --- a/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java +++ b/vcloud/hostingdotcom/src/test/java/org/jclouds/vcloud/hostingdotcom/compute/HostingDotComVCloudComputeServiceLiveTest.java @@ -19,10 +19,11 @@ package org.jclouds.vcloud.hostingdotcom.compute; -import static org.jclouds.compute.domain.OsFamily.CENTOS; +import static org.testng.Assert.assertEquals; +import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,9 +41,13 @@ public class HostingDotComVCloudComputeServiceLiveTest extends VCloudComputeServ service = "hostingdotcom"; } - @Override - protected Template buildTemplate(TemplateBuilder templateBuilder) { - return templateBuilder.osFamily(CENTOS).smallest().build(); + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS); + assertEquals(defaultTemplate.getLocation().getId(), "188849"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } // Takes too long diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java index 3f72b513c2..e7c89bbc7b 100755 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -18,6 +18,8 @@ */ package org.jclouds.vcloud.terremark.compute.config; +import static org.jclouds.compute.domain.OsFamily.JEOS; + import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -34,9 +36,12 @@ import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Size; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.ImageImpl; import org.jclouds.compute.domain.internal.SizeImpl; +import org.jclouds.compute.internal.TemplateBuilderImpl; import org.jclouds.concurrent.ConcurrentUtils; +import org.jclouds.domain.Location; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.compute.VCloudComputeClient; @@ -57,6 +62,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Configures the {@link TerremarkVCloudComputeServiceContext}; requires @@ -72,6 +78,14 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer bind(VCloudComputeClient.class).to(TerremarkVCloudComputeClient.class); } + @Override + @Provides + protected TemplateBuilder provideTemplate(Map locations, + Map images, Map sizes, + Location defaultLocation) { + return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(JEOS); + } + private static final ComputeOptionsToSize sizeConverter = new ComputeOptionsToSize(); private static class ComputeOptionsToSize implements Function { diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java index dbde7c856d..0f4ea91877 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudComputeServiceLiveTest.java @@ -19,7 +19,12 @@ package org.jclouds.vcloud.terremark.compute; +import static org.testng.Assert.assertEquals; + import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.Template; import org.jclouds.rest.RestContext; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient; @@ -41,6 +46,15 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL service = "terremark"; } + @Test + public void testTemplateBuilder() { + Template defaultTemplate = client.templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64); + assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.JEOS); + assertEquals(defaultTemplate.getLocation().getId(), "32"); + assertEquals(defaultTemplate.getSize().getCores(), 1.0d); + } + public void testAssignability() throws Exception { @SuppressWarnings("unused") RestContext tmContext = new ComputeServiceContextFactory()