diff --git a/archetypes/compute-service-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/compute-service-archetype/src/main/resources/archetype-resources/pom.xml index 431a8b2600..74b8f2a1d7 100644 --- a/archetypes/compute-service-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/compute-service-archetype/src/main/resources/archetype-resources/pom.xml @@ -54,7 +54,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/archetypes/json-client-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/json-client-archetype/src/main/resources/archetype-resources/pom.xml index 987c38e444..2efa11e0a5 100644 --- a/archetypes/json-client-archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/json-client-archetype/src/main/resources/archetype-resources/pom.xml @@ -54,7 +54,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/boxdotnet/pom.xml b/boxdotnet/pom.xml index f683bb14c7..fada127582 100644 --- a/boxdotnet/pom.xml +++ b/boxdotnet/pom.xml @@ -52,7 +52,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/chef/compute/pom.xml b/chef/compute/pom.xml new file mode 100644 index 0000000000..f347e3de5d --- /dev/null +++ b/chef/compute/pom.xml @@ -0,0 +1,150 @@ + + + + 4.0.0 + + org.jclouds + jclouds-chef-project + 1.0-SNAPSHOT + ../pom.xml + + org.jclouds + jclouds-chef-compute + jclouds chef compute integration + provisions nodes with jclouds and kick's off chef to configure and integrate + + + YOUR_PREFERRED_PROVIDER + + + YOUR_ACCOUNT + YOUR_CREDENTIAL + YOUR_USER + ${user.home}/.chef/${jclouds.chef.identity}.pem + YOUR_ORG + https://api.opscode.com/organizations/${jclouds.opscodeplatform.org} + + + + + + jclouds-googlecode-deploy + http://jclouds.googlecode.com/svn/repo + + + jclouds-rimu-snapshots-nexus + https://oss.sonatype.org/content/repositories/snapshots + + true + + + + + + + ${project.groupId} + jclouds-chef + ${project.version} + + + ${project.groupId} + jclouds-compute + ${project.version} + + + ${project.groupId} + jclouds-compute + ${project.version} + test-jar + test + + + ${project.groupId} + jclouds-allcompute + ${project.version} + test + true + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + none + + + **/*LiveTest.java + + + + jclouds.compute.provider + ${jclouds.compute.provider} + + + jclouds.compute.endpoint + ${jclouds.compute.endpoint} + + + jclouds.compute.identity + ${jclouds.compute.identity} + + + jclouds.compute.credential + ${jclouds.compute.credential} + + + jclouds.chef.identity + ${jclouds.chef.identity} + + + jclouds.chef.identity.pem + ${jclouds.chef.identity.pem} + + + jclouds.chef.endpoint + ${jclouds.chef.endpoint} + + + + + + + + + + + + diff --git a/chef/core/pom.xml b/chef/core/pom.xml index e0bf76592f..0deea59757 100644 --- a/chef/core/pom.xml +++ b/chef/core/pom.xml @@ -25,7 +25,7 @@ org.jclouds jclouds-chef-project 1.0-SNAPSHOT - ../project/pom.xml + ../pom.xml org.jclouds jclouds-chef @@ -49,7 +49,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/chef/pom.xml b/chef/pom.xml index 9af1509dea..05b43def2d 100644 --- a/chef/pom.xml +++ b/chef/pom.xml @@ -34,5 +34,6 @@ core servlet + compute diff --git a/chef/servlet/pom.xml b/chef/servlet/pom.xml index 5d32cad055..886c50736d 100644 --- a/chef/servlet/pom.xml +++ b/chef/servlet/pom.xml @@ -26,7 +26,7 @@ org.jclouds jclouds-chef-project 1.0-SNAPSHOT - ../project/pom.xml + ../pom.xml org.jclouds jclouds-chef-servlet @@ -41,7 +41,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index afe92c5120..4f776095cf 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -43,6 +43,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -50,6 +51,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.jclouds.Constants; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -92,32 +94,32 @@ import com.google.inject.Module; @Test(groups = { "integration", "live" }, sequential = true, testName = "compute.ComputeServiceLiveTest") public abstract class BaseComputeServiceLiveTest { public static final String APT_RUN_SCRIPT = new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// - .append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")// - .append( - "sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")// - .append("apt-get update\n")// - .append("apt-get install -f -y --force-yes openjdk-6-jdk\n")// - .toString(); + .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// + .append("cp /etc/apt/sources.list /etc/apt/sources.list.old\n")// + .append( + "sed 's~us.archive.ubuntu.com~mirror.anl.gov/pub~g' /etc/apt/sources.list.old >/etc/apt/sources.list\n")// + .append("apt-get update\n")// + .append("apt-get install -f -y --force-yes openjdk-6-jdk\n")// + .toString(); public static final String YUM_RUN_SCRIPT = new StringBuilder() - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") - // - .append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - // - .append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") - // - .append( - "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// - .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// - .append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")// - .append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")// - .toString(); + .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") + // + .append("echo \"[jdkrepo]\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + // + .append("echo \"name=jdkrepository\" >> /etc/yum.repos.d/CentOS-Base.repo\n") + // + .append( + "echo \"baseurl=http://ec2-us-east-mirror.rightscale.com/epel/5/i386/\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// + .append("echo \"enabled=1\" >> /etc/yum.repos.d/CentOS-Base.repo\n")// + .append("yum --nogpgcheck -y install java-1.6.0-openjdk\n")// + .append("echo \"export PATH=\\\"/usr/lib/jvm/jre-1.6.0-openjdk/bin/:\\$PATH\\\"\" >> /root/.bashrc\n")// + .toString(); public static final String ZYPPER_RUN_SCRIPT = new StringBuilder()// - .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// - .append("sudo zypper install java-1.6.0-openjdk-devl\n")// - .toString(); + .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")// + .append("sudo zypper install java-1.6.0-openjdk-devl\n")// + .toString(); abstract public void setServiceDefaults(); @@ -165,7 +167,7 @@ public abstract class BaseComputeServiceLiveTest { String secret = Files.toString(new File(secretKeyFile), Charsets.UTF_8); assert secret.startsWith("-----BEGIN RSA PRIVATE KEY-----") : "invalid key:\n" + secret; return ImmutableMap. of("private", secret, "public", Files.toString(new File(secretKeyFile - + ".pub"), Charsets.UTF_8)); + + ".pub"), Charsets.UTF_8)); } protected void setupCredentials() { @@ -180,8 +182,11 @@ public abstract class BaseComputeServiceLiveTest { private void initializeContextAndClient() throws IOException { if (context != null) context.close(); + Properties props = new Properties(); + props.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + props.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); context = new ComputeServiceContextFactory().createContext(provider, identity, credential, ImmutableSet.of( - new Log4JLoggingModule(), getSshModule())); + new Log4JLoggingModule(), getSshModule()), props); client = context.getComputeService(); } @@ -200,7 +205,7 @@ public abstract class BaseComputeServiceLiveTest { ComputeServiceContext context = null; try { context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA", ImmutableSet - . of(new Log4JLoggingModule())); + . of(new Log4JLoggingModule())); context.getComputeService().listNodes(); } finally { if (context != null) @@ -239,7 +244,7 @@ public abstract class BaseComputeServiceLiveTest { OperatingSystem os = get(nodes, 0).getOperatingSystem(); try { Map responses = runScriptWithCreds(tag, os, new Credentials( - good.identity, "romeo")); + good.identity, "romeo")); assert false : "shouldn't pass with a bad password\n" + responses; } catch (RunScriptOnNodesException e) { assert getRootCause(e).getMessage().contains("Auth fail") : e; @@ -294,8 +299,8 @@ public abstract class BaseComputeServiceLiveTest { template = buildTemplate(client.templateBuilder()); template.getOptions().installPrivateKey(newStringPayload(keyPair.get("private"))).authorizePublicKey( - newStringPayload(keyPair.get("public"))).runScript( - newStringPayload(buildScript(template.getImage().getOperatingSystem()))); + newStringPayload(keyPair.get("public"))).runScript( + newStringPayload(buildScript(template.getImage().getOperatingSystem()))); } protected void checkImageIdMatchesTemplate(NodeMetadata node) { @@ -306,8 +311,8 @@ public abstract class BaseComputeServiceLiveTest { protected void checkOsMatchesTemplate(NodeMetadata node) { if (node.getOperatingSystem() != null) assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String - .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node - .getOperatingSystem()); + .format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node + .getOperatingSystem()); } void assertLocationSameOrChild(Location test, Location expected) { @@ -332,10 +337,10 @@ public abstract class BaseComputeServiceLiveTest { } protected Map runScriptWithCreds(final String tag, OperatingSystem os, - Credentials creds) throws RunScriptOnNodesException { + Credentials creds) throws RunScriptOnNodesException { try { return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)), - overrideCredentialsWith(creds)); + overrideCredentialsWith(creds)); } catch (SshException e) { throw e; } @@ -393,7 +398,7 @@ public abstract class BaseComputeServiceLiveTest { protected void assertNodeZero(Set metadataSet) { assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]", - metadataSet, nodes); + metadataSet, nodes); } @Test(enabled = true, dependsOnMethods = "testGet") @@ -454,26 +459,26 @@ public abstract class BaseComputeServiceLiveTest { assert location != location.getParent() : location; assert location.getScope() != null : location; switch (location.getScope()) { - case PROVIDER: - assertProvider(location); - break; - case REGION: - assertProvider(location.getParent()); - break; - case ZONE: - Location provider = location.getParent().getParent(); - // zone can be a direct descendant of provider - if (provider == null) - provider = location.getParent(); - assertProvider(provider); - break; - case HOST: - Location provider2 = location.getParent().getParent().getParent(); - // zone can be a direct descendant of provider - if (provider2 == null) - provider2 = location.getParent().getParent(); - assertProvider(provider2); - break; + case PROVIDER: + assertProvider(location); + break; + case REGION: + assertProvider(location.getParent()); + break; + case ZONE: + Location provider = location.getParent().getParent(); + // zone can be a direct descendant of provider + if (provider == null) + provider = location.getParent(); + assertProvider(provider); + break; + case HOST: + Location provider2 = location.getParent().getParent().getParent(); + // zone can be a direct descendant of provider + if (provider2 == null) + provider2 = location.getParent().getParent(); + assertProvider(provider2); + break; } } } diff --git a/demos/antjruby/build.xml b/demos/antjruby/build.xml index ba54fc0a80..b76fe31e3c 100644 --- a/demos/antjruby/build.xml +++ b/demos/antjruby/build.xml @@ -31,7 +31,7 @@ classpathref="maven-ant-tasks.classpath" /> - + diff --git a/ibmdev/pom.xml b/ibmdev/pom.xml index c9a5e2295f..f838e698d2 100644 --- a/ibmdev/pom.xml +++ b/ibmdev/pom.xml @@ -51,7 +51,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots diff --git a/opscodeplatform/pom.xml b/opscodeplatform/pom.xml index 9d7ecbe6aa..e221246bc7 100644 --- a/opscodeplatform/pom.xml +++ b/opscodeplatform/pom.xml @@ -52,7 +52,7 @@ jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com:8081/nexus/content/repositories/snapshots + https://oss.sonatype.org/content/repositories/snapshots true diff --git a/thirdparty/pom.xml b/thirdparty/pom.xml index d2caf160d7..94e30ccc91 100644 --- a/thirdparty/pom.xml +++ b/thirdparty/pom.xml @@ -42,8 +42,8 @@ false - jclouds-rimu-snapshots-nexus - http://jclouds.rimuhosting.com/nexus/content/repositories/snapshots + jclouds-snapshots + https://oss.sonatype.org/content/repositories/snapshots diff --git a/tools/antcontrib/samples/cargooverssh/build.xml b/tools/antcontrib/samples/cargooverssh/build.xml index 409ea99620..b473d6fa4c 100644 --- a/tools/antcontrib/samples/cargooverssh/build.xml +++ b/tools/antcontrib/samples/cargooverssh/build.xml @@ -56,7 +56,7 @@ - + diff --git a/vcloud/core/src/main/java/domain/VCloudLoginAsyncClient.java b/vcloud/core/src/main/java/domain/VCloudLoginAsyncClient.java index fbd3d86c98..0e7401ddb6 100644 --- a/vcloud/core/src/main/java/domain/VCloudLoginAsyncClient.java +++ b/vcloud/core/src/main/java/domain/VCloudLoginAsyncClient.java @@ -44,7 +44,7 @@ import com.google.common.util.concurrent.ListenableFuture; public interface VCloudLoginAsyncClient { /** - * This request returns a token to use in subsequent requests. After ten minutes of inactivity, + * This request returns a token to use in subsequent requests. After 30 minutes of inactivity, * the token expires and you have to request a new token with this call. */ @POST diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java index 6bb34b7983..1e0fc1adfd 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java @@ -27,6 +27,7 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; import static org.jclouds.vcloud.VCloudMediaType.VM_XML; import java.net.URI; +import java.util.Map; import javax.annotation.Nullable; import javax.ws.rs.Consumes; @@ -38,6 +39,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.predicates.validators.DnsNameValidator; +import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; @@ -52,16 +54,19 @@ import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.ovf.OvfEnvelope; +import org.jclouds.vcloud.endpoints.OrgList; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; +import org.jclouds.vcloud.xml.OrgListHandler; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.VAppHandler; import org.jclouds.vcloud.xml.VAppTemplateHandler; @@ -74,11 +79,21 @@ import com.google.common.util.concurrent.ListenableFuture; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @RequestFilters(SetVCloudTokenCookie.class) public interface VCloudAsyncClient extends CommonVCloudAsyncClient { + /** + * + * @see VCloudClient#listOrgs + */ + @GET + @Endpoint(OrgList.class) + @XMLResponseParser(OrgListHandler.class) + @Consumes(VCloudMediaType.ORGLIST_XML) + ListenableFuture> listOrgs(); /** * @see VCloudClient#getVAppTemplate @@ -107,9 +122,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppTemplateHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture findVAppTemplateInOrgCatalogNamed( - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); /** * @see VCloudClient#instantiateVAppTemplateInVDC @@ -121,9 +136,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppHandler.class) @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class) ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, - @MapPayloadParam("template") URI template, - @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, - InstantiateVAppTemplateOptions... options); + @MapPayloadParam("template") URI template, + @MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, + InstantiateVAppTemplateOptions... options); /** * @see VCloudClient#cloneVAppInVDC @@ -135,8 +150,8 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(TaskHandler.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class) ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone, - @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, - CloneVAppOptions... options); + @MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppOptions... options); /** * @see VCloudClient#findVAppInOrgVDCNamed @@ -146,9 +161,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppHandler.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture findVAppInOrgVDCNamed( - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); /** * @see VCloudClient#getVApp diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java index 71ca38ced2..ac16a52d7c 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -20,12 +20,14 @@ package org.jclouds.vcloud; import java.net.URI; +import java.util.Map; import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; @@ -38,11 +40,20 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; * Provides access to VCloud resources via their REST API. *

* - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) public interface VCloudClient extends CommonVCloudClient { + /** + * The response to a login request includes a list of the organizations to + * which the authenticated user has access. + * + * @return organizations indexed by name + */ + Map listOrgs(); VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options); @@ -53,8 +64,9 @@ public interface VCloudClient extends CommonVCloudClient { OvfEnvelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate); /** - * returns the vapp template corresponding to a catalog item in the catalog associated with the - * specified name. Note that the org and catalog parameters can be null to choose default. + * returns the vapp template corresponding to a catalog item in the catalog + * associated with the specified name. Note that the org and catalog + * parameters can be null to choose default. * * @param orgName * organization name, or null for the default @@ -64,10 +76,11 @@ public interface VCloudClient extends CommonVCloudClient { * item you wish to lookup * * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that isn't present + * if you specified an org, catalog, or catalog item name that + * isn't present */ VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, - String itemName); + String itemName); VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); @@ -76,100 +89,112 @@ public interface VCloudClient extends CommonVCloudClient { Vm getVm(URI vm); /** - * To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp - * automatically deploys all of the virtual machines it contains. To deploy a virtual machine, - * the client makes a request to its action/deploy URL. + * To deploy a vApp, the client makes a request to its action/deploy URL. + * Deploying a vApp automatically deploys all of the virtual machines it + * contains. To deploy a virtual machine, the client makes a request to its + * action/deploy URL. *

- * Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed. + * Deploying a Vm implicitly deploys the parent vApp if that vApp is not + * already deployed. */ Task deployVAppOrVm(URI vAppOrVmId); /** - * like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on state + * like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on + * state * */ Task deployAndPowerOnVAppOrVm(URI vAppOrVmId); /** - * Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees - * the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false - * to indicate that it is not deployed. + * Undeploying a vApp powers off or suspends any running virtual machines it + * contains, then frees the resources reserved for the vApp and sets the + * vApp’s deploy attribute to a value of false to indicate that it is not + * deployed. *

- * Undeploying a virtual machine powers off or suspends the virtual machine, then frees the - * resources reserved for it and sets the its deploy attribute to a value of false to indicate - * that it is not deployed. This operation has no effect on the containing vApp. + * Undeploying a virtual machine powers off or suspends the virtual machine, + * then frees the resources reserved for it and sets the its deploy attribute + * to a value of false to indicate that it is not deployed. This operation + * has no effect on the containing vApp. *

NOTE

- * Using this method will simply power off the vms. In order to save their state, use - * {@link #undeployAndSaveStateOfVAppOrVm} + * Using this method will simply power off the vms. In order to save their + * state, use {@link #undeployAndSaveStateOfVAppOrVm} * */ Task undeployVAppOrVm(URI vAppOrVmId); /** - * like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines are suspended and - * their suspend state saved + * like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines + * are suspended and their suspend state saved * */ Task undeployAndSaveStateOfVAppOrVm(URI vAppOrVmId); /** - * A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as - * specified in the vApp’s StartupSection field. + * A powerOn request to a vApp URL powers on all of the virtual machines in + * the vApp, as specified in the vApp’s StartupSection field. *

- * A powerOn request to a virtual machine URL powers on the specified virtual machine and forces - * deployment of the parent vApp. + * A powerOn request to a virtual machine URL powers on the specified virtual + * machine and forces deployment of the parent vApp. *

- *

NOTE

A powerOn request to a vApp or virtual machine that is undeployed forces - * deployment. + *

NOTE

A powerOn request to a vApp or virtual machine that is + * undeployed forces deployment. */ Task powerOnVAppOrVm(URI vAppOrVmId); /** - * A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as - * specified in its StartupSection field. + * A powerOff request to a vApp URL powers off all of the virtual machines in + * the vApp, as specified in its StartupSection field. *

- * A powerOff request to a virtual machine URL powers off the specified virtual machine. + * A powerOff request to a virtual machine URL powers off the specified + * virtual machine. */ Task powerOffVAppOrVm(URI vAppOrVmId); /** - * A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as - * specified in its StartupSection field. + * A shutdown request to a vApp URL shuts down all of the virtual machines in + * the vApp, as specified in its StartupSection field. *

- * A shutdown request to a virtual machine URL shuts down the specified virtual machine. + * A shutdown request to a virtual machine URL shuts down the specified + * virtual machine. *

- *

NOTENOTE - * A reset request to a virtual machine URL resets the specified virtual machine. + * A reset request to a virtual machine URL resets the specified virtual + * machine. */ Task resetVAppOrVm(URI vAppOrVmId); /** - * A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified - * in its StartupSection field. + * A reboot request to a vApp URL reboots all of the virtual machines in the + * vApp, as specified in its StartupSection field. *

- * A reboot request to a virtual machine URL reboots the specified virtual machine. + * A reboot request to a virtual machine URL reboots the specified virtual + * machine. *

- *

NOTE

Because this request sends a signal to the guest OS, the vCloud API cannot track - * the progress or verify the result of the requested operation. Hence, void is returned + *

NOTE

Because this request sends a signal to the guest OS, the + * vCloud API cannot track the progress or verify the result of the requested + * operation. Hence, void is returned */ void rebootVAppOrVm(URI vAppOrVmId); /** - * A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified - * in its StartupSection field. + * A suspend request to a vApp URL suspends all of the virtual machines in + * the vApp, as specified in its StartupSection field. *

- * A suspend request to a virtual machine URL suspends the specified virtual machine. + * A suspend request to a virtual machine URL suspends the specified virtual + * machine. */ Task suspendVAppOrVm(URI vAppOrVmId); - + Task deleteVApp(URI vAppId); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java index 4677ca2d5a..68fed093c0 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java @@ -71,6 +71,7 @@ import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.endpoints.Network; +import org.jclouds.vcloud.endpoints.OrgList; import org.jclouds.vcloud.endpoints.TasksList; import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog; import org.jclouds.vcloud.functions.AllCatalogsInOrg; @@ -94,14 +95,15 @@ import com.google.inject.name.Names; import domain.VCloudVersionsAsyncClient; /** - * Configures the VCloud authentication service connection, including logging and http transport. + * Configures the VCloud authentication service connection, including logging + * and http transport. * * @author Adrian Cole */ @RequiresHttp @ConfiguresRestClient public class CommonVCloudRestClientModule extends - RestClientModule { + RestClientModule { public CommonVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); @@ -144,20 +146,20 @@ public class CommonVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final Supplier> orgToVDCSupplier) { + final Supplier> orgToVDCSupplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, seconds, - new Supplier>() { - @Override - public Map get() { - Map returnVal = newLinkedHashMap(); - for (Entry orgr : orgToVDCSupplier.get().entrySet()) { - for (String vdc : orgr.getValue().getVDCs().keySet()) { - returnVal.put(vdc, orgr.getKey()); - } + new Supplier>() { + @Override + public Map get() { + Map returnVal = newLinkedHashMap(); + for (Entry orgr : orgToVDCSupplier.get().entrySet()) { + for (String vdc : orgr.getValue().getVDCs().keySet()) { + returnVal.put(vdc, orgr.getKey()); } - return returnVal; } - }); + return returnVal; + } + }); } @@ -180,15 +182,24 @@ public class CommonVCloudRestClientModule> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final OrgMapSupplier supplier) { + final OrgMapSupplier supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } + seconds, new Supplier>() { + @Override + public Map get() { + return supplier.get(); + } - }); + }); + } + + @Provides + @Singleton + @OrgList + URI provideOrgListURI(Supplier sessionSupplier) { + VCloudSession session = sessionSupplier.get(); + return URI.create(Iterables.getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", + "org")); } @Singleton @@ -198,7 +209,7 @@ public class CommonVCloudRestClientModule sessionSupplier, - Function, Iterable> organizationsForNames) { + Function, Iterable> organizationsForNames) { this.sessionSupplier = sessionSupplier; this.organizationsForNames = organizationsForNames; } @@ -211,13 +222,13 @@ public class CommonVCloudRestClientModule>> { + Supplier>> { protected final Supplier> orgSupplier; private final Function> allCatalogsInOrg; @Inject protected OrgCatalogSupplier(Supplier> orgSupplier, - Function> allCatalogsInOrg) { + Function> allCatalogsInOrg) { this.orgSupplier = orgSupplier; this.allCatalogsInOrg = allCatalogsInOrg; } @@ -225,16 +236,16 @@ public class CommonVCloudRestClientModule> get() { return transformValues( - transformValues(orgSupplier.get(), allCatalogsInOrg), - new Function, Map>() { + transformValues(orgSupplier.get(), allCatalogsInOrg), + new Function, Map>() { - @Override - public Map apply( - Iterable from) { - return uniqueIndex(from, name); - } + @Override + public Map apply( + Iterable from) { + return uniqueIndex(from, name); + } - }); + }); } } @@ -265,27 +276,27 @@ public class CommonVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final OrgNameToOrgSupplier supplier) { + final OrgNameToOrgSupplier supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - }); + seconds, new Supplier>() { + @Override + public Map get() { + return supplier.get(); + } + }); } @Provides @Singleton protected Supplier> provideURIToVDC( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final URItoVDC supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( - authException, seconds, new Supplier>() { - @Override - public Map get() { - return supplier.get(); - } - }); + authException, seconds, new Supplier>() { + @Override + public Map get() { + return supplier.get(); + } + }); } @Singleton @@ -300,24 +311,24 @@ public class CommonVCloudRestClientModule get() { return uniqueIndex( - concat(transform( - orgVDCMap.get().values(), - new Function, Iterable>() { + concat(transform( + orgVDCMap.get().values(), + new Function, Iterable>() { - @Override - public Iterable apply( - Map from) { - return from.values(); - } + @Override + public Iterable apply( + Map from) { + return from.values(); + } - })), new Function() { + })), new Function() { - @Override - public URI apply(org.jclouds.vcloud.domain.VDC from) { - return from.getHref(); - } + @Override + public URI apply(org.jclouds.vcloud.domain.VDC from) { + return from.getHref(); + } - }); + }); } } @@ -346,8 +357,7 @@ public class CommonVCloudRestClientModule versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS); checkState(versions.size() > 0, "No versions present"); checkState(versions.containsKey(version), "version " + version + " not present in: " + versions); @@ -381,7 +391,7 @@ public class CommonVCloudRestClientModule>> catalogs) { + Supplier>> catalogs) { return getLast(getLast(catalogs.get().values()).keySet()); } @@ -389,7 +399,7 @@ public class CommonVCloudRestClientModule successTester(Injector injector, - @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { + @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { return new RetryablePredicate(injector.getInstance(TaskSuccess.class), completed); } @Provides @Singleton protected Supplier>> provideOrgCatalogItemMapSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogSupplier supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>( - authException, seconds, - new Supplier>>() { - @Override - public Map> get() { - return supplier.get(); - } + authException, seconds, + new Supplier>>() { + @Override + public Map> get() { + return supplier.get(); + } - }); + }); } @Provides @Singleton protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>( - authException, seconds, - new Supplier>>() { - @Override - public Map> get() { - return supplier.get(); - } + authException, seconds, new Supplier>>() { + @Override + public Map> get() { + return supplier.get(); + } - }); + }); } @Singleton public static class OrgVDCSupplier implements - Supplier>> { + Supplier>> { protected final Supplier> orgSupplier; private final Function> allVDCsInOrg; @Inject protected OrgVDCSupplier(Supplier> orgSupplier, - Function> allVDCsInOrg) { + Function> allVDCsInOrg) { this.orgSupplier = orgSupplier; this.allVDCsInOrg = allVDCsInOrg; } @@ -480,29 +489,29 @@ public class CommonVCloudRestClientModule> get() { return transformValues( - transformValues(orgSupplier.get(), allVDCsInOrg), - new Function, Map>() { + transformValues(orgSupplier.get(), allVDCsInOrg), + new Function, Map>() { - @Override - public Map apply( - Iterable from) { - return uniqueIndex(from, name); - } + @Override + public Map apply( + Iterable from) { + return uniqueIndex(from, name); + } - }); + }); } } @Singleton public static class OrgCatalogItemSupplier implements - Supplier>>> { + Supplier>>> { protected final Supplier>> catalogSupplier; private final Function> allCatalogItemsInCatalog; @Inject protected OrgCatalogItemSupplier( - Supplier>> catalogSupplier, - Function> allCatalogItemsInCatalog) { + Supplier>> catalogSupplier, + Function> allCatalogItemsInCatalog) { this.catalogSupplier = catalogSupplier; this.allCatalogItemsInCatalog = allCatalogItemsInCatalog; } @@ -510,40 +519,39 @@ public class CommonVCloudRestClientModule>> get() { return transformValues( - catalogSupplier.get(), - new Function, Map>>() { + catalogSupplier.get(), + new Function, Map>>() { - @Override - public Map> apply( - Map from) { - return transformValues( - from, - new Function>() { + @Override + public Map> apply( + Map from) { + return transformValues( + from, + new Function>() { - @Override - public Map apply( - org.jclouds.vcloud.domain.Catalog from) { - return uniqueIndex(allCatalogItemsInCatalog.apply(from), name); - } - }); + @Override + public Map apply(org.jclouds.vcloud.domain.Catalog from) { + return uniqueIndex(allCatalogItemsInCatalog.apply(from), name); + } + }); - } - }); + } + }); } } @Provides @Singleton protected Supplier>>> provideOrgCatalogItemSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogItemSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgCatalogItemSupplier supplier) { return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier>>>( - authException, seconds, - new Supplier>>>() { - @Override - public Map>> get() { - return supplier.get(); - } - }); + authException, seconds, + new Supplier>>>() { + @Override + public Map>> get() { + return supplier.get(); + } + }); } @Provides diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java new file mode 100644 index 0000000000..036d07d175 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java @@ -0,0 +1,99 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.vcloud.domain; + +import java.util.Set; + +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; + +/** + * The InstantiateVAppTemplateParams element forms the body of an instantiateVappTemplate request. + */ +public class InstantiateVAppTemplateParams { + + protected final String info; + protected final System virtualSystem; + protected final Set resourceAllocations = Sets.newLinkedHashSet(); + + public InstantiateVAppTemplateParams(String info, System virtualSystem, Iterable resourceAllocations) { + this.info = info; + this.virtualSystem = virtualSystem; + Iterables.addAll(this.resourceAllocations, resourceAllocations); + } + + public String getInfo() { + return info; + } + + public System getSystem() { + return virtualSystem; + } + + public Set getResourceAllocations() { + return resourceAllocations; + } + + @Override + public String toString() { + return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((info == null) ? 0 : info.hashCode()); + result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); + result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.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; + InstantiateVAppTemplateParams other = (InstantiateVAppTemplateParams) obj; + if (info == null) { + if (other.info != null) + return false; + } else if (!info.equals(other.info)) + return false; + if (resourceAllocations == null) { + if (other.resourceAllocations != null) + return false; + } else if (!resourceAllocations.equals(other.resourceAllocations)) + return false; + if (virtualSystem == null) { + if (other.virtualSystem != null) + return false; + } else if (!virtualSystem.equals(other.virtualSystem)) + return false; + return true; + } + +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java b/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java new file mode 100644 index 0000000000..93a9bdc70c --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.vcloud.endpoints; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a VCloud express Org List. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface OrgList { + +} \ No newline at end of file diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java index 7486aafd2b..2bfa10a84f 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java @@ -45,6 +45,7 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory.ContextSpec; +import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -67,6 +68,7 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.xml.CatalogHandler; import org.jclouds.vcloud.xml.CatalogItemHandler; import org.jclouds.vcloud.xml.OrgHandler; +import org.jclouds.vcloud.xml.OrgListHandler; import org.jclouds.vcloud.xml.OrgNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.TasksListHandler; @@ -97,21 +99,21 @@ import domain.VCloudVersionsAsyncClient; public class VCloudAsyncClientTest extends RestClientTest { public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class); + String.class, InstantiateVAppTemplateOptions[].class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp", - addNetworkConfig(new NetworkConfig("aloha", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED))); + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp", + addNetworkConfig(new NetworkConfig("aloha", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED))); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream( - "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", - false); + "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", + false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, VAppHandler.class); @@ -122,28 +124,28 @@ public class VCloudAsyncClientTest extends RestClientTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class); - processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512) - .disk(1024).addNetworkConfig( - new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), - null))); + String.class, InstantiateVAppTemplateOptions[].class); + processor + .createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory( + 512).disk(1024).addNetworkConfig( + new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))); } public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class, - CloneVAppOptions[].class); + CloneVAppOptions[].class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp"); + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-vapp"); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -154,17 +156,17 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class, - CloneVAppOptions[].class); + CloneVAppOptions[].class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server", - new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server", new CloneVAppOptions() + .deploy().powerOn().withDescription("The description of the new vApp")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -173,10 +175,25 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException { + Method method = VCloudAsyncClient.class.getMethod("listOrgs"); + HttpRequest request = processor.createRequest(method); + + assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgListHandler.class); + assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class); + + checkFilters(request); + } + public void testOrg() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getOrg", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n"); @@ -207,7 +224,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getCatalog", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); @@ -238,7 +255,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getNetwork", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/2")); + .create("https://vcenterprise.bluelock.com/api/v1.0/network/2")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); @@ -254,7 +271,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2")); + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); @@ -269,7 +286,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, String.class, - String.class); + String.class); HttpRequest request = processor.createRequest(method, "org", "catalog", "item"); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1"); @@ -285,7 +302,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class, - String.class, String.class); + String.class, String.class); HttpRequest request = processor.createRequest(method, "org", "catalog", "template"); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); @@ -302,7 +319,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); @@ -318,7 +335,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: text/xml\n"); @@ -391,7 +408,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); @@ -407,7 +424,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getTasksList", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n"); @@ -438,12 +455,12 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testDeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("deployVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); + "application/vnd.vmware.vcloud.deployVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -455,12 +472,12 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testDeployAndPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("deployAndPowerOnVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.deployVAppParams+xml", false); + "application/vnd.vmware.vcloud.deployVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -472,7 +489,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getVApp", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); @@ -488,7 +505,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n"); @@ -504,10 +521,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testRebootVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("rebootVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); @@ -521,13 +538,13 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testUndeployVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("undeployVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -537,17 +554,17 @@ public class VCloudAsyncClientTest extends RestClientTest { } public void testUndeployAndSaveStateOfVAppOrVmSaveState() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Method method = VCloudAsyncClient.class.getMethod("undeployAndSaveStateOfVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, - "", - "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + "", + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -559,7 +576,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("deleteVApp", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -575,10 +592,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testPowerOnVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("powerOnVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, null, null, false); @@ -592,10 +609,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testPowerOffVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("powerOffVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, null, null, false); @@ -609,10 +626,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testResetVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("resetVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, null, null, false); @@ -626,10 +643,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testSuspendVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("suspendVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); assertPayloadEquals(request, null, null, false); @@ -643,10 +660,10 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testShutdownVAppOrVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("shutdownVAppOrVm", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); @@ -660,7 +677,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getTask", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); @@ -676,7 +693,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("cancelTask", URI.class); HttpRequest request = processor.createRequest(method, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")); + .create("https://vcenterprise.bluelock.com/api/v1.0/task/1")); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -718,7 +735,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { @Override protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { + @Named(PROPERTY_API_VERSION) String version) { return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"); } @@ -761,13 +778,13 @@ public class VCloudAsyncClientTest extends RestClientTest { @Override protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudLoginAsyncClient login) { + final VCloudLoginAsyncClient login) { return Suppliers. ofInstance(new VCloudSession() { @Override public Map getOrgs() { return ImmutableMap. of("org", new ReferenceTypeImpl("org", - VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); + VCloudMediaType.ORG_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); } @Override @@ -788,44 +805,19 @@ public class VCloudAsyncClientTest extends RestClientTest { } protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { - return Suppliers - .>> ofInstance(ImmutableMap - .> of( - "org", + return Suppliers.>> ofInstance(ImmutableMap + .> of("org", - ImmutableMap - . of( - "vdc", - new VDCImpl( - "vdc", - null, - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), - null, - null, - "description", - null, - null, - null, - null, - null, - ImmutableMap - . of( - "vapp", - new ReferenceTypeImpl( - "vapp", - "application/vnd.vmware.vcloud.vApp+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), - "network", - new ReferenceTypeImpl( - "network", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), - null, 0, 0, 0, false)))); + ImmutableMap. of("vdc", new VDCImpl("vdc", null, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), null, null, "description", null, + null, null, null, null, ImmutableMap. of("vapp", new ReferenceTypeImpl( + "vapp", "application/vnd.vmware.vcloud.vApp+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), "network", + new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), null, 0, 0, 0, + false)))); } @@ -839,18 +831,15 @@ public class VCloudAsyncClientTest extends RestClientTest { @Override public Map get() { return ImmutableMap. of("org", new OrgImpl("org", null, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap - . of("catalog", new ReferenceTypeImpl("catalog", - VCloudMediaType.CATALOG_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap - . of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap - . of("network", new ReferenceTypeImpl("network", - VCloudMediaType.NETWORK_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))), - new ReferenceTypeImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList - . of())); + .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap + . of("catalog", new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap + . of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap + . of("network", new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))), new ReferenceTypeImpl( + "tasksList", VCloudMediaType.TASKSLIST_XML, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList. of())); } } @@ -866,14 +855,13 @@ public class VCloudAsyncClientTest extends RestClientTest { return ImmutableMap.> of("org", ImmutableMap. of("catalog", new CatalogImpl("catalog", "type", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description", - ImmutableMap. of("item", new ReferenceTypeImpl("item", + URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description", ImmutableMap + . of("item", new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), - "template", new ReferenceTypeImpl("template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), - ImmutableList. of(), true))); + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), "template", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), + ImmutableList. of(), true))); } } @@ -885,26 +873,14 @@ public class VCloudAsyncClientTest extends RestClientTest { @Override public Map>> get() { - return ImmutableMap - .>> of( - "org", - ImmutableMap - .> of( - "catalog", - ImmutableMap - . of( - "template", - new CatalogItemImpl( - "template", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), - "description", - new ReferenceTypeImpl( - "template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), - ImmutableMap. of())))); + return ImmutableMap.>> of( + "org", ImmutableMap.> of( + "catalog", ImmutableMap. of("template", + new CatalogItemImpl("template", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description", + new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", + URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), + ImmutableMap. of())))); } } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 6a4e812fd0..d52a686d36 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -47,6 +47,17 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest