updates to fix elastichosts and cloudsigma support

This commit is contained in:
Adrian Cole 2011-01-23 22:06:47 -08:00
parent ade9fa6119
commit 89e7fd6092
21 changed files with 165 additions and 155 deletions

View File

@ -39,6 +39,7 @@ import org.jclouds.elasticstack.domain.DriveInfo;
import org.jclouds.elasticstack.domain.ImageConversionType;
import org.jclouds.elasticstack.domain.Server;
import org.jclouds.elasticstack.domain.ServerInfo;
import org.jclouds.elasticstack.domain.ServerStatus;
import org.jclouds.elasticstack.domain.WellKnownImage;
import org.jclouds.elasticstack.reference.ElasticStackConstants;
import org.jclouds.location.Provider;
@ -57,7 +58,7 @@ import com.google.common.collect.ImmutableSet.Builder;
*/
@Singleton
public class ElasticStackComputeServiceAdapter implements
ComputeServiceAdapter<ServerInfo, Hardware, DriveInfo, Location> {
ComputeServiceAdapter<ServerInfo, Hardware, DriveInfo, Location> {
private final ElasticStackClient client;
private final ElasticStackAsyncClient aclient;
private final Predicate<DriveInfo> driveNotClaimed;
@ -74,10 +75,10 @@ public class ElasticStackComputeServiceAdapter implements
@Inject
public ElasticStackComputeServiceAdapter(ElasticStackClient client, ElasticStackAsyncClient aclient,
Predicate<DriveInfo> driveNotClaimed, @Provider String providerName, @Provider URI providerURI,
Map<String, WellKnownImage> preinstalledImages, Map<String, DriveInfo> cache,
@Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
Predicate<DriveInfo> driveNotClaimed, @Provider String providerName, @Provider URI providerURI,
Map<String, WellKnownImage> preinstalledImages, Map<String, DriveInfo> cache,
@Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.client = checkNotNull(client, "client");
this.aclient = checkNotNull(aclient, "aclient");
this.driveNotClaimed = checkNotNull(driveNotClaimed, "driveNotClaimed");
@ -91,11 +92,11 @@ public class ElasticStackComputeServiceAdapter implements
@Override
public ServerInfo runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
Map<String, Credentials> credentialStore) {
Map<String, Credentials> credentialStore) {
long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
logger.debug(">> creating boot drive bytes(%d)", bootSize);
DriveInfo drive = client.createDrive(new Drive.Builder().name(template.getImage().getName()).size(bootSize)
.build());
.build());
logger.debug("<< drive(%s)", drive.getUuid());
logger.debug(">> imaging boot drive source(%s)", template.getImage().getId());
@ -106,12 +107,13 @@ public class ElasticStackComputeServiceAdapter implements
client.destroyDrive(drive.getUuid());
throw new IllegalStateException("could not image drive in time!");
}
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
.cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())).build();
Server toCreate = small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam()).cpu(
(int) (template.getHardware().getProcessors().get(0).getSpeed())).build();
ServerInfo from = client.createAndStartServer(toCreate);
// 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;
}
@ -135,8 +137,8 @@ public class ElasticStackComputeServiceAdapter implements
return "sizeLessThanOrEqual(" + size + ")";
}
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu)))
.volumes(ImmutableList.<Volume> of(new VolumeImpl(size, true, true))).build());
}).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu))).volumes(
ImmutableList.<Volume> of(new VolumeImpl(size, true, true))).build());
}
return hardware.build();
}
@ -147,14 +149,14 @@ public class ElasticStackComputeServiceAdapter implements
@Override
public Iterable<DriveInfo> listImages() {
Iterable<DriveInfo> drives = transformParallel(preinstalledImages.keySet(),
new Function<String, Future<DriveInfo>>() {
new Function<String, Future<DriveInfo>>() {
@Override
public Future<DriveInfo> apply(String input) {
return aclient.getDriveInfo(input);
}
@Override
public Future<DriveInfo> apply(String input) {
return aclient.getDriveInfo(input);
}
}, executor, null, logger, "drives");
}, executor, null, logger, "drives");
Iterable<DriveInfo> returnVal = filter(drives, notNull());
for (DriveInfo drive : returnVal)
cache.put(drive.getUuid(), drive);
@ -170,7 +172,7 @@ public class ElasticStackComputeServiceAdapter implements
@Override
public Iterable<Location> listLocations() {
return ImmutableSet.<Location> of(new LocationImpl(LocationScope.PROVIDER, providerName, providerURI
.toASCIIString(), null));
.toASCIIString(), null));
}
@Override
@ -182,6 +184,8 @@ public class ElasticStackComputeServiceAdapter implements
public void destroyNode(String id) {
ServerInfo server = getNode(id);
if (server != null) {
if (server.getStatus() != ServerStatus.STOPPED)
client.stopServer(id);
client.destroyServer(id);
for (Device dev : server.getDevices().values())
client.destroyDrive(dev.getDriveUuid());

View File

@ -68,14 +68,14 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole
*/
public class ElasticStackComputeServiceContextModule
extends
ComputeServiceAdapterContextModule<ElasticStackClient, ElasticStackAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
extends
ComputeServiceAdapterContextModule<ElasticStackClient, ElasticStackAsyncClient, ServerInfo, Hardware, DriveInfo, Location> {
public ElasticStackComputeServiceContextModule() {
super(ElasticStackClient.class, ElasticStackAsyncClient.class);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings( { "unchecked", "rawtypes" })
@Override
protected void configure() {
super.configure();
@ -123,10 +123,9 @@ public class ElasticStackComputeServiceContextModule
@Singleton
@Provides
protected Map<String, WellKnownImage> provideImages(Json json, @Provider String providerName) throws IOException {
List<WellKnownImage> wellKnowns = json.fromJson(
Strings2.toStringAndClose(getClass().getResourceAsStream("/"+providerName+"/preinstalled_images.json")),
new TypeLiteral<List<WellKnownImage>>() {
}.getType());
List<WellKnownImage> wellKnowns = json.fromJson(Strings2.toStringAndClose(getClass().getResourceAsStream(
"/" + providerName + "/preinstalled_images.json")), new TypeLiteral<List<WellKnownImage>>() {
}.getType());
return Maps.uniqueIndex(wellKnowns, new Function<WellKnownImage, String>() {
@Override
@ -140,8 +139,8 @@ public class ElasticStackComputeServiceContextModule
@Provides
@Singleton
protected Predicate<DriveInfo> supplyDriveUnclaimed(DriveClaimed driveClaimed,
ComputeServiceConstants.Timeouts timeouts) {
ComputeServiceConstants.Timeouts timeouts) {
return new RetryablePredicate<DriveInfo>(Predicates.not(driveClaimed), timeouts.nodeRunning, 1000,
TimeUnit.MILLISECONDS);
TimeUnit.MILLISECONDS);
}
}

View File

@ -53,18 +53,13 @@ public class WellKnownImageToImage implements Function<DriveInfo, Image> {
@Override
public Image apply(DriveInfo drive) {
WellKnownImage input = preinstalledImages.get(drive.getUuid());
return new ImageBuilder()
.ids(drive.getUuid())
.userMetadata(
ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata())
.put("size", input.getSize() + "").build())
.defaultCredentials(new Credentials("toor", null))
.location(locationSupplier.get())
.name(input.getDescription())
.description(drive.getName())
.operatingSystem(
new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion())
.name(input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version("")
.build();
return new ImageBuilder().ids(drive.getUuid()).userMetadata(
ImmutableMap.<String, String> builder().putAll(drive.getUserMetadata())
.put("size", input.getSize() + "").build()).defaultCredentials(
new Credentials(input.getLoginUser(), null)).location(locationSupplier.get()).name(
input.getDescription()).description(drive.getName()).operatingSystem(
new OperatingSystemBuilder().family(input.getOsFamily()).version(input.getOsVersion()).name(
input.getDescription()).description(drive.getName()).is64Bit(input.is64bit()).build()).version(
"").build();
}
}

View File

@ -28,6 +28,7 @@ import com.google.common.base.Objects;
* @author Adrian Cole
*/
public class WellKnownImage {
private String loginUser = "toor";
private String uuid;
private String description;
private OsFamily osFamily;
@ -66,9 +67,13 @@ public class WellKnownImage {
return is64bit;
}
public String getLoginUser() {
return loginUser;
}
@Override
public int hashCode() {
return Objects.hashCode(uuid, description, osFamily, osVersion, size, is64bit);
return Objects.hashCode(uuid, description, osFamily, osVersion, size, is64bit, loginUser);
}
@Override
@ -81,7 +86,8 @@ public class WellKnownImage {
@Override
public String toString() {
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();
}
}

View File

@ -45,9 +45,11 @@ public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Functio
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
if (!"".equals(keyValueLine)) {
int firstIndex = keyValueLine.indexOf(' ');
String key = keyValueLine.substring(0, firstIndex);
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
map.put(key, value);
if (firstIndex != -1) {
String key = keyValueLine.substring(0, firstIndex);
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
map.put(key, value);
}
}
}
if (map.size() != 0)

View File

@ -22,12 +22,14 @@ package org.jclouds.elasticstack.functions;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import javax.inject.Singleton;
import org.jclouds.elasticstack.domain.ClaimType;
import org.jclouds.elasticstack.domain.DriveInfo;
import org.jclouds.elasticstack.domain.DriveMetrics;
import org.jclouds.elasticstack.domain.DriveStatus;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
@ -39,6 +41,10 @@ import com.google.common.collect.Maps;
*/
@Singleton
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
@Resource
protected Logger logger = Logger.NULL;
@Override
public DriveInfo apply(Map<String, String> from) {
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());
}
builder.userMetadata(metadata);
return builder.build();
try {
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) {

View File

@ -81,6 +81,7 @@ public class ElasticStackClientLiveTest {
protected ElasticStackClient client;
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> context;
protected Predicate<IPSocket> socketTester;
protected String bootDrive = "38df0986-4d85-4b76-b502-3878ffc80161";
protected String provider = "elasticstack";
protected String identity;
@ -115,13 +116,13 @@ public class ElasticStackClientLiveTest {
setupCredentials();
Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
client = context.getApi();
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
1, TimeUnit.SECONDS);
1, TimeUnit.SECONDS);
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), maxDriveImageTime, 1,
TimeUnit.SECONDS);
TimeUnit.SECONDS);
}
@Test
@ -198,12 +199,10 @@ public class ElasticStackClientLiveTest {
@Test(dependsOnMethods = "testCreateDrive")
public void testSetDriveData() throws Exception {
DriveInfo drive2 = client.setDriveData(
drive.getUuid(),
new DriveData.Builder().claimType(ClaimType.SHARED).name("rediculous")
.readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"))
.tags(ImmutableSet.of("networking", "security", "gateway"))
.userMetadata(ImmutableMap.of("foo", "bar")).build());
DriveInfo drive2 = client.setDriveData(drive.getUuid(), new DriveData.Builder().claimType(ClaimType.SHARED).name(
"rediculous").readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")).tags(
ImmutableSet.of("networking", "security", "gateway")).userMetadata(ImmutableMap.of("foo", "bar"))
.build());
assertNotNull(drive2.getUuid(), drive.getUuid());
assertEquals(drive2.getName(), "rediculous");
@ -244,8 +243,8 @@ public class ElasticStackClientLiveTest {
assertNotNull(server.getUser());
assertEquals(server.getName(), prefix);
assertEquals(server.isPersistent(), true);
assertEquals(server.getDevices(),
ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid()).build()));
assertEquals(server.getDevices(), ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid())
.build()));
assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0"));
assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp());
assertEquals(server.getNics().get(0).getModel(), Model.E1000);
@ -254,10 +253,12 @@ public class ElasticStackClientLiveTest {
@Test(dependsOnMethods = "testCreateAndStartServer")
public void testConnectivity() throws Exception {
Logger.getAnonymousLogger().info("awaiting vnc");
assert socketTester.apply(new IPSocket(server.getVnc().getIp(), 5900)) : server;
Logger.getAnonymousLogger().info("awaiting ssh");
assert socketTester.apply(new IPSocket(server.getNics().get(0).getDhcp(), 22)) : server;
IPSocket vncsocket = new IPSocket(server.getVnc().getIp(), 5900);
Logger.getAnonymousLogger().info("awaiting vnc: " + vncsocket);
assert socketTester.apply(vncsocket) : 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));
}
@ -276,7 +277,7 @@ public class ElasticStackClientLiveTest {
// behavior on shutdown depends on how your server OS is set up to respond to an ACPI power
// button signal
assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
server.getUuid()).getStatus() == ServerStatus.STOPPED);
server.getUuid()).getStatus() == ServerStatus.STOPPED);
}
@Test(dependsOnMethods = "testLifeCycle")
@ -284,11 +285,9 @@ public class ElasticStackClientLiveTest {
client.stopServer(server.getUuid());
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
ServerInfo server2 = client.setServerConfiguration(
server.getUuid(),
Server.Builder.fromServer(server).name("rediculous")
.tags(ImmutableSet.of("networking", "security", "gateway"))
.userMetadata(ImmutableMap.of("foo", "bar")).build());
ServerInfo server2 = client.setServerConfiguration(server.getUuid(), Server.Builder.fromServer(server).name(
"rediculous").tags(ImmutableSet.of("networking", "security", "gateway")).userMetadata(
ImmutableMap.of("foo", "bar")).build());
assertNotNull(server2.getUuid(), server.getUuid());
assertEquals(server2.getName(), "rediculous");
@ -314,8 +313,8 @@ public class ElasticStackClientLiveTest {
}
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException {
SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class)
.create(new IPSocket(server.getVnc().getIp(), 22), creds);
SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class).create(
new IPSocket(server.getVnc().getIp(), 22), creds);
try {
ssh.connect();
ExecResponse hello = ssh.exec("echo hello");
@ -358,7 +357,7 @@ public class ElasticStackClientLiveTest {
public void testWeCopyADriveContentsViaGzip() throws IOException {
try {
drive3 = client
.createDrive(new CreateDriveRequest.Builder().name(prefix + "3").size(1 * 1024 * 1024l).build());
.createDrive(new CreateDriveRequest.Builder().name(prefix + "3").size(1 * 1024 * 1024l).build());
System.err.println("before image; drive 2" + client.getDriveInfo(drive2.getUuid()));
System.err.println("before image; drive 3" + client.getDriveInfo(drive3.getUuid()));
client.imageDrive(drive2.getUuid(), drive3.getUuid());
@ -379,7 +378,7 @@ public class ElasticStackClientLiveTest {
protected void prepareDrive() {
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());
System.err.println("after prepare" + client.getDriveInfo(drive.getUuid()));
}

View File

@ -36,4 +36,8 @@ public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTe
return new JschSshClientModule();
}
@Override
public void testOptionToNotBlock() {
// start call is blocking anyway.
}
}

View File

@ -34,6 +34,7 @@ import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.net.ssl.SSLException;
import org.jclouds.Constants;
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.DelegatingRetryHandler;
import org.jclouds.logging.Logger;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.util.Throwables2;
import com.google.common.io.NullOutputStream;
@ -73,9 +75,9 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
@Inject
protected BaseHttpCommandExecutorService(HttpUtils utils,
@Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioWorkerExecutor,
DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
DelegatingErrorHandler errorHandler, HttpWire wire) {
@Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioWorkerExecutor,
DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
DelegatingErrorHandler errorHandler, HttpWire wire) {
this.utils = checkNotNull(utils, "utils");
this.retryHandler = checkNotNull(retryHandler, "retryHandler");
this.ioRetryHandler = checkNotNull(ioRetryHandler, "ioRetryHandler");
@ -125,7 +127,8 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
public Future<HttpResponse> submit(HttpCommand command) {
HttpRequest request = command.getCurrentRequest();
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));
}
@ -147,7 +150,7 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
request = filter.filter(request);
}
checkRequestHasContentLengthOrChunkedEncoding(request,
"After filtering, the request has niether chunked encoding nor content length: " + request);
"After filtering, the request has niether chunked encoding nor content length: " + request);
logger.debug("Sending request %s: %s", request.hashCode(), request.getRequestLine());
wirePayloadIfEnabled(wire, request);
nativeRequest = convert(request);
@ -169,13 +172,18 @@ public abstract class BaseHttpCommandExecutorService<Q> implements HttpCommandEx
}
} catch (Exception e) {
IOException ioe = Throwables2.getFirstThrowableOfType(e, IOException.class);
if (ioe != null && ioRetryHandler.shouldRetryRequest(command, ioe)) {
continue;
} else {
command.setException(new HttpResponseException(e.getMessage() + " connecting to "
+ command.getCurrentRequest().getRequestLine(), command, null, e));
break;
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;
}
}
command.setException(new HttpResponseException(e.getMessage() + " connecting to "
+ command.getCurrentRequest().getRequestLine(), command, null, e));
break;
} finally {
cleanup(nativeRequest);
}

View File

@ -44,7 +44,7 @@ public class PreinstalledDiskToImage implements Function<DriveInfo, Image> {
@Inject
public PreinstalledDiskToImage(Supplier<Location> locationSupplier,
Function<String, OsFamilyVersion64Bit> imageParser) {
Function<String, OsFamilyVersion64Bit> imageParser) {
this.locationSupplier = locationSupplier;
this.imageParser = imageParser;
}
@ -56,11 +56,11 @@ public class PreinstalledDiskToImage implements Function<DriveInfo, Image> {
String description = drive.getDescription() != null ? drive.getDescription() : drive.getName();
OperatingSystemBuilder builder = new OperatingSystemBuilder();
OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName());
builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version)
.family(parsed.family);
return new ImageBuilder().ids(drive.getUuid())
.userMetadata(ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + ""))
.defaultCredentials(new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get())
.name(drive.getName()).description(description).operatingSystem(builder.build()).version("").build();
builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version).family(
parsed.family);
return new ImageBuilder().ids(drive.getUuid()).adminPassword("cloudsigma").userMetadata(
ImmutableMap.<String, String> of("size", drive.getSize() / 1024 / 1024 / 1024 + "")).defaultCredentials(
new Credentials("cloudsigma", "cloudsigma")).location(locationSupplier.get()).name(drive.getName())
.description(description).operatingSystem(builder.build()).version("").build();
}
}

View File

@ -99,6 +99,7 @@ public class ServerInfoToNodeMetadata implements Function<ServerInfo, NodeMetada
Image image = findImageForId.apply(imageId);
if (image != null) {
builder.operatingSystem(image.getOperatingSystem());
builder.adminPassword(image.getAdminPassword());
}
}
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.privateAddresses(ImmutableSet.<String> of());
builder.credentials(credentialStore.get(from.getUuid()));
// note sudo password!
builder.adminPassword(from.getVnc().getPassword());
return builder.build();
}

View File

@ -45,9 +45,11 @@ public class ListOfKeyValuesDelimitedByBlankLinesToListOfMaps implements Functio
for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) {
if (!"".equals(keyValueLine)) {
int firstIndex = keyValueLine.indexOf(' ');
String key = keyValueLine.substring(0, firstIndex);
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
map.put(key, value);
if (firstIndex != -1) {
String key = keyValueLine.substring(0, firstIndex);
String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n");
map.put(key, value);
}
}
}
if (map.size() != 0)

View File

@ -23,6 +23,7 @@ import java.net.URI;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Resource;
import javax.inject.Singleton;
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.DriveStatus;
import org.jclouds.cloudsigma.domain.DriveType;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
@ -42,6 +44,9 @@ import com.google.common.collect.Maps;
@Singleton
public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo> {
@Resource
protected Logger logger = Logger.NULL;
@Override
public DriveInfo apply(Map<String, String> from) {
if (from.size() == 0)
@ -89,7 +94,12 @@ public class MapToDriveInfo implements Function<Map<String, String>, DriveInfo>
builder.free(new Boolean(from.get("free")));
if (from.containsKey("type"))
builder.type(DriveType.fromValue(from.get("type")));
return builder.build();
try {
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) {

View File

@ -30,5 +30,6 @@ import org.testng.annotations.Test;
public class ElasticHostsBlueSquareLondonClientLiveTest extends ElasticStackClientLiveTest {
public ElasticHostsBlueSquareLondonClientLiveTest() {
provider = "elastichosts-lon-b";
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
}
}

View File

@ -30,5 +30,6 @@ import org.testng.annotations.Test;
public class ElasticHostsPeer1LondonClientLiveTest extends ElasticStackClientLiveTest {
public ElasticHostsPeer1LondonClientLiveTest() {
provider = "elastichosts-lon-p";
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
}
}

View File

@ -30,5 +30,6 @@ import org.testng.annotations.Test;
public class ElasticHostsPeer1SanAntonioClientLiveTest extends ElasticStackClientLiveTest {
public ElasticHostsPeer1SanAntonioClientLiveTest() {
provider = "elastichosts-sat-p";
bootDrive = "aee5589a-88c3-43ef-bb0a-9cab6e64192d";
}
}

View File

@ -19,22 +19,12 @@
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 com.google.inject.Injector;
/**
*
* @author Adrian Cole
*/
public class ServerloveManchesterComputeServiceContextModule extends ElasticStackComputeServiceContextModule {
@Override
protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true);
}
}

View File

@ -1,72 +1,42 @@
[
{
"uuid": "38df0986-4d85-4b76-b502-3878ffc80161",
"uuid": "679f5f44-0be7-4745-a658-cccd4334c1aa",
"description": "CentOS Linux 5.5",
"osFamily": "CENTOS",
"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",
"osFamily": "DEBIAN",
"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",
"osFamily": "UBUNTU",
"osVersion": "10.04",
"size": "1"
"size": "1",
"loginUser": "root"
},
{
"uuid": "bf1d943e-2a55-46bb-a8c7-6099e44a3dde",
"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",
"uuid": "85623ca1-9c2a-4398-a771-9a43c347e86b",
"description": "Windows Web Server 2008 R2",
"osFamily": "WINDOWS",
"osVersion": "2008 R2",
"size": "13"
"size": "13",
"loginUser": "Administrator"
},
{
"uuid": "9397d327-3bf6-46a2-abf6-69553dbb6927",
"description": "Windows Web Server 2008 R2 + SQL Server",
"osFamily": "WINDOWS",
"osVersion": "2008 R2",
"size": "13"
},
{
"uuid": "10a88d1c-6575-46e3-8d2c-7744065ea530",
"uuid": "41993a02-0b22-4e49-bb47-0aa8975217e4",
"description": "Windows Server 2008 Standard R2",
"osFamily": "WINDOWS",
"osVersion": "2008 R2",
"size": "13"
},
{
"uuid": "662c5b3f-9828-4aa2-a866-7cfa53798cdf",
"description": "Windows Server 2008 Standard R2 + SQL Server",
"osFamily": "WINDOWS",
"osVersion": "2008 R2",
"size": "13"
"size": "13",
"loginUser": "Administrator"
}
]
]

View File

@ -19,7 +19,9 @@
package org.jclouds.serverlove;
import org.jclouds.domain.Credentials;
import org.jclouds.elasticstack.ElasticStackClientLiveTest;
import org.jclouds.elasticstack.domain.Server;
import org.testng.annotations.Test;
/**
@ -30,5 +32,10 @@ import org.testng.annotations.Test;
public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest {
public ServerloveManchesterClientLiveTest() {
provider = "serverlove-z1-man";
bootDrive = "5f2e0e29-2937-42b9-b362-d2d07eddbdeb";
}
protected Credentials getSshCredentials(Server server) {
return new Credentials("root", server.getVnc().getPassword());
}
}

View File

@ -49,8 +49,8 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui
public boolean apply(OsFamilyVersion64Bit input) {
return ((input.family == OsFamily.RHEL) || //
(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.WINDOWS) //
(input.family == OsFamily.UBUNTU && !(input.version.equals("10.04") && input.is64Bit)) || //
(input.family == OsFamily.WINDOWS && !(input.version.equals("2008 R2") && input.is64Bit)) //
);
}
@ -61,7 +61,7 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui
public void testTemplateBuilder() {
Template defaultTemplate = this.context.getComputeService().templateBuilder().build();
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.getLocation().getId(), "serverlove-z1-man");
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);

View File

@ -30,5 +30,6 @@ import org.testng.annotations.Test;
public class SkaliCloudMalaysiaClientLiveTest extends ElasticStackClientLiveTest {
public SkaliCloudMalaysiaClientLiveTest() {
provider = "skalicloud-sdg-my";
bootDrive = "3051699a-a536-4220-aeb5-67f2ec101a09";
}
}