diff --git a/antcontrib/samples/javaoverssh/README.txt b/antcontrib/samples/javaoverssh/README.txt old mode 100755 new mode 100644 diff --git a/apis/atmos/src/test/resources/log4j.xml b/apis/atmos/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/apis/byon/src/test/resources/log4j.xml b/apis/byon/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CDNManagement.java old mode 100755 new mode 100644 diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java index 997119b1ce..103b405279 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudfiles.blobstore.integration; +import org.jclouds.blobstore.domain.Blob; import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest; import org.testng.annotations.Test; @@ -27,6 +28,12 @@ import org.testng.annotations.Test; */ @Test(groups = "live") public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { - + @Override + protected void checkContentDisposition(Blob blob, String contentDisposition) { + assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob + .getPayload().getContentMetadata().getContentDisposition(); + assert blob.getMetadata().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob + .getMetadata().getContentMetadata().getContentDisposition(); + } } diff --git a/apis/cloudservers/src/test/resources/log4j.xml b/apis/cloudservers/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index da19434d0b..4b7d0f7a6a 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,24 +46,26 @@ public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.equals("11.04") || input.version.equals("8.04") || !input.is64Bit; + return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + case DEBIAN: + return !(input.version.equals("6.0")) && input.is64Bit; case CENTOS: - return input.version.matches("5.[023]") || !input.is64Bit; + return !(input.version.matches("5.[023]") || input.version.equals("8.04")) && input.is64Bit; case WINDOWS: - return input.version.equals("2008") || input.version.indexOf("2003") != -1 - || (input.version.equals("2008 R2") && !input.is64Bit); + return input.version.equals("2008 SP2") || input.version.equals("") + || (input.version.equals("2008 R2") && input.is64Bit); default: - return true; + return false; } } - }; + }); } @Test diff --git a/apis/s3/src/main/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfigured.java b/apis/s3/src/main/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfigured.java index f08c59e92a..00645901dd 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfigured.java +++ b/apis/s3/src/main/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfigured.java @@ -28,15 +28,15 @@ import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.UriBuilder; -import org.jclouds.s3.S3AsyncClient; import org.jclouds.http.HttpRequest; import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.binders.BindAsHostPrefix; +import org.jclouds.s3.S3AsyncClient; import org.jclouds.util.Strings2; -import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap; /** * @@ -52,8 +52,8 @@ public class BindAsHostPrefixIfConfigured implements Binder { @Inject public BindAsHostPrefixIfConfigured(BindAsHostPrefix bindAsHostPrefix, - @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle, - @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, Provider uriBuilderProvider) { + @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle, + @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, Provider uriBuilderProvider) { this.bindAsHostPrefix = bindAsHostPrefix; this.isVhostStyle = isVhostStyle; this.servicePath = servicePath; @@ -69,14 +69,17 @@ public class BindAsHostPrefixIfConfigured implements Binder { } else { UriBuilder builder = uriBuilderProvider.get().uri(request.getEndpoint()); StringBuilder path = new StringBuilder(Strings2.urlEncode(request.getEndpoint().getPath(), S3AsyncClient.class - .getAnnotation(SkipEncoding.class).value())); - int indexToInsert = path.indexOf(servicePath); - indexToInsert = indexToInsert == -1 ? 0 : indexToInsert; - indexToInsert += servicePath.length(); + .getAnnotation(SkipEncoding.class).value())); + int indexToInsert = 0; + if (!servicePath.equals("/")) { + indexToInsert = path.indexOf(servicePath); + indexToInsert = indexToInsert == -1 ? 0 : indexToInsert; + indexToInsert += servicePath.length(); + } path.insert(indexToInsert, "/" + payload.toString()); builder.replacePath(path.toString()); - return (R) request.toBuilder().endpoint(builder.buildFromEncodedMap(Maps. newLinkedHashMap())) - .build(); + return (R) request.toBuilder().endpoint(builder.buildFromEncodedMap(ImmutableMap. of())) + .build(); } } } diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java new file mode 100644 index 0000000000..f39734d4bc --- /dev/null +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.s3.binders; + +import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.Properties; + +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.s3.BaseS3AsyncClientTest; +import org.jclouds.s3.S3AsyncClient; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code BindAsHostPrefixIfConfigured} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredNoPathTest") +public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testBucketWithHostnameStyle() throws IOException, SecurityException, NoSuchMethodException { + + Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class); + GeneratedHttpRequest request = processor.createRequest(method, "testbucket.example.com", "test.jpg"); + assertRequestLineEquals(request, "DELETE https://s3.amazonaws.com/testbucket.example.com/test.jpg HTTP/1.1"); + } + + + @Override + protected Properties getProperties() { + Properties properties = super.getProperties(); + properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false"); + return properties; + } + +} diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java index 8751ccb821..1c13e7c5f6 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java @@ -23,6 +23,7 @@ import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCK import static org.testng.Assert.assertEquals; import java.io.IOException; +import java.lang.reflect.Method; import java.net.URI; import java.util.Properties; @@ -60,6 +61,20 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest * - * @see * @author Adrian Cole */ @@ -105,9 +107,82 @@ import com.google.common.util.concurrent.ListenableFuture; public interface VCloudAsyncClient extends CommonVCloudAsyncClient { /** + * Provides asynchronous access to VApp Template features. + * + * @see VCloudClient#getVAppTemplateClient * - * @see VCloudClient#getThumbnailOfVm */ + @Delegate + VAppTemplateAsyncClient getVAppTemplateClient(); + + /** + * Provides asynchronous access to VApp features. + * + * @see VCloudClient#getVAppClient + * + */ + @Delegate + VAppAsyncClient getVAppClient(); + + /** + * Provides asynchronous access to Vm features. + * + * @see VCloudClient#getVmClient + * + */ + @Delegate + VmAsyncClient getVmClient(); + + /** + * Provides asynchronous access to Catalog features. + * + * @see VCloudClient#getCatalogClient + * + */ + @Delegate + CatalogAsyncClient getCatalogClient(); + + /** + * Provides asynchronous access to Task features. + * + * @see VCloudClient#getTaskClient + * + */ + @Delegate + TaskAsyncClient getTaskClient(); + + /** + * Provides asynchronous access to VDC features. + * + * @see VCloudClient#getVDCClient + * + */ + @Delegate + VDCAsyncClient getVDCClient(); + + /** + * Provides asynchronous access to Network features. + * + * @see VCloudClient#getNetworkClient + * + */ + @Delegate + NetworkAsyncClient getNetworkClient(); + + /** + * Provides asynchronous access to Org features. + * + * @see VCloudClient#getOrgClient + * + */ + @Delegate + OrgAsyncClient getOrgClient(); + + /** + * + * @see VmAsyncClient#getScreenThumbnailForVm + */ + @Deprecated @GET @Path("/screen") @Consumes("image/png") @@ -116,8 +191,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { /** * - * @see VCloudClient#listOrgs + * @see OrgAsyncClient#listOrgs */ + @Deprecated @GET @Endpoint(OrgList.class) @XMLResponseParser(OrgListHandler.class) @@ -125,8 +201,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture> listOrgs(); /** - * @see VCloudClient#getVAppTemplate + * @see VAppTemplateAsyncClient#getVAppTemplate */ + @Deprecated @GET @Consumes(VAPPTEMPLATE_XML) @XMLResponseParser(VAppTemplateHandler.class) @@ -134,8 +211,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture getVAppTemplate(@EndpointParam URI vAppTemplate); /** - * @see VCloudClient#getOvfEnvelopeForVAppTemplate + * @see VAppTemplateClient#getOvfEnvelopeForVAppTemplate */ + @Deprecated @GET @Consumes(MediaType.TEXT_XML) @Path("/ovf") @@ -144,20 +222,22 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture getOvfEnvelopeForVAppTemplate(@EndpointParam URI vAppTemplate); /** - * @see VCloudClient#findVAppTemplateInOrgCatalogNamed + * @see VAppTemplateAsyncClient#findVAppTemplateInOrgCatalogNamed */ + @Deprecated @GET @Consumes(VAPPTEMPLATE_XML) @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 + * @see VAppTemplateAsyncClient#createVAppInVDCByInstantiatingTemplate */ + @Deprecated @POST @Path("/action/instantiateVAppTemplate") @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") @@ -165,52 +245,27 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppHandler.class) @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class) ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, - @PayloadParam("template") URI template, - @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, - InstantiateVAppTemplateOptions... options); + @PayloadParam("template") URI template, + @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, + InstantiateVAppTemplateOptions... options); /** - * @see VCloudClient#cloneVAppInVDC + * @see VAppAsyncClient#copyVAppToVDCAndName */ + @Deprecated @POST @Path("/action/cloneVApp") @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") @Consumes(TASK_XML) @XMLResponseParser(TaskHandler.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class) - ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone, - @PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, CloneVAppOptions... options); + ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("Source") URI toClone, + @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, CloneVAppOptions... options); /** - * @see VCloudClient#addResourceEntitytoCatalog(URI, String, String, URI) - */ - @POST - @Path("/catalogItems") - @Consumes(CATALOGITEM_XML) - @Produces(CATALOGITEM_XML) - @MapBinder(BindCatalogItemToXmlPayload.class) - @XMLResponseParser(CatalogItemHandler.class) - ListenableFuture addResourceEntitytoCatalog(@EndpointParam URI catalog, - @PayloadParam("name") String name, @PayloadParam("description") String description, - @PayloadParam("entity") URI entity); - - /** - * @see VCloudClient#addResourceEntitytoCatalog(URI, String, String, URI, - * Map) - */ - @POST - @Path("/catalogItems") - @Consumes(CATALOGITEM_XML) - @Produces(CATALOGITEM_XML) - @MapBinder(BindCatalogItemToXmlPayload.class) - @XMLResponseParser(CatalogItemHandler.class) - ListenableFuture addResourceEntitytoCatalog(@EndpointParam URI catalog, - @PayloadParam("name") String name, @PayloadParam("description") String description, - @PayloadParam("entity") URI entity, Map properties); - - /** - * @see VCloudClient#captureVAppInVDC + * @see VAppTemplateAsyncClient#captureVAppInVDC */ + @Deprecated @POST @Path("/action/captureVApp") @Produces("application/vnd.vmware.vcloud.captureVAppParams+xml") @@ -218,25 +273,27 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @XMLResponseParser(VAppTemplateHandler.class) @MapBinder(BindCaptureVAppParamsToXmlPayload.class) ListenableFuture captureVAppInVDC(@EndpointParam URI vdc, - @PayloadParam("vApp") URI toCapture, - @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName, - CaptureVAppOptions... options); + @PayloadParam("vApp") URI toCapture, + @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName, + CaptureVAppOptions... options); /** - * @see VCloudClient#findVAppInOrgVDCNamed + * @see VAppAsyncClient#findVAppInOrgVDCNamed */ + @Deprecated @GET @Consumes(VAPP_XML) @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 + * @see VAppAsyncClient#getVApp */ + @Deprecated @GET @Consumes(VAPP_XML) @XMLResponseParser(VAppHandler.class) @@ -244,8 +301,9 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture getVApp(@EndpointParam URI vApp); /** - * @see VCloudClient#getVm + * @see VmAsyncClient#getVm */ + @Deprecated @GET @Consumes(VM_XML) @XMLResponseParser(VmHandler.class) @@ -253,53 +311,36 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture getVm(@EndpointParam URI vm); /** - * @see VCloudClient#updateCPUCountOfVm - */ - @PUT - @Consumes(TASK_XML) - @Produces(RASDITEM_XML) - @Path("/virtualHardwareSection/cpu") - @XMLResponseParser(TaskHandler.class) - ListenableFuture updateCPUCountOfVm(@EndpointParam URI vm, - @BinderParam(BindCPUCountToXmlPayload.class) int cpuCount); - - /** - * @see VCloudClient#updateMemoryMBOfVm - */ - @PUT - @Consumes(TASK_XML) - @Produces(RASDITEM_XML) - @Path("/virtualHardwareSection/memory") - @XMLResponseParser(TaskHandler.class) - ListenableFuture updateMemoryMBOfVm(@EndpointParam URI vm, - @BinderParam(BindMemoryToXmlPayload.class) int memoryInMB); - - /** - * @see VCloudClient#updateGuestCustomizationOfVm + * @see VmAsyncClient#updateGuestCustomizationOfVm */ + @Deprecated @PUT @Consumes(TASK_XML) @Produces(GUESTCUSTOMIZATIONSECTION_XML) @Path("/guestCustomizationSection") @XMLResponseParser(TaskHandler.class) ListenableFuture updateGuestCustomizationOfVm( - @EndpointParam URI vm, - @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection); + @EndpointParam URI vm, + @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection); /** - * @see VCloudClient#updateNetworkConnectionOfVm + * @see VmAsyncClient#updateNetworkConnectionOfVm */ + @Deprecated @PUT @Consumes(TASK_XML) @Produces(NETWORKCONNECTIONSECTION_XML) @Path("/networkConnectionSection") @XMLResponseParser(TaskHandler.class) - ListenableFuture updateNetworkConnectionOfVm(@EndpointParam URI vm, - @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection); + ListenableFuture updateNetworkConnectionOfVm( + @EndpointParam URI vm, + @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection); /** - * @see VCloudClient#deployVAppOrVm + * @see VAppAsyncClient#deployVApp + * @see VmAsyncClient#deployVm */ + @Deprecated @POST @Consumes(TASK_XML) @Produces(DEPLOYVAPPPARAMS_XML) @@ -309,8 +350,10 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture deployVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#deployAndPowerOnVAppOrVm + * @see VAppAsyncClient#deployAndPowerOnVApp + * @see VmAsyncClient#deployAndPowerOnVm */ + @Deprecated @POST @Consumes(TASK_XML) @Produces(DEPLOYVAPPPARAMS_XML) @@ -321,8 +364,10 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture deployAndPowerOnVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#undeployVAppOrVm + * @see VAppAsyncClient#undeployVApp + * @see VmAsyncClient#undeployVm */ + @Deprecated @POST @Consumes(TASK_XML) @Produces(UNDEPLOYVAPPPARAMS_XML) @@ -332,8 +377,10 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture undeployVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#undeployAndSaveStateOfVAppOrVm + * @see VAppAsyncClient#undeployAndSaveStateOfVApp + * @see VmAsyncClient#undeployAndSaveStateOfVm */ + @Deprecated @POST @Consumes(TASK_XML) @Produces(UNDEPLOYVAPPPARAMS_XML) @@ -344,8 +391,10 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture undeployAndSaveStateOfVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#powerOnVAppOrVm + * @see VAppAsyncClient#powerOnVApp + * @see VmAsyncClient#powerOnVm */ + @Deprecated @POST @Consumes(TASK_XML) @Path("/power/action/powerOn") @@ -353,8 +402,10 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture powerOnVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#powerOffVAppOrVm + * @see VAppAsyncClient#powerOffVApp + * @see VmAsyncClient#powerOffVm */ + @Deprecated @POST @Consumes(TASK_XML) @Path("/power/action/powerOff") @@ -362,15 +413,19 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture powerOffVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#shutdownVAppOrVm + * @see VAppAsyncClient#shutdownVApp + * @see VmAsyncClient#shutdownVm */ + @Deprecated @POST @Path("/power/action/shutdown") ListenableFuture shutdownVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#resetVAppOrVm + * @see VAppAsyncClient#resetVApp + * @see VmAsyncClient#resetVm */ + @Deprecated @POST @Consumes(TASK_XML) @Path("/power/action/reset") @@ -378,15 +433,19 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture resetVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#rebootVAppOrVm + * @see VAppAsyncClient#rebootVApp + * @see VmAsyncClient#rebootVm */ + @Deprecated @POST @Path("/power/action/reboot") ListenableFuture rebootVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see VCloudClient#suspendVAppOrVm + * @see VAppAsyncClient#suspendVApp + * @see VmAsyncClient#suspendVm */ + @Deprecated @POST @Consumes(TASK_XML) @Path("/power/action/suspend") @@ -394,15 +453,7 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { ListenableFuture suspendVAppOrVm(@EndpointParam URI vAppOrVmId); /** - * @see CommonVCloudClient#deleteVAppTemplateVAppOrMediaImage - */ - @DELETE - @ExceptionParser(ReturnVoidOnNotFoundOr404.class) - @XMLResponseParser(TaskHandler.class) - ListenableFuture deleteVAppTemplateVAppOrMediaImage(@EndpointParam URI id); - - /** - * @see CommonVCloudClient#deleteVApp + * @see VAppAsyncClient#deleteVApp */ @Deprecated @DELETE diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java index 85134ef25b..4355c40232 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -21,21 +21,34 @@ package org.jclouds.vcloud; import java.io.InputStream; 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.ovf.Envelope; +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.NetworkConnectionSection; +import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.TasksList; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; +import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.domain.network.OrgNetwork; +import org.jclouds.vcloud.features.CatalogClient; +import org.jclouds.vcloud.features.NetworkClient; +import org.jclouds.vcloud.features.OrgClient; +import org.jclouds.vcloud.features.TaskClient; +import org.jclouds.vcloud.features.VAppClient; +import org.jclouds.vcloud.features.VAppTemplateClient; +import org.jclouds.vcloud.features.VDCClient; +import org.jclouds.vcloud.features.VmClient; import org.jclouds.vcloud.options.CaptureVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -44,269 +57,336 @@ 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 { + /** + * Provides asynchronous access to VApp Template features. + * + */ + @Delegate + VAppTemplateClient getVAppTemplateClient(); /** - * Get a Screen Thumbnail for a Virtual Machine - * - * @param vm - * to snapshot + * Provides synchronous access to VApp features. */ + @Delegate + VAppClient getVAppClient(); + + /** + * Provides synchronous access to Vm features. + */ + @Delegate + VmClient getVmClient(); + + /** + * Provides synchronous access to Catalog features. + */ + @Delegate + CatalogClient getCatalogClient(); + + /** + * Provides synchronous access to Task features. + */ + @Delegate + TaskClient getTaskClient(); + + /** + * Provides synchronous access to VDC features. + */ + @Delegate + VDCClient getVDCClient(); + + /** + * Provides synchronous access to Network features. + */ + @Delegate + NetworkClient getNetworkClient(); + + /** + * Provides synchronous access to Org features. + */ + @Delegate + OrgClient getOrgClient(); + + /** + * @see VmClient#getThumbnail + */ + @Deprecated InputStream getThumbnailOfVm(URI vm); /** - * The response to a login request includes a list of the organizations to - * which the authenticated user has access. - * - * @return organizations indexed by name + * @see OrgClient#listOrgs */ + @Deprecated Map listOrgs(); + /** + * @see VAppTemplateClient#createVAppInVDCByInstantiatingTemplate + */ + @Deprecated VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options); + /** + * @see VAppClient#copyVAppToVDCAndName + */ + @Deprecated Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options); /** - * The captureVApp request creates a vApp template from an instantiated vApp. - *

Note

Before it can be captured, a vApp must be undeployed - * - * @param vDC - * @param toClone - * @param templateName - * @param options - * @return template in progress + * @see VAppClient#captureAsTemplateInVDC */ + @Deprecated VAppTemplate captureVAppInVDC(URI vDC, URI toClone, String templateName, CaptureVAppOptions... options); + /** + * @see VAppTemplateClient#get + */ + @Deprecated VAppTemplate getVAppTemplate(URI vAppTemplate); + /** + * @see VAppTemplateClient#getOvfEnvelope + */ + @Deprecated Envelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate); /** - * Modify the Guest Customization Section of a Virtual Machine - * - * @param vm - * uri to modify - * @param updated - * guestCustomizationSection - * @return task in progress + * @see VmClient#updateGuestCustomization */ + @Deprecated Task updateGuestCustomizationOfVm(URI vm, GuestCustomizationSection guestCustomizationSection); /** - * Modify the Network Connection Section of a Virtual Machine - * - * @param vm - * uri to modify - * @param updated - * networkConnectionSection - * @return task in progress + * @see VmClient#updateNetworkConnection */ + @Deprecated Task updateNetworkConnectionOfVm(URI vm, NetworkConnectionSection guestCustomizationSection); /** - * 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 - * @param catalogName - * catalog name, or null for the default - * @param itemName - * item you wish to lookup - * - * @throws NoSuchElementException - * if you specified an org, catalog, or catalog item name that - * isn't present + * @see VAppTemplateClient#findInOrgCatalogNamed */ + @Deprecated VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, - String itemName); + String itemName); + /** + * @see VAppClient#findInOrgVDCNamed + */ + @Deprecated VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); + /** + * @see VAppClient#get + */ + @Deprecated VApp getVApp(URI vApp); + /** + * @see VmClient#get + */ + @Deprecated Vm getVm(URI vm); /** - * update the cpuCount of an existing VM * - * @param vm - * to update - * @param cpuCount - * count to change the primary cpu to - */ - Task updateCPUCountOfVm(URI vm, int cpuCount); - - /** - * update the memoryInMB of an existing VM - * - * @param vm - * to update - * @param memoryInMB - * memory in MB to assign to the VM - */ - Task updateMemoryMBOfVm(URI vm, int memoryInMB); - - /** - * 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. + * @see VAppClient#deploy + * @see VmClient#deploy */ + @Deprecated Task deployVAppOrVm(URI vAppOrVmId); /** - * like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on - * state * + * @see VAppClient#deployAndPowerOn + * @see VmClient#deployAndPowerOn */ + @Deprecated 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 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} * + * @see VAppClient#undeploy + * @see VmClient#undeploy */ + @Deprecated Task undeployVAppOrVm(URI vAppOrVmId); /** - * like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines - * are suspended and their suspend state saved * + * @see VAppClient#undeployAndSaveState + * @see VmClient#undeployAndSaveState */ + @Deprecated 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 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. + * + * @see VAppClient#powerOn + * @see VmClient#powerOn */ + @Deprecated 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 virtual machine URL powers off the specified - * virtual machine. + * + * @see VAppClient#powerOff + * @see VmClient#powerOff */ + @Deprecated 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 virtual machine URL shuts down the specified - * virtual machine. - *

- *

NOTE - * A reset request to a virtual machine URL resets the specified virtual - * machine. + * + * @see VAppClient#reset + * @see VmClient#reset */ + @Deprecated 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 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 + * + * @see VAppClient#reboot + * @see VmClient#reboot */ + @Deprecated 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 virtual machine URL suspends the specified virtual - * machine. + * + * @see VAppClient#suspend + * @see VmClient#suspend */ + @Deprecated Task suspendVAppOrVm(URI vAppOrVmId); /** - * delete a vAppTemplate, vApp, or media image. You cannot delete an object - * if it is in use. Any object that is being copied or moved is in use. Other - * criteria that determine whether an object is in use depend on the object - * type. - *

    - *
  • A vApptemplate is in use if it is being instantiated. After - * instantiation is complete, the template is no longer in use.
  • - *
  • A vApp is in use if it is deployed.
  • - *
  • A media image is in use if it is inserted in a Vm.
  • - *
* - * @param id - * href of the vAppTemplate, vApp, or media image - * @return task of the operation in progress - */ - Task deleteVAppTemplateVAppOrMediaImage(URI id); - - /** - * - * @see deleteVAppTemplateVAppOrMediaImage + * @see VAppClient#delete */ @Deprecated Task deleteVApp(URI vAppId); /** - * A catalog can contain references to vApp templates and media images that - * have been uploaded to any vDC in an organization. A vApp template or media - * image can be listed in at most one catalog. * - * @param catalog - * URI of the catalog to add the resourceEntity from - * @param name - * name of the entry in the catalog - * @param description - * description of the entry in the catalog - * @param entity - * the reference to the item from the VDC - * @param properties - * metadata to associate with this item - * @return the new catalog item + * @see CatalogClient#getCatalog */ - CatalogItem addResourceEntitytoCatalog(URI catalog, String name, String description, URI entity, - Map properties); + @Override + @Deprecated + Catalog getCatalog(URI catalogId); - CatalogItem addResourceEntitytoCatalog(URI catalog, String name, String description, URI entity); + /** + * + * @see CatalogClient#getCatalogItem + */ + @Override + @Deprecated + Catalog findCatalogInOrgNamed(@Nullable String orgName, @Nullable String catalogName); + + /** + * + * @see CatalogClient#getCatalogItem + */ + @Override + @Deprecated + CatalogItem getCatalogItem(URI catalogItem); + + /** + * + * @see CatalogClient#findCatalogItemInOrgCatalogNamed + */ + @Override + @Deprecated + CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName); + + /** + * + * @see TaskClient#getTasksList + */ + @Override + @Deprecated + TasksList getTasksList(URI tasksListId); + + /** + * + * @see TaskClient#findTasksListInOrgNamed + */ + @Override + @Deprecated + TasksList findTasksListInOrgNamed(String orgName); + + /** + * + * @see TaskClient#getTask + */ + @Override + @Deprecated + Task getTask(URI taskId); + + /** + * + * @see TaskClient#cancelTask + */ + @Override + @Deprecated + void cancelTask(URI taskId); + + /** + * + * @see VDCClient#getVDC + */ + @Override + @Deprecated + VDC getVDC(URI vdc); + + /** + * + * @see VDCClient#findVDCInOrgNamed + */ + @Override + @Deprecated + VDC findVDCInOrgNamed(String orgName, String vdcName); + + /** + * + * @see NetworkClient#findNetworkInOrgVDCNamed + */ + @Override + @Deprecated + OrgNetwork findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName); + + /** + * + * @see NetworkClient#getNetwork + */ + @Override + @Deprecated + OrgNetwork getNetwork(URI network); + + /** + * + * @see OrgClient#getOrg + */ + @Override + @Deprecated + Org getOrg(URI orgId); + + /** + * + * @see OrgClient#findOrgNamed + */ + @Override + @Deprecated + Org findOrgNamed(@Nullable String name); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java index cdfe1c2cf0..727f973036 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java @@ -26,8 +26,8 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_S import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; +import java.util.Map.Entry; import javax.inject.Named; import javax.inject.Singleton; @@ -39,8 +39,8 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.vcloud.options.CatalogItemOptions; -import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; @@ -58,7 +58,7 @@ public class BindCatalogItemToXmlPayload implements MapBinder { @Inject public BindCatalogItemToXmlPayload(BindToStringPayload stringBinder, - @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { + @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { this.ns = ns; this.schema = schema; this.stringBinder = stringBinder; @@ -67,19 +67,15 @@ public class BindCatalogItemToXmlPayload implements MapBinder { @Override public R bindToRequest(R request, Map postParams) { checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests!"); + "this binder is only valid for GeneratedHttpRequests!"); GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; checkState(gRequest.getArgs() != null, "args should be initialized at this point"); String name = checkNotNull(postParams.get("name"), "name"); - String description = checkNotNull(postParams.get("description"), "description"); - URI entity = URI.create(checkNotNull(postParams.get("entity"), "entity")); + URI entity = URI.create(checkNotNull(postParams.get("Entity"), "Entity")); - Map properties = findMapInArgsOrNull(gRequest); - if (properties == null) { - properties = ImmutableMap.of(); - } + CatalogItemOptions options = findOptionsInArgsOrNew(gRequest); try { - return stringBinder.bindToRequest(request, generateXml(name, description, entity, properties)); + return stringBinder.bindToRequest(request, generateXml(name, entity, options)); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (FactoryConfigurationError e) { @@ -90,12 +86,13 @@ public class BindCatalogItemToXmlPayload implements MapBinder { } - protected String generateXml(String templateName, String description, URI entity, Map properties) - throws ParserConfigurationException, FactoryConfigurationError, TransformerException { + protected String generateXml(String templateName, URI entity, CatalogItemOptions options) + throws ParserConfigurationException, FactoryConfigurationError, TransformerException { XMLBuilder rootBuilder = buildRoot(templateName); - rootBuilder.e("Description").t(description); + if (options.getDescription() != null) + rootBuilder.e("Description").t(options.getDescription()); rootBuilder.e("Entity").a("href", entity.toASCIIString()); - for (Entry entry : properties.entrySet()) { + for (Entry entry : options.getProperties().entrySet()) { rootBuilder.e("Property").a("key", entry.getKey()).t(entry.getValue()); } Properties outputProperties = new Properties(); @@ -104,19 +101,22 @@ public class BindCatalogItemToXmlPayload implements MapBinder { } protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError { - XMLBuilder rootBuilder = XMLBuilder.create("CatalogItem").a("name", name).a("xmlns", ns) - .a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema); + XMLBuilder rootBuilder = XMLBuilder.create("CatalogItem").a("name", name).a("xmlns", ns).a("xmlns:xsi", + "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema); return rootBuilder; } - @SuppressWarnings("unchecked") - protected Map findMapInArgsOrNull(GeneratedHttpRequest gRequest) { + protected CatalogItemOptions findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) { for (Object arg : gRequest.getArgs()) { - if (arg instanceof Map) { - return (Map) arg; + if (arg instanceof CatalogItemOptions) { + return CatalogItemOptions.class.cast(arg); + } else if (arg.getClass().isArray()) { + Object[] array = (Object[]) arg; + if (array.length > 0 && array[0] instanceof CatalogItemOptions) + return CatalogItemOptions.class.cast(array[0]); } } - return null; + return new CatalogItemOptions(); } @Override diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java new file mode 100644 index 0000000000..3c403127b1 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java @@ -0,0 +1,139 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.binders; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; + +import java.util.Map; +import java.util.Properties; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; +import org.jclouds.rest.binders.BindToStringPayload; +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.vcloud.options.CloneOptions; + +import com.google.common.base.Throwables; +import com.google.inject.Inject; +import com.jamesmurty.utils.XMLBuilder; + +/** + * + * @author Adrian Cole + * + */ +@Singleton +public abstract class BindCloneParamsToXmlPayload implements MapBinder { + + protected final String ns; + protected final String schema; + private final BindToStringPayload stringBinder; + + protected abstract String getRootElement(); + protected abstract String getSourceMediaType(); + protected abstract Class getOptionClass(); + + @Inject + public BindCloneParamsToXmlPayload(BindToStringPayload stringBinder, + @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { + this.ns = ns; + this.schema = schema; + this.stringBinder = stringBinder; + } + + @Override + public R bindToRequest(R request, Map postParams) { + checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, + "this binder is only valid for GeneratedHttpRequests!"); + GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; + checkState(gRequest.getArgs() != null, "args should be initialized at this point"); + String name = checkNotNull(postParams.get("name"), "name"); + String source = checkNotNull(postParams.get("Source"), "Source"); + boolean isSourceDelete = Boolean.parseBoolean(postParams.get("IsSourceDelete")); + + O options = findOptionsInArgsOrNew(gRequest); + return stringBinder.bindToRequest(request, generateXml(name, source, isSourceDelete, options)); + } + + protected String generateXml(String name, String source, boolean isSourceDelete, O options) { + XMLBuilder rootBuilder = buildRoot(name, options); + addElementsUnderRoot(rootBuilder, source, options, isSourceDelete); + Properties outputProperties = new Properties(); + outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); + try { + return rootBuilder.asString(outputProperties); + } catch (Exception e) { + throw Throwables.propagate(e); + } + } + + protected void addElementsUnderRoot(XMLBuilder rootBuilder, String source, O options, boolean isSourceDelete) { + if (options.getDescription() != null) + rootBuilder.e("Description").text(options.getDescription()); + rootBuilder.e("Source").a("href", source).a("type", getSourceMediaType()); + if (isSourceDelete) + rootBuilder.e("IsSourceDelete").t("true"); + } + + protected XMLBuilder buildRoot(String name, O options) { + try { + return XMLBuilder.create(getRootElement()).a("xmlns", ns).a("xmlns:xsi", + "http://www.w3.org/2001/XMLSchema-instance").a("xsi:schemaLocation", ns + " " + schema).a("name", + name); + } catch (Exception e) { + throw Throwables.propagate(e); + } + } + + @SuppressWarnings("unchecked") + protected O findOptionsInArgsOrNew(GeneratedHttpRequest gRequest) { + for (Object arg : gRequest.getArgs()) { + if (getOptionClass().isInstance(arg)) { + return (O) arg; + } else if (arg.getClass().isArray()) { + Object[] array = (Object[]) arg; + if (array.length > 0 && getOptionClass().isInstance(array[0])) + return (O) array[0]; + } + } + try { + return getOptionClass().newInstance(); + } catch (Exception e) { + Throwables.propagate(e); + assert false : "unreachable code"; + return null; + } + } + + @Override + public R bindToRequest(R request, Object input) { + throw new IllegalStateException("CloneParams is needs parameters"); + } + + protected String ifNullDefaultTo(String value, String defaultValue) { + return value != null ? value : checkNotNull(defaultValue, "defaultValue"); + } +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java new file mode 100644 index 0000000000..b5d83ca1d3 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.binders; + +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.rest.binders.BindToStringPayload; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.options.CloneVAppOptions; + +import com.google.inject.Inject; +import com.jamesmurty.utils.XMLBuilder; + +/** + * + * @author Adrian Cole + * + */ +@Singleton +public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload { + + @Inject + public BindCloneVAppParamsToXmlPayload(BindToStringPayload stringBinder, + @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { + super(stringBinder, schema, schema); + } + + @Override + protected Class getOptionClass() { + return CloneVAppOptions.class; + } + + @Override + protected String getRootElement() { + return "CloneVAppParams"; + } + + @Override + protected String getSourceMediaType() { + return VCloudMediaType.VAPP_XML; + } + + protected XMLBuilder buildRoot(String name, CloneVAppOptions options) { + return super.buildRoot(name, options).a("deploy", options.isDeploy() + "").a("powerOn", options.isPowerOn() + ""); + } + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java new file mode 100644 index 0000000000..900800ac9f --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java @@ -0,0 +1,62 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.binders; + +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; +import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.rest.binders.BindToStringPayload; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.options.CloneVAppTemplateOptions; + +import com.google.inject.Inject; + +/** + * + * @author Adrian Cole + * + */ +@Singleton +public class BindCloneVAppTemplateParamsToXmlPayload extends BindCloneParamsToXmlPayload { + + @Inject + public BindCloneVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder, + @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema) { + super(stringBinder, schema, schema); + } + + @Override + protected Class getOptionClass() { + return CloneVAppTemplateOptions.class; + } + + @Override + protected String getRootElement() { + return "CloneVAppTemplateParams"; + } + + @Override + protected String getSourceMediaType() { + return VCloudMediaType.VAPPTEMPLATE_XML; + } + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index d14b1d5975..2eb7627e63 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -140,7 +140,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder Set ifCustomizationScriptIsSetGetVmsInTemplate(String customizationScript, final URI template) { Set vms = Sets.newLinkedHashSet(); if (customizationScript != null) { - VAppTemplate vAppTemplate = client.getVAppTemplate(template); + VAppTemplate vAppTemplate = client.getVAppTemplateClient().getVAppTemplate(template); checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template); vms = vAppTemplate.getChildren(); checkArgument(vms.size() > 0, "no vms found in vAppTemplate %s", vAppTemplate); @@ -189,7 +189,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder @Override public String apply(URI template) { String networkName; - VAppTemplate vAppTemplate = client.getVAppTemplate(template); + VAppTemplate vAppTemplate = client.getVAppTemplateClient().getVAppTemplate(template); checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template); Set networks = vAppTemplate.getNetworkSection().getNetworks(); checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java index abcf1480fb..55f9633705 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java @@ -26,8 +26,10 @@ import javax.inject.Inject; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.predicates.ImagePredicates; +import org.jclouds.domain.Location; import org.jclouds.logging.Logger; import org.jclouds.ovf.VirtualHardwareSection; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Vm; @@ -42,11 +44,11 @@ public class HardwareForVApp implements Function { @Resource protected Logger logger = Logger.NULL; - private final FindLocationForResource findLocationForResource; + private final Function findLocationForResource; private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder; @Inject - protected HardwareForVApp(FindLocationForResource findLocationForResource, + protected HardwareForVApp(Function findLocationForResource, VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java index c3560b7870..59206a1a67 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java @@ -72,7 +72,7 @@ public class HardwareForVAppTemplate implements Function return null; } - Envelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref()); + Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref()); if (ovf == null) { logger.warn("cannot parse hardware as no ovf envelope found for %s", from); return null; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareInOrg.java index 3c8d266beb..f7ff06b13d 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareInOrg.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/HardwareInOrg.java @@ -38,7 +38,7 @@ import com.google.common.collect.Iterables; @Singleton public class HardwareInOrg implements Function> { - private final AllCatalogItemsInOrg allCatalogItemsInOrg; + private final Function> allCatalogItemsInOrg; private final Function, Iterable> vAppTemplatesForCatalogItems; private final Provider sizeForVAppTemplateProvider; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java index f1ca476d76..d473f6f533 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java @@ -63,7 +63,7 @@ public class ImageForVAppTemplate implements Function { builder.name(from.getName()); builder.location(findLocationForResource.apply(checkNotNull(parent, "parent"))); builder.description(from.getDescription() != null ? from.getDescription() : from.getName()); - Envelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref()); + Envelope ovf = client.getVAppTemplateClient().getOvfEnvelopeForVAppTemplate(from.getHref()); builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf)); builder.defaultCredentials(credentialsProvider.execute(from)); return builder.build(); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index 75dd7d2702..8602a92c7e 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -38,10 +38,10 @@ import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder; import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -54,7 +54,7 @@ import com.google.common.collect.Iterables; */ @Singleton public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn implements - CreateNodeWithGroupEncodedIntoName { + CreateNodeWithGroupEncodedIntoName { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; @@ -65,7 +65,7 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA @Inject protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(Predicate successTester, - VCloudClient client, GetNodeMetadataStrategy getNode) { + VCloudClient client, GetNodeMetadataStrategy getNode) { this.client = client; this.successTester = successTester; this.getNode = getNode; @@ -81,7 +81,7 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA String customizationScript = VCloudTemplateOptions.class.cast(template.getOptions()).getCustomizationScript(); IpAddressAllocationMode ipAddressAllocationMode = VCloudTemplateOptions.class.cast(template.getOptions()) - .getIpAddressAllocationMode(); + .getIpAddressAllocationMode(); options.description(VCloudTemplateOptions.class.cast(template.getOptions()).getDescription()); options.customizeOnInstantiate(false); @@ -96,12 +96,13 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA logger.debug(">> instantiating vApp vDC(%s) template(%s) name(%s) options(%s) ", VDC, templateId, name, options); - VApp vAppResponse = client.instantiateVAppTemplateInVDC(VDC, templateId, name, options); + VApp vAppResponse = client.getVAppTemplateClient().createVAppInVDCByInstantiatingTemplate(name, VDC, templateId, + options); waitForTask(vAppResponse.getTasks().get(0), vAppResponse); logger.debug("<< instantiated VApp(%s)", vAppResponse.getName()); // note customization is a serial concern at the moment - Vm vm = Iterables.get(client.getVApp(vAppResponse.getHref()).getChildren(), 0); + Vm vm = Iterables.get(client.getVAppClient().getVApp(vAppResponse.getHref()).getChildren(), 0); if (customizationScript != null) { logger.trace(">> updating customization vm(%s) ", vm.getName()); waitForTask(updateVmWithCustomizationScript(vm, customizationScript), vAppResponse); @@ -121,8 +122,8 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA waitForTask(updateMemoryMBOfVm(vm, memoryMB), vAppResponse); logger.trace("<< updated memoryMB vm(%s) ", vm.getName()); logger.trace(">> deploying and powering on vApp(%s) ", vAppResponse.getName()); - return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, - client.deployAndPowerOnVAppOrVm(vAppResponse.getHref())); + return blockOnDeployAndPowerOnIfConfigured(options, vAppResponse, client.getVAppClient().deployAndPowerOnVApp( + vAppResponse.getHref())); } @@ -140,34 +141,34 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA // returns a script that // loses newlines. guestConfiguration.setCustomizationScript(customizationScript); - return client.updateGuestCustomizationOfVm(vm.getHref(), guestConfiguration); + return client.getVmClient().updateGuestCustomizationOfVm(guestConfiguration, vm.getHref()); } public Task updateVmWithIpAddressAllocationMode(Vm vm, final IpAddressAllocationMode ipAddressAllocationMode) { NetworkConnectionSection net = vm.getNetworkConnectionSection(); Builder builder = net.toBuilder(); builder.connections(Iterables.transform(net.getConnections(), - new Function() { + new Function() { - @Override - public NetworkConnection apply(NetworkConnection arg0) { - return arg0.toBuilder().connected(true).ipAddressAllocationMode(ipAddressAllocationMode).build(); - } + @Override + public NetworkConnection apply(NetworkConnection arg0) { + return arg0.toBuilder().connected(true).ipAddressAllocationMode(ipAddressAllocationMode).build(); + } - })); - return client.updateNetworkConnectionOfVm(vm.getHref(), builder.build()); + })); + return client.getVmClient().updateNetworkConnectionOfVm(builder.build(), vm.getHref()); } public Task updateCPUCountOfVm(Vm vm, int cpuCount) { - return client.updateCPUCountOfVm(vm.getHref(), cpuCount); + return client.getVmClient().updateCPUCountOfVm(cpuCount, vm.getHref()); } public Task updateMemoryMBOfVm(Vm vm, int memoryInMB) { - return client.updateMemoryMBOfVm(vm.getHref(), memoryInMB); + return client.getVmClient().updateMemoryMBOfVm(memoryInMB, vm.getHref()); } private NodeMetadata blockOnDeployAndPowerOnIfConfigured(InstantiateVAppTemplateOptions options, VApp vAppResponse, - Task task) { + Task task) { if (options.shouldBlock()) { waitForTask(task, vAppResponse); logger.debug("<< ready vApp(%s)", vAppResponse.getName()); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudDestroyNodeStrategy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudDestroyNodeStrategy.java index 9d26d4a844..a11e4b0052 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudDestroyNodeStrategy.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudDestroyNodeStrategy.java @@ -64,7 +64,7 @@ public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy { @Override public NodeMetadata destroyNode(String id) { URI vappId = URI.create(checkNotNull(id, "node.id")); - VApp vApp = client.getVApp(vappId); + VApp vApp = client.getVAppClient().getVApp(vappId); if (vApp == null) return null; vApp = powerOffVAppIfDeployed(vApp); @@ -80,7 +80,7 @@ public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy { void deleteVApp(URI vappId) { logger.debug(">> deleting vApp(%s)", vappId); - Task task = client.deleteVAppTemplateVAppOrMediaImage(vappId); + Task task = client.getVAppClient().deleteVApp(vappId); if (!successTester.apply(task.getHref())) { throw new RuntimeException(String.format("failed to %s %s: %s", "delete", vappId, task)); } @@ -90,12 +90,12 @@ public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy { VApp undeployVAppIfDeployed(VApp vApp) { if (vApp.getStatus().compareTo(Status.RESOLVED) > 0) { logger.debug(">> undeploying vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); - Task task = client.undeployVAppOrVm(vApp.getHref()); + Task task = client.getVAppClient().undeployVApp(vApp.getHref()); if (!successTester.apply(task.getHref())) { // TODO timeout throw new RuntimeException(String.format("failed to %s %s: %s", "undeploy", vApp.getName(), task)); } - vApp = client.getVApp(vApp.getHref()); + vApp = client.getVAppClient().getVApp(vApp.getHref()); logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); } return vApp; @@ -104,12 +104,12 @@ public class VCloudDestroyNodeStrategy implements DestroyNodeStrategy { VApp powerOffVAppIfDeployed(VApp vApp) { if (vApp.getStatus().compareTo(Status.OFF) > 0) { logger.debug(">> powering off vApp(%s), current status: %s", vApp.getName(), vApp.getStatus()); - Task task = client.powerOffVAppOrVm(vApp.getHref()); + Task task = client.getVAppClient().powerOffVApp(vApp.getHref()); if (!successTester.apply(task.getHref())) { // TODO timeout throw new RuntimeException(String.format("failed to %s %s: %s", "powerOff", vApp.getName(), task)); } - vApp = client.getVApp(vApp.getHref()); + vApp = client.getVAppClient().getVApp(vApp.getHref()); logger.debug("<< %s vApp(%s)", vApp.getStatus(), vApp.getName()); } return vApp; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java index 4f28d615e2..7b51cc36f2 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java @@ -49,7 +49,7 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy { public NodeMetadata getNode(String in) { URI id = URI.create(in); - VApp from = client.getVApp(id); + VApp from = client.getVAppClient().getVApp(id); if (from == null) return null; return vAppToNodeMetadata.apply(from); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudLifeCycleStrategy.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudLifeCycleStrategy.java index 43adb4fcea..0828100016 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudLifeCycleStrategy.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudLifeCycleStrategy.java @@ -57,7 +57,7 @@ public class VCloudLifeCycleStrategy implements RebootNodeStrategy, ResumeNodeSt @Override public NodeMetadata rebootNode(String in) { URI id = URI.create(checkNotNull(in, "node.id")); - Task task = client.resetVAppOrVm(id); + Task task = client.getVAppClient().resetVApp(id); return returnWhenTaskCompletes(in, task); } @@ -68,13 +68,13 @@ public class VCloudLifeCycleStrategy implements RebootNodeStrategy, ResumeNodeSt @Override public NodeMetadata resumeNode(String in) { - Task task = client.powerOnVAppOrVm(URI.create(checkNotNull(in, "node.id"))); + Task task = client.getVAppClient().powerOnVApp(URI.create(checkNotNull(in, "node.id"))); return returnWhenTaskCompletes(in, task); } @Override public NodeMetadata suspendNode(String in) { - Task task = client.powerOffVAppOrVm(URI.create(checkNotNull(in, "node.id"))); + Task task = client.getVAppClient().powerOffVApp(URI.create(checkNotNull(in, "node.id"))); return returnWhenTaskCompletes(in, task); } } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java index 92a0528e68..60789123aa 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/BaseVCloudRestClientModule.java @@ -21,8 +21,10 @@ package org.jclouds.vcloud.config; import static com.google.common.base.Throwables.propagate; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import java.util.Map; import java.util.concurrent.TimeUnit; +import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; @@ -35,6 +37,7 @@ import org.jclouds.vcloud.VCloudAsyncClient; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudLoginAsyncClient; import org.jclouds.vcloud.domain.CatalogItem; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems; @@ -59,12 +62,34 @@ public abstract class BaseVCloudRestClientModule syncClientType, Class
asyncClientType, + Map, Class> delegateMap) { + super(syncClientType, asyncClientType, delegateMap); + } + + @Singleton + public static class VCloudWritableCatalog extends WriteableCatalog { + private final VCloudClient client; + + @Inject + public VCloudWritableCatalog(VCloudClient client) { + super(client); + this.client = client; + } + + @Override + public boolean apply(ReferenceType arg0) { + return !client.getCatalogClient().getCatalog(arg0.getHref()).isReadOnly(); + } + } + @Override protected void configure() { bind(new TypeLiteral, Iterable>>() { }).to(new TypeLiteral() { }); bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); + bind(WriteableCatalog.class).to(VCloudWritableCatalog.class); super.configure(); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index f8a8b806a2..bb7249e3b9 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -18,10 +18,30 @@ */ package org.jclouds.vcloud.config; +import java.util.Map; + import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.vcloud.VCloudAsyncClient; import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.features.CatalogAsyncClient; +import org.jclouds.vcloud.features.CatalogClient; +import org.jclouds.vcloud.features.NetworkAsyncClient; +import org.jclouds.vcloud.features.NetworkClient; +import org.jclouds.vcloud.features.OrgAsyncClient; +import org.jclouds.vcloud.features.OrgClient; +import org.jclouds.vcloud.features.TaskAsyncClient; +import org.jclouds.vcloud.features.TaskClient; +import org.jclouds.vcloud.features.VAppAsyncClient; +import org.jclouds.vcloud.features.VAppClient; +import org.jclouds.vcloud.features.VAppTemplateAsyncClient; +import org.jclouds.vcloud.features.VAppTemplateClient; +import org.jclouds.vcloud.features.VDCAsyncClient; +import org.jclouds.vcloud.features.VDCClient; +import org.jclouds.vcloud.features.VmAsyncClient; +import org.jclouds.vcloud.features.VmClient; + +import com.google.common.collect.ImmutableMap; /** * Configures the VCloud authentication service connection, including logging and http transport. @@ -32,8 +52,19 @@ import org.jclouds.vcloud.VCloudClient; @ConfiguresRestClient public class VCloudRestClientModule extends BaseVCloudRestClientModule { + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// + .put(VAppTemplateClient.class, VAppTemplateAsyncClient.class)// + .put(VAppClient.class, VAppAsyncClient.class)// + .put(VmClient.class, VmAsyncClient.class)// + .put(CatalogClient.class, CatalogAsyncClient.class)// + .put(TaskClient.class, TaskAsyncClient.class)// + .put(VDCClient.class, VDCAsyncClient.class)// + .put(NetworkClient.class, NetworkAsyncClient.class)// + .put(OrgClient.class, OrgAsyncClient.class)// + .build(); + public VCloudRestClientModule() { - super(VCloudClient.class, VCloudAsyncClient.class); + super(VCloudClient.class, VCloudAsyncClient.class, DELEGATE_MAP); } } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogAsyncClient.java new file mode 100644 index 0000000000..dc9c84fa61 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogAsyncClient.java @@ -0,0 +1,124 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML; +import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.vcloud.binders.BindCatalogItemToXmlPayload; +import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.CatalogItem; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint; +import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; +import org.jclouds.vcloud.options.CatalogItemOptions; +import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.CatalogItemHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Catalog functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface CatalogAsyncClient { + + /** + * @see CatalogClient#getCatalog + */ + @GET + @XMLResponseParser(CatalogHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(CATALOG_XML) + ListenableFuture getCatalog(@EndpointParam URI catalogId); + + /** + * @see CatalogClient#findCatalogInOrgNamed + */ + @GET + @XMLResponseParser(CatalogHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(CATALOG_XML) + ListenableFuture findCatalogInOrgNamed( + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName); + + /** + * @see CatalogClient#getCatalogItem + */ + @GET + @Consumes(CATALOGITEM_XML) + @XMLResponseParser(CatalogItemHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCatalogItem(@EndpointParam URI catalogItem); + + /** + * @see CatalogClient#getCatalogItemInOrg + */ + @GET + @Consumes(CATALOGITEM_XML) + @XMLResponseParser(CatalogItemHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findCatalogItemInOrgCatalogNamed( + @Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName); + + /** + * @see CatalogClient#addVAppTemplateOrMediaImageToCatalog + */ + @POST + @Path("/catalogItems") + @Consumes(CATALOGITEM_XML) + @Produces(CATALOGITEM_XML) + @MapBinder(BindCatalogItemToXmlPayload.class) + @XMLResponseParser(CatalogItemHandler.class) + ListenableFuture addVAppTemplateOrMediaImageToCatalogAndNameItem(@PayloadParam("Entity") URI entity, + @EndpointParam URI catalog, @PayloadParam("name") String name, CatalogItemOptions... options); + + + /** + * @see CatalogClient#deleteCatalogItem + */ + @DELETE + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + ListenableFuture deleteCatalogItem(@EndpointParam URI href); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogClient.java new file mode 100644 index 0000000000..131f97aabb --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/CatalogClient.java @@ -0,0 +1,94 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.NoSuchElementException; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.CatalogItem; +import org.jclouds.vcloud.options.CatalogItemOptions; + +/** + * Provides access to Catalog functionality in vCloud + *

+ * + * @see + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface CatalogClient { + + Catalog getCatalog(URI catalogId); + + /** + * returns the catalog in the organization associated with the specified name. Note that both + * parameters can be null to choose default. + * + * @param orgName + * organization name, or null for the default + * @param catalogName + * catalog name, or null for the default + * @throws NoSuchElementException + * if you specified an org or catalog name that isn't present + */ + Catalog findCatalogInOrgNamed(@Nullable String orgName, @Nullable String catalogName); + + CatalogItem getCatalogItem(URI catalogItem); + + /** + * returns the 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 + * @param catalogName + * catalog name, or null for the default + * @param itemName + * item you wish to lookup + * + * @throws NoSuchElementException + * if you specified an org, catalog, or catalog item name that isn't present + */ + CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName); + + /** + * A catalog can contain references to vApp templates and media images that have been uploaded to + * any vDC in an organization. A vApp template or media image can be listed in at most one + * catalog. + * + * @param entity + * the reference to the vApp templates and media image + * @param catalog + * URI of the catalog to add the resourceEntity from + * @param name + * name of the entry in the catalog + * + * @param options + * options such as description or properties + * @return the new catalog item + */ + CatalogItem addVAppTemplateOrMediaImageToCatalogAndNameItem(URI entity, URI catalog, String name, CatalogItemOptions... options); + + void deleteCatalogItem(URI href); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkAsyncClient.java new file mode 100644 index 0000000000..a5628167c8 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkAsyncClient.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.domain.network.OrgNetwork; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; +import org.jclouds.vcloud.xml.OrgNetworkHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Network functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface NetworkAsyncClient { + + /** + * @see NetworkClient#findNetworkInOrgVDCNamed + */ + @GET + @Consumes(NETWORK_XML) + @XMLResponseParser(OrgNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findNetworkInOrgVDCNamed( + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, + @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); + + /** + * @see NetworkClient#getNetwork + */ + @GET + @Consumes(NETWORK_XML) + @XMLResponseParser(OrgNetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork(@EndpointParam URI network); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkClient.java new file mode 100644 index 0000000000..3c366a48f8 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/NetworkClient.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.network.OrgNetwork; + +/** + * Provides access to Network functionality in vCloud + *

+ * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface NetworkClient { + + OrgNetwork findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName); + + OrgNetwork getNetwork(URI network); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgAsyncClient.java new file mode 100644 index 0000000000..1aa50c19aa --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgAsyncClient.java @@ -0,0 +1,84 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.ORG_XML; + +import java.net.URI; +import java.util.Map; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.endpoints.OrgList; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameToEndpoint; +import org.jclouds.vcloud.xml.OrgHandler; +import org.jclouds.vcloud.xml.OrgListHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Org functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface OrgAsyncClient { + + /** + * + * @see OrgClient#listOrgs + */ + @GET + @Endpoint(OrgList.class) + @XMLResponseParser(OrgListHandler.class) + @Consumes(VCloudMediaType.ORGLIST_XML) + ListenableFuture> listOrgs(); + + /** + * @see OrgClient#getOrg + */ + @GET + @XMLResponseParser(OrgHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(ORG_XML) + ListenableFuture getOrg(@EndpointParam URI orgId); + + /** + * @see OrgClient#getOrgNamed + */ + @GET + @XMLResponseParser(OrgHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(ORG_XML) + ListenableFuture findOrgNamed( + @Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgClient.java new file mode 100644 index 0000000000..76e9356aef --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/OrgClient.java @@ -0,0 +1,62 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +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.Org; +import org.jclouds.vcloud.domain.ReferenceType; + +/** + * Provides access to Org functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface OrgClient { + + /** + * 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(); + + Org getOrg(URI orgId); + + /** + * This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within + * the organization. + * + * @param name + * organization name, or null for the default + * @throws NoSuchElementException + * if you specified an org name that isn't present + */ + Org findOrgNamed(@Nullable String name); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskAsyncClient.java new file mode 100644 index 0000000000..672d791c6b --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskAsyncClient.java @@ -0,0 +1,90 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.TASKSLIST_XML; +import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.TasksList; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.TasksListHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Task functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface TaskAsyncClient { + + /** + * @see TaskClient#getTasksList + */ + @GET + @Consumes(TASKSLIST_XML) + @XMLResponseParser(TasksListHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getTasksList(@EndpointParam URI tasksListId); + + /** + * @see TaskClient#findTasksListInOrgNamed + */ + @GET + @Consumes(TASKSLIST_XML) + @XMLResponseParser(TasksListHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findTasksListInOrgNamed( + @Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName); + + /** + * @see TaskClient#getTask + */ + @GET + @Consumes(TASK_XML) + @XMLResponseParser(TaskHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getTask(@EndpointParam URI taskId); + + /** + * @see TaskClient#cancelTask + */ + @POST + @Path("/action/cancel") + ListenableFuture cancelTask(@EndpointParam URI taskId); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskClient.java new file mode 100644 index 0000000000..668a691084 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/TaskClient.java @@ -0,0 +1,54 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.TasksList; + +/** + * Provides access to Task functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface TaskClient { + + TasksList getTasksList(URI tasksListId); + + TasksList findTasksListInOrgNamed(String orgName); + + /** + * Whenever the result of a request cannot be returned immediately, the server creates a Task + * object and includes it in the response, as a member of the Tasks container in the response + * body. Each Task has an href value, which is a URL that the client can use to retrieve the Task + * element alone, without the rest of the response in which it was contained. All information + * about the task is included in the Task element when it is returned in the response’s Tasks + * container, so a client does not need to make an additional request to the Task URL unless it + * wants to follow the progress of a task that was incomplete. + */ + Task getTask(URI taskId); + + void cancelTask(URI taskId); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppAsyncClient.java new file mode 100644 index 0000000000..ca3e6f8282 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppAsyncClient.java @@ -0,0 +1,221 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML; +import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; +import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML; +import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import org.jclouds.predicates.validators.DnsNameValidator; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.ParamValidators; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; +import org.jclouds.vcloud.options.CloneVAppOptions; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VAppHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to VApp functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface VAppAsyncClient { + + /** + * @see VAppClient#copyVAppToVDCAndName + */ + @POST + @Path("/action/cloneVApp") + @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") + @Consumes(TASK_XML) + @XMLResponseParser(TaskHandler.class) + @MapBinder(BindCloneVAppParamsToXmlPayload.class) + ListenableFuture copyVAppToVDCAndName(@PayloadParam("Source") URI sourceVApp, + @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppOptions... options); + + /** + * @see VAppClient#moveVAppToVDCAndRename + */ + @POST + @Path("/action/cloneVApp") + @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") + @Consumes(TASK_XML) + @XMLResponseParser(TaskHandler.class) + @PayloadParams(keys = "IsSourceDelete", values = "true") + @MapBinder(BindCloneVAppParamsToXmlPayload.class) + ListenableFuture moveVAppToVDCAndRename(@PayloadParam("Source") URI sourceVApp, + @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppOptions... options); + + /** + * @see VAppClient#findVAppInOrgVDCNamed + */ + @GET + @Consumes(VAPP_XML) + @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); + + /** + * @see VAppClient#getVApp + */ + @GET + @Consumes(VAPP_XML) + @XMLResponseParser(VAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVApp(@EndpointParam URI href); + + /** + * @see VAppClient#deployVApp + */ + @POST + @Consumes(TASK_XML) + @Produces(DEPLOYVAPPPARAMS_XML) + @Path("/action/deploy") + @MapBinder(BindDeployVAppParamsToXmlPayload.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture deployVApp(@EndpointParam URI href); + + /** + * @see VAppClient#deployAndPowerOnVApp + */ + @POST + @Consumes(TASK_XML) + @Produces(DEPLOYVAPPPARAMS_XML) + @Path("/action/deploy") + @MapBinder(BindDeployVAppParamsToXmlPayload.class) + @PayloadParams(keys = "powerOn", values = "true") + @XMLResponseParser(TaskHandler.class) + ListenableFuture deployAndPowerOnVApp(@EndpointParam URI href); + + /** + * @see VAppClient#undeployVApp + */ + @POST + @Consumes(TASK_XML) + @Produces(UNDEPLOYVAPPPARAMS_XML) + @Path("/action/undeploy") + @MapBinder(BindUndeployVAppParamsToXmlPayload.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture undeployVApp(@EndpointParam URI href); + + /** + * @see VAppClient#undeployAndSaveStateOfVApp + */ + @POST + @Consumes(TASK_XML) + @Produces(UNDEPLOYVAPPPARAMS_XML) + @Path("/action/undeploy") + @MapBinder(BindUndeployVAppParamsToXmlPayload.class) + @PayloadParams(keys = "saveState", values = "true") + @XMLResponseParser(TaskHandler.class) + ListenableFuture undeployAndSaveStateOfVApp(@EndpointParam URI href); + + /** + * @see VAppClient#powerOnVApp + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/powerOn") + @XMLResponseParser(TaskHandler.class) + ListenableFuture powerOnVApp(@EndpointParam URI href); + + /** + * @see VAppClient#powerOffVApp + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/powerOff") + @XMLResponseParser(TaskHandler.class) + ListenableFuture powerOffVApp(@EndpointParam URI href); + + /** + * @see VAppClient#shutdownVApp + */ + @POST + @Path("/power/action/shutdown") + ListenableFuture shutdownVApp(@EndpointParam URI href); + + /** + * @see VAppClient#resetVApp + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/reset") + @XMLResponseParser(TaskHandler.class) + ListenableFuture resetVApp(@EndpointParam URI href); + + /** + * @see VAppClient#rebootVApp + */ + @POST + @Path("/power/action/reboot") + ListenableFuture rebootVApp(@EndpointParam URI href); + + /** + * @see VAppClient#suspendVApp + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/suspend") + @XMLResponseParser(TaskHandler.class) + ListenableFuture suspendVApp(@EndpointParam URI href); + + /** + * @see VAppClient#deleteVApp + */ + @DELETE + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture deleteVApp(@EndpointParam URI href); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppClient.java new file mode 100644 index 0000000000..204110d15a --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppClient.java @@ -0,0 +1,159 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.options.CloneVAppOptions; + +/** + * Provides access to VApp functionality in vCloud + *

+ * + * @see + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface VAppClient { + VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName); + + Task copyVAppToVDCAndName(URI sourceVApp, URI vDC, String newName, CloneVAppOptions... options); + + Task moveVAppToVDCAndRename(URI sourceVApp, URI vDC, String newName, CloneVAppOptions... options); + + VApp getVApp(URI vApp); + + /** + * 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. + */ + Task deployVApp(URI href); + + /** + * like {@link #deployVApp(URI)}, except deploy transistions to power on state + * + */ + Task deployAndPowerOnVApp(URI href); + + /** + * 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. + *

NOTE

+ * Using this method will simply power off the vms. In order to save their state, use + * {@link #undeployAndSaveStateOf} + * + */ + Task undeployVApp(URI href); + + /** + * like {@link #undeployVApp(URI)}, where the undeployed virtual machines are suspended and their + * suspend state saved + * + */ + Task undeployAndSaveStateOfVApp(URI href); + + /** + * 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. + *

+ *

NOTE

A powerOn request to a vApp or virtual machine that is undeployed forces + * deployment. + */ + Task powerOnVApp(URI href); + + /** + * 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. + */ + Task powerOffVApp(URI href); + + /** + * 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. + *

+ *

NOTE + * A reset request to a virtual machine URL resets the specified virtual machine. + */ + Task resetVApp(URI href); + + /** + * 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. + *

+ *

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 rebootVApp(URI href); + + /** + * 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. + */ + Task suspendVApp(URI href); + + /** + * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any + * object that is being copied or moved is in use. Other criteria that determine whether an + * object is in use depend on the object type. + *

    + *
  • A vApptemplate is in use if it is being instantiated. After instantiation is complete, the + * template is no longer in use.
  • + *
  • A vApp is in use if it is deployed.
  • + *
  • A media image is in use if it is inserted in a Vm.
  • + *
+ * + * @param href + * href of the vApp + * @return task of the operation in progress + */ + Task deleteVApp(URI href); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateAsyncClient.java new file mode 100644 index 0000000000..1be3d017b2 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateAsyncClient.java @@ -0,0 +1,167 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; +import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML; +import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.ovf.Envelope; +import org.jclouds.ovf.xml.EnvelopeHandler; +import org.jclouds.predicates.validators.DnsNameValidator; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.ParamValidators; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindCloneVAppTemplateParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VAppTemplate; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; +import org.jclouds.vcloud.options.CaptureVAppOptions; +import org.jclouds.vcloud.options.CloneVAppTemplateOptions; +import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VAppTemplateHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to VAppTemplate functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface VAppTemplateAsyncClient { + + /** + * @see VAppTemplateClient#createVAppInVDCByInstantiatingTemplate + */ + @POST + @Path("/action/instantiateVAppTemplate") + @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") + @Consumes(VAPP_XML) + @XMLResponseParser(VAppHandler.class) + @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class) + ListenableFuture createVAppInVDCByInstantiatingTemplate( + @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc, + @PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options); + + /** + * @see VAppTemplateClient#getOvfEnvelopeForVAppTemplate + */ + @GET + @Consumes(MediaType.TEXT_XML) + @Path("/ovf") + @XMLResponseParser(EnvelopeHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOvfEnvelopeForVAppTemplate(@EndpointParam URI href); + + /** + * @see VAppTemplateClient#captureVAppAsTemplateInVDC + */ + @POST + @Path("/action/captureVApp") + @Produces("application/vnd.vmware.vcloud.captureVAppParams+xml") + @Consumes(VAPPTEMPLATE_XML) + @XMLResponseParser(VAppTemplateHandler.class) + @MapBinder(BindCaptureVAppParamsToXmlPayload.class) + ListenableFuture captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture, + @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName, + @EndpointParam URI vdc, CaptureVAppOptions... options); + + /** + * @see VAppTemplateClient#copyVAppTemplateToVDCAndName + */ + @POST + @Path("/action/cloneVAppTemplate") + @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml") + @Consumes(TASK_XML) + @XMLResponseParser(TaskHandler.class) + @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class) + ListenableFuture copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate, + @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppTemplateOptions... options); + + /** + * @see VAppTemplateClient#moveVAppTemplateToVDCAndRename + */ + @POST + @Path("/action/cloneVAppTemplate") + @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml") + @Consumes(TASK_XML) + @XMLResponseParser(TaskHandler.class) + @PayloadParams(keys = "IsSourceDelete", values = "true") + @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class) + ListenableFuture moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone, + @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName, + CloneVAppTemplateOptions... options); + + /** + * @see VAppTemplateClient#findVAppTemplateInOrgCatalogNamed + */ + @GET + @Consumes(VAPPTEMPLATE_XML) + @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); + + /** + * @see VAppTemplateClient#getVAppTemplate + */ + @GET + @Consumes(VAPPTEMPLATE_XML) + @XMLResponseParser(VAppTemplateHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVAppTemplate(@EndpointParam URI vAppTemplate); + + /** + * @see VAppTemplateClient#deleteVAppTemplate + */ + @DELETE + @ExceptionParser(ReturnVoidOnNotFoundOr404.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture deleteVAppTemplate(@EndpointParam URI href); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateClient.java new file mode 100644 index 0000000000..7d0222c45d --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VAppTemplateClient.java @@ -0,0 +1,105 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.NoSuchElementException; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.ovf.Envelope; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VAppTemplate; +import org.jclouds.vcloud.options.CaptureVAppOptions; +import org.jclouds.vcloud.options.CloneVAppTemplateOptions; +import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; + +/** + * Provides access to VApp Template functionality in vCloud + *

+ * + * @see + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface VAppTemplateClient { + /** + * 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 + * @param catalogName + * catalog name, or null for the default + * @param itemName + * item you wish to lookup + * + * @throws NoSuchElementException + * if you specified an org, catalog, or catalog item name that isn't present + */ + VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName); + + /** + */ + VApp createVAppInVDCByInstantiatingTemplate(String appName, URI vDC, URI template, + InstantiateVAppTemplateOptions... options); + + Task copyVAppTemplateToVDCAndName(URI sourceVAppTemplate, URI vDC, String newName, + CloneVAppTemplateOptions... options); + + Task moveVAppTemplateToVDCAndRename(URI sourceVAppTemplate, URI vDC, String newName, + CloneVAppTemplateOptions... options); + + /** + * The captureVApp request creates a vApp template from an instantiated vApp.

Note

+ * Before it can be captured, a vApp must be undeployed + * + * @param targetVdcHref + * @param sourceVAppHref + * @param newTemplateName + * @param options + * @return template in progress + */ + VAppTemplate captureVAppAsTemplateInVDC(URI sourceVAppHref, String newTemplateName, URI targetVdcHref, + CaptureVAppOptions... options); + + VAppTemplate getVAppTemplate(URI vApp); + + Envelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate); + + /** + * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any + * object that is being copied or moved is in use. Other criteria that determine whether an + * object is in use depend on the object type. + *
    + *
  • A vApptemplate is in use if it is being instantiated. After instantiation is complete, the + * template is no longer in use.
  • + *
  • A vApp is in use if it is deployed.
  • + *
  • A media image is in use if it is inserted in a Vm.
  • + *
+ * + * @param id + * href of the vApp + * @return task of the operation in progress + */ + Task deleteVAppTemplate(URI id); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCAsyncClient.java new file mode 100644 index 0000000000..2e5d552ef5 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCAsyncClient.java @@ -0,0 +1,69 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.VDC_XML; + +import java.net.URI; + +import javax.annotation.Nullable; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; +import org.jclouds.vcloud.xml.VDCHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to VDC functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface VDCAsyncClient { + + /** + * @see VDCClient#getVDC(URI) + */ + @GET + @XMLResponseParser(VDCHandler.class) + @Consumes(VDC_XML) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVDC(@EndpointParam URI vdc); + + /** + * @see VDCClient#findVDCInOrgNamed(String, String) + */ + @GET + @XMLResponseParser(VDCHandler.class) + @Consumes(VDC_XML) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture findVDCInOrgNamed( + @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java new file mode 100644 index 0000000000..3df0dfc7fc --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.net.URI; +import java.util.NoSuchElementException; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.VDC; + +/** + * Provides access to VDC functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface VDCClient { + VDC getVDC(URI vdc); + + /** + * returns the VDC in the organization associated with the specified name. Note that both + * parameters can be null to choose default. + * + * @param orgName + * organization name, or null for the default + * @param vdcName + * catalog name, or null for the default + * @throws NoSuchElementException + * if you specified an org or vdc name that isn't present + */ + VDC findVDCInOrgNamed(String orgName, String vdcName); + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java new file mode 100644 index 0000000000..d09b1699eb --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java @@ -0,0 +1,232 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML; +import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML; +import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML; +import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML; +import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; +import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML; +import static org.jclouds.vcloud.VCloudMediaType.VM_XML; + +import java.io.InputStream; +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.binders.BindCPUCountToXmlPayload; +import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload; +import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload; +import org.jclouds.vcloud.binders.BindMemoryToXmlPayload; +import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload; +import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload; +import org.jclouds.vcloud.domain.GuestCustomizationSection; +import org.jclouds.vcloud.domain.NetworkConnectionSection; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VmHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Vm functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +public interface VmAsyncClient { + + /** + * @see VmClient#getVm + */ + @GET + @Consumes(VM_XML) + @XMLResponseParser(VmHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVm(@EndpointParam URI href); + + /** + * @see VmClient#deployVm + */ + @POST + @Consumes(TASK_XML) + @Produces(DEPLOYVAPPPARAMS_XML) + @Path("/action/deploy") + @MapBinder(BindDeployVAppParamsToXmlPayload.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture deployVm(@EndpointParam URI href); + + /** + * @see VmClient#deployAndPowerOnVm + */ + @POST + @Consumes(TASK_XML) + @Produces(DEPLOYVAPPPARAMS_XML) + @Path("/action/deploy") + @MapBinder(BindDeployVAppParamsToXmlPayload.class) + @PayloadParams(keys = "powerOn", values = "true") + @XMLResponseParser(TaskHandler.class) + ListenableFuture deployAndPowerOnVm(@EndpointParam URI href); + + /** + * @see VmClient#undeployVm + */ + @POST + @Consumes(TASK_XML) + @Produces(UNDEPLOYVAPPPARAMS_XML) + @Path("/action/undeploy") + @MapBinder(BindUndeployVAppParamsToXmlPayload.class) + @XMLResponseParser(TaskHandler.class) + ListenableFuture undeployVm(@EndpointParam URI href); + + /** + * @see VmClient#undeployAndSaveStateOfVm + */ + @POST + @Consumes(TASK_XML) + @Produces(UNDEPLOYVAPPPARAMS_XML) + @Path("/action/undeploy") + @MapBinder(BindUndeployVAppParamsToXmlPayload.class) + @PayloadParams(keys = "saveState", values = "true") + @XMLResponseParser(TaskHandler.class) + ListenableFuture undeployAndSaveStateOfVm(@EndpointParam URI href); + + /** + * @see VmClient#powerOnVm + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/powerOn") + @XMLResponseParser(TaskHandler.class) + ListenableFuture powerOnVm(@EndpointParam URI href); + + /** + * @see VmClient#powerOffVm + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/powerOff") + @XMLResponseParser(TaskHandler.class) + ListenableFuture powerOffVm(@EndpointParam URI href); + + /** + * @see VmClient#shutdownVm + */ + @POST + @Path("/power/action/shutdown") + ListenableFuture shutdownVm(@EndpointParam URI href); + + /** + * @see VmClient#resetVm + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/reset") + @XMLResponseParser(TaskHandler.class) + ListenableFuture resetVm(@EndpointParam URI href); + + /** + * @see VmClient#rebootVm + */ + @POST + @Path("/power/action/reboot") + ListenableFuture rebootVm(@EndpointParam URI href); + + /** + * @see VmClient#suspendVm + */ + @POST + @Consumes(TASK_XML) + @Path("/power/action/suspend") + @XMLResponseParser(TaskHandler.class) + ListenableFuture suspendVm(@EndpointParam URI href); + + /** + * @see VmClient#updateCPUCountOfVm + */ + @PUT + @Consumes(TASK_XML) + @Produces(RASDITEM_XML) + @Path("/virtualHardwareSection/cpu") + @XMLResponseParser(TaskHandler.class) + ListenableFuture updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount, + @EndpointParam URI href); + + /** + * @see VmClient#updateMemoryMBOfVm + */ + @PUT + @Consumes(TASK_XML) + @Produces(RASDITEM_XML) + @Path("/virtualHardwareSection/memory") + @XMLResponseParser(TaskHandler.class) + ListenableFuture updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB, + @EndpointParam URI href); + + /** + * @see VmClient#updateGuestCustomizationOfVm + */ + @PUT + @Consumes(TASK_XML) + @Produces(GUESTCUSTOMIZATIONSECTION_XML) + @Path("/guestCustomizationSection") + @XMLResponseParser(TaskHandler.class) + ListenableFuture updateGuestCustomizationOfVm( + @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection, + @EndpointParam URI href); + + /** + * @see VmClient#updateNetworkConnectionOfVm + */ + @PUT + @Consumes(TASK_XML) + @Produces(NETWORKCONNECTIONSECTION_XML) + @Path("/networkConnectionSection") + @XMLResponseParser(TaskHandler.class) + ListenableFuture updateNetworkConnectionOfVm( + @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection, + @EndpointParam URI href); + + /** + * + * @see VmClient#getScreenThumbnailForVm + */ + @GET + @Path("/screen") + @Consumes("image/png") + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getScreenThumbnailForVm(@EndpointParam URI vm); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java new file mode 100644 index 0000000000..74adb5fd69 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java @@ -0,0 +1,186 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.InputStream; +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.domain.GuestCustomizationSection; +import org.jclouds.vcloud.domain.NetworkConnectionSection; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.Vm; + +/** + * Provides access to VM functionality in vCloud + *

+ * + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface VmClient { + + Vm getVm(URI vApp); + + /** + * 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. + */ + Task deployVm(URI href); + + /** + * like {@link #deploy(URI)}, except deploy transitions to power on state + * + */ + Task deployAndPowerOnVm(URI href); + + /** + * 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. + *

NOTE

+ * Using this method will simply power off the vms. In order to save their state, use + * {@link #undeployAndSaveStateOf} + * + */ + Task undeployVm(URI href); + + /** + * like {@link #undeploy(URI)}, where the undeployed virtual machines are suspended and their + * suspend state saved + * + */ + Task undeployAndSaveStateOfVm(URI href); + + /** + * 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. + *

+ *

NOTE

A powerOn request to a vApp or virtual machine that is undeployed forces + * deployment. + */ + Task powerOnVm(URI href); + + /** + * 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. + */ + Task powerOffVm(URI href); + + /** + * 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. + *

+ *

NOTE + * A reset request to a virtual machine URL resets the specified virtual machine. + */ + Task resetVm(URI href); + + /** + * 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. + *

+ *

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 rebootVm(URI href); + + /** + * 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. + */ + Task suspendVm(URI href); + + /** + * Get a Screen Thumbnail for a Virtual Machine + * + * @param href + * to snapshot + */ + InputStream getScreenThumbnailForVm(URI href); + + /** + * Modify the Guest Customization Section of a Virtual Machine + * + * @param href + * uri to modify + * @param updated + * guestCustomizationSection + * @return task in progress + */ + Task updateGuestCustomizationOfVm(GuestCustomizationSection guestCustomizationSection, URI href); + + /** + * Modify the Network Connection Section of a Virtual Machine + * + * @param href + * uri to modify + * @param updated + * networkConnectionSection + * @return task in progress + */ + Task updateNetworkConnectionOfVm(NetworkConnectionSection guestCustomizationSection, URI href); + + /** + * update the cpuCount of an existing VM + * + * @param href + * to update + * @param cpuCount + * count to change the primary cpu to + */ + Task updateCPUCountOfVm(int cpuCount, URI href); + + /** + * update the memoryInMB of an existing VM + * + * @param href + * to update + * @param memoryInMB + * memory in MB to assign to the VM + */ + Task updateMemoryMBOfVm(int memoryInMB, URI href); +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java index b78515a407..718fa03489 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java @@ -93,7 +93,7 @@ public class VAppTemplatesForCatalogItems implements @Override public Future apply(CatalogItem from) { return new ExceptionParsingListenableFuture(Futures.makeListenable( - (Future) VCloudAsyncClient.class.cast(aclient).getVAppTemplate( + (Future) VCloudAsyncClient.class.cast(aclient).getVAppTemplateClient().getVAppTemplate( from.getEntity().getHref()), executor), returnNullOnAuthorizationException); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java new file mode 100644 index 0000000000..157504576f --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java @@ -0,0 +1,79 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.options; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; + +/** + * + * @author Adrian Cole + * + */ +public class CatalogItemOptions { + + private String description; + private Map properties = Maps.newLinkedHashMap(); + + /** + * optional description for the CatalogItem + */ + public CatalogItemOptions description(String description) { + this.description = checkNotNull(description, "description"); + return this; + } + + /** + * optional properties for the CatalogItem + */ + public CatalogItemOptions properties(Map properties) { + this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties")); + return this; + } + + public String getDescription() { + return description; + } + + public Map getProperties() { + return properties; + } + + public static class Builder { + + /** + * @see CatalogItemOptions#description + */ + public static CatalogItemOptions description(String description) { + return new CatalogItemOptions().description(description); + } + + /** + * @see CatalogItemOptions#properties + */ + public static CatalogItemOptions properties(Map properties) { + return new CatalogItemOptions().properties(properties); + } + } + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java new file mode 100644 index 0000000000..7bbfc9d90b --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneOptions.java @@ -0,0 +1,55 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.options; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * @author Adrian Cole + * + */ +public class CloneOptions { + + private String description; + + /** + * the clone should be powered on after it is deployed + */ + public CloneOptions description(String description) { + checkNotNull(description, "description"); + this.description = description; + return this; + } + + public String getDescription() { + return description; + } + + public static class Builder { + + /** + * @see CloneOptions#description(String) + */ + public static CloneOptions description(String description) { + return new CloneOptions().description(description); + } + } + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java new file mode 100644 index 0000000000..07286762ae --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java @@ -0,0 +1,90 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.options; + +import static com.google.common.base.Preconditions.checkState; + +/** + * + * @author Adrian Cole + * + */ +public class CloneVAppOptions extends CloneOptions { + + private boolean deploy; + private boolean powerOn; + + /** + * the clone should be deployed after it is created + */ + public CloneVAppOptions deploy() { + this.deploy = true; + return this; + } + + /** + * the clone should be powered on after it is deployed + */ + public CloneVAppOptions powerOn() { + checkState(deploy, "must set deploy before setting powerOn"); + powerOn = true; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public CloneVAppOptions description(String description) { + return CloneVAppOptions.class.cast(super.description(description)); + } + + public boolean isDeploy() { + return deploy; + } + + public boolean isPowerOn() { + return powerOn; + } + + public static class Builder { + + /** + * @see CloneVAppOptions#deploy() + */ + public static CloneVAppOptions deploy() { + return new CloneVAppOptions().deploy(); + } + + /** + * @see CloneVAppOptions#powerOn() + */ + public static CloneVAppOptions powerOn() { + return new CloneVAppOptions().powerOn(); + } + + /** + * {@inheritDoc} + */ + public static CloneVAppOptions description(String description) { + return new CloneVAppOptions().description(description); + } + } + +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java new file mode 100644 index 0000000000..16b9ceaf4d --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.options; + +/** + * + * @author Adrian Cole + * + */ +public class CloneVAppTemplateOptions extends CloneOptions { + /** + * {@inheritDoc} + */ + @Override + public CloneVAppTemplateOptions description(String description) { + return CloneVAppTemplateOptions.class.cast(super.description(description)); + } + + public static class Builder { + /** + * {@inheritDoc} + */ + public static CloneVAppTemplateOptions description(String description) { + return new CloneVAppTemplateOptions().description(description); + } + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java new file mode 100644 index 0000000000..2de9d696d7 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudAsyncClientTest.java @@ -0,0 +1,301 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud; + +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Map; +import java.util.Properties; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.RequiresHttp; +import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.RestClientTest; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.rest.RestContextSpec; +import org.jclouds.vcloud.config.VCloudRestClientModule; +import org.jclouds.vcloud.domain.AllocationModel; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VCloudSession; +import org.jclouds.vcloud.domain.VDCStatus; +import org.jclouds.vcloud.domain.internal.CatalogImpl; +import org.jclouds.vcloud.domain.internal.CatalogItemImpl; +import org.jclouds.vcloud.domain.internal.OrgImpl; +import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.domain.internal.VDCImpl; +import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.testng.annotations.Test; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * Tests behavior of {@code VCloudAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "BaseVCloudAsyncClientTest") +public abstract class BaseVCloudAsyncClientTest extends RestClientTest { + + @Override + protected void checkFilters(HttpRequest request) { + assertEquals(request.getFilters().size(), 1); + assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class); + } + + @Override + protected Module createModule() { + return new VCloudRestClientModuleExtension(); + } + + @Override + public RestContextSpec createContextSpec() { + Properties overrides = new Properties(); + overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0"); + return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides); + } + + @RequiresHttp + @ConfiguresRestClient + public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { + @Override + protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, + @Named(PROPERTY_API_VERSION) String version) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"); + } + + @Override + protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/org"); + + } + + @Override + protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { + return "org"; + } + + @Override + protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user, WriteableCatalog writableCatalog) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog"); + + } + + @Override + protected Org provideOrg(CommonVCloudClient discovery) { + return null; + } + + @Override + protected URI provideDefaultTasksList(Org org) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist"); + } + + @Override + protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"); + } + + @Override + protected String provideDefaultVDCName( + @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { + return "vdc"; + } + + @Override + protected URI provideDefaultNetwork(URI vdc, Injector injector) { + return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"); + } + + @Override + protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + 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"))); + } + + @Override + public String getVCloudToken() { + return "token"; + } + + }); + + } + + @Override + protected void configure() { + super.configure(); + bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); + bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); + bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); + } + + protected Supplier>> provideOrgVDCSupplierCache( + @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { + + return Suppliers + .>> ofInstance(ImmutableMap + .> of( + "org", + + ImmutableMap + . of( + "vdc", + new VDCImpl( + "vdc", + null, + URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), + VDCStatus.READY, + null, + "description", + ImmutableSet. of(), + AllocationModel.ALLOCATION_POOL, + 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"))), + ImmutableMap. of(), 0, 0, 0, + false)))); + + } + + @Singleton + public static class TestOrgMapSupplier extends OrgMapSupplier { + @Inject + protected TestOrgMapSupplier() { + super(null, null); + } + + @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())); + } + } + + @Singleton + public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { + @Inject + protected TestOrgCatalogSupplier() { + super(null, null); + } + + @Override + public Map> get() { + 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", + "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, false))); + } + } + + @Singleton + public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { + protected TestOrgCatalogItemSupplier() { + super(null, null); + } + + @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())))); + + } + } + + @Override + protected Iterable provideOrgs(Supplier cache, String user) { + return null; + } + + } + +} diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/VCloudSessionRefreshLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudClientLiveTest.java similarity index 50% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/VCloudSessionRefreshLiveTest.java rename to apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudClientLiveTest.java index 10a6c4e21d..7250540b1a 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/VCloudSessionRefreshLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/BaseVCloudClientLiveTest.java @@ -16,59 +16,63 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.vcloud.bluelock; +package org.jclouds.vcloud; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import java.util.Properties; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; -import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.vcloud.VCloudClient; -import org.testng.annotations.AfterTest; +import org.jclouds.net.IPSocket; +import org.jclouds.predicates.InetSocketAddressConnect; +import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.ssh.SshClient.Factory; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.testng.annotations.AfterGroups; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; import com.google.inject.Module; /** - * Tests session refresh works * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) -public class VCloudSessionRefreshLiveTest { +@Test(groups = "live", enabled = true, singleThreaded = true) +public abstract class BaseVCloudClientLiveTest { + protected String prefix = System.getProperty("user.name"); - private final static int timeOut = 40; - protected VCloudClient connection; - protected ComputeServiceContext context; + protected ComputeService client; - @Test - public void testSessionRefresh() throws Exception { - connection.findOrgNamed(null); - Thread.sleep(timeOut * 1000); - connection.findOrgNamed(null); - } - - protected String provider = "bluelock-vcdirector"; + protected String provider = "vcloud"; protected String identity; protected String credential; protected String endpoint; protected String apiversion; + protected RetryablePredicate socketTester; + protected Factory sshFactory; + + protected VCloudClient getVCloudApi() { + return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); + } + + @BeforeClass protected void setupCredentials() { identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider - + ".credential"); - endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); - apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider - + ".apiversion"); + credential = System.getProperty("test." + provider + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint"); + apiversion = System.getProperty("test." + provider + ".apiversion"); } protected Properties setupProperties() { @@ -76,9 +80,12 @@ public class VCloudSessionRefreshLiveTest { overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.setProperty(provider + ".identity", identity); - overrides.setProperty(provider + ".credential", credential); - overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".apiversion", apiversion); + if (credential != null) + overrides.setProperty(provider + ".credential", credential); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); return overrides; } @@ -86,18 +93,22 @@ public class VCloudSessionRefreshLiveTest { public void setupClient() { setupCredentials(); Properties overrides = setupProperties(); - - overrides.setProperty(PROPERTY_SESSION_INTERVAL, 40 + ""); - - context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet - . of(new Log4JLoggingModule()), overrides); - - connection = VCloudClient.class.cast(context.getProviderSpecificContext().getApi()); + client = new ComputeServiceContextFactory().createContext(provider, + ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService(); + socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); + sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class); } - @AfterTest + protected Properties setupRestProperties() { + return RestContextFactory.getPropertiesFromResource("/rest.properties"); + } + + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } + + @AfterGroups(groups = { "live" }) protected void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - context.close(); + client.getContext().close(); } - -} +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java deleted file mode 100644 index 48506f262e..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/CaptureVAppLiveTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.vcloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.getOnlyElement; - -import java.net.URI; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.jclouds.Constants; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.predicates.TaskSuccess; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", enabled = true, sequential = true) -public class CaptureVAppLiveTest { - - - protected ComputeService client; - protected String group = System.getProperty("user.name") + "cap"; - - protected String provider = "vcloud"; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiversion; - - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider - + ".credential"); - endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); - apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider - + ".apiversion"); - } - - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(provider + ".identity", identity); - overrides.setProperty(provider + ".credential", credential); - overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".apiversion", apiversion); - return overrides; - } - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - client = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService(); - } - - @Test - public void testCaptureVApp() throws Exception { - - NodeMetadata node = null; - VAppTemplate vappTemplate = null; - try { - - node = getOnlyElement(client.createNodesInGroup(group, 1)); - - VCloudClient vcloudApi = VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); - - Predicate taskTester = new RetryablePredicate(new TaskSuccess(vcloudApi), 600, 5, TimeUnit.SECONDS); - - // I have to powerOff first - Task task = vcloudApi.powerOffVAppOrVm(URI.create(node.getId())); - - // wait up to ten minutes per above - assert taskTester.apply(task.getHref()) : node; - - // having a problem where the api is returning an error telling us to stop! - - // // I have to undeploy first - // task = vcloudApi.undeployVAppOrVm(URI.create(node.getId())); - // - // // wait up to ten minutes per above - // assert taskTester.apply(task.getHref()) : node; - - // vdc is equiv to the node's location - // vapp uri is the same as the node's id - vappTemplate = vcloudApi.captureVAppInVDC(URI.create(node.getLocation().getId()), URI.create(node.getId()), - group); - - task = vappTemplate.getTasks().get(0); - - // wait up to ten minutes per above - assert taskTester.apply(task.getHref()) : vappTemplate; - - // TODO implement delete vAppTemplate - } finally { - if (node != null) - client.destroyNode(node.getId()); - } - } - -} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java similarity index 97% rename from apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java rename to apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java index a6736ff1b4..7dfa80af75 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/DeprecatedVCloudClientLiveTest.java @@ -32,12 +32,13 @@ import org.jclouds.vcloud.domain.Vm; import org.testng.annotations.Test; /** - * Tests behavior of {@code VCloudClient} + * Tests behavior of deprecated {@code VCloudClient} features * * @author Adrian Cole */ +@Deprecated @Test(groups = "live", singleThreaded = true) -public class VCloudClientLiveTest extends CommonVCloudClientLiveTest { +public class DeprecatedVCloudClientLiveTest extends CommonVCloudClientLiveTest { @Test public void testListOrgs() throws Exception { diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java index 5ec7223a5e..e88de13ae4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java @@ -18,54 +18,27 @@ */ package org.jclouds.vcloud; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; -import static org.testng.Assert.assertEquals; import java.io.IOException; import java.lang.reflect.Method; import java.net.URI; -import java.util.Map; import java.util.NoSuchElementException; -import java.util.Properties; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; +import java.util.concurrent.ExecutionException; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnInputStream; import org.jclouds.ovf.xml.EnvelopeHandler; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.RestClientTest; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; -import org.jclouds.vcloud.config.VCloudRestClientModule; -import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.jclouds.vcloud.domain.internal.OrgImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.VDCImpl; import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.options.CaptureVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -80,15 +53,9 @@ import org.jclouds.vcloud.xml.VAppHandler; import org.jclouds.vcloud.xml.VAppTemplateHandler; import org.jclouds.vcloud.xml.VDCHandler; import org.jclouds.vcloud.xml.VmHandler; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Injector; -import com.google.inject.Module; import com.google.inject.TypeLiteral; /** @@ -99,12 +66,43 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "VCloudAsyncClientTest") -public class VCloudAsyncClientTest extends RestClientTest { +public class VCloudAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + private VCloudAsyncClient asyncClient; + private VCloudClient syncClient; + + public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assert syncClient.getVAppClient() != null; + assert syncClient.getCatalogClient() != null; + assert syncClient.getVmClient() != null; + assert syncClient.getVAppTemplateClient() != null; + assert syncClient.getTaskClient() != null; + assert syncClient.getVDCClient() != null; + assert syncClient.getNetworkClient() != null; + assert syncClient.getOrgClient() != null; + } + + public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assert asyncClient.getVAppClient() != null; + assert asyncClient.getCatalogClient() != null; + assert asyncClient.getVmClient() != null; + assert asyncClient.getVAppTemplateClient() != null; + assert asyncClient.getTaskClient() != null; + assert asyncClient.getVDCClient() != null; + assert asyncClient.getNetworkClient() != null; + assert asyncClient.getOrgClient() != null; + } public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("getThumbnailOfVm", URI.class); HttpRequest request = processor - .createRequest(method, URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")); + .createRequest(method, URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")); assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: image/png\n"); @@ -119,55 +117,18 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("updateGuestCustomizationOfVm", URI.class, - GuestCustomizationSection.class); - GuestCustomizationSection guest = new GuestCustomizationSection( - URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); + GuestCustomizationSection.class); + GuestCustomizationSection guest = new GuestCustomizationSection(URI + .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); guest.setCustomizationScript("cat > /tmp/foo.txt< { } public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.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))); + 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))); 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, - Strings2.toStringAndClose(getClass().getResourceAsStream("/instantiationparams-network.xml")), - "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( + "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", + false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, VAppHandler.class); @@ -204,30 +163,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", - 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", + addNetworkConfig(new NetworkConfig(null, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))); } + @Deprecated public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.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"); + 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"); 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, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")), + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -236,19 +193,20 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + @Deprecated public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.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")); + 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().description("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, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")), + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, TaskHandler.class); @@ -259,17 +217,17 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCaptureVAppInVDC() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class, - CaptureVAppOptions[].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-template"); + CaptureVAppOptions[].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-template"); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); - assertPayloadEquals(request, - Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")), - "application/vnd.vmware.vcloud.captureVAppParams+xml", false); + assertPayloadEquals(request, Strings2 + .toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")), + "application/vnd.vmware.vcloud.captureVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); @@ -280,17 +238,17 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testCaptureVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("captureVAppInVDC", URI.class, URI.class, String.class, - CaptureVAppOptions[].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"), "my-template", - new CaptureVAppOptions().withDescription("The description of the new vApp Template")); + CaptureVAppOptions[].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"), "my-template", new CaptureVAppOptions() + .withDescription("The description of the new vApp Template")); assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp.xml")), - "application/vnd.vmware.vcloud.captureVAppParams+xml", false); + "application/vnd.vmware.vcloud.captureVAppParams+xml", false); assertResponseParserClassEquals(method, request, ParseSax.class); assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); @@ -316,8 +274,8 @@ public class VCloudAsyncClientTest extends RestClientTest { 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -347,8 +305,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -378,8 +336,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -394,7 +352,7 @@ public class VCloudAsyncClientTest extends RestClientTest { public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class, - String.class); + String.class); HttpRequest request = processor.createRequest(method, "org", "vdc", "network"); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2 HTTP/1.1"); @@ -410,8 +368,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -426,7 +384,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"); @@ -442,7 +400,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"); @@ -458,8 +416,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -474,8 +432,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -547,8 +505,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -563,8 +521,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -594,13 +552,13 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -611,13 +569,13 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -628,8 +586,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -644,8 +602,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -660,11 +618,11 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -677,14 +635,14 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -694,17 +652,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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -715,24 +673,8 @@ 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")); - - assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testDeleteVAppTemplateVAppOrMediaImage() throws SecurityException, NoSuchMethodException, IOException { - Method method = VCloudAsyncClient.class.getMethod("deleteVAppTemplateVAppOrMediaImage", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")); + HttpRequest request = processor.createRequest(method, URI + .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, ""); @@ -747,11 +689,11 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -762,57 +704,13 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } - public void testAddResourceEntitytoCatalogProperties() throws SecurityException, NoSuchMethodException, IOException { - Method method = VCloudAsyncClient.class.getMethod("addResourceEntitytoCatalog", URI.class, String.class, - String.class, URI.class, Map.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", "mydescription", - URI.create("http://fooentity"), ImmutableMap.of("foo", "bar")); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); - assertPayloadEquals( - request, - "mydescriptionbar", - "application/vnd.vmware.vcloud.catalogItem+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testAddResourceEntitytoCatalog() throws SecurityException, NoSuchMethodException, IOException { - Method method = VCloudAsyncClient.class.getMethod("addResourceEntitytoCatalog", URI.class, String.class, - String.class, URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", "mydescription", - URI.create("http://fooentity")); - - assertRequestLineEquals(request, - "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1"); - assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); - assertPayloadEquals( - request, - "mydescription", - "application/vnd.vmware.vcloud.catalogItem+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -825,11 +723,11 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -842,11 +740,11 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -859,11 +757,11 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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); @@ -876,8 +774,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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"); @@ -892,8 +790,8 @@ 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")); + HttpRequest request = processor.createRequest(method, URI + .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, ""); @@ -906,211 +804,12 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + @BeforeClass @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class); - } - - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } - - @Override - protected Module createModule() { - return new VCloudRestClientModuleExtension(); - } - - @Override - public RestContextSpec createContextSpec() { - Properties overrides = new Properties(); - overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0"); - return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides); - } - - @RequiresHttp - @ConfiguresRestClient - public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { - @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"); - } - - @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/org"); - - } - - @Override - protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return "org"; - } - - @Override - protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog"); - - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"); - } - - @Override - protected String provideDefaultVDCName( - @org.jclouds.vcloud.endpoints.VDC Supplier> vDCtoOrgSupplier) { - return "vdc"; - } - - @Override - protected URI provideDefaultNetwork(URI vdc, Injector injector) { - return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"); - } - - @Override - protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - 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"))); - } - - @Override - public String getVCloudToken() { - return "token"; - } - - }); - - } - - @Override - protected void configure() { - super.configure(); - bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); - bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); - bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - } - - protected Supplier>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) { - - return Suppliers.>> ofInstance(ImmutableMap - .> of("org", - - ImmutableMap. of( - "vdc", - new VDCImpl("vdc", null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), - VDCStatus.READY, null, "description", ImmutableSet. of(), - AllocationModel.ALLOCATION_POOL, 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"))), ImmutableMap - . of(), 0, 0, 0, false)))); - - } - - @Singleton - public static class TestOrgMapSupplier extends OrgMapSupplier { - @Inject - protected TestOrgMapSupplier() { - super(null, null); - } - - @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())); - } - } - - @Singleton - public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { - @Inject - protected TestOrgCatalogSupplier() { - super(null, null); - } - - @Override - public Map> get() { - 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", "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))); - } - } - - @Singleton - public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { - protected TestOrgCatalogItemSupplier() { - super(null, null); - } - - @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())))); - - } - } - - @Override - protected Iterable provideOrgs(Supplier cache, String user) { - return null; - } - + protected void setupFactory() throws IOException { + super.setupFactory(); + asyncClient = injector.getInstance(VCloudAsyncClient.class); + syncClient = injector.getInstance(VCloudClient.class); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java deleted file mode 100644 index fa0f2f2d2f..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudGuestCustomizationLiveTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * - * Copyright (C) 2011 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ -package org.jclouds.vcloud; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.get; -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.crypto.CryptoStreams.base64; -import static org.testng.Assert.assertEquals; - -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.jclouds.Constants; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.net.IPSocket; -import org.jclouds.predicates.InetSocketAddressConnect; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; -import org.jclouds.ssh.jsch.config.JschSshClientModule; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeGroups; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Module; - -/** - * This tests that we can use guest customization as an alternative to - * bootstrapping with ssh. There are a few advantages to this, including the - * fact that it can work inside google appengine where network sockets (ssh:22) - * are prohibited. - * - * @author Adrian Cole - */ -@Test(groups = "live", enabled = true, sequential = true) -public class VCloudGuestCustomizationLiveTest { - - public static final String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'"; - - protected ComputeServiceContext context; - protected ComputeService client; - protected RetryablePredicate socketTester; - protected Factory sshFactory; - - protected String provider = "vcloud"; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiversion; - - protected NodeMetadata node; - - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = System.getProperty("test." + provider + ".credential"); - endpoint = System.getProperty("test." + provider + ".endpoint"); - apiversion = System.getProperty("test." + provider + ".apiversion"); - } - - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(provider + ".identity", identity); - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (apiversion != null) - overrides.setProperty(provider + ".apiversion", apiversion); - return overrides; - } - - @BeforeGroups(groups = { "live" }) - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - client = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides).getComputeService(); - socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); - sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class); - } - - protected Properties setupRestProperties() { - return RestContextFactory.getPropertiesFromResource("/rest.properties"); - } - - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); - } - - // make sure the script has a lot of screwy characters, knowing our parser - // throws-out \r - private String iLoveAscii = "I '\"love\"' {asc|!}*&"; - - String script = "cat > /root/foo.txt< + * + * ==================================================================== + * 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; + +import org.testng.annotations.Test; + +/** + * Tests session refresh works + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true) +public class VCloudSessionRefreshLiveTest extends BaseVCloudClientLiveTest { + + private final static int timeOut = 40; + + @Test + public void testSessionRefresh() throws Exception { + VCloudClient connection = VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); + + connection.getOrgClient().findOrgNamed(null); + Thread.sleep(timeOut * 1000); + connection.getOrgClient().findOrgNamed(null); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java index ad788d5e34..45675ad1b4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java @@ -31,6 +31,7 @@ import java.util.Properties; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.VCloudPropertiesBuilder; +import org.jclouds.vcloud.options.CatalogItemOptions; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -61,14 +62,15 @@ public class BindCatalogItemToXmlPayloadTest { GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); - expect(request.getArgs()).andReturn(ImmutableList. of(ImmutableMap.of("foo", "bar"))).anyTimes(); + expect(request.getArgs()).andReturn( + ImmutableList. of(CatalogItemOptions.Builder.description("mydescription").properties( + ImmutableMap.of("foo", "bar")))).anyTimes(); request.setPayload(expected); replay(request); BindCatalogItemToXmlPayload binder = injector.getInstance(BindCatalogItemToXmlPayload.class); - Map map = ImmutableMap.of("name", "myname", "description", "mydescription", "entity", - "http://fooentity"); + Map map = ImmutableMap.of("name", "myname", "Entity", "http://fooentity"); binder.bindToRequest(request, map); verify(request); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java new file mode 100644 index 0000000000..48579971ef --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -0,0 +1,120 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.binders; + +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.easymock.classextension.EasyMock.verify; + +import java.io.IOException; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.PropertiesBuilder; +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.options.CloneVAppOptions; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.name.Names; + +/** + * Tests behavior of {@code BindCloneVAppParamsToXmlPayload} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class BindCloneVAppParamsToXmlPayloadTest { + Injector injector = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + Properties props = new Properties(); + props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); + props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); + Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + } + }); + + public void testWithDescriptionDeployOn() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")); + + CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description( + "The description of the new vApp"); + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of(options)).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "new-linux-server"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); + binder.bindToRequest(request, map.build()); + verify(request); + } + + public void testWithDescriptionDeployOnSourceDelete() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")); + + CloneVAppOptions options = new CloneVAppOptions().deploy().powerOn().description( + "The description of the new vApp"); + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of(options)).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "new-linux-server"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); + map.put("IsSourceDelete", "true"); + binder.bindToRequest(request, map.build()); + verify(request); + } + + public void testDefault() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")); + + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of()).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppParamsToXmlPayload binder = injector.getInstance(BindCloneVAppParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "my-vapp"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"); + binder.bindToRequest(request, map.build()); + verify(request); + } +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java new file mode 100644 index 0000000000..c7fd9cd7f9 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java @@ -0,0 +1,123 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.binders; + +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.easymock.classextension.EasyMock.verify; + +import java.io.IOException; +import java.net.URI; +import java.util.Properties; + +import org.jclouds.PropertiesBuilder; +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.options.CloneVAppTemplateOptions; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.name.Names; + +/** + * Tests behavior of {@code BindCloneVAppTemplateParamsToXmlPayload} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class BindCloneVAppTemplateParamsToXmlPayloadTest { + Injector injector = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + Properties props = new Properties(); + props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); + props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); + Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + } + }); + + public void testWithDescription() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")); + + CloneVAppTemplateOptions options = new CloneVAppTemplateOptions() + .description("The description of the new vAppTemplate"); + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of(options)).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppTemplateParamsToXmlPayload binder = injector + .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "new-linux-server"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); + binder.bindToRequest(request, map.build()); + verify(request); + } + + public void testWithDescriptionSourceDelete() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")); + + CloneVAppTemplateOptions options = new CloneVAppTemplateOptions() + .description("The description of the new vAppTemplate"); + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of(options)).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppTemplateParamsToXmlPayload binder = injector + .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "new-linux-server"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"); + map.put("IsSourceDelete", "true"); + binder.bindToRequest(request, map.build()); + verify(request); + } + + public void testDefault() throws IOException { + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate-default.xml")); + + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of()).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindCloneVAppTemplateParamsToXmlPayload binder = injector + .getInstance(BindCloneVAppTemplateParamsToXmlPayload.class); + + Builder map = ImmutableMap. builder(); + map.put("name", "my-vapptemplate"); + map.put("Source", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"); + binder.bindToRequest(request, map.build()); + verify(request); + } +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index 92848144dc..2439d1e8b0 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -42,6 +42,7 @@ import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; import org.jclouds.vcloud.endpoints.Network; +import org.jclouds.vcloud.features.VAppTemplateClient; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.testng.annotations.Test; @@ -63,9 +64,12 @@ import com.google.inject.name.Names; public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { Injector createInjector(URI vAppTemplate, VAppTemplate value) { final VCloudClient client = createMock(VCloudClient.class); + final VAppTemplateClient tclient = createMock(VAppTemplateClient.class); - expect(client.getVAppTemplate(vAppTemplate)).andReturn(value).anyTimes(); + expect(client.getVAppTemplateClient()).andReturn(tclient).anyTimes(); + expect(tclient.getVAppTemplate(vAppTemplate)).andReturn(value).anyTimes(); replay(client); + replay(tclient); return Guice.createInjector(new AbstractModule() { diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java index 4a932eefe7..2dbdebca5c 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java @@ -56,8 +56,7 @@ public class BindNetworkConnectionSectionToXmlPayloadTest { public void testWithIpAllocationModeNONE() throws IOException { - @SuppressWarnings("rawtypes") - HttpRequest request = new HttpRequest.Builder().endpoint(URI.create("http://localhost/key")).method("GET") + HttpRequest request = HttpRequest.builder().endpoint(URI.create("http://localhost/key")).method("GET") .build(); BindNetworkConnectionSectionToXmlPayload binder = injector diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index 71552e67dc..f7b66011c4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -69,7 +69,7 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { RestContext tmContext = new ComputeServiceContextFactory( setupRestProperties()).createContext(provider, identity, credential, ImmutableSet. of(), setupProperties()).getProviderSpecificContext(); - VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); + VApp vApp = tmContext.getApi().getVAppClient().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java index 7eb68c094c..d433e7f3af 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java @@ -43,6 +43,7 @@ import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.vcloud.VCloudPropertiesBuilder; import org.jclouds.vcloud.compute.config.CommonVCloudComputeServiceContextModule; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.xml.VAppHandler; @@ -76,6 +77,9 @@ public class VAppToNodeMetadataTest { protected void configure() { Properties props = new Properties(); Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties")); + bind(new TypeLiteral>() { + }).to(new TypeLiteral() { + }); bind(new TypeLiteral>() { }).to(new TypeLiteral() { }); @@ -108,8 +112,8 @@ public class VAppToNodeMetadataTest { } public void testWhenVDCIsLocation() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description").scope( - LocationScope.PROVIDER).build(); + Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") + .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); @@ -122,8 +126,8 @@ public class VAppToNodeMetadataTest { } public void testGracefulWhenNoIPs() { - Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description").scope( - LocationScope.PROVIDER).build(); + Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description") + .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-none.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); @@ -138,7 +142,7 @@ public class VAppToNodeMetadataTest { @Test(expectedExceptions = NoSuchElementException.class) public void testGracefulWhenVDCIsNotLocation() { Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/11111").description("description") - .scope(LocationScope.PROVIDER).build(); + .scope(LocationScope.PROVIDER).build(); Injector injector = createInjectorWithLocation(location); InputStream is = getClass().getResourceAsStream("/vapp-pool.xml"); Factory factory = injector.getInstance(ParseSax.Factory.class); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java new file mode 100644 index 0000000000..33de6247a7 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java @@ -0,0 +1,139 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.options.CatalogItemOptions; +import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.CatalogItemHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code CatalogAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "CatalogAsyncClientTest") +public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { + Method method = CatalogAsyncClient.class.getMethod("getCatalog", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class); + HttpRequest request = processor.createRequest(method, "org", "catalog"); + + 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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { + Method method = CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException { + Method method = CatalogAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", 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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testAddVAppTemplateOrMediaImageToCatalogAndNameItem() throws SecurityException, NoSuchMethodException, + IOException { + Method method = CatalogAsyncClient.class.getMethod("addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class, + URI.class, String.class, CatalogItemOptions[].class); + HttpRequest request = processor.createRequest(method, URI.create("http://fooentity"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder + .description("mydescription")); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); + assertPayloadEquals( + request, + "mydescription", + "application/vnd.vmware.vcloud.catalogItem+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java new file mode 100644 index 0000000000..b63af13266 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CatalogClientLiveTest") +public class CatalogClientLiveTest extends BaseVCloudClientLiveTest { + @Test + public void testGetCatalog() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType catalog : org.getCatalogs().values()) { + assertEquals(catalog.getType(), VCloudMediaType.CATALOG_XML); + assertNotNull(getVCloudApi().getCatalogClient().getCatalog(catalog.getHref())); + } + } + + @Test + public void testFindCatalogIsWriteable() throws Exception { + assertEquals(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly(), false); + } +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java new file mode 100644 index 0000000000..568091afd9 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.xml.OrgNetworkHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code NetworkAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "NetworkAsyncClientTest") +public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = NetworkAsyncClient.class.getMethod("getNetwork", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { + Method method = NetworkAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class, + String.class); + HttpRequest request = processor.createRequest(method, "org", "vdc", "network"); + + assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkClientLiveTest.java new file mode 100644 index 0000000000..3781b4ddd0 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkClientLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "NetworkClientLiveTest") +public class NetworkClientLiveTest extends BaseVCloudClientLiveTest { + + +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java new file mode 100644 index 0000000000..3d1f55aeed --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java @@ -0,0 +1,99 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.xml.OrgHandler; +import org.jclouds.vcloud.xml.OrgListHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code OrgAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "OrgAsyncClientTest") +public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException { + Method method = OrgAsyncClient.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 = OrgAsyncClient.class.getMethod("getOrg", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException { + Method method = OrgAsyncClient.class.getMethod("findOrgNamed", String.class); + HttpRequest request = processor.createRequest(method, "org"); + + 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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgClientLiveTest.java new file mode 100644 index 0000000000..9bcc670542 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgClientLiveTest.java @@ -0,0 +1,44 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.jclouds.vcloud.domain.ReferenceType; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "OrgClientLiveTest") +public class OrgClientLiveTest extends BaseVCloudClientLiveTest { + + @Test + public void testListOrgs() throws Exception { + for (ReferenceType response : getVCloudApi().getOrgClient().listOrgs().values()) { + assertNotNull(response); + assertNotNull(response.getName()); + assertNotNull(response.getHref()); + assertEquals(getVCloudApi().getOrgClient().getOrg(response.getHref()).getName(), response.getName()); + assertEquals(getVCloudApi().getOrgClient().findOrgNamed(response.getName()).getName(), response.getName()); + } + } +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java new file mode 100644 index 0000000000..07fc94042c --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.TasksListHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code TaskAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "TaskAsyncClientTest") +public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncClient.class.getMethod("getTasksList", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TasksListHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class); + HttpRequest request = processor.createRequest(method, "org"); + + 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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TasksListHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncClient.class.getMethod("getTask", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException { + Method method = TaskAsyncClient.class.getMethod("cancelTask", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskClientLiveTest.java new file mode 100644 index 0000000000..2377ff9484 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskClientLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "TaskClientLiveTest") +public class TaskClientLiveTest extends BaseVCloudClientLiveTest { + + +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java new file mode 100644 index 0000000000..462c407756 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java @@ -0,0 +1,323 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.options.CloneVAppOptions; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VAppHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code VAppAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "VAppAsyncClientTest") +public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, + CloneVAppOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp"); + + assertRequestLineEquals(request, + "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, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")), + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, + CloneVAppOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() + .deploy().powerOn().description("The description of the new vApp")); + + assertRequestLineEquals(request, + "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, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")), + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("moveVAppToVDCAndRename", URI.class, URI.class, String.class, + CloneVAppOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() + .deploy().powerOn().description("The description of the new vApp")); + + assertRequestLineEquals(request, + "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, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")), + "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("deployVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("getVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("rebootVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("undeployVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, "", + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, + "", + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("deleteVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("powerOnVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("powerOffVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("resetVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("suspendVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppAsyncClient.class.getMethod("shutdownVApp", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppClientLiveTest.java new file mode 100644 index 0000000000..f5aca341f3 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppClientLiveTest.java @@ -0,0 +1,55 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.testng.Assert.assertNotNull; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VDC; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppClientLiveTest") +public class VAppClientLiveTest extends BaseVCloudClientLiveTest { + + @Test + public void testGetVApp() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = getVCloudApi().getVDCClient().getVDC(vdc.getHref()); + for (ReferenceType item : response.getResourceEntities().values()) { + if (item.getType().equals(VCloudMediaType.VAPP_XML)) { + try { + VApp app = getVCloudApi().getVAppClient().getVApp(item.getHref()); + assertNotNull(app); + } catch (RuntimeException e) { + + } + } + } + } + } +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java new file mode 100644 index 0000000000..100c8d7040 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java @@ -0,0 +1,247 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.ovf.xml.EnvelopeHandler; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.domain.network.FenceMode; +import org.jclouds.vcloud.domain.network.NetworkConfig; +import org.jclouds.vcloud.options.CaptureVAppOptions; +import org.jclouds.vcloud.options.CloneVAppTemplateOptions; +import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.VAppTemplateHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code VAppTemplateAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "VAppTemplateAsyncClientTest") +public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException, + IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class, + URI.class, URI.class, InstantiateVAppTemplateOptions[].class); + HttpRequest request = processor.createRequest(method, "my-vapp", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), + 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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( + "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", + false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateVAppInVDCByInstantiatingTemplateOptionsIllegalName() throws SecurityException, + NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class, + URI.class, URI.class, InstantiateVAppTemplateOptions[].class); + processor.createRequest(method, "CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null, + URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))); + } + + public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate"); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( + "/copyVAppTemplate-default.xml")), "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", + new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")), + "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("moveVAppTemplateToVDCAndRename", URI.class, URI.class, + String.class, CloneVAppTemplateOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", + new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")), + "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, + URI.class, CaptureVAppOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); + assertPayloadEquals(request, Strings2 + .toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")), + "application/vnd.vmware.vcloud.captureVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, + URI.class, CaptureVAppOptions[].class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions() + .withDescription("The description of the new vApp Template")); + + assertRequestLineEquals(request, + "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); + assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp.xml")), + "application/vnd.vmware.vcloud.captureVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", 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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, EnvelopeHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateClientLiveTest.java new file mode 100644 index 0000000000..8ba9754b1b --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateClientLiveTest.java @@ -0,0 +1,175 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.CatalogItem; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.VAppTemplate; +import org.jclouds.vcloud.options.CatalogItemOptions; +import org.jclouds.vcloud.predicates.TaskSuccess; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppTemplateClientLiveTest") +public class VAppTemplateClientLiveTest extends BaseVCloudClientLiveTest { + + @Test + public void testGetVAppTemplate() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = getVCloudApi().getCatalogClient().getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = getVCloudApi().getCatalogClient().getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + try { + assertNotNull(getVCloudApi().getVAppTemplateClient().getVAppTemplate(item.getEntity().getHref())); + } catch (AuthorizationException e) { + + } + } + } + } + } + } + + @Test + public void testGetOvfEnvelopeForVAppTemplate() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = getVCloudApi().getCatalogClient().getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + try { + CatalogItem item = getVCloudApi().getCatalogClient().getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + assertNotNull(getVCloudApi().getVAppTemplateClient().getOvfEnvelopeForVAppTemplate( + item.getEntity().getHref())); + } + } catch (AuthorizationException e) { + + } + } + } + } + } + + @Test + public void testFindVAppTemplate() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType cat : org.getCatalogs().values()) { + Catalog response = getVCloudApi().getCatalogClient().getCatalog(cat.getHref()); + for (ReferenceType resource : response.values()) { + if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) { + CatalogItem item = getVCloudApi().getCatalogClient().getCatalogItem(resource.getHref()); + if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) { + try { + assertNotNull(getVCloudApi().getVAppTemplateClient().findVAppTemplateInOrgCatalogNamed( + org.getName(), response.getName(), item.getEntity().getName())); + } catch (AuthorizationException e) { + + } + } + } + } + } + } + + @Test + public void testCaptureVApp() throws Exception { + String group = prefix + "cap"; + NodeMetadata node = null; + VAppTemplate vappTemplate = null; + CatalogItem item = null; + try { + + node = getOnlyElement(client.createNodesInGroup(group, 1)); + + Predicate taskTester = new RetryablePredicate(new TaskSuccess(getVCloudApi()), 600, 5, + TimeUnit.SECONDS); + + // I have to powerOff first + Task task = getVCloudApi().getVAppClient().powerOffVApp(URI.create(node.getId())); + + // wait up to ten minutes per above + assert taskTester.apply(task.getHref()) : node; + + // having a problem where the api is returning an error telling us to stop! + + // I have to undeploy first + task = getVCloudApi().getVAppClient().undeployVApp(URI.create(node.getId())); + + // wait up to ten minutes per above + assert taskTester.apply(task.getHref()) : node; + + // vdc is equiv to the node's location + // vapp uri is the same as the node's id + vappTemplate = getVCloudApi().getVAppTemplateClient().captureVAppAsTemplateInVDC(URI.create(node.getId()), + group, URI.create(node.getLocation().getId())); + + assertEquals(vappTemplate.getName(), group); + + task = vappTemplate.getTasks().get(0); + + // wait up to ten minutes per above + assert taskTester.apply(task.getHref()) : vappTemplate; + + item = getVCloudApi().getCatalogClient().addVAppTemplateOrMediaImageToCatalogAndNameItem( + vappTemplate.getHref(), + getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).getHref(), "fooname", + CatalogItemOptions.Builder.description("description").properties(ImmutableMap.of("foo", "bar"))); + + assertEquals(item.getName(), "fooname"); + assertEquals(item.getDescription(), "description"); + assertEquals(item.getProperties(), ImmutableMap.of("foo", "bar")); + assertEquals(item.getEntity().getName(), vappTemplate.getName()); + assertEquals(item.getEntity().getHref(), vappTemplate.getHref()); + assertEquals(item.getEntity().getType(), vappTemplate.getType()); + + } finally { + if (item != null) + getVCloudApi().getCatalogClient().deleteCatalogItem(item.getHref()); + if (vappTemplate != null) + getVCloudApi().getVAppTemplateClient().deleteVAppTemplate(vappTemplate.getHref()); + if (node != null) + client.destroyNode(node.getId()); + } + } +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java new file mode 100644 index 0000000000..525064695f --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java @@ -0,0 +1,109 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; +import java.util.NoSuchElementException; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.xml.VDCHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code VDCAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "VDCAsyncClientTest") +public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + @Test(expectedExceptions = NoSuchElementException.class) + public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); + processor.createRequest(method, "org", "vdc1"); + } + + @Test(expectedExceptions = NoSuchElementException.class) + public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); + processor.createRequest(method, "org1", "vdc"); + } + + public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); + HttpRequest request = processor.createRequest(method, null, "vdc"); + + 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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VDCHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); + HttpRequest request = processor.createRequest(method, null, null); + + 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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VDCHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = VDCAsyncClient.class.getMethod("getVDC", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VDCHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCClientLiveTest.java new file mode 100644 index 0000000000..08ce12379f --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCClientLiveTest.java @@ -0,0 +1,31 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VDCClientLiveTest") +public class VDCClientLiveTest extends BaseVCloudClientLiveTest { + + +} \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java new file mode 100644 index 0000000000..e84a1b4ca4 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java @@ -0,0 +1,319 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.http.functions.ReturnInputStream; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.util.Strings2; +import org.jclouds.vcloud.BaseVCloudAsyncClientTest; +import org.jclouds.vcloud.domain.GuestCustomizationSection; +import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VmHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code VmAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "VmAsyncClientTest") +public class VmAsyncClientTest extends BaseVCloudAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class); + HttpRequest request = processor + .createRequest(method, URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")); + + assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: image/png\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReturnInputStream.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("updateGuestCustomizationOfVm", GuestCustomizationSection.class, + URI.class); + GuestCustomizationSection guest = new GuestCustomizationSection(URI + .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); + guest.setCustomizationScript("cat > /tmp/foo.txt<", + "application/vnd.vmware.vcloud.deployVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testGetVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("getVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VmHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("rebootVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("undeployVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, "", + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, + "", + "application/vnd.vmware.vcloud.undeployVAppParams+xml", false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("powerOnVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("powerOffVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testResetVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("resetVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("suspendVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + + public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException { + Method method = VmAsyncClient.class.getMethod("shutdownVm", URI.class); + HttpRequest request = processor.createRequest(method, URI + .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"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(request); + } + +} diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java new file mode 100644 index 0000000000..9153afab70 --- /dev/null +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java @@ -0,0 +1,173 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.features; + +import static com.google.common.collect.Iterables.get; +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.jclouds.crypto.CryptoStreams.base64; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.compute.domain.ExecResponse; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.net.IPSocket; +import org.jclouds.ssh.SshClient; +import org.jclouds.vcloud.BaseVCloudClientLiveTest; +import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; +import org.jclouds.vcloud.domain.Org; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.VDC; +import org.jclouds.vcloud.domain.Vm; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; + +/** + * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There + * are a few advantages to this, including the fact that it can work inside google appengine where + * network sockets (ssh:22) are prohibited. + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VmClientLiveTest") +public class VmClientLiveTest extends BaseVCloudClientLiveTest { + + @Test + public void testGetThumbnailOfVm() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = getVCloudApi().getVDCClient().getVDC(vdc.getHref()); + for (ReferenceType item : response.getResourceEntities().values()) { + if (item.getType().equals(VCloudMediaType.VAPP_XML)) { + try { + VApp app = getVCloudApi().getVAppClient().getVApp(item.getHref()); + assertNotNull(app); + for (Vm vm : app.getChildren()) { + assert getVCloudApi().getVmClient().getScreenThumbnailForVm(vm.getHref()) != null; + } + } catch (RuntimeException e) { + + } + } + } + } + } + + @Test + public void testGetVm() throws Exception { + Org org = getVCloudApi().getOrgClient().findOrgNamed(null); + for (ReferenceType vdc : org.getVDCs().values()) { + VDC response = getVCloudApi().getVDCClient().getVDC(vdc.getHref()); + for (ReferenceType item : response.getResourceEntities().values()) { + if (item.getType().equals(VCloudMediaType.VAPP_XML)) { + try { + VApp app = getVCloudApi().getVAppClient().getVApp(item.getHref()); + assertNotNull(app); + for (Vm vm : app.getChildren()) { + assertEquals(getVCloudApi().getVmClient().getVm(vm.getHref()).getHref(), vm.getHref()); + } + } catch (RuntimeException e) { + + } + } + } + } + } + + @Test + public void testExtendedOptionsWithCustomizationScript() throws Exception { + String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'"; + + String group = prefix + "customize"; + + NodeMetadata node = null; + try { + + TemplateOptions options = client.templateOptions(); + options.as(VCloudTemplateOptions.class).customizationScript(script); + options.as(VCloudTemplateOptions.class).description(group); + node = getOnlyElement(client.createNodesInGroup(group, 1, options)); + + VApp vapp = ((VCloudClient) client.getContext().getProviderSpecificContext().getApi()).getVAppClient() + .getVApp(node.getUri()); + assertEquals(vapp.getDescription(), group); + + Vm vm = Iterables.get(vapp.getChildren(), 0); + String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript(); + checkApiOutput(apiOutput); + + IPSocket socket = getSocket(node); + + System.out.printf("%s:%s@%s", node.getCredentials().identity, node.getCredentials().credential, socket); + assert socketTester.apply(socket) : socket; + + SshClient ssh = sshFactory.create(socket, node.getCredentials()); + try { + ssh.connect(); + ExecResponse vmTools = ssh.exec(PARSE_VMTOOLSD); + System.out.println(vmTools); + String fooTxt = ssh.exec("cat /root/foo.txt").getOutput(); + String decodedVmToolsOutput = new String(base64(vmTools.getOutput().trim())); + checkVmOutput(fooTxt, decodedVmToolsOutput); + } finally { + if (ssh != null) + ssh.disconnect(); + } + } finally { + if (node != null) + client.destroyNode(node.getId()); + } + } + + protected void checkApiOutput(String apiOutput) { + checkApiOutput1_0_1(apiOutput); + } + + // make sure the script has a lot of screwy characters, knowing our parser + // throws-out \r + String iLoveAscii = "I '\"love\"' {asc|!}*&"; + + String script = "cat > /root/foo.txt< \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVApp.xml b/apis/vcloud/src/test/resources/copyVApp.xml new file mode 100644 index 0000000000..11dfaaeeaf --- /dev/null +++ b/apis/vcloud/src/test/resources/copyVApp.xml @@ -0,0 +1 @@ +The description of the new vApp \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml b/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml new file mode 100644 index 0000000000..00b11e7746 --- /dev/null +++ b/apis/vcloud/src/test/resources/copyVAppTemplate-default.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/copyVAppTemplate.xml b/apis/vcloud/src/test/resources/copyVAppTemplate.xml new file mode 100644 index 0000000000..e612b98b62 --- /dev/null +++ b/apis/vcloud/src/test/resources/copyVAppTemplate.xml @@ -0,0 +1 @@ +The description of the new vAppTemplate \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/moveVApp.xml b/apis/vcloud/src/test/resources/moveVApp.xml new file mode 100644 index 0000000000..cba62d94aa --- /dev/null +++ b/apis/vcloud/src/test/resources/moveVApp.xml @@ -0,0 +1 @@ +The description of the new vApptrue \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/moveVAppTemplate.xml b/apis/vcloud/src/test/resources/moveVAppTemplate.xml new file mode 100644 index 0000000000..2f72f2bf7f --- /dev/null +++ b/apis/vcloud/src/test/resources/moveVAppTemplate.xml @@ -0,0 +1 @@ +The description of the new vAppTemplatetrue \ No newline at end of file diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java index f93d55db27..68048ec141 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressAsyncClient.java @@ -18,6 +18,7 @@ */ package org.jclouds.vcloud; +import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML; import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML; import static org.jclouds.vcloud.VCloudMediaType.TASK_XML; import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML; @@ -45,11 +46,13 @@ import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; +import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.network.OrgNetwork; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; +import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader; @@ -57,6 +60,7 @@ import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; import org.jclouds.vcloud.xml.TaskHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; @@ -72,6 +76,27 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(SetVCloudTokenCookie.class) public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient { + /** + * @see CommonVCloudClient#getCatalog + */ + @Override + @GET + @XMLResponseParser(VCloudExpressCatalogHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(CATALOG_XML) + ListenableFuture getCatalog(@EndpointParam URI catalogId); + + /** + * @see CommonVCloudClient#findCatalogInOrgNamed + */ + @GET + @XMLResponseParser(VCloudExpressCatalogHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Consumes(CATALOG_XML) + ListenableFuture findCatalogInOrgNamed( + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName, + @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName); + /** * @see VCloudClient#getVAppTemplate */ diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressLoginAsyncClient.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/VCloudExpressLoginAsyncClient.java old mode 100755 new mode 100644 diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java similarity index 100% rename from common/vcloud/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java rename to apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/config/VCloudExpressComputeServiceContextModule.java old mode 100755 new mode 100644 diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVCloudExpressVApp.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVCloudExpressVApp.java index 57323af379..c6e02c5922 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVCloudExpressVApp.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVCloudExpressVApp.java @@ -29,7 +29,9 @@ import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.predicates.ImagePredicates; +import org.jclouds.domain.Location; import org.jclouds.logging.Logger; +import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VCloudExpressVApp; import com.google.common.base.Function; @@ -42,12 +44,12 @@ public class HardwareForVCloudExpressVApp implements Function findLocationForResource; private final HardwareBuilderFromResourceAllocations rasdToHardwareBuilder; @Inject - protected HardwareForVCloudExpressVApp(FindLocationForResource findLocationForResource, - HardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { + protected HardwareForVCloudExpressVApp(Function findLocationForResource, + HardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); } @@ -58,8 +60,8 @@ public class HardwareForVCloudExpressVApp implements Function + * + * ==================================================================== + * 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.xml; + +import static org.jclouds.vcloud.util.Utils.newReferenceType; +import static org.jclouds.vcloud.util.Utils.putReferenceType; + +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.jclouds.vcloud.VCloudMediaType; +import org.jclouds.vcloud.domain.Catalog; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.Task; +import org.jclouds.vcloud.domain.internal.CatalogImpl; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +/** + * @author Adrian Cole + */ +public class VCloudExpressCatalogHandler extends ParseSax.HandlerWithResult { + + protected final TaskHandler taskHandler; + + @Inject + public VCloudExpressCatalogHandler(TaskHandler taskHandler) { + this.taskHandler = taskHandler; + } + + private StringBuilder currentText = new StringBuilder(); + + private ReferenceType catalog; + private Map contents = Maps.newLinkedHashMap(); + protected List tasks = Lists.newArrayList(); + private String description; + private ReferenceType org; + + private boolean published = true; + + public Catalog getResult() { + return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getHref(), org, description, contents, + tasks, published, false); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = SaxUtils.cleanseAttributes(attrs); + if (qName.equals("Catalog")) { + catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML); + } else if (qName.equals("CatalogItem")) { + putReferenceType(contents, attributes); + } else if (qName.equals("Link") && "up".equals(attributes.get("rel"))) { + org = newReferenceType(attributes); + } else { + taskHandler.startElement(uri, localName, qName, attrs); + } + } + + public void endElement(String uri, String name, String qName) { + taskHandler.endElement(uri, name, qName); + if (qName.equals("Task")) { + this.tasks.add(taskHandler.getResult()); + } else if (qName.equals("Description")) { + description = currentOrNull(); + } else if (qName.equals("IsPublished")) { + published = Boolean.parseBoolean(currentOrNull()); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + + protected String currentOrNull() { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } +} diff --git a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java index 3dae72731f..cbdcff315a 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/VCloudExpressAsyncClientTest.java @@ -62,7 +62,7 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.CatalogItemHandler; import org.jclouds.vcloud.xml.OrgHandler; import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; @@ -238,7 +238,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest of(), true))); + . of(), true, false))); } } diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java similarity index 95% rename from common/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java rename to apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java index 814e13e064..f90e4fc40a 100644 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -53,7 +53,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { @Override protected void configure() { Properties props = new Properties(); - props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); + props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v0.8"); props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); Names.bindProperties(binder(), new PropertiesBuilder(props).build()); } @@ -74,7 +74,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { Map map = Maps.newHashMap(); map.put("newName", "new-linux-server"); - map.put("vApp", "https://vcenterprise.bluelock.com/api/v1.0/vapp/201"); + map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/201"); binder.bindToRequest(request, map); verify(request); } @@ -92,7 +92,7 @@ public class BindCloneVAppParamsToXmlPayloadTest { Map map = Maps.newHashMap(); map.put("newName", "my-vapp"); - map.put("vApp", "https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"); + map.put("vApp", "https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"); binder.bindToRequest(request, map); verify(request); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/InputStreamMap.java b/blobstore/src/main/java/org/jclouds/blobstore/InputStreamMap.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/ListableMap.java b/blobstore/src/main/java/org/jclouds/blobstore/ListableMap.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobName.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/BlobName.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/ParseSystemAndUserMetadataFromHeaders.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/functions/ThrowContainerNotFoundOn404.java b/blobstore/src/main/java/org/jclouds/blobstore/functions/ThrowContainerNotFoundOn404.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobMap.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobMapImpl.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/InputStreamMapImpl.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java b/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java old mode 100755 new mode 100644 diff --git a/blobstore/src/main/java/org/jclouds/blobstore/reference/package-info.java b/blobstore/src/main/java/org/jclouds/blobstore/reference/package-info.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobFromHeadersAndHttpContentTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/ParseBlobFromHeadersAndHttpContentTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientBlobIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java old mode 100755 new mode 100644 diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/filters/FormSigner.java b/common/aws/src/main/java/org/jclouds/aws/filters/FormSigner.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/AWSClientErrorRetryHandler.java b/common/aws/src/main/java/org/jclouds/aws/handlers/AWSClientErrorRetryHandler.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/AWSRedirectionRetryHandler.java b/common/aws/src/main/java/org/jclouds/aws/handlers/AWSRedirectionRetryHandler.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/common/aws/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/handlers/package-info.java b/common/aws/src/main/java/org/jclouds/aws/handlers/package-info.java old mode 100755 new mode 100644 diff --git a/common/aws/src/main/java/org/jclouds/aws/reference/AWSConstants.java b/common/aws/src/main/java/org/jclouds/aws/reference/AWSConstants.java old mode 100755 new mode 100644 diff --git a/common/aws/src/test/java/org/jclouds/aws/xml/ErrorHandlerTest.java b/common/aws/src/test/java/org/jclouds/aws/xml/ErrorHandlerTest.java old mode 100755 new mode 100644 diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java old mode 100755 new mode 100644 diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java old mode 100755 new mode 100644 diff --git a/common/azure/src/test/resources/log4j.xml b/common/azure/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java b/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java old mode 100755 new mode 100644 diff --git a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java old mode 100755 new mode 100644 diff --git a/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java b/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java old mode 100755 new mode 100644 diff --git a/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java b/common/openstack/src/main/java/org/jclouds/openstack/functions/ParseAuthenticationResponseFromHeaders.java old mode 100755 new mode 100644 diff --git a/common/openstack/src/main/java/org/jclouds/openstack/reference/package-info.java b/common/openstack/src/main/java/org/jclouds/openstack/reference/package-info.java old mode 100755 new mode 100644 diff --git a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java old mode 100755 new mode 100644 diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java index b2be54b6bf..a199e49700 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudAsyncClient.java @@ -92,7 +92,7 @@ import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkCatalogItemHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; -import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import com.google.common.util.concurrent.ListenableFuture; @@ -152,7 +152,7 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient { */ @GET @Override - @XMLResponseParser(CatalogHandler.class) + @XMLResponseParser(VCloudExpressCatalogHandler.class) @Consumes(CATALOG_XML) @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getCatalog(@EndpointParam URI catalogId); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java index d1e4a31aad..f470e39171 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java @@ -137,12 +137,13 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function of(), null, null, null, ImmutableSet.of( + ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( + ResourceType.PROCESSOR).virtualQuantity(2l).build(),// + ResourceAllocationSettingData.builder().instanceID("2").elementName("foo").resourceType( + ResourceType.MEMORY).virtualQuantity(1024l).build(), // + ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("0") + .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE) + .virtualQuantity(209152l).build(),// + ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("1") + .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE) + .virtualQuantity(209152l).build()// + ) + + ); + + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")) + .replace("eduardo", "MyAppServer6"); + + VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1); + + GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); + expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); + expect(request.getArgs()).andReturn(ImmutableList. of(vApp, config)).atLeastOnce(); + request.setPayload(expected); + replay(request); + + BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class); + + Map map = Maps.newHashMap(); + binder.bindToRequest(request, map); + verify(request); + } + + public void testChangeAll() throws IOException { VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, ImmutableListMultimap. of(), null, null, null, ImmutableSet.of( @@ -106,10 +143,10 @@ public class BindVAppConfigurationToXmlPayloadTest { "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType( ResourceType.DISK_DRIVE).virtualQuantity(209152l).build())); - String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")) - .replace("eduardo", "MyAppServer6"); + String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVAppAll.xml")); - VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1); + VAppConfiguration config = changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1).addDisk( + 25 * 1048576).addDisk(25 * 1048576); GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class); expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes(); diff --git a/common/trmk/src/test/resources/log4j.xml b/common/trmk/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/common/trmk/src/test/resources/terremark/configureVAppAll.xml b/common/trmk/src/test/resources/terremark/configureVAppAll.xml new file mode 100644 index 0000000000..de299fe39a --- /dev/null +++ b/common/trmk/src/test/resources/terremark/configureVAppAll.xml @@ -0,0 +1 @@ +
Virtual Hardware13124153601048576917209152-191726214400-191726214400
\ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java index fb48dbb370..b10616c45a 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java @@ -31,13 +31,14 @@ import org.jclouds.domain.Location; import org.jclouds.logging.Logger; import org.jclouds.vcloud.domain.ReferenceType; +import com.google.common.base.Function; import com.google.common.base.Supplier; /** * @author Adrian Cole */ @Singleton -public class FindLocationForResource { +public class FindLocationForResource implements Function { @Resource protected Logger logger = Logger.NULL; @@ -64,7 +65,7 @@ public class FindLocationForResource { return input; } while ((input = input.getParent()) != null); } - throw new NoSuchElementException(String.format("resource: %s not found in locations: %s", resource, locations - .get())); + throw new NoSuchElementException(String.format("resource: %s not found in locations: %s", resource, + locations.get())); } } \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java b/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java index bc2eec1719..984e7e6486 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/config/CommonVCloudRestClientModule.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.config; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.concat; +import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.get; import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.transform; @@ -35,6 +36,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEO import java.net.URI; import java.util.Map; +import java.util.NoSuchElementException; import java.util.SortedMap; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; @@ -64,6 +66,7 @@ import org.jclouds.vcloud.CommonVCloudAsyncClient; import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.VCloudToken; import org.jclouds.vcloud.VCloudVersionsAsyncClient; +import org.jclouds.vcloud.compute.functions.FindLocationForResource; import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.Org; @@ -74,6 +77,7 @@ 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.AllCatalogItemsInOrg; import org.jclouds.vcloud.functions.AllCatalogsInOrg; import org.jclouds.vcloud.functions.AllVDCsInOrg; import org.jclouds.vcloud.functions.OrgsForLocations; @@ -92,7 +96,6 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; - /** * Configures the VCloud authentication service connection, including logging and http transport. * @@ -107,10 +110,18 @@ public class CommonVCloudRestClientModule syncClientType, Class asyncClientType, + Map, Class> delegateMap) { + super(syncClientType, asyncClientType, delegateMap); + } + @Override protected void configure() { requestInjection(this); super.configure(); + bind(new TypeLiteral>() { + }).to(new TypeLiteral() { + }); bind(new TypeLiteral>>() { }).to(new TypeLiteral() { }); @@ -126,6 +137,9 @@ public class CommonVCloudRestClientModule>>() { }).to(new TypeLiteral() { }); + bind(new TypeLiteral>>() { + }).to(new TypeLiteral() { + }); } @Singleton @@ -145,8 +159,8 @@ public class CommonVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, final Supplier> orgToVDCSupplier) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, seconds, - new Supplier>() { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, + seconds, new Supplier>() { @Override public Map get() { Map returnVal = newLinkedHashMap(); @@ -183,17 +197,22 @@ public class CommonVCloudRestClientModule 0, "No catalogs present in org: " + org.getName()); - return get(org.getCatalogs().values(), 0).getHref(); + try { + return find(org.getCatalogs().values(), writableCatalog).getHref(); + } catch (NoSuchElementException e) { + throw new NoSuchElementException(String.format("no writable catalogs in org %s; catalogs %s", org, org + .getCatalogs())); + } } @Provides @Singleton protected Supplier> provideOrgMapCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgMapSupplier supplier) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( + authException, seconds, new Supplier>() { @Override public Map get() { return supplier.get(); @@ -211,6 +230,21 @@ public class CommonVCloudRestClientModule { + private final CommonVCloudClient client; + + @Inject + public WriteableCatalog(CommonVCloudClient client) { + this.client = client; + } + + @Override + public boolean apply(ReferenceType arg0) { + return !client.getCatalog(arg0.getHref()).isReadOnly(); + } + } + @Singleton public static class OrgMapSupplier implements Supplier> { protected final Supplier sessionSupplier; @@ -286,8 +320,8 @@ public class CommonVCloudRestClientModule> provideVDCtoORG(@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgNameToOrgSupplier supplier) { - return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>(authException, - seconds, new Supplier>() { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier>( + authException, seconds, new Supplier>() { @Override public Map get() { return supplier.get(); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java index fda15f762a..22bc61532d 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/Catalog.java @@ -54,9 +54,14 @@ public interface Catalog extends ReferenceType, Map { * * @since vcloud api 1.0 */ - @Nullable boolean isPublished(); + /** + * @return true, if the current user cannot modify the catalog + * @since vcloud api 1.0 + */ + boolean isReadOnly(); + /** * read‐only container for Task elements. Each element in the container represents a queued, * running, or failed task owned by this object. diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java index c1a2159b86..c1bb6fcbe5 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java @@ -52,9 +52,10 @@ public class CatalogImpl extends LinkedHashMap implements private final String description; private final List tasks = Lists.newArrayList(); private final boolean published; + private final boolean readOnly; public CatalogImpl(String name, String type, URI href, ReferenceType org, @Nullable String description, - Map contents, Iterable tasks, boolean published) { + Map contents, Iterable tasks, boolean published, boolean readOnly) { this.name = checkNotNull(name, "name"); this.type = checkNotNull(type, "type"); this.org = org;// TODO: once <1.0 is killed check not null @@ -63,6 +64,7 @@ public class CatalogImpl extends LinkedHashMap implements putAll(checkNotNull(contents, "contents")); Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks")); this.published = published; + this.readOnly = readOnly; } /** @@ -120,6 +122,14 @@ public class CatalogImpl extends LinkedHashMap implements return published; } + /** + * {@inheritDoc} + */ + @Override + public boolean isReadOnly() { + return readOnly; + } + @Override public int hashCode() { final int prime = 31; diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/common/vcloud/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java old mode 100755 new mode 100644 diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java b/common/vcloud/src/main/java/org/jclouds/vcloud/reference/package-info.java old mode 100755 new mode 100644 diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java index f34e21b8c6..c2e9118706 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java @@ -60,10 +60,11 @@ public class CatalogHandler extends ParseSax.HandlerWithResult { private ReferenceType org; private boolean published = true; + private boolean readOnly = true; public Catalog getResult() { return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getHref(), org, description, contents, - tasks, published); + tasks, published, readOnly); } @Override @@ -75,6 +76,8 @@ public class CatalogHandler extends ParseSax.HandlerWithResult { putReferenceType(contents, attributes); } else if (qName.equals("Link") && "up".equals(attributes.get("rel"))) { org = newReferenceType(attributes); + } else if (qName.equals("Link") && "add".equals(attributes.get("rel"))) { + readOnly = false; } else { taskHandler.startElement(uri, localName, qName, attrs); } diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java old mode 100755 new mode 100644 diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/VCloudLoginAsyncClientTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/VCloudLoginAsyncClientTest.java old mode 100755 new mode 100644 diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java index 2f3aee4417..c4756aa163 100644 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java +++ b/common/vcloud/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java @@ -60,7 +60,7 @@ public class CatalogHandlerTest { .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081"), new ReferenceTypeImpl(null, "application/vnd.vmware.vcloud.org+xml", URI .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")), null, ImmutableMap - . of(), ImmutableList. of(), false)); + . of(), ImmutableList. of(), false, false)); } public void testTerremark() { diff --git a/common/vcloud/src/test/resources/cloneVApp-default.xml b/common/vcloud/src/test/resources/cloneVApp-default.xml deleted file mode 100644 index 5449ebd2c2..0000000000 --- a/common/vcloud/src/test/resources/cloneVApp-default.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/common/vcloud/src/test/resources/cloneVApp.xml b/common/vcloud/src/test/resources/cloneVApp.xml deleted file mode 100644 index 5448617110..0000000000 --- a/common/vcloud/src/test/resources/cloneVApp.xml +++ /dev/null @@ -1 +0,0 @@ -The description of the new vApp \ No newline at end of file diff --git a/common/vcloud/src/test/resources/log4j.xml b/common/vcloud/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java old mode 100755 new mode 100644 diff --git a/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java b/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java index 78c319e67f..89a4721560 100644 --- a/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/BaseComputeServiceContextModule.java @@ -160,7 +160,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule { @Provides @Named("DEFAULT") protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.04").os64Bit(true); + return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true); } /** diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java old mode 100755 new mode 100644 diff --git a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java index 2e1db1224d..c84e7adbb3 100644 --- a/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java +++ b/compute/src/main/java/org/jclouds/compute/reference/ComputeServiceConstants.java @@ -57,7 +57,7 @@ public interface ComputeServiceConstants { public static class ReferenceData { @Inject(optional = true) @Named(PROPERTY_OS_VERSION_MAP_JSON) - public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; + public String osVersionMapJson = "{\"suse\":{\"\":\"\",\"11\":\"11\",\"11 SP1\":\"11 SP1\"},\"debian\":{\"\":\"\",\"lenny\":\"5.0\",\"squeeze\":\"6.0\"},\"centos\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"rhel\":{\"\":\"\",\"5\":\"5.0\",\"5.2\":\"5.2\",\"5.3\":\"5.3\",\"5.4\":\"5.4\",\"5.5\":\"5.5\"},\"solaris\":{\"\":\"\",\"10\":\"10\"},\"ubuntu\":{\"\":\"\",\"hardy\":\"8.04\",\"karmic\":\"9.10\",\"lucid\":\"10.04\",\"10.04.1\":\"10.04\",\"maverick\":\"10.10\",\"natty\":\"11.04\"},\"windows\":{\"\":\"\",\"2003\":\"2003\",\"2003 Standard\":\"2003\",\"2003 R2\":\"2003 R2\",\"2008\":\"2008\",\"2008 Web\":\"2008\",\"2008 Server\":\"2008\",\"Server 2008\":\"2008\",\"2008 R1\":\"2008 R1\",\"2008 R2\":\"2008 R2\",\"Server 2008 R2\":\"2008 R2\",\"2008 Server R2\":\"2008 R2\",\"2008 SP2\":\"2008 SP2\",\"Server 2008 SP2\":\"2008 SP2\"}}"; } @Singleton diff --git a/compute/src/main/java/org/jclouds/compute/strategy/ListNodesStrategy.java b/compute/src/main/java/org/jclouds/compute/strategy/ListNodesStrategy.java old mode 100755 new mode 100644 diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/CreateNodesWithGroupEncodedIntoNameThenAddToSet.java old mode 100755 new mode 100644 diff --git a/compute/src/main/java/org/jclouds/ssh/ConfiguresSshClient.java b/compute/src/main/java/org/jclouds/ssh/ConfiguresSshClient.java old mode 100755 new mode 100644 diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java old mode 100755 new mode 100644 index b7237e647e..277bbd0a25 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -96,7 +96,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = { "integration", "live" }, sequential = true) +@Test(groups = { "integration", "live" }, singleThreaded = true) public abstract class BaseComputeServiceLiveTest { protected String group; @@ -243,7 +243,7 @@ public abstract class BaseComputeServiceLiveTest { overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()) assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " + response.getValue(); - + // test single-node execution ExecResponse response = client.runScriptOnNode(get(nodes, 0).getId(), "echo hello", wrapInInitScript(false) .runAsRoot(false)); @@ -561,6 +561,8 @@ public abstract class BaseComputeServiceLiveTest { } } + protected int nonBlockDuration = 30 * 1000; + public void testOptionToNotBlock() throws Exception { String group = this.group + "block"; try { @@ -576,7 +578,8 @@ public abstract class BaseComputeServiceLiveTest { NodeMetadata node = getOnlyElement(nodes); assert node.getState() != NodeState.RUNNING; long duration = System.currentTimeMillis() - time; - assert duration < 30 * 1000 : "duration longer than 30 seconds!: " + duration / 1000; + assert duration < nonBlockDuration : String.format("duration(%d) longer than expected(%d) seconds! ", + duration / 1000, nonBlockDuration); } finally { client.destroyNodesMatching(inGroup(group)); } @@ -611,14 +614,14 @@ public abstract class BaseComputeServiceLiveTest { assertEquals(defaultSize, smallest); - assert getCores(smallest) <= getCores(fastest) : String.format("%d ! <= %d", smallest, fastest); - assert getCores(biggest) <= getCores(fastest) : String.format("%d ! <= %d", biggest, fastest); + assert getCores(smallest) <= getCores(fastest) : String.format("%s ! <= %s", smallest, fastest); + assert getCores(biggest) <= getCores(fastest) : String.format("%s ! <= %s", biggest, fastest); - assert biggest.getRam() >= fastest.getRam() : String.format("%d ! >= %d", biggest, fastest); - assert biggest.getRam() >= smallest.getRam() : String.format("%d ! >= %d", biggest, smallest); + assert biggest.getRam() >= fastest.getRam() : String.format("%s ! >= %s", biggest, fastest); + assert biggest.getRam() >= smallest.getRam() : String.format("%s ! >= %s", biggest, smallest); - assert getCores(fastest) >= getCores(biggest) : String.format("%d ! >= %d", fastest, biggest); - assert getCores(fastest) >= getCores(smallest) : String.format("%d ! >= %d", fastest, smallest); + assert getCores(fastest) >= getCores(biggest) : String.format("%s ! >= %s", fastest, biggest); + assert getCores(fastest) >= getCores(smallest) : String.format("%s ! >= %s", fastest, smallest); } private void sshPing(NodeMetadata node) throws IOException { diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index c393d92700..cc30beefcd 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -174,7 +174,8 @@ public abstract class BaseTemplateBuilderLiveTest { @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); + assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[10].[10][04]") : defaultTemplate + .getImage().getOperatingSystem().getVersion(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); diff --git a/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java b/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java old mode 100755 new mode 100644 diff --git a/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/collect/Memoized.java b/core/src/main/java/org/jclouds/collect/Memoized.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/concurrent/ExceptionParsingListenableFuture.java b/core/src/main/java/org/jclouds/concurrent/ExceptionParsingListenableFuture.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/concurrent/SingleThreaded.java b/core/src/main/java/org/jclouds/concurrent/SingleThreaded.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/date/DateService.java b/core/src/main/java/org/jclouds/date/DateService.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/date/internal/SimpleDateFormatDateService.java b/core/src/main/java/org/jclouds/date/internal/SimpleDateFormatDateService.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java b/core/src/main/java/org/jclouds/encryption/internal/JCECrypto.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/http/functions/config/SaxParserModule.java b/core/src/main/java/org/jclouds/http/functions/config/SaxParserModule.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/Binder.java b/core/src/main/java/org/jclouds/rest/Binder.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java b/core/src/main/java/org/jclouds/rest/ConfiguresRestClient.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/RestContext.java b/core/src/main/java/org/jclouds/rest/RestContext.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/BinderParam.java b/core/src/main/java/org/jclouds/rest/annotations/BinderParam.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/ExceptionParser.java b/core/src/main/java/org/jclouds/rest/annotations/ExceptionParser.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/Headers.java b/core/src/main/java/org/jclouds/rest/annotations/Headers.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/ParamParser.java b/core/src/main/java/org/jclouds/rest/annotations/ParamParser.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/QueryParams.java b/core/src/main/java/org/jclouds/rest/annotations/QueryParams.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/RequestFilters.java b/core/src/main/java/org/jclouds/rest/annotations/RequestFilters.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/ResponseParser.java b/core/src/main/java/org/jclouds/rest/annotations/ResponseParser.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/SkipEncoding.java b/core/src/main/java/org/jclouds/rest/annotations/SkipEncoding.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/VirtualHost.java b/core/src/main/java/org/jclouds/rest/annotations/VirtualHost.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/annotations/XMLResponseParser.java b/core/src/main/java/org/jclouds/rest/annotations/XMLResponseParser.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/binders/BindToStringPayload.java b/core/src/main/java/org/jclouds/rest/binders/BindToStringPayload.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java b/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java old mode 100755 new mode 100644 diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java old mode 100755 new mode 100644 diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index 27b3da4a8f..af8b0e75e3 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -92,8 +92,8 @@ cloudservers-uk.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServer cloudservers-us.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder cloudservers-us.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUSPropertiesBuilder -bluelock-vcdirector.contextbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorContextBuilder -bluelock-vcdirector.propertiesbuilder=org.jclouds.vcloud.bluelock.BlueLockVCloudDirectorPropertiesBuilder +bluelock-vcdirector.contextbuilder=org.jclouds.vcloud.bluelock.BluelockVCloudDirectorContextBuilder +bluelock-vcdirector.propertiesbuilder=org.jclouds.vcloud.bluelock.BluelockVCloudDirectorPropertiesBuilder gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder diff --git a/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java b/core/src/test/java/org/jclouds/concurrent/FutureExceptionParserTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/date/DateServiceTest.java b/core/src/test/java/org/jclouds/date/DateServiceTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java b/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/http/filters/BasicAuthenticationTest.java b/core/src/test/java/org/jclouds/http/filters/BasicAuthenticationTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java b/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java b/core/src/test/java/org/jclouds/rest/RestContextBuilderTest.java old mode 100755 new mode 100644 diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore-spring/README.txt b/demos/gae-tweetstore-spring/README.txt index cb38c014df..dc9b56bbdb 100644 --- a/demos/gae-tweetstore-spring/README.txt +++ b/demos/gae-tweetstore-spring/README.txt @@ -37,7 +37,7 @@ attempting to run 'mvn -Plive install' true - /path/to/appengine-java-sdk-1.3.5 + /path/to/appengine-java-sdk-1.4.2 yourappid @@ -48,20 +48,13 @@ attempting to run 'mvn -Plive install' true - YOUR_ACCESS_KEY_ID - YOUR_SECRET_KEY - YOUR_USER - YOUR_HEX_KEY - YOUR_ACCOUNT - YOUR_BASE64_ENCODED_KEY - YOUR_TWITTER_USERNAME - YOUR_TWITTER_PASSWORD + YOUR_ACCESS_KEY_ID + YOUR_SECRET_KEY + YOUR_USER + YOUR_HEX_KEY + YOUR_ACCOUNT + YOUR_BASE64_ENCODED_KEY + YOUR_TWITTER_USERNAME + YOUR_TWITTER_PASSWORD - - - - - jclouds - http://jclouds.googlecode.com/svn/trunk/repo - - + \ No newline at end of file diff --git a/demos/gae-tweetstore-spring/pom.xml b/demos/gae-tweetstore-spring/pom.xml index 295952e1e2..5be9f733b2 100644 --- a/demos/gae-tweetstore-spring/pom.xml +++ b/demos/gae-tweetstore-spring/pom.xml @@ -34,14 +34,14 @@ - YOUR_APPENGINE_HOME jclouds-tweetstore-spring + 1.4.2 localhost 8088 - cloudfiles,googlestorage,s3,azureblob + cloudfiles-us,aws-s3,azureblob jclouds-tweetstore-spring @@ -67,21 +67,19 @@ org.jclouds.provider aws-s3 ${project.version} + runtime - ${project.groupId} - jclouds-atmos + org.jclouds.provider + cloudfiles-us ${project.version} + runtime - ${project.groupId} - jclouds-azure - ${project.version} - - - ${project.groupId} - jclouds-rackspace + org.jclouds.provider + azureblob ${project.version} + runtime org.jclouds.driver @@ -102,11 +100,13 @@ cglib cglib-nodep 2.2 + runtime displaytag displaytag 1.2 + runtime org.slf4j @@ -118,6 +118,7 @@ org.slf4j slf4j-jdk14 1.5.6 + runtime standard @@ -129,35 +130,26 @@ jstl javax.servlet 1.1.2 + runtime - org.apache.geronimo.specs - geronimo-el_1.0_spec - 1.0.1 - - - org.apache.geronimo.specs - geronimo-jsp_2.1_spec - 1.0.1 + javax.servlet + servlet-api + 2.5 provided + + - org.apache.geronimo.specs - geronimo-servlet_2.5_spec - 1.2 - provided + com.google.appengine + appengine-api-1.0-sdk + ${appengine.sdk.version} com.google.appengine - appengine-api-labs - 1.3.5 - - - com.google.appengine - appengine-tools-api - 1.3.5 - system - ${appengine.home}/lib/appengine-tools-api.jar + appengine-tools-sdk + ${appengine.sdk.version} + test @@ -187,8 +179,8 @@ - appengine.home - ${appengine.home} + appengine.sdk.root + ${appengine.sdk.root} devappserver.address @@ -203,15 +195,6 @@ ${project.build.directory}/${project.artifactId} - - ${appengine.home}/lib/appengine-tools-api.jar - - - true - ${appengine.home}/bin - ${appengine.home}/lib - ${appengine.home}/config/sdk - @@ -252,32 +235,24 @@ ${test.azureblob.credential} - test.cloudfiles.identity - ${test.cloudfiles.identity} + test.cloudfiles-us.identity + ${test.cloudfiles-us.identity} - test.cloudfiles.credential - ${test.cloudfiles.credential} + test.cloudfiles-us.credential + ${test.cloudfiles-us.credential} - test.googlestorage.identity - ${test.googlestorage.identity} + test.aws-s3.identity + ${test.aws-s3.identity} - test.googlestorage.credential - ${test.googlestorage.credential} + test.aws-s3.credential + ${test.aws-s3.credential} - test.s3.identity - ${test.s3.identity} - - - test.s3.credential - ${test.s3.credential} - - - appengine.home - ${appengine.home} + appengine.sdk.root + ${appengine.sdk.root} devappserver.address diff --git a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java index 6ce634b061..9cb71791c5 100644 --- a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java +++ b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/config/SpringServletConfig.java @@ -18,7 +18,7 @@ */ package org.jclouds.demo.tweetstore.config; -import static com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url; +import static com.google.appengine.api.taskqueue.TaskOptions.Builder.withUrl; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; @@ -53,10 +53,11 @@ import twitter4j.Twitter; import twitter4j.TwitterFactory; import twitter4j.conf.ConfigurationBuilder; -import com.google.appengine.api.labs.taskqueue.Queue; -import com.google.appengine.api.labs.taskqueue.QueueFactory; -import com.google.appengine.api.labs.taskqueue.TaskOptions.Method; -import com.google.appengine.repackaged.com.google.common.base.Splitter; +import com.google.appengine.api.taskqueue.Queue; +import com.google.appengine.api.taskqueue.QueueFactory; +import com.google.appengine.api.taskqueue.TaskOptions.Builder; +import com.google.appengine.api.taskqueue.TaskOptions.Method; +import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.io.Closeables; @@ -110,7 +111,7 @@ public class SpringServletConfig extends LoggingConfig implements ServletConfigA Queue queue = QueueFactory.getQueue("twitter"); // submit a job to store tweets for each configured blobstore for (String name : providerTypeToBlobStoreMap.keySet()) { - queue.add(url("/store/do").header("context", name).method(Method.GET)); + queue.add(withUrl("/store/do").header("context", name).method(Method.GET)); } logger.trace("Members initialized. Twitter: '%s', container: '%s', provider types: '%s'", twitterClient, container, providerTypeToBlobStoreMap.keySet()); diff --git a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index 9e6779587e..5a82e39055 100644 --- a/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/gae-tweetstore-spring/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -62,7 +62,7 @@ public class StoreTweetsController extends HttpServlet { } public Blob apply(Status from) { - Blob to = map.newBlob(from.getId() + ""); + Blob to = map.blobBuilder().name(from.getId() + "").build(); to.setPayload(from.getText()); to.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, from.getUser().getScreenName()); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index fd0c24297a..663a870bc1 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -52,7 +52,7 @@ public class AddTweetsControllerTest { BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); - Blob blob = context.getAsyncBlobStore().newBlob("1"); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 8a3f265eab..0f2b4f9552 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -48,7 +48,7 @@ public class KeyToStoredTweetStatusTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { BlobMap map = createMap(); - Blob blob = map.newBlob("1"); + Blob blob = map.blobBuilder().name("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); map.put("1", blob); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index a377d29ff0..c63d9821fb 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -49,7 +49,7 @@ public class ServiceToStoredTweetStatusesTest { BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); - Blob blob = context.getAsyncBlobStore().newBlob("1"); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java index a261dcf459..47a73f0581 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java @@ -18,12 +18,17 @@ */ package org.jclouds.demo.tweetstore.integration; -import com.google.appengine.tools.KickStart; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.File; import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import com.google.appengine.tools.KickStart; +import com.google.appengine.tools.info.SdkInfo; /** * Basic functionality to start a local google app engine instance. @@ -44,22 +49,29 @@ public class GoogleDevServer { assert new File(filename).exists(); this.server = new Thread(new Runnable() { public void run() { - KickStart - .main(new String[]{ - "com.google.appengine.tools.development.DevAppServerMain", - "--disable_update_check", "-a", address, "-p", - port, warfile}); - + String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY); + KickStart.main(new String[] { + KickStarter.systemProperty("java.util.logging.config.file", + format("%s/WEB-INF/logging.properties", warfile)), + KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot), + "com.google.appengine.tools.development.DevAppServerMain", + "--disable_update_check", + format("--sdk_root=%s", sdkRoot), + "-a", address, "-p", port, warfile }); } - }); server.start(); - Thread.sleep(30 * 1000); + TimeUnit.SECONDS.sleep(30); } - @SuppressWarnings("deprecation") public void stop() throws Exception { - server.stop(); + // KickStart.main opens a process and calls process.waitFor(), which is interruptable + server.interrupt(); + } + + private static class KickStarter { + private static String systemProperty(String key, String value) { + return format("--jvm_flag=-D%s=%s", key, value); + } } - } \ No newline at end of file diff --git a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java index d3f43e7a02..a76f004412 100644 --- a/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore-spring/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -62,7 +62,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class TweetStoreLiveTest { GoogleDevServer server; @@ -70,19 +70,17 @@ public class TweetStoreLiveTest { private Map contexts; private String container; - private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores", - "cloudfiles,googlestorage,s3,azureblob"); - private static final Iterable blobstores = Splitter.on(',').split(blobs); + private static final Iterable blobstores = + Splitter.on(',').split(System.getProperty("jclouds.tweetstore.blobstores", + "cloudfiles-us,aws-s3,azureblob")); private static final Properties props = new Properties(); @BeforeTest void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { - container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, - checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); props.setProperty(SpringServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); // put all identity/credential pairs into the client diff --git a/demos/gae-tweetstore/README.txt b/demos/gae-tweetstore/README.txt old mode 100755 new mode 100644 index d81b41e055..7d9623f978 --- a/demos/gae-tweetstore/README.txt +++ b/demos/gae-tweetstore/README.txt @@ -29,7 +29,7 @@ attempting to run 'mvn -Plive install' true - /path/to/appengine-java-sdk-1.3.5 + /path/to/appengine-java-sdk-1.4.2 yourappid @@ -40,20 +40,13 @@ attempting to run 'mvn -Plive install' true - YOUR_ACCESS_KEY_ID - YOUR_SECRET_KEY - YOUR_USER - YOUR_HEX_KEY - YOUR_ACCOUNT - YOUR_BASE64_ENCODED_KEY - YOUR_TWITTER_USERNAME - YOUR_TWITTER_PASSWORD + YOUR_ACCESS_KEY_ID + YOUR_SECRET_KEY + YOUR_USER + YOUR_HEX_KEY + YOUR_ACCOUNT + YOUR_BASE64_ENCODED_KEY + YOUR_TWITTER_USERNAME + YOUR_TWITTER_PASSWORD - - - - - jclouds - http://jclouds.googlecode.com/svn/trunk/repo - - + \ No newline at end of file diff --git a/demos/gae-tweetstore/pom.xml b/demos/gae-tweetstore/pom.xml index 77d100421c..44e81fa938 100644 --- a/demos/gae-tweetstore/pom.xml +++ b/demos/gae-tweetstore/pom.xml @@ -31,17 +31,16 @@ JClouds TweetStore for Google App Engine using Guice for Dependency Injection - - jclouds-replicate - 1.4.2 - localhost - 8088 - googlestorage - cloudfiles-us,aws-s3,azureblob - jclouds-replicate + + jclouds-tweetstore + 1.4.2 + localhost + 8088 + cloudfiles-us,aws-s3,azureblob + jclouds-tweetstore @@ -66,21 +65,19 @@ org.jclouds.provider aws-s3 ${project.version} + runtime - ${project.groupId} - jclouds-atmos + org.jclouds.provider + cloudfiles-us ${project.version} + runtime - ${project.groupId} - jclouds-azure - ${project.version} - - - ${project.groupId} - jclouds-rackspace + org.jclouds.provider + azureblob ${project.version} + runtime org.jclouds.driver @@ -96,6 +93,7 @@ displaytag displaytag 1.2 + runtime org.slf4j @@ -107,11 +105,13 @@ org.slf4j slf4j-jdk14 1.5.6 + runtime jstl javax.servlet 1.1.2 + runtime standard @@ -126,197 +126,188 @@ provided - - - com.google.appengine - appengine-api-1.0-sdk - ${appengine.sdk.version} - - - com.google.appengine - appengine-tools-sdk - ${appengine.sdk.version} - + + + com.google.appengine + appengine-api-1.0-sdk + ${appengine.sdk.version} + + + com.google.appengine + appengine-tools-sdk + ${appengine.sdk.version} + test + - - - org.apache.geronimo.specs - geronimo-jta_1.1_spec - 1.1.1 - runtime - - - org.apache.geronimo.specs - geronimo-jpa_3.0_spec - 1.1.1 - runtime - - - com.google.appengine.orm - jdo2-api - 2.3-eb - runtime - - - org.datanucleus - datanucleus-core - 1.1.5 - - - com.google.appengine.orm - datanucleus-appengine - 1.0.8 - runtime - - - org.datanucleus - datanucleus-jpa - 1.1.5 - runtime - - - - ${project.artifactId} - - - maven-war-plugin - - - - src/main/appengine - WEB-INF/ - true - - - - - - maven-surefire-plugin - - - integration - integration-test - - test - - - - - appengine.home - ${appengine.home} - - - devappserver.address - ${devappserver.address} - - - devappserver.port - ${devappserver.port} - - - warfile - ${project.build.directory}/${project.artifactId} - - - - ${appengine.home}/lib/appengine-tools-api.jar - - - true - ${appengine.home}/bin - ${appengine.home}/lib - ${appengine.home}/config/sdk - - - - - - - - - - - live - + + + + + + + ${project.artifactId} - - maven-surefire-plugin - - - integration - integration-test - - test - + + maven-war-plugin - - - test.azureblob.identity - ${test.azureblob.identity} - - - test.azureblob.credential - ${test.azureblob.credential} - - - test.cloudfiles-us.identity - ${test.cloudfiles-us.identity} - - - test.cloudfiles-us.credential - ${test.cloudfiles-us.credential} - - - test.aws-s3.identity - ${test.aws-s3.identity} - - - test.aws-s3.credential - ${test.aws-s3.credential} - - - test.googlestorage.identity - ${test.googlestorage.identity} - - - test.googlestorage.credential - ${test.googlestorage.credential} - - - appengine.home - ${appengine.home} - - - devappserver.address - ${devappserver.address} - - - devappserver.port - ${devappserver.port} - - - jclouds.replicate.source - ${jclouds.replicate.source} - - - jclouds.replicate.destinations - ${jclouds.replicate.destinations} - - - jclouds.replicate.container - ${jclouds.replicate.container} - - - warfile - ${project.build.directory}/${project.artifactId} - - + + + src/main/appengine + WEB-INF/ + true + + - - - + + + maven-surefire-plugin + + + integration + integration-test + + test + + + + + appengine.sdk.root + ${appengine.sdk.root} + + + devappserver.address + ${devappserver.address} + + + devappserver.port + ${devappserver.port} + + + warfile + ${project.build.directory}/${project.artifactId} + + + + + + - - + + + + + live + + + + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.twitter.identity + ${test.twitter.identity} + + + test.twitter.credential + ${test.twitter.credential} + + + test.azureblob.identity + ${test.azureblob.identity} + + + test.azureblob.credential + ${test.azureblob.credential} + + + test.cloudfiles-us.identity + ${test.cloudfiles-us.identity} + + + test.cloudfiles-us.credential + ${test.cloudfiles-us.credential} + + + test.aws-s3.identity + ${test.aws-s3.identity} + + + test.aws-s3.credential + ${test.aws-s3.credential} + + + appengine.sdk.root + ${appengine.sdk.root} + + + devappserver.address + ${devappserver.address} + + + devappserver.port + ${devappserver.port} + + + jclouds.tweetstore.blobstores + ${jclouds.tweetstore.blobstores} + + + jclouds.tweetstore.container + ${jclouds.tweetstore.container} + + + warfile + ${project.build.directory}/${project.artifactId} + + + + + + + + + diff --git a/demos/gae-tweetstore/src/main/appengine/appengine-web.xml b/demos/gae-tweetstore/src/main/appengine/appengine-web.xml old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java old mode 100755 new mode 100644 index fd2b7afb7b..6dae4161ea --- a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java +++ b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -43,7 +43,6 @@ import twitter4j.conf.ConfigurationBuilder; import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.QueueFactory; -import com.google.appengine.api.taskqueue.TaskOptions.Builder; import com.google.appengine.api.taskqueue.TaskOptions.Method; import com.google.appengine.repackaged.com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java index 9e6779587e..5a82e39055 100644 --- a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java +++ b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -62,7 +62,7 @@ public class StoreTweetsController extends HttpServlet { } public Blob apply(Status from) { - Blob to = map.newBlob(from.getId() + ""); + Blob to = map.blobBuilder().name(from.getId() + "").build(); to.setPayload(from.getText()); to.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, from.getUser().getScreenName()); diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/gae-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/webapp/WEB-INF/web.xml b/demos/gae-tweetstore/src/main/webapp/WEB-INF/web.xml old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/webapp/index.jsp b/demos/gae-tweetstore/src/main/webapp/index.jsp old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/main/webapp/tweets.jsp b/demos/gae-tweetstore/src/main/webapp/tweets.jsp old mode 100755 new mode 100644 diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java index b68780826d..f0a624d2b3 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -51,7 +51,7 @@ public class AddTweetsControllerTest { for (String name : new String[] { "1", "2" }) { BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); - Blob blob = context.getAsyncBlobStore().newBlob("1"); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java index 5943a00292..4f65c97f83 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -47,7 +47,7 @@ public class KeyToStoredTweetStatusTest { public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { BlobMap map = createMap(); - Blob blob = map.newBlob("1"); + Blob blob = map.blobBuilder().name("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); map.put("1", blob); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java index a377d29ff0..c63d9821fb 100644 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -49,7 +49,7 @@ public class ServiceToStoredTweetStatusesTest { BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); context.getAsyncBlobStore().createContainerInLocation(null, container).get(); - Blob blob = context.getAsyncBlobStore().newBlob("1"); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); blob.setPayload("I love beans!"); context.getAsyncBlobStore().putBlob(container, blob).get(); diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java old mode 100755 new mode 100644 index a261dcf459..47a73f0581 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/GoogleDevServer.java @@ -18,12 +18,17 @@ */ package org.jclouds.demo.tweetstore.integration; -import com.google.appengine.tools.KickStart; +import static com.google.common.base.Preconditions.checkNotNull; +import static java.lang.String.format; +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.File; import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import com.google.appengine.tools.KickStart; +import com.google.appengine.tools.info.SdkInfo; /** * Basic functionality to start a local google app engine instance. @@ -44,22 +49,29 @@ public class GoogleDevServer { assert new File(filename).exists(); this.server = new Thread(new Runnable() { public void run() { - KickStart - .main(new String[]{ - "com.google.appengine.tools.development.DevAppServerMain", - "--disable_update_check", "-a", address, "-p", - port, warfile}); - + String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY); + KickStart.main(new String[] { + KickStarter.systemProperty("java.util.logging.config.file", + format("%s/WEB-INF/logging.properties", warfile)), + KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot), + "com.google.appengine.tools.development.DevAppServerMain", + "--disable_update_check", + format("--sdk_root=%s", sdkRoot), + "-a", address, "-p", port, warfile }); } - }); server.start(); - Thread.sleep(30 * 1000); + TimeUnit.SECONDS.sleep(30); } - @SuppressWarnings("deprecation") public void stop() throws Exception { - server.stop(); + // KickStart.main opens a process and calls process.waitFor(), which is interruptable + server.interrupt(); + } + + private static class KickStarter { + private static String systemProperty(String key, String value) { + return format("--jvm_flag=-D%s=%s", key, value); + } } - } \ No newline at end of file diff --git a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java old mode 100755 new mode 100644 index 7bda7b5d6b..772d891934 --- a/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java +++ b/demos/gae-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -63,26 +63,24 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@Test(groups = "live", sequential = true) +@Test(groups = "live", singleThreaded = true) public class TweetStoreLiveTest { - GoogleDevServer server; private URL url; private Map contexts; private String container; - private static final String blobs = System.getProperty("jclouds.tweetstore.blobstores", - "cloudfiles,googlestorage,s3,azureblob"); - private static final Iterable blobstores = Splitter.on(',').split(blobs); + private static final Iterable blobstores = + Splitter.on(',').split(System.getProperty("jclouds.tweetstore.blobstores", + "cloudfiles-us,aws-s3,azureblob")); private static final Properties props = new Properties(); @BeforeTest void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, TwitterException { - container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER)); - - props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, - checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER)); + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), + PROPERTY_TWEETSTORE_CONTAINER); + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); // put all identity/credential pairs into the client diff --git a/demos/gae-tweetstore/src/test/resources/log4j.xml b/demos/gae-tweetstore/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/demos/getpath/README.txt b/demos/getpath/README.txt old mode 100755 new mode 100644 diff --git a/demos/getpath/src/main/java/org/jclouds/blobstore/GetPath.java b/demos/getpath/src/main/java/org/jclouds/blobstore/GetPath.java old mode 100755 new mode 100644 diff --git a/demos/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java b/demos/getpath/src/test/java/org/jclouds/blobstore/GetPathLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/getpath/src/test/resources/log4j.xml b/demos/getpath/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/demos/googleappengine/README.md b/demos/googleappengine/README.md old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/appengine/appengine-web.xml b/demos/googleappengine/src/main/appengine/appengine-web.xml old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllStatusController.java b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/GetAllStatusController.java old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/config/GuiceServletConfig.java old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/StatusResult.java b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/domain/StatusResult.java old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToStatusResult.java b/demos/googleappengine/src/main/java/org/jclouds/samples/googleappengine/functions/BlobStoreContextToStatusResult.java old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/webapp/WEB-INF/jsp/status.jsp b/demos/googleappengine/src/main/webapp/WEB-INF/jsp/status.jsp old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/webapp/WEB-INF/web.xml b/demos/googleappengine/src/main/webapp/WEB-INF/web.xml old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/main/webapp/index.jsp b/demos/googleappengine/src/main/webapp/index.jsp old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleAppEngineLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java old mode 100755 new mode 100644 index db589c7eea..b74d9d2e49 --- a/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java +++ b/demos/googleappengine/src/test/java/org/jclouds/samples/googleappengine/functest/GoogleDevServer.java @@ -18,13 +18,13 @@ */ package org.jclouds.samples.googleappengine.functest; -import com.google.appengine.tools.KickStart; - +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.io.File; import java.util.Properties; +import com.google.appengine.tools.KickStart; + /** * Basic functionality to start a local google app engine instance. * @@ -57,9 +57,9 @@ public class GoogleDevServer { Thread.sleep(30 * 1000); } - @SuppressWarnings("deprecation") public void stop() throws Exception { - server.stop(); + // KickStart.main opens a process and calls process.waitFor(), which is interruptable + server.interrupt(); } } \ No newline at end of file diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/BasePerformanceLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/JCloudsGaePerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/JCloudsGaePerformanceLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/JCloudsPerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/JCloudsPerformanceLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java old mode 100755 new mode 100644 diff --git a/demos/perftest/src/test/resources/log4j.xml b/demos/perftest/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/demos/pom.xml b/demos/pom.xml index 31b5105286..50209cbeae 100644 --- a/demos/pom.xml +++ b/demos/pom.xml @@ -37,6 +37,7 @@ getpath googleappengine perftest + runatcloud-tweetstore speedtest-azurequeue speedtest-sqs simpledb diff --git a/demos/runatcloud-tweetstore/README.txt b/demos/runatcloud-tweetstore/README.txt new file mode 100644 index 0000000000..f789b19e44 --- /dev/null +++ b/demos/runatcloud-tweetstore/README.txt @@ -0,0 +1,48 @@ +==== + + Copyright (C) 2011 Cloud Conscious, LLC. + + ==================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ==================================================================== +==== + +Please modify your maven settings.xml like below before attempting to run 'mvn -Plive install' + + + cloudbees + + true + + + yourappid + yourenv + + + + + keys + + true + + + YOUR_ACCESS_KEY_ID + YOUR_SECRET_KEY + YOUR_USER + YOUR_HEX_KEY + YOUR_ACCOUNT + YOUR_BASE64_ENCODED_KEY + YOUR_TWITTER_USERNAME + YOUR_TWITTER_PASSWORD + + \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/pom.xml b/demos/runatcloud-tweetstore/pom.xml new file mode 100644 index 0000000000..657073af65 --- /dev/null +++ b/demos/runatcloud-tweetstore/pom.xml @@ -0,0 +1,274 @@ + + + + 4.0.0 + + org.jclouds + jclouds-demos-project + 1.0-SNAPSHOT + + jclouds-demo-runatcloud-tweetstore + war + jclouds TweetStore for RUN@cloud + jclouds TweetStore for CloudBees' RUN@cloud using Guice for Dependency Injection + + + tweetstore + run + localhost + 8088 + cloudfiles-us,aws-s3,azureblob + jclouds-tweetstore-runatcloud + + + + + ${project.groupId} + jclouds-blobstore + ${project.version} + + + org.twitter4j + twitter4j-core + [2.1,) + + + ${project.groupId} + jclouds-blobstore + ${project.version} + test-jar + test + + + org.jclouds.provider + aws-s3 + ${project.version} + runtime + + + org.jclouds.provider + cloudfiles-us + ${project.version} + runtime + + + org.jclouds.provider + azureblob + ${project.version} + runtime + + + com.google.inject.extensions + guice-servlet + 3.0 + + + displaytag + displaytag + 1.2 + runtime + + + org.slf4j + slf4j-log4j12 + + + + + org.slf4j + slf4j-jdk14 + 1.5.6 + runtime + + + jstl + javax.servlet + 1.1.2 + runtime + + + standard + taglibs + 1.1.2 + runtime + + + javax.servlet + servlet-api + 2.5 + provided + + + + + net.stax + stax-appserver + 1.0.20110131-SNAPSHOT + test + + + + + + bees-plugins-snapshots + http://repository-cloudbees.forge.cloudbees.com/public-snapshot/ + + false + + + true + + + + + + ${project.artifactId} + + + maven-surefire-plugin + + + integration + integration-test + + test + + + + + bees.address + ${bees.address} + + + bees.port + ${bees.port} + + + bees.environment + ${bees.environment} + + + bees.basedir + ${project.build.directory}/bees + + + warfile + ${project.build.directory}/${project.artifactId} + + + + + + + + com.cloudbees + bees-maven-plugin + 1.0-SNAPSHOT + + + + + + + live + + + + maven-surefire-plugin + + + integration + integration-test + + test + + + + + test.twitter.identity + ${test.twitter.identity} + + + test.twitter.credential + ${test.twitter.credential} + + + test.azureblob.identity + ${test.azureblob.identity} + + + test.azureblob.credential + ${test.azureblob.credential} + + + test.cloudfiles-us.identity + ${test.cloudfiles-us.identity} + + + test.cloudfiles-us.credential + ${test.cloudfiles-us.credential} + + + test.aws-s3.identity + ${test.aws-s3.identity} + + + test.aws-s3.credential + ${test.aws-s3.credential} + + + bees.address + ${bees.address} + + + bees.port + ${bees.port} + + + bees.environment + ${bees.environment} + + + jclouds.tweetstore.blobstores + ${jclouds.tweetstore.blobstores} + + + jclouds.tweetstore.container + ${jclouds.tweetstore.container} + + + bees.basedir + ${project.build.directory}/bees + + + warfile + ${project.build.directory}/${project.artifactId} + + + + + + + + + + + diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java new file mode 100644 index 0000000000..3af47b0c2f --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/GuiceServletConfig.java @@ -0,0 +1,154 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.concurrent.TimeUnit.MINUTES; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.servlet.ServletContextEvent; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.tweetstore.config.utils.HttpRequestTask; +import org.jclouds.demo.tweetstore.config.utils.HttpRequestTask.Factory; +import org.jclouds.demo.tweetstore.config.utils.TaskQueue; +import org.jclouds.demo.tweetstore.controller.AddTweetsController; +import org.jclouds.demo.tweetstore.controller.StoreTweetsController; +import org.jclouds.http.HttpRequest; + +import twitter4j.Twitter; +import twitter4j.TwitterFactory; +import twitter4j.conf.Configuration; +import twitter4j.conf.ConfigurationBuilder; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.io.Closeables; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Module; +import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; +import com.google.inject.servlet.GuiceServletContextListener; +import com.google.inject.servlet.ServletModule; + +/** + * Setup Logging and create Injector for use in testing S3. + * + * @author Adrian Cole + */ +public class GuiceServletConfig extends GuiceServletContextListener { + public static final String PROPERTY_BLOBSTORE_CONTEXTS = "blobstore.contexts"; + + private Map providerTypeToBlobStoreMap; + private Twitter twitterClient; + private String container; + private TaskQueue queue; + + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + BlobStoreContextFactory blobStoreContextFactory = new BlobStoreContextFactory(); + + Properties props = loadJCloudsProperties(servletContextEvent); + + Set modules = ImmutableSet.of(); + // shared across all blobstores and used to retrieve tweets + try { + Configuration twitterConf = new ConfigurationBuilder() + .setUser(props.getProperty("twitter.identity")) + .setPassword(props.getProperty("twitter.credential")).build(); + twitterClient = new TwitterFactory(twitterConf).getInstance(); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("properties for twitter not configured properly in " + + props.toString(), e); + } + // common namespace for storing tweets + container = checkNotNull(props.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); + + // instantiate and store references to all blobstores by provider name + providerTypeToBlobStoreMap = Maps.newHashMap(); + for (String hint : Splitter.on(',').split(checkNotNull(props.getProperty(PROPERTY_BLOBSTORE_CONTEXTS), PROPERTY_BLOBSTORE_CONTEXTS))) { + providerTypeToBlobStoreMap.put(hint, blobStoreContextFactory.createContext(hint, modules, props)); + } + + // get a queue for submitting store tweet requests + queue = TaskQueue.builder().name("twitter").period(MINUTES).build(); + Factory taskFactory = HttpRequestTask.factory(props, "twitter"); + // submit a job to store tweets for each configured blobstore + for (String name : providerTypeToBlobStoreMap.keySet()) { + queue.add(taskFactory.create(HttpRequest.builder() + .endpoint(URI.create("http://localhost:8080" + servletContextEvent.getServletContext().getContextPath() + "/store/do")) + .headers(ImmutableMultimap.of("context", name, "X-RUN@cloud-QueueName", "twitter")) + .method("GET").build())); + } + + super.contextInitialized(servletContextEvent); + } + + private Properties loadJCloudsProperties( + ServletContextEvent servletContextEvent) { + InputStream input = servletContextEvent.getServletContext() + .getResourceAsStream("/WEB-INF/jclouds.properties"); + Properties props = new Properties(); + try { + props.load(input); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + Closeables.closeQuietly(input); + } + return props; + } + + @Override + protected Injector getInjector() { + return Guice.createInjector(new ServletModule() { + @Override + protected void configureServlets() { + bind(new TypeLiteral>() { + }).toInstance(providerTypeToBlobStoreMap); + bind(Twitter.class).toInstance(twitterClient); + bindConstant().annotatedWith( + Names.named(PROPERTY_TWEETSTORE_CONTAINER)).to( + container); + serve("/store/*").with(StoreTweetsController.class); + serve("/tweets/*").with(AddTweetsController.class); + } + }); + } + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + for (BlobStoreContext context : providerTypeToBlobStoreMap.values()) { + context.close(); + } + queue.destroy(); + super.contextDestroyed(servletContextEvent); + } +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java new file mode 100644 index 0000000000..fe28b80802 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/HttpRequestTask.java @@ -0,0 +1,132 @@ +package org.jclouds.demo.tweetstore.config.utils; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.inject.name.Names.bindProperties; +import static java.lang.String.format; + +import java.util.Properties; + +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.PropertiesBuilder; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpCommandExecutorService; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.sun.jersey.api.uri.UriBuilderImpl; + +public class HttpRequestTask implements Runnable { + public static Factory factory(Properties props) { + return factory(props, format("%s@%d", Factory.class.getName(), System.currentTimeMillis())); + } + + public static Factory factory(Properties props, String originator) { + return new Factory(props, originator); + } + + public static class Factory { + private static final String HTTP_REQUEST_ORIGINATOR_HEADER = "X-RUN@cloud-Originator"; + + protected final HttpCommandExecutorService httpClient; + protected final String originator; + + private Factory(final Properties props, String originator) { + this.originator = originator; + httpClient = Guice.createInjector(new ExecutorServiceModule(), + new JavaUrlHttpCommandExecutorServiceModule(), + new AbstractModule() { + @Override + protected void configure() { + // URL connection defaults + Properties toBind = new PropertiesBuilder().build(); + toBind.putAll(checkNotNull(props, "properties")); + toBind.putAll(System.getProperties()); + bindProperties(binder(), toBind); + bind(UriBuilder.class).to(UriBuilderImpl.class); + } + }).getInstance(HttpCommandExecutorService.class); + } + + public HttpRequestTask create(HttpRequest request) { + HttpRequest requestWithSubmitter = request.toBuilder().headers( + copyOfWithEntry(request.getHeaders(), + HTTP_REQUEST_ORIGINATOR_HEADER, originator)).build(); + return new HttpRequestTask(httpClient, requestWithSubmitter); + } + + private static Multimap copyOfWithEntry( + Multimap multimap, K k1, V v1) { + return ImmutableMultimap.builder().putAll(multimap).put(k1, v1).build(); + } + } + + private final HttpCommandExecutorService httpClient; + private final HttpRequest request; + + private HttpRequestTask(HttpCommandExecutorService httpClient, HttpRequest request) { + this.httpClient = httpClient; + this.request = request; + } + + @Override + public void run() { + httpClient.submit(new ImmutableHttpCommand(request)); + } + + private class ImmutableHttpCommand implements HttpCommand { + private final HttpRequest request; + + public ImmutableHttpCommand(HttpRequest request) { + this.request = request; + } + + @Override + public void setException(Exception exception) { + } + + @Override + public void setCurrentRequest(HttpRequest request) { + } + + @Override + public boolean isReplayable() { + return false; + } + + @Override + public int incrementRedirectCount() { + return 0; + } + + @Override + public int incrementFailureCount() { + return 0; + } + + @Override + public int getRedirectCount() { + return 0; + } + + @Override + public int getFailureCount() { + return 0; + } + + @Override + public Exception getException() { + return null; + } + + @Override + public HttpRequest getCurrentRequest() { + return request; + } + } +} diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java new file mode 100644 index 0000000000..355f98c5e7 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ImmutableHttpCommand.java @@ -0,0 +1,55 @@ +package org.jclouds.demo.tweetstore.config.utils; + +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpRequest; + +class ImmutableHttpCommand implements HttpCommand { + private final HttpRequest request; + + public ImmutableHttpCommand(HttpRequest request) { + this.request = request; + } + + @Override + public void setException(Exception exception) { + } + + @Override + public void setCurrentRequest(HttpRequest request) { + } + + @Override + public boolean isReplayable() { + return false; + } + + @Override + public int incrementRedirectCount() { + return 0; + } + + @Override + public int incrementFailureCount() { + return 0; + } + + @Override + public int getRedirectCount() { + return 0; + } + + @Override + public int getFailureCount() { + return 0; + } + + @Override + public Exception getException() { + return null; + } + + @Override + public HttpRequest getCurrentRequest() { + return request; + } +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java new file mode 100644 index 0000000000..57f857463c --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/ObjectFields.java @@ -0,0 +1,58 @@ +/* + * @(#)ObjectFields.java 26 May 2011 + * + * Copyright © 2010 Andrew Phillips. + * + * ==================================================================== + * 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.demo.tweetstore.config.utils; + +import java.lang.reflect.Field; + +public class ObjectFields { + + public static Object valueOf(String fieldName, Object source) { + return valueOf(fieldName, source, source.getClass()); + } + + public static Object valueOf(String fieldName, Object source, + Class fieldDeclaringClass) { + try { + return getAccessibleField(fieldName, fieldDeclaringClass).get(source); + } catch (Exception exception) { + throw new IllegalArgumentException(exception); + } + } + + private static Field getAccessibleField(String name, Class declaringClass) throws SecurityException, NoSuchFieldException { + Field field = declaringClass.getDeclaredField(name); + field.setAccessible(true); + return field; + } + + public static void set(String fieldName, Object target, Object value) { + set(fieldName, target, value, target.getClass()); + } + + public static void set(String fieldName, Object target, Object value, + Class fieldDeclaringClass) { + try { + getAccessibleField(fieldName, fieldDeclaringClass).set(target, value); + } catch (Exception exception) { + throw new IllegalArgumentException(exception); + } + } +} diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java new file mode 100644 index 0000000000..617201f875 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/config/utils/TaskQueue.java @@ -0,0 +1,67 @@ +package org.jclouds.demo.tweetstore.config.utils; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.TimeUnit; + +import com.google.inject.Provider; + +public class TaskQueue { + public static Builder builder() { + return new Builder(); + } + + public static class Builder implements Provider { + protected String name = "default"; + protected long taskPeriodMillis = TimeUnit.SECONDS.toMillis(1); + + public Builder name(String name) { + this.name = checkNotNull(name, "name"); + return this; + } + + public Builder period(TimeUnit period) { + this.taskPeriodMillis = checkNotNull(period, "period").toMillis(1); + return this; + } + + public Builder period(long taskPeriodMillis) { + checkArgument(taskPeriodMillis > 0, "taskPeriodMillis"); + this.taskPeriodMillis = taskPeriodMillis; + return this; + } + + public TaskQueue build() { + return new TaskQueue(name, taskPeriodMillis); + } + + @Override + public TaskQueue get() { + return build(); + } + } + + private final Timer timer; + private final long taskPeriodMillis; + + private TaskQueue(String name, long taskPeriodMillis) { + timer = new Timer(name); + this.taskPeriodMillis = taskPeriodMillis; + } + + public void add(final Runnable task) { + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + task.run(); + } + }, 0, taskPeriodMillis); + } + + public void destroy() { + timer.cancel(); + } +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java new file mode 100644 index 0000000000..7ef8e1cd6f --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/AddTweetsController.java @@ -0,0 +1,96 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.controller; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; + +/** + * Shows an example of how to use @{link BlobStoreContext} injected with Guice. + * + * @author Adrian Cole + */ +@Singleton +public class AddTweetsController extends HttpServlet implements + Function, List> { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3888348023150822683L; + private final Map contexts; + private final ServiceToStoredTweetStatuses blobStoreContextToContainerResult; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + AddTweetsController(Map contexts, + ServiceToStoredTweetStatuses blobStoreContextToContainerResult) { + this.contexts = contexts; + this.blobStoreContextToContainerResult = blobStoreContextToContainerResult; + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + try { + addMyTweetsToRequest(request); + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/tweets.jsp"); + dispatcher.forward(request, response); + } catch (Exception e) { + logger.error(e, "Error listing containers"); + throw new ServletException(e); + } + } + + void addMyTweetsToRequest(HttpServletRequest request) throws InterruptedException, + ExecutionException, TimeoutException { + request.setAttribute("tweets", apply(contexts.keySet())); + } + + public List apply(Set in) { + List statuses = Lists.newArrayList(); + for (Iterable list : Iterables.transform(in, + blobStoreContextToContainerResult)) { + Iterables.addAll(statuses, list); + } + return statuses; + } +} diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java new file mode 100644 index 0000000000..efe708ea23 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/controller/StoreTweetsController.java @@ -0,0 +1,129 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.controller; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.IOException; +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; +import org.jclouds.rest.AuthorizationException; + +import twitter4j.Status; +import twitter4j.Twitter; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; + +/** + * Grab tweets related to me and store them into blobstores + * + * @author Adrian Cole + */ +@Singleton +public class StoreTweetsController extends HttpServlet { + + private static final class StatusToBlob implements Function { + private final BlobMap map; + + private StatusToBlob(BlobMap map) { + this.map = map; + } + + public Blob apply(Status from) { + Blob to = map.blobBuilder().name(from.getId() + "").build(); + to.setPayload(from.getText()); + to.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN); + to.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, from.getUser().getScreenName()); + return to; + } + } + + /** The serialVersionUID */ + private static final long serialVersionUID = 7215420527854203714L; + + private final Map contexts; + private final Twitter client; + private final String container; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + @VisibleForTesting + public StoreTweetsController(Map contexts, + @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container, Twitter client) { + this.container = container; + this.contexts = contexts; + this.client = client; + } + + @VisibleForTesting + public void addMyTweets(String contextName, Iterable responseList) { + BlobStoreContext context = checkNotNull(contexts.get(contextName), "no context for " + contextName + " in " + + contexts.keySet()); + BlobMap map = context.createBlobMap(container); + for (Status status : responseList) { + Blob blob = null; + try { + blob = new StatusToBlob(map).apply(status); + map.put(status.getId() + "", blob); + } catch (AuthorizationException e) { + throw e; + } catch (Exception e) { + logger.error(e, "Error storing tweet %s (blob[%s]) on map %s/%s", status.getId(), blob, context, container); + } + } + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if (request.getHeader("X-RUN@cloud-Submitter") != null + && request.getHeader("X-RUN@cloud-Submitter").equals("twitter")) { + try { + String contextName = checkNotNull(request.getHeader("context"), "missing header context"); + logger.info("retrieving tweets"); + addMyTweets(contextName, client.getMentions()); + logger.debug("done storing tweets"); + response.setContentType(MediaType.TEXT_PLAIN); + response.getWriter().println("Done!"); + } catch (Exception e) { + logger.error(e, "Error storing tweets"); + throw new ServletException(e); + } + } else { + response.sendError(401); + } + } +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java new file mode 100644 index 0000000000..eebd4b4c99 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/domain/StoredTweetStatus.java @@ -0,0 +1,149 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.domain; + +import java.io.Serializable; + +/** + * + * @author Adrian Cole + */ +public class StoredTweetStatus implements Comparable, Serializable { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3257496189689220018L; + private final String service; + private final String host; + private final String container; + private final String id; + private final String from; + private final String tweet; + private final String status; + + @Override + public String toString() { + return "StoredTweetStatus [container=" + container + ", from=" + from + ", host=" + host + + ", id=" + id + ", service=" + service + ", status=" + status + ", tweet=" + tweet + + "]"; + } + + public StoredTweetStatus(String service, String host, String container, String id, String from, + String tweet, String status) { + this.service = service; + this.host = host; + this.container = container; + this.id = id; + this.from = from; + this.tweet = tweet; + this.status = status; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((container == null) ? 0 : container.hashCode()); + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + ((host == null) ? 0 : host.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((service == null) ? 0 : service.hashCode()); + result = prime * result + ((tweet == null) ? 0 : tweet.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; + StoredTweetStatus other = (StoredTweetStatus) obj; + if (container == null) { + if (other.container != null) + return false; + } else if (!container.equals(other.container)) + return false; + if (from == null) { + if (other.from != null) + return false; + } else if (!from.equals(other.from)) + return false; + if (host == null) { + if (other.host != null) + return false; + } else if (!host.equals(other.host)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (service == null) { + if (other.service != null) + return false; + } else if (!service.equals(other.service)) + return false; + if (tweet == null) { + if (other.tweet != null) + return false; + } else if (!tweet.equals(other.tweet)) + return false; + return true; + } + + + public String getService() { + return service; + } + + public String getHost() { + return host; + } + + public String getContainer() { + return container; + } + + public String getFrom() { + return from; + } + + public String getTweet() { + return tweet; + } + + public String getStatus() { + return status; + } + + public int compareTo(StoredTweetStatus o) { + if (id == null) + return -1; + return (int) ((this == o) ? 0 : id.compareTo(o.id)); + } + + + public String getId() { + return id; + } + +} diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java new file mode 100644 index 0000000000..602e51ddc4 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatus.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.functions; + +import static org.jclouds.util.Strings2.toStringAndClose; + +import javax.annotation.Resource; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; + +/** + * + * @author Adrian Cole + */ +public class KeyToStoredTweetStatus implements Function { + private final String host; + private final BlobMap map; + private final String service; + private final String container; + + @Resource + protected Logger logger = Logger.NULL; + + KeyToStoredTweetStatus(BlobMap map, String service, String host, String container) { + this.host = host; + this.map = map; + this.service = service; + this.container = container; + } + + public StoredTweetStatus apply(String id) { + String status; + String from; + String tweet; + try { + long start = System.currentTimeMillis(); + Blob blob = map.get(id); + status = ((System.currentTimeMillis() - start) + "ms"); + from = blob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME); + tweet = toStringAndClose(blob.getPayload().getInput()); + } catch (Exception e) { + logger.error(e, "Error listing container %s//%s/$s", service, container, id); + status = (e.getMessage()); + tweet = ""; + from = ""; + } + return new StoredTweetStatus(service, host, container, id, from, tweet, status); + } +} diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java new file mode 100644 index 0000000000..1f3092a640 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatuses.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.functions; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.jclouds.logging.Logger; + +import com.google.common.base.Function; +import com.google.common.collect.Iterables; + +@Singleton +public class ServiceToStoredTweetStatuses implements Function> { + + private final Map contexts; + private final String container; + + @Inject + public ServiceToStoredTweetStatuses(Map contexts, + @Named(TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER) String container) { + this.contexts = contexts; + this.container = container; + } + + @Resource + protected Logger logger = Logger.NULL; + + public Iterable apply(String service) { + BlobStoreContext context = contexts.get(service); + String host = context.getProviderSpecificContext().getEndpoint().getHost(); + try { + BlobMap blobMap = context.createBlobMap(container); + Set blobs = blobMap.keySet(); + return Iterables.transform(blobs, new KeyToStoredTweetStatus(blobMap, service, host, + container)); + } catch (Exception e) { + StoredTweetStatus result = new StoredTweetStatus(service, host, container, null, null, + null, e.getMessage()); + logger.error(e, "Error listing service %s", service); + return Collections.singletonList(result); + } + + } +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java new file mode 100644 index 0000000000..4e75d5a7fa --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/java/org/jclouds/demo/tweetstore/reference/TweetStoreConstants.java @@ -0,0 +1,33 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.reference; + +/** + * Configuration properties and constants used in TweetStore connections. + * + * @author Adrian Cole + */ +public interface TweetStoreConstants { + public static final String PROPERTY_TWEETSTORE_CONTAINER = "jclouds.tweetstore.container"; + /** + * Note that this has to conform to restrictions of all blobstores. for example, azure doesn't + * support periods. + */ + public static final String SENDER_NAME = "sendername"; +} diff --git a/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/cloudbees-web.xml b/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/cloudbees-web.xml new file mode 100644 index 0000000000..607745f47c --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/cloudbees-web.xml @@ -0,0 +1,8 @@ + + + ${bees.appid} + + application.environment + ${bees.environment} + + \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/web.xml b/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9b5c1f3d3c --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,47 @@ + + + + jclouds-tweetstore + + + + guiceFilter + com.google.inject.servlet.GuiceFilter + + + + guiceFilter + /* + + + + org.jclouds.demo.tweetstore.config.GuiceServletConfig + + + + + index.jsp + + + \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/main/webapp/index.jsp b/demos/runatcloud-tweetstore/src/main/webapp/index.jsp new file mode 100644 index 0000000000..9b1238e1dd --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/webapp/index.jsp @@ -0,0 +1,31 @@ +<%-- + + + Copyright (C) 2011 Cloud Conscious, LLC. + + ==================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ==================================================================== + +--%> + + +jclouds: anyweight cloudware for java + + +

Welcome!

+Click +
here +to see tweets about jclouds. + + diff --git a/demos/runatcloud-tweetstore/src/main/webapp/tweets.jsp b/demos/runatcloud-tweetstore/src/main/webapp/tweets.jsp new file mode 100644 index 0000000000..677199188d --- /dev/null +++ b/demos/runatcloud-tweetstore/src/main/webapp/tweets.jsp @@ -0,0 +1,108 @@ +<%-- + + + Copyright (C) 2011 Cloud Conscious, LLC. + + ==================================================================== + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ==================================================================== + +--%> +<%@ page buffer="20kb"%> +<%@ taglib uri="http://displaytag.sf.net" prefix="display"%> + + +jclouds: anyweight cloudware for java + + + +

Tweets in Clouds

+ + + + +
+ +
+ + + + + + + + + + +
+
+ + diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java new file mode 100644 index 0000000000..f0a624d2b3 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/AddTweetsControllerTest.java @@ -0,0 +1,76 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.controller; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.functions.ServiceToStoredTweetStatuses; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; +import org.testng.collections.Maps; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + +/** + * Tests behavior of {@code AddTweetsController} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class AddTweetsControllerTest { + + Map createServices(String container) throws InterruptedException, + ExecutionException { + Map services = Maps.newHashMap(); + for (String name : new String[] { "1", "2" }) { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + context.getAsyncBlobStore().putBlob(container, blob).get(); + services.put(name, context); + } + return services; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + String container = "container"; + Map contexts = createServices(container); + + ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); + AddTweetsController controller = new AddTweetsController(contexts, function); + List list = controller.apply(ImmutableSet.of("1", "2")); + assertEquals(list.size(), 2); + assertEquals(list, ImmutableList.of(new StoredTweetStatus("1", "localhost", container, "1", + "frank", "I love beans!", null), new StoredTweetStatus("2", "localhost", container, + "1", "frank", "I love beans!", null))); + + } +} diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java new file mode 100644 index 0000000000..c8aaea43ba --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/controller/StoreTweetsControllerTest.java @@ -0,0 +1,118 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.controller; + +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.easymock.classextension.EasyMock.verify; +import static org.jclouds.util.Strings2.toStringAndClose; +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; + +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.User; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +/** + * Tests behavior of {@code StoreTweetsController} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class StoreTweetsControllerTest { + + Twitter createTwitter() { + return createMock(Twitter.class); + } + + Map createBlobStores() throws InterruptedException, ExecutionException { + Map contexts = ImmutableMap. of("test1", + new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"), "test2", + new BlobStoreContextFactory().createContext("transient", "dummy", "dummy")); + for (BlobStoreContext blobstore : contexts.values()) { + blobstore.getAsyncBlobStore().createContainerInLocation(null, "favo").get(); + } + return contexts; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + Map stores = createBlobStores(); + StoreTweetsController function = new StoreTweetsController(stores, "favo", createTwitter()); + + User frank = createMock(User.class); + expect(frank.getScreenName()).andReturn("frank").atLeastOnce(); + + Status frankStatus = createMock(Status.class); + expect(frankStatus.getId()).andReturn(1l).atLeastOnce(); + expect(frankStatus.getUser()).andReturn(frank).atLeastOnce(); + expect(frankStatus.getText()).andReturn("I love beans!").atLeastOnce(); + + User jimmy = createMock(User.class); + expect(jimmy.getScreenName()).andReturn("jimmy").atLeastOnce(); + + Status jimmyStatus = createMock(Status.class); + expect(jimmyStatus.getId()).andReturn(2l).atLeastOnce(); + expect(jimmyStatus.getUser()).andReturn(jimmy).atLeastOnce(); + expect(jimmyStatus.getText()).andReturn("cloud is king").atLeastOnce(); + + replay(frank); + replay(frankStatus); + replay(jimmy); + replay(jimmyStatus); + + function.addMyTweets("test1", ImmutableList.of(frankStatus, jimmyStatus)); + function.addMyTweets("test2", ImmutableList.of(frankStatus, jimmyStatus)); + + verify(frank); + verify(frankStatus); + verify(jimmy); + verify(jimmyStatus); + + for (Entry entry : stores.entrySet()) { + BlobMap map = entry.getValue().createBlobMap("favo"); + Blob frankBlob = map.get("1"); + assertEquals(frankBlob.getMetadata().getName(), "1"); + assertEquals(frankBlob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME), "frank"); + assertEquals(frankBlob.getMetadata().getContentMetadata().getContentType(), "text/plain"); + assertEquals(toStringAndClose(frankBlob.getPayload().getInput()), "I love beans!"); + + Blob jimmyBlob = map.get("2"); + assertEquals(jimmyBlob.getMetadata().getName(), "2"); + assertEquals(jimmyBlob.getMetadata().getUserMetadata().get(TweetStoreConstants.SENDER_NAME), "jimmy"); + assertEquals(jimmyBlob.getMetadata().getContentMetadata().getContentType(), "text/plain"); + assertEquals(toStringAndClose(jimmyBlob.getPayload().getInput()), "cloud is king"); + } + + } +} diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java new file mode 100644 index 0000000000..4f65c97f83 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/KeyToStoredTweetStatusTest.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobMap; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code KeyToStoredTweetStatus} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class KeyToStoredTweetStatusTest { + + BlobMap createMap() throws InterruptedException, ExecutionException { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", "dummy", "dummy"); + context.getBlobStore().createContainerInLocation(null, "test1"); + return context.createBlobMap("test1"); + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + BlobMap map = createMap(); + Blob blob = map.blobBuilder().name("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + map.put("1", blob); + String host = "localhost"; + String service = "stub"; + String container = "tweetstore"; + + KeyToStoredTweetStatus function = new KeyToStoredTweetStatus(map, service, host, container); + StoredTweetStatus result = function.apply("1"); + + StoredTweetStatus expected = new StoredTweetStatus(service, host, container, "1", "frank", + "I love beans!", null); + + assertEquals(result, expected); + + } +} diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java new file mode 100644 index 0000000000..c63d9821fb --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/functions/ServiceToStoredTweetStatusesTest.java @@ -0,0 +1,74 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.functions; + +import static org.testng.Assert.assertEquals; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.demo.tweetstore.domain.StoredTweetStatus; +import org.jclouds.demo.tweetstore.reference.TweetStoreConstants; +import org.testng.annotations.Test; +import org.testng.collections.Maps; + +import com.google.common.collect.Iterables; + +/** + * Tests behavior of {@code ServiceToStoredTweetStatuses} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class ServiceToStoredTweetStatusesTest { + + Map createServices(String container) throws InterruptedException, + ExecutionException { + Map services = Maps.newHashMap(); + for (String name : new String[] { "1", "2" }) { + BlobStoreContext context = new BlobStoreContextFactory().createContext("transient", + "dummy", "dummy"); + context.getAsyncBlobStore().createContainerInLocation(null, container).get(); + Blob blob = context.getAsyncBlobStore().blobBuilder("1").build(); + blob.getMetadata().getUserMetadata().put(TweetStoreConstants.SENDER_NAME, "frank"); + blob.setPayload("I love beans!"); + context.getAsyncBlobStore().putBlob(container, blob).get(); + services.put(name, context); + } + return services; + } + + public void testStoreTweets() throws IOException, InterruptedException, ExecutionException { + String container = "container"; + Map contexts = createServices(container); + + ServiceToStoredTweetStatuses function = new ServiceToStoredTweetStatuses(contexts, container); + + assertEquals(Iterables.getLast(function.apply("1")), new StoredTweetStatus("1", "localhost", + container, "1", "frank", "I love beans!", null)); + + assertEquals(Iterables.getLast(function.apply("2")), new StoredTweetStatus("2", "localhost", + container, "1", "frank", "I love beans!", null)); + + } +} diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java new file mode 100644 index 0000000000..75d3cb8177 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/RunAtCloudServer.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.integration; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +import javax.servlet.ServletException; + +import org.apache.commons.cli.ParseException; + +/** + * Basic functionality to start a local google app engine instance. + * + * @author Adrian Cole + */ +public class RunAtCloudServer { + protected StaxSdkAppServer2 server; + + public void writePropertiesAndStartServer(final String address, final String port, + final String warfile, final String environments, + final String serverBaseDirectory, Properties props) throws IOException, InterruptedException, ParseException, ServletException { + String filename = String.format( + "%1$s/WEB-INF/jclouds.properties", warfile); + System.err.println("file: " + filename); + props.store(new FileOutputStream(filename), "test"); + assert new File(filename).exists(); + server = StaxSdkAppServer2.createServer(new String[] { "-web", warfile, "-port", port, "-env", environments, + "-dir", serverBaseDirectory }, new String[0], Thread.currentThread().getContextClassLoader()); + server.start(); + TimeUnit.SECONDS.sleep(30); + } + + public void stop() throws Exception { + server.stop(); + } + +} \ No newline at end of file diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java new file mode 100644 index 0000000000..3d196a79a4 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/StaxSdkAppServer2.java @@ -0,0 +1,187 @@ +/* + * @(#)StaxSdkAppServer2.java 25 May 2011 + * + * Copyright © 2010 Andrew Phillips. + * + * ==================================================================== + * 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.demo.tweetstore.integration; + +import static com.google.common.base.Predicates.instanceOf; +import static java.util.Arrays.asList; +import static org.jclouds.demo.tweetstore.config.utils.ObjectFields.set; +import static org.jclouds.demo.tweetstore.config.utils.ObjectFields.valueOf; + +import java.io.File; +import java.io.IOException; +import java.util.Timer; + +import javax.servlet.ServletException; + +import net.stax.appserver.webapp.RequestMonitorValve; +import net.stax.appserver.webapp.WebAppEngine; + +import org.apache.catalina.Engine; +import org.apache.commons.cli.ParseException; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import com.staxnet.appserver.IAppServerConfiguration; +import com.staxnet.appserver.IEngineFactory; +import com.staxnet.appserver.ServerCallbackClient; +import com.staxnet.appserver.StaxAppServerBase; +import com.staxnet.appserver.StaxSdkAppServer; +import com.staxnet.appserver.StaxSdkAppServerCLI; +import com.staxnet.appserver.TomcatServerBase; +import com.staxnet.appserver.WarBasedServerConfiguration; +import com.staxnet.appserver.config.AppServerConfig; + +class StaxSdkAppServer2 { + // code more or less exactly from StaxSdkAppServer.java + public static StaxSdkAppServer2 createServer(String[] args, String[] classPaths, + ClassLoader cl) throws ParseException, ServletException { + StaxSdkAppServerCLI cli = StaxSdkAppServerCLI.parse(args); + if (cli.getMissingOptions().length > 0) { + throw new ParseException("Missing required options: " + cli.formatMissingOptions(", ")); + } + + String[] environments = cli.getEnvironment(); + File serverConfig = cli.getServerConfigFile(); + File baseDir = new File(cli.getBaseDir()); + File webRoot = new File(cli.getWebdir()); + File workDir = new File(baseDir, "work"); + + File staxWebXml = new File(webRoot, "WEB-INF/cloudbees-web.xml"); + if (!(staxWebXml.exists())) + staxWebXml = new File(webRoot, "WEB-INF/stax-web.xml"); + IAppServerConfiguration config = WarBasedServerConfiguration.load( + serverConfig, webRoot, staxWebXml, environments); + // force the RequestMonitorValve to sleep for only a short period + set("statusInterval", StaxReflect.getAppServerConfig(config), 5); + StaxSdkAppServer server = new StaxSdkAppServer( + baseDir.getAbsolutePath(), workDir.getAbsolutePath(), cl, + classPaths, cli.getPort(), config, cli.getRepositoryPath()); + return new StaxSdkAppServer2(server); + } + + private final StaxSdkAppServer server; + private Thread serverThread; + + private StaxSdkAppServer2(StaxSdkAppServer server) { + this.server = server; + serverThread = new Thread(new Runnable() { + public void run() { + try { + StaxSdkAppServer2.this.server.start(); + } catch (ServletException exception) { + System.err.println("exception starting server: " + exception); + } + } + }); + } + + void start() throws ServletException { + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + public void run() { + stop(); + } + })); + serverThread.start(); + } + + void stop() { + server.stop(); + serverThread.interrupt(); + StaxReflect.getStaxAppQueryTimer(server).cancel(); + KillerCallback requestMonitorAssassin = new KillerCallback(StaxReflect.getRequestMonitorTimerCallback(server)); + set("callbackClient", StaxReflect.getRequestMonitorTimer(server), requestMonitorAssassin); + requestMonitorAssassin.setToKill(); + } + + private class KillerCallback extends ServerCallbackClient { + private final ServerCallbackClient delegate; + private volatile boolean killCaller = false; + + private KillerCallback(ServerCallbackClient delegate) { + super("", ""); + this.delegate = delegate; + } + + @Override + public AuthenticationResult getApplicationTicket(String username, + String password) throws IOException { + return delegate.getApplicationTicket(username, password); + } + + @Override + public AuthenticationResult renewApplicationTicket(String userAuthTicket) + throws IOException { + return delegate.renewApplicationTicket(userAuthTicket); + } + + @Override + public void updateStatus(State state) throws ServletException, + IOException { + if (killCaller) { + throw new ThreadDeath(); + } + delegate.updateStatus(state); + } + + private void setToKill() { + killCaller = true; + } + } + + private static class StaxReflect { + private static WebAppEngine getWebAppEngine(StaxSdkAppServer server) { + return (WebAppEngine) Iterables.find(asList((IEngineFactory[]) + valueOf("engineFactories", server, StaxAppServerBase.class)), + instanceOf(WebAppEngine.class)); + } + + private static Timer getStaxAppQueryTimer(StaxSdkAppServer server) { + return (Timer) valueOf("timer", getWebAppEngine(server)); + } + + private static AppServerConfig getAppServerConfig(IAppServerConfiguration config) { + return (AppServerConfig) valueOf("appServerConfig", config); + } + + private static Engine getLocalEngine(StaxSdkAppServer server) { + return (Engine) Iterables.find(asList((Engine[]) + valueOf("engines", valueOf("container", server, TomcatServerBase.class))), + new Predicate() { + @Override + public boolean apply(Engine input) { + return input.getName().equals("localEngine"); + } + }); + } + + private static Runnable getRequestMonitorTimer(StaxSdkAppServer server) { + return (Runnable) valueOf("idleTimer", Iterables.find( + asList(getLocalEngine(server).getPipeline().getValves()), + instanceOf(RequestMonitorValve.class))); + } + + private static ServerCallbackClient getRequestMonitorTimerCallback( + StaxSdkAppServer server) { + return (ServerCallbackClient) valueOf("callbackClient", + getRequestMonitorTimer(server)); + } + } +} diff --git a/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java new file mode 100644 index 0000000000..7ab92ebce2 --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/java/org/jclouds/demo/tweetstore/integration/TweetStoreLiveTest.java @@ -0,0 +1,218 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.demo.tweetstore.integration; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.demo.tweetstore.reference.TweetStoreConstants.PROPERTY_TWEETSTORE_CONTAINER; + +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.demo.tweetstore.config.GuiceServletConfig; +import org.jclouds.demo.tweetstore.controller.StoreTweetsController; +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.util.Strings2; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import twitter4j.ResponseList; +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterException; +import twitter4j.TwitterFactory; +import twitter4j.conf.Configuration; +import twitter4j.conf.ConfigurationBuilder; + +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.inject.Module; + +/** + * Starts up the Google App Engine for Java Development environment and deploys an application which + * tests accesses twitter and blobstores. + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true) +public class TweetStoreLiveTest { + + RunAtCloudServer server; + private URL url; + private Map contexts; + private String container; + private static final Iterable blobstores = + Splitter.on(',').split(System.getProperty("jclouds.tweetstore.blobstores", + "cloudfiles-us,aws-s3,azureblob")); + private static final Properties props = new Properties(); + + @BeforeTest + void clearAndCreateContainers() throws InterruptedException, ExecutionException, TimeoutException, IOException, + TwitterException { + container = checkNotNull(System.getProperty(PROPERTY_TWEETSTORE_CONTAINER), PROPERTY_TWEETSTORE_CONTAINER); + + props.setProperty(PROPERTY_TWEETSTORE_CONTAINER, container); + props.setProperty(GuiceServletConfig.PROPERTY_BLOBSTORE_CONTEXTS, Joiner.on(',').join(blobstores)); + + // put all identity/credential pairs into the client + addCredentialsForBlobStores(props); + + // example of an ad-hoc client configuration + addConfigurationForTwitter(props); + + final BlobStoreContextFactory factory = new BlobStoreContextFactory(); + // for testing, capture logs. + final Set wiring = ImmutableSet. of(new Log4JLoggingModule()); + this.contexts = Maps.newConcurrentMap(); + + for (String provider : blobstores) { + contexts.put(provider, factory.createContext(provider, wiring, props)); + } + + Configuration conf = new ConfigurationBuilder() + .setUser(props.getProperty("twitter.identity")) + .setPassword(props.getProperty("twitter.credential")).build(); + Twitter client = new TwitterFactory(conf).getInstance(); + StoreTweetsController controller = new StoreTweetsController(contexts, container, client); + + ResponseList statuses = client.getMentions(); + + boolean deleted = false; + for (BlobStoreContext context : contexts.values()) { + try { + if (context.getBlobStore().containerExists(container)) { + System.err.printf("deleting container %s at %s%n", container, context.getProviderSpecificContext() + .getEndpoint()); + context.getBlobStore().deleteContainer(container); + deleted = true; + } + } catch (AuthorizationException e) { + throw new AuthorizationException("for context: " + context, e); + } + } + if (deleted) { + System.err.println("sleeping 60 seconds to allow containers to clear"); + Thread.sleep(60000); + } + for (BlobStoreContext context : contexts.values()) { + System.err.printf("creating container %s at %s%n", container, context.getProviderSpecificContext() + .getEndpoint()); + context.getBlobStore().createContainerInLocation(null, container); + } + + if (deleted) { + System.err.println("sleeping 5 seconds to allow containers to create"); + Thread.sleep(5000); + } + + for (Entry entry : contexts.entrySet()) { + System.err.printf("filling container %s at %s%n", container, entry.getKey()); + controller.addMyTweets(entry.getKey(), statuses); + } + } + + @BeforeTest(dependsOnMethods = "clearAndCreateContainers") + @Parameters({ "warfile", "bees.address", "bees.port", "bees.environment", "bees.basedir" }) + public void startDevAppServer(final String warfile, final String address, final String port, + String environments, String serverBaseDirectory) throws Exception { + url = new URL(String.format("http://%s:%s", address, port)); + + server = new RunAtCloudServer(); + server.writePropertiesAndStartServer(address, port, warfile, environments, + serverBaseDirectory, props); + } + + private void addConfigurationForTwitter(Properties props) { + props.setProperty("twitter.identity", checkNotNull(System.getProperty("test.twitter.identity"), "test.twitter.identity")); + props.setProperty("twitter.credential", + checkNotNull(System.getProperty("test.twitter.credential"), "test.twitter.credential")); + } + + private void addCredentialsForBlobStores(Properties props) { + for (String provider : blobstores) { + props.setProperty(provider + ".identity", + checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity")); + props.setProperty(provider + ".credential", + checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider + ".credential")); + } + } + + @Test + public void shouldPass() throws InterruptedException, IOException { + InputStream i = url.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Welcome") >= 0 : string; + } + + @Test(dependsOnMethods = "shouldPass", expectedExceptions = IOException.class) + public void shouldFail() throws InterruptedException, IOException { + new URL(url, "/store/do").openStream(); + } + + @Test(dependsOnMethods = "shouldFail") + public void testPrimeContainers() throws IOException, InterruptedException { + URL gurl = new URL(url, "/store/do"); + + for (String context : blobstores) { + System.out.println("storing at context: " + context); + HttpURLConnection connection = (HttpURLConnection) gurl.openConnection(); + connection.addRequestProperty("X-AppEngine-QueueName", "twitter"); + connection.addRequestProperty("context", context); + InputStream i = connection.getInputStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Done!") >= 0 : string; + connection.disconnect(); + } + + System.err.println("sleeping 20 seconds to allow for eventual consistency delay"); + Thread.sleep(20000); + for (BlobStoreContext context : contexts.values()) { + assert context.createInputStreamMap(container).size() > 0 : context.getProviderSpecificContext().getEndpoint(); + } + } + + @Test(invocationCount = 5, dependsOnMethods = "testPrimeContainers") + public void testSerial() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } + + @Test(invocationCount = 10, dependsOnMethods = "testPrimeContainers", threadPoolSize = 3) + public void testParallel() throws InterruptedException, IOException { + URL gurl = new URL(url, "/tweets/get"); + InputStream i = gurl.openStream(); + String string = Strings2.toStringAndClose(i); + assert string.indexOf("Tweets in Clouds") >= 0 : string; + } +} diff --git a/demos/runatcloud-tweetstore/src/test/resources/log4j.xml b/demos/runatcloud-tweetstore/src/test/resources/log4j.xml new file mode 100644 index 0000000000..033a95384d --- /dev/null +++ b/demos/runatcloud-tweetstore/src/test/resources/log4j.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/speedtest-azurequeue/README.txt b/demos/speedtest-azurequeue/README.txt old mode 100755 new mode 100644 diff --git a/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java b/demos/speedtest-azurequeue/src/main/java/org/jclouds/azure/azurequeue/SpeedTest.java old mode 100755 new mode 100644 diff --git a/demos/speedtest-sqs/README.txt b/demos/speedtest-sqs/README.txt old mode 100755 new mode 100644 diff --git a/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java b/demos/speedtest-sqs/src/main/java/org/jclouds/aws/sqs/SpeedTest.java old mode 100755 new mode 100644 diff --git a/drivers/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/config/BouncyCastleCryptoModule.java b/drivers/bouncycastle/src/main/java/org/jclouds/encryption/bouncycastle/config/BouncyCastleCryptoModule.java old mode 100755 new mode 100644 diff --git a/drivers/enterprise/src/main/java/org/jclouds/enterprise/config/EnterpriseConfigurationModule.java b/drivers/enterprise/src/main/java/org/jclouds/enterprise/config/EnterpriseConfigurationModule.java old mode 100755 new mode 100644 diff --git a/drivers/joda/src/main/java/org/jclouds/date/joda/JodaDateService.java b/drivers/joda/src/main/java/org/jclouds/date/joda/JodaDateService.java old mode 100755 new mode 100644 diff --git a/drivers/joda/src/main/java/org/jclouds/date/joda/config/JodaDateServiceModule.java b/drivers/joda/src/main/java/org/jclouds/date/joda/config/JodaDateServiceModule.java old mode 100755 new mode 100644 diff --git a/drivers/joda/src/test/java/org/jclouds/date/joda/JodaDateServiceTest.java b/drivers/joda/src/test/java/org/jclouds/date/joda/JodaDateServiceTest.java old mode 100755 new mode 100644 diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java old mode 100755 new mode 100644 diff --git a/drivers/log4j/src/test/resources/log4j.xml b/drivers/log4j/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/project/pom.xml b/project/pom.xml index 7f57c42c5f..111c785f7f 100644 --- a/project/pom.xml +++ b/project/pom.xml @@ -182,10 +182,10 @@ davs://jclouds.googlecode.com/svn/maven-sites - http://mirror.cloudera.com/apache/maven/binaries/apache-maven-2.2.1-bin.tar.bz2 - c581a15cb0001d9b771ad6df7c8156f8 http://apache.opensourceresources.org/commons/logging/binaries/commons-logging-1.1.1-bin.tar.gz e5de09672af9b386c30a311654d8541a + ${jclouds.wire.httpstream.url} + ${jclouds.wire.httpstream.md5} org.jclouds.test.testng.UnitTestStatusListener diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index ec019b4e12..ed15d0962a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -39,6 +39,7 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -55,30 +56,32 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return false; - case CENTOS: - return !(input.version.matches("5.[42]") || input.version.equals("")); - case WINDOWS: - return !(input.version.matches("200[38]") || input.version.equals("")); - default: return true; + case DEBIAN: + return true; + case CENTOS: + return input.version.matches("5.[42]") || input.version.equals(""); + case WINDOWS: + return input.version.matches("200[38]") || input.version.equals(""); + default: + return false; } } - }; + }); } @Test public void testTemplateBuilderM1SMALLWithDescription() { Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL) - .osVersionMatches("10.10").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU).build(); + .osVersionMatches("1[10].[10][04]").imageDescriptionMatches("ubuntu-images").osFamily(OsFamily.UBUNTU).build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; assertEquals(template.getImage().getOperatingSystem().getVersion(), "10.10"); diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java new file mode 100644 index 0000000000..331a1702cb --- /dev/null +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.azureblob; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Blob Service. + * + * @author Adrian Cole + */ +public class AzureBlobProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "azureblob"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Microsoft Azure Blob Service"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Account Name"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Access Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.microsoft.com/windowsazure/storage/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://windows.azure.com/default.aspx"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("azureblob", "azurequeue", "azuretable"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-TX","US-IL","IE-D","SG","NL-NH","HK"); + } + +} \ No newline at end of file diff --git a/providers/azureblob/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/azureblob/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..f5f5631a61 --- /dev/null +++ b/providers/azureblob/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.azureblob.AzureBlobProviderMetadata diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java new file mode 100644 index 0000000000..f8df67304b --- /dev/null +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.azureblob; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "AzureBlobProviderTest") +public class AzureBlobProviderTest extends BaseProviderMetadataTest { + + public AzureBlobProviderTest() { + super(new AzureBlobProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } +} \ No newline at end of file diff --git a/providers/azureblob/src/test/resources/log4j.xml b/providers/azureblob/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorContextBuilder.java b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorContextBuilder.java similarity index 86% rename from providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorContextBuilder.java rename to providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorContextBuilder.java index e01aab7340..8df5951a8e 100644 --- a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorContextBuilder.java +++ b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorContextBuilder.java @@ -24,7 +24,7 @@ import java.util.Properties; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.vcloud.VCloudContextBuilder; -import org.jclouds.vcloud.bluelock.config.BlueLockVCloudDirectorRestClientModule; +import org.jclouds.vcloud.bluelock.config.BluelockVCloudDirectorRestClientModule; import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; import com.google.inject.Injector; @@ -41,11 +41,10 @@ import com.google.inject.Module; * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole - * @see BlueLockVCloudComputeServiceContext */ -public class BlueLockVCloudDirectorContextBuilder extends VCloudContextBuilder { +public class BluelockVCloudDirectorContextBuilder extends VCloudContextBuilder { - public BlueLockVCloudDirectorContextBuilder(Properties props) { + public BluelockVCloudDirectorContextBuilder(Properties props) { super(props); } @@ -56,7 +55,7 @@ public class BlueLockVCloudDirectorContextBuilder extends VCloudContextBuilder { @Override protected void addClientModule(List modules) { - modules.add(new BlueLockVCloudDirectorRestClientModule()); + modules.add(new BluelockVCloudDirectorRestClientModule()); } } diff --git a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorPropertiesBuilder.java b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java similarity index 92% rename from providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorPropertiesBuilder.java rename to providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java index 3954b3fe50..899a3912ee 100644 --- a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorPropertiesBuilder.java +++ b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorPropertiesBuilder.java @@ -31,7 +31,7 @@ import org.jclouds.vcloud.VCloudPropertiesBuilder; * * @author Adrian Cole */ -public class BlueLockVCloudDirectorPropertiesBuilder extends VCloudPropertiesBuilder { +public class BluelockVCloudDirectorPropertiesBuilder extends VCloudPropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); @@ -41,7 +41,7 @@ public class BlueLockVCloudDirectorPropertiesBuilder extends VCloudPropertiesBui return properties; } - public BlueLockVCloudDirectorPropertiesBuilder(Properties properties) { + public BluelockVCloudDirectorPropertiesBuilder(Properties properties) { super(properties); } } diff --git a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderMetadata.java b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderMetadata.java new file mode 100644 index 0000000000..17c285f082 --- /dev/null +++ b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Bluelock vCloud Director. + * + * @author Adrian Cole + */ +public class BluelockVCloudDirectorProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "bluelock-vcdirector"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Bluelock vCloud Director"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "User at Organization (user@org)"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Password"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.bluelock.com/bluelock-cloud-hosting"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://vcenterprise.bluelock.com/cloud/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("bluelock-vcdirector"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-IN"); + } + +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudDirectorRestClientModule.java b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BluelockVCloudDirectorRestClientModule.java similarity index 94% rename from providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudDirectorRestClientModule.java rename to providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BluelockVCloudDirectorRestClientModule.java index 20539e7719..656876228e 100644 --- a/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BlueLockVCloudDirectorRestClientModule.java +++ b/providers/bluelock-vcdirector/src/main/java/org/jclouds/vcloud/bluelock/config/BluelockVCloudDirectorRestClientModule.java @@ -29,6 +29,6 @@ import org.jclouds.vcloud.config.VCloudRestClientModule; */ @RequiresHttp @ConfiguresRestClient -public class BlueLockVCloudDirectorRestClientModule extends VCloudRestClientModule { +public class BluelockVCloudDirectorRestClientModule extends VCloudRestClientModule { } diff --git a/providers/bluelock-vcdirector/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/bluelock-vcdirector/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..641c685c91 --- /dev/null +++ b/providers/bluelock-vcdirector/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.vcloud.bluelock.BluelockVCloudDirectorProviderMetadata diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/ProvidersInPropertiesTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderTest.java similarity index 58% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/ProvidersInPropertiesTest.java rename to providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderTest.java index ea8df16d06..ca9fcf63b4 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/ProvidersInPropertiesTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BluelockVCloudDirectorProviderTest.java @@ -18,31 +18,18 @@ */ package org.jclouds.vcloud.bluelock; -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "bluelock-vcdirector") : providers; +@Test(groups = "unit", testName = "BluelockVCloudDirectorProviderTest") +public class BluelockVCloudDirectorProviderTest extends BaseProviderMetadataTest { + public BluelockVCloudDirectorProviderTest() { + super(new BluelockVCloudDirectorProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "bluelock-vcdirector") : providers; - } - -} +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/DeprecatedBluelockVCloudDirectorClientLiveTest.java similarity index 73% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorClientLiveTest.java rename to providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/DeprecatedBluelockVCloudDirectorClientLiveTest.java index 9b0502d31c..c6635364b2 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorClientLiveTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/DeprecatedBluelockVCloudDirectorClientLiveTest.java @@ -18,17 +18,17 @@ */ package org.jclouds.vcloud.bluelock; -import org.jclouds.vcloud.VCloudClientLiveTest; +import org.jclouds.vcloud.DeprecatedVCloudClientLiveTest; import org.testng.annotations.Test; /** - * Tests behavior of {@code BlueLockVCloudClient} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true) -public class BlueLockVCloudDirectorClientLiveTest extends VCloudClientLiveTest { - public BlueLockVCloudDirectorClientLiveTest() { +@Deprecated +@Test(groups = "live", singleThreaded = true, testName = "DeprecatedBluelockVCloudDirectorClientLiveTest") +public class DeprecatedBluelockVCloudDirectorClientLiveTest extends DeprecatedVCloudClientLiveTest { + public DeprecatedBluelockVCloudDirectorClientLiveTest() { provider = "bluelock-vcdirector"; } diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorComputeServiceLiveTest.java similarity index 87% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java rename to providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorComputeServiceLiveTest.java index fa4c03ae22..0cf76f581c 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorComputeServiceLiveTest.java @@ -34,10 +34,12 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", enabled = true, sequential = true) -public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeServiceLiveTest { - public BlueLockVCloudDirectorComputeServiceLiveTest() { +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorComputeServiceLiveTest") +public class BluelockVCloudDirectorComputeServiceLiveTest extends VCloudComputeServiceLiveTest { + public BluelockVCloudDirectorComputeServiceLiveTest() { provider = "bluelock-vcdirector"; + // vcloud requires instantiate before deploy, which takes longer than 30 seconds + nonBlockDuration = 300; } @Override diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorTemplateBuilderLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorTemplateBuilderLiveTest.java similarity index 89% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorTemplateBuilderLiveTest.java rename to providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorTemplateBuilderLiveTest.java index c086966e3a..d33902b673 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorTemplateBuilderLiveTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/compute/BluelockVCloudDirectorTemplateBuilderLiveTest.java @@ -37,10 +37,10 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -@Test(groups = "live") -public class BlueLockVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { +@Test(groups = "live", testName = "BluelockVCloudDirectorTemplateBuilderLiveTest") +public class BluelockVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - public BlueLockVCloudDirectorTemplateBuilderLiveTest() { + public BluelockVCloudDirectorTemplateBuilderLiveTest() { provider = "bluelock-vcdirector"; } @@ -52,7 +52,7 @@ public class BlueLockVCloudDirectorTemplateBuilderLiveTest extends BaseTemplateB public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !input.version.equals(""); + return !input.version.equals("") || !input.is64Bit; default: return true; } diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorCatalogClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorCatalogClientLiveTest.java new file mode 100644 index 0000000000..c19a5ee58f --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorCatalogClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.CatalogClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorCatalogClientLiveTest") +public class BluelockVCloudDirectorCatalogClientLiveTest extends CatalogClientLiveTest { + + public BluelockVCloudDirectorCatalogClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorNetworkClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorNetworkClientLiveTest.java new file mode 100644 index 0000000000..27bf92d17d --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorNetworkClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.NetworkClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorNetworkClientLiveTest") +public class BluelockVCloudDirectorNetworkClientLiveTest extends NetworkClientLiveTest { + + public BluelockVCloudDirectorNetworkClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorOrgClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorOrgClientLiveTest.java new file mode 100644 index 0000000000..de188132f4 --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorOrgClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.OrgClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorOrgClientLiveTest") +public class BluelockVCloudDirectorOrgClientLiveTest extends OrgClientLiveTest { + + public BluelockVCloudDirectorOrgClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorTaskClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorTaskClientLiveTest.java new file mode 100644 index 0000000000..cb9fba9d43 --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorTaskClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.TaskClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorTaskClientLiveTest") +public class BluelockVCloudDirectorTaskClientLiveTest extends TaskClientLiveTest { + + public BluelockVCloudDirectorTaskClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppClientLiveTest.java new file mode 100644 index 0000000000..12d258a015 --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.VAppClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorVAppClientLiveTest") +public class BluelockVCloudDirectorVAppClientLiveTest extends VAppClientLiveTest { + + public BluelockVCloudDirectorVAppClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppTemplateClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppTemplateClientLiveTest.java new file mode 100644 index 0000000000..02700fab35 --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVAppTemplateClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.VAppTemplateClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorVAppTemplateClientLiveTest") +public class BluelockVCloudDirectorVAppTemplateClientLiveTest extends VAppTemplateClientLiveTest { + + public BluelockVCloudDirectorVAppTemplateClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVDCClientLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVDCClientLiveTest.java new file mode 100644 index 0000000000..3dff1a957d --- /dev/null +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVDCClientLiveTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.vcloud.bluelock.features; + +import org.jclouds.vcloud.features.VDCClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * + * @author Adrian Cole + */ +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorVDCClientLiveTest") +public class BluelockVCloudDirectorVDCClientLiveTest extends VDCClientLiveTest { + + public BluelockVCloudDirectorVDCClientLiveTest() { + provider = "bluelock-vcdirector"; + } +} \ No newline at end of file diff --git a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorGuestCustomizationLiveTest.java b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVmClientLiveTest.java similarity index 74% rename from providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorGuestCustomizationLiveTest.java rename to providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVmClientLiveTest.java index 0f2284c210..fdb44fcd77 100644 --- a/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/BlueLockVCloudDirectorGuestCustomizationLiveTest.java +++ b/providers/bluelock-vcdirector/src/test/java/org/jclouds/vcloud/bluelock/features/BluelockVCloudDirectorVmClientLiveTest.java @@ -16,9 +16,9 @@ * limitations under the License. * ==================================================================== */ -package org.jclouds.vcloud.bluelock; +package org.jclouds.vcloud.bluelock.features; -import org.jclouds.vcloud.VCloudGuestCustomizationLiveTest; +import org.jclouds.vcloud.features.VmClientLiveTest; import org.testng.annotations.Test; /** @@ -26,14 +26,13 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", enabled = true, sequential = true) -public class BlueLockVCloudDirectorGuestCustomizationLiveTest extends VCloudGuestCustomizationLiveTest { +@Test(groups = "live", enabled = true, singleThreaded = true, testName = "BluelockVCloudDirectorVmClientLiveTest") +public class BluelockVCloudDirectorVmClientLiveTest extends VmClientLiveTest { - public BlueLockVCloudDirectorGuestCustomizationLiveTest() { + public BluelockVCloudDirectorVmClientLiveTest() { provider = "bluelock-vcdirector"; } - @Override protected void checkApiOutput(String apiOutput) { checkApiOutput1_0_0(apiOutput); } diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java new file mode 100644 index 0000000000..4285661e53 --- /dev/null +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Consciouk, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not uke 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.rackspace.cloudfiles; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files in UK. + * + * @author Adrian Cole + */ +public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudfiles-uk"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Rackspace Cloud Files UK"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://lon.manage.rackspacecloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudfiles-uk", "cloudservers-uk"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("GB-SLG"); + } + +} \ No newline at end of file diff --git a/providers/cloudfiles-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudfiles-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..2843a8883e --- /dev/null +++ b/providers/cloudfiles-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.rackspace.cloudfiles.CloudFilesUKProviderMetadata diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java new file mode 100644 index 0000000000..286a54d555 --- /dev/null +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rackspace.cloudfiles; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudFilesUKProviderTest") +public class CloudFilesUKProviderTest extends BaseProviderMetadataTest { + + public CloudFilesUKProviderTest() { + super(new CloudFilesUKProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } +} \ No newline at end of file diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java new file mode 100644 index 0000000000..168e170f30 --- /dev/null +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rackspace.cloudfiles; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files in US. + * + * @author Adrian Cole + */ +public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudfiles-us"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.BLOBSTORE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Rackspace Cloud Files US"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/files"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://manage.rackspacecloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-IL","US-TX"); + } + +} \ No newline at end of file diff --git a/providers/cloudfiles-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudfiles-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..9dca819360 --- /dev/null +++ b/providers/cloudfiles-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.rackspace.cloudfiles.CloudFilesUSProviderMetadata diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java new file mode 100644 index 0000000000..4923b7e112 --- /dev/null +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rackspace.cloudfiles; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudFilesUSProviderTest") +public class CloudFilesUSProviderTest extends BaseProviderMetadataTest { + + public CloudFilesUSProviderTest() { + super(new CloudFilesUSProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + } +} \ No newline at end of file diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java new file mode 100644 index 0000000000..eb3e161234 --- /dev/null +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.cloudloadbalancers; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers in US. + * + * @author Adrian Cole + */ +public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudloadbalancers-us"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.LOADBALANCER_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Rackspace Cloud Load Balancers US"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://manage.rackspacecloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-IL","US-TX"); + } + +} \ No newline at end of file diff --git a/providers/cloudloadbalancers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudloadbalancers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..641276781b --- /dev/null +++ b/providers/cloudloadbalancers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.cloudloadbalancers.CloudLoadBalancersUSProviderMetadata diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java new file mode 100644 index 0000000000..8e79e6b19d --- /dev/null +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.cloudloadbalancers; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudLoadBalancersUSProviderTest") +public class CloudLoadBalancersUSProviderTest extends BaseProviderMetadataTest { + + public CloudLoadBalancersUSProviderTest() { + super(new CloudLoadBalancersUSProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); + } +} \ No newline at end of file diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java new file mode 100644 index 0000000000..7268e4372b --- /dev/null +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Consciouk, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not uke 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.rackspace.cloudservers; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers. + * + * @author Adrian Cole + */ +public class CloudServersUKProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudservers-uk"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Rackspace Cloud Servers UK"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://lon.manage.rackspacecloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudfiles-uk", "cloudservers-uk"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("GB-SLG"); + } + +} \ No newline at end of file diff --git a/providers/cloudservers-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudservers-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..97c28423fa --- /dev/null +++ b/providers/cloudservers-uk/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.rackspace.cloudservers.CloudServersUKProviderMetadata diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java new file mode 100644 index 0000000000..ab46341a54 --- /dev/null +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java @@ -0,0 +1,34 @@ +/** + * + * + * ==================================================================== + * 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.rackspace.cloudservers; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudServersUKProviderTest") +public class CloudServersUKProviderTest extends BaseProviderMetadataTest { + + public CloudServersUKProviderTest() { + super(new CloudServersUKProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index adf8d8dd1b..9dcb7d1b4a 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,31 +46,33 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.equals("11.04") || input.version.equals("8.04") || !input.is64Bit; + return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + case DEBIAN: + return !(input.version.equals("6.0")) && input.is64Bit; case CENTOS: - return input.version.matches("5.[023]") || !input.is64Bit; + return (input.version.equals("") || input.version.matches("5.[45]")) && input.is64Bit; case WINDOWS: - return input.version.equals("2008") || input.version.indexOf("2003") != -1 - || (input.version.equals("2008 R2") && !input.is64Bit); + return input.version.equals("2008 SP2") || input.version.equals("") + || (input.version.equals("2008 R2") && input.is64Bit); default: - return true; + return false; } } - }; + }); } @Test public void testTemplateBuilder() { Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), provider); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java new file mode 100644 index 0000000000..9329090816 --- /dev/null +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.rackspace.cloudservers; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers in US. + * + * @author Adrian Cole + */ +public class CloudServersUSProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "cloudservers-us"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Rackspace Cloud Servers US"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Username"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/servers"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://manage.rackspacecloud.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-IL", "US-TX"); + } + +} \ No newline at end of file diff --git a/providers/cloudservers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/cloudservers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..66f2859ba8 --- /dev/null +++ b/providers/cloudservers-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.rackspace.cloudservers.CloudServersUSProviderMetadata diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java new file mode 100644 index 0000000000..a05573818b --- /dev/null +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java @@ -0,0 +1,34 @@ +/** + * + * + * ==================================================================== + * 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.rackspace.cloudservers; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudServersUSProviderTest") +public class CloudServersUSProviderTest extends BaseProviderMetadataTest { + + public CloudServersUSProviderTest() { + super(new CloudServersUSProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index e9980126e7..64ee3620ae 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,31 +46,33 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return input.version.equals("11.04") || input.version.equals("8.04") || !input.is64Bit; + return !(input.version.equals("11.04") || input.version.equals("8.04")) && input.is64Bit; + case DEBIAN: + return !(input.version.equals("6.0")) && input.is64Bit; case CENTOS: - return input.version.matches("5.[023]") || !input.is64Bit; + return !(input.version.matches("5.[023]")) && input.is64Bit; case WINDOWS: - return input.version.equals("2008") || input.version.indexOf("2003") != -1 - || (input.version.equals("2008 R2") && !input.is64Bit); + return input.version.equals("2008 SP2") || input.version.equals("") + || (input.version.equals("2008 R2") && input.is64Bit); default: - return true; + return false; } } - }; + }); } @Test public void testTemplateBuilder() { Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), provider); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java index 124946aa13..18b2d365ff 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java @@ -77,7 +77,7 @@ public class CloudSigmaComputeServiceContextModule @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true).minRam(1024); + return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true).minRam(1024); } @SuppressWarnings({ "unchecked", "rawtypes" }) diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java index e5935562f3..69e21df67a 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/ParseOsFamilyVersion64BitFromImageName.java @@ -23,13 +23,16 @@ import static com.google.common.base.Predicates.containsPattern; import static com.google.common.base.Predicates.not; import static com.google.common.base.Predicates.or; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.util.ComputeServiceUtils; import com.google.common.base.Function; @@ -42,6 +45,12 @@ import com.google.common.base.Function; */ @Singleton public class ParseOsFamilyVersion64BitFromImageName implements Function { + private final Map> osVersionMap; + + @Inject + public ParseOsFamilyVersion64BitFromImageName(Map> osVersionMap) { + this.osVersionMap = osVersionMap; + } // ex CentOS 5.5 Linux 64bit Preinstalled System with AppFirst Monitoring public static final Pattern PATTERN = Pattern.compile("([^ ]+)[^0-9]([0-9.]+) .*"); @@ -49,7 +58,7 @@ public class ParseOsFamilyVersion64BitFromImageName implements Function { if (drive.getName() == null) return null; String description = drive.getDescription() != null ? drive.getDescription() : drive.getName(); - OperatingSystemBuilder builder = new OperatingSystemBuilder(); + Builder builder = OperatingSystem.builder(); OsFamilyVersion64Bit parsed = imageParser.apply(drive.getName()); builder.name(drive.getName()).description(description).is64Bit(parsed.is64Bit).version(parsed.version).family( parsed.family); diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java index c9d0fb16f6..ae2dcd7824 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,31 +47,33 @@ public class CloudSigmaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !input.version.equals("") && !(input.version.equals("10.10") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.04")) + || !(input.version.matches("^[89].*")) && input.is64Bit; + case DEBIAN: + return input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.matches("5.[05]")) && input.is64Bit; case WINDOWS: - return !((input.version.equals("2008 R2") && input.is64Bit) - || (input.version.equals("2008") && !input.is64Bit) || input.version.equals("") || (input.version - .equals("2003"))); + return (input.version.equals("2008 R2") && input.is64Bit) + || (input.version.equals("2008") && !input.is64Bit) || input.version.equals("") + || (input.version.equals("2003")); default: - return true; + return false; } } - }; + }); } @Override public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java index d9f506c43f..729a35c9aa 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/functions/ParseOsFamilyVersion64BitFromImageNameTest.java @@ -28,8 +28,11 @@ import java.util.Map; import java.util.Map.Entry; import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName; +import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.json.Json; +import org.jclouds.json.config.GsonModule; import org.jclouds.json.internal.GsonWrapper; import org.jclouds.util.Strings2; import org.testng.annotations.DataProvider; @@ -37,6 +40,7 @@ import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.gson.Gson; +import com.google.inject.Guice; import com.google.inject.TypeLiteral; /** @@ -65,7 +69,9 @@ public class ParseOsFamilyVersion64BitFromImageNameTest { })).toArray(new Object[][] {}); } - ParseOsFamilyVersion64BitFromImageName parser = new ParseOsFamilyVersion64BitFromImageName(); + ParseOsFamilyVersion64BitFromImageName parser = new ParseOsFamilyVersion64BitFromImageName(new BaseComputeServiceContextModule() { + }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule()) + .getInstance(Json.class))); @Test(dataProvider = "data") public void test(String input, OsFamilyVersion64Bit expected) { diff --git a/providers/cloudsigma-zrh/src/test/resources/osmatches.json b/providers/cloudsigma-zrh/src/test/resources/osmatches.json index 963b533fc5..9ff751bbcc 100644 --- a/providers/cloudsigma-zrh/src/test/resources/osmatches.json +++ b/providers/cloudsigma-zrh/src/test/resources/osmatches.json @@ -1,5 +1,11 @@ { + "Ubuntu 10.04.1 LTS Desktop Edition 32bit Preinstalled System": { + "family": "UBUNTU", + "version": "10.04", + "is64Bit": false + }, + "Ubuntu 10.04 Server Edition Linux 64bit with Plesk": { "family": "UBUNTU", "version": "10.04", @@ -39,7 +45,7 @@ "Fedora 14 Linux 64bit Preinstalled System": { "family": "FEDORA", - "version": "14", + "version": "", "is64Bit": true }, @@ -102,7 +108,7 @@ "FreeBSD 8.1 Preinstalled Base System": { "family": "FREEBSD", - "version": "8.1", + "version": "", "is64Bit": true }, @@ -114,7 +120,7 @@ "Fedora 13 Linux 64bit Preinstalled System": { "family": "FEDORA", - "version": "13", + "version": "", "is64Bit": true }, @@ -134,7 +140,12 @@ "family": "DEBIAN", "version": "5.0", "is64Bit": true + }, + + "Debian 6.0 No X Minimal Linux 64bit Preinstalled System": { + "family": "DEBIAN", + "version": "6.0", + "is64Bit": true } - } \ No newline at end of file diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java index 9a7c8f394c..15adc9b3fd 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java @@ -36,7 +36,7 @@ public class ElasticHostsBlueSquareLondonPropertiesBuilder extends ElasticStackP protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.lon-p.elastichosts.com"); + properties.setProperty(PROPERTY_ENDPOINT, "https://api.lon-b.elastichosts.com"); properties.setProperty(PROPERTY_API_VERSION, "1.0"); return properties; } diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index 7058404611..1949cdb152 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,26 +46,26 @@ public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends BaseTem @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("10.04") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit)); + return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) + && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java new file mode 100644 index 0000000000..ea5259c8ac --- /dev/null +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London Peer 1. + * + * @author Adrian Cole + */ +public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "elastichosts-lon-p"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "ElasticHosts London Peer 1"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "UUID"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Secret API key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("https://lon-p.elastichosts.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://lon-p.elastichosts.com/accounts"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://www.elastichosts.com/cloud-hosting/api"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("elastichosts-lon-p"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("GB-LND"); + } + +} \ No newline at end of file diff --git a/providers/elastichosts-lon-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/elastichosts-lon-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..5f8edefd6f --- /dev/null +++ b/providers/elastichosts-lon-p/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.elastichosts.ElasticHostsPeer1LondonProviderMetadata diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java new file mode 100644 index 0000000000..fc3286b069 --- /dev/null +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.elastichosts; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ElasticHostsPeer1LondonProviderTest") +public class ElasticHostsPeer1LondonProviderTest extends BaseProviderMetadataTest { + + public ElasticHostsPeer1LondonProviderTest() { + super(new ElasticHostsPeer1LondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + } +} \ No newline at end of file diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index 8a50606034..453029ac19 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,26 +46,26 @@ public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends BaseTemplate @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("10.04") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit)); + return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) + && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index b69ad21e33..8b3bb449d8 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,26 +46,26 @@ public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemp @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("10.04") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !((input.version.equals("2008 R2") && input.is64Bit) || (input.version.equals("2008") && input.is64Bit)); + return (input.version.equals("") || input.version.equals("2008 R2") || input.version.equals("2008")) + && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/config/EucalyptusPartnerCloudComputeServiceContextModule.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/config/EucalyptusPartnerCloudComputeServiceContextModule.java index 2fa896be66..99870eccbb 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/config/EucalyptusPartnerCloudComputeServiceContextModule.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/config/EucalyptusPartnerCloudComputeServiceContextModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.epc.config; -import static org.jclouds.compute.domain.OsFamily.CENTOS; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; @@ -39,7 +39,7 @@ public class EucalyptusPartnerCloudComputeServiceContextModule extends EC2Comput protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { String virt = injector.getInstance(Key.get(String.class, Names .named("eucalyptus-partnercloud-ec2.virtualization-type"))); - return template.osFamily(CENTOS).locationId(virt + "-cluster").osDescriptionMatches(virt); + return template.osFamily(UBUNTU).locationId(virt + "-cluster"); } @Override diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/strategy/EucalyptusPartnerCloudReviseParsedImage.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/strategy/EucalyptusPartnerCloudReviseParsedImage.java index 3f5aeb959f..398d29e58a 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/strategy/EucalyptusPartnerCloudReviseParsedImage.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/strategy/EucalyptusPartnerCloudReviseParsedImage.java @@ -44,7 +44,7 @@ import org.jclouds.logging.Logger; @Singleton public class EucalyptusPartnerCloudReviseParsedImage implements ReviseParsedImage { - // centos-5.3-x86_64-xen/centos.5-3.x86-64.img.manifest.xml + // debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml public static final Pattern PATTERN = Pattern.compile("^([^-]+)-([^-]+)-.*"); public static final Pattern WINDOWS = Pattern.compile("^windows-([^/]+)/.*"); diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index 18e3ba0bb1..03193f81d4 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,23 +47,23 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("6.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.3") && input.is64Bit); - case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("2008") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test @@ -70,12 +71,12 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas Template defaultTemplate = context.getComputeService().templateBuilder().build(); assert (defaultTemplate.getImage().getProviderId().startsWith("emi-")) : defaultTemplate; - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.3"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getImage().getUserMetadata().get("rootDeviceType"), "instance-store"); assertEquals(defaultTemplate.getLocation().getId(), "kvm-cluster"); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + assertEquals(getCores(defaultTemplate.getHardware()), 2.0d); } diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java index 203df78eac..db061a6a74 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/strategy/EucalyptusPartnerCloudReviseParsedImageTest.java @@ -25,7 +25,7 @@ import java.util.Set; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.domain.OperatingSystemBuilder; +import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Credentials; @@ -60,29 +60,30 @@ public class EucalyptusPartnerCloudReviseParsedImageTest { Set result = convertImages("/eucalyptus_images.xml"); assertEquals(result.size(), 3); - assertEquals(Iterables.get(result, 0), new ImageBuilder().operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("paravirtual").version("5.3").description( - "centos-5.3-x86_64-xen/centos.5-3.x86-64.img.manifest.xml").is64Bit(true).build()).description( - "centos-5.3-x86_64-xen/centos.5-3.x86-64.img.manifest.xml").defaultCredentials( - new Credentials("root", null)).id("us-east-1/emi-F96014E1").providerId("emi-F96014E1").location( - defaultLocation).userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")) - .build()); + assertEquals(Iterables.get(result, 0).toString(), new ImageBuilder().operatingSystem( + OperatingSystem.builder().family(OsFamily.DEBIAN).arch("paravirtual").version("6.0").description( + "debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml").is64Bit(true).build()).description( + "debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml") + .defaultCredentials(new Credentials("root", null)).id("us-east-1/emi-892C130F").providerId( + "emi-892C130F").location(defaultLocation).userMetadata( + ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build().toString()); - assertEquals(Iterables.get(result, 1), new ImageBuilder().operatingSystem( - new OperatingSystemBuilder().family(OsFamily.WINDOWS).arch("paravirtual").version("2008").description( - "windows-2008-server/windows.my2008server.img.manifest.xml").is64Bit(true).build()) - .description("windows-2008-server/windows.my2008server.img.manifest.xml").defaultCredentials( - new Credentials("root", null)).id("us-east-1/emi-767B178C").providerId("emi-767B178C") - .location(defaultLocation).userMetadata( - ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build()); + assertEquals(Iterables.get(result, 1).toString(), new ImageBuilder().operatingSystem( + OperatingSystem.builder().family(OsFamily.CENTOS).arch("paravirtual").version("5.5").description( + "centos-5.5-x86_64/centos.5-5.x86-64.img.manifest.xml").is64Bit(true).build()).description( + "centos-5.5-x86_64/centos.5-5.x86-64.img.manifest.xml") + .defaultCredentials(new Credentials("root", null)).id("us-east-1/emi-9B751369").providerId( + "emi-9B751369").location(defaultLocation).userMetadata( + ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")).build().toString()); - assertEquals(Iterables.get(result, 2), new ImageBuilder().operatingSystem( - new OperatingSystemBuilder().family(OsFamily.CENTOS).arch("paravirtual").version("5.3").description( - "centos-5.3-x86_64-kvm/centos.5-3.x86-64.img.manifest.xml").is64Bit(true).build()).description( - "centos-5.3-x86_64-kvm/centos.5-3.x86-64.img.manifest.xml").defaultCredentials( - new Credentials("root", null)).id("us-east-1/emi-F9ED14E7").providerId("emi-F9ED14E7").location( + assertEquals(Iterables.get(result, 2).toString(), new ImageBuilder().operatingSystem( + OperatingSystem.builder().family(OsFamily.UBUNTU).arch("paravirtual").version("10.04").description( + "ubuntu-10.04-x86_64/ubuntu.10-04.x86-64.img.manifest.xml").is64Bit(true).build()).description( + "ubuntu-10.04-x86_64/ubuntu.10-04.x86-64.img.manifest.xml").defaultCredentials( + new Credentials("root", null)).id("us-east-1/emi-E0641459").providerId("emi-E0641459").location( defaultLocation).userMetadata(ImmutableMap.of("owner", "admin", "rootDeviceType", "instance-store")) - .build()); + .build().toString()); + } static Location defaultLocation = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description( diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/resources/eucalyptus_images.xml b/providers/eucalyptus-partnercloud-ec2/src/test/resources/eucalyptus_images.xml index dd25d19d8d..9b4111490e 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/resources/eucalyptus_images.xml +++ b/providers/eucalyptus-partnercloud-ec2/src/test/resources/eucalyptus_images.xml @@ -1,9 +1,22 @@ - 0bd968c0-b1d2-41bd-ad04-fc35017b5110 + a70893be-64cb-4cee-a6ef-ab1fcea75266 - eri-91061322 - initrd-64-xen/initrd-2.6.27.21-0.1-xen.manifest.xml + eki-23CD15B0 + kvm-kernel-x86_64/vmlinuz-2.6.28-11-generic.manifest.xml + + available + admin + true + + x86_64 + kernel + linux + + + eri-849A1703 + kvm-ramdisk-x86_64/initrd.img-2.6.28-11-generic.manifest.xml + available admin true @@ -13,78 +26,33 @@ linux - emi-F96014E1 - centos-5.3-x86_64-xen/centos.5-3.x86-64.img.manifest.xml + emi-892C130F + debian-6.0-x86_64/debian.6-0.x86-64.img.manifest.xml + available admin true x86_64 machine - eki-AE7F138B - eri-91061322 linux - emi-767B178C - windows-2008-server/windows.my2008server.img.manifest.xml + emi-9B751369 + centos-5.5-x86_64/centos.5-5.x86-64.img.manifest.xml + available admin true x86_64 machine - windows - - - eki-AE7F138B - kernel-64-xen/vmlinuz-2.6.27.21-0.1-xen.manifest.xml - available - admin - true - - x86_64 - kernel linux - eki-101E1514 - kernel-deb-ec2-32bit/vmlinuz-2.6.32-308-ec2.manifest.xml - available - admin - true - - i386 - kernel - linux - - - emi-F9ED14E7 - centos-5.3-x86_64-kvm/centos.5-3.x86-64.img.manifest.xml - available - admin - true - - x86_64 - machine - eki-C9BE147B - eri-0AEE155E - linux - - - eki-C9BE147B - kernel-64-kvm/vmlinuz-2.6.28-11-generic.manifest.xml - available - admin - true - - x86_64 - kernel - linux - - - eri-0AEE155E - initrd-64-kvm/initrd.img-2.6.28-11-generic.manifest.xml + eri-042914D2 + xen-ramdisk-x86_64/initrd-2.6.27.21-0.1-xen.manifest.xml + available admin true @@ -94,8 +62,21 @@ linux - eki-9383133A - kernel-deb-ec2/vmlinuz-2.6.32-308-ec2.manifest.xml + emi-E0641459 + ubuntu-10.04-x86_64/ubuntu.10-04.x86-64.img.manifest.xml + + available + admin + true + + x86_64 + machine + linux + + + eki-08A714DD + xen-kernel-x86_64/vmlinuz-2.6.27.21-0.1-xen.manifest.xml + available admin true diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java new file mode 100644 index 0000000000..3007a737f1 --- /dev/null +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.gogrid; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@ link org.jclouds.types.ProviderMetadata} for GoGrid. + * + * @author Adrian Cole + */ +public class GoGridProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "gogrid"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.COMPUTE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "GoGrid"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "API Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Shared Secret"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.gogrid.com"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://my.gogrid.com/gogrid"); + } + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("https://wiki.gogrid.com/wiki/index.php/API"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("gogrid"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-CA","US-VA"); + } + +} \ No newline at end of file diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java old mode 100755 new mode 100644 index 858a420e41..70448a007a --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java @@ -41,6 +41,6 @@ public class GoGridComputeServiceContextModule extends BaseComputeServiceContext @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).imageNameMatches(".*w/ None.*"); + return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").imageNameMatches(".*w/ None.*"); } } diff --git a/providers/gogrid/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/providers/gogrid/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..4aef048a04 --- /dev/null +++ b/providers/gogrid/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.gogrid.GoGridProviderMetadata diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/ProvidersInPropertiesTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java similarity index 59% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/ProvidersInPropertiesTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java index 305be9cab6..f29c6ef120 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/ProvidersInPropertiesTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java @@ -18,30 +18,18 @@ */ package org.jclouds.gogrid; -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { +@Test(groups = "unit", testName = "GoGridProviderTest") +public class GoGridProviderTest extends BaseProviderMetadataTest { - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "gogrid") : providers; + public GoGridProviderTest() { + super(new GoGridProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "gogrid") : providers; - } - -} +} \ No newline at end of file diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index c4a20270c1..3f040a2be4 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,24 +47,25 @@ public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case RHEL: - return !input.version.equals("") && !input.version.equals("5.4"); + return input.version.equals("") || input.version.equals("5.4"); + case DEBIAN: + return input.version.equals("") || input.version.equals("5.0"); case UBUNTU: - return !input.version.equals("") && !input.version.equals("10.04"); + return input.version.equals("") || input.version.equals("10.04"); case CENTOS: - return !input.version.equals("") && !input.version.matches("5.[35]"); + return input.version.equals("") || input.version.matches("5.[35]"); case WINDOWS: - return !input.version.equals("") && (input.is64Bit && !input.version.matches("200[38]")) - || (input.version.matches("200[38] [RS]P?2") && !input.is64Bit); + return input.version.equals("") || input.version.matches("200[38]"); default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/config/OpenHostingEast1ComputeServiceContextModule.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/config/OpenHostingEast1ComputeServiceContextModule.java index 1189e1492e..db37a049f6 100644 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/config/OpenHostingEast1ComputeServiceContextModule.java +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/config/OpenHostingEast1ComputeServiceContextModule.java @@ -18,22 +18,12 @@ */ package org.jclouds.openhosting.config; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; - -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; -import com.google.inject.Injector; - /** * * @author Adrian Cole */ public class OpenHostingEast1ComputeServiceContextModule extends ElasticStackComputeServiceContextModule { - @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true); - } - } diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index 051560d61c..e6159fb3ef 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,23 +47,23 @@ public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilder @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("10.10") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.10")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java new file mode 100644 index 0000000000..1146178803 --- /dev/null +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java @@ -0,0 +1,44 @@ +package org.jclouds.savvis.vpdc.compute; + +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.compute.BaseComputeServiceLiveTest; +import org.jclouds.ssh.jsch.config.JschSshClientModule; +import org.testng.annotations.Test; + +import com.google.inject.Module; + +/** + * Takes a long time to list nodes. Average response time is about 10-15 seconds per vm. + * Hence this test does not complete and is disabled until performance improves. + * @author Kedar Dave + * + */ +@Test(enabled = true, groups = "live") +public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTest { + + public VPDCComputeServiceLiveTestDisabled(){ + provider = "savvis-symphonyvpdc"; + } + + @Override + public void setServiceDefaults() { + group = "savvis-symphonyvpdc"; + } + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + // savvis uses untrusted certificates + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + return overrides; + } + + @Override + protected Module getSshModule() { + return new JschSshClientModule(); + } + +} diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java index bc9e87b32d..808d40057c 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterPropertiesBuilder.java @@ -20,6 +20,7 @@ package org.jclouds.serverlove; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; import java.util.Properties; @@ -34,6 +35,7 @@ public class ServerloveManchesterPropertiesBuilder extends ElasticStackPropertie @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); + properties.setProperty(PROPERTY_ISO3166_CODES, "GB-MAN"); properties.setProperty(PROPERTY_ENDPOINT, "https://api.z1-man.serverlove.com"); properties.setProperty(PROPERTY_API_VERSION, "1.0"); return properties; diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java index 9f8d47aa2a..acd12e7b2f 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java @@ -30,6 +30,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -45,26 +46,25 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("10.04") && input.is64Bit); + return (input.version.equals("") || input.version.equals("10.04")) && input.is64Bit; + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("5.5") && input.is64Bit); + return (input.version.equals("") || input.version.equals("5.5")) && input.is64Bit; case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("2008 R2") && input.is64Bit); + return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Test diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java index c108cd7eab..1f64c65ed4 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/config/SkaliCloudMalaysiaComputeServiceContextModule.java @@ -18,22 +18,12 @@ */ package org.jclouds.skalicloud.config; -import static org.jclouds.compute.domain.OsFamily.UBUNTU; - -import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; -import com.google.inject.Injector; - /** * * @author Adrian Cole */ public class SkaliCloudMalaysiaComputeServiceContextModule extends ElasticStackComputeServiceContextModule { - @Override - protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.10").os64Bit(true); - } - } \ No newline at end of file diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index dff53e329d..ebc3a9e155 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,24 +47,25 @@ public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends BaseTemplateBuild @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !input.version.equals("") && !input.version.equals("10.10"); + return input.version.equals("") || input.version.equals("10.10"); + case DEBIAN: + return (input.version.equals("") || input.version.equals("5.0")) && input.is64Bit; case CENTOS: - return !input.version.equals("") && !input.version.equals("5.5"); + return input.version.equals("") || input.version.equals("5.5"); case WINDOWS: - return !(input.version.equals("") && input.is64Bit) - && !(input.version.equals("2008 R2") && input.is64Bit); + return (input.version.equals("") || input.version.equals("2008 R2")) && input.is64Bit; default: - return true; + return false; } } - }; + }); } @Override diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java index 00af69b52b..e974314da1 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java @@ -34,7 +34,7 @@ import com.google.inject.Injector; public class SlicehostComputeServiceContextModule extends BaseComputeServiceContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(UBUNTU).osVersionMatches("10.04").osDescriptionMatches("^((?!MGC).)*$").os64Bit(true); + return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").osDescriptionMatches("^((?!MGC).)*$").os64Bit(true); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index 91ed4a16e8..528ad391aa 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -31,6 +31,7 @@ import org.jclouds.compute.domain.Template; import org.testng.annotations.Test; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; /** @@ -46,36 +47,35 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Override protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { + return Predicates.not(new Predicate() { @Override public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return !input.version.equals("") && !(input.version.equals("10.04") || input.version.endsWith(".10")); + return input.version.equals("") || input.version.startsWith("10") || input.version.equals("9.10"); + case DEBIAN: + return !input.version.equals("6.0"); case RHEL: - return !(input.version.equals("") && input.is64Bit); + return input.version.equals("") && input.is64Bit; case CENTOS: - return !input.version.equals("") && input.version.matches("5.[23]") - || (input.version.equals("5.0") && !input.is64Bit); + return input.version.equals("") || input.version.matches("5.[45]") + || (input.version.equals("5.0") && input.is64Bit); case WINDOWS: - return !input.version.equals("") - && input.version.startsWith("2008") - && !(input.version.startsWith("2008 R2") && input.is64Bit || input.version - .startsWith("2008 SP2") - && !input.is64Bit) || input.version.indexOf("2003") != -1; + return input.version.equals("") || (input.version.equals("2008 SP2") && !input.is64Bit) + || input.version.equals("") || (input.version.equals("2008 R2") && input.is64Bit); default: - return true; + return false; } } - }; + }); } @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 0.25d); diff --git a/providers/slicehost/src/test/resources/log4j.xml b/providers/slicehost/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java index 118e419e5d..d33a4c4b4b 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/vcloud/terremark/compute/config/TerremarkECloudComputeServiceContextModule.java @@ -18,7 +18,7 @@ */ package org.jclouds.vcloud.terremark.compute.config; -import static org.jclouds.compute.domain.OsFamily.CENTOS; +import static org.jclouds.compute.domain.OsFamily.UBUNTU; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.vcloud.compute.functions.ParseOsFromVAppTemplateName; @@ -40,12 +40,10 @@ public class TerremarkECloudComputeServiceContextModule extends TerremarkVCloudC bind(ParseOsFromVAppTemplateName.class).to(TerremarkECloudParseOsFromVAppTemplateName.class); super.configure(); } - - // as of 6-nov-2010 only centos has ssh key injection in the images. - // ssh key injection in ubuntu is targeted for dec-2010 or sooner + @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { - return template.osFamily(CENTOS).os64Bit(true); + return template.osFamily(UBUNTU).osVersionMatches("1[10].[10][04]").os64Bit(true); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java index 6bf0e59cc5..5fc7bb4e75 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/TerremarkECloudAsyncClientTest.java @@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; import org.jclouds.vcloud.CommonVCloudClient; +import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; -import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier; import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.Capacity; @@ -82,7 +82,7 @@ import org.jclouds.vcloud.terremark.xml.NodesHandler; import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; -import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; @@ -163,7 +163,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - @Override protected Template buildTemplate(TemplateBuilder templateBuilder) { Template template = super.buildTemplate(templateBuilder); @@ -93,7 +74,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv // image.getLocationId() can be null, if it is a location-free image assertEquals(image.getType(), ComputeType.IMAGE); if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS - && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { + && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; assert image.getDefaultCredentials().credential != null : image; } @@ -109,7 +90,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java index 2f431ae4fa..44825979e8 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -73,9 +73,9 @@ public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderL @Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java index e3fc4b16b0..d96827fac5 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/vcloud/terremark/compute/functions/TerremarkECloudParseOsFromVAppTemplateNameTest.java @@ -32,7 +32,7 @@ import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; -import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -52,7 +52,7 @@ public class TerremarkECloudParseOsFromVAppTemplateNameTest { InputStream is = getClass().getResourceAsStream(resource); Injector injector = Guice.createInjector(new SaxParserModule()); Factory factory = injector.getInstance(ParseSax.Factory.class); - return factory.create(injector.getInstance(CatalogHandler.class)).parse(is).keySet(); + return factory.create(injector.getInstance(VCloudExpressCatalogHandler.class)).parse(is).keySet(); } public void test() { diff --git a/providers/trmk-ecloud/src/test/resources/catalog-ecloud.xml b/providers/trmk-ecloud/src/test/resources/catalog-ecloud.xml old mode 100755 new mode 100644 diff --git a/providers/trmk-ecloud/src/test/resources/log4j.xml b/providers/trmk-ecloud/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/providers/trmk-vcloudexpress/pom.xml b/providers/trmk-vcloudexpress/pom.xml index a1ab8bcb86..4c888bde75 100644 --- a/providers/trmk-vcloudexpress/pom.xml +++ b/providers/trmk-vcloudexpress/pom.xml @@ -124,6 +124,7 @@ test + 1 test.trmk-vcloudexpress.endpoint diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java index f92608bdb6..4c9147604e 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/TerremarkVCloudExpressAsyncClientTest.java @@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; import org.jclouds.vcloud.CommonVCloudClient; +import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; -import org.jclouds.vcloud.VCloudVersionsAsyncClient; import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Catalog; @@ -81,7 +81,7 @@ import org.jclouds.vcloud.terremark.xml.NodeHandler; import org.jclouds.vcloud.terremark.xml.NodesHandler; import org.jclouds.vcloud.terremark.xml.TerremarkCatalogItemHandler; import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler; -import org.jclouds.vcloud.xml.CatalogHandler; +import org.jclouds.vcloud.xml.VCloudExpressCatalogHandler; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.Test; @@ -100,7 +100,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", sequential = true, testName = "TerremarkVCloudExpressAsyncClientTest") +@Test(groups = "unit", singleThreaded = true, testName = "TerremarkVCloudExpressAsyncClientTest") public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest { public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { @@ -163,7 +163,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); - } - + @Override protected Template buildTemplate(TemplateBuilder templateBuilder) { Template template = super.buildTemplate(templateBuilder); diff --git a/providers/trmk-vcloudexpress/src/test/resources/log4j.xml b/providers/trmk-vcloudexpress/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/LibvirtConstants.java b/sandbox-apis/libvirt/src/main/java/org/jclouds/libvirt/LibvirtConstants.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/libvirt/src/test/resources/log4j.xml b/sandbox-apis/libvirt/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClient.java b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClient.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNContextBuilder.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/config/SDNAuthRestClientModule.java b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/config/SDNAuthRestClientModule.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequestTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/AddSessionTokenToRequestTest.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/nirvanix/src/test/resources/log4j.xml b/sandbox-apis/nirvanix/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClient.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClient.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/PCSContextBuilder.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/PCSContextBuilder.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/config/PCSRestClientModule.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/config/PCSRestClientModule.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java b/sandbox-apis/pcs/src/main/java/org/jclouds/mezeo/pcs/xml/ContainerHandler.java old mode 100755 new mode 100644 diff --git a/sandbox-apis/pcs/src/test/resources/log4j.xml b/sandbox-apis/pcs/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/sandbox-providers/azurequeue/src/main/java/org/jclouds/azurequeue/AzureQueueProviderMetadata.java b/sandbox-providers/azurequeue/src/main/java/org/jclouds/azurequeue/AzureQueueProviderMetadata.java new file mode 100644 index 0000000000..e48784f4fa --- /dev/null +++ b/sandbox-providers/azurequeue/src/main/java/org/jclouds/azurequeue/AzureQueueProviderMetadata.java @@ -0,0 +1,116 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.azurequeue; + +import com.google.common.collect.ImmutableSet; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.providers.BaseProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Queue Service. + * + * @author Adrian Cole + */ +public class AzureQueueProviderMetadata extends BaseProviderMetadata { + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "azurequeue"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return ProviderMetadata.QUEUE_TYPE; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Microsoft Azure Queue Service"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return "Account Name"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return "Access Key"; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return URI.create("http://www.microsoft.com/windowsazure/storage/"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return URI.create("https://windows.azure.com/default.aspx"); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getLinkedServices() { + return ImmutableSet.of("azureblob", "azurequeue", "azuretable"); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return ImmutableSet.of("US-TX","US-IL","IE-D","SG","NL-NH","HK"); + } + +} \ No newline at end of file diff --git a/sandbox-providers/azurequeue/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/sandbox-providers/azurequeue/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..add5b002b3 --- /dev/null +++ b/sandbox-providers/azurequeue/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.azurequeue.AzureQueueProviderMetadata diff --git a/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueProviderTest.java b/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueProviderTest.java new file mode 100644 index 0000000000..8be82e7c58 --- /dev/null +++ b/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueProviderTest.java @@ -0,0 +1,35 @@ +/** + * + * Copyright (C) 2011 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.jclouds.azurequeue; + +import org.jclouds.providers.BaseProviderMetadataTest; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "AzureQueueProviderTest") +public class AzureQueueProviderTest extends BaseProviderMetadataTest { + + public AzureQueueProviderTest() { + super(new AzureQueueProviderMetadata(), ProviderMetadata.QUEUE_TYPE); + } +} \ No newline at end of file diff --git a/sandbox-providers/azurequeue/src/test/resources/log4j.xml b/sandbox-providers/azurequeue/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java b/sandbox-providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceContextModule.java old mode 100755 new mode 100644 diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java old mode 100755 new mode 100644 diff --git a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index 587f02ac57..2f5aee723b 100644 --- a/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/sandbox-providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -51,8 +51,9 @@ public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveT public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - // support for all ubuntu w/empty version and 10.04 & 10.10 - return !(input.version.equals("") || input.version.startsWith("10.")); + return input.version.matches("^[89].*"); + case DEBIAN: + return false; case CENTOS: return !input.version.equals(""); default: @@ -67,7 +68,7 @@ public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveT public void testTemplateBuilder() { Template defaultTemplate = context.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), "DCDALLAS"); assertEquals(defaultTemplate.getHardware().getProviderId(), "MIRO4B"); diff --git a/sandbox-providers/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java b/sandbox-providers/twitter/src/main/java/org/jclouds/twitter/TwitterContextBuilder.java old mode 100755 new mode 100644 diff --git a/sandbox-providers/twitter/src/main/java/org/jclouds/twitter/config/TwitterRestClientModule.java b/sandbox-providers/twitter/src/main/java/org/jclouds/twitter/config/TwitterRestClientModule.java old mode 100755 new mode 100644 diff --git a/sandbox-providers/twitter/src/test/resources/log4j.xml b/sandbox-providers/twitter/src/test/resources/log4j.xml old mode 100755 new mode 100644 diff --git a/scriptbuilder/src/test/resources/client_rb.sh b/scriptbuilder/src/test/resources/client_rb.sh old mode 100755 new mode 100644 diff --git a/scriptbuilder/src/test/resources/forget.cmd b/scriptbuilder/src/test/resources/forget.cmd old mode 100755 new mode 100644 diff --git a/scriptbuilder/src/test/resources/test_ebs.sh b/scriptbuilder/src/test/resources/test_ebs.sh old mode 100755 new mode 100644 diff --git a/scriptbuilder/src/test/resources/test_init.sh b/scriptbuilder/src/test/resources/test_init.sh old mode 100755 new mode 100644 diff --git a/skeletons/standalone-compute/src/test/resources/log4j.xml b/skeletons/standalone-compute/src/test/resources/log4j.xml old mode 100755 new mode 100644