diff --git a/.gitignore b/.gitignore
index 7c10a8150f..6da66153e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ test-output/
*.iml
*.ipr
*.iws
+TAGS
diff --git a/README.txt b/README.txt
index a547eb6471..a5311e4791 100644
--- a/README.txt
+++ b/README.txt
@@ -30,7 +30,7 @@ our current version is 1.0-beta-9c
our dev version is 1.0-SNAPSHOT
our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), deltacloud,
- cloudservers-uk, vcloud (generic), ec2 (generic), byon,
+ cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova,
trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic),
cloudsigma-zrh, elasticstack(generic), bluelock-vclouddirector,
slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1),
@@ -49,6 +49,11 @@ our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem,
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
to all of these providers
+our loadbalancer api supports: cloudloadbalancers-us
+
+ * note * the pom dependency org.jclouds/jclouds-allloadbalancer gives you access to
+ to all of these providers
+
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova,
azurequeue, simpledb, cloudstack as well as a async-http-client
driver in the sandbox
diff --git a/all/pom.xml b/all/pom.xml
index 51f0aab3ea..6b3864bffc 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -29,6 +29,11 @@
jclouds-all
all
+
+ ${project.groupId}
+ jclouds-allloadbalancer
+ ${project.version}
+
${project.groupId}
jclouds-allcompute
diff --git a/allcompute/pom.xml b/allcompute/pom.xml
index 47cdbc898f..8f41d5f0a8 100644
--- a/allcompute/pom.xml
+++ b/allcompute/pom.xml
@@ -44,6 +44,11 @@
aws-ec2
${project.version}
+
+ org.jclouds.api
+ nova
+ ${project.version}
+
org.jclouds.api
byon
diff --git a/allloadbalancer/pom.xml b/allloadbalancer/pom.xml
new file mode 100644
index 0000000000..895cba5f32
--- /dev/null
+++ b/allloadbalancer/pom.xml
@@ -0,0 +1,38 @@
+
+
+ 4.0.0
+
+ org.jclouds
+ jclouds-project
+ 1.0-SNAPSHOT
+ ../project/pom.xml
+
+ jclouds-allloadbalancer
+ allloadbalancer
+
+
+ org.jclouds.provider
+ cloudloadbalancers-us
+ ${project.version}
+
+
+
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java
index df4a6ade7f..5c4b819203 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindBackupScheduleToJsonPayload.java
@@ -22,9 +22,11 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.util.Map;
+import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
import org.jclouds.cloudservers.domain.BackupSchedule;
import org.jclouds.rest.binders.BindToJsonPayload;
@@ -37,17 +39,19 @@ import com.google.common.collect.ImmutableMap;
*/
@Singleton
public class BindBackupScheduleToJsonPayload extends BindToJsonPayload {
+ @Inject
+ public BindBackupScheduleToJsonPayload(Json jsonBinder) {
+ super(jsonBinder);
+ }
@Override
public R bindToRequest(R request, Map postParams) {
- throw new IllegalStateException(
- "Replace Backup Schedule needs an BackupSchedule object, not a Map");
+ throw new IllegalStateException("Replace Backup Schedule needs an BackupSchedule object, not a Map");
}
@Override
public R bindToRequest(R request, Object toBind) {
- checkArgument(toBind instanceof BackupSchedule,
- "this binder is only valid for BackupSchedules!");
+ checkArgument(toBind instanceof BackupSchedule, "this binder is only valid for BackupSchedules!");
return super.bindToRequest(request, ImmutableMap.of("backupSchedule", toBind));
}
}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
index 4d99b3e9b1..2fb8814686 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
@@ -26,9 +26,12 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.inject.Inject;
+
+import org.jclouds.cloudservers.domain.Addresses;
import org.jclouds.encryption.internal.Base64;
import org.jclouds.http.HttpRequest;
-import org.jclouds.cloudservers.domain.Addresses;
+import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.collect.ImmutableMap;
@@ -40,7 +43,9 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*
*/
-public class CreateServerOptions extends BindToJsonPayload {
+public class CreateServerOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
static class File {
private final String path;
@@ -50,11 +55,9 @@ public class CreateServerOptions extends BindToJsonPayload {
this.path = checkNotNull(path, "path");
this.contents = Base64.encodeBytes(checkNotNull(contents, "contents"));
checkArgument(path.getBytes().length < 255, String.format(
- "maximum length of path is 255 bytes. Path specified %s is %d bytes", path, path
- .getBytes().length));
+ "maximum length of path is 255 bytes. Path specified %s is %d bytes", path, path.getBytes().length));
checkArgument(contents.length < 10 * 1024, String.format(
- "maximum size of the file is 10KB. Contents specified is %d bytes",
- contents.length));
+ "maximum size of the file is 10KB. Contents specified is %d bytes", contents.length));
}
public String getContents() {
@@ -92,10 +95,9 @@ public class CreateServerOptions extends BindToJsonPayload {
@Override
public R bindToRequest(R request, Map postParams) {
- ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"),
- "name parameter not present"), Integer.parseInt(checkNotNull(postParams
- .get("imageId"), "imageId parameter not present")), Integer.parseInt(checkNotNull(
- postParams.get("flavorId"), "flavorId parameter not present")));
+ ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present"),
+ Integer.parseInt(checkNotNull(postParams.get("imageId"), "imageId parameter not present")), Integer
+ .parseInt(checkNotNull(postParams.get("flavorId"), "flavorId parameter not present")));
if (metadata.size() > 0)
server.metadata = metadata;
if (files.size() > 0)
@@ -162,19 +164,15 @@ public class CreateServerOptions extends BindToJsonPayload {
*/
public CreateServerOptions withMetadata(Map metadata) {
checkNotNull(metadata, "metadata");
- checkArgument(metadata.size() <= 5,
- "you cannot have more then 5 metadata values. You specified: " + metadata.size());
+ checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values. You specified: "
+ + metadata.size());
for (Entry entry : metadata.entrySet()) {
checkArgument(entry.getKey().getBytes().length < 255, String.format(
- "maximum length of metadata key is 255 bytes. Key specified %s is %d bytes",
- entry.getKey(), entry.getKey().getBytes().length));
- checkArgument(
- entry.getKey().getBytes().length < 255,
- String
- .format(
- "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes",
- entry.getKey(), entry.getValue(),
- entry.getValue().getBytes().length));
+ "maximum length of metadata key is 255 bytes. Key specified %s is %d bytes", entry.getKey(), entry
+ .getKey().getBytes().length));
+ checkArgument(entry.getKey().getBytes().length < 255, String.format(
+ "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes", entry
+ .getKey(), entry.getValue(), entry.getValue().getBytes().length));
}
this.metadata = metadata;
return this;
@@ -196,8 +194,7 @@ public class CreateServerOptions extends BindToJsonPayload {
* sharedIpGroupId is also supplied.
*/
public CreateServerOptions withSharedIp(String publicIp) {
- checkState(sharedIpGroupId != null,
- "sharedIp is invalid unless a shared ip group is specified.");
+ checkState(sharedIpGroupId != null, "sharedIp is invalid unless a shared ip group is specified.");
this.publicIp = checkNotNull(publicIp, "ip");
return this;
}
@@ -237,4 +234,9 @@ public class CreateServerOptions extends BindToJsonPayload {
}
}
+
+ @Override
+ public R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
index b2d1366eed..7421ab24b0 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
@@ -24,8 +24,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import javax.annotation.Nullable;
+import javax.inject.Inject;
import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.collect.ImmutableMap;
@@ -36,7 +38,10 @@ import com.google.common.collect.ImmutableMap;
* @author Adrian Cole
*
*/
-public class CreateSharedIpGroupOptions extends BindToJsonPayload {
+public class CreateSharedIpGroupOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
Integer serverId;
@SuppressWarnings("unused")
@@ -53,9 +58,8 @@ public class CreateSharedIpGroupOptions extends BindToJsonPayload {
@Override
public R bindToRequest(R request, Map postParams) {
- SharedIpGroupRequest createRequest = new SharedIpGroupRequest(checkNotNull(postParams
- .get("name")), serverId);
- return super.bindToRequest(request, ImmutableMap.of("sharedIpGroup", createRequest));
+ SharedIpGroupRequest createRequest = new SharedIpGroupRequest(checkNotNull(postParams.get("name")), serverId);
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("sharedIpGroup", createRequest));
}
@Override
@@ -84,4 +88,5 @@ public class CreateSharedIpGroupOptions extends BindToJsonPayload {
return options.withServer(id);
}
}
+
}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
index 2c252c7494..3d8f42a91b 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
@@ -22,7 +22,10 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.util.Map;
+import javax.inject.Inject;
+
import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.collect.ImmutableMap;
@@ -34,7 +37,9 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*
*/
-public class RebuildServerOptions extends BindToJsonPayload {
+public class RebuildServerOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
Integer imageId;
@Override
@@ -42,7 +47,7 @@ public class RebuildServerOptions extends BindToJsonPayload {
Map image = Maps.newHashMap();
if (imageId != null)
image.put("imageId", imageId);
- return super.bindToRequest(request, ImmutableMap.of("rebuild", image));
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
}
@Override
diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java
index 35bc8b855c..6ad5fb7088 100644
--- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java
+++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java
@@ -25,6 +25,9 @@ import static org.easymock.classextension.EasyMock.verify;
import java.net.URI;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
@@ -32,7 +35,12 @@ import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.config.RestModule;
import org.testng.annotations.Test;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.inject.AbstractModule;
import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Provides;
/**
* Tests behavior of {@code DeltacloudRedirectionRetry}
@@ -41,6 +49,19 @@ import com.google.inject.Guice;
*/
@Test(groups = "unit")
public class DeltacloudRedirectionRetryHandlerTest {
+ Injector injector = Guice.createInjector(new MockModule(), new RestModule(), new AbstractModule() {
+ @SuppressWarnings("unused")
+ @Provides
+ @Singleton
+ @Named("CONSTANTS")
+ protected Multimap constants() {
+ return LinkedHashMultimap.create();
+ }
+
+ @Override
+ protected void configure() {
+ }
+ });
@Test
public void test302DoesNotRetryOnDelete() {
@@ -53,7 +74,7 @@ public class DeltacloudRedirectionRetryHandlerTest {
replay(command);
- DeltacloudRedirectionRetryHandler retry = Guice.createInjector(new MockModule(), new RestModule()).getInstance(
+ DeltacloudRedirectionRetryHandler retry = injector.getInstance(
DeltacloudRedirectionRetryHandler.class);
assert !retry.shouldRetryRequest(command, response);
@@ -74,7 +95,7 @@ public class DeltacloudRedirectionRetryHandlerTest {
replay(command);
- DeltacloudRedirectionRetryHandler retry = Guice.createInjector(new MockModule(), new RestModule()).getInstance(
+ DeltacloudRedirectionRetryHandler retry = injector.getInstance(
DeltacloudRedirectionRetryHandler.class);
assert !retry.shouldRetryRequest(command, response);
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
index 85b2490c74..7cbbb0dd5a 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java
@@ -42,6 +42,7 @@ import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeService;
+import org.jclouds.compute.internal.PersistNodeCredentials;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
@@ -60,6 +61,7 @@ import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules;
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.ec2.domain.KeyPair;
import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.scriptbuilder.functions.InitAdminAccess;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
@@ -89,13 +91,14 @@ public class EC2ComputeService extends BaseComputeService {
@Named("NODE_RUNNING") Predicate nodeRunning,
@Named("NODE_TERMINATED") Predicate nodeTerminated,
@Named("NODE_SUSPENDED") Predicate nodeSuspended,
- InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, Timeouts timeouts,
+ InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, InitAdminAccess initAdminAccess,
+ PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor, EC2Client ec2Client,
Map credentialsMap, @Named("SECURITY") Map securityGroupMap) {
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getNodeMetadataStrategy,
runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, startNodeStrategy, stopNodeStrategy,
templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
- initScriptRunnerFactory, timeouts, executor);
+ initScriptRunnerFactory, initAdminAccess, persistNodeCredentials, timeouts, executor);
this.ec2Client = ec2Client;
this.credentialsMap = credentialsMap;
this.securityGroupMap = securityGroupMap;
@@ -125,7 +128,8 @@ public class EC2ComputeService extends BaseComputeService {
// when the keypair is unique per group
keyPair.getKeyName().equals("jclouds#" + group)
|| keyPair.getKeyName().matches(String.format("jclouds#%s#%s", group, "[0-9a-f]+"))
- // old keypair pattern too verbose as it has an unnecessary region qualifier
+ // old keypair pattern too verbose as it has an unnecessary
+ // region qualifier
|| keyPair.getKeyName().matches(String.format("jclouds#%s#%s#%s", group, region, "[0-9a-f]+"))) {
Set instancesUsingKeyPair = extractIdsFromInstances(filter(concat(ec2Client.getInstanceServices()
.describeInstancesInRegion(region)), usingKeyPairAndNotDead(keyPair)));
@@ -170,8 +174,8 @@ public class EC2ComputeService extends BaseComputeService {
}
/**
- * like {@link BaseComputeService#destroyNodesMatching} except that this will clean implicit
- * keypairs and security groups.
+ * like {@link BaseComputeService#destroyNodesMatching} except that this will
+ * clean implicit keypairs and security groups.
*/
@Override
public Set extends NodeMetadata> destroyNodesMatching(Predicate filter) {
diff --git a/sandbox-apis/nova/pom.xml b/apis/nova/pom.xml
similarity index 71%
rename from sandbox-apis/nova/pom.xml
rename to apis/nova/pom.xml
index 13e3dda25b..0104b4bd9c 100644
--- a/sandbox-apis/nova/pom.xml
+++ b/apis/nova/pom.xml
@@ -1,150 +1,179 @@
-
-
-
-
- 4.0.0
-
- org.jclouds
- jclouds-project
- 1.0-SNAPSHOT
- ../../project/pom.xml
-
- org.jclouds.api
- nova
- jcloud nova api
- jclouds components to access an implementation of OpenStack Nova
-
-
- https://auth.api.rackspacecloud.com
- 1.1
- FIXME
- FIXME
-
-
-
-
- org.jclouds.common
- openstack-common
- ${project.version}
-
-
- org.jclouds
- jclouds-compute
- ${project.version}
-
-
- org.jclouds
- jclouds-core
- ${project.version}
- test-jar
- test
-
-
- org.jclouds.common
- openstack-common
- ${project.version}
- test-jar
- test
-
-
- org.jclouds
- jclouds-compute
- ${project.version}
- test-jar
- test
-
-
- org.jclouds.driver
- jclouds-jsch
- ${project.version}
- test
-
-
- com.jcraft
- jsch
- test
-
-
- org.jclouds.driver
- jclouds-log4j
- ${project.version}
- test
-
-
- log4j
- log4j
- 1.2.16
- test
-
-
-
-
-
- live
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration
- integration-test
-
- test
-
-
-
-
- test.nova.endpoint
- ${test.nova.endpoint}
-
-
- test.nova.apiversion
- ${test.nova.apiversion}
-
-
- test.nova.identity
- ${test.nova.identity}
-
-
- test.nova.credential
- ${test.nova.credential}
-
-
- test.initializer
- ${test.initializer}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 4.0.0
+
+ org.jclouds
+ jclouds-project
+ 1.0-SNAPSHOT
+ ../../project/pom.xml
+
+ org.jclouds.api
+ nova
+ jcloud nova api
+ jclouds components to access an implementation of OpenStack Nova
+
+
+
+
+
+
+
+ org.jclouds.common
+ openstack-common
+ ${project.version}
+
+
+ org.jclouds
+ jclouds-compute
+ ${project.version}
+
+
+ org.jclouds
+ jclouds-core
+ ${project.version}
+ test-jar
+ test
+
+
+ org.jclouds.common
+ openstack-common
+ ${project.version}
+ test-jar
+ test
+
+
+ org.jclouds
+ jclouds-compute
+ ${project.version}
+ test-jar
+ test
+
+
+ org.jclouds.driver
+ jclouds-jsch
+ ${project.version}
+ test
+
+
+ org.jclouds.driver
+ jclouds-slf4j
+ ${project.version}
+ test
+
+
+ slf4j-api
+ org.slf4j
+ 1.6.1
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ 0.9.28
+ test
+
+
+
+
+
+
+ maven-remote-resources-plugin
+ 1.2
+
+
+ process-remote-resources
+
+
+
+
+
+
+
+
+
+
+ live
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.8.1
+
+
+ org.apache.maven.surefire
+ surefire-testng
+ 2.8.1
+
+
+
+
+ integration
+ integration-test
+
+ test
+
+
+
+
+ test.nova.endpoint
+ ${test.nova.endpoint}
+
+
+ test.nova.apiversion
+ ${test.nova.apiversion}
+
+
+ test.nova.identity
+ ${test.nova.identity}
+
+
+ test.nova.credential
+ ${test.nova.credential}
+
+
+ test.ssh.keyfile.public
+ ${test.ssh.keyfile.public}
+
+
+ test.ssh.keyfile.private
+ ${test.ssh.keyfile.private}
+
+
+ test.initializer
+ ${test.initializer}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java
similarity index 63%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java
index 73bbab0d57..663ade8c32 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java
@@ -18,50 +18,22 @@
*/
package org.jclouds.openstack.nova;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.openstack.nova.binders.BindBackupScheduleToJsonPayload;
-import org.jclouds.openstack.nova.domain.Addresses;
-import org.jclouds.openstack.nova.domain.BackupSchedule;
-import org.jclouds.openstack.nova.domain.Flavor;
-import org.jclouds.openstack.nova.domain.Image;
-import org.jclouds.openstack.nova.domain.RebootType;
-import org.jclouds.openstack.nova.domain.Server;
-import org.jclouds.openstack.nova.domain.SharedIpGroup;
-import org.jclouds.openstack.nova.options.CreateServerOptions;
-import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions;
-import org.jclouds.openstack.nova.options.ListOptions;
-import org.jclouds.openstack.nova.options.RebuildServerOptions;
-import org.jclouds.http.functions.ReturnFalseOn404;
+import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Endpoint;
-import org.jclouds.rest.annotations.ExceptionParser;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.Payload;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SkipEncoding;
-import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.openstack.nova.domain.*;
+import org.jclouds.openstack.nova.options.CreateServerOptions;
+import org.jclouds.openstack.nova.options.ListOptions;
+import org.jclouds.openstack.nova.options.RebuildServerOptions;
+import org.jclouds.rest.annotations.*;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
-import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
-import com.google.common.util.concurrent.ListenableFuture;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
/**
* Provides asynchronous access to OpenStack Nova via their REST API.
@@ -69,13 +41,13 @@ import com.google.common.util.concurrent.ListenableFuture;
* All commands return a ListenableFuture of the result from OpenStack Nova. Any exceptions incurred
* during processing will be wrapped in an {@link ExecutionException} as documented in
* {@link ListenableFuture#get()}.
- *
+ *
+ * @author Adrian Cole
* @see NovaClient
* @see
- * @author Adrian Cole
*/
-@SkipEncoding({ '/', '=' })
-@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class })
+@SkipEncoding({'/', '='})
+@RequestFilters({AuthenticateRequest.class, AddTimestampQuery.class})
@Endpoint(ServerManagement.class)
public interface NovaAsyncClient {
@@ -158,8 +130,8 @@ public interface NovaAsyncClient {
@QueryParams(keys = "format", values = "json")
@Path("/servers")
@MapBinder(CreateServerOptions.class)
- ListenableFuture createServer(@PayloadParam("name") String name, @PayloadParam("imageId") int imageId,
- @PayloadParam("flavorId") int flavorId, CreateServerOptions... options);
+ ListenableFuture createServer(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
+ @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
/**
* @see NovaClient#rebuildServer
@@ -170,33 +142,14 @@ public interface NovaAsyncClient {
@MapBinder(RebuildServerOptions.class)
ListenableFuture rebuildServer(@PathParam("id") int id, RebuildServerOptions... options);
- /**
- * @see NovaClient#shareIp
- */
- @PUT
- @Path("/servers/{id}/ips/public/{address}")
- @Produces(MediaType.APPLICATION_JSON)
- @Payload("%7B\"shareIp\":%7B\"sharedIpGroupId\":{sharedIpGroupId},\"configureServer\":{configureServer}%7D%7D")
- ListenableFuture shareIp(@PathParam("address") String addressToShare,
- @PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup,
- @PayloadParam("configureServer") boolean configureServer);
-
- /**
- * @see NovaClient#unshareIp
- */
- @DELETE
- @Path("/servers/{id}/ips/public/{address}")
- @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
- ListenableFuture unshareIp(@PathParam("address") String addressToShare,
- @PathParam("id") int serverToTosignBindressTo);
/**
* @see NovaClient#changeAdminPass
*/
- @PUT
- @Path("/servers/{id}")
+ @POST
+ @Path("/servers/{id}/action")
@Produces(MediaType.APPLICATION_JSON)
- @Payload("%7B\"server\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
+ @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
ListenableFuture changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass);
/**
@@ -271,76 +224,7 @@ public interface NovaAsyncClient {
@Produces(MediaType.APPLICATION_JSON)
@Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D")
ListenableFuture createImageFromServer(@PayloadParam("name") String imageName,
- @PayloadParam("serverId") int serverId);
-
- /**
- * @see NovaClient#listSharedIpGroups
- */
- @GET
- @Unwrap
- @Consumes(MediaType.APPLICATION_JSON)
- @QueryParams(keys = "format", values = "json")
- @Path("/shared_ip_groups")
- @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
- ListenableFuture extends Set> listSharedIpGroups(ListOptions... options);
-
- /**
- * @see NovaClient#getSharedIpGroup
- */
- @GET
- @Unwrap
- @Consumes(MediaType.APPLICATION_JSON)
- @QueryParams(keys = "format", values = "json")
- @Path("/shared_ip_groups/{id}")
- @ExceptionParser(ReturnNullOnNotFoundOr404.class)
- ListenableFuture getSharedIpGroup(@PathParam("id") int id);
-
- /**
- * @see NovaClient#createSharedIpGroup
- */
- @POST
- @Unwrap
- @Consumes(MediaType.APPLICATION_JSON)
- @QueryParams(keys = "format", values = "json")
- @Path("/shared_ip_groups")
- @MapBinder(CreateSharedIpGroupOptions.class)
- ListenableFuture createSharedIpGroup(@PayloadParam("name") String name,
- CreateSharedIpGroupOptions... options);
-
- /**
- * @see NovaClient#deleteSharedIpGroup
- */
- @DELETE
- @ExceptionParser(ReturnFalseOnNotFoundOr404.class)
- @Path("/shared_ip_groups/{id}")
- ListenableFuture deleteSharedIpGroup(@PathParam("id") int id);
-
- /**
- * @see NovaClient#listBackupSchedule
- */
- @GET
- @Unwrap
- @Consumes(MediaType.APPLICATION_JSON)
- @QueryParams(keys = "format", values = "json")
- @Path("/servers/{id}/backup_schedule")
- ListenableFuture getBackupSchedule(@PathParam("id") int serverId);
-
- /**
- * @see NovaClient#deleteBackupSchedule
- */
- @DELETE
- @ExceptionParser(ReturnFalseOnNotFoundOr404.class)
- @Path("/servers/{id}/backup_schedule")
- ListenableFuture deleteBackupSchedule(@PathParam("id") int serverId);
-
- /**
- * @see NovaClient#replaceBackupSchedule
- */
- @POST
- @ExceptionParser(ReturnFalseOn404.class)
- @Path("/servers/{id}/backup_schedule")
- ListenableFuture replaceBackupSchedule(@PathParam("id") int id,
- @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule);
+ @PayloadParam("serverId") int serverId);
/**
* @see NovaClient#listAddresses
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java
similarity index 72%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java
index 22acaf2ce6..3ed6f04e50 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaClient.java
@@ -26,14 +26,11 @@ import javax.ws.rs.PathParam;
import org.jclouds.concurrent.Timeout;
import org.jclouds.openstack.nova.domain.Addresses;
-import org.jclouds.openstack.nova.domain.BackupSchedule;
import org.jclouds.openstack.nova.domain.Flavor;
import org.jclouds.openstack.nova.domain.Image;
import org.jclouds.openstack.nova.domain.RebootType;
import org.jclouds.openstack.nova.domain.Server;
-import org.jclouds.openstack.nova.domain.SharedIpGroup;
import org.jclouds.openstack.nova.options.CreateServerOptions;
-import org.jclouds.openstack.nova.options.CreateSharedIpGroupOptions;
import org.jclouds.openstack.nova.options.ListOptions;
import org.jclouds.openstack.nova.options.RebuildServerOptions;
import org.jclouds.rest.ResourceNotFoundException;
@@ -154,7 +151,7 @@ public interface NovaClient {
* @param options
* - used to specify extra files, metadata, or ip parameters during server creation.
*/
- Server createServer(String name, int imageId, int flavorId, CreateServerOptions... options);
+ Server createServer(String name, String imageRef, String flavorRef, CreateServerOptions... options);
/**
* The rebuild function removes all data on the server and replaces it with the specified image.
@@ -173,40 +170,6 @@ public interface NovaClient {
*/
void rebuildServer(int id, RebuildServerOptions... options);
- /**
- * /** This operation allows you share an IP address to the specified server
- *
- * This operation shares an IP from an existing server in the specified shared IP group to
- * another specified server in the same group. The operation modifies cloud network restrictions
- * to allow IP traffic for the given IP to/from the server specified.
- *
- *
- * Status Transition: ACTIVE - SHARE_IP - ACTIVE (if configureServer is true) ACTIVE -
- * SHARE_IP_NO_CONFIG - ACTIVE
- *
- * @param configureServer
- *
- * if set to true, the server is configured with the new address, though the address is
- * not enabled. Note that configuring the server does require a reboot.
- *
- * If set to false, does not bind the IP to the server itself. A heartbeat facility
- * (e.g. keepalived) can then be used within the servers to perform health checks and
- * manage IP failover.
- */
- void shareIp(String addressToShare, int serverToTosignBindressTo, int sharedIpGroup,
- boolean configureServer);
-
- /**
- * This operation removes a shared IP address from the specified server.
- *
- * Status Transition: ACTIVE - DELETE_IP - ACTIVE
- *
- * @param addressToShare
- * @param serverToTosignBindressTo
- * @return
- */
- void unshareIp(String addressToShare, int serverToTosignBindressTo);
-
/**
* This operation allows you to change the administrative password.
*
@@ -295,66 +258,6 @@ public interface NovaClient {
*/
Image createImageFromServer(String imageName, int serverId);
- /**
- *
- * List shared IP groups (IDs and names only)
- *
- * in order to retrieve all details, pass the option {@link ListOptions#withDetails()
- * withDetails()}
- */
- Set listSharedIpGroups(ListOptions... options);
-
- /**
- *
- * This operation returns details of the specified shared IP group.
- *
- * @return null, if the shared ip group is not found
- *
- * @see SharedIpGroup
- */
- SharedIpGroup getSharedIpGroup(int id);
-
- /**
- * This operation creates a new shared IP group. Please note, all responses to requests for
- * shared_ip_groups return an array of servers. However, on a create request, the shared IP group
- * can be created empty or can be initially populated with a single server. Use
- * {@link CreateSharedIpGroupOptions} to specify an server.
- */
- SharedIpGroup createSharedIpGroup(String name, CreateSharedIpGroupOptions... options);
-
- /**
- * This operation deletes the specified shared IP group. This operation will ONLY succeed if 1)
- * there are no active servers in the group (i.e. they have all been terminated) or 2) no servers
- * in the group are actively sharing IPs.
- *
- * @return false if the shared ip group is not found
- * @see SharedIpGroup
- */
- boolean deleteSharedIpGroup(int id);
-
- /**
- * List the backup schedule for the specified server
- *
- * @throws ResourceNotFoundException
- * , if the server doesn't exist
- */
- BackupSchedule getBackupSchedule(int serverId);
-
- /**
- * Delete backup schedule for the specified server.
- *
- * Web Hosting #119571 currently disables the schedule, not deletes it.
- *
- * @return false if the schedule is not found
- */
- boolean deleteBackupSchedule(int serverId);
-
- /**
- * Enable/update the backup schedule for the specified server
- *
- */
- void replaceBackupSchedule(int id, BackupSchedule backupSchedule);
-
/**
* List all server addresses
*
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java
diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java
new file mode 100644
index 0000000000..8e98a04fcd
--- /dev/null
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright (C) 2011 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.openstack.nova;
+
+import org.jclouds.PropertiesBuilder;
+
+import java.util.Properties;
+
+import static org.jclouds.Constants.PROPERTY_API_VERSION;
+
+/**
+ * Builds properties used in Openstack Nova Clients
+ *
+ * @author Dmitri Babaev
+ */
+public class NovaPropertiesBuilder extends PropertiesBuilder {
+ @Override
+ protected Properties defaultProperties() {
+ Properties properties = super.defaultProperties();
+ properties.setProperty(PROPERTY_API_VERSION, "1.1");
+ return properties;
+ }
+
+ public NovaPropertiesBuilder(Properties properties) {
+ super(properties);
+ }
+
+ public NovaPropertiesBuilder() {
+ super();
+ }
+}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/ServerManagement.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/ServerManagement.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/ServerManagement.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/ServerManagement.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeStrategiesByClass.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeStrategiesByClass.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeStrategiesByClass.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeStrategiesByClass.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeSuppliersByClass.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeSuppliersByClass.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeSuppliersByClass.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaBindComputeSuppliersByClass.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java
similarity index 90%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java
index acd932d565..234b2971bc 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceDependenciesModule.java
@@ -89,19 +89,11 @@ public class NovaComputeServiceDependenciesModule extends AbstractModule {
.put(ServerStatus.PREP_RESIZE, NodeState.PENDING)//
.put(ServerStatus.RESIZE, NodeState.PENDING)//
.put(ServerStatus.VERIFY_RESIZE, NodeState.PENDING)//
- .put(ServerStatus.QUEUE_MOVE, NodeState.PENDING)//
- .put(ServerStatus.PREP_MOVE, NodeState.PENDING)//
- .put(ServerStatus.MOVE, NodeState.PENDING)//
- .put(ServerStatus.VERIFY_MOVE, NodeState.PENDING)//
.put(ServerStatus.RESCUE, NodeState.PENDING)//
- .put(ServerStatus.ERROR, NodeState.ERROR)//
.put(ServerStatus.BUILD, NodeState.PENDING)//
- .put(ServerStatus.RESTORING, NodeState.PENDING)//
.put(ServerStatus.PASSWORD, NodeState.PENDING)//
.put(ServerStatus.REBUILD, NodeState.PENDING)//
.put(ServerStatus.DELETE_IP, NodeState.PENDING)//
- .put(ServerStatus.SHARE_IP_NO_CONFIG, NodeState.PENDING)//
- .put(ServerStatus.SHARE_IP, NodeState.PENDING)//
.put(ServerStatus.REBOOT, NodeState.PENDING)//
.put(ServerStatus.HARD_REBOOT, NodeState.PENDING)//
.put(ServerStatus.UNKNOWN, NodeState.UNRECOGNIZED)//
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java
similarity index 86%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java
index 8f5064a61b..f166754303 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/FlavorToHardware.java
@@ -36,8 +36,13 @@ import com.google.common.collect.ImmutableList;
@Singleton
public class FlavorToHardware implements Function {
public Hardware apply(Flavor from) {
- return new HardwareBuilder().ids(from.getId() + "").name(from.getName())
- .processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0))).ram(from.getRam())
- .volumes(ImmutableList. of(new VolumeImpl((float) from.getDisk(), true, true))).build();
+ return new HardwareBuilder()
+ .ids(from.getId() + "")
+ .name(from.getName())
+ .processors(ImmutableList.of(new Processor(from.getDisk() / 10.0, 1.0)))
+ .ram(from.getRam())
+ .volumes(ImmutableList. of(new VolumeImpl((float) from.getDisk(), true, true)))
+ .uri(from.getURI())
+ .build();
}
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java
similarity index 86%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java
index 23660c95d4..e606c5b13a 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/functions/NovaImageToImage.java
@@ -44,11 +44,12 @@ public class NovaImageToImage implements Function {
@Override
public boolean apply(Image input) {
- return input.getProviderId().equals(instance.getImageId() + "");
+ return input.getUri().toString().equals(instance.getImageRef() + "");
}
}
@@ -88,14 +82,14 @@ public class ServerToNodeMetadata implements Function {
@Override
public boolean apply(Hardware input) {
- return input.getProviderId().equals(instance.getFlavorId() + "");
+ return input.getUri().toString().equals(instance.getFlavorRef() + "");
}
}
@Inject
ServerToNodeMetadata(Map serverStateToNodeState, Map credentialStore,
- @Memoized Supplier> images, Supplier location,
- @Memoized Supplier> hardwares) {
+ @Memoized Supplier> images, Supplier location,
+ @Memoized Supplier> hardwares) {
this.serverToNodeState = checkNotNull(serverStateToNodeState, "serverStateToNodeState");
this.credentialStore = checkNotNull(credentialStore, "credentialStore");
this.images = checkNotNull(images, "images");
@@ -109,16 +103,20 @@ public class ServerToNodeMetadata implements Function {
builder.ids(from.getId() + "");
builder.name(from.getName());
builder.location(new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()).description(
- from.getHostId()).parent(location.get()).build());
+ from.getHostId()).parent(location.get()).build());
builder.userMetadata(from.getMetadata());
builder.group(parseGroupFromName(from.getName()));
- builder.imageId(from.getImageId() + "");
- builder.operatingSystem(parseOperatingSystem(from));
+ Image image = parseImage(from);
+ if (image != null) {
+ builder.imageId(image.getId());
+ builder.operatingSystem(image.getOperatingSystem());
+ }
builder.hardware(parseHardware(from));
builder.state(serverToNodeState.get(from.getStatus()));
- builder.publicAddresses(from.getAddresses().getPublicAddresses());
- builder.privateAddresses(from.getAddresses().getPrivateAddresses());
+ builder.publicAddresses(Iterables.transform(from.getAddresses().getPublicAddresses(), Address.newAddress2StringFunction()));
+ builder.privateAddresses(Iterables.transform(from.getAddresses().getPrivateAddresses(), Address.newAddress2StringFunction()));
builder.credentials(credentialStore.get("node#" + from.getId()));
+ builder.uri(from.getURI());
return builder.build();
}
@@ -130,10 +128,10 @@ public class ServerToNodeMetadata implements Function {
}
return null;
}
-
- protected OperatingSystem parseOperatingSystem(Server from) {
+
+ protected Image parseImage(Server from) {
try {
- return Iterables.find(images.get(), new FindImageForServer(from)).getOperatingSystem();
+ return Iterables.find(images.get(), new FindImageForServer(from));
} catch (NoSuchElementException e) {
logger.warn("could not find a matching image for server %s in location %s", from, location);
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java
similarity index 92%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java
index 71e37bbb16..5cb3b1fa5a 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaCreateNodeWithGroupEncodedIntoName.java
@@ -53,8 +53,7 @@ public class NovaCreateNodeWithGroupEncodedIntoName implements CreateNodeWithGro
@Override
public NodeMetadata createNodeWithGroupEncodedIntoName(String group, String name, Template template) {
- Server from = client.createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer
- .parseInt(template.getHardware().getProviderId()));
+ Server from = client.createServer(name, template.getImage().getId(), template.getHardware().getId());
credentialStore.put("node#" + from.getId(), new Credentials("root", from.getAdminPass()));
return serverToNodeMetadata.apply(from);
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaDestroyNodeStrategy.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaDestroyNodeStrategy.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaDestroyNodeStrategy.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaDestroyNodeStrategy.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaGetNodeMetadataStrategy.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaGetNodeMetadataStrategy.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaGetNodeMetadataStrategy.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaGetNodeMetadataStrategy.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java
similarity index 97%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java
index 79a552cd27..41a0c3873b 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaLifeCycleStrategy.java
@@ -47,7 +47,7 @@ public class NovaLifeCycleStrategy implements RebootNodeStrategy, SuspendNodeStr
public NodeMetadata rebootNode(String id) {
int serverId = Integer.parseInt(id);
// if false server wasn't around in the first place
- client.rebootServer(serverId, RebootType.HARD);
+ client.rebootServer(serverId, RebootType.SOFT);
return getNode.getNode(id);
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaListNodesStrategy.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaListNodesStrategy.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaListNodesStrategy.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/strategy/NovaListNodesStrategy.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaHardwareSupplier.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaHardwareSupplier.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaHardwareSupplier.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaHardwareSupplier.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaImageSupplier.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaImageSupplier.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaImageSupplier.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/compute/suppliers/NovaImageSupplier.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/AbsoluteLimit.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/AbsoluteLimit.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/AbsoluteLimit.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/AbsoluteLimit.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Action.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Action.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Action.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Action.java
diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Address.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Address.java
new file mode 100644
index 0000000000..ce2908a29a
--- /dev/null
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Address.java
@@ -0,0 +1,98 @@
+/**
+ *
+ * Copyright (C) 2011 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.openstack.nova.domain;
+
+import com.google.common.base.Function;
+import com.google.gson.annotations.SerializedName;
+
+import javax.annotation.Nullable;
+
+/**
+ * @author Dmitri Babaev
+ */
+public class Address {
+ @SerializedName("addr")
+ private String address;
+ private int version;
+
+ //for de-serialization
+ @SuppressWarnings("unused")
+ private Address() {
+ }
+
+ public Address(String address, int version) {
+ this.address = address;
+ this.version = version;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ @Override
+ public String toString() {
+ return address;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Address address1 = (Address) o;
+
+ if (version != address1.version) return false;
+ if (address != null ? !address.equals(address1.address) : address1.address != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = address != null ? address.hashCode() : 0;
+ result = 31 * result + version;
+ return result;
+ }
+
+ public static Function newAddress2StringFunction() {
+ return new Function() {
+ @Override
+ public String apply(@Nullable Address input) {
+ return input.getAddress();
+ }
+ };
+ }
+
+ public static Address valueOf(String address) {
+ return new Address(address, address.startsWith("::") ? 6 : 4);
+ }
+
+ public static Function newString2AddressFunction() {
+ return new Function() {
+ @Override
+ public Address apply(@Nullable String input) {
+ return valueOf(input);
+ }
+ };
+ }
+}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java
similarity index 85%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java
index 02cdc9f6e0..478808f156 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Addresses.java
@@ -30,31 +30,31 @@ import com.google.gson.annotations.SerializedName;
public class Addresses {
@SerializedName("public")
- private Set publicAddresses = Sets.newLinkedHashSet();
+ private Set publicAddresses = Sets.newLinkedHashSet();
@SerializedName("private")
- private Set privateAddresses = Sets.newLinkedHashSet();
+ private Set privateAddresses = Sets.newLinkedHashSet();
public Addresses() {
}
- public Addresses(Set publicAddresses, Set privateAddresses) {
+ public Addresses(Set publicAddresses, Set privateAddresses) {
this.publicAddresses = publicAddresses;
this.privateAddresses = privateAddresses;
}
- public void setPublicAddresses(Set publicAddresses) {
+ public void setPublicAddresses(Set publicAddresses) {
this.publicAddresses = publicAddresses;
}
- public Set getPublicAddresses() {
+ public Set getPublicAddresses() {
return publicAddresses;
}
- public void setPrivateAddresses(Set privateAddresses) {
+ public void setPrivateAddresses(Set privateAddresses) {
this.privateAddresses = privateAddresses;
}
- public Set getPrivateAddresses() {
+ public Set getPrivateAddresses() {
return privateAddresses;
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java
similarity index 98%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java
index b0f9cb2b1b..94ab5c61cf 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Flavor.java
@@ -25,7 +25,7 @@ package org.jclouds.openstack.nova.domain;
*
* @author Adrian Cole
*/
-public class Flavor {
+public class Flavor extends Resource {
public Flavor() {
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java
similarity index 77%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java
index a98eeeecf9..8a3934ee6d 100644
--- a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Image.java
@@ -18,26 +18,41 @@
*/
package org.jclouds.openstack.nova.domain;
+import com.google.common.collect.Maps;
+
+import java.util.Collections;
import java.util.Date;
+import java.util.Map;
/**
* An image is a collection of files used to create or rebuild a server. Rackspace provides a number
* of pre-built OS images by default. You may also create custom images from cloud servers you have
* launched. These custom images are useful for backup purposes or for producing gold server images
* if you plan to deploy a particular server configuration frequently.
- *
+ *
* @author Adrian Cole
*/
-public class Image {
+public class Image extends Resource {
- private Date created;
private int id;
private String name;
private Integer progress;
- private Integer serverId;
+ private String serverRef;
private ImageStatus status;
+ private Map metadata = Maps.newHashMap();
+
+ private Date created;
private Date updated;
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getUpdated() {
+ return updated;
+ }
+
+
public Image() {
}
@@ -46,13 +61,6 @@ public class Image {
this.name = name;
}
- public void setCreated(Date created) {
- this.created = created;
- }
-
- public Date getCreated() {
- return created;
- }
public void setId(int id) {
this.id = id;
@@ -78,12 +86,12 @@ public class Image {
return progress;
}
- public void setServerId(Integer serverId) {
- this.serverId = serverId;
+ public void setServerRef(String serverRef) {
+ this.serverRef = serverRef;
}
- public Integer getServerId() {
- return serverId;
+ public String getServerRef() {
+ return serverRef;
}
public void setStatus(ImageStatus status) {
@@ -94,15 +102,17 @@ public class Image {
return status;
}
- public void setUpdated(Date updated) {
- this.updated = updated;
+
+ public Map getMetadata() {
+ return Collections.unmodifiableMap(metadata);
}
- public Date getUpdated() {
- return updated;
+ public void setMetadata(Map metadata) {
+ this.metadata = Maps.newHashMap(metadata);
}
+
/**
- * note that this ignores the create time
+ * note that this ignores some fields
*/
@Override
public int hashCode() {
@@ -110,12 +120,12 @@ public class Image {
int result = 1;
result = prime * result + id;
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((serverId == null) ? 0 : serverId.hashCode());
+ result = prime * result + ((serverRef == null) ? 0 : serverRef.hashCode());
return result;
}
/**
- * note that this ignores the serverid and create time.
+ * note that this ignores some fields
*/
@Override
public boolean equals(Object obj) {
@@ -138,8 +148,8 @@ public class Image {
@Override
public String toString() {
- return "Image [created=" + created + ", id=" + id + ", name=" + name + ", serverId="
- + serverId + "]";
+ return "Image [created=" + getCreated() + ", id=" + id + ", name=" + name + ", serverRef="
+ + serverRef + "]";
}
}
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/ImageStatus.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/ImageStatus.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/ImageStatus.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/ImageStatus.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Limits.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Limits.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Limits.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Limits.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimit.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimit.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimit.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimit.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimitUnit.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimitUnit.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimitUnit.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RateLimitUnit.java
diff --git a/sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RebootType.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RebootType.java
similarity index 100%
rename from sandbox-apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RebootType.java
rename to apis/nova/src/main/java/org/jclouds/openstack/nova/domain/RebootType.java
diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java
new file mode 100644
index 0000000000..ed415c03dd
--- /dev/null
+++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/Resource.java
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright (C) 2011 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.openstack.nova.domain;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.base.Functions;
+import com.google.common.collect.Lists;
+
+/**
+ * @author Dmitri Babaev
+ */
+public class Resource {
+
+ private List