diff --git a/README.md b/README.md
index 4e7adae00e..6f56e4eab7 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ jclouds
======
jclouds allows provisioning and control of cloud resources, including blobstore
and compute, from Java and Clojure. Our API gives allows developers to use
-both portable abstractions and cloud-specific features. We test support of 30
+both portable abstractions and cloud-specific features. We test support of dozens of
cloud providers and cloud software stacks, including Amazon, Azure, GoGrid,
Ninefold, OpenStack, and vCloud. jclouds is licensed under the Apache License,
Version 2.0
@@ -107,7 +107,7 @@ Check out https://github.com/jclouds/jclouds-examples for more examples!
Downloads
------------------------
-* release notes: http://www.jclouds.org/documentation/releasenotes/1.3
+* release notes: http://www.jclouds.org/documentation/releasenotes/1.5
* installation guide: http://www.jclouds.org/documentation/userguide/installation-guide
* maven repo: http://repo2.maven.org/maven2 (maven central - the default repository)
* snapshot repo: https://oss.sonatype.org/content/repositories/snapshots
@@ -116,8 +116,6 @@ Resources
----------------------------
* Project page: http://jclouds.org/
* Documentation: http://www.jclouds.org/documentation/index
-* Javadocs (1.1.0): http://jclouds.rimuhosting.com/apidocs/
-* Javadocs (1.0-SNAPSHOT): http://jclouds.rimuhosting.com/apidocs-SNAPSHOT/
* Community: http://www.jclouds.org/documentation/reference/apps-that-use-jclouds
* User group: http://groups.google.com/group/jclouds
* Dev group: http://groups.google.com/group/jclouds-dev
@@ -128,4 +126,4 @@ License
-------
Copyright (C) 2009-2012 jclouds, Inc.
-Licensed under the Apache License, Version 2.0
\ No newline at end of file
+Licensed under the Apache License, Version 2.0
diff --git a/README.txt b/README.txt
deleted file mode 100644
index c765ebaf56..0000000000
--- a/README.txt
+++ /dev/null
@@ -1,136 +0,0 @@
-Overview:
-
-jclouds allows provisioning and control of cloud resources, including blobstore
-and compute, from Java and Clojure. Our API gives allows developers to use
-both portable abstractions and cloud-specific features. We test support of 30
-cloud providers and cloud software stacks, including Amazon, Azure, GoGrid,
-Ninefold, OpenStack, and vCloud. jclouds is licensed under the Apache License,
-Version 2.0
-
-our current version is 1.4.2
-our next maintenance version is 1.4.2-SNAPSHOT
-our dev version is 1.5.0-SNAPSHOT
-
-check out our examples site! https://github.com/jclouds/jclouds-examples
-
-our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory), deltacloud,
- cloudservers-uk, vcloud (generic), ec2 (generic), byon, nova,
- trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic)
- cloudsigma-zrh, elasticstack(generic), go2cloud-jhb1, cloudsigma-lvs,
- bluelock-vcloud-zone01, stratogen-vcloud-mycloud, rimuhosting,
- slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1),
- elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare),
- openhosting-east1, serverlove-z1-man, skalicloud-sdg-my,
- greenhousedata-element-vcloud, softlayer, cloudsigma (generic),
- cloudstack (generic), ninefold-compute, openstack-nov (keystone),
- hpcloud-compute, trystack-nova, openstack-nova-ec2,
- rackspace-cloudservers-us (next gen), rackspace-cloudservers-uk (next gen)
-
- * note * the pom dependency org.jclouds/jclouds-allcompute gives you access to
- to all of these providers
-
-our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem,
- azureblob, atmos (generic), synaptic-storage, hpcloud-objectstorage,
- cloudonestorage, walrus(generic), ninefold-storage,
- eucalyptus-partnercloud-s3, swift (generic), transient (in-mem)
-
- * 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 aws-cloudwatch support.
-
-we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, openstack nova, scality ring,
- hosteurope-storage, tiscali-storage, scaleup-storage, googlestorage,
- azurequeue, simpledb, as well as a async-http-client
- driver in the sandbox
-
-
-If you want access to all jclouds components, include the maven dependency org.jclouds/jclouds-all
-
-
-BlobStore Example (Java):
- // init
- context = new BlobStoreContextFactory().createContext(
- "aws-s3",
- accesskeyid,
- secretaccesskey);
- blobStore = context.getBlobStore();
-
- // create container
- blobStore.createContainerInLocation(null, "mycontainer");
-
- // add blob
- blob = blobStore.blobBuilder("test").payload("testdata").build();
- blobStore.putBlob("mycontainer", blob);
-
-BlobStore Example (Clojure):
- (use 'org.jclouds.blobstore2)
-
- (def *blobstore* (blobstore "azureblob" account encodedkey))
- (create-container *blobstore* "mycontainer")
- (put-blob *blobstore* "mycontainer" (blob "test" :payload "testdata"))
-
-Compute Example (Java):
- // init
- context = new ComputeServiceContextFactory().createContext(
- "aws-ec2",
- accesskeyid,
- secretaccesskey,
- ImmutableSet.of(new Log4JLoggingModule(),
- new SshjSshClientModule()));
- client = context.getComputeService();
-
- // define the requirements of your node
- template = client.templateBuilder().osFamily(UBUNTU).smallest().build();
-
- // setup a boot user which is the same as your login
- template.getOptions().runScript(AdminAccess.standard());
-
- // these nodes will be accessible via ssh when the call returns
- nodes = client.createNodesInGroup("mycluster", 2, template);
-
- // you can now run ad-hoc commands on the nodes based on predicates
- responses = client.runScriptOnNodesMatching(inGroup("mycluster"), "uptime",
- wrapInInitScript(false));
-
-Compute Example (Clojure):
- (use 'org.jclouds.compute2)
-
- ; create a compute service using sshj and log4j extensions
- (def compute
- (*compute* "trmk`-ecloud" "user" "password" :sshj :log4j))
-
- ; launch a couple nodes with the default operating system, installing your user.
- (create-nodes *compute* "mycluster" 2
- (TemplateOptions$Builder/runScript (AdminAccess/standard)))
-
- ; run a command on that group
- (run-script-on-nodes-matching *compute* (in-group? "mycluster") "uptime"
- (RunScriptOptions$Builder/wrapInInitScript false))
-
-Downloads:
- * release notes: http://www.jclouds.org/documentation/releasenotes/1.3
- * installation guide: http://www.jclouds.org/documentation/userguide/installation-guide
- * maven repo: http://repo2.maven.org/maven2 (maven central - the default repository)
- * snapshot repo: https://oss.sonatype.org/content/repositories/snapshots
-
-Links:
- * project page: http://jclouds.org/
- * documentation: http://www.jclouds.org/documentation/index
- * javadocs (1.1.0): http://jclouds.rimuhosting.com/apidocs/
- * javadocs (1.0-SNAPSHOT): http://jclouds.rimuhosting.com/apidocs-SNAPSHOT/
- * community: http://www.jclouds.org/documentation/reference/apps-that-use-jclouds
- * user group: http://groups.google.com/group/jclouds
- * dev group: http://groups.google.com/group/jclouds-dev
- * twitter: http://twitter.com/jclouds
-
-## License
-
-Copyright (C) 2009-2012 jclouds, Inc.
-
-Licensed under the Apache License, Version 2.0
diff --git a/all/pom.xml b/all/pom.xml
index c0ed79dfd8..3e97bbd5ea 100644
--- a/all/pom.xml
+++ b/all/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../project/pom.xmljclouds-all
@@ -40,6 +40,11 @@
aws-cloudwatch${project.version}
+
+ org.jclouds.provider
+ aws-sqs
+ ${project.version}
+ ${project.groupId}jclouds-allloadbalancer
diff --git a/allblobstore/pom.xml b/allblobstore/pom.xml
index 42485cecdf..d0965c84df 100644
--- a/allblobstore/pom.xml
+++ b/allblobstore/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../project/pom.xmljclouds-allblobstore
diff --git a/allcompute/pom.xml b/allcompute/pom.xml
index c36fd74dbb..4039b2c67d 100644
--- a/allcompute/pom.xml
+++ b/allcompute/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../project/pom.xmljclouds-allcompute
diff --git a/allloadbalancer/pom.xml b/allloadbalancer/pom.xml
index 8d1e2faef5..26cedd4aaf 100644
--- a/allloadbalancer/pom.xml
+++ b/allloadbalancer/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../project/pom.xmljclouds-allloadbalancer
diff --git a/antcontrib/pom.xml b/antcontrib/pom.xml
deleted file mode 100644
index 9d0a6176d3..0000000000
--- a/antcontrib/pom.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
- 4.0.0
-
- org.jclouds
- jclouds-project
- 1.5.0-SNAPSHOT
- ../project/pom.xml
-
- jclouds-antcontrib
- Ant-Contrib extensions
-
-
-
-
-
- ${project.groupId}
- jclouds-scriptbuilder
- ${project.version}
-
-
- ${project.groupId}
- jclouds-compute
- ${project.version}
-
-
- org.apache.ant
- ant
- 1.7.1
- provided
-
-
- org.apache.ant
- ant-jsch
- 1.7.1
-
-
- org.jclouds.driver
- jclouds-jsch
- ${project.version}
-
-
- com.jcraft
- jsch
-
-
-
-
- ${project.artifactId}
-
-
-
- maven-assembly-plugin
-
-
- package
-
- single
-
-
-
- jar-with-dependencies
-
-
-
-
-
-
-
-
-
diff --git a/antcontrib/samples/compute/build.xml b/antcontrib/samples/compute/build.xml
deleted file mode 100644
index f473fa8941..0000000000
--- a/antcontrib/samples/compute/build.xml
+++ /dev/null
@@ -1,183 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/antcontrib/samples/javaoverssh/README.txt b/antcontrib/samples/javaoverssh/README.txt
deleted file mode 100644
index a5e1c4c05a..0000000000
--- a/antcontrib/samples/javaoverssh/README.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-====
- Licensed to jclouds, Inc. (jclouds) under one or more
- contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. jclouds licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-====
-
- this is a simple ant script that executes a java command on a remote machine via ssh
- 1. find or download a copy of jclouds-antcontrib-1.0-SNAPSHOT-jar-with-dependencies.jar
- - ex. ~/.m2/repository/org/jclouds/jclouds-antcontrib/1.0-SNAPSHOT/jclouds-antcontrib-1.0-SNAPSHOT-jar-with-dependencies.jar
- - ex. curl http://jclouds.rimuhosting.com/maven2/snapshots/org/jclouds/jclouds-antcontrib/1.0-SNAPSHOT/jclouds-antcontrib-1.0-20091215.023231-1-jar-with-dependencies.jar >jclouds-antcontrib-all.jar
- 2. invoke ant, adding the library above, and passing the properties 'host' 'username' 'keyfile' which corresponds to your remote credentials
- - ex. ant -lib ~/.m2/repository/org/jclouds/jclouds-antcontrib/1.0-SNAPSHOT/jclouds-antcontrib-1.0-SNAPSHOT-jar-with-dependencies.jar -Dhost=67.202.42.237 -Dusername=root -Dkeyfile=$HOME/.ssh/id_dsa
- - ex. ant -lib ~/.m2/repository/org/jclouds/jclouds-antcontrib/1.0-SNAPSHOT/jclouds-antcontrib-1.0-SNAPSHOT-jar-with-dependencies.jar -Dhost=localhost -Dusername=$USER -Dkeyfile=$HOME/.ssh/id_dsa
diff --git a/antcontrib/samples/javaoverssh/build.xml b/antcontrib/samples/javaoverssh/build.xml
deleted file mode 100644
index 66ddc8f389..0000000000
--- a/antcontrib/samples/javaoverssh/build.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
- simple example build file
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/logging/AntLogger.java b/antcontrib/src/main/java/org/jclouds/tools/ant/logging/AntLogger.java
deleted file mode 100644
index 48732ce1b4..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/logging/AntLogger.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.logging;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Set;
-
-import org.apache.tools.ant.Project;
-import org.jclouds.logging.BaseLogger;
-import org.jclouds.logging.Logger;
-
-import com.google.common.collect.Sets;
-
-/**
- * {@link org.apache.tools.ant.Project} implementation of {@link Logger}.
- *
- * @author Adrian Cole
- *
- */
-public class AntLogger extends BaseLogger {
- private final Project project;
- private final String category;
- private boolean alwaysLog;
-
- public static class AntLoggerFactory implements LoggerFactory {
- private final Project project;
- private final Set upgrades;
-
- public AntLoggerFactory(Project project, String... upgrades) {
- this.project = checkNotNull(project, "project");
- this.upgrades = Sets.newHashSet(upgrades);
- }
-
- public Logger getLogger(String category) {
- return new AntLogger(project, category, upgrades.contains(category));
- }
- }
-
- public AntLogger(Project project, String category, boolean alwaysLog) {
- this.project = checkNotNull(project, "project");
- this.category = category;
- this.alwaysLog = alwaysLog;
- }
-
- @Override
- protected void logTrace(String message) {
- }
-
- public boolean isTraceEnabled() {
- return false;
- }
-
- @Override
- protected void logDebug(String message) {
- project.log(" " + message, alwaysLog ? Project.MSG_INFO : Project.MSG_DEBUG);
- }
-
- public boolean isDebugEnabled() {
- return true;
- }
-
- @Override
- protected void logInfo(String message) {
- project.log(" " + message);
- }
-
- public boolean isInfoEnabled() {
- return true;
- }
-
- @Override
- protected void logWarn(String message) {
- project.log(" " + message, Project.MSG_WARN);
- }
-
- @Override
- protected void logWarn(String message, Throwable e) {
- project.log(" " + message, e, Project.MSG_WARN);
- }
-
- public boolean isWarnEnabled() {
- return true;
- }
-
- @Override
- protected void logError(String message) {
- project.log(" " + message, Project.MSG_ERR);
- }
-
- @Override
- protected void logError(String message, Throwable e) {
- project.log(" " + message, e, Project.MSG_ERR);
- }
-
- public boolean isErrorEnabled() {
- return true;
- }
-
- public String getCategory() {
- return category;
- }
-}
\ No newline at end of file
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java
deleted file mode 100644
index f087d1deec..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTask.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.taskdefs.compute;
-
-import static org.jclouds.compute.util.ComputeServiceUtils.formatStatus;
-import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
-import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.buildComputeMap;
-import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.createTemplateFromElement;
-import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyString;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.domain.ComputeMetadata;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.predicates.NodePredicates;
-import org.jclouds.domain.Location;
-import org.jclouds.http.HttpUtils;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.util.CredentialUtils;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Splitter;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.Iterables;
-import com.google.inject.Provider;
-
-/**
- * @author Adrian Cole
- * @author Ivan Meredith
- */
-public class ComputeTask extends Task {
-
- private final LoadingCache computeMap;
- private String provider;
- private String actions;
- private NodeElement nodeElement;
-
- /**
- * we don't have a reference to the project during the constructor, so we need to defer expansion
- * with a Provider.
- */
- private final Provider projectProvider = new Provider() {
- @Override
- public Project get() {
- return getProject();
- }
- };
-
- public ComputeTask(@Nullable LoadingCache computeMap) {
- this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
- }
-
- public ComputeTask() throws IOException {
- this(null);
- }
-
- public static enum Action {
- CREATE, GET, LIST, LIST_DETAILS, DESTROY, REBOOT, LIST_IMAGES, LIST_SIZES, LIST_LOCATIONS
- }
-
- /**
- * makes a connection to the compute service and invokes
- */
- public void execute() throws BuildException {
- ComputeServiceContext context = computeMap.getUnchecked(HttpUtils.createUri(provider));
-
- try {
- for (String action : Splitter.on(',').split(actions)) {
- Action act = Action.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, action));
- try {
- invokeActionOnService(act, context.getComputeService());
- } catch (RunNodesException e) {
- throw new BuildException(e);
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
- } finally {
- context.close();
- }
- }
-
- private void invokeActionOnService(Action action, ComputeService computeService) throws RunNodesException, IOException {
- switch (action) {
- case CREATE:
- case GET:
- case DESTROY:
- case REBOOT:
- if (nodeElement != null) {
- switch (action) {
- case CREATE:
- create(computeService);
- break;
- case GET:
- get(computeService);
- break;
- case DESTROY:
- destroy(computeService);
- break;
- case REBOOT:
- reboot(computeService);
- break;
- }
- } else {
- this.log("missing node element for action: " + action, Project.MSG_ERR);
- }
- break;
- case LIST:
- list(computeService);
- break;
- case LIST_DETAILS:
- listDetails(computeService);
- break;
- case LIST_IMAGES:
- listImages(computeService);
- break;
- case LIST_SIZES:
- listHardwares(computeService);
- break;
- case LIST_LOCATIONS:
- listLocations(computeService);
- break;
- default:
- this.log("bad action: " + action, Project.MSG_ERR);
- }
- }
-
- private void listDetails(ComputeService computeService) {
- log("list details");
- for (ComputeMetadata node : computeService.listNodes()) {// TODO
- // parallel
- logDetails(computeService, node);
- }
- }
-
- private void listImages(ComputeService computeService) {
- log("list images");
- for (Image image : computeService.listImages()) {// TODO
- log(String.format(" image location=%s, id=%s, name=%s, version=%s, osArch=%s, osfam=%s, osdesc=%s, desc=%s",
- image.getLocation(), image.getProviderId(), image.getName(), image.getVersion(), image
- .getOperatingSystem().getArch(), image.getOperatingSystem().getFamily(), image
- .getOperatingSystem().getDescription(), image.getDescription()));
- }
- }
-
- private void listHardwares(ComputeService computeService) {
- log("list hardwares");
- for (Hardware hardware : computeService.listHardwareProfiles()) {// TODO
- log(String.format(" hardware id=%s, cores=%s, ram=%s, volumes=%s", hardware.getProviderId(), getCores(hardware), hardware
- .getRam(), hardware.getVolumes()));
- }
- }
-
- private void listLocations(ComputeService computeService) {
- log("list locations");
- for (Location location : computeService.listAssignableLocations()) {// TODO
- log(String.format(" location id=%s, scope=%s, description=%s, parent=%s", location.getId(), location
- .getScope(), location.getDescription(), location.getParent()));
- }
- }
-
- private void list(ComputeService computeService) {
- log("list");
- for (ComputeMetadata node : computeService.listNodes()) {
- log(String.format(" location=%s, id=%s, group=%s", node.getLocation(), node.getProviderId(), node.getName()));
- }
- }
-
- private void create(ComputeService computeService) throws RunNodesException, IOException {
- String group = nodeElement.getGroup();
-
- log(String.format("create group: %s, count: %d, hardware: %s, os: %s", group, nodeElement.getCount(), nodeElement
- .getHardware(), nodeElement.getOs()));
-
- Template template = createTemplateFromElement(nodeElement, computeService);
-
- for (NodeMetadata createdNode : computeService.createNodesInGroup(group, nodeElement.getCount(), template)) {
- logDetails(computeService, createdNode);
- addNodeDetailsAsProjectProperties(createdNode);
- }
- }
-
- private void addNodeDetailsAsProjectProperties(NodeMetadata createdNode) {
- if (nodeElement.getIdproperty() != null)
- getProject().setProperty(nodeElement.getIdproperty(), createdNode.getProviderId());
- if (nodeElement.getHostproperty() != null)
- getProject().setProperty(nodeElement.getHostproperty(), ipOrEmptyString(createdNode.getPublicAddresses()));
- if (nodeElement.getPasswordproperty() != null && !CredentialUtils.isPrivateKeyCredential(createdNode.getCredentials()))
- getProject().setProperty(nodeElement.getPasswordproperty(), createdNode.getCredentials().credential);
- if (nodeElement.getUsernameproperty() != null)
- getProject().setProperty(nodeElement.getUsernameproperty(), createdNode.getCredentials().identity);
- }
-
- private void reboot(ComputeService computeService) {
- if (nodeElement.getId() != null) {
- log(String.format("reboot id: %s", nodeElement.getId()));
- computeService.rebootNode(nodeElement.getId());
- } else {
- log(String.format("reboot group: %s", nodeElement.getGroup()));
- computeService.rebootNodesMatching(NodePredicates.inGroup(nodeElement.getGroup()));
- }
- }
-
- private void destroy(ComputeService computeService) {
- if (nodeElement.getId() != null) {
- log(String.format("destroy id: %s", nodeElement.getId()));
- computeService.destroyNode(nodeElement.getId());
- } else {
- log(String.format("destroy group: %s", nodeElement.getGroup()));
- computeService.destroyNodesMatching(NodePredicates.inGroup(nodeElement.getGroup()));
- }
- }
-
- private void get(ComputeService computeService) {
- if (nodeElement.getId() != null) {
- log(String.format("get id: %s", nodeElement.getId()));
- logDetails(computeService, computeService.getNodeMetadata(nodeElement.getId()));
- } else {
- log(String.format("get group: %s", nodeElement.getGroup()));
- for (ComputeMetadata node : Iterables.filter(computeService.listNodesDetailsMatching(NodePredicates.all()),
- NodePredicates.inGroup(nodeElement.getGroup()))) {
- logDetails(computeService, node);
- }
- }
- }
-
- private void logDetails(ComputeService computeService, ComputeMetadata node) {
- NodeMetadata metadata = node instanceof NodeMetadata ? NodeMetadata.class.cast(node) : computeService
- .getNodeMetadata(node.getId());
- log(String.format(" node id=%s, name=%s, group=%s, location=%s, state=%s, publicIp=%s, privateIp=%s, hardware=%s",
- metadata.getProviderId(), metadata.getName(), metadata.getGroup(), metadata.getLocation(), formatStatus(metadata), ComputeTaskUtils.ipOrEmptyString(metadata.getPublicAddresses()),
- ipOrEmptyString(metadata.getPrivateAddresses()), metadata.getHardware()));
- }
-
- /**
- * @return the configured {@link NodeElement} element
- */
- public final NodeElement createNodes() {
- if (getNodes() == null) {
- this.nodeElement = new NodeElement();
- }
- return this.nodeElement;
- }
-
- public NodeElement getNodes() {
- return this.nodeElement;
- }
-
- public String getActions() {
- return actions;
- }
-
- public void setActions(String actions) {
- this.actions = actions;
- }
-
- public NodeElement getNodeElement() {
- return nodeElement;
- }
-
- public void setNodeElement(NodeElement nodeElement) {
- this.nodeElement = nodeElement;
- }
-
- public void setProvider(String provider) {
- this.provider = provider;
- }
-
- public String getProvider() {
- return provider;
- }
-}
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java
deleted file mode 100644
index 9c6d41afb5..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.taskdefs.compute;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.jclouds.ContextBuilder;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.TemplateBuilder;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.domain.Credentials;
-import org.jclouds.scriptbuilder.domain.Statements;
-import org.jclouds.ssh.jsch.config.JschSshClientModule;
-import org.jclouds.tools.ant.logging.config.AntLoggingModule;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Splitter;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.io.Files;
-import com.google.inject.Module;
-import com.google.inject.Provider;
-
-/**
- *
- * @author Adrian Cole
- */
-public class ComputeTaskUtils {
-
- /**
- *
- * Creates a Map that associates a uri with a live connection to the compute provider. This is
- * done on-demand.
- *
- * @param projectProvider
- * allows access to the ant project to retrieve default properties needed for compute
- * providers.
- */
- static LoadingCache buildComputeMap(final Provider projectProvider) {
- return CacheBuilder.newBuilder().build(new CacheLoader() {
-
- @SuppressWarnings("unchecked")
- @Override
- public ComputeServiceContext load(URI from) {
- Properties props = new Properties();
- props.putAll(projectProvider.get().getProperties());
- Set modules = ImmutableSet. of(new AntLoggingModule(projectProvider.get(),
- ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule());
- // adding the properties to the factory will allow us to pass
- // alternate endpoints
- String provider = from.getHost();
- Credentials creds = Credentials.parse(from);
- return ContextBuilder.newBuilder(provider)
- .credentials(creds.identity, creds.credential)
- .modules(modules)
- .overrides(props).buildView(ComputeServiceContext.class);
- }
-
- });
-
- }
-
- static Template createTemplateFromElement(NodeElement nodeElement, ComputeService computeService) throws IOException {
- TemplateBuilder templateBuilder = computeService.templateBuilder();
- if (nodeElement.getLocation() != null && !"".equals(nodeElement.getLocation()))
- templateBuilder.locationId(nodeElement.getLocation());
- if (nodeElement.getImage() != null && !"".equals(nodeElement.getImage())) {
- final String imageId = nodeElement.getImage();
- try {
- templateBuilder.imageId(imageId);
- } catch (NoSuchElementException e) {
- throw new BuildException("image not found " + nodeElement.getImage());
- }
- } else {
- templateBuilder.osFamily(OsFamily.valueOf(nodeElement.getOs()));
- }
- addHardwareFromElementToTemplate(nodeElement, templateBuilder);
- templateBuilder.options(getNodeOptionsFromElement(nodeElement));
-
- return templateBuilder.build();
- }
-
- static void addHardwareFromElementToTemplate(NodeElement nodeElement, TemplateBuilder template) {
- if (nodeElement.getHardware().equalsIgnoreCase("smallest")) {
- template.smallest();
- } else if (nodeElement.getHardware().equalsIgnoreCase("fastest")) {
- template.fastest();
- } else if (nodeElement.getHardware().equalsIgnoreCase("biggest")) {
- template.biggest();
- } else {
- throw new BuildException("size: " + nodeElement.getHardware()
- + " not supported. valid sizes are smallest, fastest, biggest");
- }
- }
-
- static TemplateOptions getNodeOptionsFromElement(NodeElement nodeElement) throws IOException {
- TemplateOptions options = new TemplateOptions().inboundPorts(getPortsToOpenFromElement(nodeElement));
- addRunScriptToOptionsIfPresentInNodeElement(nodeElement, options);
- addPrivateKeyToOptionsIfPresentInNodeElement(nodeElement, options);
- addPublicKeyToOptionsIfPresentInNodeElement(nodeElement, options);
- return options;
- }
-
- static void addRunScriptToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) throws IOException {
- if (nodeElement.getRunscript() != null)
- options.runScript(Statements.exec(Files.toString(nodeElement.getRunscript(), Charsets.UTF_8)));
- }
-
- static void addPrivateKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options)
- throws IOException {
- if (nodeElement.getPrivatekeyfile() != null)
- options.installPrivateKey(Files.toString(nodeElement.getPrivatekeyfile(), Charsets.UTF_8));
- }
-
- static void addPublicKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) throws IOException {
- if (nodeElement.getPrivatekeyfile() != null)
- options.authorizePublicKey(Files.toString(nodeElement.getPublickeyfile(), Charsets.UTF_8));
- }
-
- static String ipOrEmptyString(Set set) {
- if (set.size() > 0) {
- return Iterables.get(set, 0);
- } else {
- return "";
- }
- }
-
- static int[] getPortsToOpenFromElement(NodeElement nodeElement) {
- Iterable portStrings = Splitter.on(',').split(nodeElement.getOpenports());
- int[] ports = new int[Iterables.size(portStrings)];
- int i = 0;
- for (String port : portStrings) {
- ports[i++] = Integer.parseInt(port);
- }
- return ports;
- }
-}
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java
deleted file mode 100644
index c258c39995..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/NodeElement.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.taskdefs.compute;
-
-import java.io.File;
-
-/**
- * @author Adrian Cole
- * @author Ivan Meredith
- */
-public class NodeElement {
- private String id;
- private String group;
- private String hardware;
- private String os;
- private String image;
- private int count = 1;
- private String openports = "22";
- private String passwordproperty;
- private File privatekeyfile;
- private File publickeyfile;
- private String hostproperty;
- private String idproperty;
- private String usernameproperty;
- private String location;
- private File runscript;
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- String getUsernameproperty() {
- return usernameproperty;
- }
-
- /**
- * The name of a property in which the username of the login user should be stored.
- *
- */
- public void setUsernameproperty(String usernameproperty) {
- this.usernameproperty = usernameproperty;
- }
-
- String getPasswordproperty() {
- return passwordproperty;
- }
-
- /**
- * The name of a property in which the password of the login user should be stored.
- *
- */
- public void setPasswordproperty(String passwordproperty) {
- this.passwordproperty = passwordproperty;
- }
-
- /**
- * The name of a property in which the hostname of the machine should be stored
- *
- */
- public void setHostproperty(String hostproperty) {
- this.hostproperty = hostproperty;
- }
-
- String getHostproperty() {
- return hostproperty;
- }
-
- /**
- * The name of a property in which the id of the machine should be stored
- *
- */
- public void setIdproperty(String idproperty) {
- this.idproperty = idproperty;
- }
-
- String getIdproperty() {
- return idproperty;
- }
-
-
- public void setHardware(String hardware) {
- this.hardware = hardware;
- }
-
- public String getHardware() {
- return hardware;
- }
-
- public void setOs(String os) {
- this.os = os;
- }
-
- public String getOs() {
- return os;
- }
-
- public void setRunscript(File runscript) {
- this.runscript = runscript;
- }
-
- public File getRunscript() {
- return runscript;
- }
-
- public void setOpenports(String openports) {
- this.openports = openports;
- }
-
- public String getOpenports() {
- return openports;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
-
- public String getImage() {
- return image;
- }
-
- public void setCount(int count) {
- this.count = count;
- }
-
- public int getCount() {
- return count;
- }
-
- public void setGroup(String group) {
- this.group = group;
- }
-
- public String getGroup() {
- return group;
- }
-
- public void setPrivatekeyfile(File privatekeyfile) {
- this.privatekeyfile = privatekeyfile;
- }
-
- public File getPrivatekeyfile() {
- return privatekeyfile;
- }
-
- public void setPublickeyfile(File publickeyfile) {
- this.publickeyfile = publickeyfile;
- }
-
- public File getPublickeyfile() {
- return publickeyfile;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
-}
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java
deleted file mode 100644
index 54a071078b..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJava.java
+++ /dev/null
@@ -1,587 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.taskdefs.sshjava;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.security.SecureRandom;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Location;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.taskdefs.Replace;
-import org.apache.tools.ant.taskdefs.Replace.Replacefilter;
-import org.apache.tools.ant.taskdefs.optional.ssh.SSHUserInfo;
-import org.apache.tools.ant.taskdefs.optional.ssh.Scp;
-import org.apache.tools.ant.types.CommandlineJava;
-import org.apache.tools.ant.types.Environment;
-import org.apache.tools.ant.types.Environment.Variable;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Path;
-import org.jclouds.scriptbuilder.InitScript;
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.scriptbuilder.domain.ShellToken;
-import org.jclouds.scriptbuilder.domain.Statement;
-import org.jclouds.scriptbuilder.domain.StatementList;
-import org.jclouds.scriptbuilder.domain.Statements;
-import org.jclouds.tools.ant.util.SSHExecute;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.jcraft.jsch.JSchException;
-
-/**
- * Version of the Java task that executes over ssh.
- *
- * @author Adrian Cole
- */
-public class SSHJava extends Java {
- private final SSHExecute exec;
- private final Scp scp;
- private final SSHUserInfo userInfo;
- private File localDirectory;
- File remotebase;
- @VisibleForTesting
- File remotedir;
- @VisibleForTesting
- Environment env = new Environment();
-
- private OsFamily osFamily = OsFamily.UNIX;
- private File errorFile;
- private String errorProperty;
- private File outputFile;
- private String outputProperty;
- String id = "sshjava" + new SecureRandom().nextLong();
- private boolean append;
-
- @VisibleForTesting
- final LinkedHashMap shiftMap = Maps.newLinkedHashMap();
- @VisibleForTesting
- final LinkedHashMap replace = Maps.newLinkedHashMap();
-
- public SSHJava() {
- super();
- exec = new SSHExecute();
- exec.setProject(getProject());
- scp = new Scp();
- userInfo = new SSHUserInfo();
- scp.init();
- setFork(true);
- setTrust(true);
- }
-
- public SSHJava(Task owner) {
- this();
- bindToOwner(owner);
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public int executeJava() throws BuildException {
- checkNotNull(remotebase, "remotebase must be set");
-
- if (localDirectory == null) {
- try {
- localDirectory = File.createTempFile("sshjava", "dir");
- localDirectory.delete();
- localDirectory.mkdirs();
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
-
- if (remotedir == null)
- remotedir = new File(remotebase, id);
-
- String command = createInitScript(osFamily, id, remotedir.getAbsolutePath(), env, getCommandLine());
-
- try {
- BufferedWriter out = new BufferedWriter(new FileWriter(new File(localDirectory, "init."
- + ShellToken.SH.to(osFamily))));
- out.write(command);
- out.close();
- } catch (IOException e) {
- throw new BuildException(e);
- }
-
- replaceAllTokensIn(localDirectory);
-
- FileSet cwd = new FileSet();
- cwd.setDir(localDirectory);
- if (osFamily == OsFamily.UNIX) {
- log("removing old contents: " + remotedir.getAbsolutePath(), Project.MSG_VERBOSE);
- sshexec(exec("rm -rf " + remotedir.getAbsolutePath()).render(osFamily));
- } else {
- // TODO need recursive remove on windows
- }
- mkdirAndCopyTo(remotedir.getAbsolutePath(), ImmutableList.of(cwd));
-
- for (Entry entry : shiftMap.entrySet()) {
- FileSet set = new FileSet();
- File source = new File(entry.getKey());
- if (source.isDirectory()) {
- set.setDir(new File(entry.getKey()));
- mkdirAndCopyTo(remotebase.getAbsolutePath() + ShellToken.FS.to(osFamily) + entry.getValue(), ImmutableList
- .of(set));
- } else {
- String destination = remotebase.getAbsolutePath() + ShellToken.FS.to(osFamily)
- + new File(entry.getValue()).getParent();
- sshexec(exec("{md} " + destination).render(osFamily));
- scp.init();
- String scpDestination = getScpDir(destination);
- log("staging: " + scpDestination, Project.MSG_VERBOSE);
- scp.setFile(source.getAbsolutePath());
- scp.setTodir(scpDestination);
- scp.execute();
- }
- }
-
- if (getCommandLine().getClasspath() != null) {
- copyPathTo(getCommandLine().getClasspath(), remotedir.getAbsolutePath() + "/classpath");
- }
-
- if (getCommandLine().getBootclasspath() != null) {
- copyPathTo(getCommandLine().getBootclasspath(), remotedir.getAbsolutePath() + "/bootclasspath");
- }
-
- if (osFamily == OsFamily.UNIX) {
- sshexec(exec("chmod 755 " + remotedir.getAbsolutePath() + "{fs}init.{sh}").render(osFamily));
- }
-
- Statement statement = new StatementList(exec("{cd} " + remotedir.getAbsolutePath()), exec(remotedir
- .getAbsolutePath()
- + "{fs}init.{sh} init"), exec(remotedir.getAbsolutePath() + "{fs}init.{sh} run"));
- try {
- return sshexecRedirectStreams(statement);
- } catch (IOException e) {
- throw new BuildException(e, getLocation());
- }
- }
-
- void replaceAllTokensIn(File directory) {
- Replace replacer = new Replace();
- replacer.setProject(getProject());
- replacer.setDir(directory);
-
- Map map = Maps.newLinkedHashMap();
- // this has to go first
- map.put(directory.getAbsolutePath(), remotedir.getAbsolutePath());
-
- map.putAll(Maps.transformValues(shiftMap, new Function() {
-
- @Override
- public String apply(String in) {
- return remotebase + ShellToken.FS.to(osFamily) + in;
- }
-
- }));
- map.putAll(replace);
-
- for (Entry entry : map.entrySet()) {
- Replacefilter filter = replacer.createReplacefilter();
- filter.setToken(entry.getKey());
- filter.setValue(entry.getValue());
- }
- replacer.execute();
- }
-
- private int sshexec(String command) {
- try {
- return exec.execute(command);
- } catch (JSchException e) {
- throw new BuildException(e, getLocation());
- } catch (IOException e) {
- throw new BuildException(e, getLocation());
- } catch (TimeoutException e) {
- throw new BuildException(e, getLocation());
- }
- }
-
- private int sshexecRedirectStreams(Statement statement) throws IOException {
- exec.setStreamHandler(redirector.createHandler());
- log("starting java as:\n" + statement.render(osFamily), Project.MSG_VERBOSE);
- int exitStatus;
- try {
- exitStatus = sshexec(statement.render(osFamily));
- } finally {
- redirector.complete();
- }
- return exitStatus;
- }
-
- private void mkdirAndCopyTo(String destination, Iterable sets) {
- if (Iterables.size(sets) == 0) {
- log("no content: " + destination, Project.MSG_DEBUG);
- return;
- }
- if (sshexec(exec("test -d " + destination).render(osFamily)) == 0) {// TODO windows
- log("already created: " + destination, Project.MSG_VERBOSE);
- return;
- }
- sshexec(exec("{md} " + destination).render(osFamily));
- scp.init();
- String scpDestination = getScpDir(destination);
- log("staging: " + scpDestination, Project.MSG_VERBOSE);
- for (FileSet set : sets)
- scp.addFileset(set);
- scp.setTodir(scpDestination);
- scp.execute();
- }
-
- private String getScpDir(String path) {
- return String.format("%s:%s@%s:%s", userInfo.getName(), userInfo.getKeyfile() == null ? userInfo.getPassword()
- : userInfo.getPassphrase(), scp.getHost(), path);
- }
-
- void resetPathToUnderPrefixIfExistsAndIsFileIfNotExistsAddAsIs(Path path, String prefix, StringBuilder destination) {
- if (path == null)
- return;
- String[] paths = path.list();
- if (paths != null && paths.length > 0) {
- for (int i = 0; i < paths.length; i++) {
- log("converting: " + paths[i], Project.MSG_DEBUG);
- File file = new File(reprefix(paths[i]));
- if (file.getAbsolutePath().equals(paths[i]) && file.exists() && file.isFile()) {
- String newPath = prefix + "{fs}" + file.getName();
- log("adding new: " + newPath, Project.MSG_DEBUG);
- destination.append("{ps}").append(prefix + "{fs}" + file.getName());
- } else {
- // if the file doesn't exist, it is probably a "forward reference" to something that
- // is already on the remote machine
- destination.append("{ps}").append(file.getAbsolutePath());
- log("adding existing: " + file.getAbsolutePath(), Project.MSG_DEBUG);
- }
- }
- }
- }
-
- void copyPathTo(Path path, String destination) {
- List filesets = Lists.newArrayList();
- if (path.list() != null && path.list().length > 0) {
- for (String filepath : path.list()) {
- if (!filepath.equals(reprefix(filepath)))
- continue;// we've already copied
- File file = new File(filepath);
- if (file.exists()) {
- FileSet fileset = new FileSet();
- if (file.isFile()) {
- fileset.setFile(file);
- } else {
- fileset.setDir(file);
- }
- filesets.add(fileset);
- }
- }
- }
- mkdirAndCopyTo(destination, filesets);
- }
-
- String reprefix(String in) {
- log("comparing: " + in, Project.MSG_DEBUG);
- for (Entry entry : shiftMap.entrySet()) {
- if (in.startsWith(entry.getKey())) {
- log("match shift map: " + entry.getKey(), Project.MSG_DEBUG);
- in = remotebase + ShellToken.FS.to(osFamily) + entry.getValue() + in.substring(entry.getKey().length());
- }
- }
- for (Entry entry : replace.entrySet()) {
- if (in.startsWith(entry.getKey())) {
- log("match replaceMap: " + entry.getKey(), Project.MSG_DEBUG);
- in = entry.getValue() + in.substring(entry.getKey().length());
- }
- }
- log("now: " + in, Project.MSG_DEBUG);
- return in;
- }
-
- String createInitScript(OsFamily osFamily, String id, String basedir, Environment env,
- CommandlineJava commandLine) {
- Map envVariables = Maps.newHashMap();
- String[] environment = env.getVariables();
- if (environment != null) {
- for (int i = 0; i < environment.length; i++) {
- log("Setting environment variable: " + environment[i], Project.MSG_DEBUG);
- String[] keyValue = environment[i].split("=");
- envVariables.put(keyValue[0], keyValue[1]);
- }
- }
- StringBuilder commandBuilder = new StringBuilder(commandLine.getVmCommand().getExecutable());
- if (commandLine.getBootclasspath() != null) {
- commandBuilder.append(" -Xbootclasspath:bootclasspath");
- resetPathToUnderPrefixIfExistsAndIsFileIfNotExistsAddAsIs(commandLine.getBootclasspath(),
- "bootclasspath", commandBuilder);
- }
-
- if (commandLine.getVmCommand().getArguments() != null
- && commandLine.getVmCommand().getArguments().length > 0) {
- commandBuilder.append(" ").append(
- Joiner.on(' ').join(commandLine.getVmCommand().getArguments()));
- }
- commandBuilder.append(" -cp classpath");
- resetPathToUnderPrefixIfExistsAndIsFileIfNotExistsAddAsIs(commandLine.getClasspath(),
- "classpath", commandBuilder);
-
- if (commandLine.getSystemProperties() != null
- && commandLine.getSystemProperties().getVariables() != null
- && commandLine.getSystemProperties().getVariables().length > 0) {
- commandBuilder.append(" ").append(
- Joiner.on(' ').join(commandLine.getSystemProperties().getVariables()));
- }
-
- commandBuilder.append(" ").append(commandLine.getClassname());
-
- if (commandLine.getJavaCommand().getArguments() != null
- && commandLine.getJavaCommand().getArguments().length > 0) {
- commandBuilder.append(" ").append(
- Joiner.on(' ').join(commandLine.getJavaCommand().getArguments()));
- }
-
- InitScript testInitBuilder = InitScript.builder().name(id).home(basedir).exportVariables(envVariables)
- .run(Statements.interpret( commandBuilder.toString())).build();
- return testInitBuilder.render(osFamily);
- }
-
- @Override
- public void addEnv(Environment.Variable var) {
- env.addVariable(var);
- }
-
- /**
- * Note that if the {@code dir} property is set, this will be copied recursively to the remote
- * host.
- */
- @Override
- public void setDir(File localDir) {
- this.localDirectory = checkNotNull(localDir, "dir");
- }
-
- /**
- * All files transferred to the host will be relative to this. The java process itself will be at
- * this path/{@code id}.
- */
- public void setRemotebase(File remotebase) {
- this.remotebase = checkNotNull(remotebase, "remotebase");
- }
-
- @Override
- public void setFork(boolean fork) {
- if (!fork)
- throw new IllegalArgumentException("this only operates when fork is set");
- }
-
- /**
- * Remote host, either DNS name or IP.
- *
- * @param host
- * The new host value
- */
- public void setHost(String host) {
- exec.setHost(host);
- scp.setHost(host);
- }
-
- /**
- * Username known to remote host.
- *
- * @param username
- * The new username value
- */
- public void setUsername(String username) {
- exec.setUsername(username);
- scp.setUsername(username);
- userInfo.setName(username);
- }
-
- /**
- * Sets the password for the user.
- *
- * @param password
- * The new password value
- */
- public void setPassword(String password) {
- exec.setPassword(password);
- scp.setPassword(password);
- userInfo.setPassword(password);
- }
-
- /**
- * Sets the keyfile for the user.
- *
- * @param keyfile
- * The new keyfile value
- */
- public void setKeyfile(String keyfile) {
- exec.setKeyfile(keyfile);
- scp.setKeyfile(keyfile);
- userInfo.setKeyfile(keyfile);
- if (userInfo.getPassphrase() == null)
- userInfo.setPassphrase("");
- }
-
- /**
- * Sets the passphrase for the users key.
- *
- * @param passphrase
- * The new passphrase value
- */
- public void setPassphrase(String passphrase) {
- exec.setPassphrase(passphrase);
- scp.setPassphrase(passphrase);
- userInfo.setPassphrase(passphrase);
- }
-
- /**
- * Sets the path to the file that has the identities of all known hosts. This is used by SSH
- * protocol to validate the identity of the host. The default is
- * ${user.home}/.ssh/known_hosts.
- *
- * @param knownHosts
- * a path to the known hosts file.
- */
- public void setKnownhosts(String knownHosts) {
- exec.setKnownhosts(knownHosts);
- scp.setKnownhosts(knownHosts);
- }
-
- /**
- * Setting this to true trusts hosts whose identity is unknown.
- *
- * @param yesOrNo
- * if true trust the identity of unknown hosts.
- */
- public void setTrust(boolean yesOrNo) {
- exec.setTrust(yesOrNo);
- scp.setTrust(yesOrNo);
- userInfo.setTrust(yesOrNo);
- }
-
- /**
- * Changes the port used to connect to the remote host.
- *
- * @param port
- * port number of remote host.
- */
- public void setPort(int port) {
- exec.setPort(port);
- scp.setPort(port);
- }
-
- /**
- * The connection can be dropped after a specified number of milliseconds. This is sometimes
- * useful when a connection may be flaky. Default is 0, which means "wait forever".
- *
- * @param timeout
- * The new timeout value in seconds
- */
- public void setTimeout(long timeout) {
- exec.setTimeout(timeout);
- }
-
- @Override
- public void setProject(Project project) {
- super.setProject(project);
- exec.setProject(project);
- scp.setProject(project);
- }
-
- @Override
- public void setOwningTarget(Target target) {
- super.setOwningTarget(target);
- scp.setOwningTarget(target);
- }
-
- @Override
- public void setTaskName(String taskName) {
- super.setTaskName(taskName);
- scp.setTaskName(taskName);
- }
-
- @Override
- public void setDescription(String description) {
- super.setDescription(description);
- scp.setDescription(description);
- }
-
- @Override
- public void setLocation(Location location) {
- super.setLocation(location);
- scp.setLocation(location);
- }
-
- @Override
- public void setTaskType(String type) {
- super.setTaskType(type);
- scp.setTaskType(type);
- }
-
- @Override
- public String toString() {
- return "SSHJava [append=" + append + ", env=" + env + ", errorFile=" + errorFile + ", errorProperty="
- + errorProperty + ", localDirectory=" + localDirectory + ", osFamily=" + osFamily + ", outputFile="
- + outputFile + ", outputProperty=" + outputProperty + ", remoteDirectory=" + remotebase + ", userInfo="
- + userInfo + "]";
- }
-
- @Override
- public void addSysproperty(Variable sysp) {
- if (sysp.getKey().startsWith("sshjava.shift.")) {
- shiftMap.put(sysp.getKey().replaceFirst("sshjava.shift.", ""), sysp.getValue());
- } else if (sysp.getKey().startsWith("sshjava.replace.")) {
- replace.put(sysp.getKey().replaceFirst("sshjava.replace.", ""), sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.id")) {
- setId(sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.host")) {
- setHost(sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.port") && !sysp.getValue().equals("")) {
- setPort(Integer.parseInt(sysp.getValue()));
- } else if (sysp.getKey().equals("sshjava.username")) {
- setUsername(sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.password") && !sysp.getValue().equals("")) {
- setPassword(sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.keyfile") && !sysp.getValue().equals("")) {
- setKeyfile(sysp.getValue());
- } else if (sysp.getKey().equals("sshjava.remotebase")) {
- setRemotebase(new File(sysp.getValue()));
- } else {
- super.addSysproperty(sysp);
- }
- }
-
-}
\ No newline at end of file
diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/util/SSHExecute.java b/antcontrib/src/main/java/org/jclouds/tools/ant/util/SSHExecute.java
deleted file mode 100644
index b469f01d2e..0000000000
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/util/SSHExecute.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.util;
-
-import java.io.IOException;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
-import org.apache.tools.ant.taskdefs.PumpStreamHandler;
-import org.apache.tools.ant.taskdefs.optional.ssh.SSHUserInfo;
-import org.apache.tools.ant.util.FileUtils;
-
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-
-/**
- * Executes a command on a remote machine via ssh.
- *
- *
- * adapted from SSHBase and SSHExec ant tasks, and Execute from the ant 1.7.1 release.
- *
- * @author Adrian Cole
- *
- */
-public class SSHExecute {
-
- private static final int RETRY_INTERVAL = 500;
-
- /** units are milliseconds, default is 0=infinite */
- private long maxwait = 0;
-
- private ExecuteStreamHandler streamHandler;
- private String host;
- private SSHUserInfo userInfo;
- private int port = 22;
- private Project project;
- private String knownHosts = System.getProperty("user.home") + "/.ssh/known_hosts";
-
- /**
- * Creates a new execute object using PumpStreamHandler for stream handling.
- */
- public SSHExecute() {
- this(new PumpStreamHandler());
- }
-
- /**
- * Creates a new ssh object.
- *
- * @param streamHandler
- * the stream handler used to handle the input and output streams of the subprocess.
- */
- public SSHExecute(ExecuteStreamHandler streamHandler) {
- setStreamHandler(streamHandler);
- userInfo = new SSHUserInfo();
- }
-
- /**
- * Set the stream handler to use.
- *
- * @param streamHandler
- * ExecuteStreamHandler.
- */
- public void setStreamHandler(ExecuteStreamHandler streamHandler) {
- this.streamHandler = streamHandler;
- }
-
- /**
- * Setting this to true trusts hosts whose identity is unknown.
- *
- * @param yesOrNo
- * if true trust the identity of unknown hosts.
- */
- public void setTrust(boolean yesOrNo) {
- userInfo.setTrust(yesOrNo);
- }
-
- /**
- * Used for logging
- */
- public void setProject(Project project) {
- this.project = project;
- }
-
- /**
- * Username known to remote host.
- *
- * @param username
- * The new username value
- */
- public void setUsername(String username) {
- userInfo.setName(username);
- }
-
- /**
- * Sets the password for the user.
- *
- * @param password
- * The new password value
- */
- public void setPassword(String password) {
- userInfo.setPassword(password);
- }
-
- /**
- * Sets the keyfile for the user.
- *
- * @param keyfile
- * The new keyfile value
- */
- public void setKeyfile(String keyfile) {
- userInfo.setKeyfile(keyfile);
- }
-
- /**
- * Sets the passphrase for the users key.
- *
- * @param passphrase
- * The new passphrase value
- */
- public void setPassphrase(String passphrase) {
- userInfo.setPassphrase(passphrase);
- }
-
- /**
- * Remote host, either DNS name or IP.
- *
- * @param host
- * The new host value
- */
- public void setHost(String host) {
- this.host = host;
- }
-
- /**
- * Changes the port used to connect to the remote host.
- *
- * @param port
- * port number of remote host.
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * The connection can be dropped after a specified number of milliseconds. This is sometimes
- * useful when a connection may be flaky. Default is 0, which means "wait forever".
- *
- * @param timeout
- * The new timeout value in seconds
- */
- public void setTimeout(long timeout) {
- maxwait = timeout;
- }
-
- /**
- * Sets the path to the file that has the identities of all known hosts. This is used by SSH
- * protocol to validate the identity of the host. The default is
- * ${user.home}/.ssh/known_hosts.
- *
- * @param knownHosts
- * a path to the known hosts file.
- */
- public void setKnownhosts(String knownHosts) {
- this.knownHosts = knownHosts;
- }
-
- /**
- * Execute the command on the remote host.
- *
- * @param command
- * - what to execute on the remote host.
- *
- * @return return code of the process.
- * @throws BuildException
- * bad parameter.
- * @throws JSchException
- * if there's an underlying problem exposed in SSH
- * @throws IOException
- * if there's a problem attaching streams.
- * @throws TimeoutException
- * if we exceeded our timeout
- */
- public int execute(String command) throws BuildException, JSchException, IOException,
- TimeoutException {
- if (command == null) {
- throw new BuildException("Command is required.");
- }
- if (host == null) {
- throw new BuildException("Host is required.");
- }
- if (userInfo.getName() == null) {
- throw new BuildException("Username is required.");
- }
- if (userInfo.getKeyfile() == null && userInfo.getPassword() == null) {
- throw new BuildException("Password or Keyfile is required.");
- }
-
- Session session = null;
- try {
- session = openSession();
- return executeCommand(session, command);
- } finally {
- if (session != null && session.isConnected()) {
- session.disconnect();
- }
- }
- }
-
- /**
- * Open an ssh session.
- *
- * @return the opened session
- * @throws JSchException
- * on error
- */
- protected Session openSession() throws JSchException {
- JSch jsch = new JSch();
- if (null != userInfo.getKeyfile()) {
- jsch.addIdentity(userInfo.getKeyfile());
- }
-
- if (!userInfo.getTrust() && knownHosts != null) {
- project.log("Using known hosts: " + knownHosts, Project.MSG_DEBUG);
- jsch.setKnownHosts(knownHosts);
- }
-
- Session session = jsch.getSession(userInfo.getName(), host, port);
- session.setUserInfo(userInfo);
- project.log("Connecting to " + host + ":" + port, Project.MSG_VERBOSE);
- session.connect();
- return session;
- }
-
- /**
- *
- * FIXME Comment this
- *
- * @param session
- * @param cmd
- * @return return code of the process.
- * @throws JSchException
- * if there's an underlying problem exposed in SSH
- * @throws IOException
- * if there's a problem attaching streams.
- * @throws TimeoutException
- * if we exceeded our timeout
- */
- private int executeCommand(Session session, String cmd) throws JSchException, IOException,
- TimeoutException {
- final ChannelExec channel;
- session.setTimeout((int) maxwait);
- /* execute the command */
- channel = (ChannelExec) session.openChannel("exec");
- channel.setCommand(cmd);
- attachStreams(channel);
- project.log("executing command: " + cmd, Project.MSG_VERBOSE);
- channel.connect();
- try {
- waitFor(channel);
- } finally {
- streamHandler.stop();
- closeStreams(channel);
- }
- return channel.getExitStatus();
- }
-
- private void attachStreams(final ChannelExec channel) throws IOException {
- streamHandler.setProcessInputStream(channel.getOutputStream());
- streamHandler.setProcessOutputStream(channel.getInputStream());
- streamHandler.setProcessErrorStream(channel.getErrStream());
- streamHandler.start();
- }
-
- /**
- * Close the streams belonging to the given Process.
- *
- * @param process
- * the Process.
- * @throws IOException
- */
- public static void closeStreams(ChannelExec process) throws IOException {
- FileUtils.close(process.getInputStream());
- FileUtils.close(process.getOutputStream());
- FileUtils.close(process.getErrStream());
- }
-
- /**
- * @throws TimeoutException
- */
- @SuppressWarnings("deprecation")
- private void waitFor(final ChannelExec channel) throws TimeoutException {
- // wait for it to finish
- Thread thread = new Thread() {
- public void run() {
- while (!channel.isClosed()) {
- try {
- sleep(RETRY_INTERVAL);
- } catch (InterruptedException e) {
- // ignored
- }
- }
- }
- };
-
- thread.start();
- try {
- thread.join(maxwait);
- } catch (InterruptedException e) {
- // ignored
- }
-
- if (thread.isAlive()) {
- thread.destroy();
- throw new TimeoutException("command still running");
- }
- }
-
-}
diff --git a/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java b/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java
deleted file mode 100644
index 4cbfe86eb8..0000000000
--- a/antcontrib/src/test/java/org/jclouds/tools/ant/taskdefs/sshjava/SSHJavaTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.tools.ant.taskdefs.sshjava;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Map.Entry;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Java;
-import org.apache.tools.ant.types.Environment;
-import org.apache.tools.ant.types.Environment.Variable;
-import org.apache.tools.ant.types.Path;
-import org.jclouds.scriptbuilder.domain.OsFamily;
-import org.jclouds.tools.ant.TestClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.io.CharStreams;
-import com.google.common.io.Files;
-import com.google.common.io.Resources;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class SSHJavaTest {
- public static final Entry LAST_ENV = Iterables.getLast(System.getenv()
- .entrySet());
-
- // TODO, this test will break in windows
- @Test(enabled = false, groups = { "live" })
- public void testShift() throws SecurityException, NoSuchMethodException, IOException {
- SSHJava task = makeSSHJava();
- task = directoryShift(task);
- assertEquals(task.shiftMap, ImmutableMap. of(System.getProperty("user.home")
- + "/apache-maven-2.2.1", "maven"));
- assertEquals(task.replace, ImmutableMap. of(System.getProperty("user.name"),
- "root"));
- new File("build").mkdirs();
- Files.write(task.createInitScript(OsFamily.UNIX, "1", "remotedir", task.env, task
- .getCommandLine()), new File("build", "init.sh"), Charsets.UTF_8);
- task.remotedir=new File(task.remotebase, task.id);
- task.replaceAllTokensIn(new File("build"));
- assertEquals(Files.toString(new File("build", "init.sh"), Charsets.UTF_8), CharStreams
- .toString(Resources.newReaderSupplier(Resources.getResource("init.sh"),
- Charsets.UTF_8)));
- }
-
- private Java populateTask(Java task) {
- Project p = new Project();
- task.setProject(p);
- task.setClassname(TestClass.class.getName());
- task.createClasspath().add(new Path(p, "target/test-classes"));
- Variable prop1 = new Environment.Variable();
- prop1.setKey("fooble");
- prop1.setValue("baz");
- task.addSysproperty(prop1);
- Variable prop2 = new Environment.Variable();
- prop2.setKey("foo");
- prop2.setValue("bar");
- task.addSysproperty(prop2);
- task.createJvmarg().setValue("-Xms16m");
- task.createJvmarg().setValue("-Xmx32m");
- Variable env = new Environment.Variable();
- env.setKey(LAST_ENV.getKey());
- env.setValue(LAST_ENV.getValue());
- task.addEnv(env);
- task.createArg().setValue(env.getKey());
- task.createArg().setValue("hello");
- task.createArg().setValue("world");
- task.setDir(new File(System.getProperty("user.dir")));
- task.setFork(true);
- task.setJvm(System.getProperty("java.home") + "/bin/java");
- task.setOutputproperty("out");
- task.setErrorProperty("err");
- task.setResultProperty("result");
- return task;
- }
-
- @Test(enabled = false, groups = { "live" })
- public void testSsh() throws NumberFormatException, FileNotFoundException, IOException {
- Java java = makeJava();
- java.execute();
-
- SSHJava javaOverSsh = makeSSHJava();
- addDestinationTo(javaOverSsh);
- javaOverSsh.execute();
-
- assertEquals(javaOverSsh.getProject().getProperty("out"), javaOverSsh.getProject()
- .getProperty("out"));
- assertEquals(javaOverSsh.getProject().getProperty("err"), javaOverSsh.getProject()
- .getProperty("err"));
- assertEquals(javaOverSsh.getProject().getProperty("result"), javaOverSsh.getProject()
- .getProperty("result"));
- }
-
- @Test(enabled = false, groups = { "live" })
- public void testSshShift() throws NumberFormatException, FileNotFoundException, IOException {
- Java java = makeJava();
- directoryShift(java);
- java.execute();
-
- SSHJava javaOverSsh = makeSSHJava();
- addDestinationTo(javaOverSsh);
- directoryShift(javaOverSsh);
- javaOverSsh.execute();
-
- assertEquals(javaOverSsh.getProject().getProperty("out"), javaOverSsh.getProject()
- .getProperty("out"));
- assertEquals(javaOverSsh.getProject().getProperty("err"), javaOverSsh.getProject()
- .getProperty("err"));
- assertEquals(javaOverSsh.getProject().getProperty("result"), javaOverSsh.getProject()
- .getProperty("result"));
- }
-
- private void addDestinationTo(SSHJava javaOverSsh) throws UnknownHostException {
- String sshHost = System.getProperty("test.ssh.host");
- String sshPort = System.getProperty("test.ssh.port");
- String sshUser = System.getProperty("test.ssh.username");
- String sshPass = System.getProperty("test.ssh.password");
- String sshKeyFile = System.getProperty("test.ssh.keyfile");
-
- int port = (sshPort != null) ? Integer.parseInt(sshPort) : 22;
- InetAddress host = (sshHost != null) ? InetAddress.getByName(sshHost) : InetAddress
- .getLocalHost();
- javaOverSsh.setHost(host.getHostAddress());
- javaOverSsh.setPort(port);
- javaOverSsh.setUsername(sshUser);
- if (sshKeyFile != null && !sshKeyFile.trim().equals("")) {
- javaOverSsh.setKeyfile(sshKeyFile);
- } else {
- javaOverSsh.setPassword(sshPass);
- }
- }
-
- private SSHJava makeSSHJava() {
- SSHJava task = new SSHJava();
- populateTask(task);
- task.setRemotebase(new File("/tmp/foo"));
- task.setTrust(true);
- return task;
- }
-
- private Java makeJava() {
- return populateTask(new Java());
- }
-
- private T directoryShift(T java) {
- Variable prop1 = new Environment.Variable();
- prop1.setKey("sshjava.shift." + System.getProperty("user.home") + "/apache-maven-2.2.1");
- prop1.setValue("maven");
- java.addSysproperty(prop1);
- Variable prop2 = new Environment.Variable();
- prop2.setKey("settingsfile");
- prop2.setValue(System.getProperty("user.home") + "/apache-maven-2.2.1/conf/settings.xml");
- java.addSysproperty(prop2);
- Variable prop3 = new Environment.Variable();
- prop3.setKey("appHome");
- prop3.setValue(System.getProperty("user.home") + "/apache-maven-2.2.1");
- java.addSysproperty(prop3);
- Variable prop4 = new Environment.Variable();
- prop4.setKey("sshjava.replace." + System.getProperty("user.name"));
- prop4.setValue("root");
- java.addSysproperty(prop4);
- Variable prop5 = new Environment.Variable();
- prop5.setKey("username");
- prop5.setValue(System.getProperty("user.name"));
- java.addSysproperty(prop5);
- return java;
- }
-}
diff --git a/apis/atmos/pom.xml b/apis/atmos/pom.xml
index 3ba1605c0f..5f864a9eed 100644
--- a/apis/atmos/pom.xml
+++ b/apis/atmos/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xml
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java
index 06e64fc3ed..145b9f7fcf 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java
@@ -58,6 +58,7 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
+
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/handlers/AtmosClientErrorRetryHandler.java b/apis/atmos/src/main/java/org/jclouds/atmos/handlers/AtmosClientErrorRetryHandler.java
index 6225524064..0eef327b1e 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/handlers/AtmosClientErrorRetryHandler.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/handlers/AtmosClientErrorRetryHandler.java
@@ -37,6 +37,7 @@ import com.google.inject.Inject;
/**
* Handles Retryable responses with error codes in the 4xx range
*
+ * @see Error codes section at
* @author Adrian Cole
*/
public class AtmosClientErrorRetryHandler implements HttpRetryHandler {
@@ -62,14 +63,14 @@ public class AtmosClientErrorRetryHandler implements HttpRetryHandler {
if (response.getStatusCode() == 404 && command.getCurrentRequest().getMethod().equals("DELETE")) {
command.incrementFailureCount();
return true;
- } else if (response.getStatusCode() == 409 || response.getStatusCode() == 400) {
+ } else if (response.getStatusCode() == 409) {
byte[] content = HttpUtils.closeClientButKeepContentStream(response);
// Content can be null in the case of HEAD requests
if (content != null) {
try {
AtmosError error = utils.parseAtmosErrorFromContent(command, response,
new String(content));
- if (error.getCode() == 1016) {
+ if (error.getCode() == 1006) {
return backoffHandler.shouldRetryRequest(command, response);
}
// don't increment count before here, since backoff handler does already
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java b/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java
index af822753cf..91efe6bf44 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/util/AtmosUtils.java
@@ -27,9 +27,11 @@ import javax.inject.Provider;
import org.jclouds.atmos.AtmosClient;
import org.jclouds.atmos.blobstore.functions.BlobToObject;
import org.jclouds.atmos.domain.AtmosError;
+import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.atmos.filters.SignRequest;
import org.jclouds.atmos.options.PutOptions;
import org.jclouds.atmos.xml.ErrorHandler;
+import org.jclouds.blobstore.KeyAlreadyExistsException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.crypto.Crypto;
import org.jclouds.http.HttpCommand;
@@ -70,8 +72,15 @@ public class AtmosUtils {
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container,
Blob blob, PutOptions options) {
final String path = container + "/" + blob.getMetadata().getName();
- deleteAndEnsureGone(sync, path);
- sync.createFile(container, blob2Object.apply(blob), options);
+ final AtmosObject object = blob2Object.apply(blob);
+
+ try {
+ sync.createFile(container, object, options);
+
+ } catch(KeyAlreadyExistsException e) {
+ deleteAndEnsureGone(sync, path);
+ sync.createFile(container, object, options);
+ }
return path;
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
index d826318341..8b862d7cb8 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
@@ -32,6 +32,8 @@ public class AtmosLiveTest extends BaseBlobLiveTest {
public AtmosLiveTest() {
provider = "atmos";
}
+
+ @Override
protected void checkMD5(String container, String name, byte[] md5) {
// atmos does not support content-md5 yet
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
diff --git a/apis/byon/pom.xml b/apis/byon/pom.xml
index 3477244f66..8a2995bf00 100644
--- a/apis/byon/pom.xml
+++ b/apis/byon/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xml
diff --git a/apis/cloudfiles/pom.xml b/apis/cloudfiles/pom.xml
index 708148679c..1c458fc4c2 100644
--- a/apis/cloudfiles/pom.xml
+++ b/apis/cloudfiles/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
@@ -34,6 +34,7 @@
bundle
+ 15https://auth.api.rackspacecloud.com1.0
@@ -112,6 +113,7 @@
+ ${test.blobstore.container-count}${jclouds.blobstore.httpstream.url}${jclouds.blobstore.httpstream.md5}${test.cloudfiles.endpoint}
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
index eea9a09b28..25540f9cd1 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
@@ -22,30 +22,34 @@ import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
+import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule.StorageAndCDNManagementEndpointModule;
import org.jclouds.openstack.swift.SwiftApiMetadata;
+import org.jclouds.openstack.swift.blobstore.SwiftBlobSigner;
+import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
+import com.google.inject.TypeLiteral;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
- *
+ *
* @author Adrian Cole
*/
public class CloudFilesApiMetadata extends SwiftApiMetadata {
-
+
/** The serialVersionUID */
private static final long serialVersionUID = -1572520638079261710L;
-
+
public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() {
private static final long serialVersionUID = -5070937833892503232L;
};
-
+
private static Builder builder() {
return new Builder();
}
@@ -62,7 +66,7 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata {
protected CloudFilesApiMetadata(Builder builder) {
super(builder);
}
-
+
public static Properties defaultProperties() {
Properties properties = SwiftApiMetadata.defaultProperties();
return properties;
@@ -78,9 +82,13 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata {
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
- .defaultModules(ImmutableSet.>of(StorageAndCDNManagementEndpointModule.class, CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
+ .defaultModules(ImmutableSet.>builder()
+ .add(StorageAndCDNManagementEndpointModule.class)
+ .add(CloudFilesRestClientModule.class)
+ .add(CloudFilesBlobStoreContextModule.class)
+ .add(CloudFilesTemporaryUrlExtensionModule.class).build());
}
-
+
@Override
public CloudFilesApiMetadata build() {
return new CloudFilesApiMetadata(this);
@@ -93,4 +101,13 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata {
}
}
+ public static class CloudFilesTemporaryUrlExtensionModule extends TemporaryUrlExtensionModule {
+
+ @Override
+ protected void bindRequestSigner() {
+ bind(BlobRequestSigner.class).to(new TypeLiteral>() {
+ });
+ }
+
+ }
}
\ No newline at end of file
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java
index aa3c9aaf8d..6e2ca5ab5d 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesAsyncClient.java
@@ -39,7 +39,6 @@ import org.jclouds.cloudfiles.binders.BindIterableToHeadersWithPurgeCDNObjectEma
import org.jclouds.cloudfiles.domain.ContainerCDNMetadata;
import org.jclouds.cloudfiles.functions.ParseCdnUriFromHeaders;
import org.jclouds.cloudfiles.functions.ParseContainerCDNMetadataFromHeaders;
-import org.jclouds.cloudfiles.functions.ParseTemporaryUrlKeyFromHeaders;
import org.jclouds.cloudfiles.options.ListCdnContainerOptions;
import org.jclouds.cloudfiles.reference.CloudFilesHeaders;
import org.jclouds.openstack.filters.AuthenticateRequest;
@@ -202,19 +201,4 @@ public interface CloudFilesAsyncClient extends CommonSwiftAsyncClient {
@Headers(keys = CloudFilesHeaders.CDN_WEBSITE_ERROR, values = "{error}")
ListenableFuture setCDNStaticWebsiteError(@PathParam("container") String container,
@PathParam("error") String error);
-
- /**
- * @see CloudFilesClient#getTemporaryUrlKey
- */
- @HEAD
- @Path("/")
- @ResponseParser(ParseTemporaryUrlKeyFromHeaders.class)
- ListenableFuture getTemporaryUrlKey();
-
- /**
- * @see CloudFilesClient#setTemporaryUrlKey
- */
- @POST
- @Path("/")
- ListenableFuture setTemporaryUrlKey(@HeaderParam(CloudFilesHeaders.ACCOUNT_TEMPORARY_URL_KEY) String key);
}
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java
index 23e3dd3abb..8a40c3ed23 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesClient.java
@@ -105,25 +105,4 @@ public interface CloudFilesClient extends CommonSwiftClient {
* http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Error_Pages_for_Static_Website-dle4005.html
*/
boolean setCDNStaticWebsiteError(String container, String error);
-
- /**
- * Retrieve the key used to generate Temporary object access URLs
- *
- * @see
- * @return shared secret key
- */
- String getTemporaryUrlKey();
-
- /**
- * To create a Temporary URL you must first set a key as account metadata.
- *
- * Once the key is set, you should not change it while you still want others to be
- * able to access your temporary URL. If you change it, the TempURL becomes invalid
- * (within 60 seconds, which is the cache time for a key) and others will not be allowed
- * to access it.
- *
- * @see
- * @param temporaryUrlKey
- */
- void setTemporaryUrlKey(String temporaryUrlKey);
}
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java
index 011a3054cf..b9282dc995 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/config/CloudFilesBlobStoreContextModule.java
@@ -23,15 +23,11 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton;
-import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.cloudfiles.CloudFilesClient;
-import org.jclouds.cloudfiles.TemporaryUrlKey;
import org.jclouds.cloudfiles.blobstore.CloudFilesAsyncBlobStore;
-import org.jclouds.cloudfiles.blobstore.CloudFilesBlobRequestSigner;
import org.jclouds.cloudfiles.blobstore.CloudFilesBlobStore;
import org.jclouds.cloudfiles.blobstore.functions.CloudFilesObjectToBlobMetadata;
import org.jclouds.cloudfiles.domain.ContainerCDNMetadata;
-import org.jclouds.date.TimeStamp;
import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore;
import org.jclouds.openstack.swift.blobstore.SwiftBlobStore;
import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
@@ -64,18 +60,6 @@ public class CloudFilesBlobStoreContextModule extends SwiftBlobStoreContextModul
});
}
- @Provides
- @TimeStamp
- protected Long unixEpochTimestampProvider() {
- return System.currentTimeMillis() / 1000; /* convert to seconds */
- }
-
- @Provides
- @TemporaryUrlKey
- protected String temporaryUrlKeyProvider(CloudFilesClient client) {
- return client.getTemporaryUrlKey();
- }
-
@Override
protected void configure() {
super.configure();
@@ -83,9 +67,4 @@ public class CloudFilesBlobStoreContextModule extends SwiftBlobStoreContextModul
bind(SwiftAsyncBlobStore.class).to(CloudFilesAsyncBlobStore.class);
bind(ObjectToBlobMetadata.class).to(CloudFilesObjectToBlobMetadata.class);
}
-
- @Override
- protected void configureRequestSigner() {
- bind(BlobRequestSigner.class).to(CloudFilesBlobRequestSigner.class);
- }
}
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java
index f927e9ee80..7273a4a2ec 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java
@@ -43,7 +43,7 @@ import com.google.inject.Provides;
import com.google.inject.Scopes;
/**
- *
+ *
* @author Adrian Cole
*/
@ConfiguresRestClient
@@ -53,6 +53,7 @@ public class CloudFilesRestClientModule extends SwiftRestClientModule, Class>> of());
}
+ @Override
protected void bindResolvedClientsToCommonSwift() {
bind(CommonSwiftClient.class).to(CloudFilesClient.class).in(Scopes.SINGLETON);
bind(CommonSwiftAsyncClient.class).to(CloudFilesAsyncClient.class).in(Scopes.SINGLETON);
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java
index 10547a5f06..e3fbf27ff9 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/reference/CloudFilesHeaders.java
@@ -30,8 +30,6 @@ import org.jclouds.openstack.swift.reference.SwiftHeaders;
*/
public interface CloudFilesHeaders extends SwiftHeaders {
- public static final String ACCOUNT_TEMPORARY_URL_KEY = "X-Account-Meta-Temp-Url-Key";
-
public static final String CDN_ENABLED = "X-CDN-Enabled";
public static final String CDN_LOG_RETENTION = "X-Log-Retention";
public static final String CDN_TTL = "X-TTL";
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientTest.java
deleted file mode 100644
index f09b74dc51..0000000000
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.cloudfiles;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
-import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
-import org.jclouds.openstack.internal.TestOpenStackAuthenticationModule;
-import org.jclouds.openstack.swift.CommonSwiftClientTest;
-import org.jclouds.openstack.swift.SwiftApiMetadata;
-import org.jclouds.openstack.swift.SwiftAsyncClient;
-import org.jclouds.openstack.swift.config.SwiftRestClientModule;
-import org.jclouds.rest.HttpClient;
-import org.jclouds.rest.internal.RestAnnotationProcessor;
-import org.testng.annotations.Test;
-
-import java.util.Properties;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_ENDPOINT;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
-
-/**
- * @author Andrei Savu
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "CloudFilesClientTest")
-public class CloudFilesClientTest extends CommonSwiftClientTest {
-
- public static final long UNIX_EPOCH_TIMESTAMP = 123456789L;
- public static final String TEMPORARY_URL_KEY = "get-or-set-X-Account-Meta-Temp-Url-Key";
-
- protected String provider = "cloudfiles";
-
- public static class FixedCloudFilesBlobStoreContextModule extends CloudFilesBlobStoreContextModule {
- @Override
- protected Long unixEpochTimestampProvider() {
- return UNIX_EPOCH_TIMESTAMP;
- }
-
- @Override
- protected String temporaryUrlKeyProvider(CloudFilesClient _) {
- return TEMPORARY_URL_KEY;
- }
- }
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new CloudFilesApiMetadata().toBuilder().defaultModules(
- ImmutableSet.>of(StorageEndpointModule.class,
- CloudFilesRestClientModule.class, FixedCloudFilesBlobStoreContextModule.class)).build();
- }
-}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerExpectTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerExpectTest.java
new file mode 100644
index 0000000000..8b9c2f2ae5
--- /dev/null
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerExpectTest.java
@@ -0,0 +1,145 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jclouds.cloudfiles.blobstore;
+
+import static org.jclouds.openstack.swift.reference.SwiftHeaders.ACCOUNT_TEMPORARY_URL_KEY;
+
+import java.util.Map;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.blobstore.internal.BaseBlobSignerExpectTest;
+import org.jclouds.cloudfiles.CloudFilesApiMetadata;
+import org.jclouds.cloudfiles.CloudFilesApiMetadata.CloudFilesTemporaryUrlExtensionModule;
+import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
+import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
+import org.jclouds.cloudfiles.config.CloudFilesRestClientModule.StorageAndCDNManagementEndpointModule;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.net.HttpHeaders;
+import com.google.inject.Module;
+
+/**
+ * Tests behavior of {@code SwiftBlobSigner}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "CloudFilesBlobSignerExpectTest")
+public class CloudFilesBlobSignerExpectTest extends BaseBlobSignerExpectTest {
+
+ public CloudFilesBlobSignerExpectTest() {
+ identity = "user@jclouds.org";
+ credential = "Password1234";
+ }
+
+ @Override
+ protected HttpRequest getBlob() {
+ return HttpRequest.builder().method("GET")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name")
+ .addHeader("X-Auth-Token", authToken).build();
+ }
+
+ @Override
+ protected HttpRequest getBlobWithTime() {
+ return HttpRequest.builder().method("GET")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name?temp_url_sig=9d62a4a15076699b3f7c60c2d021609990f24115&temp_url_expires=123456792").build();
+ }
+
+ @Override
+ protected HttpRequest getBlobWithOptions() {
+ return HttpRequest.builder().method("GET")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name")
+ .addHeader("X-Auth-Token", authToken)
+ .addHeader("Range", "bytes=0-1").build();
+ }
+
+ @Override
+ protected HttpRequest putBlob() {
+ return HttpRequest.builder().method("PUT")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name")
+ .addHeader("X-Auth-Token", authToken).build();
+ }
+
+ @Override
+ protected HttpRequest putBlobWithTime() {
+ return HttpRequest.builder().method("PUT")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name?temp_url_sig=f83fa711f353f6f0bab3a66c56e35a972b9b3922&temp_url_expires=123456792").build();
+ }
+
+ @Override
+ protected HttpRequest removeBlob() {
+ return HttpRequest.builder().method("DELETE")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name")
+ .addHeader("X-Auth-Token", authToken).build();
+ }
+
+ protected String authToken = "118fb907-0786-4799-88f0-9a5b7963d1ab";
+
+ @Override
+ protected Map init() {
+
+ HttpRequest authRequest = HttpRequest.builder().method("POST")
+ .endpoint("https://auth.api.rackspacecloud.com/v1.1/auth")
+ .addHeader(HttpHeaders.ACCEPT, "application/json")
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"credentials\":{\"username\":\"user@jclouds.org\",\"key\":\"Password1234\"}}",
+ "application/json")).build();
+
+ HttpResponse authResponse = HttpResponse.builder().statusCode(200).message("HTTP/1.1 200")
+ .payload(payloadFromResourceWithContentType("/auth1_1.json", "application/json")).build();
+
+ HttpRequest temporaryKeyRequest = HttpRequest.builder().method("HEAD")
+ .endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse temporaryKeyResponse = HttpResponse.builder().statusCode(200)
+ .addHeader(ACCOUNT_TEMPORARY_URL_KEY, "TEMPORARY_KEY").build();
+
+ return ImmutableMap. builder()
+ .put(authRequest, authResponse)
+ .put(temporaryKeyRequest, temporaryKeyResponse).build();
+ }
+
+ public static class StaticTimeAndTemporaryUrlKeyModule extends CloudFilesTemporaryUrlExtensionModule {
+
+ @Override
+ protected Long unixEpochTimestampProvider() {
+ return 123456789L;
+ }
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new CloudFilesApiMetadata()
+ .toBuilder()
+ .defaultEndpoint("https://auth.api.rackspacecloud.com")
+ .defaultModules(
+ ImmutableSet.> builder()
+ .add(StorageAndCDNManagementEndpointModule.class)
+ .add(CloudFilesRestClientModule.class)
+ .add(CloudFilesBlobStoreContextModule.class)
+ .add(StaticTimeAndTemporaryUrlKeyModule.class).build()).build();
+ }
+}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerTest.java
deleted file mode 100644
index 7bdcdaefc4..0000000000
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobSignerTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.jclouds.cloudfiles.blobstore;
-
-import org.jclouds.blobstore.BlobRequestSigner;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.cloudfiles.CloudFilesClientTest;
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.util.Date;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-/**
- * @author Andrei Savu
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "CloudFilesBlobSignerTest")
-public class CloudFilesBlobSignerTest extends CloudFilesClientTest {
-
- private BlobRequestSigner signer;
- private Blob.Factory blobFactory;
-
- public void testSignGetBlobWithTime() {
- HttpRequest request = signer.signGetBlob("container", "name", 120);
-
- assertRequestLineEquals(request, "GET http://storage/container/name?" +
- "temp_url_sig=4759d99d13c826bba0af2c9f0c526ca53c95abaf&temp_url_expires=123456909 HTTP/1.1");
- assertFalse(request.getHeaders().containsKey("X-Auth-Token"));
- assertPayloadEquals(request, null, null, false);
-
- assertEquals(request.getFilters().size(), 0);
- }
-
- public void testSignPutBlobWithTime() throws Exception {
- Blob blob = blobFactory.create(null);
-
- blob.getMetadata().setName("name");
- blob.setPayload("");
- blob.getPayload().getContentMetadata().setContentLength(2l);
- blob.getPayload().getContentMetadata().setContentMD5(new byte[]{0, 2, 4, 8});
- blob.getPayload().getContentMetadata().setContentType("text/plain");
- blob.getPayload().getContentMetadata().setExpires(new Date(1000));
-
- HttpRequest request = signer.signPutBlob("container", blob, 120 /* seconds */);
-
- assertRequestLineEquals(request, "PUT http://storage/container/name?" +
- "temp_url_sig=490690286130adac9e7144d85b320a00b1bf9e2b&temp_url_expires=123456909 HTTP/1.1");
-
- assertFalse(request.getHeaders().containsKey("X-Auth-Token"));
- assertContentHeadersEqual(request, "text/plain", null, null, null, (long) 2l, new byte[]{0, 2, 4, 8}, new Date(1000));
-
- assertEquals(request.getFilters().size(), 0);
- }
-
- @BeforeClass
- protected void setupFactory() throws IOException {
- super.setupFactory();
- this.blobFactory = injector.getInstance(Blob.Factory.class);
- this.signer = injector.getInstance(BlobRequestSigner.class);
- }
-}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
index 14de7f6200..360c307c4e 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
@@ -18,9 +18,8 @@
*/
package org.jclouds.cloudfiles.blobstore.integration;
-import org.jclouds.cloudfiles.CloudFilesApiMetadata;
-import org.jclouds.cloudfiles.CloudFilesClient;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest;
+import org.jclouds.openstack.swift.extensions.TemporaryUrlKeyApi;
import org.testng.annotations.Test;
import java.util.UUID;
@@ -33,12 +32,13 @@ import static org.testng.Assert.assertNotNull;
*/
@Test(groups = {"live"})
public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest {
+
public CloudFilesBlobLiveTest() {
provider = "cloudfiles";
}
public void testGetAndSetTemporaryUrlKey() {
- CloudFilesClient client = view.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
+ TemporaryUrlKeyApi client = view.utils().injector().getInstance(TemporaryUrlKeyApi.class);
String currentSecretKey = client.getTemporaryUrlKey();
assertNotNull(currentSecretKey);
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
index 9ced14fa93..d67142e575 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
@@ -18,19 +18,9 @@
*/
package org.jclouds.cloudfiles.blobstore.integration;
-import org.jclouds.blobstore.domain.Blob;
-import org.jclouds.http.HttpRequest;
import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
/**
* @author Adrian Cole
*/
@@ -39,58 +29,4 @@ public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
public CloudFilesBlobSignerLiveTest() {
provider = "cloudfiles";
}
-
- @Test
- public void testSignGetUrlWithTime() throws InterruptedException, IOException {
- String name = "hello";
- String text = "fooooooooooooooooooooooo";
-
- Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
- String container = getContainerName();
- try {
- view.getBlobStore().putBlob(container, blob);
- assertConsistencyAwareContainerSize(container, 1);
- HttpRequest request = view.getSigner().signGetBlob(container, name, 3 /* seconds */);
-
- assertEquals(request.getFilters().size(), 0);
- assertEquals(Strings2.toString(view.utils().http().invoke(request).getPayload()), text);
-
- TimeUnit.SECONDS.sleep(4);
- try {
- Strings2.toString(view.utils().http().invoke(request).getPayload());
- fail("Temporary URL did not expire as expected");
- } catch (AuthorizationException expected) {
- }
- } finally {
- returnContainer(container);
- }
- }
-
- @Test
- public void testSignPutUrlWithTime() throws Exception {
- String name = "hello";
- String text = "fooooooooooooooooooooooo";
-
- Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
- String container = getContainerName();
- try {
- HttpRequest request = view.getSigner().signPutBlob(container, blob, 3 /* seconds */);
- assertEquals(request.getFilters().size(), 0);
-
- Strings2.toString(view.utils().http().invoke(request).getPayload());
- assertConsistencyAwareContainerSize(container, 1);
-
- view.getBlobStore().removeBlob(container, name);
- assertConsistencyAwareContainerSize(container, 0);
-
- TimeUnit.SECONDS.sleep(4);
- try {
- Strings2.toString(view.utils().http().invoke(request).getPayload());
- fail("Temporary URL did not expire as expected");
- } catch (AuthorizationException expected) {
- }
- } finally {
- returnContainer(container);
- }
- }
}
diff --git a/apis/cloudloadbalancers/pom.xml b/apis/cloudloadbalancers/pom.xml
index 48fcd6eda1..aced7205cd 100644
--- a/apis/cloudloadbalancers/pom.xml
+++ b/apis/cloudloadbalancers/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java
index fb09722a1b..061d810973 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java
@@ -20,7 +20,6 @@ package org.jclouds.cloudloadbalancers.features;
import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.Collections;
import java.util.Set;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
@@ -38,6 +37,7 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
+import com.google.common.collect.ImmutableList;
import com.google.inject.TypeLiteral;
/**
@@ -85,7 +85,7 @@ public class NodeAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTestsingleton(NodeRequest.builder().
+ HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of(NodeRequest.builder().
address("192.168.1.1").port(8080).build()), 3);
assertRequestLineEquals(httpRequest,
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
index 64bfa9611e..f3ddef1ba9 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java
@@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -30,6 +29,8 @@ import java.util.Set;
import java.util.Map.Entry;
import java.util.logging.Logger;
+import com.google.common.collect.ImmutableSet;
+
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
import org.jclouds.cloudloadbalancers.domain.Node;
@@ -71,7 +72,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
String region = lb.getRegion();
Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
Set newNodes = client.getNodeClient(region).createNodesInLoadBalancer(
- Collections. singleton(NodeRequest.builder().address("192.168.1.2").port(8080).build()),
+ ImmutableSet. of(NodeRequest.builder().address("192.168.1.2").port(8080).build()),
lb.getId());
for (Node n : newNodes) {
diff --git a/apis/cloudservers/pom.xml b/apis/cloudservers/pom.xml
index 41a3c0acfe..a9f3749c4c 100644
--- a/apis/cloudservers/pom.xml
+++ b/apis/cloudservers/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xml
diff --git a/apis/cloudsigma/pom.xml b/apis/cloudsigma/pom.xml
index d36ea17daa..b946d7412b 100644
--- a/apis/cloudsigma/pom.xml
+++ b/apis/cloudsigma/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
index bbedf65bdc..5a882ff28f 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
@@ -25,12 +25,13 @@ import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
* @author Adrian Cole
*/
-@Test(groups = "live")
+@Test(groups = "live", testName = "CloudSigmaComputeServiceLiveTest")
public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public CloudSigmaComputeServiceLiveTest() {
@@ -46,14 +47,21 @@ public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest
@Override
protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) {
assert node.getUserMetadata().equals(ImmutableMap. of()) : String.format(
- "node userMetadata did not match %s %s", userMetadata, node);
+ "node userMetadata did not match %s %s", userMetadata, node);
}
-
+
+ // cloudsigma does not support tags
+ @Override
+ protected void checkTagsInNodeEquals(final NodeMetadata node, final ImmutableSet tags) {
+ assert node.getTags().equals(ImmutableSet. of()) : String.format("node tags did not match %s %s", tags,
+ node);
+ }
+
protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) {
// hostname is not predictable based on node metadata
assert execResponse.getOutput().trim().equals("ubuntu");
}
-
+
@Override
public void testOptionToNotBlock() {
// start call has to block until we have a pool of reserved pre-cloned drives.
diff --git a/apis/cloudstack/pom.xml b/apis/cloudstack/pom.xml
index c711e8d8fa..c294366cdd 100644
--- a/apis/cloudstack/pom.xml
+++ b/apis/cloudstack/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
index cdb671f895..d0bf37c0b0 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
@@ -23,6 +23,7 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
+import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@@ -91,7 +92,10 @@ public class CloudStackApiMetadata extends BaseRestApiMetadata {
.version("2.2")
.view(TypeToken.of(CloudStackContext.class))
.defaultProperties(CloudStackApiMetadata.defaultProperties())
- .defaultModules(ImmutableSet.>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
+ .defaultModules(ImmutableSet.> builder()
+ .add(CloudStackParserModule.class)
+ .add(CloudStackRestClientModule.class)
+ .add(CloudStackComputeServiceContextModule.class).build());
}
@Override
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackDateAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackDateAdapter.java
deleted file mode 100644
index e0bc79b1d9..0000000000
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackDateAdapter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.cloudstack.config;
-
-import java.io.IOException;
-import java.util.Date;
-
-import javax.inject.Inject;
-
-import org.jclouds.date.DateService;
-import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-
-import com.google.gson.stream.JsonReader;
-
-/**
- * Data adapter for the date formats used by CloudStack.
- *
- * Essentially this is a workaround for the CloudStack getUsage() API call returning a
- * corrupted form of ISO-8601 dates, which have an unexpected pair of apostrophes, like
- * 2011-12-12'T'00:00:00+00:00
- *
- * @author Richard Downer
- */
-public class CloudStackDateAdapter extends Iso8601DateAdapter {
-
- @Inject
- private CloudStackDateAdapter(DateService dateService) {
- super(dateService);
- }
-
- public Date read(JsonReader reader) throws IOException {
- return parseDate(reader.nextString().replaceAll("'T'", "T"));
- }
-
-}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java
new file mode 100644
index 0000000000..086529fc30
--- /dev/null
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java
@@ -0,0 +1,115 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jclouds.cloudstack.config;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.inject.Inject;
+
+import org.jclouds.date.DateService;
+import org.jclouds.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+import org.jclouds.json.internal.IgnoreNullIterableTypeAdapterFactory;
+
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.ImmutableSet;
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import com.google.inject.AbstractModule;
+
+/**
+ * @author Adrian Cole
+ */
+public class CloudStackParserModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(CloudStackDateAdapter.class);
+ bind(IgnoreNullIterableTypeAdapterFactory.class).to(CommaDelimitedOKIgnoreNullIterableTypeAdapterFactory.class);
+ }
+
+ /**
+ * Data adapter for the date formats used by CloudStack.
+ *
+ * Essentially this is a workaround for the CloudStack getUsage() API call returning a corrupted
+ * form of ISO-8601 dates, which have an unexpected pair of apostrophes, like
+ * 2011-12-12'T'00:00:00+00:00
+ *
+ * @author Richard Downer
+ */
+ public static class CloudStackDateAdapter extends Iso8601DateAdapter {
+
+ @Inject
+ private CloudStackDateAdapter(DateService dateService) {
+ super(dateService);
+ }
+
+ public Date read(JsonReader reader) throws IOException {
+ return parseDate(reader.nextString().replaceAll("'T'", "T"));
+ }
+
+ }
+
+ /**
+ * Handles types that were previously strings and now arrays (ex. tags)
+ *
+ * @author Adrian Cole
+ */
+ public static class CommaDelimitedOKIgnoreNullIterableTypeAdapterFactory extends IgnoreNullIterableTypeAdapterFactory {
+
+ @Override
+ protected TypeAdapter> newIterableAdapter(final TypeAdapter elementAdapter) {
+ return new TypeAdapter>() {
+ public void write(JsonWriter out, Iterable value) throws IOException {
+ out.beginArray();
+ for (E element : value) {
+ elementAdapter.write(out, element);
+ }
+ out.endArray();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterable read(JsonReader in) throws IOException {
+ // HACK as cloudstack changed a field from String to Set!
+ if (in.peek() == JsonToken.STRING) {
+ String val = Strings.emptyToNull(in.nextString());
+ return (Iterable) (val != null ? Splitter.on(',').split(val) : ImmutableSet.of());
+ } else {
+ Builder builder = ImmutableList. builder();
+ in.beginArray();
+ while (in.hasNext()) {
+ E element = elementAdapter.read(in);
+ if (element != null)
+ builder.add(element);
+ }
+ in.endArray();
+ return builder.build();
+ }
+ }
+ }.nullSafe();
+ }
+ }
+
+}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java
index 695d72864c..cbdb216c61 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java
@@ -33,7 +33,86 @@ import org.jclouds.cloudstack.CloudStackDomainClient;
import org.jclouds.cloudstack.CloudStackGlobalAsyncClient;
import org.jclouds.cloudstack.CloudStackGlobalClient;
import org.jclouds.cloudstack.domain.LoginResponse;
-import org.jclouds.cloudstack.features.*;
+import org.jclouds.cloudstack.features.AccountAsyncClient;
+import org.jclouds.cloudstack.features.AccountClient;
+import org.jclouds.cloudstack.features.AddressAsyncClient;
+import org.jclouds.cloudstack.features.AddressClient;
+import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
+import org.jclouds.cloudstack.features.AsyncJobClient;
+import org.jclouds.cloudstack.features.ConfigurationAsyncClient;
+import org.jclouds.cloudstack.features.ConfigurationClient;
+import org.jclouds.cloudstack.features.DomainAccountAsyncClient;
+import org.jclouds.cloudstack.features.DomainAccountClient;
+import org.jclouds.cloudstack.features.DomainDomainAsyncClient;
+import org.jclouds.cloudstack.features.DomainDomainClient;
+import org.jclouds.cloudstack.features.DomainLimitAsyncClient;
+import org.jclouds.cloudstack.features.DomainLimitClient;
+import org.jclouds.cloudstack.features.DomainUserAsyncClient;
+import org.jclouds.cloudstack.features.DomainUserClient;
+import org.jclouds.cloudstack.features.EventAsyncClient;
+import org.jclouds.cloudstack.features.EventClient;
+import org.jclouds.cloudstack.features.FirewallAsyncClient;
+import org.jclouds.cloudstack.features.FirewallClient;
+import org.jclouds.cloudstack.features.GlobalAccountAsyncClient;
+import org.jclouds.cloudstack.features.GlobalAccountClient;
+import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
+import org.jclouds.cloudstack.features.GlobalAlertClient;
+import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
+import org.jclouds.cloudstack.features.GlobalCapacityClient;
+import org.jclouds.cloudstack.features.GlobalConfigurationAsyncClient;
+import org.jclouds.cloudstack.features.GlobalConfigurationClient;
+import org.jclouds.cloudstack.features.GlobalDomainAsyncClient;
+import org.jclouds.cloudstack.features.GlobalDomainClient;
+import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
+import org.jclouds.cloudstack.features.GlobalHostClient;
+import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
+import org.jclouds.cloudstack.features.GlobalOfferingClient;
+import org.jclouds.cloudstack.features.GlobalPodAsyncClient;
+import org.jclouds.cloudstack.features.GlobalPodClient;
+import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
+import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
+import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
+import org.jclouds.cloudstack.features.GlobalUsageClient;
+import org.jclouds.cloudstack.features.GlobalUserAsyncClient;
+import org.jclouds.cloudstack.features.GlobalUserClient;
+import org.jclouds.cloudstack.features.GlobalVlanAsyncClient;
+import org.jclouds.cloudstack.features.GlobalVlanClient;
+import org.jclouds.cloudstack.features.GlobalZoneAsyncClient;
+import org.jclouds.cloudstack.features.GlobalZoneClient;
+import org.jclouds.cloudstack.features.GuestOSAsyncClient;
+import org.jclouds.cloudstack.features.GuestOSClient;
+import org.jclouds.cloudstack.features.HypervisorAsyncClient;
+import org.jclouds.cloudstack.features.HypervisorClient;
+import org.jclouds.cloudstack.features.ISOAsyncClient;
+import org.jclouds.cloudstack.features.ISOClient;
+import org.jclouds.cloudstack.features.LimitAsyncClient;
+import org.jclouds.cloudstack.features.LimitClient;
+import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
+import org.jclouds.cloudstack.features.LoadBalancerClient;
+import org.jclouds.cloudstack.features.NATAsyncClient;
+import org.jclouds.cloudstack.features.NATClient;
+import org.jclouds.cloudstack.features.NetworkAsyncClient;
+import org.jclouds.cloudstack.features.NetworkClient;
+import org.jclouds.cloudstack.features.OfferingAsyncClient;
+import org.jclouds.cloudstack.features.OfferingClient;
+import org.jclouds.cloudstack.features.SSHKeyPairAsyncClient;
+import org.jclouds.cloudstack.features.SSHKeyPairClient;
+import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
+import org.jclouds.cloudstack.features.SecurityGroupClient;
+import org.jclouds.cloudstack.features.SessionAsyncClient;
+import org.jclouds.cloudstack.features.SessionClient;
+import org.jclouds.cloudstack.features.SnapshotAsyncClient;
+import org.jclouds.cloudstack.features.SnapshotClient;
+import org.jclouds.cloudstack.features.TemplateAsyncClient;
+import org.jclouds.cloudstack.features.TemplateClient;
+import org.jclouds.cloudstack.features.VMGroupAsyncClient;
+import org.jclouds.cloudstack.features.VMGroupClient;
+import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
+import org.jclouds.cloudstack.features.VirtualMachineClient;
+import org.jclouds.cloudstack.features.VolumeAsyncClient;
+import org.jclouds.cloudstack.features.VolumeClient;
+import org.jclouds.cloudstack.features.ZoneAsyncClient;
+import org.jclouds.cloudstack.features.ZoneClient;
import org.jclouds.cloudstack.filters.AddSessionKeyAndJSessionIdToRequest;
import org.jclouds.cloudstack.filters.AuthenticationFilter;
import org.jclouds.cloudstack.filters.QuerySigner;
@@ -47,7 +126,6 @@ import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
-import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
@@ -147,7 +225,6 @@ public class CloudStackRestClientModule extends RestClientModule>() {
}).to(new TypeLiteral>() {
});
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java
index ba0a5874ed..97632e4e6e 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/DiskOffering.java
@@ -22,11 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
+import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
/**
* Class DiskOffering
@@ -54,7 +56,7 @@ public class DiskOffering implements Comparable {
protected String domainId;
protected int diskSize;
protected boolean customized;
- protected String tags;
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
/**
* @see DiskOffering#getId()
@@ -123,13 +125,21 @@ public class DiskOffering implements Comparable {
/**
* @see DiskOffering#getTags()
*/
- public T tags(String tags) {
- this.tags = tags;
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
return self();
}
-
+
+ /**
+ * @see DiskOffering#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
+ return self();
+ }
+
public DiskOffering build() {
- return new DiskOffering(id, name, displayText, created, domain, domainId, diskSize, customized, tags);
+ return new DiskOffering(id, name, displayText, created, domain, domainId, diskSize, customized, tags.build());
}
public T fromDiskOffering(DiskOffering in) {
@@ -161,14 +171,14 @@ public class DiskOffering implements Comparable {
private final String domainId;
private final int diskSize;
private final boolean customized;
- private final String tags;
+ private final Set tags;
@ConstructorProperties({
"id", "name", "displaytext", "created", "domain", "domainid", "disksize", "iscustomized", "tags"
})
protected DiskOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created,
@Nullable String domain, @Nullable String domainId, int diskSize, boolean customized,
- @Nullable String tags) {
+ @Nullable Iterable tags) {
this.id = checkNotNull(id, "id");
this.name = name;
this.displayText = displayText;
@@ -177,7 +187,7 @@ public class DiskOffering implements Comparable {
this.domainId = domainId;
this.diskSize = diskSize;
this.customized = customized;
- this.tags = tags;
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
}
/**
@@ -244,8 +254,7 @@ public class DiskOffering implements Comparable {
/**
* @return the tags for the disk offering
*/
- @Nullable
- public String getTags() {
+ public Set getTags() {
return this.tags;
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java
index 7d9ea4a982..1cd4c6e15b 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Host.java
@@ -24,11 +24,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
+import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
/**
* Represents a host issued by Cloudstack
@@ -149,7 +151,7 @@ public class Host implements Comparable {
protected long diskSizeTotal;
protected String events;
protected boolean hasEnoughCapacity;
- protected String hostTags;
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
protected String hypervisor;
protected String ipAddress;
protected boolean localStorageActive;
@@ -319,13 +321,21 @@ public class Host implements Comparable {
}
/**
- * @see Host#getHostTags()
+ * @see Host#getTags()
*/
- public T hostTags(String hostTags) {
- this.hostTags = hostTags;
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
return self();
}
-
+
+ /**
+ * @see Host#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
+ return self();
+ }
+
/**
* @see Host#getHypervisor()
*/
@@ -512,7 +522,7 @@ public class Host implements Comparable {
public Host build() {
- return new Host(id, allocationState, averageLoad, capabilities, clusterId, clusterName, clusterType, cpuAllocated, cpuNumber, cpuSpeed, cpuUsed, cpuWithOverProvisioning, created, disconnected, diskSizeAllocated, diskSizeTotal, events, hasEnoughCapacity, hostTags, hypervisor, ipAddress, localStorageActive, jobId, jobStatus, lastPinged, managementServerId, memoryAllocated, memoryTotal, memoryUsed, name, networkKbsRead, networkKbsWrite, osCategoryId, osCategoryName, podId, podName, removed, state, type, version, zoneId, zoneName);
+ return new Host(id, allocationState, averageLoad, capabilities, clusterId, clusterName, clusterType, cpuAllocated, cpuNumber, cpuSpeed, cpuUsed, cpuWithOverProvisioning, created, disconnected, diskSizeAllocated, diskSizeTotal, events, hasEnoughCapacity, tags.build(), hypervisor, ipAddress, localStorageActive, jobId, jobStatus, lastPinged, managementServerId, memoryAllocated, memoryTotal, memoryUsed, name, networkKbsRead, networkKbsWrite, osCategoryId, osCategoryName, podId, podName, removed, state, type, version, zoneId, zoneName);
}
public T fromHost(Host in) {
@@ -535,7 +545,7 @@ public class Host implements Comparable {
.diskSizeTotal(in.getDiskSizeTotal())
.events(in.getEvents())
.hasEnoughCapacity(in.isHasEnoughCapacity())
- .hostTags(in.getHostTags())
+ .tags(in.getTags())
.hypervisor(in.getHypervisor())
.ipAddress(in.getIpAddress())
.localStorageActive(in.isLocalStorageActive())
@@ -587,7 +597,7 @@ public class Host implements Comparable {
private final long diskSizeTotal;
private final String events;
private final boolean hasEnoughCapacity;
- private final String hostTags;
+ private final Set tags;
private final String hypervisor;
private final String ipAddress;
private final boolean localStorageActive;
@@ -619,7 +629,7 @@ public class Host implements Comparable {
@Nullable String clusterId, @Nullable String clusterName, @Nullable Host.ClusterType clusterType,
@Nullable String cpuAllocated, int cpuNumber, int cpuSpeed, @Nullable String cpuUsed,
float cpuWithOverProvisioning, @Nullable Date created, @Nullable Date disconnected, long diskSizeAllocated,
- long diskSizeTotal, @Nullable String events, boolean hasEnoughCapacity, @Nullable String hostTags,
+ long diskSizeTotal, @Nullable String events, boolean hasEnoughCapacity, @Nullable Iterable tags,
@Nullable String hypervisor, @Nullable String ipAddress, boolean localStorageActive, @Nullable String jobId,
@Nullable AsyncJob.Status jobStatus, @Nullable Date lastPinged, @Nullable String managementServerId,
long memoryAllocated, long memoryTotal, long memoryUsed, @Nullable String name, long networkKbsRead, long networkKbsWrite,
@@ -644,7 +654,7 @@ public class Host implements Comparable {
this.diskSizeTotal = diskSizeTotal;
this.events = events;
this.hasEnoughCapacity = hasEnoughCapacity;
- this.hostTags = hostTags;
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
this.hypervisor = hypervisor;
this.ipAddress = ipAddress;
this.localStorageActive = localStorageActive;
@@ -752,11 +762,14 @@ public class Host implements Comparable {
return this.hasEnoughCapacity;
}
- @Nullable
- public String getHostTags() {
- return this.hostTags;
+ /**
+ * @return the tags for the host
+ */
+ public Set getTags() {
+ return this.tags;
}
+
@Nullable
public String getHypervisor() {
return this.hypervisor;
@@ -868,7 +881,7 @@ public class Host implements Comparable {
@Override
public int hashCode() {
- return Objects.hashCode(id, allocationState, averageLoad, capabilities, clusterId, clusterName, clusterType, cpuAllocated, cpuNumber, cpuSpeed, cpuUsed, cpuWithOverProvisioning, created, disconnected, diskSizeAllocated, diskSizeTotal, events, hasEnoughCapacity, hostTags, hypervisor, ipAddress, localStorageActive, jobId, jobStatus, lastPinged, managementServerId, memoryAllocated, memoryTotal, memoryUsed, name, networkKbsRead, networkKbsWrite, osCategoryId, osCategoryName, podId, podName, removed, state, type, version, zoneId, zoneName);
+ return Objects.hashCode(id, allocationState, averageLoad, capabilities, clusterId, clusterName, clusterType, cpuAllocated, cpuNumber, cpuSpeed, cpuUsed, cpuWithOverProvisioning, created, disconnected, diskSizeAllocated, diskSizeTotal, events, hasEnoughCapacity, tags, hypervisor, ipAddress, localStorageActive, jobId, jobStatus, lastPinged, managementServerId, memoryAllocated, memoryTotal, memoryUsed, name, networkKbsRead, networkKbsWrite, osCategoryId, osCategoryName, podId, podName, removed, state, type, version, zoneId, zoneName);
}
@Override
@@ -894,7 +907,7 @@ public class Host implements Comparable {
&& Objects.equal(this.diskSizeTotal, that.diskSizeTotal)
&& Objects.equal(this.events, that.events)
&& Objects.equal(this.hasEnoughCapacity, that.hasEnoughCapacity)
- && Objects.equal(this.hostTags, that.hostTags)
+ && Objects.equal(this.tags, that.tags)
&& Objects.equal(this.hypervisor, that.hypervisor)
&& Objects.equal(this.ipAddress, that.ipAddress)
&& Objects.equal(this.localStorageActive, that.localStorageActive)
@@ -928,7 +941,7 @@ public class Host implements Comparable {
.add("cpuSpeed", cpuSpeed).add("cpuUsed", cpuUsed).add("cpuWithOverProvisioning", cpuWithOverProvisioning)
.add("created", created).add("disconnected", disconnected).add("diskSizeAllocated", diskSizeAllocated)
.add("diskSizeTotal", diskSizeTotal).add("events", events).add("hasEnoughCapacity", hasEnoughCapacity)
- .add("hostTags", hostTags).add("hypervisor", hypervisor).add("ipAddress", ipAddress)
+ .add("tags", tags).add("hypervisor", hypervisor).add("ipAddress", ipAddress)
.add("localStorageActive", localStorageActive).add("jobId", jobId).add("jobStatus", jobStatus)
.add("lastPinged", lastPinged).add("managementServerId", managementServerId).add("memoryAllocated", memoryAllocated)
.add("memoryTotal", memoryTotal).add("memoryUsed", memoryUsed).add("name", name).add("networkKbsRead", networkKbsRead)
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java
index 457edd049c..08dd4501d9 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/Network.java
@@ -30,6 +30,7 @@ import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
/**
@@ -78,7 +79,7 @@ public class Network {
protected String VLAN;
protected TrafficType trafficType;
protected String zoneId;
- protected String tags;
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
protected boolean securityGroupEnabled;
protected Set extends NetworkService> services = ImmutableSortedSet.of();
@@ -302,10 +303,19 @@ public class Network {
/**
* @see Network#getTags()
*/
- public T tags(String tags) {
- this.tags = tags;
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
return self();
}
+
+ /**
+ * @see Network#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
+ return self();
+ }
+
/**
* @see Network#isSecurityGroupEnabled()
@@ -324,7 +334,7 @@ public class Network {
}
public Network build() {
- return new Network(id, account, broadcastDomainType, broadcastURI, displayText, DNS1, DNS2, domain, domainId, endIP, gateway, isDefault, isShared, isSystem, netmask, networkDomain, networkOfferingAvailability, networkOfferingDisplayText, networkOfferingId, networkOfferingName, related, startIP, name, state, guestIPType, VLAN, trafficType, zoneId, tags, securityGroupEnabled, services);
+ return new Network(id, account, broadcastDomainType, broadcastURI, displayText, DNS1, DNS2, domain, domainId, endIP, gateway, isDefault, isShared, isSystem, netmask, networkDomain, networkOfferingAvailability, networkOfferingDisplayText, networkOfferingId, networkOfferingName, related, startIP, name, state, guestIPType, VLAN, trafficType, zoneId, tags.build(), securityGroupEnabled, services);
}
public T fromNetwork(Network in) {
@@ -397,7 +407,7 @@ public class Network {
private final String VLAN;
private final TrafficType trafficType;
private final String zoneId;
- private final String tags;
+ private final Set tags;
private final boolean securityGroupEnabled;
private final Set extends NetworkService> services;
@@ -411,7 +421,7 @@ public class Network {
@Nullable String networkOfferingDisplayText, @Nullable String networkOfferingId, @Nullable String networkOfferingName,
@Nullable String related, @Nullable String startIP, @Nullable String name, @Nullable String state,
@Nullable GuestIPType guestIPType, @Nullable String VLAN, @Nullable TrafficType trafficType,
- @Nullable String zoneId, @Nullable String tags, boolean securityGroupEnabled, Set extends NetworkService> services) {
+ @Nullable String zoneId, @Nullable Iterable tags, boolean securityGroupEnabled, Set extends NetworkService> services) {
this.id = checkNotNull(id, "id");
this.account = account;
this.broadcastDomainType = broadcastDomainType;
@@ -440,7 +450,7 @@ public class Network {
this.VLAN = VLAN;
this.trafficType = trafficType;
this.zoneId = zoneId;
- this.tags = tags;
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
this.securityGroupEnabled = securityGroupEnabled;
this.services = ImmutableSortedSet.copyOf(services);
}
@@ -660,8 +670,7 @@ public class Network {
/**
* @return the tags for the Network
*/
- @Nullable
- public String getTags() {
+ public Set getTags() {
return this.tags;
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java
index 876b5245d6..1ec0a857a9 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkOffering.java
@@ -22,11 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
+import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
/**
* Class NetworkOffering
@@ -57,7 +59,7 @@ public class NetworkOffering implements Comparable {
protected TrafficType trafficType;
protected GuestIPType guestIPType;
protected int networkRate;
- protected String tags;
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
/**
* @see NetworkOffering#getId()
@@ -146,17 +148,26 @@ public class NetworkOffering implements Comparable {
this.networkRate = networkRate;
return self();
}
-
+
/**
* @see NetworkOffering#getTags()
*/
- public T tags(String tags) {
- this.tags = tags;
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
return self();
}
+
+ /**
+ * @see NetworkOffering#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
+ return self();
+ }
+
public NetworkOffering build() {
- return new NetworkOffering(id, name, displayText, created, availability, maxConnections, isDefault, supportsVLAN, trafficType, guestIPType, networkRate, tags);
+ return new NetworkOffering(id, name, displayText, created, availability, maxConnections, isDefault, supportsVLAN, trafficType, guestIPType, networkRate, tags.build());
}
public T fromNetworkOffering(NetworkOffering in) {
@@ -194,12 +205,12 @@ public class NetworkOffering implements Comparable {
private final TrafficType trafficType;
private final GuestIPType guestIPType;
private final int networkRate;
- private final String tags;
+ private final Set tags;
@ConstructorProperties({
"id", "name", "displaytext", "created", "availability", "maxconnections", "isdefault", "specifyvlan", "traffictype", "guestiptype", "networkrate", "tags"
})
- protected NetworkOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created, @Nullable NetworkOfferingAvailabilityType availability, @Nullable Integer maxConnections, boolean isDefault, boolean supportsVLAN, @Nullable TrafficType trafficType, @Nullable GuestIPType guestIPType, int networkRate, @Nullable String tags) {
+ protected NetworkOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created, @Nullable NetworkOfferingAvailabilityType availability, @Nullable Integer maxConnections, boolean isDefault, boolean supportsVLAN, @Nullable TrafficType trafficType, @Nullable GuestIPType guestIPType, int networkRate, @Nullable Iterable tags) {
this.id = checkNotNull(id, "id");
this.name = name;
this.displayText = displayText;
@@ -211,7 +222,7 @@ public class NetworkOffering implements Comparable {
this.trafficType = trafficType;
this.guestIPType = guestIPType;
this.networkRate = networkRate;
- this.tags = tags;
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
}
/**
@@ -302,8 +313,7 @@ public class NetworkOffering implements Comparable {
/**
* @return the tags for the network offering
*/
- @Nullable
- public String getTags() {
+ public Set getTags() {
return this.tags;
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java
index b5bd47f365..e472da73c3 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/ServiceOffering.java
@@ -26,11 +26,8 @@ import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
-import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
/**
@@ -63,12 +60,11 @@ public class ServiceOffering implements Comparable {
protected boolean haSupport;
protected StorageType storageType;
protected boolean defaultUse;
- protected String hostTags;
protected boolean systemOffering;
protected boolean cpuUseLimited;
protected long networkRate;
protected boolean systemVmType;
- private Set tags = ImmutableSet.of();
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
/**
* @see ServiceOffering#getId()
@@ -161,11 +157,19 @@ public class ServiceOffering implements Comparable {
/**
* @see ServiceOffering#getTags()
*/
- public T tags(Set tags) {
- this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
return self();
}
-
+
+ /**
+ * @see ServiceOffering#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
+ return self();
+ }
+
/**
* @see ServiceOffering#isDefaultUse()
*/
@@ -174,14 +178,6 @@ public class ServiceOffering implements Comparable {
return self();
}
- /**
- * @see ServiceOffering#getHostTags()
- */
- public T hostTags(String hostTags) {
- this.hostTags = hostTags;
- return self();
- }
-
/**
* @see ServiceOffering#isSystemOffering()
*/
@@ -216,7 +212,7 @@ public class ServiceOffering implements Comparable {
public ServiceOffering build() {
return new ServiceOffering(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, haSupport, storageType,
- Joiner.on(",").join(tags), defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate, systemVmType);
+ tags.build(), defaultUse, systemOffering, cpuUseLimited, networkRate, systemVmType);
}
public T fromServiceOffering(ServiceOffering in) {
@@ -234,7 +230,6 @@ public class ServiceOffering implements Comparable {
.storageType(in.getStorageType())
.tags(in.getTags())
.defaultUse(in.isDefaultUse())
- .hostTags(in.getHostTags())
.systemOffering(in.isSystemOffering())
.cpuUseLimited(in.isCpuUseLimited())
.networkRate(in.getNetworkRate())
@@ -262,19 +257,18 @@ public class ServiceOffering implements Comparable {
private final StorageType storageType;
private final Set tags;
private final boolean defaultUse;
- private final String hostTags;
private final boolean systemOffering;
private final boolean cpuUseLimited;
private final long networkRate;
private final boolean systemVmType;
@ConstructorProperties({
- "id", "name", "displaytext", "created", "domain", "domainid", "cpunumber", "cpuspeed", "memory", "offerha", "storagetype", "tags", "defaultuse", "hosttags", "issystem", "limitcpuuse", "networkrate", "systemvmtype"
+ "id", "name", "displaytext", "created", "domain", "domainid", "cpunumber", "cpuspeed", "memory", "offerha", "storagetype", "tags", "defaultuse", "issystem", "limitcpuuse", "networkrate", "systemvmtype"
})
protected ServiceOffering(String id, @Nullable String name, @Nullable String displayText, @Nullable Date created,
@Nullable String domain, @Nullable String domainId, int cpuNumber, int cpuSpeed, int memory,
- boolean haSupport, @Nullable StorageType storageType, @Nullable String tags, boolean defaultUse,
- @Nullable String hostTags, boolean systemOffering, boolean cpuUseLimited, long networkRate, boolean systemVmType) {
+ boolean haSupport, @Nullable StorageType storageType, @Nullable Iterable tags, boolean defaultUse,
+ boolean systemOffering, boolean cpuUseLimited, long networkRate, boolean systemVmType) {
this.id = checkNotNull(id, "id");
this.name = name;
this.displayText = displayText;
@@ -286,10 +280,8 @@ public class ServiceOffering implements Comparable {
this.memory = memory;
this.haSupport = haSupport;
this.storageType = storageType;
- this.tags = !(Strings.emptyToNull(tags) == null) ? ImmutableSet.copyOf(Splitter.on(',').split(tags))
- : ImmutableSet. of();
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
this.defaultUse = defaultUse;
- this.hostTags = hostTags;
this.systemOffering = systemOffering;
this.cpuUseLimited = cpuUseLimited;
this.networkRate = networkRate;
@@ -389,14 +381,6 @@ public class ServiceOffering implements Comparable {
return this.defaultUse;
}
- /**
- * @return the host tag for the service offering
- */
- @Nullable
- public String getHostTags() {
- return this.hostTags;
- }
-
/**
* @return whether this is a system vm offering
*/
@@ -427,7 +411,7 @@ public class ServiceOffering implements Comparable {
@Override
public int hashCode() {
- return Objects.hashCode(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, haSupport, storageType, tags, defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate, systemVmType);
+ return Objects.hashCode(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, haSupport, storageType, tags, defaultUse, systemOffering, cpuUseLimited, networkRate, systemVmType);
}
@Override
@@ -448,7 +432,6 @@ public class ServiceOffering implements Comparable {
&& Objects.equal(this.storageType, that.storageType)
&& Objects.equal(this.getTags(), that.getTags())
&& Objects.equal(this.defaultUse, that.defaultUse)
- && Objects.equal(this.hostTags, that.hostTags)
&& Objects.equal(this.systemOffering, that.systemOffering)
&& Objects.equal(this.cpuUseLimited, that.cpuUseLimited)
&& Objects.equal(this.networkRate, that.networkRate)
@@ -460,7 +443,7 @@ public class ServiceOffering implements Comparable {
.add("id", id).add("name", name).add("displayText", displayText).add("created", created).add("domain", domain)
.add("domainId", domainId).add("cpuNumber", cpuNumber).add("cpuSpeed", cpuSpeed).add("memory", memory)
.add("haSupport", haSupport).add("storageType", storageType).add("tags", getTags()).add("defaultUse", defaultUse)
- .add("hostTags", hostTags).add("systemOffering", systemOffering).add("cpuUseLimited", cpuUseLimited)
+ .add("systemOffering", systemOffering).add("cpuUseLimited", cpuUseLimited)
.add("networkRate", networkRate).add("systemVmType", systemVmType);
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java
index 5416c07c24..5c9a32775b 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/StoragePool.java
@@ -22,12 +22,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
+import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
/**
* Represents a storage pool in CloudStack
@@ -102,7 +104,7 @@ public class StoragePool implements Comparable {
protected String id;
protected String name;
protected String path;
- protected String tags;
+ protected ImmutableSet.Builder tags = ImmutableSet.builder();
protected StoragePool.State state;
protected StoragePool.Type type;
protected String zoneId;
@@ -143,10 +145,18 @@ public class StoragePool implements Comparable {
}
/**
- * @see StoragePool#getTags()
+ * @see DiskOffering#getTags()
*/
- public T tags(String tags) {
- this.tags = tags;
+ public T tags(Iterable tags) {
+ this.tags = ImmutableSet.builder().addAll(tags);
+ return self();
+ }
+
+ /**
+ * @see DiskOffering#getTags()
+ */
+ public T tag(String tag) {
+ this.tags.add(tag);
return self();
}
@@ -263,7 +273,7 @@ public class StoragePool implements Comparable {
}
public StoragePool build() {
- return new StoragePool(id, name, path, tags, state, type, zoneId, zoneName, podId, podName, clusterId, clusterName, created, diskSizeAllocated, diskSizeTotal, ipAddress, jobId, jobStatus);
+ return new StoragePool(id, name, path, tags.build(), state, type, zoneId, zoneName, podId, podName, clusterId, clusterName, created, diskSizeAllocated, diskSizeTotal, ipAddress, jobId, jobStatus);
}
public T fromStoragePool(StoragePool in) {
@@ -299,7 +309,7 @@ public class StoragePool implements Comparable {
private final String id;
private final String name;
private final String path;
- private final String tags;
+ private final Set tags;
private final StoragePool.State state;
private final StoragePool.Type type;
private final String zoneId;
@@ -318,11 +328,15 @@ public class StoragePool implements Comparable {
@ConstructorProperties({
"id", "name", "path", "tags", "state", "type", "zoneid", "zonename", "podid", "podname", "clusterid", "clustername", "created", "disksizeallocated", "disksizetotal", "ipaddress", "jobid", "jobstatus"
})
- protected StoragePool(String id, @Nullable String name, @Nullable String path, @Nullable String tags, @Nullable StoragePool.State state, @Nullable StoragePool.Type type, @Nullable String zoneId, @Nullable String zoneName, @Nullable String podId, @Nullable String podName, @Nullable String clusterId, @Nullable String clusterName, @Nullable Date created, long diskSizeAllocated, long diskSizeTotal, @Nullable String ipAddress, @Nullable String jobId, @Nullable String jobStatus) {
+ protected StoragePool(String id, @Nullable String name, @Nullable String path, @Nullable Iterable tags,
+ @Nullable StoragePool.State state, @Nullable StoragePool.Type type, @Nullable String zoneId,
+ @Nullable String zoneName, @Nullable String podId, @Nullable String podName, @Nullable String clusterId,
+ @Nullable String clusterName, @Nullable Date created, long diskSizeAllocated, long diskSizeTotal,
+ @Nullable String ipAddress, @Nullable String jobId, @Nullable String jobStatus) {
this.id = checkNotNull(id, "id");
this.name = name;
this.path = path;
- this.tags = tags;
+ this.tags = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet. of();
this.state = state;
this.type = type;
this.zoneId = zoneId;
@@ -353,8 +367,7 @@ public class StoragePool implements Comparable {
return this.path;
}
- @Nullable
- public String getTags() {
+ public Set getTags() {
return this.tags;
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java
index ecd39c6e92..bd578010d2 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/TemplateFilter.java
@@ -40,6 +40,15 @@ public enum TemplateFilter {
* to deploy a new VM
*/
SELF_EXECUTABLE,
+ /**
+ * templates that have been registered/created by the owner that can be used
+ * to deploy a new VM - 3.x filter value.
+ */
+ SELFEXECUTABLE,
+ /**
+ * templates that have been granted to the calling user by another user
+ */
+ SHAREDEXECUTABLE,
/**
* all templates that can be used to deploy a new VM
*/
@@ -47,7 +56,11 @@ public enum TemplateFilter {
/**
* templates that are public
*/
- COMMUNITY;
+ COMMUNITY,
+ /**
+ * All templates
+ */
+ ALL;
@Override
public String toString() {
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java
index 732a74c507..95807433c3 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/WindowsLoginCredentialsFromEncryptedData.java
@@ -1,6 +1,5 @@
package org.jclouds.cloudstack.functions;
-import java.nio.charset.Charset;
import java.security.KeyFactory;
import java.security.PrivateKey;
import java.security.spec.KeySpec;
@@ -14,6 +13,7 @@ import org.jclouds.domain.LoginCredentials;
import org.jclouds.encryption.internal.Base64;
import org.jclouds.javax.annotation.Nullable;
+import com.google.common.base.Charsets;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.inject.Inject;
@@ -48,7 +48,7 @@ public class WindowsLoginCredentialsFromEncryptedData implements Function EMPTY_NETWORKS_MAP = Collections.emptyMap();
+ private static final Map EMPTY_NETWORKS_MAP = ImmutableMap.of();
private static final String ZONE_ID = "2";
private final NetworkService firewallServiceWithStaticNat
= NetworkService.builder().name("Firewall").capabilities(ImmutableMap.of("StaticNat", "true")).build();
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java
index 26c96b0ac6..c7f4502381 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostClientExpectTest.java
@@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals;
import java.util.Calendar;
-import java.util.Collections;
import java.util.Date;
import java.util.Set;
import java.util.TimeZone;
@@ -65,7 +64,7 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
- Host host1 = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
+ Host host1 = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
Date disconnected = makeDate(2011, Calendar.NOVEMBER, 26, 23, 33, 38, "GMT+02:00");
lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 42, 30, "GMT+02:00");
@@ -109,10 +108,10 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
- Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
+ Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
Host actual = requestSendsResponse(request, response).addHost("1", "http://example.com", "XenServer", "fred", "sekrit",
- AddHostOptions.Builder.hostTags(Collections.emptySet()).allocationState(AllocationState.ENABLED).clusterId("1").clusterName("Xen Clust 1").podId("1"));
+ AddHostOptions.Builder.hostTags(ImmutableSet.of()).allocationState(AllocationState.ENABLED).clusterId("1").clusterName("Xen Clust 1").podId("1"));
assertEquals(actual, expected);
}
@@ -129,9 +128,9 @@ public class GlobalHostClientExpectTest extends BaseCloudStackRestClientExpectTe
Date lastPinged = makeDate(1970, Calendar.JANUARY, 16, 0, 54, 43, "GMT+02:00");
Date created = makeDate(2011, Calendar.NOVEMBER, 26, 23, 28, 36, "GMT+02:00");
- Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hostTags("").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
+ Host expected = Host.builder().id("1").name("cs2-xevsrv.alucloud.local").state(Host.State.UP).type(Host.Type.ROUTING).ipAddress("10.26.26.107").zoneId("1").zoneName("Dev Zone 1").podId("1").podName("Dev Pod 1").version("2.2.12.20110928142833").hypervisor("XenServer").cpuNumber(24).cpuSpeed(2266).cpuAllocated("2.76%").cpuUsed("0.1%").cpuWithOverProvisioning(54384.0F).networkKbsRead(4443).networkKbsWrite(15048).memoryTotal(100549733760L).memoryAllocated(3623878656L).memoryUsed(3623878656L).capabilities("xen-3.0-x86_64 , xen-3.0-x86_32p , hvm-3.0-x86_32 , hvm-3.0-x86_32p , hvm-3.0-x86_64").lastPinged(lastPinged).managementServerId("223098941760041").clusterId("1").clusterName("Xen Clust 1").clusterType(Host.ClusterType.CLOUD_MANAGED).localStorageActive(false).created(created).events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping").hasEnoughCapacity(false).allocationState(AllocationState.ENABLED).build();
- Host actual = requestSendsResponse(request, response).updateHost("1", UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(Collections.emptySet()).osCategoryId("5"));
+ Host actual = requestSendsResponse(request, response).updateHost("1", UpdateHostOptions.Builder.allocationState(AllocationState.ENABLED).hostTags(ImmutableSet.of()).osCategoryId("5"));
assertEquals(actual, expected);
}
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java
index b857fd6e83..60f909659e 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListHostsResponseTest.java
@@ -22,17 +22,16 @@ import static org.testng.Assert.assertEquals;
import java.util.Set;
+import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.domain.AllocationState;
import org.jclouds.cloudstack.domain.Host;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.json.BaseParserTest;
-import org.jclouds.json.BaseSetParserTest;
import org.jclouds.json.config.GsonModule;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
import com.google.inject.Guice;
import com.google.inject.Injector;
@@ -48,16 +47,7 @@ public class ListHostsResponseTest extends BaseParserTest, Set>
@Override
protected Injector injector() {
- return Guice.createInjector(new GsonModule() {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(Iso8601DateAdapter.class);
- super.configure();
- }
-
- });
-
+ return Guice.createInjector(new GsonModule(), new CloudStackParserModule());
}
@Override
@@ -102,7 +92,6 @@ public class ListHostsResponseTest extends BaseParserTest, Set>
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-26T23:28:36+0200"))
.events("PrepareUnmanaged; HypervisorVersionChanged; ManagementServerDown; PingTimeout; " +
"AgentDisconnected; MaintenanceRequested; HostDown; AgentConnected; StartAgentRebalance; ShutdownRequested; Ping")
- .hostTags("")
.hasEnoughCapacity(false)
.allocationState(AllocationState.ENABLED).build(),
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListStoragePoolsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListStoragePoolsResponseTest.java
index 2c4f85dcd4..661afca398 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListStoragePoolsResponseTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListStoragePoolsResponseTest.java
@@ -23,18 +23,22 @@ import java.util.Date;
import java.util.Set;
import java.util.TimeZone;
+import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.domain.StoragePool;
import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
/**
*
* @author Richard Downer
*/
-@Test(groups = "unit")
+@Test(groups = "unit", testName = "ListStoragePoolsResponseTest")
public class ListStoragePoolsResponseTest extends BaseItemParserTest> {
@Override
@@ -54,7 +58,16 @@ public class ListStoragePoolsResponseTest extends BaseItemParserTest
.templateId("0").id("203").startDate(start).endDate(end).build());
}
-
+
@Override
protected Injector injector() {
- return Guice.createInjector(new GsonModule() {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(CloudStackDateAdapter.class);
- super.configure();
- }
-
- });
+ return Guice.createInjector(new GsonModule(), new CloudStackParserModule());
}
+
}
diff --git a/apis/cloudstack/src/test/resources/liststoragepoolsresponse.json b/apis/cloudstack/src/test/resources/liststoragepoolsresponse.json
index deca7a28c7..dc3ae46444 100644
--- a/apis/cloudstack/src/test/resources/liststoragepoolsresponse.json
+++ b/apis/cloudstack/src/test/resources/liststoragepoolsresponse.json
@@ -1 +1 @@
-{ "liststoragepoolsresponse" : { "count":1 ,"storagepool" : [ {"id":201,"zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","name":"NFS Pri 1","ipaddress":"10.26.26.165","path":"/mnt/nfs/cs_pri","created":"2011-11-26T23:33:06+0200","type":"NetworkFilesystem","clusterid":1,"clustername":"Xen Clust 1","disksizetotal":898356445184,"disksizeallocated":18276679680,"tags":"","state":"Up"} ] } }
\ No newline at end of file
+{ "liststoragepoolsresponse" : { "count":1 ,"storagepool" : [ {"id":201,"zoneid":1,"zonename":"Dev Zone 1","podid":1,"podname":"Dev Pod 1","name":"NFS Pri 1","ipaddress":"10.26.26.165","path":"/mnt/nfs/cs_pri","created":"2011-11-26T23:33:06+0200","type":"NetworkFilesystem","clusterid":1,"clustername":"Xen Clust 1","disksizetotal":898356445184,"disksizeallocated":18276679680,"tags":"tag1","state":"Up"} ] } }
\ No newline at end of file
diff --git a/apis/cloudwatch/pom.xml b/apis/cloudwatch/pom.xml
index 7628283e0a..16fb1c5003 100644
--- a/apis/cloudwatch/pom.xml
+++ b/apis/cloudwatch/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/binders/MetricDataBinder.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/binders/MetricDataBinder.java
index 997f437b2f..38524189f2 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/binders/MetricDataBinder.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/binders/MetricDataBinder.java
@@ -93,8 +93,10 @@ public class MetricDataBinder implements org.jclouds.rest.Binder {
formParameters.put("MetricData.member." + metricDatumIndex + ".Unit",
String.valueOf(metricDatum.getUnit()));
- formParameters.put("MetricData.member." + metricDatumIndex + ".Value",
- String.valueOf(metricDatum.getValue()));
+ if (metricDatum.getValue().isPresent()) {
+ formParameters.put("MetricData.member." + metricDatumIndex + ".Value",
+ String.valueOf(metricDatum.getValue().get()));
+ }
metricDatumIndex++;
}
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/GetMetricStatisticsResponse.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/GetMetricStatisticsResponse.java
index 146de9c569..d455908f39 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/GetMetricStatisticsResponse.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/GetMetricStatisticsResponse.java
@@ -18,12 +18,12 @@
*/
package org.jclouds.cloudwatch.domain;
-import java.util.Set;
+import java.util.Iterator;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
-import com.google.common.collect.ForwardingSet;
+import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
/**
@@ -33,12 +33,12 @@ import com.google.common.collect.ImmutableSet;
*
* @author Jeremy Whitlock
*/
-public class GetMetricStatisticsResponse extends ForwardingSet {
+public class GetMetricStatisticsResponse extends FluentIterable {
- private final Set datapoints;
+ private final Iterable datapoints;
private final String label;
- public GetMetricStatisticsResponse(@Nullable Set datapoints, String label) {
+ public GetMetricStatisticsResponse(@Nullable Iterable datapoints, String label) {
// Default to an empty set
if (datapoints == null) {
this.datapoints = ImmutableSet.of();
@@ -90,8 +90,8 @@ public class GetMetricStatisticsResponse extends ForwardingSet {
}
@Override
- protected Set delegate() {
- return datapoints;
+ public Iterator iterator() {
+ return datapoints.iterator();
}
}
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/MetricDatum.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/MetricDatum.java
index 2bd2d1385e..23745a9eb4 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/MetricDatum.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/domain/MetricDatum.java
@@ -25,14 +25,16 @@ import java.util.Date;
import java.util.Set;
import com.google.common.base.Objects;
-import com.google.common.base.Optional;
import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
/**
- * @see
- *
+ * @see
+ *
* @author Jeremy Whitlock
*/
public class MetricDatum {
@@ -42,17 +44,17 @@ public class MetricDatum {
private final Optional statisticValues;
private final Optional timestamp;
private final Unit unit;
- private final double value;
+ private final Optional value;
/**
* Private constructor to enforce using {@link Builder}.
*/
- protected MetricDatum(Set dimensions, String metricName, StatisticValues statisticValues, Date timestamp,
- Unit unit, double value) {
- this.dimensions = ImmutableSet.copyOf(checkNotNull(dimensions, "dimensions"));
+ protected MetricDatum(Iterable dimensions, String metricName, Optional statisticValues,
+ Optional timestamp, Unit unit, Optional value) {
+ this.dimensions = ImmutableSet. copyOf(checkNotNull(dimensions, "dimensions"));
this.metricName = checkNotNull(metricName, "metricName");
- this.statisticValues = Optional.fromNullable(statisticValues);
- this.timestamp = Optional.fromNullable(timestamp);
+ this.statisticValues = checkNotNull(statisticValues, "statisticValues");
+ this.timestamp = checkNotNull(timestamp, "timestamp");
this.unit = checkNotNull(unit, "unit");
this.value = checkNotNull(value, "value");
}
@@ -95,13 +97,13 @@ public class MetricDatum {
/**
* return the actual value of the metric
*/
- public double getValue() {
+ public Optional getValue() {
return value;
}
/**
- * Returns a new builder. The generated builder is equivalent to the builder
- * created by the {@link Builder} constructor.
+ * Returns a new builder. The generated builder is equivalent to the builder created by the
+ * {@link Builder} constructor.
*/
public static Builder builder() {
return new Builder();
@@ -110,36 +112,39 @@ public class MetricDatum {
public static class Builder {
// this builder is set to be additive on dimension calls, so make this mutable
- private Set dimensions = Sets.newLinkedHashSet();
+ private ImmutableList.Builder dimensions = ImmutableList. builder();
private String metricName;
- private StatisticValues statisticValues;
- private Date timestamp;
+ private Optional statisticValues = Optional.absent();
+ private Optional timestamp = Optional.absent();
private Unit unit = Unit.NONE;
- private double value;
+ private Optional value = Optional.absent();
/**
- * Creates a new builder. The returned builder is equivalent to the builder
- * generated by {@link org.jclouds.cloudwatch.domain.MetricDatum#builder}.
+ * Creates a new builder. The returned builder is equivalent to the builder generated by
+ * {@link org.jclouds.cloudwatch.domain.MetricDatum#builder}.
*/
- public Builder() {}
+ public Builder() {
+ }
/**
* A list of dimensions describing qualities of the metric.
- *
- * @param dimensions the dimensions describing the qualities of the metric
- *
+ *
+ * @param dimensions
+ * the dimensions describing the qualities of the metric
+ *
* @return this {@code Builder} object
*/
- public Builder dimensions(Set dimensions) {
+ public Builder dimensions(Iterable dimensions) {
this.dimensions.addAll(checkNotNull(dimensions, "dimensions"));
return this;
}
/**
* A dimension describing qualities of the metric.
- *
- * @param dimension the dimension describing the qualities of the metric
- *
+ *
+ * @param dimension
+ * the dimension describing the qualities of the metric
+ *
* @return this {@code Builder} object
*/
public Builder dimension(Dimension dimension) {
@@ -149,9 +154,10 @@ public class MetricDatum {
/**
* The name of the metric.
- *
- * @param metricName the metric name
- *
+ *
+ * @param metricName
+ * the metric name
+ *
* @return this {@code Builder} object
*/
public Builder metricName(String metricName) {
@@ -161,34 +167,37 @@ public class MetricDatum {
/**
* The object describing the set of statistical values describing the metric.
- *
- * @param statisticValues the object describing the set of statistical values for the metric
- *
+ *
+ * @param statisticValues
+ * the object describing the set of statistical values for the metric
+ *
* @return this {@code Builder} object
*/
public Builder statisticValues(StatisticValues statisticValues) {
- this.statisticValues = statisticValues;
+ this.statisticValues = Optional.fromNullable(statisticValues);
return this;
}
/**
- * The time stamp used for the metric. If not specified, the default value is set to the time the metric data was
- * received.
- *
- * @param timestamp the time stamp used for the metric
- *
+ * The time stamp used for the metric. If not specified, the default value is set to the time
+ * the metric data was received.
+ *
+ * @param timestamp
+ * the time stamp used for the metric
+ *
* @return this {@code Builder} object
*/
public Builder timestamp(Date timestamp) {
- this.timestamp = timestamp;
+ this.timestamp = Optional.fromNullable(timestamp);
return this;
}
/**
* The unit for the metric.
- *
- * @param unit the unit for the metric
- *
+ *
+ * @param unit
+ * the unit for the metric
+ *
* @return this {@code Builder} object
*/
public Builder unit(Unit unit) {
@@ -198,13 +207,14 @@ public class MetricDatum {
/**
* The value for the metric.
- *
- * @param value the value for the metric
- *
+ *
+ * @param value
+ * the value for the metric
+ *
* @return this {@code Builder} object
*/
- public Builder value(double value) {
- this.value = value;
+ public Builder value(Double value) {
+ this.value = Optional.fromNullable(value);
return this;
}
@@ -212,7 +222,7 @@ public class MetricDatum {
* Returns a newly-created {@code MetricDatum} based on the contents of the {@code Builder}.
*/
public MetricDatum build() {
- return new MetricDatum(dimensions, metricName, statisticValues, timestamp, unit, value);
+ return new MetricDatum(dimensions.build(), metricName, statisticValues, timestamp, unit, value);
}
}
@@ -240,7 +250,8 @@ public class MetricDatum {
}
protected ToStringHelper string() {
- return Objects.toStringHelper("").add("dimensions", dimensions).add("metricName", metricName).add(
- "statisticValues", statisticValues).add("timestamp", timestamp).add("unit", unit).add("value", value);
+ return Objects.toStringHelper("").omitNullValues().add("dimensions", dimensions).add("metricName", metricName)
+ .add("statisticValues", statisticValues.orNull()).add("timestamp", timestamp.orNull()).add("unit", unit)
+ .add("value", value.orNull());
}
}
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
index 9e5deabc37..a573656440 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricApi.java
@@ -34,6 +34,7 @@ import org.jclouds.concurrent.Timeout;
* Provides access to Amazon CloudWatch via the Query API
*
*
+ * @see MetricAsyncApi
* @see
* @author Jeremy Whitlock
*/
diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
index 3e739b5234..3e813809db 100644
--- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
+++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/features/MetricAsyncApi.java
@@ -37,11 +37,14 @@ import org.jclouds.cloudwatch.xml.ListMetricsResponseHandler;
import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable;
import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.rest.functions.ReturnEmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.rest.functions.ReturnEmptyPagedIterableOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture;
@@ -64,6 +67,7 @@ public interface MetricAsyncApi {
@XMLResponseParser(ListMetricsResponseHandler.class)
@Transform(MetricsToPagedIterable.class)
@FormParams(keys = "Action", values = "ListMetrics")
+ @ExceptionParser(ReturnEmptyPagedIterableOnNotFoundOr404.class)
ListenableFuture extends PagedIterable> list();
/**
@@ -73,6 +77,7 @@ public interface MetricAsyncApi {
@Path("/")
@XMLResponseParser(ListMetricsResponseHandler.class)
@FormParams(keys = "Action", values = "ListMetrics")
+ @ExceptionParser(ReturnEmptyIterableWithMarkerOnNotFoundOr404.class)
ListenableFuture extends IterableWithMarker> list(ListMetricsOptions options);
/**
diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/binders/MetricDataBinderTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/binders/MetricDataBinderTest.java
index 94dcac48f6..003fb90274 100644
--- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/binders/MetricDataBinderTest.java
+++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/binders/MetricDataBinderTest.java
@@ -60,7 +60,6 @@ public class MetricDataBinderTest {
.statisticValues(ss)
.dimension(new Dimension("TestDimension", "FAKE"))
.unit(Unit.COUNT)
- .value(2)
.build();
HttpRequest request = binder.bindToRequest(request(), ImmutableSet.of(metricDatum));
@@ -73,8 +72,7 @@ public class MetricDataBinderTest {
"&MetricData.member.1.StatisticValues.Minimum=1.0" +
"&MetricData.member.1.StatisticValues.SampleCount=4.0" +
"&MetricData.member.1.StatisticValues.Sum=10.0" +
- "&MetricData.member.1.Unit=" + Unit.COUNT.toString() +
- "&MetricData.member.1.Value=2.0");
+ "&MetricData.member.1.Unit=" + Unit.COUNT.toString());
}
public void testMetricWithMultipleDimensions() throws Exception {
diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/features/MetricApiExpectTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/features/MetricApiExpectTest.java
index 25cae952fe..90ff95865c 100644
--- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/features/MetricApiExpectTest.java
+++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/features/MetricApiExpectTest.java
@@ -33,6 +33,7 @@ import org.jclouds.cloudwatch.domain.Unit;
import org.jclouds.cloudwatch.internal.BaseCloudWatchApiExpectTest;
import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
+import org.jclouds.collect.IterableWithMarkers;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.rest.ResourceNotFoundException;
@@ -76,8 +77,6 @@ public class MetricApiExpectTest extends BaseCloudWatchApiExpectTest {
"[Metric{namespace=AWS/EC2, metricName=CPUUtilization, dimension=[Dimension{name=InstanceId, value=i-689fcf0f}]}]");
}
- // TODO: this should really be an empty set
- @Test(expectedExceptions = ResourceNotFoundException.class)
public void testListMetricsWhenResponseIs404() throws Exception {
HttpResponse listMetricsResponse = HttpResponse.builder().statusCode(404).build();
@@ -85,7 +84,7 @@ public class MetricApiExpectTest extends BaseCloudWatchApiExpectTest {
CloudWatchApi apiWhenMetricsDontExist = requestSendsResponse(
listMetrics, listMetricsResponse);
- apiWhenMetricsDontExist.getMetricApiForRegion(null).list().get(0);
+ assertEquals(apiWhenMetricsDontExist.getMetricApiForRegion(null).list().get(0), IterableWithMarkers.EMPTY);
}
public void testListMetrics2PagesWhenResponseIs2xx() throws Exception {
diff --git a/apis/deltacloud/pom.xml b/apis/deltacloud/pom.xml
index bfef9b8b6b..9470789a81 100644
--- a/apis/deltacloud/pom.xml
+++ b/apis/deltacloud/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java
index dc8402ca28..3f6c359ac8 100644
--- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java
+++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/options/CreateInstanceOptionsTest.java
@@ -21,7 +21,7 @@ package org.jclouds.deltacloud.options;
import static org.jclouds.deltacloud.options.CreateInstanceOptions.Builder.named;
import static org.testng.Assert.assertEquals;
-import java.util.Collections;
+import com.google.common.collect.ImmutableList;
import org.jclouds.http.options.HttpRequestOptions;
import org.testng.annotations.Test;
@@ -43,19 +43,19 @@ public class CreateInstanceOptionsTest {
public void testWithNamed() {
CreateInstanceOptions options = new CreateInstanceOptions();
options.named("test");
- assertEquals(options.buildFormParameters().get("name"), Collections.singletonList("test"));
+ assertEquals(options.buildFormParameters().get("name"), ImmutableList.of("test"));
}
@Test
public void testNullWithNamed() {
CreateInstanceOptions options = new CreateInstanceOptions();
- assertEquals(options.buildFormParameters().get("name"), Collections.EMPTY_LIST);
+ assertEquals(options.buildFormParameters().get("name"), ImmutableList.of());
}
@Test
public void testWithNamedStatic() {
CreateInstanceOptions options = named("test");
- assertEquals(options.buildFormParameters().get("name"), Collections.singletonList("test"));
+ assertEquals(options.buildFormParameters().get("name"), ImmutableList.of("test"));
}
@Test(expectedExceptions = NullPointerException.class)
diff --git a/apis/ec2/pom.xml b/apis/ec2/pom.xml
index 4b8eb5bfa1..8e9463c262 100644
--- a/apis/ec2/pom.xml
+++ b/apis/ec2/pom.xml
@@ -24,7 +24,7 @@
org.jcloudsjclouds-project
- 1.5.0-SNAPSHOT
+ 1.6.0-SNAPSHOT../../project/pom.xmlorg.jclouds.api
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java
index 731999357f..a134ec036e 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java
@@ -196,7 +196,7 @@ public class RunningInstanceToNodeMetadata implements Function> {
public Set extends Image> get() {
if (amiOwners.length == 0) {
logger.debug(">> no owners specified, skipping image parsing");
- return Collections.emptySet();
+ return ImmutableSet.of();
} else {
logger.debug(">> providing images");
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Attachment.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Attachment.java
index 0f1e79bc89..73a6fee3b4 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Attachment.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Attachment.java
@@ -114,8 +114,12 @@ public class Attachment implements Comparable {
}
/**
- * Snapshots are tied to Regions and can only be used for volumes within the same Region.
+ * To be removed in jclouds 1.6
Warning
+ *
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/BundleTask.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/BundleTask.java
index 235004493d..9ec3bbd2e5 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/BundleTask.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/BundleTask.java
@@ -209,9 +209,12 @@ public class BundleTask implements Comparable {
}
/**
+ * To be removed in jclouds 1.6
Warning
*
- * @return region of the bundle task
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java
index 99bb4ae5e6..1c50e637e1 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Image.java
@@ -219,9 +219,12 @@ public class Image implements Comparable {
}
/**
- * AMIs are tied to the Region where its files are located within Amazon S3.
+ * To be removed in jclouds 1.6
Warning
*
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java
index 3f0518769a..ab38a4b5f1 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java
@@ -47,8 +47,12 @@ public class InstanceStateChange implements Comparable {
}
/**
- * Instances are tied to Availability Zones. However, the instance ID is tied to the Region.
+ * To be removed in jclouds 1.6
Warning
+ *
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermission.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermission.java
index 722313161c..69bb6a7ad3 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermission.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermission.java
@@ -18,49 +18,174 @@
*/
package org.jclouds.ec2.domain;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.Set;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
/**
- *
+ *
* @see
* @author Adrian Cole
*/
-public interface IpPermission extends Comparable {
+public class IpPermission {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private int fromPort;
+ private int toPort;
+ private IpProtocol ipProtocol;
+ private Multimap userIdGroupPairs = LinkedHashMultimap.create();
+ private Set groupIds = Sets.newLinkedHashSet();
+ private Set ipRanges = Sets.newLinkedHashSet();
+
+ public Builder fromPort(int fromPort) {
+ this.fromPort = fromPort;
+ return this;
+ }
+
+ public Builder toPort(int toPort) {
+ this.toPort = toPort;
+ return this;
+ }
+
+ public Builder ipProtocol(IpProtocol ipProtocol) {
+ this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
+ return this;
+ }
+
+ public Builder userIdGroupPair(String userId, String groupNameOrId) {
+ this.userIdGroupPairs.put(checkNotNull(userId, "userId"), checkNotNull(groupNameOrId, "groupNameOrId of %s", userId));
+ return this;
+ }
+
+ public Builder userIdGroupPairs(Multimap userIdGroupPairs) {
+ this.userIdGroupPairs.putAll(checkNotNull(userIdGroupPairs, "userIdGroupPairs"));
+ return this;
+ }
+
+ public Builder ipRange(String ipRange) {
+ this.ipRanges.add(ipRange);
+ return this;
+ }
+
+ public Builder ipRanges(Iterable ipRanges) {
+ Iterables.addAll(this.ipRanges, checkNotNull(ipRanges, "ipRanges"));
+ return this;
+ }
+
+ public Builder groupId(String groupId) {
+ this.groupIds.add(checkNotNull(groupId, "groupId"));
+ return this;
+ }
+
+ public Builder groupIds(Iterable groupIds) {
+ Iterables.addAll(this.groupIds, checkNotNull(groupIds, "groupIds"));
+ return this;
+ }
+
+ public IpPermission build() {
+ return new IpPermission(ipProtocol, fromPort, toPort, userIdGroupPairs, groupIds, ipRanges);
+ }
+ }
+
+ private final int fromPort;
+ private final int toPort;
+ private final Multimap userIdGroupPairs;
+ private final Set groupIds;
+ private final IpProtocol ipProtocol;
+ private final Set ipRanges;
+
+ public IpPermission(IpProtocol ipProtocol, int fromPort, int toPort, Multimap userIdGroupPairs,
+ Iterable groupIds, Iterable ipRanges) {
+ this.fromPort = fromPort;
+ this.toPort = toPort;
+ this.userIdGroupPairs = ImmutableMultimap.copyOf(checkNotNull(userIdGroupPairs, "userIdGroupPairs"));
+ this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
+ this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds"));
+ this.ipRanges = ImmutableSet.copyOf(checkNotNull(ipRanges, "ipRanges"));
+ }
/**
* Start of port range for the TCP and UDP protocols, or an ICMP type number.
* An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type
* number).
*/
- int getFromPort();
+ public int getFromPort() {
+ return fromPort;
+ }
/**
* End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP
* code of -1 indicates a wildcard (i.e., any ICMP code).
*/
- int getToPort();
+ public int getToPort() {
+ return toPort;
+ }
/**
* List of security group and user ID pairs.
*/
- Multimap getUserIdGroupPairs();
+ public Multimap getUserIdGroupPairs() {
+ return userIdGroupPairs;
+ }
/**
* List of security group Ids
*/
- Set getGroupIds();
+ public Set getGroupIds() {
+ return groupIds;
+ }
/**
* IP protocol
*/
- IpProtocol getIpProtocol();
+ public IpProtocol getIpProtocol() {
+ return ipProtocol;
+ }
/**
* IP ranges.
*/
- Set getIpRanges();
+ public Set getIpRanges() {
+ return ipRanges;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(fromPort, toPort, groupIds, ipProtocol, ipRanges, userIdGroupPairs);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+ IpPermission that = IpPermission.class.cast(obj);
+ return Objects.equal(this.fromPort, that.fromPort) && Objects.equal(this.toPort, that.toPort)
+ && Objects.equal(this.groupIds, that.groupIds) && Objects.equal(this.ipProtocol, that.ipProtocol)
+ && Objects.equal(this.ipRanges, that.ipRanges)
+ && Objects.equal(this.userIdGroupPairs, that.userIdGroupPairs);
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).omitNullValues().add("fromPort", fromPort == -1 ? null : fromPort)
+ .add("toPort", toPort == -1 ? null : toPort).add("groupIds", groupIds.size() == 0 ? null : groupIds)
+ .add("ipProtocol", ipProtocol).add("ipRanges", ipRanges.size() == 0 ? null : ipRanges)
+ .add("userIdGroupPairs", userIdGroupPairs.size() == 0 ? null : userIdGroupPairs).toString();
+ }
+
}
\ No newline at end of file
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermissionImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermissionImpl.java
deleted file mode 100644
index fe801981ee..0000000000
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/IpPermissionImpl.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. jclouds licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jclouds.ec2.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Set;
-
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.LinkedHashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Sets;
-
-/**
- *
- * @see
- * @author Adrian Cole
- */
-public class IpPermissionImpl implements IpPermission {
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private int fromPort;
- private int toPort;
- private IpProtocol ipProtocol;
- private Multimap userIdGroupPairs = LinkedHashMultimap.create();
- private Set groupIds = Sets.newLinkedHashSet();
- private Set ipRanges = Sets.newLinkedHashSet();
-
- public Builder fromPort(int fromPort) {
- this.fromPort = fromPort;
- return this;
- }
-
- public Builder toPort(int toPort) {
- this.fromPort = toPort;
- return this;
- }
-
- public Builder ipProtocol(IpProtocol ipProtocol) {
- this.ipProtocol = ipProtocol;
- return this;
- }
-
- public Builder userIdGroupPair(String userId, String groupNameOrId) {
- this.userIdGroupPairs.put(userId, groupNameOrId);
- return this;
- }
-
- public Builder userIdGroupPairs(Multimap userIdGroupPairs) {
- this.userIdGroupPairs.putAll(userIdGroupPairs);
- return this;
- }
-
- public Builder ipRange(String ipRange) {
- this.ipRanges.add(ipRange);
- return this;
- }
-
- public Builder ipRanges(Iterable ipRanges) {
- Iterables.addAll(this.ipRanges, ipRanges);
- return this;
- }
-
- public Builder groupId(String groupId) {
- this.groupIds.add(groupId);
- return this;
- }
-
- public Builder groupIds(Iterable groupIds) {
- Iterables.addAll(this.groupIds, groupIds);
- return this;
- }
-
- public IpPermission build() {
- return new IpPermissionImpl(ipProtocol, fromPort, toPort, userIdGroupPairs, groupIds, ipRanges);
- }
- }
-
- private final int fromPort;
- private final int toPort;
- private final Multimap userIdGroupPairs;
- private final Set groupIds;
- private final IpProtocol ipProtocol;
- private final Set ipRanges;
-
- public IpPermissionImpl(IpProtocol ipProtocol, int fromPort, int toPort,
- Multimap userIdGroupPairs, Iterable groupIds, Iterable ipRanges) {
- this.fromPort = fromPort;
- this.toPort = toPort;
- this.userIdGroupPairs = ImmutableMultimap.copyOf(checkNotNull(userIdGroupPairs, "userIdGroupPairs"));
- this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
- this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds"));
- this.ipRanges = ImmutableSet.copyOf(checkNotNull(ipRanges, "ipRanges"));
- }
-
- /**
- * {@inheritDoc}
- */
- public int compareTo(IpPermission o) {
- return (this == o) ? 0 : getIpProtocol().compareTo(o.getIpProtocol());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getFromPort() {
- return fromPort;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getToPort() {
- return toPort;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Multimap getUserIdGroupPairs() {
- return userIdGroupPairs;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set getGroupIds() {
- return groupIds;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IpProtocol getIpProtocol() {
- return ipProtocol;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set getIpRanges() {
- return ipRanges;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + fromPort;
- result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode());
- result = prime * result + ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
- result = prime * result + ((ipRanges == null) ? 0 : ipRanges.hashCode());
- result = prime * result + toPort;
- result = prime * result + ((userIdGroupPairs == null) ? 0 : userIdGroupPairs.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;
- IpPermissionImpl other = (IpPermissionImpl) obj;
- if (fromPort != other.fromPort)
- return false;
- if (groupIds == null) {
- if (other.groupIds != null)
- return false;
- } else if (!groupIds.equals(other.groupIds))
- return false;
- if (ipProtocol != other.ipProtocol)
- return false;
- if (ipRanges == null) {
- if (other.ipRanges != null)
- return false;
- } else if (!ipRanges.equals(other.ipRanges))
- return false;
- if (toPort != other.toPort)
- return false;
- if (userIdGroupPairs == null) {
- if (other.userIdGroupPairs != null)
- return false;
- } else if (!userIdGroupPairs.equals(other.userIdGroupPairs))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "[fromPort=" + fromPort + ", toPort=" + toPort + ", userIdGroupPairs=" + userIdGroupPairs + ", groupIds="
- + groupIds + ", ipProtocol=" + ipProtocol + ", ipRanges=" + ipRanges + "]";
- }
-
-}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/KeyPair.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/KeyPair.java
index ead73cb9e3..bd927a3893 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/KeyPair.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/KeyPair.java
@@ -103,8 +103,12 @@ public class KeyPair implements Comparable {
}
/**
- * Key pairs (to connect to instances) are Region-specific.
+ * To be removed in jclouds 1.6
Warning
+ *
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java
index 8f03cab684..189fe7c92f 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java
@@ -42,8 +42,12 @@ public class PublicIpInstanceIdPair implements ComparableWarning
+ *
+ * Especially on EC2 clones that may not support regions, this value is fragile. Consider
+ * alternate means to determine context.
*/
+ @Deprecated
public String getRegion() {
return region;
}
diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Reservation.java b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Reservation.java
index 48f6d06190..5a621b290d 100644
--- a/apis/ec2/src/main/java/org/jclouds/ec2/domain/Reservation.java
+++ b/apis/ec2/src/main/java/org/jclouds/ec2/domain/Reservation.java
@@ -20,27 +20,119 @@ package org.jclouds.ec2.domain;
import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.LinkedHashSet;
import java.util.Set;
import org.jclouds.javax.annotation.Nullable;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
+import com.google.common.base.Objects;
+import com.google.common.collect.ComparisonChain;
+import com.google.common.collect.ForwardingSet;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Ordering;
/**
*
- * @see
* @author Adrian Cole
*/
-public class Reservation extends LinkedHashSet implements Comparable>,
- Set {
+public class Reservation extends ForwardingSet implements Comparable>{
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return Reservation. builder().fromReservation(this);
+ }
+
+ public static class Builder {
+ private String region;
+ private String ownerId;
+ private String requesterId;
+ private String reservationId;
+
+ private ImmutableSet.Builder