mirror of https://github.com/apache/jclouds.git
Issue 221: made sure default template always works on all cloud providers
This commit is contained in:
parent
4ee4bb8764
commit
190c768d02
|
@ -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.options.DescribeImagesOptions.Builder.ownedBy;
|
||||||
import static org.jclouds.aws.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
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.net.URI;
|
||||||
import java.util.Map;
|
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.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
|
@ -102,6 +105,13 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
|
bind(DestroyNodeStrategy.class).to(EC2DestroyNodeStrategy.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU);
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class EC2ListNodesStrategy implements ListNodesStrategy {
|
public static class EC2ListNodesStrategy implements ListNodesStrategy {
|
||||||
private final InstanceClient client;
|
private final InstanceClient client;
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.aws.ec2.compute;
|
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.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.compute.domain.Architecture;
|
import org.jclouds.compute.domain.Architecture;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -40,13 +40,18 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
service = "ec2";
|
service = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
@Test
|
||||||
return templateBuilder.osFamily(UBUNTU).smallest().architecture(Architecture.X86_32).build();
|
public void testTemplateBuilderCanUseImageId() {
|
||||||
|
client.templateBuilder().imageId("ami-d57f93bc").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilder() {
|
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
|
@Override
|
||||||
|
|
|
@ -9,18 +9,28 @@ Here's an example of getting some compute configuration from rackspace:
|
||||||
(use 'org.jclouds.compute)
|
(use 'org.jclouds.compute)
|
||||||
(use 'clojure.contrib.pprint)
|
(use 'clojure.contrib.pprint)
|
||||||
|
|
||||||
|
(def provider \"cloudservers\")
|
||||||
(def user \"username\")
|
(def user \"username\")
|
||||||
(def password \"password\")
|
(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]
|
(with-compute-service [compute]
|
||||||
(pprint (locations))
|
(pprint (locations))
|
||||||
(pprint (images))
|
(pprint (images))
|
||||||
(pprint (nodes))
|
(pprint (nodes))
|
||||||
(pprint (sizes)))
|
(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."
|
See http://code.google.com/p/jclouds for details."
|
||||||
(:use org.jclouds.core
|
(:use org.jclouds.core
|
||||||
clojure.contrib.duck-streams
|
clojure.contrib.duck-streams
|
||||||
|
@ -107,8 +117,6 @@ See http://code.google.com/p/jclouds for details."
|
||||||
([] (default-template *compute*))
|
([] (default-template *compute*))
|
||||||
([#^ComputeService compute]
|
([#^ComputeService compute]
|
||||||
(.. compute (templateBuilder)
|
(.. compute (templateBuilder)
|
||||||
(osFamily OsFamily/UBUNTU)
|
|
||||||
smallest
|
|
||||||
(options
|
(options
|
||||||
(org.jclouds.compute.options.TemplateOptions$Builder/authorizePublicKey
|
(org.jclouds.compute.options.TemplateOptions$Builder/authorizePublicKey
|
||||||
(slurp (str (. System getProperty "user.home") "/.ssh/id_rsa.pub"))))
|
(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
|
(defn run-nodes
|
||||||
"Create the specified number of nodes using the default or specified
|
"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]
|
([tag count]
|
||||||
(run-nodes tag count (default-template *compute*) *compute*))
|
(run-nodes tag count (default-template *compute*) *compute*))
|
||||||
([tag count compute-or-template]
|
([tag count compute-or-template]
|
||||||
|
@ -129,7 +156,17 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(.runNodesWithTag compute tag count template))))
|
(.runNodesWithTag compute tag count template))))
|
||||||
|
|
||||||
(defn run-node
|
(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]
|
([tag]
|
||||||
(run-nodes tag 1 (default-template *compute*) *compute*))
|
(run-nodes tag 1 (default-template *compute*) *compute*))
|
||||||
([tag compute-or-template]
|
([tag compute-or-template]
|
||||||
|
@ -298,7 +335,12 @@ See http://code.google.com/p/jclouds for details."
|
||||||
(f builder value)
|
(f builder value)
|
||||||
(println "Unknown option" option))))
|
(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))]
|
(let [builder (.. compute (templateBuilder))]
|
||||||
(loop [option option
|
(loop [option option
|
||||||
remaining options]
|
remaining options]
|
||||||
|
|
|
@ -1,24 +1,19 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* you may not use this file except in compliance with the License.
|
||||||
* distributed with this work for additional information
|
* You may obtain a copy of the License at
|
||||||
* 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
|
|
||||||
*
|
*
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute.domain;
|
package org.jclouds.compute.domain;
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ComparisonChain;
|
import com.google.common.collect.ComparisonChain;
|
||||||
|
@ -63,21 +64,35 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
private final Map<String, ? extends Image> images;
|
private final Map<String, ? extends Image> images;
|
||||||
private final Map<String, ? extends Size> sizes;
|
private final Map<String, ? extends Size> sizes;
|
||||||
private final Map<String, ? extends Location> locations;
|
private final Map<String, ? extends Location> locations;
|
||||||
private OsFamily os;
|
@VisibleForTesting
|
||||||
private Architecture arch;
|
OsFamily os;
|
||||||
private String locationId;
|
@VisibleForTesting
|
||||||
private String imageId;
|
Architecture arch;
|
||||||
private String sizeId;
|
@VisibleForTesting
|
||||||
private String osDescription;
|
String locationId;
|
||||||
private String imageVersion;
|
@VisibleForTesting
|
||||||
private String imageName;
|
String imageId;
|
||||||
private String imageDescription;
|
@VisibleForTesting
|
||||||
|
String sizeId;
|
||||||
|
@VisibleForTesting
|
||||||
|
String osDescription;
|
||||||
|
@VisibleForTesting
|
||||||
|
String imageVersion;
|
||||||
|
|
||||||
private double minCores;
|
@VisibleForTesting
|
||||||
private int minRam;
|
String imageName;
|
||||||
|
@VisibleForTesting
|
||||||
|
String imageDescription;
|
||||||
|
|
||||||
private boolean biggest;
|
@VisibleForTesting
|
||||||
private boolean fastest;
|
double minCores;
|
||||||
|
@VisibleForTesting
|
||||||
|
int minRam;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean biggest;
|
||||||
|
@VisibleForTesting
|
||||||
|
boolean fastest;
|
||||||
|
|
||||||
private TemplateOptions options = TemplateOptions.NONE;
|
private TemplateOptions options = TemplateOptions.NONE;
|
||||||
|
|
||||||
|
@ -411,6 +426,12 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
@Override
|
@Override
|
||||||
public TemplateBuilder imageId(String imageId) {
|
public TemplateBuilder imageId(String imageId) {
|
||||||
this.imageId = imageId;
|
this.imageId = imageId;
|
||||||
|
this.imageName = null;
|
||||||
|
this.imageDescription = null;
|
||||||
|
this.imageVersion = null;
|
||||||
|
this.arch = null;
|
||||||
|
this.os = null;
|
||||||
|
this.osDescription = null;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
@ -139,7 +140,8 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
template = buildTemplate(client.templateBuilder());
|
template = buildTemplate(client.templateBuilder());
|
||||||
|
|
||||||
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(
|
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());
|
nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 2, template).values());
|
||||||
assertEquals(nodes.size(), 2);
|
assertEquals(nodes.size(), 2);
|
||||||
checkNodes();
|
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() {
|
protected String buildScript(OsFamily osFamily) {
|
||||||
return new StringBuilder()//
|
switch (osFamily) {
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
case JEOS:
|
||||||
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
|
case UBUNTU:
|
||||||
.append(
|
return new StringBuilder()//
|
||||||
"sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")//
|
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
|
||||||
.append("apt-get update\n")//
|
.append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")//
|
||||||
.append("apt-get install -f -y --force-yes openjdk-6-jdk\n")//
|
.append(
|
||||||
.append("wget -qO/usr/bin/runurl run.alestic.com/runurl\n")//
|
"sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")//
|
||||||
.append("chmod 755 /usr/bin/runurl\n")//
|
.append("apt-get update\n")//
|
||||||
.toString();
|
.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")
|
@Test(enabled = true, dependsOnMethods = "testCreate")
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* 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.<String, Location> of(),
|
||||||
|
ImmutableMap.<String, Image> of(), ImmutableMap.<String, Size> 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");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.gogrid.config;
|
package org.jclouds.gogrid.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
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.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
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.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
@ -106,6 +109,14 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
bind(DestroyNodeStrategy.class).to(GoGridDestroyNodeStrategy.class);
|
bind(DestroyNodeStrategy.class).to(GoGridDestroyNodeStrategy.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS)
|
||||||
|
.imageNameMatches(".*w/ None.*");
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("NAMING_CONVENTION")
|
@Named("NAMING_CONVENTION")
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -140,7 +151,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
int numOfRetries = 20;
|
int numOfRetries = 20;
|
||||||
// lock-free consumption of a shared resource: IP address pool
|
// lock-free consumption of a shared resource: IP address pool
|
||||||
while (notStarted) { // TODO: replace with Predicate-based thread collision avoidance for
|
while (notStarted) { // TODO: replace with Predicate-based thread collision avoidance for
|
||||||
// simplicity
|
// simplicity
|
||||||
Set<Ip> availableIps = client.getIpServices().getIpList(
|
Set<Ip> availableIps = client.getIpServices().getIpList(
|
||||||
new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC));
|
new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC));
|
||||||
if (availableIps.size() == 0)
|
if (availableIps.size() == 0)
|
||||||
|
@ -316,6 +327,7 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
private final Function<String, InetAddress> stringIpToInetAddress;
|
private final Function<String, InetAddress> stringIpToInetAddress;
|
||||||
private final GoGridClient client;
|
private final GoGridClient client;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Inject
|
@Inject
|
||||||
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState,
|
ServerToNodeMetadata(Map<String, NodeState> serverStateToNodeState,
|
||||||
Function<String, InetAddress> stringIpToInetAddress, GoGridClient client) {
|
Function<String, InetAddress> stringIpToInetAddress, GoGridClient client) {
|
||||||
|
@ -337,7 +349,6 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null,
|
return new NodeMetadataImpl(from.getId() + "", from.getName(), locationId, null,
|
||||||
ImmutableMap.<String, String> of(), tag, state, ipSet, ImmutableList
|
ImmutableMap.<String, String> of(), tag, state, ipSet, ImmutableList
|
||||||
.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
.<InetAddress> of(), ImmutableMap.<String, String> of(), creds);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,8 +458,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
holder.logger.debug("<< didn't match os(%s)", matchedOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(), null,
|
images.add(new ImageImpl(from.getId() + "", from.getFriendlyName(), location.getId(),
|
||||||
ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
null, ImmutableMap.<String, String> of(), from.getDescription(), version, os,
|
||||||
osDescription, arch));
|
osDescription, arch));
|
||||||
}
|
}
|
||||||
holder.logger.debug("<< images(%d)", images.size());
|
holder.logger.debug("<< images(%d)", images.size());
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid;
|
package org.jclouds.gogrid;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
@ -27,11 +26,12 @@ import java.util.Map;
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -52,24 +52,13 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
service = "gogrid";
|
service = "gogrid";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Test
|
||||||
public String buildScript() {
|
public void testTemplateBuilder() {
|
||||||
return new StringBuilder()
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
.append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")
|
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
||||||
.append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.CENTOS);
|
||||||
.append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n")
|
assertEquals(defaultTemplate.getLocation().getId(), "SANFRANCISCO");
|
||||||
.append(
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
"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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudservers.compute.config;
|
package org.jclouds.rackspace.cloudservers.compute.config;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
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.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
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.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.BaseComputeService;
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
@ -104,6 +108,13 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
bind(DestroyNodeStrategy.class).to(CloudServersDestroyNodeStrategy.class);
|
bind(DestroyNodeStrategy.class).to(CloudServersDestroyNodeStrategy.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("NAMING_CONVENTION")
|
@Named("NAMING_CONVENTION")
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.rackspace.cloudservers.compute;
|
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.BaseComputeServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
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.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient;
|
import org.jclouds.rackspace.cloudservers.CloudServersAsyncClient;
|
||||||
import org.jclouds.rackspace.cloudservers.CloudServersClient;
|
import org.jclouds.rackspace.cloudservers.CloudServersClient;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
@ -47,8 +48,13 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
|
||||||
service = "cloudservers";
|
service = "cloudservers";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
@Test
|
||||||
return templateBuilder.osFamily(UBUNTU).osDescriptionMatches(".*9.10.*").smallest().build();
|
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
|
@Override
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.rimuhosting.miro.compute.config;
|
package org.jclouds.rimuhosting.miro.compute.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
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.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
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.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
@ -108,6 +111,14 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
bind(DestroyNodeStrategy.class).to(RimuHostingDestroyNodeStrategy.class);
|
bind(DestroyNodeStrategy.class).to(RimuHostingDestroyNodeStrategy.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).sizeId("MIRO1B")
|
||||||
|
.osFamily(UBUNTU);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("NAMING_CONVENTION")
|
@Named("NAMING_CONVENTION")
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.google.gson.annotations.SerializedName;
|
||||||
public class Image implements Comparable<Image> {
|
public class Image implements Comparable<Image> {
|
||||||
@SerializedName("distro_code")
|
@SerializedName("distro_code")
|
||||||
private String id;
|
private String id;
|
||||||
@SerializedName("distro_desciption")
|
@SerializedName("distro_description")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,11 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.compute;
|
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.BaseComputeServiceLiveTest;
|
||||||
|
import org.jclouds.compute.domain.Architecture;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Template;
|
import org.jclouds.compute.domain.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -39,8 +40,14 @@ public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTes
|
||||||
tag = "rimuhosting.jclouds";
|
tag = "rimuhosting.jclouds";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
@Test
|
||||||
return templateBuilder.osFamily(UBUNTU).sizeId("MIRO1B").build();
|
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
|
@Override
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class BlueLockVCloudComputeServiceContextModule extends VCloudComputeServ
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
bind(VCloudComputeClient.class).to(BlueLockVCloudComputeClient.class);
|
bind(VCloudComputeClient.class).to(BlueLockVCloudComputeClient.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.Architecture;
|
||||||
import org.jclouds.compute.domain.Image;
|
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.http.HttpResponseException;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
|
@ -56,24 +59,33 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
|
||||||
// TODO verify parsing works
|
// TODO verify parsing works
|
||||||
}
|
}
|
||||||
|
|
||||||
// // https://forums.bluelock.com/showthread.php?p=353#post353
|
@Test
|
||||||
// @Override
|
public void testTemplateBuilder() {
|
||||||
// @Test(enabled = false)
|
Template defaultTemplate = client.templateBuilder().build();
|
||||||
// public void testCreate() throws Exception {
|
assertEquals(defaultTemplate.getImage().getArchitecture(), Architecture.X86_64);
|
||||||
// super.testCreate();
|
assertEquals(defaultTemplate.getImage().getOsFamily(), OsFamily.UBUNTU);
|
||||||
// }
|
assertEquals(defaultTemplate.getLocation().getId(), "133");
|
||||||
//
|
assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
|
||||||
// @Override
|
}
|
||||||
// @Test(enabled = false)
|
|
||||||
// public void testGet() throws Exception {
|
// // https://forums.bluelock.com/showthread.php?p=353#post353
|
||||||
// super.testGet();
|
// @Override
|
||||||
// }
|
// @Test(enabled = false)
|
||||||
//
|
// public void testCreate() throws Exception {
|
||||||
// @Override
|
// super.testCreate();
|
||||||
// @Test(enabled = false)
|
// }
|
||||||
// public void testReboot() throws Exception {
|
//
|
||||||
// super.testReboot();
|
// @Override
|
||||||
// }
|
// @Test(enabled = false)
|
||||||
|
// public void testGet() throws Exception {
|
||||||
|
// super.testGet();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// @Test(enabled = false)
|
||||||
|
// public void testReboot() throws Exception {
|
||||||
|
// super.testReboot();
|
||||||
|
// }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExample() throws Exception {
|
public void testExample() throws Exception {
|
||||||
|
|
|
@ -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.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
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.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
import org.jclouds.compute.domain.Size;
|
||||||
import org.jclouds.compute.domain.Template;
|
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.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
import org.jclouds.compute.domain.internal.NodeMetadataImpl;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.compute.predicates.RunScriptRunning;
|
import org.jclouds.compute.predicates.RunScriptRunning;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
|
||||||
|
@ -110,6 +113,13 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
VAppStatus.UNRESOLVED, NodeState.PENDING).build();
|
VAppStatus.UNRESOLVED, NodeState.PENDING).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package org.jclouds.vcloud.compute;
|
package org.jclouds.vcloud.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
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.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
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.rest.RestContext;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
|
@ -36,11 +33,6 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
service = "vcloud";
|
service = "vcloud";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
|
||||||
return templateBuilder.osFamily(UBUNTU).smallest().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JschSshClientModule getSshModule() {
|
protected JschSshClientModule getSshModule() {
|
||||||
return new JschSshClientModule();
|
return new JschSshClientModule();
|
||||||
|
|
|
@ -18,10 +18,21 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.hostingdotcom.compute.config;
|
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.VCloudComputeClient;
|
||||||
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
||||||
import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient;
|
import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeClient;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link HostingDotComVCloudComputeServiceContext}; requires
|
* Configures the {@link HostingDotComVCloudComputeServiceContext}; requires
|
||||||
* {@link HostingDotComVCloudComputeClient} bound.
|
* {@link HostingDotComVCloudComputeClient} bound.
|
||||||
|
@ -37,4 +48,12 @@ public class HostingDotComVCloudComputeServiceContextModule extends
|
||||||
bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class);
|
bind(VCloudComputeClient.class).to(HostingDotComVCloudComputeClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Provides
|
||||||
|
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,11 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.hostingdotcom.compute;
|
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.Template;
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -40,9 +41,13 @@ public class HostingDotComVCloudComputeServiceLiveTest extends VCloudComputeServ
|
||||||
service = "hostingdotcom";
|
service = "hostingdotcom";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Test
|
||||||
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
public void testTemplateBuilder() {
|
||||||
return templateBuilder.osFamily(CENTOS).smallest().build();
|
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
|
// Takes too long
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark.compute.config;
|
package org.jclouds.vcloud.terremark.compute.config;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.domain.OsFamily.JEOS;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
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.Image;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
import org.jclouds.compute.domain.Size;
|
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.ImageImpl;
|
||||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.concurrent.ConcurrentUtils;
|
import org.jclouds.concurrent.ConcurrentUtils;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
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.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link TerremarkVCloudComputeServiceContext}; requires
|
* Configures the {@link TerremarkVCloudComputeServiceContext}; requires
|
||||||
|
@ -72,6 +78,14 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
bind(VCloudComputeClient.class).to(TerremarkVCloudComputeClient.class);
|
bind(VCloudComputeClient.class).to(TerremarkVCloudComputeClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Provides
|
||||||
|
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
||||||
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
|
Location defaultLocation) {
|
||||||
|
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(JEOS);
|
||||||
|
}
|
||||||
|
|
||||||
private static final ComputeOptionsToSize sizeConverter = new ComputeOptionsToSize();
|
private static final ComputeOptionsToSize sizeConverter = new ComputeOptionsToSize();
|
||||||
|
|
||||||
private static class ComputeOptionsToSize implements Function<ComputeOptions, Size> {
|
private static class ComputeOptionsToSize implements Function<ComputeOptions, Size> {
|
||||||
|
|
|
@ -19,7 +19,12 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.compute;
|
package org.jclouds.vcloud.terremark.compute;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
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.rest.RestContext;
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
||||||
|
@ -41,6 +46,15 @@ public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceL
|
||||||
service = "terremark";
|
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 {
|
public void testAssignability() throws Exception {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory()
|
RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory()
|
||||||
|
|
Loading…
Reference in New Issue