mirror of https://github.com/apache/jclouds.git
fixed templateBuilder logger and also fixed copyright headers
This commit is contained in:
parent
d08b359956
commit
dedd8f8270
|
@ -107,11 +107,8 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.architecture(Architecture.X86_32).osFamily(UBUNTU);
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).architecture(
|
|
||||||
Architecture.X86_32).osFamily(UBUNTU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
@ -68,10 +68,9 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
Template simpleTemplate = client.templateBuilder().smallest().build();
|
Template simpleTemplate = client.templateBuilder().smallest().build();
|
||||||
client.runNodesWithTag("ec2", 1, simpleTemplate);
|
client.runNodesWithTag("ec2", 1, simpleTemplate);
|
||||||
Map<String, ? extends NodeMetadata> map = client.getNodesWithTag("ec2");
|
Map<String, ? extends NodeMetadata> map = client.getNodesWithTag("ec2");
|
||||||
NodeMetadata node = map.values().iterator().next();
|
map.values().iterator().next();
|
||||||
Credentials creds = new Credentials("ubuntu", keyPair.get("public"));
|
Credentials creds = new Credentials("ubuntu", keyPair.get("public"));
|
||||||
client.runScriptOnNodesWithTag("ec2", creds,
|
client.runScriptOnNodesWithTag("ec2", creds, "mkdir ~/ahha; sleep 3".getBytes());
|
||||||
"mkdir ~/ahha; sleep 3".getBytes());
|
|
||||||
client.destroyNodesWithTag("ec2");
|
client.destroyNodesWithTag("ec2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,8 @@ public class EC2ComputeServiceTest {
|
||||||
return new TemplateBuilderImpl(ImmutableMap.of("us-east-1", location), ImmutableMap.of(
|
return new TemplateBuilderImpl(ImmutableMap.of("us-east-1", location), ImmutableMap.of(
|
||||||
"ami-image", image), Maps.uniqueIndex(ImmutableSet.of(EC2Size.C1_MEDIUM,
|
"ami-image", image), Maps.uniqueIndex(ImmutableSet.of(EC2Size.C1_MEDIUM,
|
||||||
EC2Size.C1_XLARGE, EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE,
|
EC2Size.C1_XLARGE, EC2Size.M1_LARGE, EC2Size.M1_SMALL, EC2Size.M1_XLARGE,
|
||||||
EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE), indexer()), location);
|
EC2Size.M2_XLARGE, EC2Size.M2_2XLARGE, EC2Size.M2_4XLARGE), indexer()), location) {
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Function<ComputeMetadata, String> indexer() {
|
Function<ComputeMetadata, String> indexer() {
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.blobstore
|
(ns org.jclouds.blobstore
|
||||||
"A clojure binding for the jclouds BlobStore.
|
"A clojure binding for the jclouds BlobStore.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.blobstore-test
|
(ns org.jclouds.blobstore-test
|
||||||
(:use [org.jclouds.blobstore] :reload-all)
|
(:use [org.jclouds.blobstore] :reload-all)
|
||||||
(:use [clojure.test])
|
(:use [clojure.test])
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.compute
|
(ns org.jclouds.compute
|
||||||
"A clojure binding to the jclouds ComputeService.
|
"A clojure binding to the jclouds ComputeService.
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,15 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.compute;
|
package org.jclouds.compute;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import org.jclouds.compute.config.ResolvesImages;
|
import org.jclouds.compute.config.ResolvesImages;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.rest.RestContextBuilder;
|
import org.jclouds.rest.RestContextBuilder;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
@ -80,7 +79,6 @@ public abstract class ComputeServiceContextBuilder<A, S> extends RestContextBuil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedDeclaration"})
|
|
||||||
protected void addImageResolutionModule() {
|
protected void addImageResolutionModule() {
|
||||||
// do nothing;
|
// do nothing;
|
||||||
// this is to be overridden when needed
|
// this is to be overridden when needed
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
import org.jclouds.compute.strategy.RunNodesAndAddToSetStrategy;
|
||||||
import org.jclouds.compute.util.ComputeUtils;
|
import org.jclouds.compute.util.ComputeUtils;
|
||||||
|
import org.jclouds.compute.util.ComputeUtils.SshCallable;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -334,44 +335,51 @@ public class BaseComputeService implements ComputeService {
|
||||||
/**
|
/**
|
||||||
* Run the script on all nodes with the specific tag.
|
* Run the script on all nodes with the specific tag.
|
||||||
*
|
*
|
||||||
* @param tag tag to look up the nodes
|
* @param tag
|
||||||
* @param credentials nullable credentials to use (same for all nodes).
|
* tag to look up the nodes
|
||||||
* @param runScript script to run in byte format. If the script is a string, use
|
* @param credentials
|
||||||
|
* nullable credentials to use (same for all nodes).
|
||||||
|
* @param runScript
|
||||||
|
* script to run in byte format. If the script is a string, use
|
||||||
* {@link String#getBytes()} to retrieve the bytes
|
* {@link String#getBytes()} to retrieve the bytes
|
||||||
* @param options nullable options to how to run the script
|
* @param options
|
||||||
|
* nullable options to how to run the script
|
||||||
* @return map with node identifiers and corresponding responses
|
* @return map with node identifiers and corresponding responses
|
||||||
*/
|
*/
|
||||||
public Map<String, ExecResponse> runScriptOnNodesWithTag(String tag, @Nullable Credentials credentials,
|
public Map<String, ExecResponse> runScriptOnNodesWithTag(String tag,
|
||||||
byte[] runScript, @Nullable RunScriptOptions options) {
|
@Nullable Credentials credentials, byte[] runScript, @Nullable RunScriptOptions options) {
|
||||||
checkNotEmpty(tag, "Tag must be provided");
|
checkNotEmpty(tag, "Tag must be provided");
|
||||||
checkNotNull(runScript,
|
checkNotNull(runScript,
|
||||||
"The script (represented by bytes array - use \"script\".getBytes() must be provided");
|
"The script (represented by bytes array - use \"script\".getBytes() must be provided");
|
||||||
if(options == null) options = RunScriptOptions.NONE;
|
if (options == null)
|
||||||
|
options = RunScriptOptions.NONE;
|
||||||
|
|
||||||
Map<String, ? extends NodeMetadata> nodes = getNodesWithTag(tag);
|
Map<String, ? extends NodeMetadata> nodes = getNodesWithTag(tag);
|
||||||
Map<String, ExecResponse> responses = Maps.newHashMap();
|
Map<String, ExecResponse> responses = Maps.newHashMap();
|
||||||
|
|
||||||
for(NodeMetadata node : nodes.values()) {
|
for (NodeMetadata node : nodes.values()) {
|
||||||
if(NodeState.RUNNING != node.getState()) continue; //make sure the node is active
|
if (NodeState.RUNNING != node.getState())
|
||||||
|
continue; // make sure the node is active
|
||||||
|
|
||||||
if(options.isOverrideCredentials()) {
|
if (options.isOverrideCredentials()) {
|
||||||
//override the credentials with provided to this method
|
// override the credentials with provided to this method
|
||||||
checkNotNull(credentials, "If the credentials need to be overridden, they can't be null");
|
checkNotNull(credentials,
|
||||||
|
"If the credentials need to be overridden, they can't be null");
|
||||||
node = ComputeUtils.installNewCredentials(node, credentials);
|
node = ComputeUtils.installNewCredentials(node, credentials);
|
||||||
} else {
|
} else {
|
||||||
//don't override
|
// don't override
|
||||||
checkNotNull(node.getCredentials(), "If the default credentials need to be used, they can't be null");
|
checkNotNull(node.getCredentials(),
|
||||||
|
"If the default credentials need to be used, they can't be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo: execute script as root if required
|
// todo: execute script as root if required
|
||||||
|
|
||||||
ComputeUtils.SshCallable<?> callable = utils.runScriptOnNode(node, "computeserv.sh", runScript);
|
ComputeUtils.SshCallable<?> callable = utils.runScriptOnNode(node, "computeserv.sh",
|
||||||
|
runScript);
|
||||||
|
|
||||||
Map<ComputeUtils.SshCallable<?>, ?> scriptRunResults = utils.runCallablesOnNode(node,
|
Map<ComputeUtils.SshCallable<?>, ?> scriptRunResults = utils.runCallablesOnNode(node, Sets
|
||||||
Sets.newHashSet(callable),
|
.<SshCallable<?>> newHashSet(callable), null);
|
||||||
null);
|
responses.put(node.getId(), (ExecResponse) scriptRunResults.get(callable));
|
||||||
responses.put(node.getId(),
|
|
||||||
(ExecResponse) scriptRunResults.get(callable));
|
|
||||||
}
|
}
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
private TemplateOptions options = TemplateOptions.NONE;
|
private TemplateOptions options = TemplateOptions.NONE;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TemplateBuilderImpl(Map<String, ? extends Location> locations,
|
protected TemplateBuilderImpl(Map<String, ? extends Location> locations,
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
||||||
Location defaultLocation) {
|
Location defaultLocation) {
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
|
|
|
@ -130,8 +130,8 @@ public class ComputeUtils {
|
||||||
return new RunScriptOnNode(runScriptNotRunning, node, scriptName, script);
|
return new RunScriptOnNode(runScriptNotRunning, node, scriptName, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<SshCallable<?>, ?> runCallablesOnNode(NodeMetadata node, Iterable<? extends SshCallable<?>> parallel,
|
public Map<SshCallable<?>, ?> runCallablesOnNode(NodeMetadata node,
|
||||||
@Nullable SshCallable<?> last) {
|
Iterable<? extends SshCallable<?>> parallel, @Nullable SshCallable<?> last) {
|
||||||
checkState(this.sshFactory != null, "runScript requested, but no SshModule configured");
|
checkState(this.sshFactory != null, "runScript requested, but no SshModule configured");
|
||||||
|
|
||||||
InetSocketAddress socket = new InetSocketAddress(Iterables.get(node.getPublicAddresses(), 0),
|
InetSocketAddress socket = new InetSocketAddress(Iterables.get(node.getPublicAddresses(), 0),
|
||||||
|
@ -183,17 +183,19 @@ public class ComputeUtils {
|
||||||
ssh.disconnect();
|
ssh.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException(String.format("Couldn't connect to node %s and run the script", node.getId()));
|
throw new RuntimeException(String.format("Couldn't connect to node %s and run the script",
|
||||||
|
node.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T> Map<SshCallable<?>, T> transform(Map<SshCallable<?>, ListenableFuture<?>> responses) {
|
public <T> Map<SshCallable<?>, T> transform(Map<SshCallable<?>, ListenableFuture<?>> responses) {
|
||||||
Map<SshCallable<?>, T> actualResponses = Maps.newHashMap();
|
Map<SshCallable<?>, T> actualResponses = Maps.newHashMap();
|
||||||
for(Map.Entry<SshCallable<?>, ListenableFuture<?>> entry : responses.entrySet()) {
|
for (Map.Entry<SshCallable<?>, ListenableFuture<?>> entry : responses.entrySet()) {
|
||||||
try {
|
try {
|
||||||
actualResponses.put(entry.getKey(), (T) entry.getValue().get());
|
actualResponses.put(entry.getKey(), (T) entry.getValue().get());
|
||||||
} catch(InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
} catch(ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,13 +324,13 @@ public class ComputeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given the instances of {@link NodeMetadata} (immutable)
|
* Given the instances of {@link NodeMetadata} (immutable) and {@link Credentials} (immutable),
|
||||||
* and {@link Credentials} (immutable), returns a new instance of {@link NodeMetadata}
|
* returns a new instance of {@link NodeMetadata} that has new credentials
|
||||||
* that has new credentials
|
|
||||||
*/
|
*/
|
||||||
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
public static NodeMetadata installNewCredentials(NodeMetadata node, Credentials newCredentials) {
|
||||||
return new NodeMetadataImpl(node.getId(), node.getName(), node.getLocationId(), node.getUri(),
|
return new NodeMetadataImpl(node.getId(), node.getName(), node.getLocationId(),
|
||||||
node.getUserMetadata(), node.getTag(), node.getState(), node. getPublicAddresses(),
|
node.getUri(), node.getUserMetadata(), node.getTag(), node.getState(), node
|
||||||
node.getPrivateAddresses(), node.getExtra(), newCredentials);
|
.getPublicAddresses(), node.getPrivateAddresses(), node.getExtra(),
|
||||||
|
newCredentials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.compute-test
|
(ns org.jclouds.compute-test
|
||||||
(:use [org.jclouds.compute] :reload-all)
|
(:use [org.jclouds.compute] :reload-all)
|
||||||
(:use clojure.test))
|
(:use clojure.test))
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.core
|
(ns org.jclouds.core
|
||||||
"Core functionality used across blobstore and compute."
|
"Core functionality used across blobstore and compute."
|
||||||
(:use clojure.contrib.logging
|
(:use clojure.contrib.logging
|
||||||
|
@ -8,6 +26,7 @@
|
||||||
|
|
||||||
(def module-lookup
|
(def module-lookup
|
||||||
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
{:log4j 'org.jclouds.logging.log4j.config.Log4JLoggingModule
|
||||||
|
:lognull 'org.jclouds.logging.config.NullLoggingModule
|
||||||
:ssh 'org.jclouds.ssh.jsch.config.JschSshClientModule
|
:ssh 'org.jclouds.ssh.jsch.config.JschSshClientModule
|
||||||
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule
|
:enterprise 'org.jclouds.enterprise.config.EnterpriseConfigurationModule
|
||||||
:httpnio 'org.jclouds.http.httpnio.config.NioTransformingHttpCommandExecutorServiceModule
|
:httpnio 'org.jclouds.http.httpnio.config.NioTransformingHttpCommandExecutorServiceModule
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
;;
|
||||||
|
;; Copyright (C) 2010 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.
|
||||||
|
;; ====================================================================
|
||||||
|
;;
|
||||||
|
|
||||||
(ns org.jclouds.core-test
|
(ns org.jclouds.core-test
|
||||||
(:use [org.jclouds.core] :reload-all)
|
(:use [org.jclouds.core] :reload-all)
|
||||||
(:use clojure.test))
|
(:use clojure.test))
|
||||||
|
|
|
@ -106,11 +106,8 @@ public class GoGridComputeServiceContextModule extends GoGridContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.osFamily(CENTOS).imageNameMatches(".*w/ None.*");
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS)
|
|
||||||
.imageNameMatches(".*w/ None.*");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -109,10 +109,8 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.osFamily(UBUNTU);
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -112,11 +112,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.sizeId("MIRO1B").osFamily(UBUNTU);
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).sizeId("MIRO1B")
|
|
||||||
.osFamily(UBUNTU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -50,16 +50,19 @@ public class ParseDestroyResponseFromJsonResponse extends ParseJson<List<String>
|
||||||
return cancel_messages;
|
return cancel_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setCancelMessages(List<String> cancel_messages) {
|
public void setCancelMessages(List<String> cancel_messages) {
|
||||||
this.cancel_messages = cancel_messages;
|
this.cancel_messages = cancel_messages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> apply(InputStream stream) {
|
protected List<String> apply(InputStream stream) {
|
||||||
Type setType = new TypeToken<Map<String, DestroyResponse>>() {
|
Type setType = new TypeToken<Map<String, DestroyResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, DestroyResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, DestroyResponse> responseMap = gson.fromJson(new InputStreamReader(stream,
|
||||||
|
"UTF-8"), setType);
|
||||||
return responseMap.values().iterator().next().getCancelMessages();
|
return responseMap.values().iterator().next().getCancelMessages();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -18,14 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.functions;
|
package org.jclouds.rimuhosting.miro.functions;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.jclouds.http.functions.ParseJson;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.Image;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
@ -33,10 +25,19 @@ import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseJson;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.Image;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ParseImagesFromJsonResponse extends ParseJson<SortedSet<Image>> {
|
public class ParseImagesFromJsonResponse extends ParseJson<SortedSet<Image>> {
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ public class ParseImagesFromJsonResponse extends ParseJson<SortedSet<Image>> {
|
||||||
return distro_infos;
|
return distro_infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setDistroInfos(SortedSet<Image> distro_infos) {
|
public void setDistroInfos(SortedSet<Image> distro_infos) {
|
||||||
this.distro_infos = distro_infos;
|
this.distro_infos = distro_infos;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +63,8 @@ public class ParseImagesFromJsonResponse extends ParseJson<SortedSet<Image>> {
|
||||||
Type setType = new TypeToken<Map<String, DistroResponse>>() {
|
Type setType = new TypeToken<Map<String, DistroResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, DistroResponse> t = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, DistroResponse> t = gson.fromJson(new InputStreamReader(stream, "UTF-8"),
|
||||||
|
setType);
|
||||||
return t.values().iterator().next().getDistroInfos();
|
return t.values().iterator().next().getDistroInfos();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -18,24 +18,25 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.functions;
|
package org.jclouds.rimuhosting.miro.functions;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.jclouds.http.functions.ParseJson;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseJson;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ParseInstanceFromJsonResponse extends ParseJson<Server> {
|
public class ParseInstanceFromJsonResponse extends ParseJson<Server> {
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -45,20 +46,24 @@ public class ParseInstanceFromJsonResponse extends ParseJson<Server> {
|
||||||
|
|
||||||
private static class OrderResponse extends RimuHostingResponse {
|
private static class OrderResponse extends RimuHostingResponse {
|
||||||
private Server about_order;
|
private Server about_order;
|
||||||
|
|
||||||
public Server getAboutOrder() {
|
public Server getAboutOrder() {
|
||||||
return about_order;
|
return about_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setAboutOrder(Server about_orders) {
|
public void setAboutOrder(Server about_orders) {
|
||||||
this.about_order = about_orders;
|
this.about_order = about_orders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Server apply(InputStream stream) {
|
protected Server apply(InputStream stream) {
|
||||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream,
|
||||||
|
"UTF-8"), setType);
|
||||||
return responseMap.values().iterator().next().getAboutOrder();
|
return responseMap.values().iterator().next().getAboutOrder();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -18,20 +18,22 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.functions;
|
package org.jclouds.rimuhosting.miro.functions;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.jclouds.http.functions.ParseJson;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.ServerInfo;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseJson;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.ServerInfo;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
@ -49,16 +51,19 @@ public class ParseInstanceInfoFromJsonResponse extends ParseJson<ServerInfo> {
|
||||||
return running_vps_info;
|
return running_vps_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setInstanceInfo(ServerInfo running_vps_info) {
|
public void setInstanceInfo(ServerInfo running_vps_info) {
|
||||||
this.running_vps_info = running_vps_info;
|
this.running_vps_info = running_vps_info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ServerInfo apply(InputStream stream) {
|
protected ServerInfo apply(InputStream stream) {
|
||||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream,
|
||||||
|
"UTF-8"), setType);
|
||||||
return responseMap.values().iterator().next().getInstanceInfo();
|
return responseMap.values().iterator().next().getInstanceInfo();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -18,14 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.functions;
|
package org.jclouds.rimuhosting.miro.functions;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.jclouds.http.functions.ParseJson;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
@ -33,6 +25,16 @@ import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseJson;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.Server;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
@ -45,20 +47,24 @@ public class ParseInstancesFromJsonResponse extends ParseJson<SortedSet<Server>>
|
||||||
|
|
||||||
private static class OrderResponse extends RimuHostingResponse {
|
private static class OrderResponse extends RimuHostingResponse {
|
||||||
private SortedSet<Server> about_orders;
|
private SortedSet<Server> about_orders;
|
||||||
|
|
||||||
public SortedSet<Server> getAboutOrders() {
|
public SortedSet<Server> getAboutOrders() {
|
||||||
return about_orders;
|
return about_orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setAboutOrders(SortedSet<Server> about_orders) {
|
public void setAboutOrders(SortedSet<Server> about_orders) {
|
||||||
this.about_orders = about_orders;
|
this.about_orders = about_orders;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SortedSet<Server> apply(InputStream stream) {
|
protected SortedSet<Server> apply(InputStream stream) {
|
||||||
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
Type setType = new TypeToken<Map<String, OrderResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, OrderResponse> responseMap = gson.fromJson(new InputStreamReader(stream,
|
||||||
|
"UTF-8"), setType);
|
||||||
return responseMap.values().iterator().next().getAboutOrders();
|
return responseMap.values().iterator().next().getAboutOrders();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -18,14 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.functions;
|
package org.jclouds.rimuhosting.miro.functions;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.jclouds.http.functions.ParseJson;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
@ -33,6 +25,16 @@ import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseJson;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.PricingPlan;
|
||||||
|
import org.jclouds.rimuhosting.miro.domain.internal.RimuHostingResponse;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
|
@ -50,16 +52,19 @@ public class ParsePricingPlansFromJsonResponse extends ParseJson<SortedSet<Prici
|
||||||
return pricing_plan_infos;
|
return pricing_plan_infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setPricingPlanInfos(SortedSet<PricingPlan> pricing_plan_infos) {
|
public void setPricingPlanInfos(SortedSet<PricingPlan> pricing_plan_infos) {
|
||||||
this.pricing_plan_infos = pricing_plan_infos;
|
this.pricing_plan_infos = pricing_plan_infos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SortedSet<PricingPlan> apply(InputStream stream) {
|
protected SortedSet<PricingPlan> apply(InputStream stream) {
|
||||||
Type setType = new TypeToken<Map<String, PlansResponse>>() {
|
Type setType = new TypeToken<Map<String, PlansResponse>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
try {
|
try {
|
||||||
Map<String, PlansResponse> responseMap = gson.fromJson(new InputStreamReader(stream, "UTF-8"), setType);
|
Map<String, PlansResponse> responseMap = gson.fromJson(new InputStreamReader(stream,
|
||||||
|
"UTF-8"), setType);
|
||||||
return responseMap.values().iterator().next().getPricingPlanInfos();
|
return responseMap.values().iterator().next().getPricingPlanInfos();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.rimuhosting.miro;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ivan Meredith
|
|
||||||
*/
|
|
||||||
public class RimuHostingComputeClient {
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
private final Predicate<InetSocketAddress> socketTester;
|
|
||||||
private final RimuHostingClient rhClient;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public RimuHostingComputeClient(RimuHostingClient rhClient, Factory sshFactory,
|
|
||||||
Predicate<InetSocketAddress> socketTester) {
|
|
||||||
this.rhClient = rhClient;
|
|
||||||
this.sshFactory = sshFactory;
|
|
||||||
this.socketTester = socketTester;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Factory sshFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public Long start(String name, String planId, String imageId) {
|
|
||||||
logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId);
|
|
||||||
NewServerResponse serverRespone = rhClient.createServer(name, imageId, planId);
|
|
||||||
logger.debug(">> VPS id(%d) started and running.", serverRespone.getServer().getId());
|
|
||||||
return serverRespone.getServer().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void reboot(Long id) {
|
|
||||||
Server server = rhClient.getServer(id);
|
|
||||||
logger.debug(">> rebooting VPS(%d)", server.getId());
|
|
||||||
rhClient.restartServer(id);
|
|
||||||
logger.debug("<< on VPS(%d)", server.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy(Long id) {
|
|
||||||
Server server = rhClient.getServer(id);
|
|
||||||
logger.debug(">> destroy VPS(%d)", server.getId());
|
|
||||||
rhClient.destroyServer(id);
|
|
||||||
logger.debug(">> destroyed VPS");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* 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.rimuhosting.miro;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.predicates.AddressReachable;
|
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
|
||||||
import org.jclouds.rimuhosting.miro.domain.Server;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests behavior of {@code TerremarkVCloudClient}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "live", sequential = true, testName = "rimuhosting.RimuHostingComputeClientLiveTest")
|
|
||||||
public class RimuHostingComputeClientLiveTest {
|
|
||||||
RimuHostingComputeClient client;
|
|
||||||
RimuHostingClient rhClient;
|
|
||||||
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private InetAddress publicIp;
|
|
||||||
private Predicate<InetAddress> addressTester;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
|
||||||
IOException {
|
|
||||||
String imageId = "lenny";
|
|
||||||
String serverName = "test.compute.jclouds.org";
|
|
||||||
String planId = "MIRO1B";
|
|
||||||
|
|
||||||
id = client.start(serverName, planId, imageId);
|
|
||||||
Server server = rhClient.getServer(id);
|
|
||||||
assertEquals(imageId, server.getImageId());
|
|
||||||
assertEquals(serverName, server.getName());
|
|
||||||
assertEquals(new Integer(160), server.getInstanceParameters().getRam());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
|
||||||
if (id != null)
|
|
||||||
client.destroy(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
public void setupClient() {
|
|
||||||
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
|
||||||
Injector injector = new RimuHostingContextBuilder(new RimuHostingPropertiesBuilder(key)
|
|
||||||
.relaxSSLHostname(true).build()).withModules(new Log4JLoggingModule(),
|
|
||||||
new JschSshClientModule(), new AbstractModule() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
private Predicate<InetAddress> addressTester(AddressReachable reachable) {
|
|
||||||
return new RetryablePredicate<InetAddress>(reachable, 60, 5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).buildInjector();
|
|
||||||
client = injector.getInstance(RimuHostingComputeClient.class);
|
|
||||||
rhClient = injector.getInstance(RimuHostingClient.class);
|
|
||||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -114,10 +114,8 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
protected TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.osFamily(UBUNTU);
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(UBUNTU);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,13 +20,8 @@ package org.jclouds.vcloud.hostingdotcom.compute.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
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.domain.TemplateBuilder;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
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;
|
||||||
|
@ -47,10 +42,8 @@ public class HostingDotComVCloudComputeServiceContextModule extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
protected TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.osFamily(CENTOS);
|
||||||
Location defaultLocation) {
|
|
||||||
return new TemplateBuilderImpl(locations, images, sizes, defaultLocation).osFamily(CENTOS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ import org.jclouds.compute.domain.internal.SizeImpl;
|
||||||
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
import org.jclouds.compute.internal.TemplateBuilderImpl;
|
||||||
import org.jclouds.concurrent.ConcurrentUtils;
|
import org.jclouds.concurrent.ConcurrentUtils;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
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;
|
||||||
|
@ -79,10 +78,8 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TemplateBuilder provideTemplate(Map<String, ? extends Location> locations,
|
protected TemplateBuilder provideTemplate(TemplateBuilderImpl template) {
|
||||||
Map<String, ? extends Image> images, Map<String, ? extends Size> sizes,
|
return template.osFamily(JEOS);
|
||||||
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();
|
||||||
|
|
Loading…
Reference in New Issue