mirror of https://github.com/apache/jclouds.git
updates to fix elastichosts and cloudsigma support
This commit is contained in:
parent
ade9fa6119
commit
89e7fd6092
|
@ -39,6 +39,7 @@ import org.jclouds.elasticstack.domain.DriveInfo;
|
||||||
import org.jclouds.elasticstack.domain.ImageConversionType;
|
import org.jclouds.elasticstack.domain.ImageConversionType;
|
||||||
import org.jclouds.elasticstack.domain.Server;
|
import org.jclouds.elasticstack.domain.Server;
|
||||||
import org.jclouds.elasticstack.domain.ServerInfo;
|
import org.jclouds.elasticstack.domain.ServerInfo;
|
||||||
|
import org.jclouds.elasticstack.domain.ServerStatus;
|
||||||
import org.jclouds.elasticstack.domain.WellKnownImage;
|
import org.jclouds.elasticstack.domain.WellKnownImage;
|
||||||
import org.jclouds.elasticstack.reference.ElasticStackConstants;
|
import org.jclouds.elasticstack.reference.ElasticStackConstants;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
|
@ -106,12 +107,13 @@ public class ElasticStackComputeServiceAdapter implements
|
||||||
client.destroyDrive(drive.getUuid());
|
client.destroyDrive(drive.getUuid());
|
||||||
throw new IllegalStateException("could not image drive in time!");
|
throw new IllegalStateException("could not image drive in time!");
|
||||||
}
|
}
|
||||||
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
|
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()).cpu(
|
||||||
.cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())).build();
|
(int) (template.getHardware().getProcessors().get(0).getSpeed())).build();
|
||||||
|
|
||||||
ServerInfo from = client.createAndStartServer(toCreate);
|
ServerInfo from = client.createAndStartServer(toCreate);
|
||||||
// store the credentials so that later functions can use them
|
// store the credentials so that later functions can use them
|
||||||
credentialStore.put(from.getUuid() + "", new Credentials("toor", from.getVnc().getPassword()));
|
credentialStore.put(from.getUuid() + "", new Credentials(template.getImage().getDefaultCredentials().identity,
|
||||||
|
from.getVnc().getPassword()));
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +137,8 @@ public class ElasticStackComputeServiceAdapter implements
|
||||||
return "sizeLessThanOrEqual(" + size + ")";
|
return "sizeLessThanOrEqual(" + size + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu)))
|
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu))).volumes(
|
||||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl(size, true, true))).build());
|
ImmutableList.<Volume> of(new VolumeImpl(size, true, true))).build());
|
||||||
}
|
}
|
||||||
return hardware.build();
|
return hardware.build();
|
||||||
}
|
}
|
||||||
|
@ -182,6 +184,8 @@ public class ElasticStackComputeServiceAdapter implements
|
||||||
public void destroyNode(String id) {
|
public void destroyNode(String id) {
|
||||||
ServerInfo server = getNode(id);
|
ServerInfo server = getNode(id);
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
|
if (server.getStatus() != ServerStatus.STOPPED)
|
||||||
|
client.stopServer(id);
|
||||||
client.destroyServer(id);
|
client.destroyServer(id);
|
||||||
for (Device dev : server.getDevices().values())
|
for (Device dev : server.getDevices().values())
|
||||||
client.destroyDrive(dev.getDriveUuid());
|
client.destroyDrive(dev.getDriveUuid());
|
||||||
|
|
|
@ -123,9 +123,8 @@ public class ElasticStackComputeServiceContextModule
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
protected Map<String, WellKnownImage> provideImages(Json json, @Provider String providerName) throws IOException {
|
protected Map<String, WellKnownImage> provideImages(Json json, @Provider String providerName) throws IOException {
|
||||||
List<WellKnownImage> wellKnowns = json.fromJson(
|
List<WellKnownImage> wellKnowns = json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/"+providerName+"/preinstalled_images.json")),
|
"/" + providerName + "/preinstalled_images.json")), new TypeLiteral<List<WellKnownImage>>() {
|
||||||
new TypeLiteral<List<WellKnownImage>>() {
|
|
||||||
}.getType());
|
}.getType());
|
||||||
return Maps.uniqueIndex(wellKnowns, new Function<WellKnownImage, String>() {
|
return Maps.uniqueIndex(wellKnowns, new Function<WellKnownImage, String>() {
|
||||||
|
|
||||||
|
|
|
@ -53,18 +53,13 @@ public class WellKnownImageToImage implements Function<DriveInfo, Image> {
|
||||||
@Override
|
@Override
|
||||||
public Image apply(DriveInfo drive) {
|
public Image apply(DriveInfo drive) {
|
||||||
WellKnownImage input = preinstalledImages.get(drive.getUuid());
|
WellKnownImage input = preinstalledImages.get(drive.getUuid());
|
||||||
return new ImageBuilder()
|
return new ImageBuilder().ids(drive.getUuid()).userMetadata(
|
||||||
.ids(drive.getUuid())
|
|
||||||
.userMetadata(
|
|
||||||
ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata())
|
ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata())
|
||||||
.put("size", input.getSize() + "").build())
|
.put("size", input.getSize() + "").build()).defaultCredentials(
|
||||||
.defaultCredentials(new Credentials("toor", null))
|
new Credentials(input.getLoginUser(), null)).location(locationSupplier.get()).name(
|
||||||
.location(locationSupplier.get())
|
input.getDescription()).description(drive.getName()).operatingSystem(
|
||||||
.name(input.getDescription())
|
new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion()).name(
|
||||||
.description(drive.getName())
|
input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version(
|
||||||
.operatingSystem(
|
"").build();
|
||||||
new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion())
|
|
||||||
.name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version("")
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,7 @@ import com.google.common.base.Objects;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class WellKnownImage {
|
public class WellKnownImage {
|
||||||
|
private String loginUser = "toor";
|
||||||
private String uuid;
|
private String uuid;
|
||||||
private String description;
|
private String description;
|
||||||
private OsFamily osFamily;
|
private OsFamily osFamily;
|
||||||
|
@ -66,9 +67,13 @@ public class WellKnownImage {
|
||||||
return is64bit;
|
return is64bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLoginUser() {
|
||||||
|
return loginUser;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(uuid, description, osFamily, osVersion, size, is64bit);
|
return Objects.hashCode(uuid, description, osFamily, osVersion, size, is64bit, loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,7 +86,8 @@ public class WellKnownImage {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Objects.toStringHelper(this).add("uuid", uuid).add("description", description).add("osFamily", osFamily)
|
return Objects.toStringHelper(this).add("uuid", uuid).add("description", description).add("osFamily", osFamily)
|
||||||
.add("osVersion", osVersion).add("size", size).add("is64bit", is64bit).toString();
|
.add("osVersion", osVersion).add("size", size).add("is64bit", is64bit).add("loginUser", loginUser)
|
||||||
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -45,11 +45,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Functio
|
||||||
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
|
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
|
||||||
if (!"".equals(keyValueLine)) {
|
if (!"".equals(keyValueLine)) {
|
||||||
int firstIndex = keyValueLine.indexOf(' ');
|
int firstIndex = keyValueLine.indexOf(' ');
|
||||||
|
if (firstIndex != -1) {
|
||||||
String key = keyValueLine.substring(0, firstIndex);
|
String key = keyValueLine.substring(0, firstIndex);
|
||||||
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
|
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
|
||||||
map.put(key, value);
|
map.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (map.size() != 0)
|
if (map.size() != 0)
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,14 @@ package org.jclouds.elasticstack.functions;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.elasticstack.domain.ClaimType;
|
import org.jclouds.elasticstack.domain.ClaimType;
|
||||||
import org.jclouds.elasticstack.domain.DriveInfo;
|
import org.jclouds.elasticstack.domain.DriveInfo;
|
||||||
import org.jclouds.elasticstack.domain.DriveMetrics;
|
import org.jclouds.elasticstack.domain.DriveMetrics;
|
||||||
import org.jclouds.elasticstack.domain.DriveStatus;
|
import org.jclouds.elasticstack.domain.DriveStatus;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -39,6 +41,10 @@ import com.google.common.collect.Maps;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
|
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DriveInfo apply(Map<String, String> from) {
|
public DriveInfo apply(Map<String, String> from) {
|
||||||
if (from.size() == 0)
|
if (from.size() == 0)
|
||||||
|
@ -67,7 +73,12 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
|
||||||
metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue());
|
metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue());
|
||||||
}
|
}
|
||||||
builder.userMetadata(metadata);
|
builder.userMetadata(metadata);
|
||||||
|
try {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.trace("entry missing data: %s; %s", e.getMessage(), from);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DriveMetrics buildMetrics(Map<String, String> from) {
|
protected DriveMetrics buildMetrics(Map<String, String> from) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ public class ElasticStackClientLiveTest {
|
||||||
protected ElasticStackClient client;
|
protected ElasticStackClient client;
|
||||||
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> context;
|
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> context;
|
||||||
protected Predicate<IPSocket> socketTester;
|
protected Predicate<IPSocket> socketTester;
|
||||||
|
protected String bootDrive = "38df0986-4d85-4b76-b502-3878ffc80161";
|
||||||
|
|
||||||
protected String provider = "elasticstack";
|
protected String provider = "elasticstack";
|
||||||
protected String identity;
|
protected String identity;
|
||||||
|
@ -198,12 +199,10 @@ public class ElasticStackClientLiveTest {
|
||||||
@Test(dependsOnMethods = "testCreateDrive")
|
@Test(dependsOnMethods = "testCreateDrive")
|
||||||
public void testSetDriveData() throws Exception {
|
public void testSetDriveData() throws Exception {
|
||||||
|
|
||||||
DriveInfo drive2 = client.setDriveData(
|
DriveInfo drive2 = client.setDriveData(drive.getUuid(), new DriveData.Builder().claimType(ClaimType.SHARED).name(
|
||||||
drive.getUuid(),
|
"rediculous").readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")).tags(
|
||||||
new DriveData.Builder().claimType(ClaimType.SHARED).name("rediculous")
|
ImmutableSet.of("networking", "security", "gateway")).userMetadata(ImmutableMap.of("foo", "bar"))
|
||||||
.readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))
|
.build());
|
||||||
.tags(ImmutableSet.of("networking", "security", "gateway"))
|
|
||||||
.userMetadata(ImmutableMap.of("foo", "bar")).build());
|
|
||||||
|
|
||||||
assertNotNull(drive2.getUuid(), drive.getUuid());
|
assertNotNull(drive2.getUuid(), drive.getUuid());
|
||||||
assertEquals(drive2.getName(), "rediculous");
|
assertEquals(drive2.getName(), "rediculous");
|
||||||
|
@ -244,8 +243,8 @@ public class ElasticStackClientLiveTest {
|
||||||
assertNotNull(server.getUser());
|
assertNotNull(server.getUser());
|
||||||
assertEquals(server.getName(), prefix);
|
assertEquals(server.getName(), prefix);
|
||||||
assertEquals(server.isPersistent(), true);
|
assertEquals(server.isPersistent(), true);
|
||||||
assertEquals(server.getDevices(),
|
assertEquals(server.getDevices(), ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid())
|
||||||
ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid()).build()));
|
.build()));
|
||||||
assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0"));
|
assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0"));
|
||||||
assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp());
|
assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp());
|
||||||
assertEquals(server.getNics().get(0).getModel(), Model.E1000);
|
assertEquals(server.getNics().get(0).getModel(), Model.E1000);
|
||||||
|
@ -254,10 +253,12 @@ public class ElasticStackClientLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndStartServer")
|
@Test(dependsOnMethods = "testCreateAndStartServer")
|
||||||
public void testConnectivity() throws Exception {
|
public void testConnectivity() throws Exception {
|
||||||
Logger.getAnonymousLogger().info("awaiting vnc");
|
IPSocket vncsocket = new IPSocket(server.getVnc().getIp(), 5900);
|
||||||
assert socketTester.apply(new IPSocket(server.getVnc().getIp(), 5900)) : server;
|
Logger.getAnonymousLogger().info("awaiting vnc: " + vncsocket);
|
||||||
Logger.getAnonymousLogger().info("awaiting ssh");
|
assert socketTester.apply(vncsocket) : server;
|
||||||
assert socketTester.apply(new IPSocket(server.getNics().get(0).getDhcp(), 22)) : server;
|
IPSocket sshsocket = new IPSocket(server.getNics().get(0).getDhcp(), 22);
|
||||||
|
Logger.getAnonymousLogger().info("awaiting ssh: " + sshsocket);
|
||||||
|
assert socketTester.apply(sshsocket) : server;
|
||||||
doConnectViaSsh(server, getSshCredentials(server));
|
doConnectViaSsh(server, getSshCredentials(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,11 +285,9 @@ public class ElasticStackClientLiveTest {
|
||||||
client.stopServer(server.getUuid());
|
client.stopServer(server.getUuid());
|
||||||
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
|
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
|
||||||
|
|
||||||
ServerInfo server2 = client.setServerConfiguration(
|
ServerInfo server2 = client.setServerConfiguration(server.getUuid(), Server.Builder.fromServer(server).name(
|
||||||
server.getUuid(),
|
"rediculous").tags(ImmutableSet.of("networking", "security", "gateway")).userMetadata(
|
||||||
Server.Builder.fromServer(server).name("rediculous")
|
ImmutableMap.of("foo", "bar")).build());
|
||||||
.tags(ImmutableSet.of("networking", "security", "gateway"))
|
|
||||||
.userMetadata(ImmutableMap.of("foo", "bar")).build());
|
|
||||||
|
|
||||||
assertNotNull(server2.getUuid(), server.getUuid());
|
assertNotNull(server2.getUuid(), server.getUuid());
|
||||||
assertEquals(server2.getName(), "rediculous");
|
assertEquals(server2.getName(), "rediculous");
|
||||||
|
@ -314,8 +313,8 @@ public class ElasticStackClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException {
|
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException {
|
||||||
SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class)
|
SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class).create(
|
||||||
.create(new IPSocket(server.getVnc().getIp(), 22), creds);
|
new IPSocket(server.getVnc().getIp(), 22), creds);
|
||||||
try {
|
try {
|
||||||
ssh.connect();
|
ssh.connect();
|
||||||
ExecResponse hello = ssh.exec("echo hello");
|
ExecResponse hello = ssh.exec("echo hello");
|
||||||
|
@ -379,7 +378,7 @@ public class ElasticStackClientLiveTest {
|
||||||
|
|
||||||
protected void prepareDrive() {
|
protected void prepareDrive() {
|
||||||
System.err.println("before prepare" + client.getDriveInfo(drive.getUuid()));
|
System.err.println("before prepare" + client.getDriveInfo(drive.getUuid()));
|
||||||
client.imageDrive("38df0986-4d85-4b76-b502-3878ffc80161", drive.getUuid(), ImageConversionType.GUNZIP);
|
client.imageDrive(bootDrive, drive.getUuid(), ImageConversionType.GUNZIP);
|
||||||
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
|
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
|
||||||
System.err.println("after prepare" + client.getDriveInfo(drive.getUuid()));
|
System.err.println("after prepare" + client.getDriveInfo(drive.getUuid()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,4 +36,8 @@ public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTe
|
||||||
return new JschSshClientModule();
|
return new JschSshClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testOptionToNotBlock() {
|
||||||
|
// start call is blocking anyway.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.Future;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
import javax.net.ssl.SSLException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
|
@ -47,6 +48,7 @@ import org.jclouds.http.IOExceptionRetryHandler;
|
||||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.util.Throwables2;
|
import org.jclouds.util.Throwables2;
|
||||||
|
|
||||||
import com.google.common.io.NullOutputStream;
|
import com.google.common.io.NullOutputStream;
|
||||||
|
@ -125,7 +127,8 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
||||||
public Future<HttpResponse> submit(HttpCommand command) {
|
public Future<HttpResponse> submit(HttpCommand command) {
|
||||||
HttpRequest request = command.getCurrentRequest();
|
HttpRequest request = command.getCurrentRequest();
|
||||||
checkRequestHasContentLengthOrChunkedEncoding(request,
|
checkRequestHasContentLengthOrChunkedEncoding(request,
|
||||||
"if the request has a payload, it must be set to chunked encoding or specify a content length: " + request);
|
"if the request has a payload, it must be set to chunked encoding or specify a content length: "
|
||||||
|
+ request);
|
||||||
return ioWorkerExecutor.submit(new HttpResponseCallable(command));
|
return ioWorkerExecutor.submit(new HttpResponseCallable(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,13 +172,18 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
IOException ioe = Throwables2.getFirstThrowableOfType(e, IOException.class);
|
IOException ioe = Throwables2.getFirstThrowableOfType(e, IOException.class);
|
||||||
if (ioe != null && ioRetryHandler.shouldRetryRequest(command, ioe)) {
|
if (ioe != null) {
|
||||||
|
if (ioe instanceof SSLException) {
|
||||||
|
command.setException(new AuthorizationException(e.getMessage() + " connecting to "
|
||||||
|
+ command.getCurrentRequest().getRequestLine(), e));
|
||||||
|
break;
|
||||||
|
} else if (ioRetryHandler.shouldRetryRequest(command, ioe)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
command.setException(new HttpResponseException(e.getMessage() + " connecting to "
|
command.setException(new HttpResponseException(e.getMessage() + " connecting to "
|
||||||
+ command.getCurrentRequest().getRequestLine(), command, null, e));
|
+ command.getCurrentRequest().getRequestLine(), command, null, e));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
cleanup(nativeRequest);
|
cleanup(nativeRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,11 @@ public class PreinstalledDiskToImage implements Function<DriveInfo, Image> {
|
||||||
String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
|
String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
|
||||||
OperatingSystemBuilder builder = new OperatingSystemBuilder();
|
OperatingSystemBuilder builder = new OperatingSystemBuilder();
|
||||||
OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
|
OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
|
||||||
builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version)
|
builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version).family(
|
||||||
.family(parsed.family);
|
parsed.family);
|
||||||
return new ImageBuilder().ids(drive.getUuid())
|
return new ImageBuilder().ids(drive.getUuid()).adminPassword("cloudsigma").userMetadata(
|
||||||
.userMetadata(ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + ""))
|
ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + "")).defaultCredentials(
|
||||||
.defaultCredentials(new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get())
|
new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get()).name(drive.getName())
|
||||||
.name(drive.getName()).description(description).operatingSystem(builder.build()).version("").build();
|
.description(description).operatingSystem(builder.build()).version("").build();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -99,6 +99,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
Image image = findImageForId.apply(imageId);
|
Image image = findImageForId.apply(imageId);
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
builder.operatingSystem(image.getOperatingSystem());
|
builder.operatingSystem(image.getOperatingSystem());
|
||||||
|
builder.adminPassword(image.getAdminPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.hardware(new HardwareBuilder().ids(from.getUuid())
|
builder.hardware(new HardwareBuilder().ids(from.getUuid())
|
||||||
|
@ -108,8 +109,6 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
|
||||||
builder.publicAddresses(ImmutableSet.<String> of(from.getVnc().getIp()));
|
builder.publicAddresses(ImmutableSet.<String> of(from.getVnc().getIp()));
|
||||||
builder.privateAddresses(ImmutableSet.<String> of());
|
builder.privateAddresses(ImmutableSet.<String> of());
|
||||||
builder.credentials(credentialStore.get(from.getUuid()));
|
builder.credentials(credentialStore.get(from.getUuid()));
|
||||||
// note sudo password!
|
|
||||||
builder.adminPassword(from.getVnc().getPassword());
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,11 +45,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Functio
|
||||||
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
|
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
|
||||||
if (!"".equals(keyValueLine)) {
|
if (!"".equals(keyValueLine)) {
|
||||||
int firstIndex = keyValueLine.indexOf(' ');
|
int firstIndex = keyValueLine.indexOf(' ');
|
||||||
|
if (firstIndex != -1) {
|
||||||
String key = keyValueLine.substring(0, firstIndex);
|
String key = keyValueLine.substring(0, firstIndex);
|
||||||
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
|
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
|
||||||
map.put(key, value);
|
map.put(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (map.size() != 0)
|
if (map.size() != 0)
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.cloudsigma.domain.ClaimType;
|
import org.jclouds.cloudsigma.domain.ClaimType;
|
||||||
|
@ -30,6 +31,7 @@ import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||||
import org.jclouds.cloudsigma.domain.DriveMetrics;
|
import org.jclouds.cloudsigma.domain.DriveMetrics;
|
||||||
import org.jclouds.cloudsigma.domain.DriveStatus;
|
import org.jclouds.cloudsigma.domain.DriveStatus;
|
||||||
import org.jclouds.cloudsigma.domain.DriveType;
|
import org.jclouds.cloudsigma.domain.DriveType;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -42,6 +44,9 @@ import com.google.common.collect.Maps;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
|
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DriveInfo apply(Map<String, String> from) {
|
public DriveInfo apply(Map<String, String> from) {
|
||||||
if (from.size() == 0)
|
if (from.size() == 0)
|
||||||
|
@ -89,7 +94,12 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
|
||||||
builder.free(new Boolean(from.get("free")));
|
builder.free(new Boolean(from.get("free")));
|
||||||
if (from.containsKey("type"))
|
if (from.containsKey("type"))
|
||||||
builder.type(DriveType.fromValue(from.get("type")));
|
builder.type(DriveType.fromValue(from.get("type")));
|
||||||
|
try {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
logger.trace("entry missing data: %s; %s", e.getMessage(), from);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DriveMetrics buildMetrics(Map<String, String> from) {
|
protected DriveMetrics buildMetrics(Map<String, String> from) {
|
||||||
|
|
|
@ -30,5 +30,6 @@ import org.testng.annotations.Test;
|
||||||
public class ElasticHostsBlueSquareLondonClientLiveTest extends ElasticStackClientLiveTest {
|
public class ElasticHostsBlueSquareLondonClientLiveTest extends ElasticStackClientLiveTest {
|
||||||
public ElasticHostsBlueSquareLondonClientLiveTest() {
|
public ElasticHostsBlueSquareLondonClientLiveTest() {
|
||||||
provider = "elastichosts-lon-b";
|
provider = "elastichosts-lon-b";
|
||||||
|
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,6 @@ import org.testng.annotations.Test;
|
||||||
public class ElasticHostsPeer1LondonClientLiveTest extends ElasticStackClientLiveTest {
|
public class ElasticHostsPeer1LondonClientLiveTest extends ElasticStackClientLiveTest {
|
||||||
public ElasticHostsPeer1LondonClientLiveTest() {
|
public ElasticHostsPeer1LondonClientLiveTest() {
|
||||||
provider = "elastichosts-lon-p";
|
provider = "elastichosts-lon-p";
|
||||||
|
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,6 @@ import org.testng.annotations.Test;
|
||||||
public class ElasticHostsPeer1SanAntonioClientLiveTest extends ElasticStackClientLiveTest {
|
public class ElasticHostsPeer1SanAntonioClientLiveTest extends ElasticStackClientLiveTest {
|
||||||
public ElasticHostsPeer1SanAntonioClientLiveTest() {
|
public ElasticHostsPeer1SanAntonioClientLiveTest() {
|
||||||
provider = "elastichosts-sat-p";
|
provider = "elastichosts-sat-p";
|
||||||
|
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,22 +19,12 @@
|
||||||
|
|
||||||
package org.jclouds.serverlove.config;
|
package org.jclouds.serverlove.config;
|
||||||
|
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.TemplateBuilder;
|
|
||||||
import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule;
|
import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class ServerloveManchesterComputeServiceContextModule extends ElasticStackComputeServiceContextModule {
|
public class ServerloveManchesterComputeServiceContextModule extends ElasticStackComputeServiceContextModule {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
|
|
||||||
return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,42 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"uuid": "38df0986-4d85-4b76-b502-3878ffc80161",
|
"uuid": "679f5f44-0be7-4745-a658-cccd4334c1aa",
|
||||||
"description": "CentOS Linux 5.5",
|
"description": "CentOS Linux 5.5",
|
||||||
"osFamily": "CENTOS",
|
"osFamily": "CENTOS",
|
||||||
"osVersion": "5.5",
|
"osVersion": "5.5",
|
||||||
"size": "3"
|
"size": "3",
|
||||||
|
"loginUser": "root"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "980cf63c-f21e-4382-997b-6541d5809629",
|
"uuid": "5795b68f-ed26-4639-b41d-c93235062b6b",
|
||||||
"description": "Debian Linux 5.0",
|
"description": "Debian Linux 5.0",
|
||||||
"osFamily": "DEBIAN",
|
"osFamily": "DEBIAN",
|
||||||
"osVersion": "5.0",
|
"osVersion": "5.0",
|
||||||
"size": "1"
|
"size": "1",
|
||||||
|
"loginUser": "root"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "aee5589a-88c3-43ef-bb0a-9cab6e64192d",
|
"uuid": "5f2e0e29-2937-42b9-b362-d2d07eddbdeb",
|
||||||
"description": "Ubuntu Linux 10.04",
|
"description": "Ubuntu Linux 10.04",
|
||||||
"osFamily": "UBUNTU",
|
"osFamily": "UBUNTU",
|
||||||
"osVersion": "10.04",
|
"osVersion": "10.04",
|
||||||
"size": "1"
|
"size": "1",
|
||||||
|
"loginUser": "root"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "bf1d943e-2a55-46bb-a8c7-6099e44a3dde",
|
"uuid": "85623ca1-9c2a-4398-a771-9a43c347e86b",
|
||||||
"description": "Ubuntu Linux 8.10: Base system with X",
|
|
||||||
"osFamily": "UBUNTU",
|
|
||||||
"osVersion": "8.10",
|
|
||||||
"size": "3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uuid": "757586d5-f1e9-4d9c-b215-5a391c9a24bf",
|
|
||||||
"description": "Ubuntu Linux 9.04: Base system with X",
|
|
||||||
"osFamily": "UBUNTU",
|
|
||||||
"osVersion": "9.04",
|
|
||||||
"size": "3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uuid": "b9d0eb72-d273-43f1-98e3-0d4b87d372c0",
|
|
||||||
"description": "Windows Web Server 2008",
|
|
||||||
"osFamily": "WINDOWS",
|
|
||||||
"osVersion": "2008",
|
|
||||||
"size": "13"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uuid": "b405b598-4ae4-4ba8-8a2b-a9487d693f34",
|
|
||||||
"description": "Windows Web Server 2008 R2",
|
"description": "Windows Web Server 2008 R2",
|
||||||
"osFamily": "WINDOWS",
|
"osFamily": "WINDOWS",
|
||||||
"osVersion": "2008 R2",
|
"osVersion": "2008 R2",
|
||||||
"size": "13"
|
"size": "13",
|
||||||
|
"loginUser": "Administrator"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927",
|
"uuid": "41993a02-0b22-4e49-bb47-0aa8975217e4",
|
||||||
"description": "Windows Web Server 2008 R2 + SQL Server",
|
|
||||||
"osFamily": "WINDOWS",
|
|
||||||
"osVersion": "2008 R2",
|
|
||||||
"size": "13"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"uuid": "10a88d1c-6575-46e3-8d2c-7744065ea530",
|
|
||||||
"description": "Windows Server 2008 Standard R2",
|
"description": "Windows Server 2008 Standard R2",
|
||||||
"osFamily": "WINDOWS",
|
"osFamily": "WINDOWS",
|
||||||
"osVersion": "2008 R2",
|
"osVersion": "2008 R2",
|
||||||
"size": "13"
|
"size": "13",
|
||||||
},
|
"loginUser": "Administrator"
|
||||||
{
|
|
||||||
"uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf",
|
|
||||||
"description": "Windows Server 2008 Standard R2 + SQL Server",
|
|
||||||
"osFamily": "WINDOWS",
|
|
||||||
"osVersion": "2008 R2",
|
|
||||||
"size": "13"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
package org.jclouds.serverlove;
|
package org.jclouds.serverlove;
|
||||||
|
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.elasticstack.ElasticStackClientLiveTest;
|
import org.jclouds.elasticstack.ElasticStackClientLiveTest;
|
||||||
|
import org.jclouds.elasticstack.domain.Server;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,5 +32,10 @@ import org.testng.annotations.Test;
|
||||||
public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest {
|
public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest {
|
||||||
public ServerloveManchesterClientLiveTest() {
|
public ServerloveManchesterClientLiveTest() {
|
||||||
provider = "serverlove-z1-man";
|
provider = "serverlove-z1-man";
|
||||||
|
bootDrive = "5f2e0e29-2937-42b9-b362-d2d07eddbdeb";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Credentials getSshCredentials(Server server) {
|
||||||
|
return new Credentials("root", server.getVnc().getPassword());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui
|
||||||
public boolean apply(OsFamilyVersion64Bit input) {
|
public boolean apply(OsFamilyVersion64Bit input) {
|
||||||
return ((input.family == OsFamily.RHEL) || //
|
return ((input.family == OsFamily.RHEL) || //
|
||||||
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
|
(input.family == OsFamily.CENTOS && !(input.version.equals("5.5") && input.is64Bit)) || //
|
||||||
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.10") && input.is64Bit)) || //
|
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
|
||||||
(input.family == OsFamily.WINDOWS) //
|
(input.family == OsFamily.WINDOWS && !(input.version.equals("2008 R2") && input.is64Bit)) //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui
|
||||||
public void testTemplateBuilder() {
|
public void testTemplateBuilder() {
|
||||||
Template defaultTemplate = this.context.getComputeService().templateBuilder().build();
|
Template defaultTemplate = this.context.getComputeService().templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10");
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
assertEquals(defaultTemplate.getLocation().getId(), "serverlove-z1-man");
|
assertEquals(defaultTemplate.getLocation().getId(), "serverlove-z1-man");
|
||||||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
||||||
|
|
|
@ -30,5 +30,6 @@ import org.testng.annotations.Test;
|
||||||
public class SkaliCloudMalaysiaClientLiveTest extends ElasticStackClientLiveTest {
|
public class SkaliCloudMalaysiaClientLiveTest extends ElasticStackClientLiveTest {
|
||||||
public SkaliCloudMalaysiaClientLiveTest() {
|
public SkaliCloudMalaysiaClientLiveTest() {
|
||||||
provider = "skalicloud-sdg-my";
|
provider = "skalicloud-sdg-my";
|
||||||
|
bootDrive = "3051699a-a536-4220-aeb5-67f2ec101a09";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue