diff --git a/README.txt b/README.txt
index 6fbeb8f7de..6ef98d2ad9 100644
--- a/README.txt
+++ b/README.txt
@@ -30,8 +30,10 @@ our current version is 1.0-beta-8
our dev version is 1.0-SNAPSHOT
our compute api supports: ec2, gogrid, cloudservers (rackspace), rimuhosting, vcloud,
- trmk-ecloud, trmk-vcloudexpress, eucalyptus,
- bluelock-vclouddirector, slicehost, stub (in-memory)
+ trmk-ecloud, trmk-vcloudexpress, eucalyptus, cloudsigma,
+ elasticstack, bluelock-vclouddirector, slicehost,
+ elastichosts-lon-p (Peer 1), elastichosts-sat-p (Peer 1),
+ elastichosts-lon-b (BlueSquare), stub (in-memory)
* note * the pom dependency org.jclouds/jclouds-allcompute gives you access to
to all of these providers
@@ -103,8 +105,8 @@ Compute Example (Clojure):
Downloads:
* distribution zip: http://jclouds.googlecode.com/files/jclouds-1.0-beta-8.zip
- * maven repo: http://jclouds.googlecode.com/svn/repo
- * snapshot repo: http://jclouds.rimuhosting.com/maven2/snapshots
+ * maven repo: https://oss.sonatype.org/content/repositories/releases
+ * snapshot repo: https://oss.sonatype.org/content/repositories/snapshots
Links:
* project page: http://code.google.com/p/jclouds/
diff --git a/allcompute/pom.xml b/allcompute/pom.xml
index 000e927a1f..3d4e4dfb54 100644
--- a/allcompute/pom.xml
+++ b/allcompute/pom.xml
@@ -69,5 +69,15 @@
jclouds-slicehost
${project.version}
+
+ ${project.groupId}
+ jclouds-elasticstack
+ ${project.version}
+
+
+ ${project.groupId}
+ jclouds-cloudsigma
+ ${project.version}
+
diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RegionAndIdToImage.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RegionAndIdToImage.java
index 310b30f9ca..03333a0544 100644
--- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RegionAndIdToImage.java
+++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/functions/RegionAndIdToImage.java
@@ -21,6 +21,8 @@ package org.jclouds.aws.ec2.compute.functions;
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
+import java.util.NoSuchElementException;
+
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -29,6 +31,7 @@ import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.compute.domain.RegionAndName;
import org.jclouds.compute.domain.Image;
import org.jclouds.logging.Logger;
+import org.jclouds.rest.ResourceNotFoundException;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
@@ -56,9 +59,19 @@ public final class RegionAndIdToImage implements Function
org.jclouds.aws.ec2.domain.Image image = Iterables.getOnlyElement(sync.getAMIServices()
.describeImagesInRegion(key.getRegion(), imageIds(key.getName())));
return parser.apply(image);
+ } catch (NoSuchElementException e) {
+ logger.debug(message(key, e));
+ return null;
+ } catch (ResourceNotFoundException e) {
+ logger.debug(message(key, e));
+ return null;
} catch (Exception e) {
- logger.warn(e, "could not find image %s/%s: %s", key.getRegion(), key.getName(), e.getMessage());
+ logger.warn(e, message(key, e));
return null;
}
}
+
+ public static String message(RegionAndName key, Exception e) {
+ return String.format("could not find image %s/%s: %s", key.getRegion(), key.getName(), e.getMessage());
+ }
}
\ No newline at end of file
diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
index 64c8eb219a..cc7839635d 100644
--- a/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
+++ b/aws/core/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java
@@ -39,6 +39,7 @@ import org.jclouds.aws.ec2.domain.KeyPair;
import org.jclouds.aws.ec2.options.RunInstancesOptions;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.rest.annotations.Provider;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Sets;
@@ -49,6 +50,8 @@ import com.google.common.collect.Sets;
*/
@Singleton
public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions {
+ @VisibleForTesting
+ final String provider;
@VisibleForTesting
final Map credentialsMap;
@VisibleForTesting
@@ -63,11 +66,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
final CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded;
@Inject
- CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(Map credentialsMap,
- @Named("SECURITY") Map securityGroupMap,
+ CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(@Provider String provider,
+ Map credentialsMap, @Named("SECURITY") Map securityGroupMap,
@Named("PLACEMENT") Map placementGroupMap, CreateUniqueKeyPair createUniqueKeyPair,
CreateSecurityGroupIfNeeded createSecurityGroupIfNeeded,
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded) {
+ this.provider = provider;
this.credentialsMap = credentialsMap;
this.securityGroupMap = securityGroupMap;
this.placementGroupMap = placementGroupMap;
@@ -76,9 +80,14 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
this.createPlacementGroupIfNeeded = createPlacementGroupIfNeeded;
}
+ // this method only exists so that we can mock
+ String getProvider() {
+ return provider;
+ }
+
public RunInstancesOptions execute(String region, String tag, Template template) {
- RunInstancesOptions instanceOptions = asType(template.getHardware().getId()).withAdditionalInfo(tag);
+ RunInstancesOptions instanceOptions = asType(template.getHardware().getId());
String keyPairName = createNewKeyPairUnlessUserSpecifiedOtherwise(region, tag, template.getOptions());
diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java b/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java
index b9bd70cb42..0701fe43ba 100644
--- a/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java
+++ b/aws/core/src/main/java/org/jclouds/aws/ec2/options/RunInstancesOptions.java
@@ -41,7 +41,8 @@ import org.jclouds.encryption.internal.Base64;
*
* @author Adrian Cole
* @see
*/
public class RunInstancesOptions extends BaseEC2RequestOptions {
@@ -105,24 +106,13 @@ public class RunInstancesOptions extends BaseEC2RequestOptions {
return getFirstFormOrNull("Placement.GroupName");
}
- /**
- * Specifies additional information to make available to the instance(s).
- */
- public RunInstancesOptions withAdditionalInfo(String info) {
- formParameters.put("AdditionalInfo", checkNotNull(info, "info"));
- return this;
- }
-
- String getAdditionalInfo() {
- return getFirstFormOrNull("AdditionalInfo");
- }
-
/**
* Unencoded data
*/
public RunInstancesOptions withUserData(byte[] unencodedData) {
- checkArgument(checkNotNull(unencodedData, "unencodedData").length <= 16 * 1024,
- "userData cannot be larger than 16kb");
+ int length = checkNotNull(unencodedData, "unencodedData").length;
+ checkArgument(length > 0, "userData cannot be empty");
+ checkArgument(length <= 16 * 1024, "userData cannot be larger than 16kb");
formParameters.put("UserData", Base64.encodeBytes(unencodedData));
return this;
}
@@ -244,14 +234,6 @@ public class RunInstancesOptions extends BaseEC2RequestOptions {
return options.inPlacementGroup(placementGroup);
}
- /**
- * @see RunInstancesOptions#withAdditionalInfo(String)
- */
- public static RunInstancesOptions withAdditionalInfo(String additionalInfo) {
- RunInstancesOptions options = new RunInstancesOptions();
- return options.withAdditionalInfo(additionalInfo);
- }
-
/**
* @see RunInstancesOptions#withUserData(byte [])
*/
diff --git a/aws/core/src/test/java/org/jclouds/aws/cloudwatch/CloudWatchAsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/cloudwatch/CloudWatchAsyncClientTest.java
index 9c3b11b049..545edf3847 100644
--- a/aws/core/src/test/java/org/jclouds/aws/cloudwatch/CloudWatchAsyncClientTest.java
+++ b/aws/core/src/test/java/org/jclouds/aws/cloudwatch/CloudWatchAsyncClientTest.java
@@ -57,16 +57,23 @@ public class CloudWatchAsyncClientTest extends RestClientTest of());
assertEquals(
runOptions.buildFormParameters().entries(),
- ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
- "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName).entries());
+ ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+ generatedGroup, "KeyName", systemGeneratedKeyPairName).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. of());
assertEquals(runOptions.buildStringPayload(), null);
@@ -158,9 +160,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap. of());
assertEquals(
runOptions.buildFormParameters().entries(),
- ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
- "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName",
- generatedGroup).entries());
+ ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+ generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup)
+ .entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. of());
assertEquals(runOptions.buildStringPayload(), null);
@@ -217,9 +219,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap. of());
assertEquals(
runOptions.buildFormParameters().entries(),
- ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
- "SecurityGroup.1", generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName",
- generatedGroup).entries());
+ ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1",
+ generatedGroup, "KeyName", systemGeneratedKeyPairName, "Placement.GroupName", generatedGroup)
+ .entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. of());
assertEquals(runOptions.buildStringPayload(), null);
@@ -271,8 +273,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap. of());
assertEquals(
runOptions.buildFormParameters().entries(),
- ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
- "SubnetId", "1", "KeyName", systemGeneratedKeyPairName).entries());
+ ImmutableMultimap. of("InstanceType", size.getProviderId(), "SubnetId", "1", "KeyName",
+ systemGeneratedKeyPairName).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. of());
assertEquals(runOptions.buildStringPayload(), null);
@@ -291,7 +293,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
String systemGeneratedKeyPairName = "systemGeneratedKeyPair";
String generatedGroup = "group";
Set generatedGroups = ImmutableSet.of(generatedGroup);
-
+
// create mocks
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = createMock(
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.class,
@@ -327,8 +329,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
assertEquals(runOptions.buildQueryParameters(), ImmutableMultimap. of());
assertEquals(
runOptions.buildFormParameters().entries(),
- ImmutableMultimap. of("InstanceType", size.getProviderId(), "AdditionalInfo", tag,
- "SecurityGroup.1", "group", "KeyName", systemGeneratedKeyPairName, "UserData", Base64.encodeBytes("hello".getBytes())).entries());
+ ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", "group",
+ "KeyName", systemGeneratedKeyPairName, "UserData", Base64.encodeBytes("hello".getBytes())).entries());
assertEquals(runOptions.buildMatrixParameters(), ImmutableMultimap. of());
assertEquals(runOptions.buildRequestHeaders(), ImmutableMultimap. of());
assertEquals(runOptions.buildStringPayload(), null);
@@ -681,8 +683,12 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
verify(strategy.createPlacementGroupIfNeeded);
}
- @SuppressWarnings("unchecked")
private CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy() {
+ return setupStrategy("ec2");
+ }
+
+ @SuppressWarnings("unchecked")
+ private CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions setupStrategy(String provider) {
Map credentialsMap = createMock(Map.class);
Map securityGroupMap = createMock(Map.class);
Map placementGroupMap = createMock(Map.class);
@@ -690,8 +696,9 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
CreateSecurityGroupIfNeeded createSecurityGroupIfNeeded = createMock(CreateSecurityGroupIfNeeded.class);
CreatePlacementGroupIfNeeded createPlacementGroupIfNeeded = createMock(CreatePlacementGroupIfNeeded.class);
- return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(credentialsMap, securityGroupMap,
- placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded, createPlacementGroupIfNeeded);
+ return new CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions(provider, credentialsMap,
+ securityGroupMap, placementGroupMap, createUniqueKeyPair, createSecurityGroupIfNeeded,
+ createPlacementGroupIfNeeded);
}
private void replayStrategy(CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy) {
diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java
index 945ab9f88b..f29be3c5b5 100644
--- a/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java
+++ b/aws/core/src/test/java/org/jclouds/aws/ec2/options/RunInstancesOptionsTest.java
@@ -21,7 +21,6 @@ package org.jclouds.aws.ec2.options;
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.asType;
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.enableMonitoring;
-import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withAdditionalInfo;
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withDeviceName;
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withKernelId;
import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.withKeyName;
@@ -79,8 +78,7 @@ public class RunInstancesOptionsTest {
public void testWithSecurityGroup() {
RunInstancesOptions options = new RunInstancesOptions();
options.withSecurityGroup("test");
- assertEquals(options.buildFormParameters().get("SecurityGroup.1"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("SecurityGroup.1"), Collections.singletonList("test"));
}
@Test
@@ -92,8 +90,7 @@ public class RunInstancesOptionsTest {
@Test
public void testWithSecurityGroupStatic() {
RunInstancesOptions options = withSecurityGroup("test");
- assertEquals(options.buildFormParameters().get("SecurityGroup.1"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("SecurityGroup.1"), Collections.singletonList("test"));
}
@Test(expectedExceptions = NullPointerException.class)
@@ -101,32 +98,12 @@ public class RunInstancesOptionsTest {
withSecurityGroup(null);
}
- @Test
- public void testWithAdditionalInfo() {
- RunInstancesOptions options = new RunInstancesOptions();
- options.withAdditionalInfo("test");
- assertEquals(options.buildFormParameters().get("AdditionalInfo"), Collections
- .singletonList("test"));
- }
-
@Test
public void testNullWithAdditionalInfo() {
RunInstancesOptions options = new RunInstancesOptions();
assertEquals(options.buildFormParameters().get("AdditionalInfo"), Collections.EMPTY_LIST);
}
- @Test
- public void testWithAdditionalInfoStatic() {
- RunInstancesOptions options = withAdditionalInfo("test");
- assertEquals(options.buildFormParameters().get("AdditionalInfo"), Collections
- .singletonList("test"));
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testWithAdditionalInfoNPE() {
- withAdditionalInfo(null);
- }
-
@Test
public void testWithUserData() {
RunInstancesOptions options = new RunInstancesOptions();
@@ -151,12 +128,16 @@ public class RunInstancesOptionsTest {
withUserData(null);
}
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testWithUserDataEmpty() {
+ withUserData("".getBytes());
+ }
+
@Test
public void testWithInstanceType() {
RunInstancesOptions options = new RunInstancesOptions();
options.asType(InstanceType.C1_XLARGE);
- assertEquals(options.buildFormParameters().get("InstanceType"), Collections
- .singletonList("c1.xlarge"));
+ assertEquals(options.buildFormParameters().get("InstanceType"), Collections.singletonList("c1.xlarge"));
}
@Test
@@ -168,8 +149,7 @@ public class RunInstancesOptionsTest {
@Test
public void testWithInstanceTypeStatic() {
RunInstancesOptions options = asType(InstanceType.C1_XLARGE);
- assertEquals(options.buildFormParameters().get("InstanceType"), Collections
- .singletonList("c1.xlarge"));
+ assertEquals(options.buildFormParameters().get("InstanceType"), Collections.singletonList("c1.xlarge"));
}
@Test(expectedExceptions = NullPointerException.class)
@@ -205,22 +185,21 @@ public class RunInstancesOptionsTest {
public void testWithDeviceName() {
RunInstancesOptions options = new RunInstancesOptions();
options.withDeviceName("test");
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"),
+ Collections.singletonList("test"));
}
@Test
public void testNullWithDeviceName() {
RunInstancesOptions options = new RunInstancesOptions();
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"),
- Collections.EMPTY_LIST);
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"), Collections.EMPTY_LIST);
}
@Test
public void testWithDeviceNameStatic() {
RunInstancesOptions options = withDeviceName("test");
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.DeviceName"),
+ Collections.singletonList("test"));
}
@Test(expectedExceptions = NullPointerException.class)
@@ -232,8 +211,7 @@ public class RunInstancesOptionsTest {
public void testWithMonitoringEnabled() {
RunInstancesOptions options = new RunInstancesOptions();
options.enableMonitoring();
- assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), Collections
- .singletonList("true"));
+ assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), Collections.singletonList("true"));
}
@Test
@@ -245,8 +223,7 @@ public class RunInstancesOptionsTest {
@Test
public void testWithMonitoringEnabledStatic() {
RunInstancesOptions options = enableMonitoring();
- assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), Collections
- .singletonList("true"));
+ assertEquals(options.buildFormParameters().get("Monitoring.Enabled"), Collections.singletonList("true"));
}
@Test
@@ -277,8 +254,7 @@ public class RunInstancesOptionsTest {
public void testWithRamdisk() {
RunInstancesOptions options = new RunInstancesOptions();
options.withRamdisk("test");
- assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("RamdiskId"), Collections.singletonList("test"));
}
@Test
@@ -290,8 +266,7 @@ public class RunInstancesOptionsTest {
@Test
public void testWithRamdiskStatic() {
RunInstancesOptions options = withRamdisk("test");
- assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("RamdiskId"), Collections.singletonList("test"));
}
@Test(expectedExceptions = NullPointerException.class)
@@ -303,22 +278,21 @@ public class RunInstancesOptionsTest {
public void testWithVirtualName() {
RunInstancesOptions options = new RunInstancesOptions();
options.withVirtualName("test");
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"),
+ Collections.singletonList("test"));
}
@Test
public void testNullWithVirtualName() {
RunInstancesOptions options = new RunInstancesOptions();
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"),
- Collections.EMPTY_LIST);
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), Collections.EMPTY_LIST);
}
@Test
public void testWithVirtualNameStatic() {
RunInstancesOptions options = withVirtualName("test");
- assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"), Collections
- .singletonList("test"));
+ assertEquals(options.buildFormParameters().get("BlockDeviceMapping.VirtualName"),
+ Collections.singletonList("test"));
}
@Test(expectedExceptions = NullPointerException.class)
diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java
index daa9214b2d..98f5883c59 100644
--- a/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java
+++ b/aws/core/src/test/java/org/jclouds/aws/ec2/services/InstanceAsyncClientTest.java
@@ -111,9 +111,14 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTestorg.jclouds
jclouds-project
1.0-SNAPSHOT
- ../../project/pom.xml
+ ../project/pom.xml
org.jclouds
jclouds-cloudsigma
@@ -61,9 +61,15 @@
${project.groupId}
- jclouds-elasticstack
+ jclouds-compute
${project.version}
+
+ ${project.groupId}
+ jclouds-jsch
+ ${project.version}
+ test
+
${project.groupId}
jclouds-core
@@ -73,7 +79,14 @@
${project.groupId}
- jclouds-elasticstack
+ jclouds-core
+ ${project.version}
+ test-jar
+ test
+
+
+ ${project.groupId}
+ jclouds-compute
${project.version}
test-jar
test
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
new file mode 100644
index 0000000000..e199a1e378
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
@@ -0,0 +1,235 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.cloudsigma.functions.SplitNewlines;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.ExceptionParser;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.MapPayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
+import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to CloudSigma via their REST API.
+ *
+ *
+ * @see CloudSigmaClient
+ * @see
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Consumes(MediaType.TEXT_PLAIN)
+public interface CloudSigmaAsyncClient {
+
+ /**
+ * @see CloudSigmaClient#listStandardDrives
+ */
+ @GET
+ @Path("/drives/standard/list")
+ @ResponseParser(SplitNewlines.class)
+ ListenableFuture> listStandardDrives();
+
+ /**
+ * @see CloudSigmaClient#listStandardCds
+ */
+ @GET
+ @Path("/drives/standard/cd/list")
+ @ResponseParser(SplitNewlines.class)
+ ListenableFuture> listStandardCds();
+
+ /**
+ * @see CloudSigmaClient#listStandardImages
+ */
+ @GET
+ @Path("/drives/standard/img/list")
+ @ResponseParser(SplitNewlines.class)
+ ListenableFuture> listStandardImages();
+
+ /**
+ * @see CloudSigmaClient#cloneDrive
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/clone")
+ @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
+ ListenableFuture cloneDrive(@PathParam("uuid") String sourceUuid,
+ @MapPayloadParam("name") String newName, CloneDriveOptions... options);
+
+ /**
+ * @see CloudSigmaClient#listDriveInfo
+ */
+ @GET
+ @Path("/drives/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
+ ListenableFuture> listDriveInfo();
+
+ /**
+ * @see CloudSigmaClient#getDriveInfo
+ */
+ @GET
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/info")
+ ListenableFuture getDriveInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#createDrive
+ */
+ @POST
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/create")
+ ListenableFuture createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
+
+ /**
+ * @see CloudSigmaClient#setDriveData
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/set")
+ ListenableFuture setDriveData(@PathParam("uuid") String uuid,
+ @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive);
+
+ /**
+ * @see CloudSigmaClient#createServer
+ */
+ @POST
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/create")
+ ListenableFuture createServer(
+ @BinderParam(BindServerToPlainTextString.class) Server createServer);
+
+ /**
+ * @see CloudSigmaClient#listServerInfo
+ */
+ @GET
+ @Path("/servers/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
+ ListenableFuture> listServerInfo();
+
+ /**
+ * @see CloudSigmaClient#getServerInfo
+ */
+ @GET
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/info")
+ ListenableFuture getServerInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#setServerConfiguration
+ */
+ @POST
+ @ExceptionParser(ReturnNullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/set")
+ ListenableFuture setServerConfiguration(@PathParam("uuid") String uuid,
+ @BinderParam(BindServerToPlainTextString.class) Server setServer);
+
+ /**
+ * @see CloudSigmaClient#listServers
+ */
+ @GET
+ @Path("/servers/list")
+ @ResponseParser(SplitNewlines.class)
+ ListenableFuture> listServers();
+
+ /**
+ * @see CloudSigmaClient#destroyServer
+ */
+ @POST
+ @Path("/servers/{uuid}/destroy")
+ @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
+ ListenableFuture destroyServer(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#startServer
+ */
+ @POST
+ @Path("/servers/{uuid}/start")
+ ListenableFuture startServer(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#stopServer
+ */
+ @POST
+ @Path("/servers/{uuid}/stop")
+ ListenableFuture stopServer(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#shutdownServer
+ */
+ @POST
+ @Path("/servers/{uuid}/shutdown")
+ ListenableFuture shutdownServer(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#resetServer
+ */
+ @POST
+ @Path("/servers/{uuid}/reset")
+ ListenableFuture resetServer(@PathParam("uuid") String uuid);
+
+ /**
+ * @see CloudSigmaClient#listDrives
+ */
+ @GET
+ @Path("/drives/list")
+ @ResponseParser(SplitNewlines.class)
+ ListenableFuture> listDrives();
+
+ /**
+ * @see CloudSigmaClient#destroyDrive
+ */
+ @POST
+ @Path("/drives/{uuid}/destroy")
+ @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
+ ListenableFuture destroyDrive(@PathParam("uuid") String uuid);
+}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
new file mode 100644
index 0000000000..84a8bb8db7
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
@@ -0,0 +1,215 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.concurrent.Timeout;
+
+/**
+ * Provides synchronous access to CloudSigma.
+ *
+ *
+ * @see CloudSigmaAsyncClient
+ * @see
+ * @author Adrian Cole
+ */
+@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
+public interface CloudSigmaClient {
+ /**
+ * list of server uuids in your account
+ *
+ * @return or empty set if no servers are found
+ */
+ Set listServers();
+
+ /**
+ * Get all servers info
+ *
+ * @return or empty set if no servers are found
+ */
+ Set extends ServerInfo> listServerInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ ServerInfo getServerInfo(String uuid);
+
+ /**
+ * create a new server
+ *
+ * @param server
+ * @return newly created server
+ */
+ ServerInfo createServer(Server server);
+
+ /**
+ * set server configuration
+ *
+ * @param uuid
+ * what server to change
+ * @param serverData
+ * what values to change
+ * @return new data
+ */
+ ServerInfo setServerConfiguration(String uuid, Server server);
+
+ /**
+ * Destroy a server
+ *
+ * @param uuid
+ * what to destroy
+ */
+ void destroyServer(String uuid);
+
+ /**
+ * Start a server
+ *
+ * @param uuid
+ * what to start
+ */
+ void startServer(String uuid);
+
+ /**
+ * Stop a server
+ *
+ * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
+ * status if it is persistent and is automatically destroyed otherwise.
+ *
+ * @param uuid
+ * what to stop
+ */
+ void stopServer(String uuid);
+
+ /**
+ * Shutdown a server
+ *
+ * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
+ * persistent and is automatically destroyed otherwise.
+ * note
behaviour on shutdown depends on how your server OS is set up to respond to an
+ * ACPI power button signal.
+ *
+ * @param uuid
+ * what to shutdown
+ */
+ void shutdownServer(String uuid);
+
+ /**
+ * Reset a server
+ *
+ * @param uuid
+ * what to reset
+ */
+ void resetServer(String uuid);
+
+ /**
+ * list of drive uuids in your account
+ *
+ * @return or empty set if no drives are found
+ */
+ Set listDrives();
+
+ /**
+ * Get all drives info
+ *
+ * @return or empty set if no drives are found
+ */
+ Set extends DriveInfo> listDriveInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ DriveInfo getDriveInfo(String uuid);
+
+ /**
+ * create a new drive
+ *
+ * @param createDrive
+ * required parameters: name, size
+ * @return newly created drive
+ */
+ DriveInfo createDrive(Drive createDrive);
+
+ /**
+ * set extra drive data
+ *
+ * @param uuid
+ * what drive to change
+ * @param driveData
+ * what values to change
+ * @return new data
+ */
+ DriveInfo setDriveData(String uuid, DriveData driveData);
+
+ /**
+ * Destroy a drive
+ *
+ * @param uuid
+ * what to delete
+ */
+ void destroyDrive(String uuid);
+
+ /**
+ * list of drive uuids that are in the library
+ *
+ * @return or empty set if no drives are found
+ */
+ Set listStandardDrives();
+
+ /**
+ * list of cd uuids that are in the library
+ *
+ * @return or empty set if no cds are found
+ */
+ Set listStandardCds();
+
+ /**
+ * list of image uuids that are in the library
+ *
+ * @return or empty set if no images are found
+ */
+ Set listStandardImages();
+
+ /**
+ * Clone an existing drive. By default, the size is the same as the source
+ *
+ * @param sourceUuid
+ * source to clone
+ * @param newName
+ * name of the resulting drive
+ * @param options
+ * options to control size
+ * @return new drive
+ */
+ DriveInfo cloneDrive(String sourceUuid, String newName, CloneDriveOptions... options);
+
+
+}
diff --git a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
similarity index 75%
rename from sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
rename to cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
index d69dfc3874..71f5fc550e 100644
--- a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
@@ -22,8 +22,9 @@ package org.jclouds.cloudsigma;
import java.util.List;
import java.util.Properties;
+import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
-import org.jclouds.rest.RestContextBuilder;
+import org.jclouds.compute.ComputeServiceContextBuilder;
import com.google.inject.Module;
@@ -31,13 +32,17 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudSigmaContextBuilder extends
- RestContextBuilder {
+public class CloudSigmaContextBuilder extends ComputeServiceContextBuilder {
public CloudSigmaContextBuilder(Properties props) {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class, props);
}
+ @Override
+ protected void addContextModule(List modules) {
+ modules.add(new CloudSigmaComputeServiceContextModule());
+ }
+
protected void addClientModule(List modules) {
modules.add(new CloudSigmaRestClientModule());
}
diff --git a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
similarity index 76%
rename from sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
rename to cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
index d1daf9bde5..4a38f0f2dd 100644
--- a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
@@ -19,8 +19,10 @@
package org.jclouds.cloudsigma;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
+import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
import java.util.Properties;
@@ -37,6 +39,7 @@ public class CloudSigmaPropertiesBuilder extends PropertiesBuilder {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ENDPOINT, "https://api.cloudsigma.com");
properties.setProperty(PROPERTY_API_VERSION, "1.0");
+ properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
return properties;
}
@@ -44,4 +47,11 @@ public class CloudSigmaPropertiesBuilder extends PropertiesBuilder {
super(properties);
}
+ @Override
+ public Properties build() {
+ Properties props = super.build();
+ checkArgument(props.getProperty(PROPERTY_VNC_PASSWORD).length() <= 8,
+ "vnc passwords should be less that 8 characters!");
+ return props;
+ }
}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java
new file mode 100644
index 0000000000..c0e26d0a88
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextString.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
+import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
+ private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+
+ @Inject
+ public BindCloneDriveOptionsToPlainTextString(
+ ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
+ this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+ }
+
+ @Override
+ public void bindToRequest(HttpRequest request, Map postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ @SuppressWarnings("unchecked")
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ checkState(gRequest.getArgs() != null, "args should be initialized at this point");
+
+ CloneDriveOptions options = findOptionsInArgsOrNull(gRequest);
+ if (options != null) {
+ postParams = ImmutableMap. builder().putAll(postParams).putAll(options.getOptions()).build();
+ }
+
+ request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(postParams)));
+ request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
+
+ }
+
+ static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest> gRequest) {
+ for (Object arg : gRequest.getArgs()) {
+ if (arg instanceof CloneDriveOptions) {
+ return (CloneDriveOptions) arg;
+ } else if (arg instanceof CloneDriveOptions[]) {
+ CloneDriveOptions[] options = (CloneDriveOptions[]) arg;
+ return (options.length > 0) ? options[0] : null;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void bindToRequest(HttpRequest request, Object input) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java
new file mode 100644
index 0000000000..9f86bfcceb
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveDataToPlainTextString.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindDriveDataToPlainTextString implements Binder {
+ private final Function> createDriveRequestToMap;
+ private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+
+ @Inject
+ public BindDriveDataToPlainTextString(Function> createDriveRequestToMap,
+ ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
+ this.createDriveRequestToMap = createDriveRequestToMap;
+ this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+ }
+
+ public void bindToRequest(HttpRequest request, Object payload) {
+ checkArgument(payload instanceof DriveData, "this binder is only valid for DriveData!");
+ DriveData create = DriveData.class.cast(payload);
+ Map map = createDriveRequestToMap.apply(create);
+ request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
+ request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
+ }
+}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java
new file mode 100644
index 0000000000..71d5627b1a
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindDriveToPlainTextString.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindDriveToPlainTextString implements Binder {
+ private final Function> createDriveRequestToMap;
+ private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+
+ @Inject
+ public BindDriveToPlainTextString(Function> createDriveRequestToMap,
+ ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
+ this.createDriveRequestToMap = createDriveRequestToMap;
+ this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+ }
+
+ public void bindToRequest(HttpRequest request, Object payload) {
+ checkArgument(payload instanceof Drive, "this binder is only valid for Drive!");
+ Drive create = Drive.class.cast(payload);
+ Map map = createDriveRequestToMap.apply(create);
+ request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
+ request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
+ }
+}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java
new file mode 100644
index 0000000000..371b1858db
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/binders/BindServerToPlainTextString.java
@@ -0,0 +1,61 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindServerToPlainTextString implements Binder {
+ private final Function> createServerRequestToMap;
+ private final ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+
+ @Inject
+ public BindServerToPlainTextString(Function> createServerRequestToMap,
+ ListOfMapsToListOfKeyValuesDelimitedByBlankLines listOfMapsToListOfKeyValuesDelimitedByBlankLines) {
+ this.createServerRequestToMap = createServerRequestToMap;
+ this.listOfMapsToListOfKeyValuesDelimitedByBlankLines = listOfMapsToListOfKeyValuesDelimitedByBlankLines;
+ }
+
+ public void bindToRequest(HttpRequest request, Object payload) {
+ checkArgument(payload instanceof Server, "this binder is only valid for Server!");
+ Server create = Server.class.cast(payload);
+ Map map = createServerRequestToMap.apply(create);
+ request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
+ request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
+ }
+}
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
new file mode 100644
index 0000000000..c29111a60a
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
@@ -0,0 +1,231 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.compute;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.filter;
+import static org.jclouds.concurrent.FutureIterables.transformParallel;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
+import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.domain.Device;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.DriveType;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.cloudsigma.reference.CloudSigmaConstants;
+import org.jclouds.cloudsigma.util.Servers;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.internal.VolumeImpl;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.internal.LocationImpl;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.annotations.Provider;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * defines the connection between the {@link CloudSigmaClient} implementation and the jclouds
+ * {@link ComputeService}
+ *
+ */
+@Singleton
+public class CloudSigmaComputeServiceAdapter implements
+ ComputeServiceAdapter {
+ private static final Predicate PREINSTALLED_DISK = Predicates.and(Predicates.notNull(),
+ new Predicate() {
+
+ @Override
+ public boolean apply(DriveInfo drive) {
+ return drive.getType().equals(DriveType.DISK) && drive.getDriveType().contains("preinstalled");
+ }
+
+ });
+ private final CloudSigmaClient client;
+ private final CloudSigmaAsyncClient aclient;
+ private final Predicate driveNotClaimed;
+ private final String providerName;
+ private final URI providerURI;
+ private final String defaultVncPassword;
+ private final Map cache;
+ private final ExecutorService executor;
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ public CloudSigmaComputeServiceAdapter(CloudSigmaClient client, CloudSigmaAsyncClient aclient,
+ Predicate driveNotClaimed, @Provider String providerName, @Provider URI providerURI,
+ @Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword, Map cache,
+ @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
+ this.client = checkNotNull(client, "client");
+ this.aclient = checkNotNull(aclient, "aclient");
+ this.driveNotClaimed = checkNotNull(driveNotClaimed, "driveNotClaimed");
+ this.providerName = checkNotNull(providerName, "providerName");
+ this.providerURI = checkNotNull(providerURI, "providerURI");
+ this.defaultVncPassword = checkNotNull(defaultVncPassword, "defaultVncPassword");
+ this.cache = checkNotNull(cache, "cache");
+ this.executor = checkNotNull(executor, "executor");
+ }
+
+ @Override
+ public ServerInfo runNodeWithTagAndNameAndStoreCredentials(String tag, String name, Template template,
+ Map credentialStore) {
+ long bootSize = (long) (template.getHardware().getVolumes().get(0).getSize() * 1024 * 1024 * 1024l);
+ logger.debug(">> imaging boot drive source(%s) bytes(%d)", template.getImage().getId(), bootSize);
+ DriveInfo drive = client.cloneDrive(template.getImage().getId(), template.getImage().getId(),
+ new CloneDriveOptions().size(bootSize));
+ boolean success = driveNotClaimed.apply(drive);
+ logger.debug("<< image(%s) complete(%s)", drive.getUuid(), success);
+ if (!success) {
+ client.destroyDrive(drive.getUuid());
+ throw new IllegalStateException("could not image drive in time!");
+ }
+ Server toCreate = Servers.small(name, drive.getUuid(), defaultVncPassword).mem(template.getHardware().getRam())
+ .cpu((int) (template.getHardware().getProcessors().get(0).getSpeed())).build();
+
+ logger.debug(">> creating server");
+ ServerInfo from = client.createServer(toCreate);
+ logger.debug("<< created server(%s)", from.getUuid());
+ logger.debug(">> starting server(%s)", from.getUuid());
+ client.startServer(from.getUuid());
+ // store the credentials so that later functions can use them
+ credentialStore.put(from.getUuid() + "", new Credentials("cloudsigma", "cloudsigma"));
+ return from;
+ }
+
+ @Override
+ public Iterable listHardwareProfiles() {
+ Builder hardware = ImmutableSet. builder();
+ for (double cpu : new double[] { 1000, 5000, 10000, 20000 })
+ for (int ram : new int[] { 512, 1024, 4 * 1024, 16 * 1024, 32 * 1024 }) {
+ final float size = (float) cpu / 100;
+ String id = String.format("cpu=%f,ram=%s,disk=%f", cpu, ram, size);
+ hardware.add(new HardwareBuilder().supportsImage(new Predicate() {
+
+ @Override
+ public boolean apply(Image input) {
+ String toParse = input.getUserMetadata().get("size");
+ return (toParse != null && new Float(toParse) <= size);
+ }
+
+ @Override
+ public String toString() {
+ return "sizeLessThanOrEqual(" + size + ")";
+ }
+
+ }).ids(id).ram(ram).processors(ImmutableList.of(new Processor(1, cpu)))
+ .volumes(ImmutableList. of(new VolumeImpl(size, true, true))).build());
+ }
+ return hardware.build();
+ }
+
+ /**
+ * look up the current standard images and do not error out, if they are not found.
+ */
+ @Override
+ public Iterable listImages() {
+ Iterable drives = transformParallel(client.listStandardDrives(),
+ new Function>() {
+
+ @Override
+ public Future apply(String input) {
+ return aclient.getDriveInfo(input);
+ }
+
+ }, executor, null, logger, "drives");
+ Iterable returnVal = filter(drives, PREINSTALLED_DISK);
+ for (DriveInfo drive : returnVal)
+ cache.put(drive.getUuid(), drive);
+ return returnVal;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Iterable listNodes() {
+ return (Iterable) client.listServerInfo();
+ }
+
+ @Override
+ public Iterable listLocations() {
+ return ImmutableSet. of(new LocationImpl(LocationScope.PROVIDER, providerName, providerURI
+ .toASCIIString(), null));
+ }
+
+ @Override
+ public ServerInfo getNode(String id) {
+ return client.getServerInfo(id);
+ }
+
+ @Override
+ public void destroyNode(String id) {
+ ServerInfo server = getNode(id);
+ if (server != null) {
+ client.stopServer(id);
+ client.destroyServer(id);
+ for (Device dev : server.getDevices().values())
+ client.destroyDrive(dev.getDriveUuid());
+ }
+ }
+
+ @Override
+ public void rebootNode(String id) {
+ client.resetServer(id);
+ }
+
+ @Override
+ public void resumeNode(String id) {
+ client.startServer(id);
+
+ }
+
+ @Override
+ public void suspendNode(String id) {
+ client.stopServer(id);
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
new file mode 100644
index 0000000000..055c85fa6b
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
@@ -0,0 +1,140 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.compute.config;
+
+import static org.jclouds.compute.domain.OsFamily.UBUNTU;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
+import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
+import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName;
+import org.jclouds.cloudsigma.compute.functions.PreinstalledDiskToImage;
+import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata;
+import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume;
+import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.FindImageForId;
+import org.jclouds.cloudsigma.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer;
+import org.jclouds.cloudsigma.domain.Device;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.predicates.DriveClaimed;
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
+import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule.IdentityFunction;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.suppliers.DefaultLocationSupplier;
+import org.jclouds.domain.Location;
+import org.jclouds.predicates.RetryablePredicate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.collect.MapMaker;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class CloudSigmaComputeServiceContextModule
+ extends
+ ComputeServiceAdapterContextModule {
+
+ public CloudSigmaComputeServiceContextModule() {
+ super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
+ }
+
+ @Override
+ protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) {
+ return template.osFamily(UBUNTU).osVersionMatches("10.04").os64Bit(true).minRam(1024);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(new TypeLiteral>() {
+ }).to(CloudSigmaComputeServiceAdapter.class);
+ bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
+ bind(new TypeLiteral>() {
+ }).to(DefaultLocationSupplier.class);
+ bind(new TypeLiteral>() {
+ }).to(ServerInfoToNodeMetadata.class);
+ bind(new TypeLiteral>() {
+ }).to((Class) IdentityFunction.class);
+ bind(new TypeLiteral>() {
+ }).to(PreinstalledDiskToImage.class);
+ bind(new TypeLiteral>() {
+ }).to((Class) IdentityFunction.class);
+ bind(new TypeLiteral>() {
+ }).to(DeviceToVolume.class);
+ bind(new TypeLiteral>() {
+ }).to(GetImageIdFromServer.class);
+ bind(new TypeLiteral>() {
+ }).to(FindImageForId.class);
+ bind(new TypeLiteral>() {
+ }).to(ParseOsFamilyVersion64BitFromImageName.class);
+
+ }
+
+ @Provides
+ @Singleton
+ protected Map cache(GetDrive getDrive) {
+ return new MapMaker().makeComputingMap(getDrive);
+ }
+
+ @Singleton
+ public static class GetDrive implements Function {
+ private final CloudSigmaClient client;
+
+ @Inject
+ public GetDrive(CloudSigmaClient client) {
+ this.client = client;
+ }
+
+ @Override
+ public DriveInfo apply(String input) {
+ return client.getDriveInfo(input);
+ }
+ }
+
+ @Provides
+ @Singleton
+ protected Predicate supplyDriveUnclaimed(DriveClaimed driveClaimed,
+ ComputeServiceConstants.Timeouts timeouts) {
+ return new RetryablePredicate(Predicates.not(driveClaimed), timeouts.nodeRunning, 1000,
+ TimeUnit.MILLISECONDS);
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java
new file mode 100644
index 0000000000..a86f2a32e3
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java
@@ -0,0 +1,81 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.compute.functions;
+
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.containsPattern;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.base.Predicates.or;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
+
+import com.google.common.base.Function;
+
+/**
+ * Defaults to version null and 64bit, if the operating system is unrecognized and the pattern
+ * "32bit" isn't in the string.
+ *
+ * @author Adrian Cole
+ *
+ */
+@Singleton
+public class ParseOsFamilyVersion64BitFromImageName implements Function {
+
+ // ex CentOS 5.5 Linux 64bit Preinstalled System with AppFirst Monitoring
+ public static final Pattern PATTERN = Pattern.compile("([^ ]+)[^0-9]([0-9.]+) .*");
+
+ @Override
+ public OsFamilyVersion64Bit apply(String input) {
+ boolean is64Bit = and(not(containsPattern("32bit")),
+ or(containsPattern("64bit"), not(containsPattern("Windows")))).apply(input);
+ if (input.contains("Windows")) {
+ String version = null;
+ Matcher matcher = Pattern.compile(".*(20[01][0-9] R[1-9]).*").matcher(input);
+ if (matcher.find()) {
+ version = matcher.group(1);
+ } else {
+ matcher = Pattern.compile(".*(20[01][0-9]).*").matcher(input);
+ if (matcher.find())
+ version = matcher.group(1);
+ }
+ return new OsFamilyVersion64Bit(OsFamily.WINDOWS, version, is64Bit);
+ } else {
+ Matcher matcher = PATTERN.matcher(input);
+ if (matcher.find()) {
+ OsFamily fam = OsFamily.fromValue(matcher.group(1).toLowerCase());
+ String version = matcher.group(2);
+ switch (fam) {
+ case UNRECOGNIZED:
+ return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit);
+ case WINDOWS:
+ }
+ return new OsFamilyVersion64Bit(fam, version, is64Bit);
+ } else {
+ return new OsFamilyVersion64Bit(OsFamily.UNRECOGNIZED, null, is64Bit);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java
new file mode 100644
index 0000000000..1815bac10f
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.compute.functions;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystemBuilder;
+import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class PreinstalledDiskToImage implements Function {
+ private final Supplier locationSupplier;
+ private final Function imageParser;
+
+ @Inject
+ public PreinstalledDiskToImage(Supplier locationSupplier,
+ Function imageParser) {
+ this.locationSupplier = locationSupplier;
+ this.imageParser = imageParser;
+ }
+
+ @Override
+ public Image apply(DriveInfo drive) {
+ if (drive.getName() == null)
+ return null;
+ 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. 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();
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java
new file mode 100644
index 0000000000..ef07925402
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/ServerInfoToNodeMetadata.java
@@ -0,0 +1,183 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.cloudsigma.domain.Device;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.domain.ServerStatus;
+import org.jclouds.collect.FindResourceInSet;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.NodeState;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.VolumeBuilder;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class ServerInfoToNodeMetadata implements Function {
+ public static final Map serverStatusToNodeState = ImmutableMap
+ . builder().put(ServerStatus.ACTIVE, NodeState.RUNNING)//
+ .put(ServerStatus.STOPPED, NodeState.SUSPENDED)//
+ .put(ServerStatus.PAUSED, NodeState.SUSPENDED)//
+ .put(ServerStatus.DUMPED, NodeState.PENDING)//
+ .put(ServerStatus.DEAD, NodeState.TERMINATED)//
+ .put(ServerStatus.UNRECOGNIZED, NodeState.UNRECOGNIZED)//
+ .build();
+
+ private final Function getImageIdFromServer;
+ private final Function findImageForId;
+ private final Map credentialStore;
+ private final Supplier locationSupplier;
+ private final Function deviceToVolume;
+
+ @Inject
+ ServerInfoToNodeMetadata(Map credentialStore, Function getImageIdFromServer,
+ Function findImageForId, Function deviceToVolume,
+ Supplier locationSupplier) {
+ this.credentialStore = checkNotNull(credentialStore, "credentialStore");
+ this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
+ this.deviceToVolume = checkNotNull(deviceToVolume, "deviceToVolume");
+ this.findImageForId = checkNotNull(findImageForId, "findImageForId");
+ this.getImageIdFromServer = checkNotNull(getImageIdFromServer, "getImageIdFromServer");
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public NodeMetadata apply(ServerInfo from) {
+ NodeMetadataBuilder builder = new NodeMetadataBuilder();
+ builder.ids(from.getUuid());
+ builder.name(from.getName());
+ builder.location(locationSupplier.get());
+ builder.tag(parseTagFromName(from.getName()));
+
+ String imageId = getImageIdFromServer.apply(from);
+ if (imageId != null) {
+ Image image = findImageForId.apply(imageId);
+ if (image != null) {
+ builder.operatingSystem(image.getOperatingSystem());
+ }
+ }
+ builder.hardware(new HardwareBuilder().ids(from.getUuid())
+ .processors(ImmutableList.of(new Processor(1, from.getCpu()))).ram(from.getMem())
+ .volumes((List) ImmutableList.of(Iterables.transform(from.getDevices().values(), deviceToVolume))).build());
+ builder.state(serverStatusToNodeState.get(from.getStatus()));
+ builder.publicAddresses(ImmutableSet. of(from.getVnc().getIp()));
+ builder.privateAddresses(ImmutableSet. of());
+ builder.credentials(credentialStore.get(from.getUuid()));
+ // note sudo password!
+ builder.adminPassword(from.getVnc().getPassword());
+ return builder.build();
+ }
+
+ @Singleton
+ public static final class DeviceToVolume implements Function {
+ private final Map cache;
+
+ @Inject
+ public DeviceToVolume(Map cache) {
+ this.cache = checkNotNull(cache, "cache");
+ }
+
+ @Override
+ public Volume apply(Device input) {
+ VolumeBuilder builder = new VolumeBuilder();
+ builder.id(input.getId());
+ DriveInfo drive = cache.get(input.getDriveUuid());
+ if (drive != null) {
+ builder.size(drive.getSize() / 1024 / 1024f);
+ }
+ return new VolumeBuilder().durable(true).type(Volume.Type.NAS).build();
+ }
+ }
+
+ /**
+ * When we create the boot drive of the server, by convention we set the name to the image it
+ * came from.
+ *
+ * @author Adrian Cole
+ *
+ */
+ @Singleton
+ public static class GetImageIdFromServer implements Function {
+ private final Map cache;
+
+ @Inject
+ public GetImageIdFromServer(Map cache) {
+ this.cache = cache;
+ }
+
+ @Override
+ public String apply(Server from) {
+ String imageId = null;
+ String bootDeviceId = Iterables.get(from.getBootDeviceIds(), 0);
+ Device bootDevice = from.getDevices().get(bootDeviceId);
+ if (bootDevice != null) {
+ try {
+ imageId = cache.get(bootDevice.getDriveUuid()).getName();
+ } catch (NullPointerException e) {
+
+ }
+ }
+ return imageId;
+ }
+ }
+
+ @Singleton
+ public static class FindImageForId extends FindResourceInSet {
+
+ @Inject
+ public FindImageForId(@Memoized Supplier> images) {
+ super(images);
+ }
+
+ @Override
+ public boolean matches(String from, Image input) {
+ return input.getProviderId().equals(from);
+ }
+ }
+
+}
diff --git a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
similarity index 73%
rename from sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
rename to cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
index e935551866..cdd01de601 100644
--- a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
@@ -24,20 +24,22 @@ import java.util.Map;
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
import org.jclouds.cloudsigma.CloudSigmaClient;
-import org.jclouds.cloudsigma.functions.CreateDriveRequestToMap;
+import org.jclouds.cloudsigma.domain.Device;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.DriveMetrics;
+import org.jclouds.cloudsigma.domain.NIC;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerMetrics;
+import org.jclouds.cloudsigma.functions.BaseDriveToMap;
import org.jclouds.cloudsigma.functions.DriveDataToMap;
-import org.jclouds.elasticstack.domain.Device;
-import org.jclouds.elasticstack.domain.Drive;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.DriveMetrics;
-import org.jclouds.elasticstack.domain.NIC;
-import org.jclouds.elasticstack.domain.ServerMetrics;
-import org.jclouds.elasticstack.functions.MapToDevices;
-import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId;
-import org.jclouds.elasticstack.functions.MapToDriveMetrics;
-import org.jclouds.elasticstack.functions.MapToNICs;
-import org.jclouds.elasticstack.functions.MapToServerMetrics;
-import org.jclouds.elasticstack.handlers.ElasticStackErrorHandler;
+import org.jclouds.cloudsigma.functions.MapToDevices;
+import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
+import org.jclouds.cloudsigma.functions.MapToDriveMetrics;
+import org.jclouds.cloudsigma.functions.MapToNICs;
+import org.jclouds.cloudsigma.functions.MapToServerMetrics;
+import org.jclouds.cloudsigma.functions.ServerToMap;
+import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
@@ -64,16 +66,16 @@ public class CloudSigmaRestClientModule extends RestClientModule>>() {
- }).to(CreateDriveRequestToMap.class);
+ }).to(BaseDriveToMap.class);
bind(new TypeLiteral>>() {
}).to(DriveDataToMap.class);
bind(new TypeLiteral, List>>() {
@@ -86,6 +88,8 @@ public class CloudSigmaRestClientModule extends RestClientModule>() {
}).to(DeviceToId.class);
+ bind(new TypeLiteral>>() {
+ }).to(ServerToMap.class);
}
@Override
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java
new file mode 100644
index 0000000000..42ae17cb78
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/BlockDevice.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class BlockDevice extends Device {
+ public static class Builder extends Device.Builder {
+ private final int index;
+
+ public Builder(int index) {
+ this.index = index;
+ }
+
+ @Override
+ public Device build() {
+ return new BlockDevice(uuid, mediaType, index);
+ }
+
+ }
+
+ private final int index;
+
+ public BlockDevice(String driveUuid, MediaType mediaType, int index) {
+ super(driveUuid, mediaType);
+ checkArgument(index >= 0 && index < 8, "index must be between 0 and 7");
+ this.index = index;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + index;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BlockDevice other = (BlockDevice) obj;
+ if (index != other.index)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String getId() {
+ return String.format("block:%d", index);
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java
new file mode 100644
index 0000000000..ccaa572ba1
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ClaimType.java
@@ -0,0 +1,57 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * either 'exclusive' (the default) or 'shared' to allow multiple servers to access a drive
+ * simultaneously
+ *
+ * @author Adrian Cole
+ */
+public enum ClaimType {
+ /**
+ *
+ */
+ EXCLUSIVE,
+ /**
+ * allow multiple servers to access a drive simultaneously
+ */
+ SHARED, UNRECOGNIZED;
+
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static ClaimType fromValue(String claim) {
+ try {
+ return valueOf(checkNotNull(claim, "claim").toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java
new file mode 100644
index 0000000000..4f3987de66
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/CreateDriveRequest.java
@@ -0,0 +1,162 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class CreateDriveRequest extends Drive {
+ public static class Builder extends Drive.Builder {
+
+ private Set avoid = ImmutableSet.of();
+
+ @Nullable
+ private String encryptionCipher;
+
+ public Builder avoid(Iterable avoid) {
+ this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder claimType(ClaimType claimType) {
+ return Builder.class.cast(super.claimType(claimType));
+ }
+
+ public Builder encryptionCipher(String encryptionCipher) {
+ this.encryptionCipher = encryptionCipher;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder name(String name) {
+ return Builder.class.cast(super.name(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder readers(Iterable readers) {
+ return Builder.class.cast(super.readers(readers));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder size(long size) {
+ return Builder.class.cast(super.size(size));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
+ }
+
+ public CreateDriveRequest build() {
+ return new CreateDriveRequest(name, size, claimType, readers, use, encryptionCipher, avoid);
+ }
+ }
+
+ private final Set avoid;
+ @Nullable
+ private final String encryptionCipher;
+
+ public CreateDriveRequest(String name, long size, @Nullable ClaimType claimType, Iterable readers,
+ Iterable use, @Nullable String encryptionCipher, Iterable avoid) {
+ super(null, name, size, claimType, readers, use);
+ this.encryptionCipher = encryptionCipher;
+ this.avoid = ImmutableSet.copyOf(checkNotNull(avoid, "avoid"));
+ }
+
+ /**
+ *
+ * @return list of existing drives to ensure this new drive is created on physical different
+ * hardware than those existing drives
+ */
+ public Set getAvoid() {
+ return avoid;
+ }
+
+ /**
+ *
+ * @return either 'none' or 'aes-xts-plain' (the default)
+ */
+ @Nullable
+ public String getEncryptionCipher() {
+ return encryptionCipher;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((avoid == null) ? 0 : avoid.hashCode());
+ result = prime * result + ((encryptionCipher == null) ? 0 : encryptionCipher.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CreateDriveRequest other = (CreateDriveRequest) obj;
+ if (avoid == null) {
+ if (other.avoid != null)
+ return false;
+ } else if (!avoid.equals(other.avoid))
+ return false;
+ if (encryptionCipher == null) {
+ if (other.encryptionCipher != null)
+ return false;
+ } else if (!encryptionCipher.equals(other.encryptionCipher))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[name=" + name + ", size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", use=" + use
+ + ", avoid=" + avoid + ", encryptionCipher=" + encryptionCipher + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java
new file mode 100644
index 0000000000..13a45b996b
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Device.java
@@ -0,0 +1,108 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public abstract class Device {
+ public static abstract class Builder {
+ protected String uuid;
+ protected MediaType mediaType = MediaType.DISK;
+
+ public Builder mediaType(MediaType mediaType) {
+ this.mediaType = mediaType;
+ return this;
+ }
+
+ public Builder uuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ public abstract Device build();
+ }
+
+ protected final String driveUuid;
+ protected final MediaType mediaType;
+
+ public Device(String driveUuid, MediaType mediaType) {
+ this.driveUuid = checkNotNull(driveUuid, "driveUuid");
+ this.mediaType = checkNotNull(mediaType, "mediaType");
+ }
+
+ /**
+ * id generated based on the device bus, unit, and/or index numbers;
+ */
+ public abstract String getId();
+
+ /**
+ *
+ * @return Drive UUID to connect as specified device.
+ */
+ public String getDriveUuid() {
+ return driveUuid;
+ }
+
+ /**
+ *
+ * @return set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard
+ * disk.
+ */
+ public MediaType getMediaType() {
+ return mediaType;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((driveUuid == null) ? 0 : driveUuid.hashCode());
+ result = prime * result + ((mediaType == null) ? 0 : mediaType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Device other = (Device) obj;
+ if (driveUuid == null) {
+ if (other.driveUuid != null)
+ return false;
+ } else if (!driveUuid.equals(other.driveUuid))
+ return false;
+ if (mediaType != other.mediaType)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java
new file mode 100644
index 0000000000..2b19a03fa4
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Drive.java
@@ -0,0 +1,203 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class Drive extends Item {
+ public static class Builder extends Item.Builder {
+ protected long size;
+ protected ClaimType claimType = ClaimType.EXCLUSIVE;
+ protected Set readers = ImmutableSet.of();
+
+ public Builder claimType(ClaimType claimType) {
+ this.claimType = claimType;
+ return this;
+ }
+
+ public Builder readers(Iterable readers) {
+ this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
+ return this;
+ }
+
+ public Builder size(long size) {
+ this.size = size;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder uuid(String uuid) {
+ return Builder.class.cast(super.uuid(uuid));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder name(String name) {
+ return Builder.class.cast(super.name(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
+ }
+
+ public Drive build() {
+ return new Drive(uuid, name, size, claimType, readers, use);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((claimType == null) ? 0 : claimType.hashCode());
+ result = prime * result + ((readers == null) ? 0 : readers.hashCode());
+ result = prime * result + (int) (size ^ (size >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Builder other = (Builder) obj;
+ if (claimType != other.claimType)
+ return false;
+ if (readers == null) {
+ if (other.readers != null)
+ return false;
+ } else if (!readers.equals(other.readers))
+ return false;
+ if (size != other.size)
+ return false;
+ return true;
+ }
+ }
+
+ protected final long size;
+ protected final ClaimType claimType;
+ protected final Set readers;
+
+ public Drive(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType, Iterable readers,
+ Iterable use) {
+ super(uuid, name, use);
+ this.size = size;
+ this.claimType = checkNotNull(claimType, "set claimType to exclusive, not null");
+ this.readers = ImmutableSet.copyOf(checkNotNull(readers, "readers"));
+ }
+
+ /**
+ *
+ * @return either 'exclusive' (the default) or 'shared' to allow multiple servers to access a
+ * drive simultaneously
+ */
+ @Nullable
+ public ClaimType getClaimType() {
+ return claimType;
+ }
+
+ /**
+ *
+ * @return list of users allowed to read from a drive or 'ffffffff-ffff-ffff-ffff-ffffffffffff'
+ * for all users
+ */
+ public Set getReaders() {
+ return readers;
+ }
+
+ /**
+ *
+ * @return size of drive in bytes
+ */
+ public long getSize() {
+ return size;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((claimType == null) ? 0 : claimType.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((readers == null) ? 0 : readers.hashCode());
+ result = prime * result + (int) (size ^ (size >>> 32));
+ result = prime * result + ((use == null) ? 0 : use.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Drive other = (Drive) obj;
+ if (claimType != other.claimType)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (readers == null) {
+ if (other.readers != null)
+ return false;
+ } else if (!readers.equals(other.readers))
+ return false;
+ if (size != other.size)
+ return false;
+ if (use == null) {
+ if (other.use != null)
+ return false;
+ } else if (!use.equals(other.use))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[uuid=" + uuid + ", name=" + name + ", use=" + use + ", size=" + size + ", claimType=" + claimType
+ + ", readers=" + readers + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java
new file mode 100644
index 0000000000..4504f5f4f7
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveData.java
@@ -0,0 +1,80 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import javax.annotation.Nullable;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class DriveData extends Drive {
+ public static class Builder extends Drive.Builder {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder claimType(ClaimType claimType) {
+ return Builder.class.cast(super.claimType(claimType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder name(String name) {
+ return Builder.class.cast(super.name(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder readers(Iterable readers) {
+ return Builder.class.cast(super.readers(readers));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder size(long size) {
+ return Builder.class.cast(super.size(size));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
+ }
+
+ public DriveData build() {
+ return new DriveData(uuid, name, size, claimType, readers, use);
+ }
+ }
+
+ public DriveData(@Nullable String uuid, String name, long size, @Nullable ClaimType claimType,
+ Iterable readers, Iterable use) {
+ super(uuid, name, size, claimType, readers, use);
+ }
+}
\ No newline at end of file
diff --git a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java
similarity index 61%
rename from sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java
rename to cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java
index ddec88deac..9792cf65e8 100644
--- a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveInfo.java
@@ -22,12 +22,9 @@ package org.jclouds.cloudsigma.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
-import java.util.Map;
import java.util.Set;
-import org.jclouds.elasticstack.domain.ClaimType;
-import org.jclouds.elasticstack.domain.DriveMetrics;
-import org.jclouds.elasticstack.domain.DriveStatus;
+import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
@@ -35,8 +32,17 @@ import com.google.common.collect.ImmutableSet;
*
* @author Adrian Cole
*/
-public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
- public static class Builder extends org.jclouds.elasticstack.domain.DriveInfo.Builder {
+public class DriveInfo extends Drive {
+ public static class Builder extends Drive.Builder {
+
+ protected DriveStatus status;
+ protected String user;
+ protected Set claimed = ImmutableSet.of();
+ @Nullable
+ protected String encryptionCipher;
+ @Nullable
+ protected String imaging;
+ protected DriveMetrics metrics;
private Boolean autoexpanding;
private Integer bits;
private String description;
@@ -48,6 +54,36 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
private DriveType type;
private URI url;
+ public Builder status(DriveStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ public Builder user(String user) {
+ this.user = user;
+ return this;
+ }
+
+ public Builder claimed(Iterable claimed) {
+ this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed"));
+ return this;
+ }
+
+ public Builder imaging(String imaging) {
+ this.imaging = imaging;
+ return this;
+ }
+
+ public Builder metrics(DriveMetrics metrics) {
+ this.metrics = metrics;
+ return this;
+ }
+
+ public Builder encryptionCipher(String encryptionCipher) {
+ this.encryptionCipher = encryptionCipher;
+ return this;
+ }
+
public Builder autoexpanding(Boolean autoexpanding) {
this.autoexpanding = autoexpanding;
return this;
@@ -98,55 +134,6 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
return this;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder status(DriveStatus status) {
- return Builder.class.cast(super.status(status));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder user(String user) {
- return Builder.class.cast(super.user(user));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder claimed(Iterable claimed) {
- return Builder.class.cast(super.claimed(claimed));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder imaging(String imaging) {
- return Builder.class.cast(super.imaging(imaging));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder metrics(DriveMetrics metrics) {
- return Builder.class.cast(super.metrics(metrics));
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder encryptionCipher(String encryptionCipher) {
- return Builder.class.cast(super.encryptionCipher(encryptionCipher));
- }
-
/**
* {@inheritDoc}
*/
@@ -191,24 +178,17 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
* {@inheritDoc}
*/
@Override
- public Builder tags(Iterable tags) {
- return Builder.class.cast(super.tags(tags));
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
}
- /**
- * {@inheritDoc}
- */
- @Override
- public Builder userMetadata(Map userMetadata) {
- return Builder.class.cast(super.userMetadata(userMetadata));
- }
-
- public static Builder fromDriveInfo(org.jclouds.elasticstack.domain.DriveInfo driveInfo) {
- return new Builder().uuid(driveInfo.getUuid()).name(driveInfo.getName()).size(driveInfo.getSize())
- .claimType(driveInfo.getClaimType()).readers(driveInfo.getReaders()).tags(driveInfo.getTags())
- .userMetadata(driveInfo.getUserMetadata()).status(driveInfo.getStatus()).user(driveInfo.getUser())
- .claimed(driveInfo.getClaimed()).encryptionCipher(driveInfo.getEncryptionCipher())
- .imaging(driveInfo.getImaging()).metrics(driveInfo.getMetrics());
+ public static Builder fromDriveInfo(DriveInfo in) {
+ return new Builder().uuid(in.getUuid()).name(in.getName()).size(in.getSize()).claimType(in.getClaimType())
+ .readers(in.getReaders()).use(in.getUse()).status(in.getStatus()).user(in.getUser())
+ .claimed(in.getClaimed()).encryptionCipher(in.getEncryptionCipher()).imaging(in.getImaging())
+ .metrics(in.getMetrics()).autoexpanding(in.getAutoexpanding()).bits(in.getBits())
+ .description(in.getDescription()).encryptionKey(in.getEncryptionKey()).free(in.getFree())
+ .installNotes(in.getInstallNotes()).type(in.getType()).url(in.getUrl());
}
/**
@@ -216,12 +196,21 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
*/
@Override
public DriveInfo build() {
- return new DriveInfo(uuid, name, size, claimType, readers, tags, userMetadata, status, user, claimed,
- encryptionCipher, imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free,
- installNotes, os, type, url);
+ return new DriveInfo(uuid, name, size, claimType, readers, use, status, user, claimed, encryptionCipher,
+ imaging, metrics, autoexpanding, bits, description, driveType, encryptionKey, free, installNotes, os,
+ type, url);
}
+
}
+ protected final DriveStatus status;
+ protected final String user;
+ protected final Set claimed;
+ @Nullable
+ protected final String encryptionCipher;
+ @Nullable
+ protected final String imaging;
+ protected final DriveMetrics metrics;
private final Boolean autoexpanding;
private final Integer bits;
private final String description;
@@ -234,12 +223,17 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
private final URI url;
public DriveInfo(String uuid, String name, long size, ClaimType claimType, Iterable readers,
- Iterable tags, Map userMetadata, DriveStatus status, String user, Set claimed,
- String encryptionCipher, String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits,
- String description, Iterable driveType, String encryptionKey, Boolean free, String installNotes,
- String os, DriveType type, URI url) {
- super(uuid, name, size, claimType, readers, tags, userMetadata, status, user, claimed, encryptionCipher, imaging,
- metrics);
+ Iterable use, DriveStatus status, String user, Set claimed, String encryptionCipher,
+ String imaging, DriveMetrics metrics, Boolean autoexpanding, Integer bits, String description,
+ Iterable driveType, String encryptionKey, Boolean free, String installNotes, String os,
+ DriveType type, URI url) {
+ super(uuid, name, size, claimType, readers, use);
+ this.status = status;
+ this.user = user;
+ this.claimed = ImmutableSet.copyOf(checkNotNull(claimed, "claimed"));
+ this.encryptionCipher = encryptionCipher;
+ this.imaging = imaging;
+ this.metrics = checkNotNull(metrics, "metrics");
this.autoexpanding = autoexpanding;
this.bits = bits;
this.description = description;
@@ -252,80 +246,54 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
this.url = url;
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((autoexpanding == null) ? 0 : autoexpanding.hashCode());
- result = prime * result + ((bits == null) ? 0 : bits.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + ((driveType == null) ? 0 : driveType.hashCode());
- result = prime * result + ((encryptionKey == null) ? 0 : encryptionKey.hashCode());
- result = prime * result + ((free == null) ? 0 : free.hashCode());
- result = prime * result + ((installNotes == null) ? 0 : installNotes.hashCode());
- result = prime * result + ((os == null) ? 0 : os.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((url == null) ? 0 : url.hashCode());
- return result;
+ /**
+ *
+ * @return current status of the drive
+ */
+ public DriveStatus getStatus() {
+ return status;
}
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- DriveInfo other = (DriveInfo) obj;
- if (autoexpanding == null) {
- if (other.autoexpanding != null)
- return false;
- } else if (!autoexpanding.equals(other.autoexpanding))
- return false;
- if (bits == null) {
- if (other.bits != null)
- return false;
- } else if (!bits.equals(other.bits))
- return false;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (driveType == null) {
- if (other.driveType != null)
- return false;
- } else if (!driveType.equals(other.driveType))
- return false;
- if (encryptionKey == null) {
- if (other.encryptionKey != null)
- return false;
- } else if (!encryptionKey.equals(other.encryptionKey))
- return false;
- if (free == null) {
- if (other.free != null)
- return false;
- } else if (!free.equals(other.free))
- return false;
- if (installNotes == null) {
- if (other.installNotes != null)
- return false;
- } else if (!installNotes.equals(other.installNotes))
- return false;
- if (os == null) {
- if (other.os != null)
- return false;
- } else if (!os.equals(other.os))
- return false;
- if (type != other.type)
- return false;
- if (url == null) {
- if (other.url != null)
- return false;
- } else if (!url.equals(other.url))
- return false;
- return true;
+ /**
+ *
+ * @return owner of the drive
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ *
+ * @return if drive is in use by a server, values are the server uuids
+ */
+ public Set getClaimed() {
+ return claimed;
+ }
+
+ /**
+ *
+ * @return either 'none' or 'aes-xts-plain' (the default)
+ */
+ @Nullable
+ public String getEncryptionCipher() {
+ return encryptionCipher;
+ }
+
+ /**
+ *
+ * @return percentage completed of drive imaging if this is underway, or 'queued' if waiting for
+ * another imaging operation to complete first
+ */
+ public String getImaging() {
+ return imaging;
+ }
+
+ /**
+ *
+ * @return i/o and request metrics for read and write ops
+ */
+ public DriveMetrics getMetrics() {
+ return metrics;
}
// TODO
@@ -373,19 +341,124 @@ public class DriveInfo extends org.jclouds.elasticstack.domain.DriveInfo {
return type;
}
- // TODO
-
- @Override
- public String toString() {
- return "[size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", uuid=" + uuid + ", name="
- + name + ", tags=" + tags + ", userMetadata=" + userMetadata + ", autoexpanding=" + autoexpanding
- + ", bits=" + bits + ", description=" + description + ", driveType=" + driveType + ", encryptionKey="
- + encryptionKey + ", free=" + free + ", installNotes=" + installNotes + ", os=" + os + ", type=" + type
- + ", url=" + url + "]";
- }
-
public URI getUrl() {
return url;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((autoexpanding == null) ? 0 : autoexpanding.hashCode());
+ result = prime * result + ((bits == null) ? 0 : bits.hashCode());
+ result = prime * result + ((claimed == null) ? 0 : claimed.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((driveType == null) ? 0 : driveType.hashCode());
+ result = prime * result + ((encryptionCipher == null) ? 0 : encryptionCipher.hashCode());
+ result = prime * result + ((encryptionKey == null) ? 0 : encryptionKey.hashCode());
+ result = prime * result + ((free == null) ? 0 : free.hashCode());
+ result = prime * result + ((imaging == null) ? 0 : imaging.hashCode());
+ result = prime * result + ((installNotes == null) ? 0 : installNotes.hashCode());
+ result = prime * result + ((metrics == null) ? 0 : metrics.hashCode());
+ result = prime * result + ((os == null) ? 0 : os.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + ((url == null) ? 0 : url.hashCode());
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DriveInfo other = (DriveInfo) obj;
+ if (autoexpanding == null) {
+ if (other.autoexpanding != null)
+ return false;
+ } else if (!autoexpanding.equals(other.autoexpanding))
+ return false;
+ if (bits == null) {
+ if (other.bits != null)
+ return false;
+ } else if (!bits.equals(other.bits))
+ return false;
+ if (claimed == null) {
+ if (other.claimed != null)
+ return false;
+ } else if (!claimed.equals(other.claimed))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (driveType == null) {
+ if (other.driveType != null)
+ return false;
+ } else if (!driveType.equals(other.driveType))
+ return false;
+ if (encryptionCipher == null) {
+ if (other.encryptionCipher != null)
+ return false;
+ } else if (!encryptionCipher.equals(other.encryptionCipher))
+ return false;
+ if (encryptionKey == null) {
+ if (other.encryptionKey != null)
+ return false;
+ } else if (!encryptionKey.equals(other.encryptionKey))
+ return false;
+ if (free == null) {
+ if (other.free != null)
+ return false;
+ } else if (!free.equals(other.free))
+ return false;
+ if (imaging == null) {
+ if (other.imaging != null)
+ return false;
+ } else if (!imaging.equals(other.imaging))
+ return false;
+ if (installNotes == null) {
+ if (other.installNotes != null)
+ return false;
+ } else if (!installNotes.equals(other.installNotes))
+ return false;
+ if (metrics == null) {
+ if (other.metrics != null)
+ return false;
+ } else if (!metrics.equals(other.metrics))
+ return false;
+ if (os == null) {
+ if (other.os != null)
+ return false;
+ } else if (!os.equals(other.os))
+ return false;
+ if (status != other.status)
+ return false;
+ if (type != other.type)
+ return false;
+ if (url == null) {
+ if (other.url != null)
+ return false;
+ } else if (!url.equals(other.url))
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[size=" + size + ", claimType=" + claimType + ", readers=" + readers + ", uuid=" + uuid + ", name="
+ + name + ", use=" + use + ", status=" + status + ", user=" + user + ", claimed=" + claimed
+ + ", encryptionCipher=" + encryptionCipher + ", imaging=" + imaging + ", metrics=" + metrics + "]";
+ }
+
}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java
new file mode 100644
index 0000000000..f3f69eda6f
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveMetrics.java
@@ -0,0 +1,139 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class DriveMetrics {
+ public static class Builder {
+ protected long readBytes;
+ protected long readRequests;
+ protected long writeBytes;
+ protected long writeRequests;
+
+ public Builder readBytes(long readBytes) {
+ this.readBytes = readBytes;
+ return this;
+ }
+
+ public Builder readRequests(long readRequests) {
+ this.readRequests = readRequests;
+ return this;
+ }
+
+ public Builder writeBytes(long writeBytes) {
+ this.writeBytes = writeBytes;
+ return this;
+ }
+
+ public Builder writeRequests(long writeRequests) {
+ this.writeRequests = writeRequests;
+ return this;
+ }
+
+ public DriveMetrics build() {
+ return new DriveMetrics(readBytes, readRequests, writeBytes, writeRequests);
+ }
+ }
+
+ protected final long readBytes;
+ protected final long readRequests;
+ protected final long writeBytes;
+ protected final long writeRequests;
+
+ public DriveMetrics(long readBytes, long readRequests, long writeBytes, long writeRequests) {
+ this.readBytes = readBytes;
+ this.readRequests = readRequests;
+ this.writeBytes = writeBytes;
+ this.writeRequests = writeRequests;
+ }
+
+ /**
+ *
+ * @return Cumulative i/o byte/request count for each drive
+ */
+ public long getReadBytes() {
+ return readBytes;
+ }
+
+ /**
+ *
+ * @return Cumulative i/o byte/request count for each drive
+ */
+ public long getReadRequests() {
+ return readRequests;
+ }
+
+ /**
+ *
+ * @return Cumulative i/o byte/request count for each drive
+ */
+ public long getWriteBytes() {
+ return writeBytes;
+ }
+
+ /**
+ *
+ * @return Cumulative i/o byte/request count for each drive
+ */
+ public long getWriteRequests() {
+ return writeRequests;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (readBytes ^ (readBytes >>> 32));
+ result = prime * result + (int) (readRequests ^ (readRequests >>> 32));
+ result = prime * result + (int) (writeBytes ^ (writeBytes >>> 32));
+ result = prime * result + (int) (writeRequests ^ (writeRequests >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ DriveMetrics other = (DriveMetrics) obj;
+ if (readBytes != other.readBytes)
+ return false;
+ if (readRequests != other.readRequests)
+ return false;
+ if (writeBytes != other.writeBytes)
+ return false;
+ if (writeRequests != other.writeRequests)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[readBytes=" + readBytes + ", readRequests=" + readRequests + ", writeBytes=" + writeBytes
+ + ", writeRequests=" + writeRequests + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java
new file mode 100644
index 0000000000..20b47fe597
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveStatus.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public enum DriveStatus {
+ ACTIVE, INACTIVE, COPYING, IMAGING, UNRECOGNIZED;
+
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static DriveStatus fromValue(String status) {
+ try {
+ return valueOf(checkNotNull(status, "status").toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java
similarity index 100%
rename from sandbox/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java
rename to cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/DriveType.java
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java
new file mode 100644
index 0000000000..8dc328a3ea
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/IDEDevice.java
@@ -0,0 +1,98 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class IDEDevice extends Device {
+ public static class Builder extends Device.Builder {
+ private final int bus;
+ private final int unit;
+
+ public Builder(int bus, int unit) {
+ this.bus = bus;
+ this.unit = unit;
+ }
+
+ @Override
+ public Device build() {
+ return new IDEDevice(uuid, mediaType, bus, unit);
+ }
+
+ }
+
+ private final int bus;
+ private final int unit;
+
+ public IDEDevice(String driveUuid, MediaType mediaType, int bus, int unit) {
+ super(driveUuid, mediaType);
+ checkArgument(bus == 0 || bus == 1, "bus must be 0 or 1");
+ checkArgument(unit == 0 || unit == 1, "unit must be 0 or 1");
+ this.bus = bus;
+ this.unit = unit;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + bus;
+ result = prime * result + unit;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ IDEDevice other = (IDEDevice) obj;
+ if (bus != other.bus)
+ return false;
+ if (unit != other.unit)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String getId() {
+ return String.format("ide:%d:%d", bus, unit);
+ }
+
+ public int getBus() {
+ return bus;
+ }
+
+ public int getUnit() {
+ return unit;
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java
new file mode 100644
index 0000000000..ead2748e01
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Item.java
@@ -0,0 +1,170 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class Item {
+ public static class Builder {
+ protected String uuid;
+ protected String name;
+ protected Set use = ImmutableSet.of();
+
+ public Builder uuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder use(Iterable use) {
+ this.use = ImmutableSet.copyOf(checkNotNull(use, "use"));
+ return this;
+ }
+
+ public Item build() {
+ return new Item(uuid, name, use);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((use == null) ? 0 : use.hashCode());
+ result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Builder other = (Builder) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (use == null) {
+ if (other.use != null)
+ return false;
+ } else if (!use.equals(other.use))
+ return false;
+ if (uuid == null) {
+ if (other.uuid != null)
+ return false;
+ } else if (!uuid.equals(other.uuid))
+ return false;
+ return true;
+ }
+ }
+
+ @Nullable
+ protected final String uuid;
+ protected final String name;
+ protected final Set use;
+
+ public Item(@Nullable String uuid, String name, Iterable use) {
+ this.uuid = uuid;
+ this.name = checkNotNull(name, "name");
+ this.use = ImmutableSet.copyOf(checkNotNull(use, "use"));
+ }
+
+ /**
+ *
+ * @return uuid of the item.
+ */
+ @Nullable
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ *
+ * @return name of the item
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @return list of use
+ */
+ public Set getUse() {
+ return use;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((use == null) ? 0 : use.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Item other = (Item) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (use == null) {
+ if (other.use != null)
+ return false;
+ } else if (!use.equals(other.use))
+ return false;
+
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[uuid=" + uuid + ", name=" + name + ", use=" + use + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java
new file mode 100644
index 0000000000..4fd67bb459
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/MediaType.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Media type - set to 'cdrom' to simulate a cdrom, set to 'disk' or leave unset to simulate a hard
+ * disk.
+ *
+ * @author Adrian Cole
+ */
+public enum MediaType {
+ DISK, CDROM, UNRECOGNIZED;
+
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static MediaType fromValue(String type) {
+ try {
+ return valueOf(checkNotNull(type, "type").toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java
new file mode 100644
index 0000000000..cbec34277b
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Model.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public enum Model {
+ E1000, RTl8139, VIRTIO, UNRECOGNIZED;
+
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static Model fromValue(String model) {
+ try {
+ return valueOf(checkNotNull(model, "model").toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java
new file mode 100644
index 0000000000..f19f3d3259
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/NIC.java
@@ -0,0 +1,177 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class NIC {
+ public static class Builder {
+ private String dhcp;
+ private Model model;
+ private String vlan;
+ private String mac;
+ // TODO cloudsigma specific
+ private Set block = ImmutableSet.of();
+
+ public Builder dhcp(String dhcp) {
+ this.dhcp = dhcp;
+ return this;
+ }
+
+ public Builder model(Model model) {
+ this.model = model;
+ return this;
+ }
+
+ public Builder vlan(String vlan) {
+ this.vlan = vlan;
+ return this;
+ }
+
+ public Builder mac(String mac) {
+ this.mac = mac;
+ return this;
+ }
+
+ public Builder block(Iterable block) {
+ this.block = ImmutableSet.copyOf(checkNotNull(block, "block"));
+ return this;
+ }
+
+ public NIC build() {
+ return new NIC(dhcp, model, vlan, mac, block);
+ }
+ }
+
+ private final String dhcp;
+ private final Model model;
+ private final String vlan;
+ private final String mac;
+ private final Set block;
+
+ public NIC(@Nullable String dhcp, Model model, @Nullable String vlan, @Nullable String mac, Iterable block) {
+ this.dhcp = dhcp;
+ this.model = checkNotNull(model, "model");
+ this.vlan = vlan;
+ this.mac = mac;
+ this.block = ImmutableSet.copyOf(checkNotNull(block, "block"));
+ }
+
+ /**
+ *
+ * @return The IP address offered by DHCP to network interface 0. If unset, no address is
+ * offered. Set to 'auto' to allocate a temporary IP at boot.
+ */
+ public String getDhcp() {
+ return dhcp;
+ }
+
+ /**
+ *
+ * @return Create network interface with given type (use 'e1000' as default value; 'rtl8139' or
+ * 'virtio' are also available).
+ */
+ public Model getModel() {
+ return model;
+ }
+
+ /**
+ *
+ * @return The VLAN to which the network interface is attached.
+ */
+ public String getVlan() {
+ return vlan;
+ }
+
+ /**
+ *
+ * @return The MAC address of the network interface. If unset, a randomly generated address is
+ * used. If set, should be unique on the VLAN.
+ */
+ public String getMac() {
+ return mac;
+ }
+
+ // TODO undocumented
+ public Set getBlock() {
+ return block;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((block == null) ? 0 : block.hashCode());
+ result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
+ result = prime * result + ((mac == null) ? 0 : mac.hashCode());
+ result = prime * result + ((model == null) ? 0 : model.hashCode());
+ result = prime * result + ((vlan == null) ? 0 : vlan.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NIC other = (NIC) obj;
+ if (block == null) {
+ if (other.block != null)
+ return false;
+ } else if (!block.equals(other.block))
+ return false;
+ if (dhcp == null) {
+ if (other.dhcp != null)
+ return false;
+ } else if (!dhcp.equals(other.dhcp))
+ return false;
+ if (mac == null) {
+ if (other.mac != null)
+ return false;
+ } else if (!mac.equals(other.mac))
+ return false;
+ if (model != other.model)
+ return false;
+ if (vlan == null) {
+ if (other.vlan != null)
+ return false;
+ } else if (!vlan.equals(other.vlan))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[dhcp=" + dhcp + ", model=" + model + ", vlan=" + vlan + ", mac=" + mac + ", block=" + block + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java
new file mode 100644
index 0000000000..aad202cc56
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/SCSIDevice.java
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class SCSIDevice extends Device {
+ public static class Builder extends Device.Builder {
+ private final int unit;
+
+ public Builder(int unit) {
+ this.unit = unit;
+ }
+
+ @Override
+ public Device build() {
+ return new SCSIDevice(uuid, mediaType, unit);
+ }
+
+ }
+
+ private final int bus = 0;
+ private final int unit;
+
+ public SCSIDevice(String driveUuid, MediaType mediaType, int unit) {
+ super(driveUuid, mediaType);
+ checkArgument(unit >= 0 && unit < 8, "unit must be between 0 and 7");
+ this.unit = unit;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + bus;
+ result = prime * result + unit;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SCSIDevice other = (SCSIDevice) obj;
+ if (bus != other.bus)
+ return false;
+ if (unit != other.unit)
+ return false;
+ return true;
+ }
+
+ public int getBus() {
+ return bus;
+ }
+
+ public int getUnit() {
+ return unit;
+ }
+
+ @Override
+ public String getId() {
+ return String.format("scsi:%d:%d", bus, unit);
+ }
+
+ @Override
+ public String toString() {
+ return "[id=" + getId() + ", driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
+ }
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java
new file mode 100644
index 0000000000..87e026f00c
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/Server.java
@@ -0,0 +1,293 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class Server extends Item {
+
+ public static class Builder extends Item.Builder {
+ protected int cpu;
+ protected Integer smp;
+ protected int mem;
+ protected boolean persistent;
+ protected Map devices = ImmutableMap.of();
+ protected Set bootDeviceIds = ImmutableSet.of();
+ protected List nics = ImmutableList.of();
+ protected VNC vnc;
+ // TODO cloudsigma specific
+ protected String description;
+
+ public Builder cpu(int cpu) {
+ this.cpu = cpu;
+ return this;
+ }
+
+ public Builder smp(Integer smp) {
+ this.smp = smp;
+ return this;
+ }
+
+ public Builder mem(int mem) {
+ this.mem = mem;
+ return this;
+ }
+
+ public Builder persistent(boolean persistent) {
+ this.persistent = persistent;
+ return this;
+ }
+
+ public Builder devices(Map devices) {
+ this.devices = ImmutableMap.copyOf(checkNotNull(devices, "devices"));
+ return this;
+ }
+
+ public Builder bootDeviceIds(Iterable bootDeviceIds) {
+ this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds"));
+ return this;
+ }
+
+ public Builder nics(Iterable nics) {
+ this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics"));
+ return this;
+ }
+
+ public Builder vnc(VNC vnc) {
+ this.vnc = vnc;
+ return this;
+ }
+
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder uuid(String uuid) {
+ return Builder.class.cast(super.uuid(uuid));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder name(String name) {
+ return Builder.class.cast(super.name(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
+ }
+
+ public Server build() {
+ return new Server(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description);
+ }
+
+ public static Builder fromServer(Server in) {
+ return new Builder().uuid(in.getUuid()).name(in.getName()).cpu(in.getCpu()).mem(in.getMem())
+ .persistent(in.isPersistent()).description(in.getDescription()).devices(in.getDevices())
+ .bootDeviceIds(in.getBootDeviceIds()).use(in.getUse()).nics(in.getNics()).vnc(in.getVnc());
+ }
+ }
+
+ protected final int cpu;
+ protected final Integer smp;
+ protected final int mem;
+ protected final boolean persistent;
+ @Nullable
+ protected final Map devices;
+ protected final Set bootDeviceIds;
+ protected final List nics;
+ protected final VNC vnc;
+ @Nullable
+ private final String description;
+
+ public Server(@Nullable String uuid, String name, int cpu, @Nullable Integer smp, int mem, boolean persistent,
+ Map devices, Iterable bootDeviceIds, Iterable use,
+ Iterable nics, VNC vnc, String description) {
+ super(uuid, name, use);
+ this.cpu = cpu;
+ this.smp = smp;
+ this.mem = mem;
+ this.persistent = persistent;
+ this.devices = ImmutableMap.copyOf(checkNotNull(devices, "devices"));
+ this.bootDeviceIds = ImmutableSet.copyOf(checkNotNull(bootDeviceIds, "bootDeviceIds"));
+ this.nics = ImmutableList.copyOf(checkNotNull(nics, "nics"));
+ this.vnc = checkNotNull(vnc, "vnc");
+ this.description = description;
+ }
+
+ /**
+ *
+ * @return CPU quota in core MHz.
+ */
+ public int getCpu() {
+ return cpu;
+ }
+
+ /**
+ *
+ * @return number of virtual processors or null if calculated based on cpu.
+ */
+ public Integer getSmp() {
+ return smp;
+ }
+
+ /**
+ *
+ * @return virtual memory size in MB.
+ */
+ public int getMem() {
+ return mem;
+ }
+
+ /**
+ *
+ * @return 'true' means that server will revert to a 'stopped' status on server stop or shutdown,
+ * rather than being destroyed automatically.
+ */
+ public boolean isPersistent() {
+ return persistent;
+ }
+
+ /**
+ *
+ * @return devices present, mapped by id
+ */
+ public Map getDevices() {
+ return devices;
+ }
+
+ /**
+ *
+ * @return ids of the devices to boot, e.g. ide:0:0 or ide:1:0
+ * @see Device#getId()
+ */
+ public Set getBootDeviceIds() {
+ return bootDeviceIds;
+ }
+
+ public List getNics() {
+ return nics;
+ }
+
+ public VNC getVnc() {
+ return vnc;
+ }
+
+ // TODO undocumented
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((bootDeviceIds == null) ? 0 : bootDeviceIds.hashCode());
+ result = prime * result + cpu;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((devices == null) ? 0 : devices.hashCode());
+ result = prime * result + mem;
+ result = prime * result + ((nics == null) ? 0 : nics.hashCode());
+ result = prime * result + (persistent ? 1231 : 1237);
+ result = prime * result + ((smp == null) ? 0 : smp.hashCode());
+ result = prime * result + ((vnc == null) ? 0 : vnc.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Server other = (Server) obj;
+ if (bootDeviceIds == null) {
+ if (other.bootDeviceIds != null)
+ return false;
+ } else if (!bootDeviceIds.equals(other.bootDeviceIds))
+ return false;
+ if (cpu != other.cpu)
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (devices == null) {
+ if (other.devices != null)
+ return false;
+ } else if (!devices.equals(other.devices))
+ return false;
+ if (mem != other.mem)
+ return false;
+ if (nics == null) {
+ if (other.nics != null)
+ return false;
+ } else if (!nics.equals(other.nics))
+ return false;
+ if (persistent != other.persistent)
+ return false;
+ if (smp == null) {
+ if (other.smp != null)
+ return false;
+ } else if (!smp.equals(other.smp))
+ return false;
+ if (vnc == null) {
+ if (other.vnc != null)
+ return false;
+ } else if (!vnc.equals(other.vnc))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[uuid=" + uuid + ", name=" + name + ", use=" + use + ", cpu=" + cpu + ", smp=" + smp + ", mem=" + mem
+ + ", persistent=" + persistent + ", devices=" + devices + ", bootDeviceIds=" + bootDeviceIds + ", nics="
+ + nics + ", vnc=" + vnc + ", description=" + description + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java
new file mode 100644
index 0000000000..1fcc31f422
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerInfo.java
@@ -0,0 +1,258 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import java.util.Date;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class ServerInfo extends Server {
+
+ public static class Builder extends Server.Builder {
+ protected ServerStatus status;
+ protected Date started;
+ protected String user;
+ protected ServerMetrics metrics;
+
+ public Builder status(ServerStatus status) {
+ this.status = status;
+ return this;
+ }
+
+ public Builder started(Date started) {
+ this.started = started;
+ return this;
+ }
+
+ public Builder user(String user) {
+ this.user = user;
+ return this;
+ }
+
+ public Builder metrics(ServerMetrics metrics) {
+ this.metrics = metrics;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder cpu(int cpu) {
+ return Builder.class.cast(super.cpu(cpu));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder smp(Integer smp) {
+ return Builder.class.cast(super.smp(smp));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder mem(int mem) {
+ return Builder.class.cast(super.mem(mem));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder persistent(boolean persistent) {
+ return Builder.class.cast(super.persistent(persistent));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder devices(Map devices) {
+ return Builder.class.cast(super.devices(devices));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder bootDeviceIds(Iterable bootDeviceIds) {
+ return Builder.class.cast(super.bootDeviceIds(bootDeviceIds));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder nics(Iterable nics) {
+ return Builder.class.cast(super.nics(nics));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder vnc(VNC vnc) {
+ return Builder.class.cast(super.vnc(vnc));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder description(String description) {
+ return Builder.class.cast(super.description(description));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder uuid(String uuid) {
+ return Builder.class.cast(super.uuid(uuid));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder name(String name) {
+ return Builder.class.cast(super.name(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Builder use(Iterable use) {
+ return Builder.class.cast(super.use(use));
+ }
+
+ public ServerInfo build() {
+ return new ServerInfo(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc,
+ description, status, started, user, metrics);
+ }
+ }
+
+ protected final ServerStatus status;
+ @Nullable
+ protected final Date started;
+ @Nullable
+ protected final String user;
+ protected final ServerMetrics metrics;
+
+ public ServerInfo(String uuid, String name, int cpu, Integer smp, int mem, boolean persistent,
+ Map devices, Iterable bootDeviceIds, Iterable use,
+ Iterable nics, VNC vnc, String description, ServerStatus status, Date started, String user,
+ @Nullable ServerMetrics metrics) {
+ super(uuid, name, cpu, smp, mem, persistent, devices, bootDeviceIds, use, nics, vnc, description);
+ this.status = status;
+ this.started = started;
+ this.user = user;
+ this.metrics = metrics;
+ }
+
+ /**
+ *
+ * @return active | stopped | paused | dumped | dead
+ */
+ public ServerStatus getStatus() {
+ return status;
+ }
+
+ // TODO undocumented
+ public Date getStarted() {
+ return started;
+ }
+
+ /**
+ *
+ * @return metrics, if the server is running, or null
+ */
+ @Nullable
+ public ServerMetrics getMetrics() {
+ return metrics;
+ }
+
+ // TODO undocumented
+ /**
+ *
+ * @return owner of the server.
+ */
+ public String getUser() {
+ return user;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((metrics == null) ? 0 : metrics.hashCode());
+ result = prime * result + ((started == null) ? 0 : started.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ServerInfo other = (ServerInfo) obj;
+ if (metrics == null) {
+ if (other.metrics != null)
+ return false;
+ } else if (!metrics.equals(other.metrics))
+ return false;
+ if (started == null) {
+ if (other.started != null)
+ return false;
+ } else if (!started.equals(other.started))
+ return false;
+ if (status != other.status)
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[cpu=" + cpu + ", smp=" + smp + ", mem=" + mem + ", persistent=" + persistent + ", devices=" + devices
+ + ", bootDeviceIds=" + bootDeviceIds + ", nics=" + nics + ", vnc=" + vnc + ", uuid=" + uuid + ", name="
+ + name + ", use=" + use + ", status=" + status + ", started=" + started + ", user=" + user + ", metrics="
+ + metrics + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java
new file mode 100644
index 0000000000..8826bfe0af
--- /dev/null
+++ b/cloudsigma/src/main/java/org/jclouds/cloudsigma/domain/ServerMetrics.java
@@ -0,0 +1,156 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ====================================================================
+ */
+
+package org.jclouds.cloudsigma.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class ServerMetrics {
+
+ public static class Builder {
+ protected long txPackets;
+ protected long tx;
+ protected long rxPackets;
+ protected long rx;
+ protected Map driveMetrics = ImmutableMap.