mirror of https://github.com/apache/jclouds.git
Issue 112, Issue 129, Issue 130: add hosting.com to compute provider and ant tool
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2444 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
9518a67228
commit
f9e5839134
|
@ -1,4 +1,6 @@
|
|||
rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder
|
||||
rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder
|
||||
terremark.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudContextBuilder
|
||||
terremark.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder
|
||||
terremark.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder
|
||||
hostingdotcom.contextbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudContextBuilder
|
||||
hostingdotcom.propertiesbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudPropertiesBuilder
|
|
@ -41,7 +41,7 @@ public class CredentialsTest {
|
|||
assertEquals(creds.account, "account");
|
||||
assertEquals(creds.key, "Base64==");
|
||||
}
|
||||
|
||||
|
||||
public void testAtmos() {
|
||||
Credentials creds = Credentials.parse(URI
|
||||
.create("blobstore://domain%2Fuser:Base64%3D%3D@azureblob/container-hyphen/prefix"));
|
||||
|
@ -49,6 +49,13 @@ public class CredentialsTest {
|
|||
assertEquals(creds.key, "Base64==");
|
||||
}
|
||||
|
||||
public void testHosting() {
|
||||
Credentials creds = Credentials.parse(URI
|
||||
.create("compute://user%40domain:pa%24sword@hostingdotcom"));
|
||||
assertEquals(creds.account, "user@domain");
|
||||
assertEquals(creds.key, "pa$sword");
|
||||
}
|
||||
|
||||
public void testCloudFiles() {
|
||||
Credentials creds = Credentials.parse(URI
|
||||
.create("blobstore://account:h3c@cloudfiles/container-hyphen/prefix"));
|
||||
|
|
|
@ -64,6 +64,12 @@ public class HttpUtilsTest extends PerformanceTest {
|
|||
.create("blobstore://account:Base64==@azureblob/container-hyphen/prefix"));
|
||||
}
|
||||
|
||||
public void testHosting() {
|
||||
URI creds = HttpUtils.createUri("compute://user@domain:pa$sword@hostingdotcom");
|
||||
assertEquals(creds.getUserInfo(), "user@domain:pa$sword");
|
||||
assertEquals(creds, URI.create("compute://user%40domain:pa%24sword@hostingdotcom"));
|
||||
}
|
||||
|
||||
public void testTerremark() {
|
||||
URI creds = HttpUtils.createUri("compute://user@domain:password@terremark");
|
||||
assertEquals(creds.getUserInfo(), "user@domain:password");
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
<artifact:dependencies pathId="jclouds.classpath">
|
||||
<dependency groupId="org.jclouds" artifactId="jclouds-ant-plugin" version="1.0-SNAPSHOT" />
|
||||
<dependency groupId="org.jclouds" artifactId="jclouds-terremark" version="1.0-SNAPSHOT" />
|
||||
<dependency groupId="org.jclouds" artifactId="jclouds-hostingdotcom" version="1.0-SNAPSHOT" />
|
||||
<dependency groupId="org.jclouds" artifactId="jclouds-rimuhosting" version="1.0-SNAPSHOT" />
|
||||
<localRepository refid="local.repository" />
|
||||
<remoteRepository refid="jclouds-snapshot.repository" />
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
|||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextBuilder;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
import org.jclouds.vcloud.config.VCloudContextModule;
|
||||
import org.jclouds.vcloud.config.VCloudDiscoveryRestClientModule;
|
||||
import org.jclouds.vcloud.hostingdotcom.config.HostingDotComVCloudContextModule;
|
||||
import org.jclouds.vcloud.hostingdotcom.config.HostingDotComVCloudRestClientModule;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
@ -70,7 +70,7 @@ public class HostingDotComVCloudContextBuilder extends
|
|||
|
||||
@Override
|
||||
protected void addContextModule(List<Module> modules) {
|
||||
modules.add(new VCloudContextModule());
|
||||
modules.add(new HostingDotComVCloudContextModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.jclouds.vcloud.hostingdotcom;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Creates {@link HostingDotComVCloudContext} instances based on the most commonly requested
|
||||
* arguments.
|
||||
* <p/>
|
||||
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see HostingDotComVCloudContext
|
||||
*/
|
||||
public class HostingDotComVCloudContextFactory {
|
||||
|
||||
public static RestContext<HostingDotComVCloudAsyncClient, HostingDotComVCloudClient> createContext(
|
||||
String username, String password, Module... modules) {
|
||||
return new HostingDotComVCloudContextBuilder(new HostingDotComVCloudPropertiesBuilder(
|
||||
username, password).build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<HostingDotComVCloudAsyncClient, HostingDotComVCloudClient> createContext(
|
||||
Properties props, Module... modules) {
|
||||
return new HostingDotComVCloudContextBuilder(new HostingDotComVCloudPropertiesBuilder(props)
|
||||
.build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
}
|
|
@ -21,25 +21,23 @@
|
|||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.vcloud.hostingdotcom;
|
||||
package org.jclouds.vcloud.hostingdotcom.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.ssh.ExecResponse;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshClient.Factory;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppStatus;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;
|
||||
import org.jclouds.vcloud.hostingdotcom.domain.HostingDotComVApp;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
|
@ -55,34 +53,21 @@ public class HostingDotComVCloudComputeClient {
|
|||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final Predicate<InetSocketAddress> socketTester;
|
||||
private final Predicate<URI> taskTester;
|
||||
private final HostingDotComVCloudClient tmClient;
|
||||
|
||||
@Inject
|
||||
public HostingDotComVCloudComputeClient(HostingDotComVCloudClient tmClient, Factory sshFactory,
|
||||
Predicate<InetSocketAddress> socketTester, Predicate<URI> successTester) {
|
||||
public HostingDotComVCloudComputeClient(HostingDotComVCloudClient tmClient,
|
||||
Predicate<URI> successTester) {
|
||||
this.tmClient = tmClient;
|
||||
this.sshFactory = sshFactory;
|
||||
this.socketTester = socketTester;
|
||||
this.taskTester = successTester;
|
||||
}
|
||||
|
||||
private final Factory sshFactory;
|
||||
|
||||
public enum Image {
|
||||
CENTOS_53, RHEL_53, UMBUNTU_90, UMBUNTU_JEOS
|
||||
}
|
||||
|
||||
private Map<Image, String> imageCatalogIdMap = ImmutableMap.<Image, String> builder().put(
|
||||
Image.CENTOS_53, "3").put(Image.RHEL_53, "8").put(Image.UMBUNTU_90, "10").put(
|
||||
Image.UMBUNTU_JEOS, "11").build();
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
||||
public String start(String name, int minCores, int minMegs, Image image) {
|
||||
public Map<String, String> start(String name, int minCores, int minMegs, Image image) {
|
||||
checkArgument(imageCatalogIdMap.containsKey(image), "image not configured: " + image);
|
||||
String templateId = imageCatalogIdMap.get(image);
|
||||
|
||||
|
@ -91,23 +76,22 @@ public class HostingDotComVCloudComputeClient {
|
|||
HostingDotComVApp vAppResponse = (HostingDotComVApp) tmClient.instantiateVAppTemplate(name,
|
||||
templateId, InstantiateVAppTemplateOptions.Builder.cpuCount(minCores).megabytes(
|
||||
minMegs));
|
||||
this.username = vAppResponse.getUsername();
|
||||
this.password = vAppResponse.getPassword();
|
||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
||||
|
||||
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
||||
VApp vApp = blockUntilVAppStatusOrThrowException(vAppResponse, tmClient
|
||||
.deployVApp(vAppResponse.getId()), "deploy", VAppStatus.ON);// TODO, I'm not sure
|
||||
// this should be on
|
||||
// already
|
||||
// logger.debug("<< deployed vApp(%s)", vApp.getId());
|
||||
//
|
||||
// logger.debug(">> powering vApp(%s)", vApp.getId());
|
||||
// vApp = blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOnVApp(vApp.getId()),
|
||||
// "powerOn", VAppStatus.ON);
|
||||
// this should be on
|
||||
// already
|
||||
// logger.debug("<< deployed vApp(%s)", vApp.getId());
|
||||
//
|
||||
// logger.debug(">> powering vApp(%s)", vApp.getId());
|
||||
// vApp = blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOnVApp(vApp.getId()),
|
||||
// "powerOn", VAppStatus.ON);
|
||||
logger.debug("<< on vApp(%s)", vApp.getId());
|
||||
|
||||
return vApp.getId();
|
||||
return ImmutableMap.<String, String> of("id", vApp.getId(), "username", vAppResponse
|
||||
.getUsername(), "password", vAppResponse.getPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,14 +104,6 @@ public class HostingDotComVCloudComputeClient {
|
|||
return Iterables.getLast(vApp.getNetworkToAddresses().values());
|
||||
}
|
||||
|
||||
public ExecResponse exec(InetAddress address, String command) {
|
||||
InetSocketAddress sshSocket = new InetSocketAddress(address, 22);
|
||||
logger.debug(">> exec ssh://%s@%s/%s", username, sshSocket, command);
|
||||
ExecResponse exec = exec(sshSocket, username, password, command);
|
||||
logger.debug("<< output(%s) error(%s)", exec.getOutput(), exec.getError());
|
||||
return exec;
|
||||
}
|
||||
|
||||
public void reboot(String id) {
|
||||
VApp vApp = tmClient.getVApp(id);
|
||||
logger.debug(">> rebooting vApp(%s)", vApp.getId());
|
||||
|
@ -149,21 +125,6 @@ public class HostingDotComVCloudComputeClient {
|
|||
logger.debug("<< deleted vApp(%s)", vApp.getId());
|
||||
}
|
||||
|
||||
private ExecResponse exec(InetSocketAddress socket, String username, String password,
|
||||
String command) {
|
||||
if (!socketTester.apply(socket)) {
|
||||
throw new SocketNotOpenException(socket);
|
||||
}
|
||||
SshClient connection = sshFactory.create(socket, username, password);
|
||||
try {
|
||||
connection.connect();
|
||||
return connection.exec(command);
|
||||
} finally {
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private VApp blockUntilVAppStatusOrThrowException(VApp vApp, Task deployTask, String taskType,
|
||||
VAppStatus expectedStatus) {
|
||||
if (!taskTester.apply(deployTask.getLocation())) {
|
||||
|
@ -196,23 +157,6 @@ public class HostingDotComVCloudComputeClient {
|
|||
|
||||
}
|
||||
|
||||
public static class SocketNotOpenException extends RuntimeException {
|
||||
|
||||
private final InetSocketAddress socket;
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 251801929573211256L;
|
||||
|
||||
public SocketNotOpenException(InetSocketAddress socket) {
|
||||
super("socket not open: " + socket);
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public InetSocketAddress getSocket() {
|
||||
return socket;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class VAppException extends RuntimeException {
|
||||
|
||||
private final VApp vApp;
|
|
@ -0,0 +1,114 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* 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.vcloud.hostingdotcom.compute;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.domain.CreateServerResponse;
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.LoginType;
|
||||
import org.jclouds.compute.domain.Profile;
|
||||
import org.jclouds.compute.domain.ServerIdentity;
|
||||
import org.jclouds.compute.domain.ServerMetadata;
|
||||
import org.jclouds.compute.domain.internal.CreateServerResponseImpl;
|
||||
import org.jclouds.compute.domain.internal.ServerMetadataImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.domain.NamedResource;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.internal.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class HostingDotComVCloudComputeService implements ComputeService {
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
private final HostingDotComVCloudComputeClient computeClient;
|
||||
private final HostingDotComVCloudClient tmClient;
|
||||
|
||||
@Inject
|
||||
public HostingDotComVCloudComputeService(HostingDotComVCloudClient tmClient,
|
||||
HostingDotComVCloudComputeClient computeClient) {
|
||||
this.tmClient = tmClient;
|
||||
this.computeClient = computeClient;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
||||
Map<String, String> metaMap = computeClient.start(name, 1, 512, image);
|
||||
VApp vApp = tmClient.getVApp(metaMap.get("id"));
|
||||
return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), vApp
|
||||
.getNetworkToAddresses().values(), ImmutableSet.<InetAddress> of(), 22,
|
||||
LoginType.SSH, new Credentials(metaMap.get("username"), metaMap.get("password")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerMetadata getServerMetadata(String id) {
|
||||
VApp vApp = tmClient.getVApp(id);
|
||||
return new ServerMetadataImpl(vApp.getId(), vApp.getName(), vApp.getNetworkToAddresses()
|
||||
.values(), ImmutableSet.<InetAddress> of(), 22, LoginType.SSH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<ServerIdentity> getServerByName(final String name) {
|
||||
return Sets.newTreeSet(Iterables.filter(listServers(), new Predicate<ServerIdentity>() {
|
||||
@Override
|
||||
public boolean apply(ServerIdentity input) {
|
||||
return input.getName().equalsIgnoreCase(name);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<ServerIdentity> listServers() {
|
||||
SortedSet<ServerIdentity> servers = Sets.newTreeSet();
|
||||
for (NamedResource resource : tmClient.getDefaultVDC().getResourceEntities().values()) {
|
||||
if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
|
||||
servers.add(getServerMetadata(resource.getId()));
|
||||
}
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyServer(String id) {
|
||||
computeClient.stop(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.jclouds.vcloud.hostingdotcom.config;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudAsyncClient;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;
|
||||
import org.jclouds.vcloud.hostingdotcom.compute.HostingDotComVCloudComputeService;
|
||||
import org.jclouds.vcloud.reference.VCloudConstants;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class HostingDotComVCloudContextModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ComputeService.class).to(HostingDotComVCloudComputeService.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<HostingDotComVCloudAsyncClient, HostingDotComVCloudClient> provideContext(Closer closer,
|
||||
HostingDotComVCloudAsyncClient asynchApi, HostingDotComVCloudClient defaultApi,
|
||||
@Org URI endPoint, @Named(VCloudConstants.PROPERTY_VCLOUD_USER) String account) {
|
||||
return new RestContextImpl<HostingDotComVCloudAsyncClient, HostingDotComVCloudClient>(closer,
|
||||
asynchApi, defaultApi, endPoint, account);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,12 +23,18 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.hostingdotcom.config;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.internal.SyncProxy;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.predicates.AddressReachable;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestClientFactory;
|
||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||
|
@ -36,7 +42,9 @@ import org.jclouds.vcloud.VCloudClient;
|
|||
import org.jclouds.vcloud.config.VCloudRestClientModule;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudAsyncClient;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;
|
||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +57,26 @@ import com.google.inject.Provides;
|
|||
public class HostingDotComVCloudRestClientModule extends VCloudRestClientModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
protected HostingDotComVCloudAsyncClient provideHostingDotComVCloudAsyncClient(VCloudAsyncClient in) {
|
||||
protected Predicate<InetSocketAddress> socketTester(SocketOpen open) {
|
||||
return new RetryablePredicate<InetSocketAddress>(open, 130, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Predicate<InetAddress> addressTester(AddressReachable reachable) {
|
||||
return new RetryablePredicate<InetAddress>(reachable, 60, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected Predicate<URI> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<URI>(success, 600, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected HostingDotComVCloudAsyncClient provideHostingDotComVCloudAsyncClient(
|
||||
VCloudAsyncClient in) {
|
||||
return (HostingDotComVCloudAsyncClient) in;
|
||||
}
|
||||
|
||||
|
@ -69,7 +96,7 @@ public class HostingDotComVCloudRestClientModule extends VCloudRestClientModule
|
|||
SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(HostingDotComVCloudClient.class, client);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultNetwork(VCloudAsyncClient client) {
|
||||
return URI.create("https://vcloud.safesecureweb.com/network/1990");
|
||||
|
|
|
@ -21,39 +21,33 @@
|
|||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.vcloud.hostingdotcom;
|
||||
package org.jclouds.vcloud.hostingdotcom.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.predicates.AddressReachable;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.jclouds.vcloud.domain.ResourceType;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppStatus;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudComputeClient.Image;
|
||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudClient;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudContextBuilder;
|
||||
import org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudPropertiesBuilder;
|
||||
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;
|
||||
import com.google.inject.internal.ImmutableMap;
|
||||
|
||||
|
@ -101,7 +95,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
|||
int processorCount = 1;
|
||||
int memory = 512;
|
||||
|
||||
id = client.start(serverName, processorCount, memory, toTest);
|
||||
id = client.start(serverName, processorCount, memory, toTest).get("id");
|
||||
Expectation expectation = expectationMap.get(toTest);
|
||||
|
||||
VApp vApp = tmClient.getVApp(id);
|
||||
|
@ -122,16 +116,10 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
|||
assert !addressTester.apply(privateAddress);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
||||
public void testSshLoadBalanceIp() {
|
||||
// assert addressTester.apply(publicIp);
|
||||
client.exec(privateAddress, "uname -a");
|
||||
}
|
||||
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs,
|
||||
int processorCount, int memory, long hardDisk) {
|
||||
// assertEquals(vApp.getName(), serverName);
|
||||
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||
// assertEquals(vApp.getName(), serverName);
|
||||
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)
|
||||
.getVirtualQuantity(), processorCount);
|
||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER)
|
||||
|
@ -156,35 +144,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
|||
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||
Injector injector = new HostingDotComVCloudContextBuilder(
|
||||
new HostingDotComVCloudPropertiesBuilder(account, key).relaxSSLHostname().build())
|
||||
.withModules(new Log4JLoggingModule(), new JschSshClientModule(),
|
||||
new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
private Predicate<InetSocketAddress> socketTester(SocketOpen open) {
|
||||
return new RetryablePredicate<InetSocketAddress>(open, 130, 10,
|
||||
TimeUnit.SECONDS);// make it longer then
|
||||
// default internet
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
private Predicate<InetAddress> addressTester(AddressReachable reachable) {
|
||||
return new RetryablePredicate<InetAddress>(reachable, 60, 5,
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
private Predicate<URI> successTester(TaskSuccess success) {
|
||||
return new RetryablePredicate<URI>(success, 5400, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}).buildInjector();
|
||||
.withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector();
|
||||
client = injector.getInstance(HostingDotComVCloudComputeClient.class);
|
||||
tmClient = injector.getInstance(HostingDotComVCloudClient.class);
|
||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
|
@ -1,6 +1,5 @@
|
|||
package org.jclouds.vcloud.terremark;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -23,19 +22,14 @@ import com.google.inject.Module;
|
|||
*/
|
||||
public class TerremarkVCloudContextFactory {
|
||||
|
||||
public static RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> createContext(String username, String password,
|
||||
Module... modules) {
|
||||
return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(username, password).build())
|
||||
.withModules(modules).buildContext();
|
||||
public static RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> createContext(
|
||||
String username, String password, Module... modules) {
|
||||
return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(username,
|
||||
password).build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> createContext(URI endpoint, String username,
|
||||
String password, Module... modules) {
|
||||
return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(username, password).withEndpoint(
|
||||
endpoint).build()).withModules(modules).buildContext();
|
||||
}
|
||||
|
||||
public static RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> createContext(Properties props, Module... modules) {
|
||||
public static RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> createContext(
|
||||
Properties props, Module... modules) {
|
||||
return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(props).build())
|
||||
.withModules(modules).buildContext();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue