From 81f070738248bcda1ba4bc520419922db1568f0f Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 20 Mar 2011 02:42:53 -0700 Subject: [PATCH 1/5] Issue 435: refactored savvis code --- .../org/jclouds/vcloud/xml/TaskHandler.java | 2 + core/src/main/resources/rest.properties | 3 + .../savvis-symphony-vpdc/pom.xml | 46 +- .../savvis/vpdc/SymphonyVPDCAsyncClient.java | 363 ------- .../jclouds/savvis/vpdc/VPDCAsyncClient.java | 41 + ...ymphonyVPDCClient.java => VPDCClient.java} | 26 +- ...xtBuilder.java => VPDCContextBuilder.java} | 17 +- ...uilder.java => VPDCPropertiesBuilder.java} | 10 +- .../VPDCComputeServiceContextModule.java | 53 + .../config/SymphonyVPDCRestClientModule.java | 83 -- .../vpdc/config/VPDCRestClientModule.java | 143 +++ .../org/jclouds/savvis/vpdc/domain/Link.java | 56 ++ .../jclouds/savvis/vpdc/domain/Network.java | 147 +++ .../org/jclouds/savvis/vpdc/domain/Org.java | 168 ++++ .../jclouds/savvis/vpdc/domain/Resource.java | 134 +++ .../vpdc/domain/ResourceAllocation.java | 279 ++++++ .../vpdc/domain/SymphonyVPDCNetwork.java | 85 -- .../org/jclouds/savvis/vpdc/domain/Task.java | 214 +++++ .../jclouds/savvis/vpdc/domain/TaskError.java | 136 +++ .../org/jclouds/savvis/vpdc/domain/VApp.java | 251 +++++ .../org/jclouds/savvis/vpdc/domain/VDC.java | 218 +++++ .../internal/SymphonyVPDCNetworkImpl.java | 205 ---- .../domain/internal/SymphonyVPDCVDCImpl.java | 75 -- .../internal/VCloudSession.java} | 12 +- .../savvis/vpdc/domain/vapp/Network.java | 59 ++ .../vpdc/domain/vapp/NetworkSection.java | 71 ++ .../vpdc/features/BrowsingAsyncClient.java | 110 +++ .../savvis/vpdc/features/BrowsingClient.java | 105 ++ .../vpdc/filters/SetVCloudTokenCookie.java | 53 + .../vpdc/functions/DefaultOrgIfNull.java | 48 + .../ParseLoginResponseFromHeaders.java | 76 ++ ...rrorHandler.java => VPDCErrorHandler.java} | 2 +- .../vpdc/internal/LoginAsyncClient.java | 51 + .../jclouds/savvis/vpdc/internal/Network.java | 40 + .../org/jclouds/savvis/vpdc/internal/Org.java | 40 + .../VCloudToken.java} | 22 +- .../org/jclouds/savvis/vpdc/internal/VDC.java | 40 + .../savvis/vpdc/predicates/TaskSuccess.java | 42 + .../vpdc/reference/VCloudConstants.java | 41 + .../vpdc/reference/VCloudMediaType.java | 207 ++++ .../org/jclouds/savvis/vpdc/util/Utils.java | 72 ++ .../savvis/vpdc/xml/NetworkHandler.java | 80 ++ .../vpdc/xml/NetworkSectionHandler.java | 58 ++ .../jclouds/savvis/vpdc/xml/OrgHandler.java | 83 ++ .../savvis/vpdc/xml/OrgListHandler.java | 39 + .../vpdc/xml/ResourceAllocationHandler.java | 59 ++ .../vpdc/xml/SymphonyVPDCNetworkHandler.java | 154 --- .../vpdc/xml/SymphonyVPDCVAppHandler.java | 147 --- .../vpdc/xml/SymphonyVPDCVDCHandler.java | 58 -- .../jclouds/savvis/vpdc/xml/TaskHandler.java | 106 ++ .../savvis/vpdc/xml/TasksListHandler.java | 68 ++ .../jclouds/savvis/vpdc/xml/VAppHandler.java | 111 +++ .../jclouds/savvis/vpdc/xml/VDCHandler.java | 83 ++ .../vpdc/SymphonyVPDCAsyncClientTest.java | 903 ------------------ .../vpdc/SymphonyVPDCClientLiveTest.java | 326 ------- .../savvis/vpdc/VPDCAsyncClientTest.java | 71 ++ .../SymphonyVPDCComputeServiceLiveTest.java | 57 -- .../SymphonyVPDCTemplateBuilderLiveTest.java | 77 -- .../features/BaseVPDCAsyncClientTest.java | 99 ++ .../vpdc/features/BaseVPDCClientLiveTest.java | 85 ++ .../features/BrowsingAsyncClientTest.java | 195 ++++ .../vpdc/features/BrowsingClientLiveTest.java | 132 +++ .../filters/SetVCloudTokenCookieTest.java | 59 ++ ...lerTest.java => VPDCErrorHandlerTest.java} | 4 +- .../savvis/vpdc/xml/NetworkHandlerTest.java | 75 ++ .../savvis/vpdc/xml/OrgHandlerTest.java | 28 +- .../savvis/vpdc/xml/OrgListHandlerTest.java | 56 ++ .../xml/ResourceAllocationHandlerTest.java | 32 + .../vpdc/xml/SymphonyVPDCVDCHandlerTest.java | 93 -- .../savvis/vpdc/xml/TaskHandlerTest.java | 248 +++++ .../savvis/vpdc/xml/VDCHandlerTest.java | 194 ++++ .../src/test/resources/log4j.xml | 170 ++++ .../src/test/resources/network-nat.xml | 18 + .../src/test/resources/network-unused.xml | 14 + .../src/test/resources/network.xml | 10 + .../src/test/resources/{savvis => }/org.xml | 0 .../src/test/resources/orglist.xml | 4 + .../src/test/resources/resourceallocation.xml | 26 + .../src/test/resources/task-error.xml | 11 + .../src/test/resources/task-failed.xml | 14 + .../src/test/resources/task-queued.xml | 15 + .../src/test/resources/task-running.xml | 15 + .../src/test/resources/task-unsupported.xml | 12 + .../src/test/resources/task-vapp.xml | 14 + .../src/test/resources/task-vmdk.xml | 14 + .../src/test/resources/vdc-1net.xml | 14 + .../src/test/resources/vdc-failed.xml | 11 + .../src/test/resources/vdc-saved.xml | 14 + .../src/test/resources/{savvis => }/vdc.xml | 2 +- 89 files changed, 5287 insertions(+), 2717 deletions(-) delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/{SymphonyVPDCClient.java => VPDCClient.java} (65%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/{SymphonyVPDCContextBuilder.java => VPDCContextBuilder.java} (63%) rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/{SymphonyVPDCPropertiesBuilder.java => VPDCPropertiesBuilder.java} (74%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCVDCImpl.java rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/{compute/config/SymphonyVPDCComputeServiceContextModule.java => domain/internal/VCloudSession.java} (77%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/{SymphonyVPDCErrorHandler.java => VPDCErrorHandler.java} (97%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java rename sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/{domain/SymphonyVPDCVDC.java => internal/VCloudToken.java} (65%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java rename sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/{SymphonyVPDCErrorHandlerTest.java => VPDCErrorHandlerTest.java} (96%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java delete mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandlerTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml rename sandbox-providers/savvis-symphony-vpdc/src/test/resources/{savvis => }/org.xml (100%) create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml create mode 100644 sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml rename sandbox-providers/savvis-symphony-vpdc/src/test/resources/{savvis => }/vdc.xml (88%) diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java index 7d2fdfe6b9..602274b4a3 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java @@ -25,6 +25,7 @@ import java.text.ParseException; import java.util.Date; import java.util.Map; +import javax.annotation.Resource; import javax.inject.Inject; import org.jclouds.date.DateService; @@ -55,6 +56,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult { private VCloudError error; private boolean inOwner; + @Resource protected Logger logger = Logger.NULL; @Inject diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties index d3c5a8770a..1b2d272f74 100644 --- a/core/src/main/resources/rest.properties +++ b/core/src/main/resources/rest.properties @@ -157,6 +157,9 @@ cloudstack.propertiesbuilder=org.jclouds.cloudstack.CloudStackPropertiesBuilder softlayer.contextbuilder=org.jclouds.softlayer.SoftLayerContextBuilder softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder +savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder +savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder + cloudfiles-us.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPropertiesBuilder diff --git a/sandbox-providers/savvis-symphony-vpdc/pom.xml b/sandbox-providers/savvis-symphony-vpdc/pom.xml index d9c357c863..acc3402847 100644 --- a/sandbox-providers/savvis-symphony-vpdc/pom.xml +++ b/sandbox-providers/savvis-symphony-vpdc/pom.xml @@ -31,9 +31,9 @@ ../../project/pom.xml org.jclouds.provider - savvis-symphony-vpdc - jclouds savvis core - jclouds components to access savvis + savvis-symphonyvpdc + jclouds savvis-vpdc vpdc + jclouds components to access Savvis Symphony VPDC @@ -52,34 +52,20 @@ node-924 - https://api.sandbox.symphonyVPDC.savvis.net/rest/api - 0.8 - FIXME - FIXME + https://api.symphonyvpdc.savvis.net/rest/api + 0.8 + FIXME + FIXME - - org.jclouds.api - vcloudexpress - ${project.version} - - - org.jclouds.api - vcloudexpress - ${project.version} - test-jar - test - org.jclouds jclouds-compute ${project.version} - test-jar - test org.jclouds - jclouds-vcloud + jclouds-compute ${project.version} test-jar test @@ -133,20 +119,20 @@ - test.savvis-symphony-vpdc.endpoint - ${test.savvis-symphony-vpdc.endpoint} + test.savvis-symphonyvpdc.endpoint + ${test.savvis-symphonyvpdc.endpoint} - test.savvis-symphony-vpdc.apiversion - ${test.savvis-symphony-vpdc.apiversion} + test.savvis-symphonyvpdc.apiversion + ${test.savvis-symphonyvpdc.apiversion} - test.savvis-symphony-vpdc.identity - ${test.savvis-symphony-vpdc.identity} + test.savvis-symphonyvpdc.identity + ${test.savvis-symphonyvpdc.identity} - test.savvis-symphony-vpdc.credential - ${test.savvis-symphony-vpdc.credential} + test.savvis-symphonyvpdc.credential + ${test.savvis-symphonyvpdc.credential} jclouds.compute.blacklist-nodes diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java deleted file mode 100644 index 2a6f8f6954..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClient.java +++ /dev/null @@ -1,363 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc; - -import java.net.URI; - -import javax.annotation.Nullable; -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.RequestFilters; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVDCHandler; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudExpressAsyncClient; -import org.jclouds.vcloud.VCloudExpressClient; -import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; -import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.TasksList; -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.OrgNameAndVDCNameToEndpoint; -import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; -import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; -import org.jclouds.vcloud.functions.OrgNameToEndpoint; -import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint; -import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.CatalogItemHandler; -import org.jclouds.vcloud.xml.OrgHandler; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.TasksListHandler; -import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; -import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Symphony VPDC resources via their REST API. - *

- * - * @see - * @author Adrian Cole - */ -@RequestFilters(SetVCloudTokenCookie.class) -public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient { - - /** - * {@inheritDoc} - */ - @GET - // no accept header - @XMLResponseParser(OrgHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findOrgNamed( - @Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName); - - /** - * {@inheritDoc} - */ - - @GET - // no accept header - @XMLResponseParser(OrgHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getOrg(@EndpointParam URI orgId); - - /** - * @see CommonVCloudClient#getVDC(URI) - */ - @GET - // no accept header - @XMLResponseParser(SymphonyVPDCVDCHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getVDC(@EndpointParam URI vdc); - - /** - * @see CommonVCloudClient#findVDCInOrgNamed(String, String) - */ - @GET - // no accept header - @XMLResponseParser(SymphonyVPDCVDCHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findVDCInOrgNamed( - @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName); - - /** - * @see CommonVCloudClient#findNetworkInOrgVDCNamed - */ - @GET - // no accept header - @XMLResponseParser(SymphonyVPDCNetworkHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findNetworkInOrgVDCNamed( - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName); - - /** - * @see CommonVCloudClient#getNetwork - */ - @GET - // no accept header - @XMLResponseParser(SymphonyVPDCNetworkHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getNetwork(@EndpointParam URI network); - - /** - * @see VCloudClient#getVApp - */ - @GET - // no accept header - @XMLResponseParser(SymphonyVPDCVAppHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getVApp(@EndpointParam URI vApp); - - /** - * @see VCloudClient#getVAppTemplate - */ - @GET - // no accept header - @XMLResponseParser(VCloudExpressVAppTemplateHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getVAppTemplate(@EndpointParam URI vAppTemplate); - - /** - * @see VCloudClient#findVAppTemplateInOrgCatalogNamed - */ - @GET - // no accept header - @XMLResponseParser(VCloudExpressVAppTemplateHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findVAppTemplateInOrgCatalogNamed( - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName); - - /** - * @see VCloudExpressClient#instantiateVAppTemplateInVDC - */ - @POST - @Path("/action/instantiateVAppTemplate") - @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml") - // no accept header - @XMLResponseParser(VCloudExpressVAppHandler.class) - @MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class) - @Override - ListenableFuture instantiateVAppTemplateInVDC(@EndpointParam URI vdc, - @PayloadParam("template") URI template, - @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, - InstantiateVAppTemplateOptions... options); - - /** - * @see VCloudExpressClient#cloneVAppInVDC - */ - @POST - @Path("/action/cloneVApp") - @Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml") - // no accept header - @XMLResponseParser(TaskHandler.class) - @MapBinder(BindCloneVAppParamsToXmlPayload.class) - @Override - ListenableFuture cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone, - @PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, CloneVAppOptions... options); - - /** - * @see VCloudClient#findVAppInOrgVDCNamed - */ - @GET - // no accept header - @XMLResponseParser(VCloudExpressVAppHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findVAppInOrgVDCNamed( - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName); - - /** - * @see CommonVCloudClient#deployVApp - */ - @POST - // no accept header - @Path("/action/deploy") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture deployVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#undeployVApp - */ - @POST - // no accept header - @Path("/action/undeploy") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture undeployVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#powerOnVApp - */ - @POST - // no accept header - @Path("/power/action/powerOn") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture powerOnVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#powerOffVApp - */ - @POST - // no accept header - @Path("/power/action/powerOff") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture powerOffVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#resetVApp - */ - @POST - // no accept header - @Path("/power/action/reset") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture resetVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#suspendVApp - */ - @POST - // no accept header - @Path("/power/action/suspend") - @XMLResponseParser(TaskHandler.class) - @Override - ListenableFuture suspendVApp(@EndpointParam URI vAppId); - - /** - * @see CommonVCloudClient#getCatalog - */ - @GET - @XMLResponseParser(CatalogHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - // no accept header - @Override - ListenableFuture getCatalog(@EndpointParam URI catalogId); - - /** - * @see CommonVCloudClient#findCatalogInOrgNamed - */ - @GET - @XMLResponseParser(CatalogHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - // no accept header - @Override - ListenableFuture findCatalogInOrgNamed( - @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName); - - /** - * @see CommonVCloudClient#getCatalogItem - */ - @GET - // no accept header - @XMLResponseParser(CatalogItemHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getCatalogItem(@EndpointParam URI catalogItem); - - /** - * @see CommonVCloudClient#getCatalogItemInOrg - */ - @GET - // no accept header - @XMLResponseParser(CatalogItemHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findCatalogItemInOrgCatalogNamed( - @Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName, - @Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName, - @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName); - - /** - * @see CommonVCloudClient#getTasksList - */ - @GET - // no accept header - @XMLResponseParser(TasksListHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getTasksList(@EndpointParam URI tasksListId); - - /** - * @see CommonVCloudClient#findTasksListInOrgNamed - */ - @GET - // no accept header - @XMLResponseParser(TasksListHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture findTasksListInOrgNamed( - @Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName); - - /** - * @see CommonVCloudClient#getTask - */ - @GET - // no accept header - @XMLResponseParser(TaskHandler.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - @Override - ListenableFuture getTask(@EndpointParam URI taskId); - -} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java new file mode 100644 index 0000000000..4320855b96 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc; + +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient; + +/** + * Provides asynchronous access to VPDC via their REST API. + *

+ * + * @see VPDCClient + * @see + * @author Adrian Cole + */ +public interface VPDCAsyncClient { + + /** + * Provides asynchronous access to Browsing features. + */ + @Delegate + BrowsingAsyncClient getBrowsingClient(); + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java similarity index 65% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java index 236c990cb3..379e16c26e 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCClient.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java @@ -19,25 +19,27 @@ package org.jclouds.savvis.vpdc; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC; -import org.jclouds.vcloud.VCloudExpressClient; +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.savvis.vpdc.features.BrowsingClient; /** - * Provides access to Symphony VPDC resources via their REST API. + * Provides synchronous access to VPDC. *

* - * @see + * @see VPDCAsyncClient + * @see * @author Adrian Cole */ -@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) -public interface SymphonyVPDCClient extends VCloudExpressClient { - @Override - SymphonyVPDCVDC findVDCInOrgNamed(String orgName, String vdcName); +@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) +public interface VPDCClient { - @Override - SymphonyVPDCVDC getVDC(URI vdc); -} \ No newline at end of file + /** + * Provides synchronous access to Browsing features. + */ + @Delegate + BrowsingClient getBrowsingClient(); + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java similarity index 63% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java index aa06ef4c39..dd4533340b 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCContextBuilder.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java @@ -23,8 +23,7 @@ import java.util.List; import java.util.Properties; import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.savvis.vpdc.compute.config.SymphonyVPDCComputeServiceContextModule; -import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule; +import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; import com.google.inject.Module; @@ -32,20 +31,14 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class SymphonyVPDCContextBuilder extends - ComputeServiceContextBuilder { +public class VPDCContextBuilder extends ComputeServiceContextBuilder { - public SymphonyVPDCContextBuilder(Properties props) { - super(SymphonyVPDCClient.class, SymphonyVPDCAsyncClient.class, props); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SymphonyVPDCComputeServiceContextModule()); + public VPDCContextBuilder(Properties props) { + super(VPDCClient.class, VPDCAsyncClient.class, props); } protected void addClientModule(List modules) { - modules.add(new SymphonyVPDCRestClientModule()); + modules.add(new VPDCRestClientModule()); } } diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java similarity index 74% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java index 4240562f46..4ee290529b 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/SymphonyVPDCPropertiesBuilder.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java @@ -21,26 +21,28 @@ package org.jclouds.savvis.vpdc; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; import java.util.Properties; -import org.jclouds.vcloud.VCloudExpressPropertiesBuilder; +import org.jclouds.PropertiesBuilder; /** * Builds properties used in Symphony VPDC Clients * * @author Adrian Cole */ -public class SymphonyVPDCPropertiesBuilder extends VCloudExpressPropertiesBuilder { +public class VPDCPropertiesBuilder extends PropertiesBuilder { @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_API_VERSION, "0.8"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.sandbox.symphonyVPDC.savvis.net/rest/api"); + properties.setProperty(PROPERTY_ENDPOINT, "https://api.symphonyvpdc.savvis.net/rest/api"); + properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); return properties; } - public SymphonyVPDCPropertiesBuilder(Properties properties) { + public VPDCPropertiesBuilder(Properties properties) { super(properties); } diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java new file mode 100644 index 0000000000..cbcd0372d3 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java @@ -0,0 +1,53 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.compute.config; + +import java.util.Map; + +import javax.inject.Singleton; + +import org.jclouds.compute.config.BaseComputeServiceContextModule; +import org.jclouds.compute.domain.NodeState; +import org.jclouds.savvis.vpdc.domain.VApp; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Provides; + +/** + * + * @author Adrian Cole + */ +public class VPDCComputeServiceContextModule extends BaseComputeServiceContextModule { + + @VisibleForTesting + public static final Map VAPPSTATUS_TO_NODESTATE = ImmutableMap + . builder().put(VApp.Status.OFF, NodeState.SUSPENDED) + .put(VApp.Status.ON, NodeState.RUNNING).put(VApp.Status.RESOLVED, NodeState.PENDING) + .put(VApp.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(VApp.Status.UNKNOWN, NodeState.UNRECOGNIZED) + .put(VApp.Status.SUSPENDED, NodeState.SUSPENDED).put(VApp.Status.UNRESOLVED, NodeState.PENDING).build(); + + @Singleton + @Provides + protected Map provideVAppStatusToNodeState() { + return VAPPSTATUS_TO_NODESTATE; + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java deleted file mode 100644 index 24d40457b7..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/SymphonyVPDCRestClientModule.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.config; - -import java.net.URI; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.savvis.vpdc.SymphonyVPDCAsyncClient; -import org.jclouds.savvis.vpdc.SymphonyVPDCClient; -import org.jclouds.savvis.vpdc.handlers.SymphonyVPDCErrorHandler; -import org.jclouds.vcloud.VCloudExpressAsyncClient; -import org.jclouds.vcloud.VCloudExpressClient; -import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule; -import org.jclouds.vcloud.domain.Org; - -import com.google.inject.Provides; - -public class SymphonyVPDCRestClientModule extends - BaseVCloudExpressRestClientModule { - - public SymphonyVPDCRestClientModule() { - super(SymphonyVPDCClient.class, SymphonyVPDCAsyncClient.class); - } - - @Provides - @Singleton - protected VCloudExpressAsyncClient provideVCloudAsyncClient(SymphonyVPDCAsyncClient in) { - return in; - } - - @Provides - @Singleton - protected VCloudExpressClient provideVCloudClient(SymphonyVPDCClient in) { - return in; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - if(org.getTasksList() != null){ - return org.getTasksList().getHref(); - }else{ - return URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList"); - } - } - - - @Override - protected void configure() { - super.configure(); -// no longer needed.. just here to show an example of how to override an xml handler -// bind(OrgListHandler.class).to(SymphonyVPDCOrgListHandler.class); - } - -@Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(SymphonyVPDCErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(SymphonyVPDCErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(SymphonyVPDCErrorHandler.class); - } - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java new file mode 100644 index 0000000000..fd1269a8eb --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java @@ -0,0 +1,143 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.config; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Throwables.propagate; +import static org.jclouds.Constants.PROPERTY_IDENTITY; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.jclouds.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; + +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.http.HttpErrorHandler; +import org.jclouds.http.annotation.ClientError; +import org.jclouds.http.annotation.Redirection; +import org.jclouds.http.annotation.ServerError; +import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.AsyncClientFactory; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.config.RestClientModule; +import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; +import org.jclouds.savvis.vpdc.VPDCAsyncClient; +import org.jclouds.savvis.vpdc.VPDCClient; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.internal.VCloudSession; +import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient; +import org.jclouds.savvis.vpdc.features.BrowsingClient; +import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler; +import org.jclouds.savvis.vpdc.internal.LoginAsyncClient; +import org.jclouds.savvis.vpdc.internal.VCloudToken; +import org.jclouds.savvis.vpdc.predicates.TaskSuccess; + +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.inject.Injector; +import com.google.inject.Provides; + +/** + * + * @author Adrian Cole + * + */ +public class VPDCRestClientModule extends RestClientModule { + @Provides + @Singleton + protected LoginAsyncClient provideVCloudVersions(AsyncClientFactory factory) { + return factory.create(LoginAsyncClient.class); + } + + @VCloudToken + @Provides + String provideVCloudToken(Supplier cache) { + return checkNotNull(cache.get().getVCloudToken(), "No token present in session"); + } + + @Provides + @org.jclouds.savvis.vpdc.internal.Org + @Singleton + protected Iterable provideOrgs(Supplier cache, + @Named(PROPERTY_IDENTITY) String user) { + VCloudSession discovery = cache.get(); + checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user); + return discovery.getOrgs(); + } + + @Provides + @org.jclouds.savvis.vpdc.internal.Org + @Singleton + protected String provideDefaultOrgId(@org.jclouds.savvis.vpdc.internal.Org Iterable orgs) { + return Iterables.get(orgs, 0).getId(); + } + + protected AtomicReference authException = new AtomicReference(); + + @Provides + @Singleton + protected Predicate successTester(Injector injector, + @Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) { + return new RetryablePredicate(injector.getInstance(TaskSuccess.class), completed); + } + + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// + .put(BrowsingClient.class, BrowsingAsyncClient.class)// + .build(); + + public VPDCRestClientModule() { + super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP); + } + + @Provides + @Singleton + protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + final LoginAsyncClient login) { + return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(authException, seconds, + new Supplier() { + + @Override + public VCloudSession get() { + try { + return login.login().get(10, TimeUnit.SECONDS); + } catch (Exception e) { + propagate(e); + assert false : e; + return null; + } + } + + }); + } + + @Override + protected void bindErrorHandlers() { + bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(VPDCErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(VPDCErrorHandler.class); + bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(VPDCErrorHandler.class); + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java new file mode 100644 index 0000000000..0e1dd4f474 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java @@ -0,0 +1,56 @@ +package org.jclouds.savvis.vpdc.domain; + +import java.net.URI; + +/** + * Location of a Rest resource + * + * @author Adrian Cole + * + */ +public class Link extends Resource { + protected final String rel; + + public Link( String id,String name, String type, URI href, String rel) { + super(id, name, type, href); + this.rel = rel; + } + + public String getRel() { + return rel; + } + + public int compareTo(Link that) { + return (this == that) ? 0 : getHref().compareTo(that.getHref()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((rel == null) ? 0 : rel.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + Link other = (Link) obj; + if (rel == null) { + if (other.rel != null) + return false; + } else if (!rel.equals(other.rel)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", rel=" + rel + "]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java new file mode 100644 index 0000000000..bd0fdea8b0 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java @@ -0,0 +1,147 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; + +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; + +/** + * Various network features such NAT Public IP, Gateway and Netmask. + * + * @author Adrian Cole + */ +public class Network extends Resource { + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Resource.Builder { + private String gateway; + private String netmask; + private Map internalToExternalNATRules = Maps.newLinkedHashMap(); + + public Builder gateway(String gateway) { + this.gateway = gateway; + return this; + } + + public Builder netmask(String netmask) { + this.netmask = netmask; + return this; + } + + public Builder internalToExternalNATRule(String internalIP, String externalIP) { + this.internalToExternalNATRules.put(checkNotNull(internalIP, "internalIP"), + checkNotNull(externalIP, "externalIP")); + return this; + } + + public Builder internalToExternalNATRules(Map internalToExternalNATRules) { + this.internalToExternalNATRules.putAll(checkNotNull(internalToExternalNATRules, "internalToExternalNATRules")); + return this; + } + + @Override + public Network build() { + return new Network(id, name, type, href, gateway, netmask, internalToExternalNATRules); + } + + public static Builder fromOrg(Network in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()) + .gateway(in.getGateway()).internalToExternalNATRules(in.getInternalToExternalNATRules()) + .netmask(in.getNetmask()); + } + + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + } + + @Nullable + private final String gateway; + private final String netmask; + private final Map internalToExternalNATRules; + + public Network(String id, String name, String type, URI href, @Nullable String gateway, String netmask, + Map internalToExternalNATRules) { + super(id, name, type, href); + this.gateway = gateway; + this.netmask = netmask; + this.internalToExternalNATRules = ImmutableMap.copyOf(checkNotNull(internalToExternalNATRules, + "internalToExternalNATRules")); + } + + /** + * @return IP of the network's gateway + */ + public String getGateway() { + return gateway; + } + + /** + * @return IP of the network's netmask + */ + public String getNetmask() { + return netmask; + } + + /** + * @return map of internal to external ip when it has any nat1to1 enabled deployed VApp + */ + public Map getInternalToExternalNATRules() { + return internalToExternalNATRules; + } + + @Override + public Builder toBuilder() { + return Builder.fromOrg(this); + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", gateway=" + gateway + + ", netmask=" + netmask + ", internalToExternalNATRules=" + internalToExternalNATRules + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java new file mode 100644 index 0000000000..282a54143d --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java @@ -0,0 +1,168 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * A cloud can contain one or more Organizations. There are two types of Organizations, hard-walled + * and soft-walled. + *

+ * + * @author Adrian Cole + */ +public class Org extends Resource { + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Resource.Builder { + private String description; + private Set vDCs = Sets.newLinkedHashSet(); + private Set images = Sets.newLinkedHashSet(); + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder vDC(Link vDC) { + this.vDCs.add(checkNotNull(vDC, "vDC")); + return this; + } + + public Builder vDCs(Set vDCs) { + this.vDCs.addAll(checkNotNull(vDCs, "vDCs")); + return this; + } + + public Builder image(Link image) { + this.images.add(checkNotNull(image, "image")); + return this; + } + + public Builder images(Set images) { + this.images.addAll(checkNotNull(images, "images")); + return this; + } + + @Override + public Org build() { + return new Org(id, name, type, href, description, vDCs, images); + } + + public static Builder fromOrg(Org in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()) + .description(in.getDescription()).images(in.getImages()).vDCs(in.getVDCs()); + } + + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + } + + @Nullable + private final String description; + private final Set vDCs; + private final Set images; + + public Org(String id, String name, String type, URI href, @Nullable String description, Set vDCs, + Set images) { + super(id, name, type, href); + this.description = description; + this.vDCs = ImmutableSet.copyOf(checkNotNull(vDCs, "vDCs")); + this.images = ImmutableSet.copyOf(checkNotNull(images, "images")); + } + + /** + * {@inheritDoc} + */ + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + public Set getVDCs() { + return vDCs; + } + + /** + * {@inheritDoc} + */ + public Set getImages() { + return images; + } + + @Override + public Builder toBuilder() { + return Builder.fromOrg(this); + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", description=" + description + + ", vDCs=" + vDCs + ", images=" + images + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java new file mode 100644 index 0000000000..8f3ac09192 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java @@ -0,0 +1,134 @@ +package org.jclouds.savvis.vpdc.domain; + +import java.net.URI; + +/** + * Location of a Rest resource + * + * @author Adrian Cole + * + */ +public class Resource { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + protected String id; + protected String name; + protected String type; + protected URI href; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public Builder href(URI href) { + this.href = href; + return this; + } + + public Resource build() { + return new Resource(id, name, type, href); + } + + public static Builder fromResource(Resource in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()); + } + } + + protected final String id; + protected final String name; + protected final String type; + protected final URI href; + + public Resource(String id, String name, String type, URI href) { + this.id = id; + this.name = name; + this.type = type; + this.href = href; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getType() { + return type; + } + + public URI getHref() { + return href; + } + + public int compareTo(Resource that) { + return (this == that) ? 0 : getHref().compareTo(that.getHref()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((href == null) ? 0 : href.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.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; + Resource other = (Resource) obj; + if (href == null) { + if (other.href != null) + return false; + } else if (!href.equals(other.href)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } + + public Builder toBuilder() { + return Builder.fromResource(this); + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + "]"; + } +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java new file mode 100644 index 0000000000..d87527b9c7 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java @@ -0,0 +1,279 @@ +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * @author Adrian Cole + * + */ +public class ResourceAllocation { + public enum Type { + /** + * 3 GHz equals 1 vCPU + *

+ * 1.5 Ghz equals 0.5 vCPU + */ + PROCESSOR, + /** + * Gigabytes + */ + MEMORY, ETHERNET_ADAPTER, + /** + * Gigabytes + */ + BOOT_DISK, + /** + * Gigabytes + */ + DATA_DISK, UNRECOGNIZED; + + public String value() { + switch (this) { + case PROCESSOR: + return "3"; + case MEMORY: + return "4"; + case ETHERNET_ADAPTER: + return "10"; + case BOOT_DISK: + return "27"; + case DATA_DISK: + return "26"; + default: + return "UNRECOGNIZED"; + } + } + + public static Type fromValue(String type) { + try { + return fromValue(Integer.parseInt(checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + public static Type fromValue(int v) { + switch (v) { + case 3: + return PROCESSOR; + case 4: + return MEMORY; + case 10: + return ETHERNET_ADAPTER; + case 27: + return BOOT_DISK; + case 26: + return DATA_DISK; + default: + return UNRECOGNIZED; + } + } + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + protected int id; + protected Type type; + protected String name; + protected String description; + protected String allocationUnits; + protected long virtualQuantity; + protected String connection; + protected String caption; + protected String hostResource; + + public Builder id(int id) { + this.id = id; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder connection(String connection) { + this.connection = connection; + return this; + } + + public Builder caption(String caption) { + this.caption = caption; + return this; + } + + public Builder hostResource(String hostResource) { + this.hostResource = hostResource; + return this; + } + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder allocationUnits(String allocationUnits) { + this.allocationUnits = allocationUnits; + return this; + } + + public Builder type(Type type) { + this.type = type; + return this; + } + + public Builder virtualQuantity(long virtualQuantity) { + this.virtualQuantity = virtualQuantity; + return this; + } + + public ResourceAllocation build() { + return new ResourceAllocation(id, type, name, description, allocationUnits, virtualQuantity, connection, + caption, hostResource); + } + + public static Builder fromResourceAllocation(ResourceAllocation in) { + return new Builder().id(in.getId()).type(in.getType()).name(in.getName()).description(in.getDescription()) + .allocationUnits(in.getAllocationUnits()).virtualQuantity(in.getVirtualQuantity()) + .connection(in.getConnection()).caption(in.getCaption()).hostResource(in.getHostResource()); + } + } + + protected final int id; + protected final Type type; + protected final String name; + protected final String description; + protected final String allocationUnits; + protected final long virtualQuantity; + protected final String connection; + protected final String caption; + protected final String hostResource; + + public ResourceAllocation(int id, Type type, String name, String description, String allocationUnits, + long virtualQuantity, String connection, String caption, String hostResource) { + this.id = id; + this.type = checkNotNull(type, "type"); + this.name = checkNotNull(name, "name"); + this.description = description; + this.allocationUnits = allocationUnits; + this.virtualQuantity = virtualQuantity; + this.connection = connection; + this.caption = caption; + this.hostResource = hostResource; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public Type getType() { + return type; + } + + public String getAllocationUnits() { + return allocationUnits; + } + + public String getConnection() { + return connection; + } + + public String getCaption() { + return caption; + } + + public long getVirtualQuantity() { + return virtualQuantity; + } + + public String getHostResource() { + return hostResource; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((allocationUnits == null) ? 0 : allocationUnits.hashCode()); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + ((connection == null) ? 0 : connection.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((hostResource == null) ? 0 : hostResource.hashCode()); + result = prime * result + id; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResourceAllocation other = (ResourceAllocation) obj; + if (allocationUnits == null) { + if (other.allocationUnits != null) + return false; + } else if (!allocationUnits.equals(other.allocationUnits)) + return false; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (connection == null) { + if (other.connection != null) + return false; + } else if (!connection.equals(other.connection)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (hostResource == null) { + if (other.hostResource != null) + return false; + } else if (!hostResource.equals(other.hostResource)) + return false; + if (id != other.id) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (type != other.type) + return false; + if (virtualQuantity != other.virtualQuantity) + return false; + return true; + } + + public Builder toBuilder() { + return Builder.fromResourceAllocation(this); + } + + @Override + public String toString() { + return "[id=" + id + ", type=" + type + ", name=" + name + ", description=" + description + ", allocationUnits=" + + allocationUnits + ", virtualQuantity=" + virtualQuantity + ", connection=" + connection + ", caption=" + + caption + ", hostResource=" + hostResource + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java deleted file mode 100644 index 818ac64e9a..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCNetwork.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.domain; - -import java.util.Set; - -import javax.annotation.Nullable; - -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.firewall.FirewallRule; -import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; - -/** - * - * A network that is available in a vDC. - * - * @author Kedar Dave - */ -public interface SymphonyVPDCNetwork extends ReferenceType { - /** - * - * @return Description of the network - */ - String getDescription(); - - /** - * @return IP addresses of the network’s DNS servers. - */ - Set getDnsServers(); - - /** - * - * - * @return The IP address of the network’s primary gateway - */ - String getGateway(); - - /** - * * - * - * @return the network’s subnet mask - */ - String getNetmask(); - - /** - * return the network’s fence modes. - */ - Set getFenceModes(); - - /** - * return True if the network provides DHCP services - */ - @Nullable - Boolean isDhcp(); - - /** - * - * @return Network Address Translation rules for the network - */ - Set getNatRules(); - - /** - * @return Firewall rules for the network - */ - Set getFirewallRules(); - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java new file mode 100644 index 0000000000..e34a9529f3 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java @@ -0,0 +1,214 @@ +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Date; + +import javax.annotation.Nullable; + +/** + * The result of a client request cannot be returned immediately, the server creates a task entity + * and returns its URL to the client. The client can use this URL in a subsequent GET request to + * obtain the current status of the task. + * + * @see + */ +public class Task extends Resource { + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Resource.Builder { + private Status status; + private Date startTime; + private Date endTime; + private Resource owner; + private Resource result; + private TaskError error; + + public Builder status(Status status) { + this.status = status; + return this; + } + + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + public Builder owner(Resource owner) { + this.owner = owner; + return this; + } + + public Builder result(Resource result) { + this.result = result; + return this; + } + + public Builder error(TaskError error) { + this.error = error; + return this; + } + + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + @Override + public Task build() { + return new Task(id, name, type, href, status, startTime, endTime, owner, result, error); + } + + public static Builder fromTask(Task in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()) + .status(in.getStatus()).startTime(in.getStartTime()).endTime(in.getEndTime()).owner(in.getOwner()) + .error(in.getError()).result(in.getResult()); + } + } + + public enum Status { + /** + * Savvis VPDC successfully provisioned and available for use. + */ + SUCCESS, + /** + * Savvis VPDC is processing the user request, please wait for the provisioning process to + * complete. + */ + RUNNING, + + /** + * Savvis VPDC is processing the user request, please wait for the provisioning process to + * complete. + */ + QUEUED, + /** + * Savvis VPDC is failed, please kindly contact Savvis administrator for further + * clarification/assistance with the respective request data. + */ + ERROR, + /** + * Unexpected Savvus VPDC Status, Savvis VPDC is failed, please kindly contact Savvis + * administrator for further clarification/assistance with the respective request data. + */ + NONE, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + @Override + public String toString() { + return value(); + } + + public static Status fromValue(String status) { + try { + return valueOf(checkNotNull(status, "status").toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + } + + private final Status status; + private final Date startTime; + private final Date endTime; + private final Resource owner; + private final Resource result; + private final TaskError error; + + public Task(String id, String name, String type, URI href, Status status, Date startTime, Date endTime, + Resource result, Resource owner, TaskError error) { + super(id, name, type, href); + this.status = status; + this.startTime = startTime; + this.endTime = endTime; + this.owner = owner; + this.result = result; + this.error = error; + } + + /** + * The current status of the task. + */ + public Status getStatus() { + return status; + } + + /** + * date and time when the task was started. + */ + public Date getStartTime() { + return startTime; + } + + /** + * date and time when the task completed. Does not appear for running tasks. + */ + @Nullable + public Date getEndTime() { + return endTime; + } + + /** + * A link to the object that owns the task. For copy operations, the owner is the copy that is + * being created. For delete operations, the owner is the deleted object, so this element is not + * included. For all other operations, the owner is the object to which the request was made. + */ + @Nullable + public Resource getOwner() { + return owner; + } + + /** + * Result is represent outcome of request url. if any VM related operation, the result will + * present as get VApp. if any VMDK related operation, the result will present as get VMKD + */ + @Nullable + public Resource getResult() { + return result; + } + + /** + * error message or related information returned by the task + */ + @Nullable + public TaskError getError() { + return error; + } + + public Builder toBuilder() { + return Builder.fromTask(this); + } + + @Override + public String toString() { + return "[status=" + status + ", startTime=" + startTime + ", endTime=" + endTime + ", owner=" + owner + + ", result=" + result + ", error=" + error + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java new file mode 100644 index 0000000000..2efdd9be90 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java @@ -0,0 +1,136 @@ +package org.jclouds.savvis.vpdc.domain; + +import javax.annotation.Nullable; + +/** + * + * + * @author Adrian Cole + */ +public class TaskError { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private String message; + private int majorErrorCode = -1; + private int minorErrorCode = -1; + private String vendorSpecificErrorCode; + + public Builder message(String message) { + this.message = message; + return this; + } + + public Builder majorErrorCode(int majorErrorCode) { + this.majorErrorCode = majorErrorCode; + return this; + } + + public Builder minorErrorCode(int minorErrorCode) { + this.minorErrorCode = minorErrorCode; + return this; + } + + public Builder vendorSpecificErrorCode(String vendorSpecificErrorCode) { + this.vendorSpecificErrorCode = vendorSpecificErrorCode; + return this; + } + + public TaskError build() { + return new TaskError(message, majorErrorCode, minorErrorCode, vendorSpecificErrorCode); + } + } + + private final String message; + private final int majorErrorCode; + private final int minorErrorCode; + private final String vendorSpecificErrorCode; + + public TaskError(String message, int majorErrorCode, int minorErrorCode, @Nullable String vendorSpecificErrorCode) { + this.message = message; + this.majorErrorCode = majorErrorCode; + this.minorErrorCode = minorErrorCode; + this.vendorSpecificErrorCode = vendorSpecificErrorCode; + } + + /** + * + * @return message describing the error + */ + public String getMessage() { + return message; + } + + /** + * + * @return matches the HTTP status code + */ + public int getMajorErrorCode() { + return majorErrorCode; + } + + /** + * + * @return matches the minor code, typically -1 + */ + public int getMinorErrorCode() { + return minorErrorCode; + } + + /** + * + * @return optional additional information about the source of the error + */ + @Nullable + public String getVendorSpecificErrorCode() { + return vendorSpecificErrorCode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + majorErrorCode; + result = prime * result + ((message == null) ? 0 : message.hashCode()); + result = prime * result + minorErrorCode; + result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.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; + TaskError other = (TaskError) obj; + if (majorErrorCode != other.majorErrorCode) + return false; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + if (minorErrorCode != other.minorErrorCode) + return false; + if (vendorSpecificErrorCode == null) { + if (other.vendorSpecificErrorCode != null) + return false; + } else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode)) + return false; + return true; + } + + @Override + public String toString() { + return "[message=" + message + ", majorErrorCode=" + majorErrorCode + ", minorErrorCode=" + minorErrorCode + + ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java new file mode 100644 index 0000000000..69f566d013 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java @@ -0,0 +1,251 @@ +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * A virtual application (vApp) is a software solution, packaged in OVF containing one or more + * virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators + * in Enterprises and Service Providers. + * + * @author Adrian Cole + */ +public class VApp extends Resource { + /** + * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the + * state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm + * objects) each have a status of their own, is computed from the status of the Children. + * + *

NOTE

+ *

+ * The deployment status of an object is indicated by the value of its deployed attribute. + * + * @since vcloud api 0.8 + * + * @author Adrian Cole + */ + public enum Status { + + /** + * When the VM is in Designing,Saved,Inqueue, has issue in pre provisioning or any exception + * cases. VM is not in Savvis VPDC (may the VM has been removed) or cannot get VM state due to + * unknown exception + */ + UNRESOLVED, + /** + * When the Savvis VPDC is in Provisioning, PartiallyDeployed, Failed and the VM failed in + * provisioning or pending infrastructure notification + */ + RESOLVED, + /** + * When the VM is deployed in vmware and powered off. + */ + OFF, + /** + * We do not support suspended state. + */ + SUSPENDED, + /** + * When the VM is deployed in vmware and powered on. + */ + ON, + /** + * The VM is deployed in vmware but the state of VM may be Uninitialized, Start, Stop, Resume, + * Reset, RebootGuest, Error, Failed, Unknown, PoweringOn, PoweringOff, Suspending, Stopping, + * Starting, Resetting, RebootingGuest. Please call back the Get VApp Power State API after + * few minute. + */ + UNKNOWN, UNRECOGNIZED; + + public String value() { + switch (this) { + case UNRESOLVED: + return "0"; + case RESOLVED: + return "1"; + case OFF: + return "2"; + case SUSPENDED: + return "3"; + case ON: + return "4"; + case UNKNOWN: + return "5"; + default: + return "UNRECOGNIZED"; + } + } + + public static Status fromValue(String status) { + try { + return fromValue(Integer.parseInt(checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + public static Status fromValue(int v) { + switch (v) { + case 0: + return UNRESOLVED; + case 1: + return RESOLVED; + case 2: + return OFF; + case 3: + return SUSPENDED; + case 4: + return ON; + case 5: + return UNKNOWN; + default: + return UNRECOGNIZED; + } + } + + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Resource.Builder { + private Status status; + private String ipAddress; + private Integer osType; + private String osDescripton; + private NetworkSection networkSection; + private Set resourceAllocations = Sets.newLinkedHashSet(); + + public Builder ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + public Builder status(Status status) { + this.status = status; + return this; + } + + public Builder osType(Integer osType) { + this.osType = osType; + return this; + } + + public Builder networkSection(NetworkSection networkSection) { + this.networkSection = networkSection; + return this; + } + + public Builder osDescripton(String osDescripton) { + this.osDescripton = osDescripton; + return this; + } + + public Builder resourceAllocation(ResourceAllocation in) { + this.resourceAllocations.add(checkNotNull(in, "resourceAllocation")); + return this; + } + + public Builder resourceAllocations(Set resourceAllocations) { + this.resourceAllocations.addAll(checkNotNull(resourceAllocations, "resourceAllocations")); + return this; + } + + @Override + public VApp build() { + return new VApp(id, name, type, href, status, ipAddress, osType, osDescripton, networkSection, + resourceAllocations); + } + + public static Builder fromVApp(VApp in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()) + .status(in.getStatus()).ipAddress(in.getIpAddress()).osType(in.getOsType()) + .networkSection(in.getNetworkSection()).resourceAllocations(in.getResourceAllocations()) + .osDescripton(in.getOsDescripton()); + } + + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + } + + private final Status status; + private final String ipAddress; + private final Integer osType; + private final String osDescripton; + private final NetworkSection networkSection; + private final Set resourceAllocations; + + public VApp(String id, String name, String type, URI href, Status status, String ipAddress, Integer osType, + String osDescripton, NetworkSection networkSection, Set resourceAllocations) { + super(id, name, type, href); + this.status = status; + this.ipAddress = ipAddress; + this.osType = osType; + this.osDescripton = osDescripton; + this.networkSection = networkSection; + this.resourceAllocations = ImmutableSet.copyOf(checkNotNull(resourceAllocations, "resourceAllocations")); + } + + public Status getStatus() { + return status; + } + + public String getIpAddress() { + return ipAddress; + } + + public Integer getOsType() { + return osType; + } + + public String getOsDescripton() { + return osDescripton; + } + + public NetworkSection getNetworkSection() { + return networkSection; + } + + public Set getResourceAllocations() { + return resourceAllocations; + } + + @Override + public Builder toBuilder() { + return Builder.fromVApp(this); + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", status=" + status + + ", ipAddress=" + ipAddress + ", osType=" + osType + ", osDescripton=" + osDescripton + + ", networkSection=" + networkSection + ", resourceAllocations=" + resourceAllocations + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java new file mode 100644 index 0000000000..6a970aa1ef --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java @@ -0,0 +1,218 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Set; + +import javax.annotation.Nullable; + +import com.google.common.base.CaseFormat; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * VDC is a virtual data center ,the API returns a list of VAPPs own by given bill site Id. + * + * @author Adrian Cole + */ +public class VDC extends Resource { + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Resource.Builder { + private String description; + private Status status; + private Set resourceEntities = Sets.newLinkedHashSet(); + private Set availableNetworks = Sets.newLinkedHashSet(); + + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder status(Status status) { + this.status = status; + return this; + } + + public Builder resourceEntity(Resource resourceEntity) { + this.resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity")); + return this; + } + + public Builder resourceEntities(Set resourceEntities) { + this.resourceEntities.addAll(checkNotNull(resourceEntities, "resourceEntities")); + return this; + } + + public Builder availableNetwork(Resource availableNetwork) { + this.availableNetworks.add(checkNotNull(availableNetwork, "availableNetwork")); + return this; + } + + public Builder availableNetworks(Set availableNetworks) { + this.availableNetworks.addAll(checkNotNull(availableNetworks, "availableNetworks")); + return this; + } + + @Override + public VDC build() { + return new VDC(id, name, type, href, description, status, resourceEntities, availableNetworks); + } + + public static Builder fromVDC(VDC in) { + return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref()) + .status(in.getStatus()).description(in.getDescription()).availableNetworks(in.getAvailableNetworks()) + .resourceEntities(in.getResourceEntities()); + } + + @Override + public Builder id(String id) { + return Builder.class.cast(super.id(id)); + } + + @Override + public Builder name(String name) { + return Builder.class.cast(super.name(name)); + } + + @Override + public Builder type(String type) { + return Builder.class.cast(super.type(type)); + } + + @Override + public Builder href(URI href) { + return Builder.class.cast(super.href(href)); + } + + } + + public enum Status { + /** + * Savvis VPDC successfully provisioned and available for use + */ + DEPLOYED, + /** + * Savvis VPDC need to be provisioned and cannot invoke any of the VCloud (post request method + * type) API's + */ + DESIGNING, + /** + * Savvis VPDC need to be provisioned and cannot invoke any of the VCloud (post request method + * type) API's + */ + SAVED, + /** + * Please wait for the provisioning process to complete and cannot invoke any of the VCloud + * (post request method type) API's + */ + INQUEUE, + /** + * Please wait for the provisioning process to complete and cannot invoke any of the VCloud + * (post request method type) API's + */ + PROVISIONING, + /** + * Please kindly contact Savvis administrator for further clarification/assistance with the + * respective request data. and cannot invoke any of the VCloud (post request method type) + * API's + */ + PARTIALLY_DEPLOYED, + /** + * Please kindly contact Savvis administrator for further clarification/assistance with the + * respective request data and cannot invoke any of the VCloud (post request method type) + * API's + */ + FAILED, UNRECOGNIZED; + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + public static Status fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + @Nullable + private final String description; + private final VDC.Status status; + private final Set resourceEntities; + private final Set availableNetworks; + + public VDC(String id, String name, String type, URI href, @Nullable String description, VDC.Status status, + Set resourceEntities, Set availableNetworks) { + super(id, name, type, href); + this.description = description; + this.status = checkNotNull(status, "status"); + this.resourceEntities = ImmutableSet.copyOf(checkNotNull(resourceEntities, "resourceEntities")); + this.availableNetworks = ImmutableSet.copyOf(checkNotNull(availableNetworks, "availableNetworks")); + } + + /** + * {@inheritDoc} + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + public VDC.Status getStatus() { + return status; + } + + /** + * {@inheritDoc} + */ + public Set getResourceEntities() { + return resourceEntities; + } + + /** + * {@inheritDoc} + */ + public Set getAvailableNetworks() { + return availableNetworks; + } + + @Override + public Builder toBuilder() { + return Builder.fromVDC(this); + } + + @Override + public String toString() { + return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", description=" + description + + ", status=" + status + ", resourceEntities=" + resourceEntities + ", availableNetworks=" + + availableNetworks + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java deleted file mode 100644 index 19510622fd..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCNetworkImpl.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.domain.internal; - -import java.net.URI; -import java.util.Set; - -import javax.annotation.Nullable; - -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.firewall.FirewallRule; -import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; - -import com.google.common.collect.Sets; - -/** - * Locations of resources in vCloud - * - * @author Kedar Dave - * - */ -public class SymphonyVPDCNetworkImpl extends ReferenceTypeImpl implements SymphonyVPDCNetwork { - - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; - protected final String description; - protected final Set dnsServers = Sets.newHashSet(); - protected final String gateway; - protected final String netmask; - protected final Set fenceModes = Sets.newHashSet(); - @Nullable - protected final Boolean dhcp; - protected final Set natRules = Sets.newHashSet(); - protected final Set firewallRules = Sets.newHashSet(); - - public SymphonyVPDCNetworkImpl(String name, String type, URI id, String description, Set dnsServers, - String gateway, String netmask, Set fenceModes, Boolean dhcp, Set natRules, - Set firewallRules) { - super(name, type, id); - this.description = description; - this.dnsServers.addAll(dnsServers); - this.gateway = gateway; - this.netmask = netmask; - this.fenceModes.addAll(fenceModes); - this.dhcp = dhcp; - this.natRules.addAll(natRules); - this.firewallRules.addAll(firewallRules); - } - - /** - * {@inheritDoc} - */ - public String getDescription() { - return description; - } - - /** - * {@inheritDoc} - */ - public Set getDnsServers() { - return dnsServers; - } - - /** - * {@inheritDoc} - */ - public String getGateway() { - return gateway; - } - - /** - * {@inheritDoc} - */ - public String getNetmask() { - return netmask; - } - - /** - * {@inheritDoc} - */ - public Set getFenceModes() { - return fenceModes; - } - - /** - * {@inheritDoc} - */ - public Boolean isDhcp() { - return dhcp; - } - - /** - * {@inheritDoc} - */ - public Set getNatRules() { - return natRules; - } - - /** - * {@inheritDoc} - */ - public Set getFirewallRules() { - return firewallRules; - } - - @Override - public int compareTo(ReferenceType o) { - return (this == o) ? 0 : getHref().compareTo(o.getHref()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode()); - result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode()); - result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode()); - result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode()); - result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); - result = prime * result + ((natRules == null) ? 0 : natRules.hashCode()); - result = prime * result + ((netmask == null) ? 0 : netmask.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - SymphonyVPDCNetworkImpl other = (SymphonyVPDCNetworkImpl) obj; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (dhcp == null) { - if (other.dhcp != null) - return false; - } else if (!dhcp.equals(other.dhcp)) - return false; - if (dnsServers == null) { - if (other.dnsServers != null) - return false; - } else if (!dnsServers.equals(other.dnsServers)) - return false; - if (fenceModes == null) { - if (other.fenceModes != null) - return false; - } else if (!fenceModes.equals(other.fenceModes)) - return false; - if (firewallRules == null) { - if (other.firewallRules != null) - return false; - } else if (!firewallRules.equals(other.firewallRules)) - return false; - if (gateway == null) { - if (other.gateway != null) - return false; - } else if (!gateway.equals(other.gateway)) - return false; - if (natRules == null) { - if (other.natRules != null) - return false; - } else if (!natRules.equals(other.natRules)) - return false; - if (netmask == null) { - if (other.netmask != null) - return false; - } else if (!netmask.equals(other.netmask)) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description - + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules=" - + firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask=" + netmask + "]"; - } - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCVDCImpl.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCVDCImpl.java deleted file mode 100644 index 5a8d829b7f..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/SymphonyVPDCVDCImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.jclouds.savvis.vpdc.domain.internal; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; -import java.util.Map; - -import javax.annotation.Nullable; - -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.Capacity; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.VDCImpl; - -/** - * Locations of resources in SymphonyVPDC vDC - * - * @author Adrian Cole - * - */ -public class SymphonyVPDCVDCImpl extends VDCImpl implements SymphonyVPDCVDC { - private final String offeringTag; - - /** The serialVersionUID */ - private static final long serialVersionUID = 8464716396538298809L; - - public SymphonyVPDCVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, - @Nullable String description, Iterable tasks, AllocationModel allocationModel, - @Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity, - Map resourceEntities, Map availableNetworks, int nicQuota, - int networkQuota, int vmQuota, boolean isEnabled, String offeringTag) { - super(name, type, id, status, org, description, tasks, allocationModel, storageCapacity, cpuCapacity, - memoryCapacity, resourceEntities, availableNetworks, nicQuota, networkQuota, vmQuota, isEnabled); - this.offeringTag = checkNotNull(offeringTag, "offeringTag"); - } - - @Override - public String getOfferingTag() { - return offeringTag; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((offeringTag == null) ? 0 : offeringTag.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - SymphonyVPDCVDCImpl other = (SymphonyVPDCVDCImpl) obj; - if (offeringTag == null) { - if (other.offeringTag != null) - return false; - } else if (!offeringTag.equals(other.offeringTag)) - return false; - return true; - } - - @Override - public String toString() { - return "[id=" + getHref() + ", name=" + getName() + ", description=" + getDescription() + ", offeringTag=" - + offeringTag + "]"; - } -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java similarity index 77% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java index ce962be795..ebbf14fc87 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/SymphonyVPDCComputeServiceContextModule.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java @@ -17,14 +17,18 @@ * ==================================================================== */ -package org.jclouds.savvis.vpdc.compute.config; +package org.jclouds.savvis.vpdc.domain.internal; -import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule; +import java.util.Set; + +import org.jclouds.savvis.vpdc.domain.Resource; /** * * @author Adrian Cole */ -public class SymphonyVPDCComputeServiceContextModule extends VCloudExpressComputeServiceContextModule { +public interface VCloudSession { + String getVCloudToken(); -} + Set getOrgs(); +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java new file mode 100644 index 0000000000..9f65e6386e --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java @@ -0,0 +1,59 @@ +package org.jclouds.savvis.vpdc.domain.vapp; + +/** + * + * @author Adrian Cole + */ +public class Network { + private final String name; + private final String description; + + public Network(String name, String description) { + this.name = name; + this.description = description; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((name == null) ? 0 : name.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; + Network other = (Network) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + return "Network [name=" + name + ", description=" + description + "]"; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java new file mode 100644 index 0000000000..b99c363bd5 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java @@ -0,0 +1,71 @@ +package org.jclouds.savvis.vpdc.domain.vapp; + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + +/** + * The NetworkSection element shall list all logical networks used in the OVF package. + * + * @author Adrian Cole + */ +public class NetworkSection { + private final String info; + private final Set networks; + + public NetworkSection(String info, Iterable networks) { + this.info = info; + this.networks = ImmutableSet. copyOf(networks); + } + + public String getInfo() { + return info; + } + + /** + * All networks referred to from Connection elements in all {@link VirtualHardwareSection} + * elements shall be defined in the NetworkSection. + * + * @return + */ + public Set getNetworks() { + return networks; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((info == null) ? 0 : info.hashCode()); + result = prime * result + ((networks == null) ? 0 : networks.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; + NetworkSection other = (NetworkSection) obj; + if (info == null) { + if (other.info != null) + return false; + } else if (!info.equals(other.info)) + return false; + if (networks == null) { + if (other.networks != null) + return false; + } else if (!networks.equals(other.networks)) + return false; + return true; + } + + @Override + public String toString() { + return "[info=" + info + ", networks=" + networks + "]"; + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java new file mode 100644 index 0000000000..fed2ed8f91 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java @@ -0,0 +1,110 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.features; + +import javax.annotation.Nullable; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.XMLResponseParser; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.savvis.vpdc.domain.Network; +import org.jclouds.savvis.vpdc.domain.Org; +import org.jclouds.savvis.vpdc.domain.Task; +import org.jclouds.savvis.vpdc.domain.VApp; +import org.jclouds.savvis.vpdc.domain.VDC; +import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie; +import org.jclouds.savvis.vpdc.functions.DefaultOrgIfNull; +import org.jclouds.savvis.vpdc.xml.NetworkHandler; +import org.jclouds.savvis.vpdc.xml.OrgHandler; +import org.jclouds.savvis.vpdc.xml.TaskHandler; +import org.jclouds.savvis.vpdc.xml.VAppHandler; +import org.jclouds.savvis.vpdc.xml.VDCHandler; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides access to Symphony VPDC resources via their REST API. + *

+ * + * @see + * @author Adrian Cole + */ +@RequestFilters(SetVCloudTokenCookie.class) +@Path("v{jclouds.api-version}") +public interface BrowsingAsyncClient { + + /** + * @see BrowsingClient#getOrg + */ + @GET + @XMLResponseParser(OrgHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("org/{billingSiteId}") + ListenableFuture getOrg( + @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId); + + /** + * @see BrowsingClient#getVDCInOrg + */ + @GET + @XMLResponseParser(VDCHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("org/{billingSiteId}/vdc/{vpdcId}") + ListenableFuture getVDCInOrg( + @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId, + @PathParam("vpdcId") String vpdcId); + + /** + * @see BrowsingClient#getNetworkInOrgAndVDC + */ + @GET + @XMLResponseParser(NetworkHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("org/{billingSiteId}/vdc/{vpdcId}/network/{network-tier-name}") + ListenableFuture getNetworkInOrgAndVDC( + @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId, + @PathParam("vpdcId") String vpdcId, @PathParam("network-tier-name") String networkTierName); + + /** + * @see BrowsingClient#getVAppInOrgAndVDC + */ + @GET + @XMLResponseParser(VAppHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("org/{billingSiteId}/vdc/{vpdcId}/vApp/{vAppId}") + ListenableFuture getVAppInOrgAndVDC( + @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId, + @PathParam("vpdcId") String vpdcId, @PathParam("vAppId") String vAppId); + + /** + * @see BrowsingClient#getTask + */ + @GET + @XMLResponseParser(TaskHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @Path("task/{taskId}") + ListenableFuture getTask(@PathParam("taskId") String taskId); + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java new file mode 100644 index 0000000000..3e7ce324d1 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java @@ -0,0 +1,105 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.features; + +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nullable; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.savvis.vpdc.domain.Network; +import org.jclouds.savvis.vpdc.domain.Org; +import org.jclouds.savvis.vpdc.domain.Task; +import org.jclouds.savvis.vpdc.domain.VApp; +import org.jclouds.savvis.vpdc.domain.VDC; + +/** + * Provides access to Symphony VPDC resources via their REST API. + *

+ * + * @see + * @author Adrian Cole + */ +@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS) +public interface BrowsingClient { + /** + * Get an organization, which can contain list of vDC entities + * + * @param billingSiteId + * billing site Id, or null for default + * @return organization, or null if not present + */ + Org getOrg(@Nullable String billingSiteId); + + /** + * VDC is a virtual data center ,the API returns a list of VAPPs own by given bill site Id. + * + * @param billingSiteId + * billing site Id, or null for default + * @param vpdcId + * vpdc Id + * @return a list of resource entity and VM configurations, or null if not present + */ + VDC getVDCInOrg(@Nullable String billingSiteId, String vpdcId); + + /** + * Get Network API returns network detail + * + * @param billingSiteId + * billing site Id, or null for default + * @param vpdcId + * vpdc Id + * @param networkTierName + * network tier name + * + * @return network detail if it used any one deployed VM and NetworkConfigSection defines various + * network features such NAT Public IP, Gateway and Netmask, or null if not present + */ + Network getNetworkInOrgAndVDC(String billingSiteId, String vpdcId, String networkTierName); + + /** + * VAPP is a software solution, the API returns details of virtual machine configuration such as + * CPU,RAM Memory and hard drive. The VM State is from the MW Database. + * + * @param billingSiteId + * billing site Id, or null for default + * @param vpdcId + * vpdc Id + * @param vAppId + * vApp ID + * + * @return A virtual application (vApp) is a software solution comprising one or more virtual + * machines, all of which are deployed, managed, and maintained as a unit, or null if not + * present + */ + VApp getVAppInOrgAndVDC(String billingSiteId, String vpdcId, String vAppId); + + /** + * Gets an existing task. + * + * @param taskId + * task id + * @return If the request is successful, caller could get the VApp/VMDK details as specified in + * the result element and if the request is not successful, caller would get empty + * VAPP/VMDK URL and respective validation (error) message. + */ + Task getTask(String taskId); + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java new file mode 100644 index 0000000000..425eafbeca --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java @@ -0,0 +1,53 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.filters; + +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Singleton; +import javax.ws.rs.core.HttpHeaders; + +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpRequestFilter; +import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.savvis.vpdc.internal.VCloudToken; + +/** + * Adds the VCloud Token to the request as a cookie + * + * @author Adrian Cole + * + */ +@Singleton +public class SetVCloudTokenCookie implements HttpRequestFilter { + private Provider vcloudTokenProvider; + + @Inject + public SetVCloudTokenCookie(@VCloudToken Provider authTokenProvider) { + this.vcloudTokenProvider = authTokenProvider; + } + + @Override + public HttpRequest filter(HttpRequest request) throws HttpException { + return ModifyRequest.replaceHeader(request, HttpHeaders.COOKIE, "vcloud-token=" + vcloudTokenProvider.get()); + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java new file mode 100644 index 0000000000..b4228c234b --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java @@ -0,0 +1,48 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.functions; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; +import javax.inject.Provider; + +import org.jclouds.savvis.vpdc.internal.Org; + +import com.google.common.base.Function; + +/** + * + * @author Adrian Cole + */ +public class DefaultOrgIfNull implements Function { + + private Provider defaultOrg; + + @Inject + public DefaultOrgIfNull(@Org Provider defaultOrg) { + this.defaultOrg = checkNotNull(defaultOrg, "defaultOrg"); + } + + public String apply(Object from) { + return from == null ? defaultOrg.get() : from.toString(); + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java new file mode 100644 index 0000000000..c2e6d79fbe --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java @@ -0,0 +1,76 @@ +package org.jclouds.savvis.vpdc.functions; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.http.HttpUtils.releasePayload; + +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Singleton; +import javax.ws.rs.core.HttpHeaders; + +import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.internal.VCloudSession; +import org.jclouds.savvis.vpdc.internal.VCloudToken; +import org.jclouds.savvis.vpdc.xml.OrgListHandler; + +import com.google.common.base.Function; + +/** + * This parses {@link VCloudSession} from HTTP headers. + * + * @author Adrian Cole + */ +@Singleton +public class ParseLoginResponseFromHeaders implements Function { + static final Pattern pattern = Pattern.compile("vcloud-token=([^;]+);.*"); + + private final ParseSax.Factory factory; + private final Provider orgHandlerProvider; + + @Inject + private ParseLoginResponseFromHeaders(Factory factory, + Provider orgHandlerProvider) { + this.factory = factory; + this.orgHandlerProvider = orgHandlerProvider; + } + + /** + * parses the http response headers to create a new {@link VCloudSession} object. + */ + public VCloudSession apply(HttpResponse from) { + String cookieHeader = checkNotNull(from.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE), + HttpHeaders.SET_COOKIE); + + final Matcher matcher = pattern.matcher(cookieHeader); + boolean matchFound = matcher.find(); + try { + if (matchFound) { + final Set org = factory.create(orgHandlerProvider.get()).parse( + from.getPayload().getInput()); + + return new VCloudSession() { + @VCloudToken + public String getVCloudToken() { + return matcher.group(1); + } + + public Set getOrgs() { + return org; + } + }; + + } + } finally { + releasePayload(from); + } + throw new HttpResponseException("not found ", null, from); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java similarity index 97% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java index 6a667705cb..b38c2a9f80 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandler.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java @@ -42,7 +42,7 @@ import com.google.common.io.Closeables; * */ @Singleton -public class SymphonyVPDCErrorHandler implements HttpErrorHandler { +public class VPDCErrorHandler implements HttpErrorHandler { @Resource protected Logger logger = Logger.NULL; diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java new file mode 100644 index 0000000000..ab24bd9f01 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.internal; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.http.filters.BasicAuthentication; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.savvis.vpdc.domain.internal.VCloudSession; +import org.jclouds.savvis.vpdc.functions.ParseLoginResponseFromHeaders; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Establishes a context with a VCloud endpoint. + *

+ * + * @see + * @author Adrian Cole + */ +@RequestFilters(BasicAuthentication.class) +public interface LoginAsyncClient { + + /** + * This request returns a token to use in subsequent requests. After 30 minutes of inactivity, + * the token expires and you have to request a new token with this call. + */ + @POST + @ResponseParser(ParseLoginResponseFromHeaders.class) + @Path("v{jclouds.api-version}/login") + ListenableFuture login(); +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java new file mode 100644 index 0000000000..87396d0e53 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a VCloud Network. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Network { + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java new file mode 100644 index 0000000000..d8f74351fc --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a VCloud express Org. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Org { + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCVDC.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java similarity index 65% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCVDC.java rename to sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java index 7c8913dbf5..d90a52a6b1 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/SymphonyVPDCVDC.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java @@ -17,18 +17,24 @@ * ==================================================================== */ -package org.jclouds.savvis.vpdc.domain; +package org.jclouds.savvis.vpdc.internal; -import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCVDCImpl; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.VDC; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; -import com.google.inject.ImplementedBy; +import javax.inject.Qualifier; /** + * A VCloud Session Token + * * @author Adrian Cole + * */ -@ImplementedBy(SymphonyVPDCVDCImpl.class) -public interface SymphonyVPDCVDC extends VDC { - String getOfferingTag(); +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface VCloudToken { + } \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java new file mode 100644 index 0000000000..5f74684ce0 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.internal; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Related to a VCloud express Catalog. + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface VDC { + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java new file mode 100644 index 0000000000..fd180ef672 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java @@ -0,0 +1,42 @@ +package org.jclouds.savvis.vpdc.predicates; + +import javax.annotation.Resource; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.savvis.vpdc.VPDCClient; +import org.jclouds.savvis.vpdc.domain.Task; + +import com.google.common.base.Predicate; +import com.google.inject.Inject; + +/** + * + * Tests to see if a task succeeds. + * + * @author Adrian Cole + */ +@Singleton +public class TaskSuccess implements Predicate { + + private final VPDCClient client; + + @Resource + protected Logger logger = Logger.NULL; + + @Inject + public TaskSuccess(VPDCClient client) { + this.client = client; + } + + public boolean apply(String taskId) { + logger.trace("looking for status on task %s", taskId); + + Task task = client.getBrowsingClient().getTask(taskId); + logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus()); + if (task.getStatus() == Task.Status.ERROR || task.getStatus() == Task.Status.NONE) + throw new RuntimeException("error on task: " + task.getHref() + " error: " + task.getError()); + return task.getStatus() == Task.Status.SUCCESS; + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java new file mode 100644 index 0000000000..38874dcc59 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.reference; + +/** + * Configuration properties and constants used in VCloud connections. + * + * @author Adrian Cole + */ +public interface VCloudConstants { + public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema"; + + /** + * name of the default network, in the default VDC that your vApp will join. + */ + public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network"; + public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode"; + + public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns"; + public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema"; + + public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete"; + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java new file mode 100644 index 0000000000..99c9b81878 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java @@ -0,0 +1,207 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.reference; + +import javax.ws.rs.core.MediaType; + +/** + * Resource Types used in VCloud + * + * @see MediaType + */ +public interface VCloudMediaType { + /** + * "application/vnd.vmware.vcloud.error+xml" + */ + public final static String ERROR_XML = "application/vnd.vmware.vcloud.error+xml"; + + /** + * "application/vnd.vmware.vcloud.error+xml" + */ + public final static MediaType ERROR_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.error+xml"); + + /** + * "application/vnd.vmware.vcloud.vcloud+xml" + */ + public final static String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml"; + + /** + * "application/vnd.vmware.vcloud.vcloud+xml" + */ + public final static MediaType VCLOUD_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vcloud+xml"); + /** + * "application/vnd.vmware.vcloud.orgList+xml" + */ + public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml"; + + /** + * "application/vnd.vmware.vcloud.orgList+xml" + */ + public final static MediaType ORGLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.orgList+xml"); + /** + * "application/vnd.vmware.vcloud.org+xml" + */ + public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml"; + /** + * "application/vnd.vmware.vcloud.org+xml" + */ + public final static MediaType ORG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.org+xml"); + + /** + * "application/vnd.vmware.vcloud.vdc+xml" + */ + public final static String VDC_XML = "application/vnd.vmware.vcloud.vdc+xml"; + /** + * "application/vnd.vmware.vcloud.vdc+xml" + */ + public final static MediaType VDC_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vdc+xml"); + + /** + * "application/vnd.vmware.vcloud.catalog+xml" + */ + public final static String CATALOG_XML = "application/vnd.vmware.vcloud.catalog+xml"; + /** + * "application/vnd.vmware.vcloud.catalog+xml" + */ + public final static MediaType CATALOG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.catalog+xml"); + + /** + * "application/vnd.vmware.vcloud.tasksList+xml" + */ + public final static String TASKSLIST_XML = "application/vnd.vmware.vcloud.tasksList+xml"; + /** + * "application/vnd.vmware.vcloud.tasksList+xml" + */ + public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.tasksList+xml"); + + /** + * "application/vnd.vmware.vcloud.catalogItem+xml" + */ + public final static String CATALOGITEM_XML = "application/vnd.vmware.vcloud.catalogItem+xml"; + /** + * "application/vnd.vmware.vcloud.catalogItem+xml" + */ + public final static MediaType CATALOGITEM_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.catalogItem+xml"); + /** + * "application/vnd.vmware.vcloud.networkConnectionSection+xml" + */ + public final static String NETWORKCONNECTIONSECTION_XML = "application/vnd.vmware.vcloud.networkConnectionSection+xml"; + /** + * "application/vnd.vmware.vcloud.networkConnectionSection+xml" + */ + public final static MediaType NETWORKCONNECTIONSECTION_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.networkConnectionSection+xml"); + /** + * "application/vnd.vmware.vcloud.virtualHardwareSection+xml" + */ + public final static String VIRTUALHARDWARESECTION_XML = "application/vnd.vmware.vcloud.virtualHardwareSection+xml"; + /** + * "application/vnd.vmware.vcloud.virtualHardwareSection+xml" + */ + public final static MediaType VIRTUALHARDWARESECTION_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.virtualHardwareSection+xml"); + /** + * "application/vnd.vmware.vcloud.guestCustomizationSection+xml" + */ + public final static String GUESTCUSTOMIZATIONSECTION_XML = "application/vnd.vmware.vcloud.guestCustomizationSection+xml"; + /** + * "application/vnd.vmware.vcloud.guestCustomizationSection+xml" + */ + public final static MediaType GUESTCUSTOMIZATIONSECTION_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.guestCustomizationSection+xml"); + + /** + * "application/vnd.vmware.vcloud.networkSection+xml" + */ + public final static String NETWORKSECTION_XML = "application/vnd.vmware.vcloud.networkSection+xml"; + /** + * "application/vnd.vmware.vcloud.networkSection+xml" + */ + public final static MediaType NETWORKSECTION_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.networkSection+xml"); + + /** + * "application/vnd.vmware.vcloud.task+xml" + */ + public final static String TASK_XML = "application/vnd.vmware.vcloud.task+xml"; + /** + * "application/vnd.vmware.vcloud.task+xml" + */ + public final static MediaType TASK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.task+xml"); + + /** + * "application/vnd.vmware.vcloud.undeployVAppParams+xml" + */ + public final static String UNDEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.undeployVAppParams+xml"; + /** + * "application/vnd.vmware.vcloud.undeployVAppParams+xml" + */ + public final static MediaType UNDEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.undeployVAppParams+xml"); + + /** + * "application/vnd.vmware.vcloud.deployVAppParams+xml" + */ + public final static String DEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.deployVAppParams+xml"; + /** + * "application/vnd.vmware.vcloud.deployVAppParams+xml" + */ + public final static MediaType DEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.deployVAppParams+xml"); + + /** + * "application/vnd.vmware.vcloud.vApp+xml" + */ + public final static String VAPP_XML = "application/vnd.vmware.vcloud.vApp+xml"; + /** + * "application/vnd.vmware.vcloud.vApp+xml" + */ + public final static MediaType VAPP_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vApp+xml"); + + /** + * "application/vnd.vmware.vcloud.vm+xml" + */ + public final static String VM_XML = "application/vnd.vmware.vcloud.vm+xml"; + /** + * "application/vnd.vmware.vcloud.vm+xml" + */ + public final static MediaType VM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vm+xml"); + + /** + * "application/vnd.vmware.vcloud.vAppTemplate+xml" + */ + public final static String VAPPTEMPLATE_XML = "application/vnd.vmware.vcloud.vAppTemplate+xml"; + /** + * "application/vnd.vmware.vcloud.vAppTemplate+xml" + */ + public final static MediaType VAPPTEMPLATE_XML_TYPE = new MediaType("application", + "vnd.vmware.vcloud.vAppTemplate+xml"); + + /** + * "application/vnd.vmware.vcloud.network+xml" + */ + public final static String NETWORK_XML = "application/vnd.vmware.vcloud.network+xml"; + /** + * "application/vnd.vmware.vcloud.network+xml" + */ + public final static MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml"); + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java new file mode 100644 index 0000000000..3558729a60 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java @@ -0,0 +1,72 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.util; + +import java.net.URI; +import java.util.Map; + +import org.jclouds.savvis.vpdc.domain.Link; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.xml.sax.Attributes; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; + +/** + * + * @author Adrian Cole + */ +public class Utils { + + public static Resource newResource(Map attributes, String defaultType) { + String uri = attributes.get("href"); + String type = attributes.get("type"); + // savvis org has null href + String id = null; + URI href = null; + if (uri != null) { + href = URI.create(uri); + id = uri.substring(uri.lastIndexOf('/') + 1); + } + return (attributes.containsKey("rel")) ? new Link(id, attributes.get("name"), type != null ? type : defaultType, + href, attributes.get("rel")) : new Resource(id, attributes.get("name"), type != null ? type : defaultType, + href); + } + + public static Map cleanseAttributes(Attributes in) { + Builder attrs = ImmutableMap. builder(); + for (int i = 0; i < in.getLength(); i++) { + String name = in.getQName(i); + if (name.indexOf(':') != -1) + name = name.substring(name.indexOf(':') + 1); + attrs.put(name, in.getValue(i)); + } + return attrs.build(); + } + + public static String currentOrNull(StringBuilder currentText) { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } + + public static Resource newResource(Map attributes) { + return newResource(attributes, null); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java new file mode 100644 index 0000000000..ef176aa529 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java @@ -0,0 +1,80 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes; +import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull; +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Map; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Network; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableMap; + +/** + * @author Adrian Cole + */ +public class NetworkHandler extends ParseSax.HandlerWithResult { + + protected StringBuilder currentText = new StringBuilder(); + + protected Network.Builder builder = Network.builder(); + + public Network getResult() { + try { + return builder.build(); + } finally { + builder = Network.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Network")) { + // savvis doesn't add href in the header for some reason + if (!attributes.containsKey("href") && getRequest() != null) + attributes = ImmutableMap. builder().putAll(attributes) + .put("href", getRequest().getEndpoint().toASCIIString()).build(); + Resource org = newResource(attributes); + builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref()); + } else if (qName.endsWith("NatRule")) { + builder.internalToExternalNATRule(attributes.get("internalIP"), attributes.get("externalIP")); + } + } + + public void endElement(String uri, String name, String qName) { + if (qName.endsWith("Gateway")) { + builder.gateway(currentOrNull(currentText)); + } else if (qName.endsWith("Netmask")) { + builder.netmask(currentOrNull(currentText)); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java new file mode 100644 index 0000000000..eb05aec977 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java @@ -0,0 +1,58 @@ +package org.jclouds.savvis.vpdc.xml; + +import java.util.Map; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.vapp.Network; +import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection; +import org.jclouds.savvis.vpdc.util.Utils; +import org.xml.sax.Attributes; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; + +/** + * @author Adrian Cole + */ +public class NetworkSectionHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + + protected String info; + protected String name; + protected String description; + + protected Builder networks = ImmutableSet. builder(); + + public NetworkSection getResult() { + try { + return new NetworkSection(info, networks.build()); + } finally { + this.info = null; + this.networks = ImmutableSet. builder(); + } + } + + public void startElement(String uri, String localName, String qName, Attributes attrs) { + Map attributes = Utils.cleanseAttributes(attrs); + if (qName.endsWith("Network")) { + name = attributes.get("name"); + } + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (qName.endsWith("Info")) { + this.info = Utils.currentOrNull(currentText); + } else if (qName.endsWith("Description")) { + this.description = Utils.currentOrNull(currentText); + } else if (qName.endsWith("Network")) { + this.networks.add(new Network(name, description)); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java new file mode 100644 index 0000000000..20b847f872 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes; +import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull; +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Map; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Link; +import org.jclouds.savvis.vpdc.domain.Org; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableMap; + +/** + * @author Adrian Cole + */ +public class OrgHandler extends ParseSax.HandlerWithResult { + + protected StringBuilder currentText = new StringBuilder(); + + protected Org.Builder builder = Org.builder(); + + public Org getResult() { + try { + return builder.build(); + } finally { + builder = Org.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Org")) { + // savvis doesn't add href in the header for some reason + if (!attributes.containsKey("href") && getRequest() != null) + attributes = ImmutableMap. builder().putAll(attributes) + .put("href", getRequest().getEndpoint().toASCIIString()).build(); + Resource org = newResource(attributes); + builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref()); + } else if (qName.endsWith("Link")) { + Link link = Link.class.cast(newResource(attributes)); + if ("down".equals(link.getRel())) + builder.vDC(link); + else + builder.image(link); + } + } + + public void endElement(String uri, String name, String qName) { + if (qName.endsWith("Description")) { + builder.description(currentOrNull(currentText)); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java new file mode 100644 index 0000000000..71730f6333 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java @@ -0,0 +1,39 @@ +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes; +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Map; +import java.util.Set; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; + +/** + * @author Adrian Cole + */ +public class OrgListHandler extends ParseSax.HandlerWithResult> { + + private Builder org = ImmutableSet. builder(); + + public Set getResult() { + try { + return org.build(); + } finally { + org = ImmutableSet. builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Org")) { + org.add(newResource(attributes)); + } + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java new file mode 100644 index 0000000000..112445d639 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java @@ -0,0 +1,59 @@ +package org.jclouds.savvis.vpdc.xml; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.ResourceAllocation; +import org.jclouds.savvis.vpdc.util.Utils; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class ResourceAllocationHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + + protected ResourceAllocation.Builder builder = ResourceAllocation.builder(); + + public ResourceAllocation getResult() { + try { + return builder.build(); + } finally { + builder = ResourceAllocation.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + } + + @Override + public void endElement(String uri, String localName, String qName) { + String current = Utils.currentOrNull(currentText); + if (current != null) { + if (qName.endsWith("AllocationUnits")) { + builder.allocationUnits(current); + } else if (qName.endsWith("Description")) { + builder.description(current); + } else if (qName.endsWith("ElementName")) { + builder.name(current); + } else if (qName.endsWith("InstanceID")) { + builder.id(Integer.parseInt(current)); + } else if (qName.endsWith("ResourceType")) { + builder.type(ResourceAllocation.Type.fromValue(current)); + } else if (qName.endsWith("VirtualQuantity")) { + builder.virtualQuantity(Long.parseLong(current)); + } else if (qName.endsWith("Caption")) { + builder.caption(current); + } else if (qName.endsWith("Connection")) { + builder.connection(current); + } else if (qName.endsWith("HostResource")) { + builder.hostResource(current); + } + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java deleted file mode 100644 index ce31f2f95f..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCNetworkHandler.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.xml; - -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork; -import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCNetworkImpl; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy; -import org.jclouds.vcloud.domain.network.firewall.FirewallRule; -import org.jclouds.vcloud.domain.network.nat.NatProtocol; -import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Sets; - -/** - * @author Kedar Dave - */ -public class SymphonyVPDCNetworkHandler extends ParseSax.HandlerWithResult{ - - @Resource - protected Logger logger = Logger.NULL; - - private ReferenceType ips; - private ReferenceType extension; - - protected StringBuilder currentText = new StringBuilder(); - - protected ReferenceType network; - - protected String description; - - protected Set dnsServers = Sets.newLinkedHashSet(); - protected String gateway; - protected String netmask; - protected Set fenceModes = Sets.newLinkedHashSet(); - protected Boolean dhcp; - protected Set natRules = Sets.newLinkedHashSet(); - protected Set firewallRules = Sets.newLinkedHashSet(); - - protected String externalIP; - protected Integer externalPort; - protected String internalIP; - protected Integer internalPort; - - protected FirewallPolicy policy; - protected String sourceIP; - protected int sourcePort; - - public SymphonyVPDCNetwork getResult() { - return new SymphonyVPDCNetworkImpl(network.getName(), network.getType(), network.getHref(), description, - dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); - if (qName.endsWith("Network")) { - network = newReferenceType(attributes); - } else if (qName.endsWith("Link")) { - if ("IP Addresses".equals(attributes.get("name"))) { - ips = newReferenceType(attributes); - } else if ("down".equals(attributes.get("rel"))) { - extension = newReferenceType(attributes); - } - } - } - - public void endElement(String uri, String name, String qName) { - if (qName.equals("Description")) { - description = currentOrNull(); - } else if (qName.equals("Dns")) { - dnsServers.add(currentOrNull()); - } else if (qName.equals("Gateway")) { - gateway = currentOrNull(); - } else if (qName.equals("Netmask")) { - netmask = currentOrNull(); - } else if (qName.equals("FenceMode")) { - try { - fenceModes.add(FenceMode.fromValue(currentOrNull())); - } catch (IllegalArgumentException e) { - fenceModes.add(FenceMode.BRIDGED); - } - } else if (qName.equals("Dhcp")) { - dhcp = new Boolean(currentOrNull()); - } else if (qName.equals("NatRule")) { - natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP)); - externalIP = null; - externalPort = null; - internalIP = null; - internalPort = null; - } else if (qName.equals("ExternalIP")) { - externalIP = currentOrNull(); - } else if (qName.equals("ExternalPort")) { - externalPort = Integer.parseInt(currentOrNull()); - } else if (qName.equals("InternalIP")) { - internalIP = currentOrNull(); - } else if (qName.equals("InternalPort")) { - internalPort = Integer.parseInt(currentOrNull()); - } else if (qName.equals("FirewallRule")) { - firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP)); - policy = null; - sourceIP = null; - sourcePort = -1; - } else if (qName.equals("Policy")) { - policy = FirewallPolicy.fromValue(currentOrNull()); - } else if (qName.equals("SourceIp")) { - sourceIP = currentOrNull(); - } else if (qName.equals("SourcePort")) { - sourcePort = Integer.parseInt(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/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java deleted file mode 100644 index 5e56a0ccc5..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVAppHandler.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.xml; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; -import static org.jclouds.vcloud.util.Utils.newReferenceType; - -import java.net.URI; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.logging.Logger; -import org.jclouds.vcloud.VCloudExpressMediaType; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.System; -import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler; -import org.jclouds.vcloud.xml.ovf.SystemHandler; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Sets; - -/** - * @author Kedar Dave - */ -public class SymphonyVPDCVAppHandler extends ParseSax.HandlerWithResult { - private final String apiVersion; - private final SystemHandler systemHandler; - private final ResourceAllocationHandler allocationHandler; - @Resource - protected Logger logger = Logger.NULL; - - @Inject - public SymphonyVPDCVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler, - ResourceAllocationHandler allocationHandler) { - this.apiVersion = apiVersion; - this.systemHandler = systemHandler; - this.allocationHandler = allocationHandler; - } - - protected System system; - protected Set allocations = Sets.newLinkedHashSet(); - protected Status status; - protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); - protected StringBuilder currentText = new StringBuilder(); - protected String operatingSystemDescription; - protected boolean inOs; - protected String networkName; - protected String name; - protected Integer osType; - protected URI location; - protected Long size; - protected ReferenceType vDC; - - public VCloudExpressVApp getResult() { - return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType, - operatingSystemDescription, system, allocations); - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); - if (qName.endsWith("VApp")) { - ReferenceType resource = newReferenceType(attributes); - name = resource.getName(); - location = resource.getHref(); - String statusString = attributes.get("status"); - if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString)) - status = Status.OFF; - else - status = Status.fromValue(statusString); - if (attributes.containsKey("size")) - size = new Long(attributes.get("size")); - } else if (qName.equals("Link")) { // type should never be missing - if (attributes.containsKey("type") && attributes.get("type").equals(VCloudExpressMediaType.VDC_XML)) { - vDC = newReferenceType(attributes); - } - } else if (qName.endsWith("OperatingSystemSection")) { - inOs = true; - if (attributes.containsKey("id")) - osType = Integer.parseInt(attributes.get("id")); - } else if (qName.endsWith("NetworkConnection")) { - networkName = attributes.get("Network"); - } else { - systemHandler.startElement(uri, localName, qName, attrs); - allocationHandler.startElement(uri, localName, qName, attrs); - } - - } - - @Override - public void endElement(String uri, String localName, String qName) throws SAXException { - if (qName.endsWith("OperatingSystemSection")) { - inOs = false; - } else if (inOs && qName.endsWith("Description")) { - operatingSystemDescription = currentText.toString().trim(); - } else if (qName.endsWith("IpAddress")) { - networkToAddresses.put(networkName, currentText.toString().trim()); - } else if (qName.equals("System")) { - systemHandler.endElement(uri, localName, qName); - system = systemHandler.getResult(); - } else if (qName.equals("Item")) { - allocationHandler.endElement(uri, localName, qName); - allocations.add(allocationHandler.getResult()); - } else { - systemHandler.endElement(uri, localName, qName); - allocationHandler.endElement(uri, localName, qName); - } - currentText = new StringBuilder(); - } - - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - systemHandler.characters(ch, start, length); - allocationHandler.characters(ch, start, length); - } - -} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandler.java deleted file mode 100644 index b1295f29c6..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.xml; - -import javax.inject.Inject; - -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC; -import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCVDCImpl; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.VDCHandler; - -/** - * @author Adrian Cole - */ -public class SymphonyVPDCVDCHandler extends VDCHandler { - - @Inject - public SymphonyVPDCVDCHandler(TaskHandler taskHandler) { - super(taskHandler); - } - - private String offeringTag; - - public SymphonyVPDCVDC getResult() { - VDC vDC = super.getResult(); - return new SymphonyVPDCVDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), status, org, description, tasks, - allocationModel, storageCapacity, cpuCapacity, memoryCapacity, resourceEntities, availableNetworks, - nicQuota, networkQuota, vmQuota, isEnabled, offeringTag); - } - - @Override - public void endElement(String uri, String name, String qName) { - if (qName.endsWith("OfferingTag")) { - this.offeringTag = currentOrNull(); - } - super.endElement(uri, name, qName); - - } - -} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java new file mode 100644 index 0000000000..49f8e44743 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java @@ -0,0 +1,106 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes; +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Date; +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.date.DateService; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.logging.Logger; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.Task; +import org.jclouds.savvis.vpdc.domain.TaskError; +import org.jclouds.savvis.vpdc.util.Utils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +/** + * @author Adrian Cole + */ +public class TaskHandler extends ParseSax.HandlerWithResult { + @javax.annotation.Resource + protected Logger logger = Logger.NULL; + + protected final DateService dateService; + + private Task.Builder builder = Task.builder(); + + @Inject + public TaskHandler(DateService dateService) { + this.dateService = dateService; + } + + public Task getResult() { + try { + return builder.build(); + } finally { + builder = Task.builder(); + } + + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Task")) { + Resource task = newResource(attributes); + builder.id(task.getId()); + builder.type(task.getType()); + builder.href(task.getHref()); + if (attributes.containsKey("startTime")) + builder.startTime(parseDate(attributes.get("startTime"))); + if (attributes.containsKey("endTime")) + builder.endTime(parseDate(attributes.get("endTime"))); + builder.status(Task.Status.fromValue(attributes.get("status"))); + } else if (qName.endsWith("Owner")) { + builder.owner(Utils.newResource(attributes)); + } else if (qName.endsWith("Result")) { + builder.result(Utils.newResource(attributes)); + } else if (qName.endsWith("Error")) { + builder.error(new TaskError(attributes.get("message"), Integer.parseInt(attributes.get("majorErrorCode")), + Integer.parseInt(attributes.get("minorErrorCode")), attributes.get("vendorSpecificErrorCode"))); + } + + } + + private Date parseDate(String toParse) { + try { + return dateService.iso8601DateParse(toParse); + } catch (RuntimeException e) { + logger.error(e, "error parsing date, %s", toParse); + } + return null; + } + + @Override + public void endElement(String uri, String localName, String qName) { + } + + @Override + public void characters(char ch[], int start, int length) { + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java new file mode 100644 index 0000000000..3c5a22044a --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java @@ -0,0 +1,68 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Task; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; + +/** + * @author Adrian Cole + */ +public class TasksListHandler extends ParseSax.HandlerWithResult> { + + private Builder tasks = ImmutableSet. builder(); + private final TaskHandler taskHandler; + + @Inject + public TasksListHandler(TaskHandler taskHandler) { + this.taskHandler = taskHandler; + } + + public Set getResult() { + try { + return tasks.build(); + } finally { + tasks = ImmutableSet. builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + taskHandler.startElement(uri, localName, qName, attrs); + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + taskHandler.endElement(uri, localName, qName); + if (qName.equals("Task")) { + this.tasks.add(taskHandler.getResult()); + } + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java new file mode 100644 index 0000000000..b78ba99f80 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java @@ -0,0 +1,111 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.VApp; +import org.jclouds.savvis.vpdc.util.Utils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableMap; + +/** + * @author Kedar Dave + */ +public class VAppHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + private final NetworkSectionHandler networkSectionHandler; + private final ResourceAllocationHandler allocationHandler; + + @Inject + public VAppHandler(NetworkSectionHandler networkSectionHandler, ResourceAllocationHandler allocationHandler) { + this.networkSectionHandler = networkSectionHandler; + this.allocationHandler = allocationHandler; + } + + private VApp.Builder builder = VApp.builder(); + protected boolean inOs; + + public VApp getResult() { + try { + return builder.build(); + } finally { + builder = VApp.builder(); + } + } + + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = Utils.cleanseAttributes(attrs); + if (qName.endsWith("VApp")) { + // savvis doesn't add href in the header for some reason + if (!attributes.containsKey("href") && getRequest() != null) + attributes = ImmutableMap. builder().putAll(attributes) + .put("href", getRequest().getEndpoint().toASCIIString()).build(); + Resource vApp = newResource(attributes); + builder.name(vApp.getName()).type(vApp.getType()).id(vApp.getId()).href(vApp.getHref()); + builder.status(VApp.Status.fromValue(attributes.get("status"))); + } else if (qName.endsWith("OperatingSystemSection")) { + inOs = true; + if (attributes.containsKey("id")) + builder.osType(Integer.parseInt(attributes.get("id"))); + } else { + networkSectionHandler.startElement(uri, localName, qName, attrs); + allocationHandler.startElement(uri, localName, qName, attrs); + } + + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + if (qName.endsWith("OperatingSystemSection")) { + inOs = false; + } else if (inOs && qName.endsWith("Description")) { + builder.osDescripton(Utils.currentOrNull(currentText)); + } else if (qName.endsWith("IpAddress")) { + builder.ipAddress(Utils.currentOrNull(currentText)); + } else if (qName.endsWith("NetworkSection")) { + networkSectionHandler.endElement(uri, localName, qName); + builder.networkSection(networkSectionHandler.getResult()); + } else if (qName.endsWith("Item")) { + allocationHandler.endElement(uri, localName, qName); + builder.resourceAllocation(allocationHandler.getResult()); + } else { + networkSectionHandler.endElement(uri, localName, qName); + allocationHandler.endElement(uri, localName, qName); + } + currentText = new StringBuilder(); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + networkSectionHandler.characters(ch, start, length); + allocationHandler.characters(ch, start, length); + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java new file mode 100644 index 0000000000..e06f161a55 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes; +import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull; +import static org.jclouds.savvis.vpdc.util.Utils.newResource; + +import java.util.Map; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.VDC; +import org.jclouds.savvis.vpdc.domain.VDC.Status; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import com.google.common.collect.ImmutableMap; + +/** + * @author Adrian Cole + */ +public class VDCHandler extends ParseSax.HandlerWithResult { + + protected StringBuilder currentText = new StringBuilder(); + + protected VDC.Builder builder = VDC.builder(); + + public VDC getResult() { + try { + return builder.build(); + } finally { + builder = VDC.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("Vdc")) { + // savvis doesn't add href in the header for some reason + if (!attributes.containsKey("href") && getRequest() != null) + attributes = ImmutableMap. builder().putAll(attributes) + .put("href", getRequest().getEndpoint().toASCIIString()).build(); + Resource vDC = newResource(attributes); + builder.name(vDC.getName()).type(vDC.getType()).id(vDC.getId()).href(vDC.getHref()); + } else if (qName.endsWith("Network")) { + builder.availableNetwork(newResource(attributes)); + } else if (qName.endsWith("ResourceEntity")) { + builder.resourceEntity(newResource(attributes)); + } + } + + public void endElement(String uri, String name, String qName) { + if (qName.endsWith("Description")) { + builder.description(currentOrNull(currentText)); + } else if (qName.endsWith("OfferingTag")) { + builder.status(Status.fromValue(currentOrNull(currentText))); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java deleted file mode 100644 index 3a7b8a5e2e..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCAsyncClientTest.java +++ /dev/null @@ -1,903 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc; - -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.processorCount; -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 org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -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.ReturnNullOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; -import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler; -import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVDCHandler; -import org.jclouds.util.Strings2; -import org.jclouds.vcloud.CommonVCloudClient; -import org.jclouds.vcloud.VCloudExpressLoginAsyncClient; -import org.jclouds.vcloud.VCloudExpressMediaType; -import org.jclouds.vcloud.VCloudVersionsAsyncClient; -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.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.CloneVAppOptions; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.xml.CatalogHandler; -import org.jclouds.vcloud.xml.CatalogItemHandler; -import org.jclouds.vcloud.xml.OrgHandler; -import org.jclouds.vcloud.xml.TaskHandler; -import org.jclouds.vcloud.xml.TasksListHandler; -import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; -import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler; -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.inject.Injector; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; - -/** - * Tests annotation parsing of {@code SymphonyVPDCAsyncClient} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class SymphonyVPDCAsyncClientTest extends RestClientTest { - public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/3"), "my-vapp"); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals( - request, - Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hosting.xml")).replace( - "vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"), - "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException, - IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class); - HttpRequest request = processor.createRequest( - method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/3"), - "my-vapp", - processorCount(1) - .memory(512) - .disk(1024) - .addNetworkConfig( - new NetworkConfig(null, URI.create("https://vcloud.safesecureweb.com/network/1990"), - FenceMode.BRIDGED))); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, - Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml")) - .replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"), - "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException, - IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, - String.class, InstantiateVAppTemplateOptions[].class); - processor.createRequest( - method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - "CentOS 01", - processorCount(1) - .memory(512) - .disk(1024) - .addNetworkConfig( - new NetworkConfig("aloha", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"), null))); - } - - public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class, - CloneVAppOptions[].class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vapp/4181"), "my-vapp"); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals( - request, - Strings2.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp-default.xml")).replace( - "vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class, - CloneVAppOptions[].class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vapp/201"), "new-linux-server", - new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp.xml")) - .replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"), - "application/vnd.vmware.vcloud.cloneVAppParams+xml", false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testOrg() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getOrg", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1")); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("findOrgNamed", String.class); - HttpRequest request = processor.createRequest(method, "org"); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, OrgHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getCatalog", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1")); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class); - HttpRequest request = processor.createRequest(method, "org", "catalog"); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getNetwork", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2")); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCNetworkHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getCatalogItem", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2")); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, - String.class, String.class); - HttpRequest request = processor.createRequest(method, "org", "catalog", "item"); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, CatalogItemHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class, - String.class, String.class); - HttpRequest request = processor.createRequest(method, "org", "catalog", "template"); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VCloudExpressVAppTemplateHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getVAppTemplate", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2")); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, VCloudExpressVAppTemplateHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); - HttpRequest request = processor.createRequest(method, "org", "vdc"); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.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 = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); - processor.createRequest(method, "org1", "vdc"); - } - - public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); - HttpRequest request = processor.createRequest(method, null, "vdc"); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); - HttpRequest request = processor.createRequest(method, null, null); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getVDC", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1")); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getTasksList", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1")); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class); - HttpRequest request = processor.createRequest(method, "org"); - - assertRequestLineEquals(request, - "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TasksListHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("deployVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/deploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testGet() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, SymphonyVPDCVAppHandler.class); - assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("undeployVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/undeploy HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseSax.class); - assertSaxResponseParserClassEquals(method, TaskHandler.class); - assertExceptionParserClassEquals(method, null); - - checkFilters(request); - } - - public void testDelete() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("deleteVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "DELETE https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); - assertSaxResponseParserClassEquals(method, null); - assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); - - checkFilters(request); - } - - public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("powerOnVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("powerOffVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("resetVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/reset HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("suspendVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/suspend HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("shutdownVApp", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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); - } - - public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { - Method method = SymphonyVPDCAsyncClient.class.getMethod("getTask", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1")); - - assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); - 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 = SymphonyVPDCAsyncClient.class.getMethod("cancelTask", URI.class); - HttpRequest request = processor.createRequest(method, - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1")); - - assertRequestLineEquals(request, - "POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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); - } - - @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 SymphonyVPDCRestClientModuleExtension(); - } - - @Override - public RestContextSpec createContextSpec() { - Properties restProperties = new Properties(); - restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); - restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - SymphonyVPDCPropertiesBuilder.class.getName()); - - Properties overrides = new Properties(); - overrides.setProperty("savvis-symphony-vpdc.endpoint", - "https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8"); - return new RestContextFactory(restProperties).createContextSpec("savvis-symphony-vpdc", "identity", "credential", - overrides); - } - - @RequiresHttp - @ConfiguresRestClient - public static class SymphonyVPDCRestClientModuleExtension extends SymphonyVPDCRestClientModule { - @Override - protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, - @Named(PROPERTY_API_VERSION) String version) { - return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/login"); - } - - @Override - protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable orgs) { - return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog"); - - } - - @Override - protected Org provideOrg(CommonVCloudClient discovery) { - return null; - } - - @Override - protected Iterable provideOrgs(Supplier cache, @Named(PROPERTY_IDENTITY) String user) { - return null; - } - - @Override - protected URI provideDefaultTasksList(Org org) { - return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/taskslist"); - } - - @Override - protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) { - return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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://vcloud.safesecureweb.com/network/1990"); - } - - @Override - protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudExpressLoginAsyncClient login) { - return Suppliers. ofInstance(new VCloudSession() { - - @Override - public Map getOrgs() { - return ImmutableMap. of( - "org", - new ReferenceTypeImpl("org", VCloudExpressMediaType.ORG_XML, URI - .create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"), - null, - null, - "description", - null, - null, - null, - null, - null, - ImmutableMap. of( - "vapp", - new ReferenceTypeImpl( - "vapp", - "application/vnd.vmware.vcloud.vApp+xml", - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/188849-1")), - "network", - new ReferenceTypeImpl( - "network", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdcItem/2"))), - null, 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://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1"), "org", null, - ImmutableMap. of( - "catalog", - new ReferenceTypeImpl("catalog", VCloudExpressMediaType.CATALOG_XML, URI - .create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1"))), - ImmutableMap. of( - "vdc", - new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML, URI - .create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"))), - ImmutableMap. of(), new ReferenceTypeImpl("tasksList", - VCloudExpressMediaType.TASKSLIST_XML, URI - .create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1"), - null, - "description", - ImmutableMap. of( - "item", - new ReferenceTypeImpl( - "item", - "application/vnd.vmware.vcloud.catalogItem+xml", - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/1")), - "template", - new ReferenceTypeImpl( - "template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/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://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2"), - "description", - new ReferenceTypeImpl( - "template", - "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2")), - ImmutableMap. of())))); - - } - } - - } - -} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java deleted file mode 100644 index ecd00306e5..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/SymphonyVPDCClientLiveTest.java +++ /dev/null @@ -1,326 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc; - -import static com.google.common.collect.Iterables.find; -import static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; -import java.util.Properties; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.jclouds.domain.Credentials; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.net.IPSocket; -import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.RestContextFactory; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; -import org.jclouds.ssh.SshException; -import org.jclouds.ssh.jsch.config.JschSshClientModule; -import org.jclouds.vcloud.VCloudExpressClientLiveTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Status; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.options.CloneVAppOptions; -import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; -import org.jclouds.vcloud.predicates.TaskSuccess; -import org.testng.annotations.AfterTest; -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.common.collect.Iterables; -import com.google.inject.Injector; -import com.google.inject.Module; - -public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest { - public SymphonyVPDCClientLiveTest() { - provider = "savvis-symphony-vpdc"; - } - - @BeforeGroups(groups = { "live" }) - @Override - public void setupClient() { - setupCredentials(); - Properties overrides = setupProperties(); - - // TODO remove these lines when this is registered under jclouds-core/rest.properties - Properties restProperties = new Properties(); - restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); - restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - SymphonyVPDCPropertiesBuilder.class.getName()); - - Injector injector = new RestContextFactory(restProperties).createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); - - connection = injector.getInstance(SymphonyVPDCClient.class); - - sshFactory = injector.getInstance(SshClient.Factory.class); - socketTester = new RetryablePredicate(injector.getInstance(SocketOpen.class), 130, 10, TimeUnit.SECONDS);// make - // it - // longer - // then - // default internet - // service timeout - successTester = new RetryablePredicate(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS); - } - - protected String expectedOs = "Ubuntu Linux (64-bit)"; - protected String itemName = "Ubuntu JeOS 9.10 (64-bit)"; - - protected Factory sshFactory; - private VCloudExpressVApp vApp; - private RetryablePredicate socketTester; - private RetryablePredicate successTester; - private VCloudExpressVApp clone; - private VDC vdc; - public static final String PREFIX = System.getProperty("user.name") + "-savvis"; - - @Test(enabled = true) - public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException, - IOException { - prepare(); - StringBuffer name = new StringBuffer(); - for (int i = 0; i < 15; i++) - name.append("c"); - String serverName = name.toString();// "adriantest"; - - long hardDisk = 4194304; - - // long hardDisk = 4194304 / 4 * 10; - // String catalogOs = "CentOS 5.3 (64-bit)"; - // String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)"; - - // lookup the datacenter you are deploying into - vdc = connection.findVDCInOrgNamed(null, null); - - ReferenceType vAppTemplateId = Iterables.find(vdc.getResourceEntities().values(), new Predicate() { - - @Override - public boolean apply(ReferenceType arg0) { - return arg0.getType().equals(VCloudMediaType.VAPPTEMPLATE_XML); - } - - }); - - VCloudExpressVAppTemplate vAppTemplate = connection.getVAppTemplate(vAppTemplateId.getHref()); - - assert vAppTemplate != null; - - // create an options object to collect the configuration we want. - InstantiateVAppTemplateOptions instantiateOptions = new InstantiateVAppTemplateOptions(); - - // instantiate, noting vApp returned has minimal details - vApp = connection.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName, - instantiateOptions); - - assertEquals(vApp.getStatus(), Status.RESOLVED); - - Task deployTask = connection.deployVApp(vApp.getHref()); - - // check to see the result of calling deploy twice - deployTask = connection.deployVApp(vApp.getHref()); - assertEquals(deployTask.getHref(), deployTask.getHref()); - - vApp = connection.getVApp(vApp.getHref()); - - assertEquals(vApp.getStatus(), Status.RESOLVED); - - try {// per docs, this is not supported - connection.cancelTask(deployTask.getHref()); - } catch (UnsupportedOperationException e) { - } - - assert successTester.apply(deployTask.getHref()); - System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis()); - - vApp = connection.getVApp(vApp.getHref()); - - ReferenceType vAppResource = connection.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName); - assertEquals(vAppResource.getHref(), vApp.getHref()); - - int processorCount = 1; - long memory = 512; - verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk); - assertEquals(vApp.getStatus(), Status.OFF); - - assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref()); - System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis()); - - vApp = connection.getVApp(vApp.getHref()); - assertEquals(vApp.getStatus(), Status.ON); - } - - protected void prepare() { - - } - - @Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn") - public void testCloneVApp() throws IOException { - assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref()); - System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis()); - - StringBuffer name = new StringBuffer(); - for (int i = 0; i < 15; i++) - name.append("b"); - String newName = name.toString(); - - CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName); - - System.out.printf("%d: cloning vApp%n", System.currentTimeMillis()); - Task task = connection.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options); - - // wait for the task to complete - assert successTester.apply(task.getHref()); - System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis()); - - assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref()); - System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis()); - - // refresh task to get the new vApp location - task = connection.getTask(task.getHref()); - - clone = connection.getVApp(task.getOwner().getHref()); - assertEquals(clone.getStatus(), Status.ON); - - assertEquals(clone.getName(), newName); - assertEquals(clone.getNetworkToAddresses().values().size(), 1); - } - - private void loopAndCheckPass(String publicIp) throws IOException { - for (int i = 0; i < 5; i++) {// retry loop TODO replace with predicate. - try { - doCheckPass(publicIp); - return; - } catch (SshException e) { - try { - Thread.sleep(10 * 1000); - } catch (InterruptedException e1) { - } - continue; - } - } - } - - @Test(enabled = true, dependsOnMethods = "testCloneVApp") - public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException { - - try {// per docs, this is not supported - connection.undeployVApp(vApp.getHref()); - assert false; - } catch (UnsupportedOperationException e) { - } - - try {// per docs, this is not supported - connection.suspendVApp(vApp.getHref()); - assert false; - } catch (UnsupportedOperationException e) { - } - - assert successTester.apply(connection.resetVApp(vApp.getHref()).getHref()); - - vApp = connection.getVApp(vApp.getHref()); - - assertEquals(vApp.getStatus(), Status.ON); - - // TODO we need to determine whether shutdown is supported before invoking - // it. - // connection.shutdownVApp(vApp.getId()); - // vApp = connection.getVApp(vApp.getId()); - // assertEquals(vApp.getStatus(), VAppStatus.ON); - - assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref()); - - vApp = connection.getVApp(vApp.getHref()); - assertEquals(vApp.getStatus(), Status.OFF); - } - - private void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs, - int processorCount, long memory, long hardDisk) { - assertEquals(vApp.getName(), serverName); - assertEquals(vApp.getOperatingSystemDescription(), expectedOs); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), - processorCount); - assertEquals( - find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(), - hardDisk); - assertEquals(vApp.getSize().longValue(), - find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); - } - - private void doCheckPass(String address) throws IOException { - IPSocket socket = new IPSocket(address, 22); - - System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(), socket); - assert socketTester.apply(socket); - System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), socket); - - SshClient connection = getConnectionFor(socket); - try { - connection.connect(); - System.out.printf("%d: %s ssh connection made%n", System.currentTimeMillis(), socket); - System.out.println(connection.exec("df -h")); - } finally { - if (connection != null) - connection.disconnect(); - } - } - - protected SshClient getConnectionFor(IPSocket socket) { - // TODO add in the correct login credentials for the vApp template - return sshFactory.create(socket, new Credentials("root", "password")); - } - - @AfterTest - void cleanup() throws InterruptedException, ExecutionException, TimeoutException { - if (vApp != null) { - try { - successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref()); - } catch (Exception e) { - - } - connection.deleteVApp(vApp.getHref()); - } - if (clone != null) { - try { - successTester.apply(connection.powerOffVApp(clone.getHref()).getHref()); - } catch (Exception e) { - - } - connection.deleteVApp(clone.getHref()); - } - - } -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java new file mode 100644 index 0000000000..cfc57520b1 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc; + +import java.io.IOException; +import java.util.concurrent.ExecutionException; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.savvis.vpdc.features.BaseVPDCAsyncClientTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests behavior of {@code VPDCAsyncClient} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "VPDCAsyncClientTest") +public class VPDCAsyncClientTest extends BaseVPDCAsyncClientTest { + + private VPDCAsyncClient asyncClient; + private VPDCClient syncClient; + + public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assert syncClient.getBrowsingClient() != null; + } + + public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { + assert asyncClient.getBrowsingClient() != null; + } + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + + @BeforeClass + @Override + protected void setupFactory() throws IOException { + super.setupFactory(); + asyncClient = injector.getInstance(VPDCAsyncClient.class); + syncClient = injector.getInstance(VPDCClient.class); + } + + @Override + protected void checkFilters(HttpRequest request) { + + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java deleted file mode 100644 index b3ee5db239..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCComputeServiceLiveTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.compute; - -import java.util.Properties; - -import org.jclouds.compute.BaseComputeServiceLiveTest; -import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder; -import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder; -import org.jclouds.ssh.jsch.config.JschSshClientModule; -import org.testng.annotations.Test; - -/** - * - * - * @author Kedar Dave - */ -@Test(groups = "live", enabled = false, sequential = true) -public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest { - public SymphonyVPDCComputeServiceLiveTest() { - provider = "savvis-symphony-vpdc"; - group = "savvis.jclouds"; - } - - @Override - protected Properties setupRestProperties() { - // TODO remove these lines when this is registered under jclouds-core/rest.properties - Properties restProperties = new Properties(); - restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); - restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - SymphonyVPDCPropertiesBuilder.class.getName()); - return restProperties; - } - - @Override - protected JschSshClientModule getSshModule() { - return new JschSshClientModule(); - } - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java deleted file mode 100644 index 30cd9d297c..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/compute/SymphonyVPDCTemplateBuilderLiveTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.jclouds.savvis.vpdc.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; - -import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.ComputeServiceContextFactory; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder; -import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder; -import org.testng.annotations.BeforeClass; -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 = false) -public class SymphonyVPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public SymphonyVPDCTemplateBuilderLiveTest() { - provider = "savvis-symphony-vpdc"; - } - - @Override - @BeforeClass - public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { - setupCredentials(); - // TODO remove these lines when this is registered under jclouds-core/rest.properties - Properties restProperties = new Properties(); - restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName()); - restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder", - SymphonyVPDCPropertiesBuilder.class.getName()); - - context = new ComputeServiceContextFactory(restProperties).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), setupProperties()); - } - - @Override - protected Predicate defineUnsupportedOperatingSystems() { - return new Predicate() { - - @Override - public boolean apply(OsFamilyVersion64Bit input) { - // TODO it seems there are no base vApp Templates available in Savvis - return true; - } - }; - } - - @Test - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5"); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set getIso3166Codes() { - return ImmutableSet. of("US-FL", "NL-NH"); - } -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java new file mode 100644 index 0000000000..dd573a2364 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.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.savvis.vpdc.features; + +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.Properties; +import java.util.Set; + +import javax.inject.Named; + +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.savvis.vpdc.VPDCAsyncClient; +import org.jclouds.savvis.vpdc.VPDCClient; +import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.internal.VCloudSession; +import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie; +import org.jclouds.savvis.vpdc.internal.LoginAsyncClient; +import org.jclouds.savvis.vpdc.reference.VCloudMediaType; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * @author Adrian Cole + */ +public abstract class BaseVPDCAsyncClientTest extends RestClientTest { + + @Override + public RestContextSpec createContextSpec() { + Properties props = new Properties(); + return new RestContextFactory().createContextSpec("savvis-symphonyvpdc", "apiKey", "secretKey", props); + } + + @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 VPDCRestClientModuleExtension(); + } + + @RequiresHttp + @ConfiguresRestClient + public static class VPDCRestClientModuleExtension extends VPDCRestClientModule { + + @Override + protected Supplier provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, + final LoginAsyncClient login) { + return Suppliers. ofInstance(new VCloudSession() { + + @Override + public Set getOrgs() { + return ImmutableSet.of(new Resource("1", "org", VCloudMediaType.ORG_XML, URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1"))); + } + + @Override + public String getVCloudToken() { + return "token"; + } + + }); + + } + + } + +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java new file mode 100644 index 0000000000..1f3aec75ec --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -0,0 +1,85 @@ +/** + * + * 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.savvis.vpdc.features; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Properties; + +import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.RestContextFactory; +import org.jclouds.savvis.vpdc.VPDCAsyncClient; +import org.jclouds.savvis.vpdc.VPDCClient; +import org.testng.annotations.AfterGroups; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * Tests behavior of {@code VPDCClient} + * + * @author Adrian Cole + */ +@Test(groups = "live") +public class BaseVPDCClientLiveTest { + + protected RestContext context; + protected String provider = "savvis-symphonyvpdc"; + 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(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(); + context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), + overrides); + } + + @AfterGroups(groups = "live") + protected void tearDown() { + if (context != null) + context.close(); + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java new file mode 100644 index 0000000000..3c509c1ee4 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java @@ -0,0 +1,195 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.features; + +import java.io.IOException; +import java.lang.reflect.Method; + +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.savvis.vpdc.xml.NetworkHandler; +import org.jclouds.savvis.vpdc.xml.OrgHandler; +import org.jclouds.savvis.vpdc.xml.TaskHandler; +import org.jclouds.savvis.vpdc.xml.VAppHandler; +import org.jclouds.savvis.vpdc.xml.VDCHandler; +import org.testng.annotations.Test; + +import com.google.inject.TypeLiteral; + +/** + * Tests annotation parsing of {@code BrowsingAsyncClient} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class BrowsingAsyncClientTest extends BaseVPDCAsyncClientTest { + + public void testOrg() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getOrg", String.class); + HttpRequest request = processor.createRequest(method, "11"); + + assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testOrgNull() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getOrg", String.class); + HttpRequest request = processor.createRequest(method, (String) null); + + assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OrgHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testVDC() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class); + HttpRequest request = processor.createRequest(method, "11", "22"); + + assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VDCHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testVDCWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class); + HttpRequest request = processor.createRequest(method, (String) null, "22"); + + assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VDCHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getNetworkInOrgAndVDC", String.class, String.class, + String.class); + HttpRequest request = processor.createRequest(method, "11", "22", "VM-Tier01"); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/network/VM-Tier01 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, NetworkHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testNetworkWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getNetworkInOrgAndVDC", String.class, String.class, + String.class); + HttpRequest request = processor.createRequest(method, (String) null, "22", "VM-Tier01"); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22/network/VM-Tier01 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, NetworkHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testVApp() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getVAppInOrgAndVDC", String.class, String.class, + String.class); + HttpRequest request = processor.createRequest(method, "11", "22", "VM-Tier01"); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/VM-Tier01 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testVAppWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getVAppInOrgAndVDC", String.class, String.class, + String.class); + HttpRequest request = processor.createRequest(method, (String) null, "22", "VM-Tier01"); + + assertRequestLineEquals(request, + "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22/vApp/VM-Tier01 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, VAppHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { + Method method = BrowsingAsyncClient.class.getMethod("getTask", String.class); + HttpRequest request = processor.createRequest(method, "1"); + + assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/1 HTTP/1.1"); + assertNonPayloadHeadersEqual(request, ""); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, TaskHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java new file mode 100644 index 0000000000..fb528059d9 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java @@ -0,0 +1,132 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import org.jclouds.savvis.vpdc.domain.Network; +import org.jclouds.savvis.vpdc.domain.Org; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.VApp; +import org.jclouds.savvis.vpdc.domain.VDC; +import org.jclouds.savvis.vpdc.reference.VCloudMediaType; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + +@Test(groups = "live") +public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest { + + private BrowsingClient client; + + @Override + @BeforeGroups(groups = { "live" }) + public void setupClient() { + super.setupClient(); + client = context.getApi().getBrowsingClient(); + } + + @Test + public void testOrg() throws Exception { + Org response = client.getOrg(null); + assertNotNull(response); + assertNotNull(response.getId()); + assertNotNull(response.getHref()); + assertNotNull(response.getName()); + // savvis leaves this null for some reason + assertEquals(response.getType(), null); + assert response.getImages().size() >= 0; + assert response.getDescription() != null; + assert response.getVDCs().size() >= 1; + assertEquals(client.getOrg(response.getId()).toString(), response.toString()); + } + + @Test + public void testVDC() throws Exception { + Org org = client.getOrg(null); + for (Resource vdc : org.getVDCs()) { + VDC response = client.getVDCInOrg(null, vdc.getId()); + assertNotNull(response); + assertNotNull(response.getId()); + assertNotNull(response.getHref()); + assertNotNull(response.getName()); + assertNotNull(response.getStatus()); + assertEquals(response.getType(), "application/vnd.vmware.vcloud.vdc+xml"); + assertNotNull(response.getDescription()); + assertNotNull(response.getResourceEntities()); + assertNotNull(response.getAvailableNetworks()); + assertEquals(client.getVDCInOrg(null, response.getId()).toString(), response.toString()); + } + } + + @Test + public void testNetwork() throws Exception { + Org org = client.getOrg(null); + for (Resource vdc : org.getVDCs()) { + VDC VDC = client.getVDCInOrg(null, vdc.getId()); + for (Resource vApp : VDC.getAvailableNetworks()) { + Network response = client.getNetworkInOrgAndVDC(org.getId(), vdc.getId(), vApp.getId()); + assertNotNull(response); + assertNotNull(response.getId()); + assertNotNull(response.getHref()); + assertNotNull(response.getName()); + assertEquals(response.getType(), VCloudMediaType.NETWORK_XML); + assertNotNull(response.getNetmask()); + assertNotNull(response.getGateway()); + assertNotNull(response.getInternalToExternalNATRules()); + assertEquals(client.getNetworkInOrgAndVDC(null, vdc.getId(), response.getId()).toString(), + response.toString()); + } + } + } + + @Test + public void testVApp() throws Exception { + Org org = client.getOrg(null); + for (Resource vdc : org.getVDCs()) { + VDC VDC = client.getVDCInOrg(null, vdc.getId()); + for (Resource vApp : Iterables.filter(VDC.getResourceEntities(), new Predicate() { + + @Override + public boolean apply(Resource arg0) { + return VCloudMediaType.VAPP_XML.equals(arg0.getType()); + } + + })) { + VApp response = client.getVAppInOrgAndVDC(org.getId(), vdc.getId(), vApp.getId()); + assertNotNull(response); + assertNotNull(response.getId()); + assertNotNull(response.getHref()); + assertNotNull(response.getName()); + assertEquals(response.getType(), "application/vnd.vmware.vcloud.vApp+xml"); + assertNotNull(response.getIpAddress()); + assertNotNull(response.getStatus()); + assertNotNull(response.getOsDescripton()); + assertNotNull(response.getOsType()); + assertNotNull(response.getNetworkSection()); + assertNotNull(response.getResourceAllocations()); + assertEquals(client.getVAppInOrgAndVDC(null, vdc.getId(), response.getId()).toString(), response.toString()); + } + } + } +} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java new file mode 100644 index 0000000000..87fd996497 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java @@ -0,0 +1,59 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.filters; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; + +import javax.inject.Provider; +import javax.ws.rs.core.HttpHeaders; + +import org.jclouds.http.HttpRequest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test +public class SetVCloudTokenCookieTest { + + private SetVCloudTokenCookie filter; + + @BeforeTest + void setUp() { + filter = new SetVCloudTokenCookie(new Provider() { + public String get() { + return "token"; + } + }); + } + + @Test + public void testApply() { + HttpRequest request = new HttpRequest("GET", URI.create("http://localhost")); + request = filter.filter(request); + assertEquals(request.getHeaders().size(), 1); + assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token"); + + } + +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java similarity index 96% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java rename to sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java index 7faefe658a..d31bf744cc 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/SymphonyVPDCErrorHandlerTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java @@ -44,7 +44,7 @@ import com.google.inject.Guice; * @author Adrian Cole */ @Test(groups = { "unit" }) -public class SymphonyVPDCErrorHandlerTest { +public class VPDCErrorHandlerTest { @Test public void test400MakesIllegalArgumentException() { @@ -83,7 +83,7 @@ public class SymphonyVPDCErrorHandlerTest { private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType, String content, Class expected) { - SymphonyVPDCErrorHandler function = Guice.createInjector().getInstance(SymphonyVPDCErrorHandler.class); + VPDCErrorHandler function = Guice.createInjector().getInstance(VPDCErrorHandler.class); HttpCommand command = createMock(HttpCommand.class); HttpRequest request = new HttpRequest(method, uri); diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java new file mode 100644 index 0000000000..5116882e20 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java @@ -0,0 +1,75 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.savvis.vpdc.domain.Network; +import org.jclouds.savvis.vpdc.reference.VCloudMediaType; +import org.testng.annotations.Test; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code NetworkHandler} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class NetworkHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/network.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is); + assertEquals( + result.toString(), + Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM-Tier01").gateway("1.1.1.1") + .netmask("255.255.255.240").build().toString()); + } + + public void testNat() { + InputStream is = getClass().getResourceAsStream("/network-nat.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is); + assertEquals(result.toString(), + Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("1.1.1.1").netmask("2.2.2.2") + .internalToExternalNATRule("3.3.3.3", "4.4.4.4").internalToExternalNATRule("3.3.3.4", "4.4.4.5") + .build().toString()); + } + + public void tesWhenNoVAppsInNetworkSetsAllZerosToGatewayAndNetmask() { + InputStream is = getClass().getResourceAsStream("/network-unused.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is); + assertEquals(result.toString(), + Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("0.0.0.0").netmask("0.0.0.0") + .build().toString()); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java index 3725b4cacb..fb55ebf01c 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java @@ -27,16 +27,10 @@ import java.net.URI; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.OrgImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.xml.OrgHandler; +import org.jclouds.savvis.vpdc.domain.Link; +import org.jclouds.savvis.vpdc.domain.Org; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.inject.Guice; import com.google.inject.Injector; @@ -49,18 +43,18 @@ import com.google.inject.Injector; public class OrgHandlerTest { public void testSavvis() { - InputStream is = getClass().getResourceAsStream("/savvis/org.xml"); + InputStream is = getClass().getResourceAsStream("/org.xml"); Injector injector = Guice.createInjector(new SaxParserModule()); Factory factory = injector.getInstance(ParseSax.Factory.class); - Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is); + Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is); assertEquals( - result, - new OrgImpl("100000.0", null, null, "100000.0", "SAVVISStation Integration Testing", ImmutableMap - . of(), ImmutableMap. of( - "demo_vpdcname", - new ReferenceTypeImpl("demo_vpdcname", "application/vnd.vmware.vcloud.vdc+xml", URI - .create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))), - ImmutableMap. of(), null, ImmutableSet. of())); + result.toString(), + Org.builder() + .name("100000.0") + .description("SAVVISStation Integration Testing") + .vDC(new Link("2736", "demo_vpdcname", "application/vnd.vmware.vcloud.vdc+xml", URI + .create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"), + "down")).build().toString()); } } diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java new file mode 100644 index 0000000000..d21725134f --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java @@ -0,0 +1,56 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.net.URI; +import java.util.Set; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code OrgListHandler} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class OrgListHandlerTest { + + public void testSavvis() { + InputStream is = getClass().getResourceAsStream("/orglist.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + Set result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is); + assertEquals(result, ImmutableSet.of(new Resource("100000.0", "SAVVISStation Integration Testing", + "application/vnd.vmware.vcloud.org+xml", URI + .create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0")))); + + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java new file mode 100644 index 0000000000..8c3a79b483 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java @@ -0,0 +1,32 @@ +package org.jclouds.savvis.vpdc.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.savvis.vpdc.domain.ResourceAllocation; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code ResourceAllocationHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ResourceAllocationHandlerTest") +public class ResourceAllocationHandlerTest extends BaseHandlerTest { + + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/resourceallocation.xml"); + + ResourceAllocation result = factory.create(injector.getInstance(ResourceAllocationHandler.class)).parse(is); + + ResourceAllocation expects = ResourceAllocation.builder() + + .allocationUnits("Gigabytes").caption("1234568").description("Hard Disk").name("D:\\").hostResource("data").id(6) + .type(ResourceAllocation.Type.DATA_DISK).virtualQuantity(50) + .build(); + assertEquals(result, expects); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandlerTest.java deleted file mode 100644 index 9a19945b85..0000000000 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/SymphonyVPDCVDCHandlerTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.savvis.vpdc.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code SymphonyVPDCVDCHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class SymphonyVPDCVDCHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/savvis/vdc.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - SymphonyVPDCVDC result = (SymphonyVPDCVDC) factory.create(injector.getInstance(SymphonyVPDCVDCHandler.class)) - .parse(is); - assertEquals(result.getName(), "demo_vpdcname"); - assertEquals(result.getHref(), null); - assertEquals(result.getDescription(), - "ServiceProfileName = Balanced; ServiceLocation = North America; Email = jim@company.com;"); - assertEquals(result.getOfferingTag(), "Deployed"); - assertEquals(result.getStorageCapacity(), null); - assertEquals(result.getCpuCapacity(), null); - assertEquals(result.getMemoryCapacity(), null); - assertEquals(result.getVmQuota(), 0); - assertEquals( - result.getResourceEntities(), - ImmutableMap. of( - "DemoHost-1", - new ReferenceTypeImpl( - "DemoHost-1", - VCloudMediaType.VAPP_XML, - URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001")), - "DemoHost-2", - new ReferenceTypeImpl( - "DemoHost-2", - VCloudMediaType.VAPP_XML, - URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")), - "DemoHost-3", - new ReferenceTypeImpl( - "DemoHost-3", - VCloudMediaType.VAPP_XML, - URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003")), - "CustomerTemplateName", - new ReferenceTypeImpl( - "CustomerTemplateName", - VCloudMediaType.VAPPTEMPLATE_XML, - URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234")), - "firewall", - new ReferenceTypeImpl( - "firewall", - "api.sandbox.symphonyVPDC.savvis.net+xml", - URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService")))); - assertEquals(result.getAvailableNetworks(), ImmutableMap.of()); - } -} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java new file mode 100644 index 0000000000..547d6e7b97 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java @@ -0,0 +1,248 @@ +package org.jclouds.savvis.vpdc.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.net.URI; + +import org.jclouds.date.DateService; +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.Task; +import org.jclouds.savvis.vpdc.domain.TaskError; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code TaskHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "TaskHandlerTest") +public class TaskHandlerTest extends BaseHandlerTest { + + private DateService dateService; + + @BeforeTest + @Override + protected void setUpInjector() { + super.setUpInjector(); + dateService = injector.getInstance(DateService.class); + } + + public void testVAppSuccess() { + InputStream is = getClass().getResourceAsStream("/task-vapp.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00")) + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .status(Task.Status.SUCCESS) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002")) + .owner( + Resource + .builder() + .id("2736") + .name("mockVpdc8") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736")) + .build()) + .result( + Resource + .builder() + .id("1002") + .name("mock_vpdc_item_007") + .type("application/vnd.vmware.vcloud.vApp+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")) + .build()).build(); + assertEquals(result.toString(), expects.toString()); + + } + + public void testVMDKSuccess() { + InputStream is = getClass().getResourceAsStream("/task-vmdk.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00")) + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .status(Task.Status.SUCCESS) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002")) + .owner( + Resource + .builder() + .id("2736") + .name("mockVpdc8") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736")) + .build()) + .result( + Resource + .builder() + .id("1234567") + .name("mock_vpdc_item_008") + .type("application/vnd.vmware.vcloud.vApp+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/vdc/2736/vmdk/1234567")) + .build()).build(); + assertEquals(result.toString(), expects.toString()); + + } + + public void testRunning() { + InputStream is = getClass().getResourceAsStream("/task-running.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .status(Task.Status.RUNNING) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002")) + .owner( + Resource + .builder() + .id("2736") + .name("mockVpdc8") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736")) + .build()) + .result( + Resource + .builder() + .id("1002") + .name("mock_vpdc_item_007") + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")) + .build()).build(); + + assertEquals(result.toString(), expects.toString()); + + } + + public void testQueued() { + InputStream is = getClass().getResourceAsStream("/task-queued.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .id("6904") + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .status(Task.Status.QUEUED) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904")) + .owner( + Resource + .builder() + .id("2736") + .name("mockVpdc8") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736")) + .build()) + .result( + Resource + .builder() + .id("1002") + .name("mock_vpdc_item_007") + .type("application/vnd.vmware.vcloud.catalogItem+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")) + .build()).build(); + assertEquals(result.toString(), expects.toString()); + + } + + public void testFailed() { + InputStream is = getClass().getResourceAsStream("/task-failed.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .id("6904-123") + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00")) + .status(Task.Status.ERROR) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123")) + .owner( + Resource + .builder() + .id("2736") + .name("mockVpdc8") + .type("application/vnd.vmware.vcloud.vdc+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736")) + .build()) + .result( + Resource + .builder() + .id("1002") + .name("mock_vpdc_item_007") + .type("application/vnd.vmware.vcloud.vApp+xml") + .href(URI + .create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")) + .build()).build(); + assertEquals(result.toString(), expects.toString()); + + } + + public void testError() { + InputStream is = getClass().getResourceAsStream("/task-error.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .id("6904-123") + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00")) + .status(Task.Status.ERROR) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123")) + .error( + TaskError + .builder() + .vendorSpecificErrorCode("0") + .minorErrorCode(0) + .majorErrorCode(0) + .message( + "There is an internal exception occured in System, please kindly contact savvis support team to get solution.") + .build()).build(); + assertEquals(result.toString(), expects.toString()); + + } + + public void testUnsupported() { + InputStream is = getClass().getResourceAsStream("/task-unsupported.xml"); + + Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); + Task expects = Task + .builder() + .id("6904-123") + .startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00")) + .endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00")) + .status(Task.Status.NONE) + .type("application/vnd.vmware.vcloud.task+xml") + .href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123")) + .error( + TaskError + .builder() + .vendorSpecificErrorCode("3000") + .minorErrorCode(-1) + .majorErrorCode(500) + .message( + "your requested task id is not found. Please contact Savvis Administrator for further assistance/clarification ") + .build()).build(); + assertEquals(result.toString(), expects.toString()); + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java new file mode 100644 index 0000000000..2bce26a353 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java @@ -0,0 +1,194 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.net.URI; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.savvis.vpdc.domain.Resource; +import org.jclouds.savvis.vpdc.domain.VDC; +import org.jclouds.savvis.vpdc.domain.VDC.Status; +import org.jclouds.savvis.vpdc.reference.VCloudMediaType; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code VDCHandler} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class VDCHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/vdc.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); + assertEquals(result.getName(), "demo_vpdcname"); + assertEquals(result.getDescription(), + "ServiceProfileName = Balanced; ServiceLocation = North America; Email = jim@company.com;"); + assertEquals(result.getStatus(), Status.DEPLOYED); + assertEquals( + result.getResourceEntities(), + ImmutableSet. of( + new Resource( + "1001", + "DemoHost-1", + VCloudMediaType.VAPP_XML, + URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001")), + new Resource( + "1002", + "DemoHost-2", + VCloudMediaType.VAPP_XML, + URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")), + new Resource( + "1003", + "DemoHost-3", + VCloudMediaType.VAPP_XML, + URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003")), + new Resource( + "1234", + "CustomerTemplateName", + VCloudMediaType.VAPPTEMPLATE_XML, + URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234")), + new Resource( + "FirewallService", + "firewall", + "api.symphonyvpdc.savvis.net+xml", + URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService")))); + assertEquals(result.getAvailableNetworks(), ImmutableSet.of()); + } + + public void test1net() { + InputStream is = getClass().getResourceAsStream("/vdc-1net.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); + assertEquals(result.getName(), "demo6"); + assertEquals(result.getDescription(), + "ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;"); + assertEquals(result.getStatus(), Status.DEPLOYED); + assertEquals(result.getResourceEntities(), ImmutableSet.of( + new Resource("1001", "Host1", VCloudMediaType.VAPP_XML, URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1001")), + new Resource("1002", "Host2", VCloudMediaType.VAPP_XML, URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1002")), + new Resource("1003", "Host3", VCloudMediaType.VAPP_XML, URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1003")), + new Resource("1004", "Host4", VCloudMediaType.VAPP_XML, URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1004")))); + assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource + .builder() + .id("VM-Tier01") + .name("VM Tier01") + .type(VCloudMediaType.NETWORK_XML) + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/network/VM-Tier01")) + .build())); + + } + + public void testFailed() { + InputStream is = getClass().getResourceAsStream("/vdc-failed.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); + assertEquals(result.getName(), "Demo7"); + assertEquals(result.getDescription(), + "ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;"); + assertEquals(result.getStatus(), Status.FAILED); + assertEquals(result.getResourceEntities(), ImmutableSet.of(new Resource("1001", "Host1", + VCloudMediaType.VAPP_XML, URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/vApp/1001")))); + assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource + .builder() + .id("VM-Tier01") + .name("VM Tier01") + .type(VCloudMediaType.NETWORK_XML) + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/network/VM-Tier01")) + .build())); + + } + + public void testSaved() { + InputStream is = getClass().getResourceAsStream("/vdc-saved.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is); + assertEquals(result.getName(), "CloudBurst1"); + assertEquals(result.getDescription(), + "ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = me@my.com;"); + assertEquals(result.getStatus(), Status.SAVED); + assertEquals( + result.getResourceEntities(), + ImmutableSet.of( + Resource + .builder() + .name("templateHost") + .type("application/vnd.vmware.vcloud.vApp+xml") + .id("1001") + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1001")) + .build(), + Resource + .builder() + .name("host-c501") + .type("application/vnd.vmware.vcloud.vApp+xml") + .id("1037") + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1037")) + .build(), + Resource + .builder() + .name("host-c501") + .type("application/vnd.vmware.vcloud.vApp+xml") + .id("1038") + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1038")) + .build(), + Resource + .builder() + .name("host-c601") + .type("application/vnd.vmware.vcloud.vApp+xml") + .id("1039") + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1039")) + .build())); + assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource + .builder() + .id("VM-Tier01") + .name("VM Tier01") + .type(VCloudMediaType.NETWORK_XML) + .href(URI + .create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/network/VM-Tier01")) + .build())); + + } +} diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml new file mode 100644 index 0000000000..7343ec00e2 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml new file mode 100644 index 0000000000..0de09a6782 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml @@ -0,0 +1,18 @@ + + + + 1.1.1.1 + 2.2.2.2 + + + allowInOut + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml new file mode 100644 index 0000000000..5cade31b8b --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml @@ -0,0 +1,14 @@ + + + + 0.0.0.0 + 0.0.0.0 + + + allowInOut + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml new file mode 100644 index 0000000000..43b568b1e7 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml @@ -0,0 +1,10 @@ + + + + 1.1.1.1 + 255.255.255.240 + + + allowInOut + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/savvis/org.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/org.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/savvis/org.xml rename to sandbox-providers/savvis-symphony-vpdc/src/test/resources/org.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml new file mode 100644 index 0000000000..24367a5bdc --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml new file mode 100644 index 0000000000..e8cede2d99 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml @@ -0,0 +1,26 @@ + + + + Gigabytes + + + 1234568 + + + + Hard Disk + D:\ + + data + 6 + + + + + + + + 26 + 50 + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml new file mode 100644 index 0000000000..32ef2b6c69 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml new file mode 100644 index 0000000000..d14ef3f814 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml new file mode 100644 index 0000000000..1412912cd0 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml new file mode 100644 index 0000000000..1b42f0052f --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml new file mode 100644 index 0000000000..60a56580c6 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml new file mode 100644 index 0000000000..8a8a3520c1 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml new file mode 100644 index 0000000000..f3368dec3c --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml new file mode 100644 index 0000000000..52a387acd4 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml @@ -0,0 +1,14 @@ + + + ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com; + Deployed + + + + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml new file mode 100644 index 0000000000..16a8e932b5 --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml @@ -0,0 +1,11 @@ + + + ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com; + Failed + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml new file mode 100644 index 0000000000..3dccdf3dfb --- /dev/null +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml @@ -0,0 +1,14 @@ + + + ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = me@my.com; + Saved + + + + + + + + + + \ No newline at end of file diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/savvis/vdc.xml b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc.xml similarity index 88% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/savvis/vdc.xml rename to sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc.xml index 57d28ef190..d52b555094 100644 --- a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/savvis/vdc.xml +++ b/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc.xml @@ -7,7 +7,7 @@ - + \ No newline at end of file From 7b08e0f1d5eef491eaffcdffd37c1e55ebbdca98 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 20 Mar 2011 02:43:34 -0700 Subject: [PATCH 2/5] renamed savvis dir to be consistent with dns name --- .../{savvis-symphony-vpdc => savvis-symphonyvpdc}/pom.xml | 0 .../src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java | 0 .../main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java | 0 .../vpdc/compute/config/VPDCComputeServiceContextModule.java | 0 .../java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/Link.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/Network.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/Org.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java | 0 .../java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/Task.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java | 0 .../org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java | 0 .../main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java | 0 .../java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java | 0 .../org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java | 0 .../java/org/jclouds/savvis/vpdc/features/BrowsingClient.java | 0 .../org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java | 0 .../java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java | 0 .../savvis/vpdc/functions/ParseLoginResponseFromHeaders.java | 0 .../java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java | 0 .../java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/internal/Network.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/internal/Org.java | 0 .../main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java | 0 .../main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java | 0 .../java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java | 0 .../java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/util/Utils.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java | 0 .../java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java | 0 .../org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java | 0 .../main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java | 0 .../src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java | 0 .../test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java | 0 .../org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java | 0 .../org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java | 0 .../org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java | 0 .../org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java | 0 .../org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java | 0 .../org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java | 0 .../test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java | 0 .../src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java | 0 .../test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java | 0 .../jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java | 0 .../test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java | 0 .../src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java | 0 .../src/test/resources/log4j.xml | 0 .../src/test/resources/network-nat.xml | 0 .../src/test/resources/network-unused.xml | 0 .../src/test/resources/network.xml | 0 .../src/test/resources/org.xml | 0 .../src/test/resources/orglist.xml | 0 .../src/test/resources/resourceallocation.xml | 0 .../src/test/resources/task-error.xml | 0 .../src/test/resources/task-failed.xml | 0 .../src/test/resources/task-queued.xml | 0 .../src/test/resources/task-running.xml | 0 .../src/test/resources/task-unsupported.xml | 0 .../src/test/resources/task-vapp.xml | 0 .../src/test/resources/task-vmdk.xml | 0 .../src/test/resources/vdc-1net.xml | 0 .../src/test/resources/vdc-failed.xml | 0 .../src/test/resources/vdc-saved.xml | 0 .../src/test/resources/vdc.xml | 0 74 files changed, 0 insertions(+), 0 deletions(-) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/pom.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/log4j.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/network-nat.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/network-unused.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/network.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/org.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/orglist.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/resourceallocation.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-error.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-failed.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-queued.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-running.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-unsupported.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-vapp.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/task-vmdk.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/vdc-1net.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/vdc-failed.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/vdc-saved.xml (100%) rename sandbox-providers/{savvis-symphony-vpdc => savvis-symphonyvpdc}/src/test/resources/vdc.xml (100%) diff --git a/sandbox-providers/savvis-symphony-vpdc/pom.xml b/sandbox-providers/savvis-symphonyvpdc/pom.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/pom.xml rename to sandbox-providers/savvis-symphonyvpdc/pom.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCAsyncClient.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCClient.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Link.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Network.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Org.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Resource.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/Task.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/TaskError.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VDC.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/internal/VCloudSession.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/Network.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookie.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/functions/DefaultOrgIfNull.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/functions/ParseLoginResponseFromHeaders.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/LoginAsyncClient.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Network.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/Org.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VCloudToken.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/internal/VDC.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/predicates/TaskSuccess.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudConstants.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/reference/VCloudMediaType.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/util/Utils.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/OrgListHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TaskHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/TasksListHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java rename to sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VDCHandler.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/VPDCAsyncClientTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingClientLiveTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/OrgListHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/TaskHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java rename to sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/VDCHandlerTest.java diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/log4j.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/log4j.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/log4j.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/network-nat.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-nat.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/network-nat.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/network-unused.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/network-unused.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/network-unused.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/network.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/network.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/network.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/org.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/org.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/org.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/org.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/orglist.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/orglist.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/orglist.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/resourceallocation.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/resourceallocation.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/resourceallocation.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-error.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-error.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-error.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-failed.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-failed.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-failed.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-queued.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-queued.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-queued.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-running.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-running.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-running.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-unsupported.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-unsupported.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-unsupported.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-vapp.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vapp.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-vapp.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-vmdk.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/task-vmdk.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/task-vmdk.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-1net.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-1net.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-1net.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-failed.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-failed.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-failed.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-saved.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc-saved.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc-saved.xml diff --git a/sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc.xml b/sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc.xml similarity index 100% rename from sandbox-providers/savvis-symphony-vpdc/src/test/resources/vdc.xml rename to sandbox-providers/savvis-symphonyvpdc/src/test/resources/vdc.xml From f952b4df8cd7cd13b32570fa4b43f4b05e98fb12 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 20 Mar 2011 09:44:22 -0700 Subject: [PATCH 3/5] added log config for compute --- compute/src/test/resources/log4j.xml | 133 +++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 compute/src/test/resources/log4j.xml diff --git a/compute/src/test/resources/log4j.xml b/compute/src/test/resources/log4j.xml new file mode 100644 index 0000000000..189ef74609 --- /dev/null +++ b/compute/src/test/resources/log4j.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From fff61b8b4de41e82d2182ed0c91d42f8932070ee Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 20 Mar 2011 22:15:08 -0700 Subject: [PATCH 4/5] Issue 508: promoted OVF and CIM to jclouds-compute so that they can be reused across vcloud, trmk, and savvis --- .../org/jclouds/atmos/AtmosAsyncClient.java | 2 + .../java/org/jclouds/atmos/AtmosClient.java | 3 + .../java/org/jclouds/s3/S3AsyncClient.java | 2 + .../main/java/org/jclouds/s3/S3Client.java | 3 + .../swift/CommonSwiftAsyncClient.java | 3 +- .../openstack/swift/CommonSwiftClient.java | 4 +- .../org/jclouds/vcloud/VCloudAsyncClient.java | 4 +- .../java/org/jclouds/vcloud/VCloudClient.java | 2 +- ...antiateVAppTemplateParamsToXmlPayload.java | 2 +- .../compute/functions/HardwareForVApp.java | 43 +- .../functions/HardwareForVAppTemplate.java | 47 +- .../functions/ImageForVAppTemplate.java | 6 +- .../ResourceAllocationsToVolumes.java | 61 -- ...ardwareBuilderFromResourceAllocations.java | 46 ++ .../compute/util/VCloudComputeUtils.java | 25 +- .../config/BaseVCloudRestClientModule.java | 33 +- .../domain/InstantiateVAppTemplateParams.java | 14 +- .../ovf/EditableResourceAllocation.java | 72 -- ...EditableResourceAllocationSettingData.java | 303 ++++++++ .../vcloud/domain/ovf/VCloudHardDisk.java | 315 +++++++- .../domain/ovf/VCloudNetworkAdapter.java | 321 ++++++-- .../domain/ovf/VCloudNetworkSection.java | 3 +- .../ovf/VCloudOperatingSystemSection.java | 1 + .../ovf/VCloudVirtualHardwareSection.java | 25 +- .../xml/GuestCustomizationSectionHandler.java | 4 +- .../vcloud/xml/NetworkConnectionHandler.java | 5 +- .../xml/NetworkConnectionSectionHandler.java | 4 +- .../org/jclouds/vcloud/xml/VAppHandler.java | 4 +- .../vcloud/xml/VAppTemplateHandler.java | 4 +- .../xml/VCloudVirtualHardwareHandler.java | 7 +- .../org/jclouds/vcloud/xml/VmHandler.java | 4 +- .../xml/ovf/VCloudNetworkSectionHandler.java | 6 +- .../xml/ovf/VCloudOperatingSystemHandler.java | 3 +- ...ResourceAllocationSettingDataHandler.java} | 52 +- .../jclouds/vcloud/VCloudAsyncClientTest.java | 2 +- ...ateVAppTemplateParamsToXmlPayloadTest.java | 4 +- .../functions/VAppToNodeMetadataTest.java | 13 +- .../jclouds/vcloud/xml/VAppHandlerTest.java | 11 +- .../vcloud/xml/VAppTemplateHandlerTest.java | 2 +- .../org/jclouds/vcloud/xml/VmHandlerTest.java | 11 +- ...loudVirtualHardwareSectionHandlerTest.java | 142 ++-- .../xml/ovf/VirtualSystemHandlerTest.java | 106 --- ...ExpressVAppTemplateParamsToXmlPayload.java | 2 +- .../HardwareForVCloudExpressVApp.java | 40 +- .../ResourceAllocationsToVolumes.java | 55 -- .../VCloudExpressVAppToNodeMetadata.java | 2 +- .../vcloud/domain/VCloudExpressVApp.java | 8 +- .../internal/VCloudExpressVAppImpl.java | 14 +- .../xml/VCloudExpressNetworkHandler.java | 34 +- .../vcloud/xml/VCloudExpressVAppHandler.java | 24 +- .../xml/VCloudExpressVAppTemplateHandler.java | 10 +- .../xml/ovf/VCloudExpressVAppHandlerTest.java | 84 ++- .../BindVAppConfigurationToXmlPayload.java | 38 +- ...antiateVAppTemplateParamsToXmlPayload.java | 4 +- .../xml/TerremarkCatalogItemHandler.java | 2 +- .../terremark/xml/TerremarkOrgHandler.java | 2 +- .../TerremarkVCloudExpressNetworkHandler.java | 2 +- .../terremark/xml/TerremarkVDCHandler.java | 2 +- .../terremark/TerremarkClientLiveTest.java | 66 +- ...BindVAppConfigurationToXmlPayloadTest.java | 80 +- .../xml/ResourceAllocationHandlerTest.java | 20 +- .../vcloud/terremark/xml/VAppHandlerTest.java | 96 ++- .../terremark/xml/ovf/SystemHandlerTest.java | 12 +- .../vcloud/domain/ovf/ResourceAllocation.java | 201 ----- .../vcloud/domain/ovf/ResourceType.java | 100 --- .../org/jclouds/vcloud/domain/ovf/System.java | 114 --- .../java/org/jclouds/vcloud/util/Utils.java | 16 +- .../jclouds/vcloud/xml/CatalogHandler.java | 4 +- .../vcloud/xml/CatalogItemHandler.java | 4 +- .../org/jclouds/vcloud/xml/ErrorHandler.java | 5 +- .../org/jclouds/vcloud/xml/OrgHandler.java | 4 +- .../jclouds/vcloud/xml/OrgListHandler.java | 4 +- .../jclouds/vcloud/xml/OrgNetworkHandler.java | 4 +- .../org/jclouds/vcloud/xml/TaskHandler.java | 5 +- .../jclouds/vcloud/xml/TasksListHandler.java | 5 +- .../org/jclouds/vcloud/xml/VDCHandler.java | 4 +- .../xml/ovf/ResourceAllocationHandler.java | 128 ---- .../jclouds/vcloud/xml/ovf/SystemHandler.java | 72 -- .../ovf/ResourceAllocationHandlerTest.java | 53 -- .../vcloud/xml/ovf/SystemHandlerTest.java | 50 -- .../java/org/jclouds/cim/CIMPredicates.java | 23 +- .../java/org/jclouds/cim/ManagedElement.java | 114 +++ .../cim/ResourceAllocationSettingData.java | 708 ++++++++++++++++++ .../java/org/jclouds/cim/SettingData.java | 126 ++++ .../jclouds/cim/VirtualSystemSettingData.java | 575 ++++++++++++++ ...ardwareBuilderFromResourceAllocations.java | 76 ++ .../ResourceAllocationSettingDataHandler.java | 130 ++++ .../xml/VirtualSystemSettingDataHandler.java | 125 ++++ .../domain/{os => }/CIMOperatingSystem.java | 22 +- .../compute/domain/HardwareBuilder.java | 9 +- .../domain/{os => }/OsFamilyVersion64Bit.java | 3 +- .../main/java/org/jclouds/ovf}/Network.java | 2 +- .../java/org/jclouds}/ovf/NetworkSection.java | 11 +- .../jclouds}/ovf/OperatingSystemSection.java | 2 +- .../java/org/jclouds}/ovf/OvfEnvelope.java | 2 +- .../jclouds}/ovf/VirtualHardwareSection.java | 21 +- .../java/org/jclouds}/ovf/VirtualSystem.java | 3 +- .../ovf/xml}/NetworkSectionHandler.java | 29 +- .../xml}/OperatingSystemSectionHandler.java | 21 +- .../jclouds/ovf/xml}/OvfEnvelopeHandler.java | 6 +- .../xml/VirtualHardwareSectionHandler.java | 23 +- .../ovf/xml}/VirtualSystemHandler.java | 34 +- ...ourceAllocationSettingDataHandlerTest.java | 65 ++ .../VirtualSystemSettingDataHandlerTest.java | 131 ++++ .../compute/BaseTemplateBuilderLiveTest.java | 2 +- .../OperatingSystemPredicatesTest.java | 4 +- .../ovf/xml}/OvfEnvelopeHandlerTest.java | 8 +- compute/src/test/resources/os.xml | 11 + .../src/test/resources/ovf.xml | 0 .../resources/resourceallocation-hosting.xml | 0 .../src/test/resources/resourceallocation.xml | 0 .../test/resources/virtualhardwaresection.xml | 118 +++ .../test/resources/virtualsystem-hosting.xml | 0 .../src/test/resources/virtualsystem.xml | 0 .../rest/internal/AsyncRestClientProxy.java | 18 +- .../internal/RestAnnotationProcessor.java | 5 +- .../main/java/org/jclouds/util/SaxUtils.java | 19 +- .../concurrent/internal/SyncProxyTest.java | 14 +- .../http/IntegrationTestAsyncClient.java | 2 + .../jclouds/http/IntegrationTestClient.java | 2 + .../internal/RestAnnotationProcessorTest.java | 340 +++++---- .../AWSEC2TemplateBuilderLiveTest.java | 2 +- .../azureblob/AzureBlobAsyncClient.java | 3 +- .../jclouds/azureblob/AzureBlobClient.java | 3 + ...VCloudDirectorTemplateBuilderLiveTest.java | 2 +- ...CloudServersUKTemplateBuilderLiveTest.java | 2 +- ...CloudServersUSTemplateBuilderLiveTest.java | 2 +- ...CloudSigmaComputeServiceContextModule.java | 2 +- ...arseOsFamilyVersion64BitFromImageName.java | 2 +- .../functions/PreinstalledDiskToImage.java | 2 +- .../CloudSigmaTemplateBuilderLiveTest.java | 2 +- ...OsFamilyVersion64BitFromImageNameTest.java | 2 +- ...ueSquareLondonTemplateBuilderLiveTest.java | 2 +- ...stsPeer1LondonTemplateBuilderLiveTest.java | 2 +- ...eer1SanAntonioTemplateBuilderLiveTest.java | 2 +- ...loudEucalyptusTemplateBuilderLiveTest.java | 2 +- .../GoGridTemplateBuilderLiveTest.java | 2 +- ...enHostingEast1TemplateBuilderLiveTest.java | 2 +- ...loveManchesterTemplateBuilderLiveTest.java | 2 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 2 +- .../SlicehostTemplateBuilderLiveTest.java | 2 +- ...erremarkECloudTemplateBuilderLiveTest.java | 2 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 2 +- .../jclouds/nirvanix/sdn/SDNAsyncClient.java | 3 +- .../org/jclouds/nirvanix/sdn/SDNClient.java | 4 +- ...DeveloperCloudTemplateBuilderLiveTest.java | 2 +- .../vpdc/domain/ResourceAllocation.java | 279 ------- .../org/jclouds/savvis/vpdc/domain/VApp.java | 15 +- .../vpdc/domain/vapp/NetworkSection.java | 71 -- .../vpdc/features/BrowsingAsyncClient.java | 6 +- .../savvis/vpdc/features/BrowsingClient.java | 5 +- .../vpdc/options/BindGetVAppOptions.java | 37 + .../savvis/vpdc/options/GetVAppOptions.java | 67 ++ .../vpdc/xml/NetworkSectionHandler.java | 58 -- .../vpdc/xml/ResourceAllocationHandler.java | 59 -- .../jclouds/savvis/vpdc/xml/VAppHandler.java | 6 +- .../vpdc/features/BaseVPDCClientLiveTest.java | 15 +- .../features/BrowsingAsyncClientTest.java | 35 +- .../vpdc/features/BrowsingClientLiveTest.java | 9 +- .../xml/ResourceAllocationHandlerTest.java | 32 - 160 files changed, 4177 insertions(+), 2470 deletions(-) delete mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java create mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java delete mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java create mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java rename apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/{VCloudResourceAllocationHandler.java => VCloudResourceAllocationSettingDataHandler.java} (60%) delete mode 100644 apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java delete mode 100644 apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java delete mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java delete mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java delete mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/System.java delete mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java delete mode 100644 common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/SystemHandler.java delete mode 100644 common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java delete mode 100644 common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java rename common/vcloud/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java => compute/src/main/java/org/jclouds/cim/CIMPredicates.java (64%) create mode 100644 compute/src/main/java/org/jclouds/cim/ManagedElement.java create mode 100644 compute/src/main/java/org/jclouds/cim/ResourceAllocationSettingData.java create mode 100644 compute/src/main/java/org/jclouds/cim/SettingData.java create mode 100644 compute/src/main/java/org/jclouds/cim/VirtualSystemSettingData.java create mode 100644 compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java create mode 100644 compute/src/main/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandler.java create mode 100644 compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java rename compute/src/main/java/org/jclouds/compute/domain/{os => }/CIMOperatingSystem.java (92%) rename compute/src/main/java/org/jclouds/compute/domain/{os => }/OsFamilyVersion64Bit.java (96%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/network => compute/src/main/java/org/jclouds/ovf}/Network.java (97%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain => compute/src/main/java/org/jclouds}/ovf/NetworkSection.java (89%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain => compute/src/main/java/org/jclouds}/ovf/OperatingSystemSection.java (98%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain => compute/src/main/java/org/jclouds}/ovf/OvfEnvelope.java (98%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain => compute/src/main/java/org/jclouds}/ovf/VirtualHardwareSection.java (80%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/domain => compute/src/main/java/org/jclouds}/ovf/VirtualSystem.java (99%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf => compute/src/main/java/org/jclouds/ovf/xml}/NetworkSectionHandler.java (74%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf => compute/src/main/java/org/jclouds/ovf/xml}/OperatingSystemSectionHandler.java (76%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf => compute/src/main/java/org/jclouds/ovf/xml}/OvfEnvelopeHandler.java (95%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud => compute/src/main/java/org/jclouds/ovf}/xml/VirtualHardwareSectionHandler.java (79%) rename {apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf => compute/src/main/java/org/jclouds/ovf/xml}/VirtualSystemHandler.java (79%) create mode 100644 compute/src/test/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandlerTest.java create mode 100644 compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java rename {apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf => compute/src/test/java/org/jclouds/ovf/xml}/OvfEnvelopeHandlerTest.java (86%) create mode 100644 compute/src/test/resources/os.xml rename {apis/vcloud => compute}/src/test/resources/ovf.xml (100%) rename {common/vcloud => compute}/src/test/resources/resourceallocation-hosting.xml (100%) rename {sandbox-providers/savvis-symphonyvpdc => compute}/src/test/resources/resourceallocation.xml (100%) create mode 100644 compute/src/test/resources/virtualhardwaresection.xml rename {common/vcloud => compute}/src/test/resources/virtualsystem-hosting.xml (100%) rename {apis/vcloud => compute}/src/test/resources/virtualsystem.xml (100%) delete mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java delete mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java create mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/BindGetVAppOptions.java create mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/GetVAppOptions.java delete mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java delete mode 100644 sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java delete mode 100644 sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandlerTest.java diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java index 003e429201..2bb2ece124 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosAsyncClient.java @@ -60,6 +60,7 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides asynchronous access to EMC Atmos Online Storage resources via their REST API. @@ -76,6 +77,7 @@ public interface AtmosAsyncClient { /** * Creates a default implementation of AtmosObject */ + @Provides AtmosObject newObject(); /** diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java index 5be01e6e42..0f4cb7cdaf 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosClient.java @@ -31,6 +31,8 @@ import org.jclouds.atmos.options.ListOptions; import org.jclouds.concurrent.Timeout; import org.jclouds.http.options.GetOptions; +import com.google.inject.Provides; + /** * Provides access to EMC Atmos Online Storage resources via their REST API. *

@@ -44,6 +46,7 @@ public interface AtmosClient { /** * Creates a default implementation of AtmosObject */ + @Provides AtmosObject newObject(); BoundedSet listDirectories(ListOptions... options); diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3AsyncClient.java b/apis/s3/src/main/java/org/jclouds/s3/S3AsyncClient.java index 1d41f7e5d5..71806e4f8a 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3AsyncClient.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3AsyncClient.java @@ -88,6 +88,7 @@ import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides asynchronous access to S3 via their REST API. @@ -110,6 +111,7 @@ public interface S3AsyncClient { /** * Creates a default implementation of S3Object */ + @Provides public S3Object newS3Object(); /** diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3Client.java b/apis/s3/src/main/java/org/jclouds/s3/S3Client.java index f9fe89a657..4e523c5fca 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3Client.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3Client.java @@ -39,6 +39,8 @@ import org.jclouds.s3.options.PutObjectOptions; import org.jclouds.concurrent.Timeout; import org.jclouds.http.options.GetOptions; +import com.google.inject.Provides; + import java.util.concurrent.Future; /** @@ -58,6 +60,7 @@ public interface S3Client { /** * Creates a default implementation of S3Object */ + @Provides public S3Object newS3Object(); /** diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java index 08f8c38547..e67dfb8ced 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftAsyncClient.java @@ -64,6 +64,7 @@ import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Common features between OpenStack Swift and CloudFiles @@ -76,7 +77,7 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(AuthenticateRequest.class) @Endpoint(Storage.class) public interface CommonSwiftAsyncClient { - + @Provides SwiftObject newSwiftObject(); /** diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java index cece147011..0578926e55 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java @@ -34,6 +34,8 @@ import org.jclouds.openstack.swift.domain.ObjectInfo; import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.openstack.swift.options.ListContainerOptions; +import com.google.inject.Provides; + /** * Common features between OpenStack Swift and CloudFiles * @@ -42,7 +44,7 @@ import org.jclouds.openstack.swift.options.ListContainerOptions; */ @Timeout(duration = 120, timeUnit = TimeUnit.SECONDS) public interface CommonSwiftClient { - + @Provides SwiftObject newSwiftObject(); /** diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java index 9f34a339e2..b3f8b3b77d 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java @@ -42,6 +42,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.jclouds.ovf.OvfEnvelope; +import org.jclouds.ovf.xml.OvfEnvelopeHandler; import org.jclouds.predicates.validators.DnsNameValidator; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Endpoint; @@ -69,7 +71,6 @@ import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; import org.jclouds.vcloud.endpoints.OrgList; import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; @@ -82,7 +83,6 @@ import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.VAppHandler; import org.jclouds.vcloud.xml.VAppTemplateHandler; import org.jclouds.vcloud.xml.VmHandler; -import org.jclouds.vcloud.xml.ovf.OvfEnvelopeHandler; import com.google.common.util.concurrent.ListenableFuture; 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 78bb784fa4..d1f5aca4c1 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import org.jclouds.concurrent.Timeout; +import org.jclouds.ovf.OvfEnvelope; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.NetworkConnectionSection; import org.jclouds.vcloud.domain.ReferenceType; @@ -35,7 +36,6 @@ import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; import org.jclouds.vcloud.options.CaptureVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; 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 e076338735..03f583e4fe 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 @@ -192,7 +192,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder String networkName; VAppTemplate vAppTemplate = client.getVAppTemplate(template); checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template); - Set networks = vAppTemplate.getNetworkSection().getNetworks(); + Set networks = vAppTemplate.getNetworkSection().getNetworks(); checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate); if (networks.size() > 1) logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks); 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 cb1a134e34..659a685b3c 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 @@ -20,32 +20,20 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; - -import java.util.List; import javax.annotation.Resource; import javax.inject.Inject; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; 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.VApp; import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection; import com.google.common.base.Function; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; /** * @author Adrian Cole @@ -56,13 +44,13 @@ public class HardwareForVApp implements Function { protected Logger logger = Logger.NULL; private final FindLocationForResource findLocationForResource; - private final ResourceAllocationsToVolumes resourceAllocationsToVolumes; + private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder; @Inject protected HardwareForVApp(FindLocationForResource findLocationForResource, - ResourceAllocationsToVolumes resourceAllocationsToVolumes) { + VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); - this.resourceAllocationsToVolumes = checkNotNull(resourceAllocationsToVolumes, "resourceAllocationsToVolumes"); + this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); } @Override @@ -72,25 +60,12 @@ public class HardwareForVApp implements Function { Vm vm = from.getChildren().size() == 0 ? null : Iterables.get(from.getChildren(), 0); if (vm == null) return null; - Location location = findLocationForResource.apply(checkNotNull(from, "from").getVDC()); VirtualHardwareSection hardware = vm.getVirtualHardwareSection(); - - int ram = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(); - - List processors = Lists.newArrayList(transform( - filter(hardware.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)), - new Function() { - - @Override - public Processor apply(ResourceAllocation arg0) { - return new Processor(arg0.getVirtualQuantity(), 1); - } - - })); - List volumes = Lists.newArrayList(resourceAllocationsToVolumes.apply(hardware.getResourceAllocations())); - return new HardwareBuilder().ids(from.getHref().toASCIIString()).uri(from.getHref()).name(from.getName()) - .location(location).processors(processors).ram(ram).volumes(volumes) - .supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString())).build(); + HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getResourceAllocations()); + builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC())); + builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( + ImagePredicates.idEquals(from.getHref().toASCIIString())); + return builder.build(); } } \ No newline at end of file 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 973a7d3269..b26841ea12 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 @@ -20,34 +20,22 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; - -import java.util.List; import javax.annotation.Resource; import javax.inject.Inject; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.domain.Location; import org.jclouds.logging.Logger; +import org.jclouds.ovf.OvfEnvelope; +import org.jclouds.ovf.VirtualHardwareSection; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection; import com.google.common.base.Function; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; /** * @author Adrian Cole @@ -59,16 +47,16 @@ public class HardwareForVAppTemplate implements Function private final VCloudClient client; private final FindLocationForResource findLocationForResource; - private final ResourceAllocationsToVolumes resourceAllocationsToVolumes; + private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder; private ReferenceType parent; @Inject protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource, - ResourceAllocationsToVolumes resourceAllocationsToVolumes) { + VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) { this.client = checkNotNull(client, "client"); this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); - this.resourceAllocationsToVolumes = checkNotNull(resourceAllocationsToVolumes, "resourceAllocationsToVolumes"); + this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder"); } public HardwareForVAppTemplate withParent(ReferenceType parent) { @@ -90,8 +78,6 @@ public class HardwareForVAppTemplate implements Function logger.warn("cannot parse hardware as no ovf envelope found for %s", from); return null; } - - Location location = findLocationForResource.apply(checkNotNull(parent, "parent")); if (ovf.getVirtualSystem().getHardware().size() == 0) { logger.warn("cannot parse hardware for %s as no hardware sections exist in ovf %s", ovf); return null; @@ -100,24 +86,11 @@ public class HardwareForVAppTemplate implements Function logger.warn("multiple hardware choices found. using first", ovf); } VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getHardware(), 0); - - int ram = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(); - - List processors = Lists.newArrayList(transform( - filter(hardware.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)), - new Function() { - - @Override - public Processor apply(ResourceAllocation arg0) { - return new Processor(arg0.getVirtualQuantity(), 1); - } - - })); - List volumes = Lists.newArrayList(resourceAllocationsToVolumes.apply(hardware.getResourceAllocations())); - return new HardwareBuilder().ids(from.getHref().toASCIIString()).uri(from.getHref()).name(from.getName()) - .location(location).processors(processors).ram(ram).volumes(volumes) - .supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString())).build(); - + HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getResourceAllocations()); + builder.location(findLocationForResource.apply(checkNotNull(parent, "parent"))); + builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( + ImagePredicates.idEquals(from.getHref().toASCIIString())); + return builder.build(); } protected String getName(String name) { 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 277b0a12f2..d5ae785c4b 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 @@ -20,17 +20,17 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs; import javax.inject.Inject; +import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; +import org.jclouds.ovf.OvfEnvelope; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; import com.google.common.base.Function; @@ -65,7 +65,7 @@ public class ImageForVAppTemplate implements Function { builder.location(findLocationForResource.apply(checkNotNull(parent, "parent"))); builder.description(from.getDescription() != null ? from.getDescription() : from.getName()); OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref()); - builder.operatingSystem(toComputeOs(ovf)); + 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/functions/ResourceAllocationsToVolumes.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java deleted file mode 100644 index 3add051baa..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class ResourceAllocationsToVolumes implements Function, Iterable> { - @Override - public Iterable apply(Iterable resourceAllocations) { - Iterable volumes = transform(filter(resourceAllocations, resourceType(ResourceType.DISK_DRIVE)), - new Function() { - - @Override - public Volume apply(ResourceAllocation from) { - if (from instanceof VCloudHardDisk) { - VCloudHardDisk vDisk = VCloudHardDisk.class.cast(from); - return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, - vDisk.getCapacity() / 1024f, null, from.getAddressOnParent() == 0, true); - } else { - return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, - from.getVirtualQuantity() / 1024 / 1024f, null, from.getAddressOnParent() == 0, true); - } - } - - }); - return volumes; - } -} \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java new file mode 100644 index 0000000000..64947de771 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java @@ -0,0 +1,46 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.vcloud.compute.functions; + +import javax.inject.Singleton; + +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.internal.VolumeImpl; +import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; + +/** + * @author Adrian Cole + */ +@Singleton +public class VCloudHardwareBuilderFromResourceAllocations extends HardwareBuilderFromResourceAllocations { + @Override + public Volume apply(ResourceAllocationSettingData from) { + if (from instanceof VCloudHardDisk) { + VCloudHardDisk vDisk = VCloudHardDisk.class.cast(from); + return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, vDisk.getCapacity() / 1024f, null, + "0".equals(from.getAddressOnParent()), true); + } else { + return super.apply(from); + } + + } +} \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java index a5d19e7c15..a32d6445be 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java @@ -20,25 +20,24 @@ package org.jclouds.vcloud.compute.util; import static com.google.common.collect.Iterables.filter; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; import java.util.Set; +import org.jclouds.cim.CIMPredicates; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.os.CIMOperatingSystem; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; /** * @@ -55,16 +54,8 @@ public class VCloudComputeUtils { return vApp.getChildren().size() > 0 ? toComputeOs(Iterables.get(vApp.getChildren(), 0)) : null; } - public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) { - return toComputeOs(ovf.getVirtualSystem().getOperatingSystem()); - } - public static CIMOperatingSystem toComputeOs(Vm vm) { - return toComputeOs(vm.getOperatingSystemSection()); - } - - public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystemSection os) { - return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), "", null, os.getDescription()); + return CIMOperatingSystem.toComputeOs(vm.getOperatingSystemSection()); } public static Credentials getCredentialsFrom(VApp vApp) { @@ -106,8 +97,8 @@ public class VCloudComputeUtils { ips.add(connection.getExternalIpAddress()); } } else { - for (ResourceAllocation net : filter(vm.getVirtualHardwareSection().getResourceAllocations(), - resourceType(ResourceType.ETHERNET_ADAPTER))) { + for (ResourceAllocationSettingData net : filter(vm.getVirtualHardwareSection().getResourceAllocations(), + CIMPredicates.resourceTypeIn(ResourceType.ETHERNET_ADAPTER))) { if (net instanceof VCloudNetworkAdapter) { VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net); if (vNet.getIpAddress() != null) 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 626f36fe9f..b06c71297e 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 @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.RequiresHttp; import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.ConfiguresRestClient; @@ -38,23 +39,22 @@ import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems; +import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.inject.Provides; import com.google.inject.TypeLiteral; - /** - * Configures the VCloud authentication service connection, including logging - * and http transport. + * Configures the VCloud authentication service connection, including logging and http transport. * * @author Adrian Cole */ @RequiresHttp @ConfiguresRestClient public abstract class BaseVCloudRestClientModule extends - CommonVCloudRestClientModule { + CommonVCloudRestClientModule { public BaseVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); @@ -65,6 +65,7 @@ public abstract class BaseVCloudRestClientModule, Iterable>>() { }).to(new TypeLiteral() { }); + bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); super.configure(); } @@ -77,21 +78,21 @@ public abstract class BaseVCloudRestClientModule provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - final VCloudLoginAsyncClient login) { + final VCloudLoginAsyncClient login) { return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier(authException, seconds, - new Supplier() { + new Supplier() { - @Override - public VCloudSession get() { - try { - return login.login().get(10, TimeUnit.SECONDS); - } catch (Exception e) { - propagate(e); - assert false : e; - return null; + @Override + public VCloudSession get() { + try { + return login.login().get(10, TimeUnit.SECONDS); + } catch (Exception e) { + propagate(e); + assert false : e; + return null; + } } - } - }); + }); } } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java index 036d07d175..c8a5d870e4 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java @@ -21,8 +21,8 @@ package org.jclouds.vcloud.domain; import java.util.Set; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.System; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -33,10 +33,10 @@ import com.google.common.collect.Sets; public class InstantiateVAppTemplateParams { protected final String info; - protected final System virtualSystem; - protected final Set resourceAllocations = Sets.newLinkedHashSet(); + protected final VirtualSystemSettingData virtualSystem; + protected final Set resourceAllocations = Sets.newLinkedHashSet(); - public InstantiateVAppTemplateParams(String info, System virtualSystem, Iterable resourceAllocations) { + public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable resourceAllocations) { this.info = info; this.virtualSystem = virtualSystem; Iterables.addAll(this.resourceAllocations, resourceAllocations); @@ -46,11 +46,11 @@ public class InstantiateVAppTemplateParams { return info; } - public System getSystem() { + public VirtualSystemSettingData getSystem() { return virtualSystem; } - public Set getResourceAllocations() { + public Set getResourceAllocationSettingDatas() { return resourceAllocations; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java deleted file mode 100644 index 3094f212ad..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.domain.ovf; - -import org.jclouds.vcloud.domain.ReferenceType; - -/** - * @author Adrian Cole - * - */ -public class EditableResourceAllocation extends ResourceAllocation { - private final ReferenceType edit; - - public EditableResourceAllocation(int id, String name, String description, ResourceType type, String subType, - String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected, - long virtualQuantity, String virtualQuantityUnits, ReferenceType edit) { - super(id, name, description, type, subType, hostResource, address, addressOnParent, parent, connected, - virtualQuantity, virtualQuantityUnits); - this.edit = edit; - - } - - @Override - public String toString() { - return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType() - + ", virtualQuantity=" + getVirtualQuantity() + ", virtualQuantityUnits=" + getVirtualQuantityUnits() - + ", edit=" + edit + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((edit == null) ? 0 : edit.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - EditableResourceAllocation other = (EditableResourceAllocation) obj; - if (edit == null) { - if (other.edit != null) - return false; - } else if (!edit.equals(other.edit)) - return false; - return true; - } - -} \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java new file mode 100644 index 0000000000..c472fd25c0 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java @@ -0,0 +1,303 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.vcloud.domain.ovf; + +import java.util.List; + +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.vcloud.domain.ReferenceType; + +/** + * @author Adrian Cole + * + */ +public class EditableResourceAllocationSettingData extends ResourceAllocationSettingData { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends ResourceAllocationSettingData.Builder { + private ReferenceType edit; + + /** + * @see EditableResourceAllocationSettingData#getEdit + */ + public Builder edit(ReferenceType edit) { + this.edit = edit; + return this; + } + + public EditableResourceAllocationSettingData build() { + return new EditableResourceAllocationSettingData(elementName, instanceID, caption, description, address, + addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, edit); + } + + public Builder fromEditableResourceAllocationSettingData(EditableResourceAllocationSettingData in) { + return edit(in.getEdit()).fromResourceAllocationSettingData(in); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder caption(String caption) { + return Builder.class.cast(super.caption(caption)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder address(String address) { + return Builder.class.cast(super.address(address)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder addressOnParent(String addressOnParent) { + return Builder.class.cast(super.addressOnParent(addressOnParent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder allocationUnits(String allocationUnits) { + return Builder.class.cast(super.allocationUnits(allocationUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticAllocation(Boolean automaticAllocation) { + return Builder.class.cast(super.automaticAllocation(automaticAllocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticDeallocation(Boolean automaticDeallocation) { + return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connection(String connection) { + return Builder.class.cast(super.connection(connection)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connections(List connections) { + return Builder.class.cast(super.connections(connections)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { + return Builder.class.cast(super.consumerVisibility(consumerVisibility)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResource(String hostResource) { + return Builder.class.cast(super.hostResource(hostResource)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResources(List hostResources) { + return Builder.class.cast(super.hostResources(hostResources)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder limit(Long limit) { + return Builder.class.cast(super.limit(limit)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder mappingBehavior(MappingBehavior mappingBehavior) { + return Builder.class.cast(super.mappingBehavior(mappingBehavior)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder otherResourceType(String otherResourceType) { + return Builder.class.cast(super.otherResourceType(otherResourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder parent(String parent) { + return Builder.class.cast(super.parent(parent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder poolID(String poolID) { + return Builder.class.cast(super.poolID(poolID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder reservation(Long reservation) { + return Builder.class.cast(super.reservation(reservation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceSubType(String resourceSubType) { + return Builder.class.cast(super.resourceSubType(resourceSubType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { + return Builder.class.cast(super.resourceType(resourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantity(Long virtualQuantity) { + return Builder.class.cast(super.virtualQuantity(virtualQuantity)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantityUnits(String virtualQuantityUnits) { + return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder weight(Integer weight) { + return Builder.class.cast(super.weight(weight)); + } + + @Override + public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { + return Builder.class.cast(super.fromResourceAllocationSettingData(in)); + } + + } + + private final ReferenceType edit; + + public EditableResourceAllocationSettingData(String elementName, String instanceID, String caption, + String description, String address, String addressOnParent, String allocationUnits, + Boolean automaticAllocation, Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, + Long limit, MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, + Long reservation, String resourceSubType, + org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity, + String virtualQuantityUnits, Integer weight, List connections, List hostResources, + ReferenceType edit) { + super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, + otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, + virtualQuantityUnits, weight, connections, hostResources); + this.edit = edit; + } + + public ReferenceType getEdit() { + return edit; + } + + @Override + public Builder toBuilder() { + return new Builder().fromEditableResourceAllocationSettingData(this); + } + + @Override + public String toString() { + return String + .format( + "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, edit=%s]", + elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight, edit); + } + +} \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java index f8b54e6770..22c4f3fc60 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java @@ -19,21 +19,283 @@ package org.jclouds.vcloud.domain.ovf; +import java.util.List; + +import org.jclouds.cim.ResourceAllocationSettingData; /** * @author Adrian Cole * */ -public class VCloudHardDisk extends ResourceAllocation { +public class VCloudHardDisk extends ResourceAllocationSettingData { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends ResourceAllocationSettingData.Builder { + private long capacity; + private int busType; + private String busSubType; + + /** + * @see VCloudHardDisk#getCapacity + */ + public Builder capacity(long capacity) { + this.capacity = capacity; + return this; + } + + /** + * @see VCloudHardDisk#getBusType + */ + public Builder busType(int busType) { + this.busType = busType; + return this; + } + + /** + * @see VCloudHardDisk#getBusSubType + */ + public Builder busSubType(String busSubType) { + this.busSubType = busSubType; + return this; + } + + public VCloudHardDisk build() { + return new VCloudHardDisk(elementName, instanceID, caption, description, address, addressOnParent, + allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, + mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, + virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, capacity, busType, + busSubType); + } + + public Builder fromVCloudHardDisk(VCloudHardDisk in) { + return capacity(in.getCapacity()).busType(in.getBusType()).busSubType(in.getBusSubType()) + .fromResourceAllocationSettingData(in); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder caption(String caption) { + return Builder.class.cast(super.caption(caption)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder address(String address) { + return Builder.class.cast(super.address(address)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder addressOnParent(String addressOnParent) { + return Builder.class.cast(super.addressOnParent(addressOnParent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder allocationUnits(String allocationUnits) { + return Builder.class.cast(super.allocationUnits(allocationUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticAllocation(Boolean automaticAllocation) { + return Builder.class.cast(super.automaticAllocation(automaticAllocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticDeallocation(Boolean automaticDeallocation) { + return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connection(String connection) { + return Builder.class.cast(super.connection(connection)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connections(List connections) { + return Builder.class.cast(super.connections(connections)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { + return Builder.class.cast(super.consumerVisibility(consumerVisibility)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResource(String hostResource) { + return Builder.class.cast(super.hostResource(hostResource)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResources(List hostResources) { + return Builder.class.cast(super.hostResources(hostResources)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder limit(Long limit) { + return Builder.class.cast(super.limit(limit)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder mappingBehavior(MappingBehavior mappingBehavior) { + return Builder.class.cast(super.mappingBehavior(mappingBehavior)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder otherResourceType(String otherResourceType) { + return Builder.class.cast(super.otherResourceType(otherResourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder parent(String parent) { + return Builder.class.cast(super.parent(parent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder poolID(String poolID) { + return Builder.class.cast(super.poolID(poolID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder reservation(Long reservation) { + return Builder.class.cast(super.reservation(reservation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceSubType(String resourceSubType) { + return Builder.class.cast(super.resourceSubType(resourceSubType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { + return Builder.class.cast(super.resourceType(resourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantity(Long virtualQuantity) { + return Builder.class.cast(super.virtualQuantity(virtualQuantity)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantityUnits(String virtualQuantityUnits) { + return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder weight(Integer weight) { + return Builder.class.cast(super.weight(weight)); + } + + @Override + public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { + return Builder.class.cast(super.fromResourceAllocationSettingData(in)); + } + } + private final long capacity; private final int busType; private final String busSubType; - public VCloudHardDisk(int id, String name, String description, ResourceType type, String subType, - String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected, - long virtualQuantity, String virtualQuantityUnits, long capacity, int busType, String busSubType) { - super(id, name, description, type, subType, hostResource, address, addressOnParent, parent, connected, - virtualQuantity, virtualQuantityUnits); + public VCloudHardDisk(String elementName, String instanceID, String caption, String description, String address, + String addressOnParent, String allocationUnits, Boolean automaticAllocation, Boolean automaticDeallocation, + ConsumerVisibility consumerVisibility, Long limit, MappingBehavior mappingBehavior, + String otherResourceType, String parent, String poolID, Long reservation, String resourceSubType, + org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity, + String virtualQuantityUnits, Integer weight, List connections, List hostResources, + long capacity, int busType, String busSubType) { + super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, + otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, + virtualQuantityUnits, weight, connections, hostResources); this.capacity = capacity; this.busType = busType; this.busSubType = busSubType; @@ -52,41 +314,18 @@ public class VCloudHardDisk extends ResourceAllocation { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((busSubType == null) ? 0 : busSubType.hashCode()); - result = prime * result + busType; - result = prime * result + (int) (capacity ^ (capacity >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VCloudHardDisk other = (VCloudHardDisk) obj; - if (busSubType == null) { - if (other.busSubType != null) - return false; - } else if (!busSubType.equals(other.busSubType)) - return false; - if (busType != other.busType) - return false; - if (capacity != other.capacity) - return false; - return true; + public Builder toBuilder() { + return builder().fromVCloudHardDisk(this); } @Override public String toString() { - return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType() - + ", virtualQuantity=" + getVirtualQuantity() + ", virtualQuantityUnits=" + getVirtualQuantityUnits() - + ", capacity=" + capacity + ", busType=" + busType + ", busSubType=" + busSubType + "]"; + return String + .format( + "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, busSubType=%s, busType=%s, capacity=%s]", + elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight, busSubType, busType, capacity); } - } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java index 9540be1aba..2234c13365 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java @@ -19,21 +19,283 @@ package org.jclouds.vcloud.domain.ovf; +import java.util.List; + +import org.jclouds.cim.ResourceAllocationSettingData; + /** * @author Adrian Cole * */ -public class VCloudNetworkAdapter extends ResourceAllocation { +public class VCloudNetworkAdapter extends ResourceAllocationSettingData { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends ResourceAllocationSettingData.Builder { + private String ipAddress; + private boolean primaryNetworkConnection; + private String ipAddressingMode; + + /** + * @see VCloudNetworkAdapter#getCapacity + */ + public Builder ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * @see VCloudNetworkAdapter#getBusType + */ + public Builder primaryNetworkConnection(boolean primaryNetworkConnection) { + this.primaryNetworkConnection = primaryNetworkConnection; + return this; + } + + /** + * @see VCloudNetworkAdapter#getBusSubType + */ + public Builder ipAddressingMode(String ipAddressingMode) { + this.ipAddressingMode = ipAddressingMode; + return this; + } + + public VCloudNetworkAdapter build() { + return new VCloudNetworkAdapter(elementName, instanceID, caption, description, address, addressOnParent, + allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit, + mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, + virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, ipAddress, + primaryNetworkConnection, ipAddressingMode); + } + + public Builder fromVCloudNetworkAdapter(VCloudNetworkAdapter in) { + return ipAddress(in.getIpAddress()).primaryNetworkConnection(in.isPrimaryNetworkConnection()) + .ipAddressingMode(in.getIpAddressingMode()).fromResourceAllocationSettingData(in); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder caption(String caption) { + return Builder.class.cast(super.caption(caption)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder address(String address) { + return Builder.class.cast(super.address(address)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder addressOnParent(String addressOnParent) { + return Builder.class.cast(super.addressOnParent(addressOnParent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder allocationUnits(String allocationUnits) { + return Builder.class.cast(super.allocationUnits(allocationUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticAllocation(Boolean automaticAllocation) { + return Builder.class.cast(super.automaticAllocation(automaticAllocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder automaticDeallocation(Boolean automaticDeallocation) { + return Builder.class.cast(super.automaticDeallocation(automaticDeallocation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connection(String connection) { + return Builder.class.cast(super.connection(connection)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder connections(List connections) { + return Builder.class.cast(super.connections(connections)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { + return Builder.class.cast(super.consumerVisibility(consumerVisibility)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResource(String hostResource) { + return Builder.class.cast(super.hostResource(hostResource)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder hostResources(List hostResources) { + return Builder.class.cast(super.hostResources(hostResources)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder limit(Long limit) { + return Builder.class.cast(super.limit(limit)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder mappingBehavior(MappingBehavior mappingBehavior) { + return Builder.class.cast(super.mappingBehavior(mappingBehavior)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder otherResourceType(String otherResourceType) { + return Builder.class.cast(super.otherResourceType(otherResourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder parent(String parent) { + return Builder.class.cast(super.parent(parent)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder poolID(String poolID) { + return Builder.class.cast(super.poolID(poolID)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder reservation(Long reservation) { + return Builder.class.cast(super.reservation(reservation)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceSubType(String resourceSubType) { + return Builder.class.cast(super.resourceSubType(resourceSubType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder resourceType(org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType) { + return Builder.class.cast(super.resourceType(resourceType)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantity(Long virtualQuantity) { + return Builder.class.cast(super.virtualQuantity(virtualQuantity)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder virtualQuantityUnits(String virtualQuantityUnits) { + return Builder.class.cast(super.virtualQuantityUnits(virtualQuantityUnits)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder weight(Integer weight) { + return Builder.class.cast(super.weight(weight)); + } + + @Override + public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { + return Builder.class.cast(super.fromResourceAllocationSettingData(in)); + } + } + private final String ipAddress; private final boolean primaryNetworkConnection; private final String ipAddressingMode; - public VCloudNetworkAdapter(int id, String name, String description, ResourceType type, String subType, - String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected, - long virtualQuantity, String virtualQuantityUnits, String ipAddress, boolean primaryNetworkConnection, - String ipAddressingMode) { - super(id, name, description, type, subType, hostResource, address, addressOnParent, parent, connected, - virtualQuantity, virtualQuantityUnits); + public VCloudNetworkAdapter(String elementName, String instanceID, String caption, String description, + String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, + Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, + MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, + String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, + Long virtualQuantity, String virtualQuantityUnits, Integer weight, List connections, + List hostResources, String ipAddress, boolean primaryNetworkConnection, String ipAddressingMode) { + super(elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, consumerVisibility, limit, mappingBehavior, + otherResourceType, parent, poolID, reservation, resourceSubType, resourceType, virtualQuantity, + virtualQuantityUnits, weight, connections, hostResources); this.ipAddress = ipAddress; this.primaryNetworkConnection = primaryNetworkConnection; this.ipAddressingMode = ipAddressingMode; @@ -52,44 +314,19 @@ public class VCloudNetworkAdapter extends ResourceAllocation { } @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode()); - result = prime * result + ((ipAddressingMode == null) ? 0 : ipAddressingMode.hashCode()); - result = prime * result + (primaryNetworkConnection ? 1231 : 1237); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - VCloudNetworkAdapter other = (VCloudNetworkAdapter) obj; - if (ipAddress == null) { - if (other.ipAddress != null) - return false; - } else if (!ipAddress.equals(other.ipAddress)) - return false; - if (ipAddressingMode == null) { - if (other.ipAddressingMode != null) - return false; - } else if (!ipAddressingMode.equals(other.ipAddressingMode)) - return false; - if (primaryNetworkConnection != other.primaryNetworkConnection) - return false; - return true; + public Builder toBuilder() { + return builder().fromVCloudNetworkAdapter(this); } @Override public String toString() { - return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType() - + ", address=" + getAddress() + ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode - + ", primaryNetworkConnection=" + primaryNetworkConnection + "]"; + return String + .format( + "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s, ipAddressingMode=%s, primaryNetworkConnection=%s, ipAddress=%s]", + elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight, ipAddressingMode, + primaryNetworkConnection, ipAddress); } - } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java index 01e7d35c2e..29ac68b734 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java @@ -21,7 +21,8 @@ package org.jclouds.vcloud.domain.ovf; import java.net.URI; -import org.jclouds.vcloud.domain.ovf.network.Network; +import org.jclouds.ovf.Network; +import org.jclouds.ovf.NetworkSection; /** * VCloud extension diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java index f497a1a105..4155edf6e2 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java @@ -25,6 +25,7 @@ import java.net.URI; import javax.annotation.Nullable; +import org.jclouds.ovf.OperatingSystemSection; import org.jclouds.vcloud.domain.ReferenceType; /** diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java index e892aaf65c..e909cabb51 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java @@ -21,6 +21,9 @@ package org.jclouds.vcloud.domain.ovf; import java.net.URI; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.ovf.VirtualHardwareSection; /** * A description of the virtual hardware supported by a virtual machine. @@ -29,8 +32,8 @@ public class VCloudVirtualHardwareSection extends VirtualHardwareSection { protected final String type; protected final URI href; - public VCloudVirtualHardwareSection(String type, URI href, String info, System virtualSystem, - Iterable resourceAllocations) { + public VCloudVirtualHardwareSection(String type, URI href, String info, VirtualSystemSettingData virtualSystem, + Iterable resourceAllocations) { super(info, virtualSystem, resourceAllocations); this.type = type; this.href = href; @@ -46,11 +49,7 @@ public class VCloudVirtualHardwareSection extends VirtualHardwareSection { @Override public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((href == null) ? 0 : href.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; + return href.hashCode(); } @Override @@ -62,17 +61,7 @@ public class VCloudVirtualHardwareSection extends VirtualHardwareSection { if (getClass() != obj.getClass()) return false; VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj; - if (href == null) { - if (other.href != null) - return false; - } else if (!href.equals(other.href)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - return true; + return href.equals(other.href); } @Override diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java index 7fb899e35f..9b99c77d4e 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java @@ -19,12 +19,12 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.ReferenceType; import org.xml.sax.Attributes; @@ -80,7 +80,7 @@ public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult } public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); this.currentText = new StringBuilder(); if (qName.endsWith("GuestCustomizationSection")) { guest = newReferenceType(attributes); diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java index bf70f958fb..c70729d247 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java @@ -19,11 +19,10 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; - import java.util.Map; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import org.xml.sax.Attributes; @@ -56,7 +55,7 @@ public class NetworkConnectionHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("NetworkConnection")) { network = attributes.get("network"); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java index 5de8b76d12..3c83e2f1e9 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; @@ -28,6 +27,7 @@ import java.util.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.NetworkConnectionSection; import org.jclouds.vcloud.domain.ReferenceType; @@ -62,7 +62,7 @@ public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult< @Override public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("NetworkConnection")) { inConnections = true; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index 59273d59b5..72a7cc0223 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.List; @@ -29,6 +28,7 @@ import java.util.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; @@ -75,7 +75,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Children")) { inChildren = true; } else if (qName.endsWith("Tasks")) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java index a2c3364941..ada8fdb1aa 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.List; @@ -29,6 +28,7 @@ import java.util.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; @@ -83,7 +83,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Children")) { inChildren = true; } else if (qName.endsWith("Tasks")) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java index f9408ae514..a4a0ac9782 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; @@ -27,9 +26,11 @@ import java.util.Map; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.ovf.VirtualHardwareSection; +import org.jclouds.ovf.xml.VirtualHardwareSectionHandler; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; -import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection; import org.xml.sax.Attributes; /** @@ -53,7 +54,7 @@ public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("VirtualHardwareSection")) { hardware = newReferenceType(attributes); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java index 0a30097b68..e285efff1f 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/VmHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.List; @@ -28,6 +27,7 @@ import java.util.Map; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.NetworkConnectionSection; import org.jclouds.vcloud.domain.ReferenceType; @@ -92,7 +92,7 @@ public class VmHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("VirtualHardwareSection")) { inHardware = true; } else if (qName.endsWith("OperatingSystemSection")) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java index 1ec59929c1..e0c701b9da 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java @@ -24,8 +24,10 @@ import java.util.Map; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.ovf.NetworkSection; +import org.jclouds.ovf.xml.NetworkSectionHandler; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.NetworkSection; import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; @@ -49,7 +51,7 @@ public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult attributes = Utils.cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("NetworkSection")) { this.net = Utils.newReferenceType(attributes); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java index 1a8d88de6b..901aa4c327 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java @@ -24,6 +24,7 @@ import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection; import org.jclouds.vcloud.util.Utils; @@ -56,7 +57,7 @@ public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult attributes = Utils.cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Link")) { this.edit = Utils.newReferenceType(attributes); } else if (qName.endsWith("OperatingSystemSection")) { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationHandler.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java similarity index 60% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationHandler.java rename to apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java index cf5fd7673e..c111b3cfca 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationHandler.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java @@ -21,9 +21,11 @@ package org.jclouds.vcloud.xml.ovf; import java.util.Map; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData; import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; import org.jclouds.vcloud.util.Utils; @@ -32,7 +34,7 @@ import org.xml.sax.Attributes; /** * @author Adrian Cole */ -public class VCloudResourceAllocationHandler extends ResourceAllocationHandler { +public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler { private ReferenceType edit; @@ -44,37 +46,35 @@ public class VCloudResourceAllocationHandler extends ResourceAllocationHandler { private boolean primaryNetworkConnection; private String ipAddressingMode; - protected ResourceAllocation newResourceAllocation() { - if (edit != null) { - ResourceAllocation allocation = new EditableResourceAllocation(instanceID, elementName, description, - resourceType, resourceSubType, hostResource, address, addressOnParent, parent, connected, - virtualQuantity, virtualQuantityUnits, edit); - this.edit = null; - return allocation; - } else if (busSubType != null) { - ResourceAllocation allocation = new VCloudHardDisk(instanceID, elementName, description, resourceType, - resourceSubType, hostResource, address, addressOnParent, parent, connected, virtualQuantity, - virtualQuantityUnits, capacity, busType, busSubType); - capacity = -1; - busType = -1; - busSubType = null; - return allocation; - } else if (ipAddress != null) { - ResourceAllocation allocation = new VCloudNetworkAdapter(instanceID, elementName, description, resourceType, - resourceSubType, hostResource, address, addressOnParent, parent, connected, virtualQuantity, - virtualQuantityUnits, ipAddress, primaryNetworkConnection, ipAddressingMode); + public ResourceAllocationSettingData getResult() { + try { + ResourceAllocationSettingData from = super.getResult(); + if (edit != null) { + return EditableResourceAllocationSettingData.builder().fromResourceAllocationSettingData(from).edit(edit) + .build(); + } else if (busSubType != null) { + return VCloudHardDisk.builder().fromResourceAllocationSettingData(from).capacity(capacity).busType(busType) + .busSubType(busSubType).build(); + } else if (ipAddress != null) { + return VCloudNetworkAdapter.builder().fromResourceAllocationSettingData(from).ipAddress(ipAddress) + .primaryNetworkConnection(primaryNetworkConnection).ipAddressingMode(ipAddressingMode).build(); + } else { + return from; + } + } finally { ipAddress = null; primaryNetworkConnection = false; ipAddressingMode = null; - return allocation; - } else { - return super.newResourceAllocation(); + capacity = -1; + busType = -1; + busSubType = null; + edit = null; } } @Override public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = Utils.cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Link")) { this.edit = Utils.newReferenceType(attributes); } else if (qName.endsWith("HostResource") && attributes.size() > 0) { 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 9dfdf129ee..c37cbc04b4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java @@ -42,6 +42,7 @@ 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.OvfEnvelopeHandler; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; @@ -81,7 +82,6 @@ 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.jclouds.vcloud.xml.ovf.OvfEnvelopeHandler; import org.testng.annotations.Test; import com.google.common.base.Supplier; 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 9364f9253f..72b0e14a04 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 @@ -102,7 +102,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { expect(net.getNetworks()) .andReturn( ImmutableSet - . of(new org.jclouds.vcloud.domain.ovf.network.Network( + . of(new org.jclouds.ovf.Network( "vAppNet-vApp Internal", null))); replay(request); @@ -219,7 +219,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest { expect(net.getNetworks()) .andReturn( ImmutableSet - . of(new org.jclouds.vcloud.domain.ovf.network.Network( + . of(new org.jclouds.ovf.Network( "vAppNet-vApp Internal", null))); replay(request); 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 13792ec293..d0bd2e39ee 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 @@ -30,6 +30,7 @@ import java.util.Set; import javax.inject.Singleton; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; @@ -46,6 +47,7 @@ import org.jclouds.vcloud.compute.config.CommonVCloudComputeServiceContextModule import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.xml.VAppHandler; +import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; import org.testng.annotations.Test; import com.google.common.base.Function; @@ -78,6 +80,7 @@ public class VAppToNodeMetadataTest { bind(new TypeLiteral>() { }).to(new TypeLiteral() { }); + bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); } @SuppressWarnings("unused") @@ -106,8 +109,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); @@ -120,8 +123,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); @@ -136,7 +139,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/xml/VAppHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java index 523cd26429..7953649391 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; @@ -32,6 +33,7 @@ import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -49,7 +51,14 @@ public class VAppHandlerTest { public void testRhelOffStatic() { InputStream is = getClass().getResourceAsStream("/vapp-rhel-off-static.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); + Injector injector = Guice.createInjector(new SaxParserModule() { + + @Override + protected void configure() { + super.configure(); + bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); + } + }); Factory factory = injector.getInstance(ParseSax.Factory.class); VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); assertEquals(result.getName(), "vApp_acole_2"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java index 449b87d7ec..2f31dc2918 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java @@ -28,6 +28,7 @@ import org.jclouds.date.DateService; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.ovf.Network; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.Status; @@ -37,7 +38,6 @@ import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.TaskImpl; import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection; -import org.jclouds.vcloud.domain.ovf.network.Network; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java index 8c6033d2f8..c534c74ac7 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; @@ -32,6 +33,7 @@ import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest; +import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler; import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest; import org.testng.annotations.Test; @@ -48,7 +50,14 @@ import com.google.inject.Injector; public class VmHandlerTest { public void testVCloud1_0() { InputStream is = getClass().getResourceAsStream("/vm-rhel-off-static.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); + Injector injector = Guice.createInjector(new SaxParserModule() { + + @Override + protected void configure() { + super.configure(); + bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); + } + }); Factory factory = injector.getInstance(ParseSax.Factory.class); Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is); checkVm(result); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java index 89d6fdd52d..0ca1b00bb5 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java @@ -25,20 +25,24 @@ import java.io.InputStream; import java.net.URI; import java.net.UnknownHostException; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.System; +import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData; import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.inject.Guice; /** * Tests behavior of {@code VCloudVirtualHardwareSectionHandler} @@ -48,11 +52,24 @@ import com.google.common.collect.Iterables; // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest") public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest { + @BeforeTest + @Override + protected void setUpInjector() { + injector = Guice.createInjector(new SaxParserModule() { + public void configure() { + super.configure(); + bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class); + } + }); + factory = injector.getInstance(ParseSax.Factory.class); + assert factory != null; + } public void testDefault() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml"); - VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)).parse(is); + VCloudVirtualHardwareSection result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)) + .parse(is); checkHardware(result); @@ -60,73 +77,80 @@ public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest { @Test(enabled = false) public static void checkHardware(VCloudVirtualHardwareSection result) { - System system = new System(0, "Virtual Hardware Family", "RHEL5", ImmutableSet.of("vmx-07")); + VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("RHEL5").virtualSystemType("vmx-07").build(); assertEquals(result.getHref(), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/")); assertEquals(result.getType(), "application/vnd.vmware.vcloud.virtualHardwareSection+xml"); - assertEquals(result.getSystem(), system); + assertEquals(result.getSystem().toString(), system.toString()); assertEquals(result.getInfo(), "Virtual hardware requirements"); - assertEquals(Iterables.get(result.getResourceAllocations(), 0), new VCloudNetworkAdapter(1, "Network adapter 0", - "PCNet32 ethernet adapter", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, "00:50:56:01:01:f2", 0, - null, false, 1, null, "174.47.101.164", true, "POOL")); + assertEquals(Iterables.get(result.getResourceAllocations(), 0).toString(), VCloudNetworkAdapter.builder() + .instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter").resourceType( + ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").automaticAllocation(true).connection( + "internet01").address("00:50:56:01:01:f2").addressOnParent("0").ipAddress("174.47.101.164") + .primaryNetworkConnection(true).ipAddressingMode("POOL").build().toString()); - assertEquals(Iterables.get(result.getResourceAllocations(), 1), new ResourceAllocation(2, "SCSI Controller 0", - "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null)); + assertEquals(Iterables.get(result.getResourceAllocations(), 1).toString(), ResourceAllocationSettingData + .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType( + ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); - assertEquals(Iterables.get(result.getResourceAllocations(), 2), new VCloudHardDisk(2000, "Hard disk 1", - "Hard disk", ResourceType.DISK_DRIVE, null, null, null, 0, 2, null, 1, null, 30720, 6, "lsilogic")); + assertEquals(Iterables.get(result.getResourceAllocations(), 2).toString(), VCloudHardDisk.builder().instanceID( + "2000").elementName("Hard disk 1").description("Hard disk").resourceType(ResourceType.DISK_DRIVE) + .addressOnParent("0").parent("2").capacity(30720).busType(6).busSubType("lsilogic").build().toString()); - assertEquals(Iterables.get(result.getResourceAllocations(), 3), new ResourceAllocation(3, "IDE Controller 0", - "IDE Controller", ResourceType.IDE_CONTROLLER, null, null, "0", null, null, null, 1, null)); + assertEquals(Iterables.get(result.getResourceAllocations(), 3).toString(), ResourceAllocationSettingData + .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType( + ResourceType.IDE_CONTROLLER).address("0").build().toString()); - assertEquals(Iterables.get(result.getResourceAllocations(), 4), new ResourceAllocation(3002, "CD/DVD Drive 1", - "CD/DVD Drive", ResourceType.CD_DRIVE, null, null, null, 0, 3, null, 1, null)); + assertEquals(Iterables.get(result.getResourceAllocations(), 4).toString(), ResourceAllocationSettingData + .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType( + ResourceType.CD_DRIVE).addressOnParent("0").automaticAllocation(false).parent("3").build() + .toString()); - assertEquals(Iterables.get(result.getResourceAllocations(), 5), new ResourceAllocation(8000, "Floppy Drive 1", - "Floppy Drive", ResourceType.FLOPPY_DRIVE, null, null, null, 0, null, null, 1, null)); + assertEquals(Iterables.get(result.getResourceAllocations(), 5).toString(), ResourceAllocationSettingData + .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType( + ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); assertEquals( - Iterables.get(result.getResourceAllocations(), 6), - new EditableResourceAllocation( - 4, - "1 virtual CPU(s)", - "Number of Virtual CPUs", - ResourceType.PROCESSOR, - null, - null, - null, - null, - null, - null, - 1, - "hertz * 10^6", - new ReferenceTypeImpl( - null, - "application/vnd.vmware.vcloud.rasdItem+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu")))); + Iterables.get(result.getResourceAllocations(), 6).toString(), + EditableResourceAllocationSettingData + .builder() + .instanceID("4") + .elementName("1 virtual CPU(s)") + .description("Number of Virtual CPUs") + .resourceType(ResourceType.PROCESSOR) + .virtualQuantity(1l) + .allocationUnits("hertz * 10^6") + .reservation(0l) + .weight(0) + .edit( + new ReferenceTypeImpl( + null, + "application/vnd.vmware.vcloud.rasdItem+xml", + URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"))) + .build().toString()); assertEquals( - Iterables.get(result.getResourceAllocations(), 7), - new EditableResourceAllocation( - 5, - "384 MB of memory", - "Memory Size", - ResourceType.MEMORY, - null, - null, - null, - null, - null, - null, - 384, - "byte * 2^20", - new ReferenceTypeImpl( - null, - "application/vnd.vmware.vcloud.rasdItem+xml", - URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory")))); + Iterables.get(result.getResourceAllocations(), 7).toString(), + EditableResourceAllocationSettingData + .builder() + .instanceID("5") + .elementName("384 MB of memory") + .description("Memory Size") + .resourceType(ResourceType.MEMORY) + .virtualQuantity(384l) + .allocationUnits("byte * 2^20") + .reservation(0l) + .weight(0) + .edit( + new ReferenceTypeImpl( + null, + "application/vnd.vmware.vcloud.rasdItem+xml", + URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"))) + .build().toString()); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java deleted file mode 100644 index 91218d63db..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.xml.ovf; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.System; -import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; -import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; -import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection; -import org.jclouds.vcloud.domain.ovf.VirtualSystem; -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.Injector; - -/** - * Tests behavior of {@code VirtualSystemHandler} - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class VirtualSystemHandlerTest { - - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/virtualsystem.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)).parse(is); - checkVirtualSystem(result); - } - - static void checkVirtualSystem(VirtualSystem result) { - assertEquals(result.getId(), "Ubuntu1004"); - assertEquals(result.getName(), "Ubuntu1004"); - assertEquals(result.getInfo(), "A virtual machine:"); - checkHardware(Iterables.get(result.getHardware(), 0)); - checkOs(result.getOperatingSystem()); - } - - @Test(enabled = false) - public static void checkHardware(VirtualHardwareSection result) { - assertEquals(result.getSystem(), - new System(0, "Virtual Hardware Family", "Ubuntu1004", ImmutableSet.of("vmx-07"))); - assertEquals(result.getInfo(), "Virtual hardware requirements"); - - assertEquals(Iterables.get(result.getResourceAllocations(), 0), new VCloudNetworkAdapter(1, "Network adapter 0", - "PCNet32 ethernet adapter", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, "00:50:56:8c:00:13", 0, - null, false, 1, null, "192.168.2.100", true, "POOL")); - - assertEquals(Iterables.get(result.getResourceAllocations(), 1), new ResourceAllocation(2, "SCSI Controller 0", - "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null)); - - assertEquals(Iterables.get(result.getResourceAllocations(), 2), new VCloudHardDisk(2000, "Hard disk 1", - "Hard disk", ResourceType.DISK_DRIVE, null, null, null, 0, 2, null, 1, null, 30720, 6, "lsilogic")); - - assertEquals(Iterables.get(result.getResourceAllocations(), 3), new ResourceAllocation(3, "IDE Controller 0", - "IDE Controller", ResourceType.IDE_CONTROLLER, null, null, "0", null, null, null, 1, null)); - - assertEquals(Iterables.get(result.getResourceAllocations(), 4), new ResourceAllocation(3002, "CD/DVD Drive 1", - "CD/DVD Drive", ResourceType.CD_DRIVE, null, null, null, 0, 3, null, 1, null)); - - assertEquals(Iterables.get(result.getResourceAllocations(), 5), new ResourceAllocation(8000, "Floppy Drive 1", - "Floppy Drive", ResourceType.FLOPPY_DRIVE, null, null, null, 0, null, null, 1, null)); - - assertEquals(Iterables.get(result.getResourceAllocations(), 6), new ResourceAllocation(4, "1 virtual CPU(s)", - "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6")); - - assertEquals(Iterables.get(result.getResourceAllocations(), 7), new ResourceAllocation(5, "512 MB of memory", - "Memory Size", ResourceType.MEMORY, null, null, null, null, null, null, 512, "byte * 2^20")); - } - - @Test(enabled = false) - public static void checkOs(OperatingSystemSection result) { - assertEquals(result.getDescription(), "Ubuntu Linux (64-bit)"); - assertEquals(result.getId(), new Integer(94)); - assertEquals(result.getInfo(), "Specifies the operating system installed"); - } -} diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java index c19be44295..3290040827 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java @@ -40,12 +40,12 @@ import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; 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.domain.network.NetworkConfig; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; 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 3e973ccc8e..bb0eaf4731 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 @@ -20,30 +20,20 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; -import java.util.List; import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Inject; +import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; -import org.jclouds.compute.domain.Processor; -import org.jclouds.compute.domain.Volume; import org.jclouds.compute.predicates.ImagePredicates; -import org.jclouds.domain.Location; import org.jclouds.logging.Logger; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; import com.google.common.base.Function; -import com.google.common.collect.Lists; /** * @author Adrian Cole @@ -54,36 +44,24 @@ public class HardwareForVCloudExpressVApp implements Function processors = Lists.newArrayList(transform( - filter(from.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)), - new Function() { - - @Override - public Processor apply(ResourceAllocation arg0) { - return new Processor(arg0.getVirtualQuantity(), 1); - } - - })); - List volumes = Lists.newArrayList(resourceAllocationsToVolumes.apply(from.getResourceAllocations())); - return new HardwareBuilder().ids(from.getHref().toASCIIString()).name(from.getName()).location(location) - .processors(processors).ram(ram).volumes(volumes) - .supportsImage(ImagePredicates.idEquals(from.getHref().toASCIIString())).build(); + HardwareBuilder builder = rasdToHardwareBuilder.apply(from.getResourceAllocations()); + builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC())); + builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage( + ImagePredicates.idEquals(from.getHref().toASCIIString())); + return builder.build(); } catch (NoSuchElementException e) { logger.debug("incomplete data to form vApp %s", from.getHref()); return null; diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java deleted file mode 100644 index 55198ab74a..0000000000 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/ResourceAllocationsToVolumes.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.compute.functions; - -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; - -import javax.inject.Singleton; - -import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.internal.VolumeImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; - -import com.google.common.base.Function; - -/** - * @author Adrian Cole - */ -@Singleton -public class ResourceAllocationsToVolumes implements Function, Iterable> { - @Override - public Iterable apply(Iterable resourceAllocations) { - Iterable volumes = transform(filter(resourceAllocations, resourceType(ResourceType.DISK_DRIVE)), - new Function() { - - @Override - public Volume apply(ResourceAllocation from) { - return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, - from.getVirtualQuantity() / 1024 / 1024f, null, from.getAddressOnParent() == 0, true); - - } - - }); - return volumes; - } -} \ No newline at end of file diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java index d23ecc3cf4..fcab9a97f8 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/compute/functions/VCloudExpressVAppToNodeMetadata.java @@ -29,11 +29,11 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.collect.Memoized; +import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.domain.os.CIMOperatingSystem; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.compute.VCloudExpressComputeClient; import org.jclouds.vcloud.domain.Status; diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java index a37092b4de..86c9c21756 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java @@ -23,9 +23,9 @@ import java.util.Set; import javax.annotation.Nullable; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.System; import com.google.common.collect.ListMultimap; import com.google.inject.ImplementedBy; @@ -62,8 +62,8 @@ public interface VCloudExpressVApp extends ReferenceType { @Nullable String getOperatingSystemDescription(); - System getSystem(); + VirtualSystemSettingData getSystem(); - Set getResourceAllocations(); + Set getResourceAllocations(); } \ No newline at end of file diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java index c3418c7af5..cd115cf65a 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java @@ -24,12 +24,12 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.System; import com.google.common.collect.ListMultimap; @@ -46,8 +46,8 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { private final Long size; private final ListMultimap networkToAddresses; private final String operatingSystemDescription; - private final System system; - private final Set resourceAllocations; + private final VirtualSystemSettingData system; + private final Set resourceAllocations; private final Integer osType; /** The serialVersionUID */ @@ -55,7 +55,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC, ListMultimap networkToAddresses, Integer osType, String operatingSystemDescription, - System system, Set resourceAllocations) { + VirtualSystemSettingData system, Set resourceAllocations) { this.name = checkNotNull(name, "name"); this.href = checkNotNull(href, "href"); this.status = checkNotNull(status, "status"); @@ -89,12 +89,12 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { } @Override - public System getSystem() { + public VirtualSystemSettingData getSystem() { return system; } @Override - public Set getResourceAllocations() { + public Set getResourceAllocations() { return resourceAllocations; } diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressNetworkHandler.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressNetworkHandler.java index 6515a97d54..2dc0896a62 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressNetworkHandler.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressNetworkHandler.java @@ -19,7 +19,8 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; @@ -88,21 +89,21 @@ public class VCloudExpressNetworkHandler extends ParseSax.HandlerWithResult { private final String apiVersion; - private final SystemHandler systemHandler; - private final ResourceAllocationHandler allocationHandler; + private final VirtualSystemSettingDataHandler systemHandler; + private final ResourceAllocationSettingDataHandler allocationHandler; @Resource protected Logger logger = Logger.NULL; @Inject - public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler, - ResourceAllocationHandler allocationHandler) { + public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, + VirtualSystemSettingDataHandler systemHandler, ResourceAllocationSettingDataHandler allocationHandler) { this.apiVersion = apiVersion; this.systemHandler = systemHandler; this.allocationHandler = allocationHandler; } - protected System system; - protected Set allocations = Sets.newLinkedHashSet(); + protected VirtualSystemSettingData system; + protected Set allocations = Sets.newLinkedHashSet(); protected Status status; protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); protected StringBuilder currentText = new StringBuilder(); @@ -87,7 +87,7 @@ public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("VApp")) { ReferenceType resource = newReferenceType(attributes); name = resource.getName(); diff --git a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppTemplateHandler.java b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppTemplateHandler.java index ab5b30614f..7fdc92ec1b 100644 --- a/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppTemplateHandler.java +++ b/apis/vcloudexpress/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppTemplateHandler.java @@ -19,7 +19,8 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; @@ -58,7 +59,7 @@ public class VCloudExpressVAppTemplateHandler extends ParseSax.HandlerWithResult public void endElement(String uri, String name, String qName) { if (qName.equals("Description")) { - description = currentOrNull(); + description = currentOrNull(currentText); } currentText = new StringBuilder(); } @@ -66,9 +67,4 @@ public class VCloudExpressVAppTemplateHandler extends ParseSax.HandlerWithResult 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/xml/ovf/VCloudExpressVAppHandlerTest.java b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudExpressVAppHandlerTest.java index f842c22196..635d46cc75 100644 --- a/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudExpressVAppHandlerTest.java +++ b/apis/vcloudexpress/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudExpressVAppHandlerTest.java @@ -28,6 +28,9 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; @@ -35,9 +38,6 @@ import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.System; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -81,7 +81,8 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI .create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, 123456789l, new ReferenceTypeImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")), - ImmutableListMultimap. of(), null, null, null, ImmutableSet. of()); + ImmutableListMultimap. of(), null, null, null, ImmutableSet + . of()); assertEquals(result, expects); } @@ -92,17 +93,31 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", "10.150.4.93"); - System system = new System(0, "Virtual Hardware Family", "centos53", ImmutableSet.of("vmx-07")); - Set resourceAllocations = ImmutableSet. of(new ResourceAllocation(1, - "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, - null, 1, "hertz * 10^6"), new ResourceAllocation(2, "16MB of memory", "Memory Size", - ResourceType.MEMORY, null, null, null, null, null, null, 16, "byte * 2^20"), new ResourceAllocation(3, - "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, - null, 1, null), new ResourceAllocation(8, "Network Adapter 1", - "PCNet32 ethernet adapter on \"Internal\" network", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, - null, 7, null, true, 1, null), new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, - null, "104857", null, 0, 3, null, 104857, "byte * 2^20")); + VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("centos53").virtualSystemType("vmx-07").build(); + + Set resourceAllocations = ImmutableSet. of( + ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description( + "Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l) + .allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(), + + ResourceAllocationSettingData.builder().instanceID("2").elementName("16MB of memory").description( + "Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(16l).allocationUnits( + "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), + + ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description( + "SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic") + .address("0").build(), + + ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description( + "PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER) + .resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation( + true).build(), + + ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType( + ResourceType.DISK_DRIVE).hostResource("104857").addressOnParent("0").parent("3") + .virtualQuantity(104857l).build()); VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI .create("http://10.150.4.49/api/v0.8/vApp/10"), Status.ON, new Long(104857), new ReferenceTypeImpl(null, @@ -112,10 +127,10 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { assertEquals(result.getName(), expects.getName()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription()); - assertEquals(result.getResourceAllocations(), expects.getResourceAllocations()); + assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString()); assertEquals(result.getSize(), expects.getSize()); assertEquals(result.getStatus(), expects.getStatus()); - assertEquals(result.getSystem(), expects.getSystem()); + assertEquals(result.getSystem().toString(), expects.getSystem().toString()); assertEquals(result.getType(), expects.getType()); assertEquals(result.getVDC(), expects.getVDC()); } @@ -127,17 +142,30 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", "10.23.119.221"); - System system = new System(0, "Virtual Hardware Family", "m1", ImmutableSet.of("vmx-07")); + VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("m1").virtualSystemType("vmx-07").build(); - Set resourceAllocations = ImmutableSet. of(new ResourceAllocation(1, - "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, - null, 1, "hertz * 10^6"), new ResourceAllocation(2, "512MB of memory", "Memory Size", - ResourceType.MEMORY, null, null, null, null, null, null, 512, "byte * 2^20"), new ResourceAllocation(3, - "SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, - null, 1, null), new ResourceAllocation(8, "Network Adapter 1", - "PCNet32 ethernet adapter on \"Internal\" network", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, - null, 7, null, true, 1, null), new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, - null, "10485760", null, 0, 3, null, 10485760, "byte * 2^20")); + Set resourceAllocations = ImmutableSet. of( + ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description( + "Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l) + .allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(), + + ResourceAllocationSettingData.builder().instanceID("2").elementName("512MB of memory").description( + "Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l).allocationUnits( + "byte * 2^20").virtualQuantityUnits("byte * 2^20").build(), + + ResourceAllocationSettingData.builder().instanceID("3").elementName("SCSI Controller 0").description( + "SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic") + .address("0").build(), + + ResourceAllocationSettingData.builder().instanceID("8").elementName("Network Adapter 1").description( + "PCNet32 ethernet adapter on \"Internal\" network").resourceType(ResourceType.ETHERNET_ADAPTER) + .resourceSubType("PCNet32").addressOnParent("7").connection("Internal").automaticAllocation( + true).build(), + + ResourceAllocationSettingData.builder().instanceID("9").elementName("Hard Disk 1").resourceType( + ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0").parent("3") + .virtualQuantity(10485760l).build()); VCloudExpressVApp expects = new VCloudExpressVAppImpl("m1", URI.create("http://localhost:8000/api/v0.8/vApp/80"), Status.ON, new Long(10485760), new ReferenceTypeImpl(null, "application/vnd.vmware.vcloud.vdc+xml", URI @@ -147,10 +175,10 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { assertEquals(result.getName(), expects.getName()); assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses()); assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription()); - assertEquals(result.getResourceAllocations(), expects.getResourceAllocations()); + assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString()); assertEquals(result.getSize(), expects.getSize()); assertEquals(result.getStatus(), expects.getStatus()); - assertEquals(result.getSystem(), expects.getSystem()); + assertEquals(result.getSystem().toString(), expects.getSystem().toString()); assertEquals(result.getType(), expects.getType()); assertEquals(result.getVDC(), expects.getVDC()); } 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 5364e10f86..ac3f48df53 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 @@ -25,7 +25,6 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; @@ -39,14 +38,15 @@ import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; +import org.jclouds.cim.CIMPredicates; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; 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.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import com.google.common.base.Function; @@ -101,8 +101,8 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function R bindToRequest(R request, Object input) { throw new IllegalStateException("BindVAppConfigurationToXmlPayload needs parameters"); diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java index 8e6dd54ca3..34a8e8b08c 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java @@ -26,18 +26,18 @@ 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.SortedMap; +import java.util.Map.Entry; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.endpoints.Network; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions; diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkCatalogItemHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkCatalogItemHandler.java index 48c278828b..8f4fb169ae 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkCatalogItemHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkCatalogItemHandler.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud.terremark.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java index c479cb9dee..db4562bbdf 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkOrgHandler.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud.terremark.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVCloudExpressNetworkHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVCloudExpressNetworkHandler.java index 1bce0bef27..8bd6654747 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVCloudExpressNetworkHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVCloudExpressNetworkHandler.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud.terremark.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; diff --git a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandler.java b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandler.java index 85f05ce5a4..13129649ef 100644 --- a/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandler.java +++ b/common/trmk/src/main/java/org/jclouds/vcloud/terremark/xml/TerremarkVDCHandler.java @@ -19,7 +19,7 @@ package org.jclouds.vcloud.terremark.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; import java.util.Map; diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index a08e019741..e5ccbaae6b 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -24,7 +24,6 @@ import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.size; import static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.changeNameTo; import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent; import static org.testng.Assert.assertEquals; @@ -33,22 +32,25 @@ import static org.testng.Assert.assertNotNull; import java.io.IOException; import java.net.URI; import java.util.List; -import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; +import org.jclouds.cim.CIMPredicates; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.RestContextFactory; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshException; +import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.VCloudExpressClientLiveTest; import org.jclouds.vcloud.VCloudExpressMediaType; @@ -59,8 +61,6 @@ import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.predicates.TaskSuccess; import org.jclouds.vcloud.terremark.domain.CustomizationParameters; @@ -102,7 +102,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes @Test public void testGetAllInternetServices() throws Exception { for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.findVDCInOrgNamed(null, null) - .getHref())) { + .getHref())) { assertNotNull(tmClient.getNodes(service.getId())); } } @@ -114,14 +114,14 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes PublicIpAddress publicIp = publicIpAddresses.iterator().next(); InternetService service = tmClient.addInternetServiceToExistingIp(publicIp.getId(), PREFIX + "-no-monitoring", - Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled()); + Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled()); tmClient.deleteInternetService(service.getId()); } @Test public void testGetPublicIpsAssociatedWithVDC() throws Exception { for (PublicIpAddress ip : tmClient - .getPublicIpsAssociatedWithVDC(tmClient.findVDCInOrgNamed(null, null).getHref())) { + .getPublicIpsAssociatedWithVDC(tmClient.findVDCInOrgNamed(null, null).getHref())) { assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId())); assertNotNull(tmClient.getPublicIp(ip.getId())); } @@ -150,7 +150,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes @Test(enabled = true) public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException, - IOException { + IOException { prepare(); StringBuffer name = new StringBuffer(); for (int i = 0; i < 15; i++) @@ -176,7 +176,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // if this template supports setting the root password, let's add it to // our options CustomizationParameters customizationOptions = tmClient.getCustomizationOptions(item.getCustomizationOptions() - .getHref()); + .getHref()); if (customizationOptions.canCustomizePassword()) instantiateOptions.withPassword("robotsarefun"); @@ -186,7 +186,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes // instantiate, noting vApp returned has minimal details vApp = tmClient.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName, - instantiateOptions); + instantiateOptions); assertEquals(vApp.getStatus(), Status.RESOLVED); @@ -278,7 +278,7 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes @Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" }) public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException { node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName() - + "-SSH", 22); + + "-SSH", 22); loopAndCheckPass(); } @@ -341,15 +341,18 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes vApp = tmClient.getVApp(vApp.getHref()); Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1) - .addDisk(25 * 1048576).addDisk(25 * 1048576)); + .addDisk(25 * 1048576).addDisk(25 * 1048576)); assert successTester.apply(task.getHref()); vApp = tmClient.getVApp(vApp.getHref()); assertEquals(vApp.getName(), "eduardo"); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1536); - assertEquals(size(filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))), 3); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) + .getVirtualQuantity().longValue(), 1); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) + .getVirtualQuantity().longValue(), 1536); + assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))), + 3); assert successTester.apply(tmClient.powerOnVApp(vApp.getHref()).getHref()); @@ -358,11 +361,12 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes assert successTester.apply(tmClient.powerOffVApp(vApp.getHref()).getHref()); // extract the disks on the vApp sorted by addressOnParent - List disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), - resourceType(ResourceType.DISK_DRIVE))); + List disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), + CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))); // delete the second disk - task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1).getAddressOnParent())); + task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1) + .getAddressOnParent()))); assert successTester.apply(task.getHref()); @@ -371,18 +375,19 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes } private void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs, - int processorCount, long memory, long hardDisk) { + int processorCount, long memory, long hardDisk) { assertEquals(vApp.getName(), serverName); assertEquals(vApp.getOperatingSystemDescription(), expectedOs); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), - processorCount); - assertEquals( - find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(), - hardDisk); - assertEquals(vApp.getSize().longValue(), - find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); + assertEquals((int) find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) + .getVirtualQuantity().longValue(), processorCount); + assertEquals((int) find(vApp.getResourceAllocations(), + CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA)).getVirtualQuantity().longValue(), 1); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) + .getVirtualQuantity().longValue(), memory); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)) + .getVirtualQuantity().longValue(), hardDisk); + assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(), + CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue()); } private void doCheckPass(String address) throws IOException { @@ -465,7 +470,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes Properties overrides = setupProperties(); Injector injector = new RestContextFactory().createContextBuilder(provider, - ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector(); + ImmutableSet. of(new Log4JLoggingModule(), new JschSshClientModule()), overrides) + .buildInjector(); connection = tmClient = injector.getInstance(TerremarkVCloudClient.class); diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java index db7e3e7ae8..8c62bb0c57 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java @@ -30,12 +30,12 @@ import java.net.URI; import java.util.Map; import java.util.Properties; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.testng.annotations.Test; @@ -61,22 +61,25 @@ public class BindVAppConfigurationToXmlPayloadTest { @Override protected void configure() { Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names + .bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), + "properties")); } }); public void testChangeName() 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(new ResourceAllocation(1, - "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), - new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, - null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, - 0, null, null, 209152, null))); + 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( + 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())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")) - .replace("eduardo", "roberto"); + .replace("eduardo", "roberto"); VAppConfiguration config = new VAppConfiguration().changeNameTo("roberto"); @@ -94,17 +97,18 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testRemoveDisk() 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(new ResourceAllocation(1, - "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), - new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, - null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, - 0, null, null, 209152, null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, - null, "1048576", null, 1, null, null, 209152, null))); + 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( + 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())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml")) - .replace("eduardo", "MyAppServer6"); + .replace("eduardo", "MyAppServer6"); VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1); @@ -122,13 +126,15 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testChangeCPUCountTo4() throws IOException { - VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("eduardo", - URI.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, - ImmutableListMultimap. of(), null, null, null, ImmutableSet.of(new ResourceAllocation(1, - "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 4, null), - new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024, - null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, - 0, null, null, 209152, null))); + VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("eduardo", URI + .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null, + ImmutableListMultimap. of(), null, null, null, ImmutableSet.of( + ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( + ResourceType.PROCESSOR).virtualQuantity(4l).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())); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp4.xml")); VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4); @@ -147,16 +153,18 @@ public class BindVAppConfigurationToXmlPayloadTest { } public void testChangeMemoryTo1536() 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(new ResourceAllocation(1, - "n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null), - new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1536, - null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null, - 0, null, null, 209152, null))); + 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( + ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType( + ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData + .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY) + .virtualQuantity(1536l).build(), ResourceAllocationSettingData.builder().instanceID( + "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").replace("1024", "1536"); + .replace("eduardo", "MyAppServer6").replace("1024", "1536"); VAppConfiguration config = new VAppConfiguration().changeMemoryTo(1536); diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java index 4948848f9e..33cfd4e201 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java @@ -23,10 +23,10 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -48,15 +48,13 @@ public class ResourceAllocationHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/terremark/item.xml"); - ResourceAllocation result = (ResourceAllocation) factory.create( - injector.getInstance(ResourceAllocationHandler.class)).parse(is); + ResourceAllocationSettingData result = factory.create( + injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); assertEquals(result.getAddress(), "0"); assertEquals(result.getDescription(), "SCSI Controller"); - assertEquals(result.getName(), "SCSI Controller 0"); - assertEquals(result.getId(), 3); - assertEquals(result.getSubType(), "lsilogic"); - assertEquals(result.getType(), ResourceType.SCSI_CONTROLLER); - assertEquals(result.getVirtualQuantity(), 1); - + assertEquals(result.getElementName(), "SCSI Controller 0"); + assertEquals(result.getInstanceID(), "3"); + assertEquals(result.getResourceSubType(), "lsilogic"); + assertEquals(result.getResourceType(), ResourceType.PARALLEL_SCSI_HBA); } } diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java index 933f13bd1d..2a43a4ff7a 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java @@ -19,9 +19,7 @@ package org.jclouds.vcloud.terremark.xml; -import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType; import static org.testng.Assert.assertEquals; import java.io.InputStream; @@ -31,6 +29,10 @@ import java.util.List; import java.util.Properties; import org.jclouds.Constants; +import org.jclouds.cim.CIMPredicates; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; @@ -38,15 +40,13 @@ import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.domain.ovf.System; import org.jclouds.vcloud.xml.VCloudExpressVAppHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.inject.AbstractModule; import com.google.inject.Guice; @@ -110,27 +110,35 @@ public class VAppHandlerTest extends BaseHandlerTest { assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); - assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "centos-53", ImmutableSet.of("vmx-07"))); + VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("centos-53").virtualSystemType("vmx-07").build(); + assertEquals(result.getSystem().toString(), system.toString()); assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList. of("10.114.34.132")); - ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", - ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6"); + ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName( + "1 virtual CPU(s)").description("Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR) + .virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build(); - ResourceAllocation controller = new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", - ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null); - ResourceAllocation memory = new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY, - null, null, null, null, null, null, 512, "byte * 2^20"); - ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, - "10485760", null, 0, 3, null, 10485760, "byte * 2^20"); + ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName( + "SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA) + .resourceSubType("lsilogic").address("0").virtualQuantity(1l).build(); + ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName( + "512MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l) + .virtualQuantityUnits("byte * 2^20").build(); + ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName( + "Hard Disk 1").resourceType(ResourceType.DISK_DRIVE).hostResource("10485760").addressOnParent("0") + .virtualQuantity(10485760l).virtualQuantityUnits("byte * 2^20").build(); assertEquals(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk)); - assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1); - assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)) - .getVirtualQuantity(), 1); - assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 512); - assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(), - 10485760); + assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) + .getVirtualQuantity().intValue(), 1); + find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA)); + + assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) + .getVirtualQuantity().intValue(), 512); + assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)) + .getVirtualQuantity().longValue(), 10485760); assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(), - resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity()); + CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue()); } public void testGetVApp2disks() throws UnknownHostException { @@ -147,34 +155,42 @@ public class VAppHandlerTest extends BaseHandlerTest { assertEquals(vApp.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15639")); assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); + VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("eduardo").virtualSystemType("vmx-07").build(); + assertEquals(vApp.getSystem().toString(), system.toString()); - assertEquals(vApp.getSystem(), new System(0, "Virtual Hardware Family", "eduardo", ImmutableSet.of("vmx-07"))); assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131")); - ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs", - ResourceType.PROCESSOR, null, null, null, null, null, null, 2, "hertz * 10^6"); + ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName( + "2 virtual CPU(s)").description("Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR) + .virtualQuantity(2l).virtualQuantityUnits("hertz * 10^6").build(); - ResourceAllocation controller = new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller", - ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null); - ResourceAllocation memory = new ResourceAllocation(2, "1024MB of memory", "Memory Size", ResourceType.MEMORY, - null, null, null, null, null, null, 1024, "byte * 2^20"); - ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, - "4194304", null, 0, 3, null, 4194304, "byte * 2^20"); - ResourceAllocation disk2 = new ResourceAllocation(9, "Hard Disk 2", null, ResourceType.DISK_DRIVE, null, - "26214400", null, 1, 3, null, 26214400, "byte * 2^20"); + ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName( + "SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA) + .resourceSubType("lsilogic").address("0").virtualQuantity(1l).build(); + ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName( + "1024MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(1024l) + .virtualQuantityUnits("byte * 2^20").build(); + ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName( + "Hard Disk 1").resourceType(ResourceType.DISK_DRIVE).hostResource("4194304").addressOnParent("0") + .virtualQuantity(4194304l).virtualQuantityUnits("byte * 2^20").build(); + ResourceAllocationSettingData disk2 = ResourceAllocationSettingData.builder().instanceID("9").elementName( + "Hard Disk 2").resourceType(ResourceType.DISK_DRIVE).hostResource("26214400").addressOnParent("1") + .virtualQuantity(26214400l).virtualQuantityUnits("byte * 2^20").build(); assertEquals(vApp.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk, disk2)); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 2); - assertEquals( - find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1); - assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1024); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)) + .getVirtualQuantity().intValue(), 2); + find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA)); + assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY)) + .getVirtualQuantity().longValue(), 1024); // extract the disks on the vApp sorted by addressOnParent - List disks = Lists.newArrayList(filter(vApp.getResourceAllocations(), - resourceType(ResourceType.DISK_DRIVE))); + List disks = Lists.newArrayList(Iterables.filter(vApp.getResourceAllocations(), + CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))); - assertEquals(disks.get(0).getVirtualQuantity(), 4194304); - assertEquals(disks.get(1).getVirtualQuantity(), 26214400); + assertEquals(disks.get(0).getVirtualQuantity().longValue(), 4194304); + assertEquals(disks.get(1).getVirtualQuantity().longValue(), 26214400); } diff --git a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ovf/SystemHandlerTest.java b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ovf/SystemHandlerTest.java index 69b1f6dbe4..5bd70c82ad 100644 --- a/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ovf/SystemHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/vcloud/terremark/xml/ovf/SystemHandlerTest.java @@ -23,8 +23,9 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.xml.VirtualSystemSettingDataHandler; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.xml.ovf.SystemHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -48,10 +49,11 @@ public class SystemHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/terremark/system.xml"); - org.jclouds.vcloud.domain.ovf.System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is); - assertEquals(result.getName(), "Virtual Hardware Family"); - assertEquals(result.getId(), 0); - assertEquals(result.getIdentifier(), "adriantest1"); + VirtualSystemSettingData result = factory.create(injector.getInstance(VirtualSystemSettingDataHandler.class)) + .parse(is); + assertEquals(result.getElementName(), "Virtual Hardware Family"); + assertEquals(result.getInstanceID(), "0"); + assertEquals(result.getVirtualSystemIdentifier(), "adriantest1"); assertEquals(result.getVirtualSystemTypes(), ImmutableSet.of("vmx-07")); } } diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java deleted file mode 100644 index da760e799d..0000000000 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.domain.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author Adrian Cole - * - */ -public class ResourceAllocation { - - private final int id; - private final String name; - private final String description; - private final ResourceType type; - private final String subType; - private final String hostResource; - private final String address; - private final Integer addressOnParent; - private final Integer parent; - private final Boolean connected; - private final long virtualQuantity; - private final String virtualQuantityUnits; - - public ResourceAllocation(int id, String name, String description, ResourceType type, String subType, - String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected, - long virtualQuantity, String virtualQuantityUnits) { - this.id = id; - this.name = checkNotNull(name, "name"); - this.description = description; - this.type = checkNotNull(type, "type"); - this.subType = subType; - this.hostResource = hostResource; - this.address = address; - this.addressOnParent = addressOnParent; - this.parent = parent; - this.connected = connected; - this.virtualQuantity = virtualQuantity; - this.virtualQuantityUnits = virtualQuantityUnits; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public ResourceType getType() { - return type; - } - - public String getSubType() { - return subType; - } - - public String getAddress() { - return address; - } - - public Integer getAddressOnParent() { - return addressOnParent; - } - - public Integer getParent() { - return parent; - } - - public Boolean getConnected() { - return connected; - } - - public long getVirtualQuantity() { - return virtualQuantity; - } - - public String getVirtualQuantityUnits() { - return virtualQuantityUnits; - } - - public String getHostResource() { - return hostResource; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((address == null) ? 0 : address.hashCode()); - result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode()); - result = prime * result + ((connected == null) ? 0 : connected.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((hostResource == null) ? 0 : hostResource.hashCode()); - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((parent == null) ? 0 : parent.hashCode()); - result = prime * result + ((subType == null) ? 0 : subType.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32)); - result = prime * result + ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits.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; - ResourceAllocation other = (ResourceAllocation) obj; - if (address == null) { - if (other.address != null) - return false; - } else if (!address.equals(other.address)) - return false; - if (addressOnParent == null) { - if (other.addressOnParent != null) - return false; - } else if (!addressOnParent.equals(other.addressOnParent)) - return false; - if (connected == null) { - if (other.connected != null) - return false; - } else if (!connected.equals(other.connected)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (hostResource == null) { - if (other.hostResource != null) - return false; - } else if (!hostResource.equals(other.hostResource)) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (parent == null) { - if (other.parent != null) - return false; - } else if (!parent.equals(other.parent)) - return false; - if (subType == null) { - if (other.subType != null) - return false; - } else if (!subType.equals(other.subType)) - return false; - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - if (virtualQuantity != other.virtualQuantity) - return false; - if (virtualQuantityUnits == null) { - if (other.virtualQuantityUnits != null) - return false; - } else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits)) - return false; - return true; - } - - @Override - public String toString() { - return "[address=" + address + ", addressOnParent=" + addressOnParent + ", connected=" + connected - + ", description=" + description + ", hostResource=" + hostResource + ", id=" + id + ", name=" + name - + ", parent=" + parent + ", subType=" + subType + ", type=" + type + ", virtualQuantity=" - + virtualQuantity + ", virtualQuantityUnits=" + virtualQuantityUnits + "]"; - } - -} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java deleted file mode 100644 index 8fb4134482..0000000000 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.domain.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * - * VirtualResource such as disks or CPU - * - * @author Adrian Cole - * @see - * - */ -public enum ResourceType { - OTHER, PROCESSOR, MEMORY, IDE_CONTROLLER, SCSI_CONTROLLER, ETHERNET_ADAPTER, FLOPPY_DRIVE, CD_DRIVE, DVD_DRIVE, DISK_DRIVE, USB_CONTROLLER, UNRECOGNIZED; - - public String value() { - switch (this) { - case OTHER: - return "1"; - case PROCESSOR: - return "3"; - case MEMORY: - return "4"; - case IDE_CONTROLLER: - return "5"; - case SCSI_CONTROLLER: - return "6"; - case ETHERNET_ADAPTER: - return "10"; - case FLOPPY_DRIVE: - return "14"; - case CD_DRIVE: - return "15"; - case DVD_DRIVE: - return "16"; - case DISK_DRIVE: - return "17"; - case USB_CONTROLLER: - return "23"; - default: - throw new IllegalArgumentException("invalid type:" + this); - } - } - - public static ResourceType fromValue(String type) { - try { - return fromValue(Integer.parseInt(checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - public static ResourceType fromValue(int v) { - switch (v) { - case 1: - return OTHER; - case 3: - return PROCESSOR; - case 4: - return MEMORY; - case 5: - return IDE_CONTROLLER; - case 6: - return SCSI_CONTROLLER; - case 10: - return ETHERNET_ADAPTER; - case 14: - return FLOPPY_DRIVE; - case 15: - return CD_DRIVE; - case 16: - return DVD_DRIVE; - case 17: - return DISK_DRIVE; - case 23: - return USB_CONTROLLER; - default: - return UNRECOGNIZED; - } - } -} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/System.java b/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/System.java deleted file mode 100644 index 28229ec5bc..0000000000 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/System.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.domain.ovf; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - -public class System { - protected final int id; - protected final String name; - protected final String identifier; - protected final Set virtualSystemTypes = Sets.newLinkedHashSet(); - - public System(int id, String name, String identifier, Iterable virtualSystemTypes) { - this.id = id; - this.name = checkNotNull(name, "name"); - this.identifier = checkNotNull(identifier, "identifier"); - Iterables.addAll(this.virtualSystemTypes, checkNotNull(virtualSystemTypes, "virtualSystemTypes")); - - } - - public String getName() { - return name; - } - - public int getId() { - return id; - } - - public String getIdentifier() { - return identifier; - } - - /** - * specifies a virtual system virtualSystemTypes identifier, which is an implementation defined string that - * uniquely identifies the virtualSystemTypes of the virtual system. - * - *

- * For example, a virtual system virtualSystemTypes identifier could be vmx-4 for VMware’s fourth-generation - * virtual hardware or xen-3 for Xen’s third-generation virtual hardware. - * - */ - public Set getVirtualSystemTypes() { - return virtualSystemTypes; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((virtualSystemTypes == null) ? 0 : virtualSystemTypes.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; - System other = (System) obj; - if (id != other.id) - return false; - if (identifier == null) { - if (other.identifier != null) - return false; - } else if (!identifier.equals(other.identifier)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (virtualSystemTypes == null) { - if (other.virtualSystemTypes != null) - return false; - } else if (!virtualSystemTypes.equals(other.virtualSystemTypes)) - return false; - return true; - } - - @Override - public String toString() { - return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name + ", virtualSystemTypes=" - + virtualSystemTypes + "]"; - } - -} \ No newline at end of file diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java b/common/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java index ef34edbd73..5ce8fea408 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/util/Utils.java @@ -22,14 +22,11 @@ package org.jclouds.vcloud.util; import java.net.URI; import java.util.Map; -import org.jclouds.vcloud.domain.VCloudError; import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VCloudError; import org.jclouds.vcloud.domain.VCloudError.MinorCode; import org.jclouds.vcloud.domain.internal.ErrorImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.xml.sax.Attributes; - -import com.google.common.collect.Maps; /** * @@ -45,17 +42,6 @@ public class Utils { return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href); } - public static Map cleanseAttributes(Attributes in) { - Map attrs = Maps.newLinkedHashMap(); - for (int i = 0; i < in.getLength(); i++) { - String name = in.getQName(i); - if (name.indexOf(':') != -1) - name = name.substring(name.indexOf(':') + 1); - attrs.put(name, in.getValue(i)); - } - return attrs; - } - public static ReferenceType newReferenceType(Map attributes) { return newReferenceType(attributes, null); } 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 74541aeb9d..ec19da2609 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 @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import static org.jclouds.vcloud.util.Utils.putReferenceType; @@ -29,6 +28,7 @@ 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; @@ -69,7 +69,7 @@ public class CatalogHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("Catalog")) { catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML); } else if (qName.equals("CatalogItem")) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java index 4b077a8127..c9c4c4032c 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java @@ -19,13 +19,13 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.Map; import java.util.SortedMap; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.CatalogItem; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.internal.CatalogItemImpl; @@ -53,7 +53,7 @@ public class CatalogItemHandler extends ParseSax.HandlerWithResult @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("CatalogItem")) { catalogItem = newReferenceType(attributes); } else if (qName.equals("Entity")) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java index 0250ff4c90..4110a65cd8 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java @@ -19,11 +19,10 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; - import java.util.Map; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.VCloudError; import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; @@ -41,7 +40,7 @@ public class ErrorHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("Error")) { error = Utils.newError(attributes); } diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java index fd05d24156..80c6bbcab7 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import static org.jclouds.vcloud.util.Utils.putReferenceType; @@ -29,6 +28,7 @@ import java.util.Map; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; @@ -70,7 +70,7 @@ public class OrgHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Org")) { org = newReferenceType(attributes); } else if (qName.endsWith("Link")) { 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 index 855785f9ef..20c9e4deae 100755 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java @@ -19,12 +19,12 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.putReferenceType; import java.util.Map; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -44,7 +44,7 @@ public class OrgListHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Org")) { String type = attributes.get("type"); if (type != null) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java index 5cb0211afa..a46e8a62b8 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import java.util.List; @@ -29,6 +28,7 @@ import java.util.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.network.DhcpService; @@ -144,7 +144,7 @@ public class OrgNetworkHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("OrgNetwork")) { network = newReferenceType(attributes); } else if (qName.equals("FirewallRule")) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java index 602274b4a3..07f37f8539 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java @@ -19,8 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; - import java.text.ParseException; import java.util.Date; import java.util.Map; @@ -31,6 +29,7 @@ import javax.inject.Inject; import org.jclouds.date.DateService; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.Logger; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; @@ -70,7 +69,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equalsIgnoreCase("Task")) { if (attributes.get("href") != null && !inOwner)// queued tasks may not have an // href yet diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java index 3868fce28e..ca378a8ad0 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java @@ -19,14 +19,13 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; - import java.util.Map; import java.util.SortedSet; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TasksList; @@ -57,7 +56,7 @@ public class TasksListHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.equals("TasksList")) { resource = Utils.newReferenceType(attributes); } else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) { diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java index 8343314f9a..0e54013460 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; import static org.jclouds.vcloud.util.Utils.newReferenceType; import static org.jclouds.vcloud.util.Utils.putReferenceType; @@ -29,6 +28,7 @@ import java.util.Map; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.ReferenceType; @@ -97,7 +97,7 @@ public class VDCHandler extends ParseSax.HandlerWithResult { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { - Map attributes = cleanseAttributes(attrs); + Map attributes = SaxUtils.cleanseAttributes(attrs); if (qName.endsWith("Vdc")) { vDC = newReferenceType(attributes); String status = attributes.get("status"); diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java deleted file mode 100644 index 82676ce484..0000000000 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.xml.ovf; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.util.Utils; -import org.xml.sax.Attributes; - -/** - * @author Adrian Cole - */ -public class ResourceAllocationHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - - protected String address; - protected Integer addressOnParent; - protected String hostResource; - protected String allocationUnits; - protected String automaticAllocation; - protected Boolean connected; - protected String description; - protected String elementName; - protected int instanceID; - protected Integer parent; - protected String resourceSubType; - protected ResourceType resourceType; - protected long virtualQuantity = 1; - protected String virtualQuantityUnits; - - public org.jclouds.vcloud.domain.ovf.ResourceAllocation getResult() { - if (allocationUnits != null) - virtualQuantityUnits = allocationUnits; - ResourceAllocation allocation = newResourceAllocation(); - address = null; - addressOnParent = null; - allocationUnits = null; - automaticAllocation = null; - connected = null; - description = null; - elementName = null; - instanceID = -1; - parent = null; - resourceSubType = null; - resourceType = null; - virtualQuantity = 1; - virtualQuantityUnits = null; - hostResource = null; - return allocation; - } - - protected ResourceAllocation newResourceAllocation() { - return new ResourceAllocation(instanceID, elementName, description, resourceType, resourceSubType, hostResource, - address, addressOnParent, parent, connected, virtualQuantity, virtualQuantityUnits); - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = Utils.cleanseAttributes(attrs); - if (qName.endsWith("Connection")) { - connected = new Boolean(attributes.get("connected")); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - String current = currentOrNull(); - if (current != null) { - if (qName.endsWith("Address")) { - address = current; - } else if (qName.endsWith("AddressOnParent")) { - addressOnParent = Integer.parseInt(current); - } else if (qName.endsWith("AllocationUnits")) { - allocationUnits = current; - } else if (qName.endsWith("Description")) { - description = current; - } else if (qName.endsWith("ElementName")) { - elementName = current; - } else if (qName.endsWith("InstanceID")) { - instanceID = Integer.parseInt(current); - } else if (qName.endsWith("Parent")) { - parent = Integer.parseInt(current); - } else if (qName.endsWith("ResourceSubType")) { - resourceSubType = current; - } else if (qName.endsWith("ResourceType")) { - resourceType = ResourceType.fromValue(current); - } else if (qName.endsWith("VirtualQuantity")) { - virtualQuantity = Long.parseLong(current); - } else if (qName.endsWith("VirtualQuantityUnits")) { - virtualQuantityUnits = current; - } else if (qName.endsWith("HostResource")) { - hostResource = currentText.toString().trim(); - virtualQuantity = Long.parseLong(current); - virtualQuantityUnits = "byte * 2^20"; - } - } - 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/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/SystemHandler.java b/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/SystemHandler.java deleted file mode 100644 index 42e2ba09a2..0000000000 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/SystemHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.xml.ovf; - -import java.util.Set; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ovf.System; -import org.xml.sax.Attributes; - -import com.google.common.collect.Sets; - -/** - * @author Adrian Cole - */ -public class SystemHandler extends ParseSax.HandlerWithResult { - private StringBuilder currentText = new StringBuilder(); - - private String elementName; - private int instanceID; - private String virtualSystemIdentifier; - private Set virtualSystemTypes = Sets.newLinkedHashSet(); - - public System getResult() { - System system = new org.jclouds.vcloud.domain.ovf.System(instanceID, elementName, virtualSystemIdentifier, - virtualSystemTypes); - this.elementName = null; - this.instanceID = -1; - this.virtualSystemIdentifier = null; - this.virtualSystemTypes = null; - return system; - } - - public void startElement(String uri, String localName, String qName, Attributes attributes) { - // no op - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("ElementName")) { - this.elementName = currentText.toString().trim(); - } else if (qName.endsWith("InstanceID")) { - this.instanceID = Integer.parseInt(currentText.toString().trim()); - } else if (qName.endsWith("VirtualSystemIdentifier")) { - this.virtualSystemIdentifier = currentText.toString().trim(); - } else if (qName.endsWith("VirtualSystemType")) { - this.virtualSystemTypes.add(currentText.toString().trim()); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } -} diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java deleted file mode 100644 index 41a563fce7..0000000000 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.xml.ovf; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; -import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code ResourceAllocationHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ResourceAllocationHandlerTest") -public class ResourceAllocationHandlerTest extends BaseHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/resourceallocation-hosting.xml"); - - ResourceAllocation result = factory.create( - injector.getInstance(ResourceAllocationHandler.class)).parse(is); - - ResourceAllocation expects = new ResourceAllocation(1, "1 virtual CPU(s)", - "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, - null, 1, "hertz * 10^6"); - assertEquals(result, expects); - - } -} diff --git a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java b/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java deleted file mode 100644 index faae8ccf0a..0000000000 --- a/common/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.jclouds.vcloud.xml.ovf; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.ovf.System; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code SystemHandler} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SystemHandlerTest") -public class SystemHandlerTest extends BaseHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml"); - - System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is); - - System expects = new System(0, "Virtual Hardware Family", "SimpleVM", ImmutableSet.of("vmx-04")); - assertEquals(result, expects); - - } -} diff --git a/common/vcloud/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java b/compute/src/main/java/org/jclouds/cim/CIMPredicates.java similarity index 64% rename from common/vcloud/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java rename to compute/src/main/java/org/jclouds/cim/CIMPredicates.java index d5030b01ef..1d3afdfc02 100644 --- a/common/vcloud/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java +++ b/compute/src/main/java/org/jclouds/cim/CIMPredicates.java @@ -17,20 +17,22 @@ * ==================================================================== */ -package org.jclouds.vcloud.predicates; +package org.jclouds.cim; import static com.google.common.base.Preconditions.checkNotNull; -import org.jclouds.vcloud.domain.ovf.ResourceAllocation; -import org.jclouds.vcloud.domain.ovf.ResourceType; +import java.util.Set; + +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableSet; /** * * @author Adrian Cole */ -public class VCloudPredicates { +public class CIMPredicates { /** * Return resource allocations of the specific type. @@ -39,17 +41,18 @@ public class VCloudPredicates { * type to match the items * @return predicate */ - public static Predicate resourceType(final ResourceType type) { - checkNotNull(type, "type"); - return new Predicate() { + public static Predicate resourceTypeIn(final ResourceType... types) { + checkNotNull(types, "resourceTypes"); + final Set resourceTypes = ImmutableSet.copyOf(types); + return new Predicate() { @Override - public boolean apply(ResourceAllocation in) { - return type.equals(in.getType()); + public boolean apply(ResourceAllocationSettingData in) { + return resourceTypes.contains(in.getResourceType()); } @Override public String toString() { - return "resourceAllocationType(" + type + ")"; + return "resourceTypeIn(" + resourceTypes + ")"; } }; } diff --git a/compute/src/main/java/org/jclouds/cim/ManagedElement.java b/compute/src/main/java/org/jclouds/cim/ManagedElement.java new file mode 100644 index 0000000000..f21c786338 --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/ManagedElement.java @@ -0,0 +1,114 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim; + +/** + * + * ManagedElement is an abstract class that provides a common superclass (or top of the inheritance + * tree) for the non-association classes in the CIM Schema. + * + * @author Adrian Cole + * @see + * + */ +public abstract class ManagedElement extends SettingData { + + public static class Builder extends SettingData.Builder { + protected String caption; + protected String description; + + /** + * @see ManagedSettingData#getCaption + */ + public Builder caption(String caption) { + this.caption = caption; + return this; + } + + /** + * @see ManagedSettingData#getDescription + */ + public Builder description(String description) { + this.description = description; + return this; + } + + public Builder fromManagedElement(ManagedElement in) { + return caption(in.getCaption()).description(in.getDescription()).fromSettingData(in); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromSettingData(SettingData in) { + return Builder.class.cast(super.fromSettingData(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + } + + protected final String caption; + protected final String description; + + public ManagedElement(String elementName, String instanceID, String caption, String description) { + super(elementName, instanceID); + this.caption = caption; + this.description = description; + } + + /** + * The Caption property is a short textual description (one- line string) of the object. + */ + public String getCaption() { + return caption; + } + + /** + * The Description property provides a textual description of the object. + */ + public String getDescription() { + return description; + } + + @Override + public String toString() { + return String.format("[elementName=%s, instanceID=%s, caption=%s, description=%s]", elementName, instanceID, + caption, description); + } + +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/cim/ResourceAllocationSettingData.java b/compute/src/main/java/org/jclouds/cim/ResourceAllocationSettingData.java new file mode 100644 index 0000000000..44b9c122de --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/ResourceAllocationSettingData.java @@ -0,0 +1,708 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.List; +import java.util.Map; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +/** + * + * The ResourceAllocationSettingData class represents settings specifically related to an allocated + * resource that are outside the scope of the CIM class typically used to represent the resource + * itself. These settings include information specific to the allocation that may not be visible to + * the consumer of the resource itself. For example, a virtual processor may look like a 2 ghz + * processor to the consumer (virtual computer system), however the virtualization system may use + * time-slicing to schedule the the virtual processor to only allow it to use 1 ghz. + * + * @author Adrian Cole + * @see + * + */ +public class ResourceAllocationSettingData extends ManagedElement { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends ManagedElement.Builder { + + protected String address; + protected String addressOnParent; + protected String allocationUnits; + protected Boolean automaticAllocation; + protected Boolean automaticDeallocation; + protected ConsumerVisibility consumerVisibility; + protected Long limit; + protected MappingBehavior mappingBehavior; + protected String otherResourceType; + protected String parent; + protected String poolID; + protected Long reservation; + protected String resourceSubType; + protected ResourceType resourceType; + protected Long virtualQuantity; + protected String virtualQuantityUnits; + protected Integer weight; + protected List connections = Lists.newArrayList(); + protected List hostResources = Lists.newArrayList(); + + /** + * @see ResourceAllocationSettingData#getAddress + */ + public Builder address(String address) { + this.address = address; + return this; + } + + /** + * @see ResourceAllocationSettingData#getAddressOnParent + */ + public Builder addressOnParent(String addressOnParent) { + this.addressOnParent = addressOnParent; + return this; + } + + /** + * @see ResourceAllocationSettingData#getAllocationUnits + */ + public Builder allocationUnits(String allocationUnits) { + this.allocationUnits = allocationUnits; + return this; + } + + /** + * @see ResourceAllocationSettingData#getAutomaticAllocation + */ + public Builder automaticAllocation(Boolean automaticAllocation) { + this.automaticAllocation = automaticAllocation; + return this; + } + + /** + * @see ResourceAllocationSettingData#getAutomaticDeallocation + */ + public Builder automaticDeallocation(Boolean automaticDeallocation) { + this.automaticDeallocation = automaticDeallocation; + return this; + } + + /** + * @see ResourceAllocationSettingData#getConsumerVisibility + */ + public Builder consumerVisibility(ConsumerVisibility consumerVisibility) { + this.consumerVisibility = consumerVisibility; + return this; + } + + /** + * @see ResourceAllocationSettingData#getLimit + */ + public Builder limit(Long limit) { + this.limit = limit; + return this; + } + + /** + * @see ResourceAllocationSettingData#getMappingBehavior + */ + public Builder mappingBehavior(MappingBehavior mappingBehavior) { + this.mappingBehavior = mappingBehavior; + return this; + } + + /** + * @see ResourceAllocationSettingData#getOtherResourceType + */ + public Builder otherResourceType(String otherResourceType) { + this.otherResourceType = otherResourceType; + return this; + } + + /** + * @see ResourceAllocationSettingData#getParent + */ + public Builder parent(String parent) { + this.parent = parent; + return this; + } + + /** + * @see ResourceAllocationSettingData#getPoolID + */ + public Builder poolID(String poolID) { + this.poolID = poolID; + return this; + } + + /** + * @see ResourceAllocationSettingData#getReservation + */ + public Builder reservation(Long reservation) { + this.reservation = reservation; + return this; + } + + /** + * @see ResourceAllocationSettingData#getResourceSubType + */ + public Builder resourceSubType(String resourceSubType) { + this.resourceSubType = resourceSubType; + return this; + } + + /** + * @see ResourceAllocationSettingData#getResourceType + */ + public Builder resourceType(ResourceType resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * @see ResourceAllocationSettingData#getVirtualQuantity + */ + public Builder virtualQuantity(Long virtualQuantity) { + this.virtualQuantity = virtualQuantity; + return this; + } + + /** + * @see ResourceAllocationSettingData#getVirtualQuantityUnits + */ + public Builder virtualQuantityUnits(String virtualQuantityUnits) { + this.virtualQuantityUnits = virtualQuantityUnits; + return this; + } + + /** + * @see ResourceAllocationSettingData#getWeight + */ + public Builder weight(Integer weight) { + this.weight = weight; + return this; + } + + /** + * @see ResourceAllocationSettingData#getConnection + */ + public Builder connection(String connection) { + this.connections.add(checkNotNull(connection, "connection")); + return this; + } + + /** + * @see ResourceAllocationSettingData#getHostResource + */ + public Builder hostResource(String hostResource) { + this.hostResources.add(checkNotNull(hostResource, "hostResource")); + return this; + } + + /** + * @see ResourceAllocationSettingData#getConnections + */ + public Builder connections(List connections) { + this.connections.addAll(checkNotNull(connections, "connections")); + return this; + } + + /** + * @see ResourceAllocationSettingData#getHostResources + */ + public Builder hostResources(List hostResources) { + this.hostResources.addAll(checkNotNull(hostResources, "hostResources")); + return this; + } + + public ResourceAllocationSettingData build() { + return new ResourceAllocationSettingData(elementName, instanceID, caption, description, address, + addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight, connections, hostResources); + } + + public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) { + return elementName(in.getElementName()).instanceID(in.getInstanceID()).caption(in.getCaption()).description( + in.getDescription()).address(in.getAddress()).addressOnParent(in.getAddressOnParent()) + .allocationUnits(in.getAllocationUnits()).automaticAllocation(in.isAutomaticAllocation()) + .automaticDeallocation(in.isAutomaticDeallocation()).consumerVisibility(in.getConsumerVisibility()) + .limit(in.getLimit()).mappingBehavior(in.getMappingBehavior()).otherResourceType( + in.getOtherResourceType()).parent(in.getParent()).poolID(in.getPoolID()).reservation( + in.getReservation()).resourceSubType(in.getResourceSubType()).resourceType( + in.getResourceType()).virtualQuantity(in.getVirtualQuantity()).virtualQuantityUnits( + in.getVirtualQuantityUnits()).weight(in.getWeight()).connections(in.getConnections()) + .hostResources(in.getHostResources()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder caption(String caption) { + return Builder.class.cast(super.caption(caption)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + } + + /** + * The type of resource this allocation setting represents. + */ + public static enum ResourceType { + + OTHER(1), COMPUTER_SYSTEM(2), PROCESSOR(3), MEMORY(4), IDE_CONTROLLER(5), PARALLEL_SCSI_HBA(6), FC_HBA(7), ISCSI_HBA( + 8), IB_HCA(9), ETHERNET_ADAPTER(10), OTHER_NETWORK_ADAPTER(11), IO_SLOT(12), IO_DEVICE(13), FLOPPY_DRIVE( + 14), CD_DRIVE(15), DVD_DRIVE(16), DISK_DRIVE(17), TAPE_DRIVE(18), STORAGE_EXTENT(19), OTHER_STORAGE_DEVICE( + 20), SERIAL_PORT(21), PARALLEL_PORT(22), USB_CONTROLLER(23), GRAPHICS_CONTROLLER(24), IEEE_1394_CONTROLLER( + 25), PARTITIONABLE_UNIT(26), BASE_PARTITIONABLE_UNIT(27), POWER(28), COOLING_CAPACITY(29), ETHERNET_SWITCH_PORT( + 30), LOGICAL_DISK(31), STORAGE_VOLUME(32), ETHERNET_CONNECTION(33), DMTF_RESERVED(Integer.valueOf( + "8000", 16)), VENDOR_RESERVED(Integer.valueOf("FFFF", 16)); + + protected final int code; + + ResourceType(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map RESOURCE_TYPE_BY_ID = Maps.uniqueIndex(ImmutableSet + .copyOf(ResourceType.values()), new Function() { + + @Override + public Integer apply(ResourceType input) { + return input.code; + } + + }); + + public static ResourceType fromValue(String type) { + return RESOURCE_TYPE_BY_ID.get(new Integer(checkNotNull(type, "type"))); + } + } + + /** + * Describes the consumers visibility to the allocated resource. + */ + public static enum ConsumerVisibility { + UNKNOWN(0), + /** + * indicates the underlying or host resource is utilized and passed through to the consumer, + * possibly using partitioning. At least one item shall be present in the HostResource + * property. + */ + PASSED_THROUGH(2), + /** + * indicates the resource is virtualized and may not map directly to an underlying/host + * resource. Some implementations may support specific assignment for virtualized resources, + * in which case the host resource(s) are exposed using the HostResource property. + */ + VIRTUALIZED(3), + /** + * indicates a representation of the resource does not exist within the context of the + * resource consumer. + */ + NOT_REPRESENTED(4), DMTF_RESERVED(32767), VENDOR_RESERVED(65535); + + protected final int code; + + ConsumerVisibility(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(ImmutableSet + .copyOf(ConsumerVisibility.values()), new Function() { + + @Override + public Integer apply(ConsumerVisibility input) { + return input.code; + } + + }); + + public static ConsumerVisibility fromValue(String behavior) { + return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior"))); + } + } + + /** + * Specifies how this resource maps to underlying resourcesIf the HostResource array contains any + * entries, this property reflects how the resource maps to those specific resources. + */ + public static enum MappingBehavior { + UNKNOWN(0), NOT_SUPPORTED(2), DEDICATED(3), SOFT_AFFINITY(4), HARD_AFFINITY(5), DMTF_RESERVED(32767), VENDOR_RESERVED( + 65535); + + protected final int code; + + MappingBehavior(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(ImmutableSet + .copyOf(MappingBehavior.values()), new Function() { + + @Override + public Integer apply(MappingBehavior input) { + return input.code; + } + + }); + + public static MappingBehavior fromValue(String behavior) { + return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior"))); + } + } + + protected final String address; + protected final String addressOnParent; + protected final String allocationUnits; + protected final Boolean automaticAllocation; + protected final Boolean automaticDeallocation; + protected final ConsumerVisibility consumerVisibility; + protected final Long limit; + protected final MappingBehavior mappingBehavior; + protected final String otherResourceType; + protected final String parent; + protected final String poolID; + protected final Long reservation; + protected final String resourceSubType; + protected final ResourceType resourceType; + protected final Long virtualQuantity; + protected final String virtualQuantityUnits; + protected final Integer weight; + protected final List connections; + protected final List hostResources; + + public ResourceAllocationSettingData(String elementName, String instanceID, String caption, String description, + String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation, + Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit, + MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation, + String resourceSubType, ResourceType resourceType, Long virtualQuantity, String virtualQuantityUnits, + Integer weight, List connections, List hostResources) { + super(elementName, instanceID, caption, description); + this.address = address; + this.addressOnParent = addressOnParent; + this.allocationUnits = allocationUnits; + this.automaticAllocation = automaticAllocation; + this.automaticDeallocation = automaticDeallocation; + this.consumerVisibility = consumerVisibility; + this.limit = limit; + this.mappingBehavior = mappingBehavior; + this.otherResourceType = otherResourceType; + this.parent = parent; + this.poolID = poolID; + this.reservation = reservation; + this.resourceSubType = resourceSubType; + this.resourceType = resourceType; + this.virtualQuantity = virtualQuantity; + this.virtualQuantityUnits = virtualQuantityUnits; + this.weight = weight; + this.connections = ImmutableList.copyOf(connections); + this.hostResources = ImmutableList.copyOf(hostResources); + } + + /** + * The address of the resource. For example, the MAC address of a Ethernet port. + */ + public String getAddress() { + return address; + } + + /** + * Describes the address of this resource in the context of the Parent. The + * Parent/AddressOnParent properties are used to describe the controller relationship as well the + * ordering of devices on a controller.For example, if the parent is a PCI Controller, this + * property would specify the PCI slot of this child device. + */ + public String getAddressOnParent() { + return addressOnParent; + } + + /** + * This property specifies the units of allocation used by the Reservation and Limit properties. + * For example, when ResourceType=Processor, AllocationUnits may be set to hertz*10^6 or percent. + * When ResourceType=Memory, AllocationUnits may be set to bytes*10^3. It is expected that + * profiles constrain the units that apply in context of particular resource types. The value of + * this property shall be a legal value of the Programmatic Units qualifier as defined in Annex + * C.1 of DSP0004 V2.5 or later. + */ + public String getAllocationUnits() { + return allocationUnits; + } + + /** + * This property specifies if the resource will be automatically allocated. For example when set + * to true, when the consuming virtual computer system is powered on, this resource would be + * allocated. A value of false indicates the resource must be explicitly allocated. For example, + * the setting may represent removable media (cdrom, floppy, etc.) where at power on time, the + * media is not present. An explicit operation is required to allocate the resource. + */ + public Boolean isAutomaticAllocation() { + return automaticAllocation; + } + + /** + * This property specifies if the resource will be automatically de-allocated. For example, when + * set to true, when the consuming virtual computer system is powered off, this resource would be + * de-allocated. When set to false, the resource will remain allocated and must be explicitly + * de-allocated. + */ + public Boolean isAutomaticDeallocation() { + return automaticDeallocation; + } + + /** + * Describes the consumers visibility to the allocated resource. + */ + public ConsumerVisibility getConsumerVisibility() { + return consumerVisibility; + } + + /** + * This property specifies the upper bound, or maximum amount of resource that will be granted + * for this allocation. For example, a system which supports memory paging may support setting + * the Limit of a Memory allocation below that of the VirtualQuantity, thus forcing paging to + * occur for this allocation. The value of the Limit property is expressed in the unit specified + * by the value of the AllocationUnits property. + */ + public Long getLimit() { + return limit; + } + + /** + * Specifies how this resource maps to underlying resourcesIf the HostResource array contains any + * entries, this property reflects how the resource maps to those specific resources. + */ + public MappingBehavior getMappingBehavior() { + return mappingBehavior; + } + + /** + * A string that describes the resource type when a well defined value is not available and + * ResourceType has the value "Other". + */ + public String getOtherResourceType() { + return otherResourceType; + } + + /** + * The Parent of the resource. For example, a controller for the current allocation + */ + public String getParent() { + return parent; + } + + /** + * This property specifies which ResourcePool the resource is currently allocated from, or which + * ResourcePool the resource will be allocated from when the allocation occurs. + */ + public String getPoolID() { + return poolID; + } + + /** + * This property specifies the amount of resource guaranteed to be available for this allocation. + * On system which support over-commitment of resources, this value is typically used for + * admission control to prevent an an allocation from being accepted thus preventing starvation. + * The value of the Reservation property is expressed in the unit specified by the value of the + * AllocationUnits property. + */ + public Long getReservation() { + return reservation; + } + + /** + * A string describing an implementation specific sub-type for this resource. F + */ + public String getResourceSubType() { + return resourceSubType; + } + + /** + * The type of resource this allocation setting represents. + */ + public ResourceType getResourceType() { + return resourceType; + } + + /** + * This property specifies the quantity of resources presented to the consumer. For example, when + * ResourceType=Processor, this property would reflect the number of discrete Processors + * presented to the virtual computer system. When ResourceType=Memory, this property could + * reflect the number of MB reported to the virtual computer system. The value of the + * VirtualQuantity property should be expressed in units as defined by the value of the + * VirtualQuantityUnits property. + */ + public Long getVirtualQuantity() { + return virtualQuantity; + } + + /** + * This property specifies the units used by the VirtualQuantity property. For example - if + * ResourceType=Processor, the value of the VirtualQuantityUnits property may be set to "count", + * indicating that the value of the VirtualQuantity property is expressed as a count. - if + * ResourceType=Memory, the value of the VirtualQuantityUnits property may be set to + * "bytes*10^3", indicating that the value of the VirtualQuantity property is expressed in + * kilobyte. It is expected that profiles constrain the units that apply in context of particular + * resource types. The value of this property shall be a legal value of the Programmatic Units + * qualifier as defined in Annex C.1 of DSP0004 V2.5 or later. + */ + public String getVirtualQuantityUnits() { + return virtualQuantityUnits; + } + + /** + * This property specifies a relative priority for this allocation in relation to other + * allocations from the same ResourcePool. This property has no unit of measure, and is only + * relevant when compared to other allocations vying for the same host resources. + */ + public Integer getWeight() { + return weight; + } + + /** + * The thing to which this resource is connected. For example, a named network or switch port. + */ + public List getConnections() { + return connections; + } + + /** + * This property exposes specific assignment of resources. Each non-null value of the + * HostResource property shall be formated as a URI per RFC3986. If this resource is modeled then + * a value should be a WBEM URI (DSP0207). If the resource is not modeled then see the + * appropriate profile. Profiles may further constrain the type of URI. A NULL value or empty + * array requests the implementation decide the kind of host resource. If the virtual resource is + * mapped to more than oneunderlying resource, this property may be left NULL. If NULL, the + * DeviceAllocatedFromPool or ResourceAllocationFromPool associations may be used to determine + * the pool of host resources this virtual resource may use. If specific assignment is utilized, + * all underlying resources used by this virtual resource should be listed.The kind of dependency + * is specified by the ConsumerVisibility and the MappingBehavior properties. Typically the array + * contains one item, however multiple host resources may be specified. A client may set the + * value(s) to indicate that the requested virtual resource allocation be based on host resources + * that are identified by element values. + */ + public List getHostResources() { + return hostResources; + } + + public Builder toBuilder() { + return new Builder().fromResourceAllocationSettingData(this); + } + + @Override + public String toString() { + return String + .format( + "[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s]", + elementName, instanceID, caption, description, address, addressOnParent, allocationUnits, + automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, + limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, + resourceType, virtualQuantity, virtualQuantityUnits, weight); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode()); + result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode()); + result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + ResourceAllocationSettingData other = (ResourceAllocationSettingData) obj; + if (address == null) { + if (other.address != null) + return false; + } else if (!address.equals(other.address)) + return false; + if (addressOnParent == null) { + if (other.addressOnParent != null) + return false; + } else if (!addressOnParent.equals(other.addressOnParent)) + return false; + if (resourceSubType == null) { + if (other.resourceSubType != null) + return false; + } else if (!resourceSubType.equals(other.resourceSubType)) + return false; + if (resourceType == null) { + if (other.resourceType != null) + return false; + } else if (!resourceType.equals(other.resourceType)) + return false; + return true; + } + +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/cim/SettingData.java b/compute/src/main/java/org/jclouds/cim/SettingData.java new file mode 100644 index 0000000000..09ea7d70a0 --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/SettingData.java @@ -0,0 +1,126 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * The type of resource this allocation setting represents. + * + * @author Adrian Cole + * @see + * + */ +public abstract class SettingData { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + protected String elementName; + protected String instanceID; + + /** + * @see SettingData#getElementName + */ + public Builder elementName(String elementName) { + this.elementName = checkNotNull(elementName, "elementName"); + return this; + } + + /** + * @see SettingData#getInstanceID + */ + public Builder instanceID(String instanceID) { + this.instanceID = checkNotNull(instanceID, "instanceID"); + return this; + } + + public Builder fromSettingData(SettingData in) { + return elementName(in.getElementName()).instanceID(in.getInstanceID()); + } + } + + protected final String elementName; + protected final String instanceID; + + public SettingData(String elementName, String instanceID) { + this.elementName = checkNotNull(elementName, "elementName"); + this.instanceID = checkNotNull(instanceID, "instanceID"); + } + + /** + * The user-friendly name for this instance of SettingData. In addition, the user-friendly name + * can be used as an index property for a search or query. (Note: The name does not have to be + * unique within a namespace.) + */ + public String getElementName() { + return elementName; + } + + /** + * Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies + * an instance of this class. + */ + public String getInstanceID() { + return instanceID; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((elementName == null) ? 0 : elementName.hashCode()); + result = prime * result + ((instanceID == null) ? 0 : instanceID.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; + SettingData other = (SettingData) obj; + if (elementName == null) { + if (other.elementName != null) + return false; + } else if (!elementName.equals(other.elementName)) + return false; + if (instanceID == null) { + if (other.instanceID != null) + return false; + } else if (!instanceID.equals(other.instanceID)) + return false; + return true; + } + + @Override + public String toString() { + return String.format("[elementName=%s, instanceID=%s]", elementName, instanceID); + } + +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/cim/VirtualSystemSettingData.java b/compute/src/main/java/org/jclouds/cim/VirtualSystemSettingData.java new file mode 100644 index 0000000000..6241e1bbbd --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/VirtualSystemSettingData.java @@ -0,0 +1,575 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +/** + * + * CIM_VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of + * virtualization specific properties. CIM_VirtualSystemSettingData is also used as the top level + * class of virtual system configurations. Virtual system configurations model configuration + * information about virtual systems and their components. A virtual system configuration consists + * of one top-level instance of class CIM_VirtualSystemSettingData that aggregates a number of + * instances of class CIM_ResourceAllocationSettingData, using association CIM_ConcreteComponent. + * Virtual system configurations may for example be used to reflect configurations of - virtual + * systems that are defined at a virtualization platform, - virtual systems that are currently + * active, - input requests to create new virtual systems, - input requests to modify existing + * virtual systems, or - snapshots of virtual systems. + * + * @author Adrian Cole + * @see + * + */ +public class VirtualSystemSettingData extends ManagedElement { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends ManagedElement.Builder { + private AutomaticRecoveryAction automaticRecoveryAction; + private AutomaticShutdownAction automaticShutdownAction; + private AutomaticStartupAction automaticStartupAction; + private Long automaticStartupActionDelay; + private Integer automaticStartupActionSequenceNumber; + private URI configurationDataRoot; + private URI configurationFile; + private String configurationID; + private Date creationTime; + private URI logDataRoot; + private URI recoveryFile; + private URI snapshotDataRoot; + private URI suspendDataRoot; + private URI swapFileDataRoot; + private String virtualSystemIdentifier; + private Set virtualSystemTypes = Sets.newLinkedHashSet(); + private String notes; + + public Builder automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) { + this.automaticRecoveryAction = automaticRecoveryAction; + return this; + } + + public Builder automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) { + this.automaticShutdownAction = automaticShutdownAction; + return this; + } + + public Builder automaticStartupAction(AutomaticStartupAction automaticStartupAction) { + this.automaticStartupAction = automaticStartupAction; + return this; + } + + public Builder automaticStartupActionDelay(Long automaticStartupActionDelay) { + this.automaticStartupActionDelay = automaticStartupActionDelay; + return this; + } + + public Builder automaticStartupActionSequenceNumber(Integer automaticStartupActionSequenceNumber) { + this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber; + return this; + } + + public Builder configurationDataRoot(URI configurationDataRoot) { + this.configurationDataRoot = configurationDataRoot; + return this; + } + + public Builder configurationFile(URI configurationFile) { + this.configurationFile = configurationFile; + return this; + } + + public Builder configurationID(String configurationID) { + this.configurationID = configurationID; + return this; + } + + public Builder creationTime(Date creationTime) { + this.creationTime = creationTime; + return this; + } + + public Builder logDataRoot(URI logDataRoot) { + this.logDataRoot = logDataRoot; + return this; + } + + public Builder recoveryFile(URI recoveryFile) { + this.recoveryFile = recoveryFile; + return this; + } + + public Builder snapshotDataRoot(URI snapshotDataRoot) { + this.snapshotDataRoot = snapshotDataRoot; + return this; + } + + public Builder suspendDataRoot(URI suspendDataRoot) { + this.suspendDataRoot = suspendDataRoot; + return this; + } + + public Builder swapFileDataRoot(URI swapFileDataRoot) { + this.swapFileDataRoot = swapFileDataRoot; + return this; + } + + public Builder virtualSystemIdentifier(String virtualSystemIdentifier) { + this.virtualSystemIdentifier = virtualSystemIdentifier; + return this; + } + + public Builder virtualSystemTypes(Iterable virtualSystemTypes) { + this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes")); + return this; + } + + public Builder virtualSystemType(String virtualSystemType) { + this.virtualSystemTypes.add(checkNotNull(virtualSystemType, "virtualSystemType")); + return this; + } + + public Builder notes(String notes) { + this.notes = notes; + return this; + } + + public VirtualSystemSettingData build() { + return new VirtualSystemSettingData(elementName, instanceID, caption, description, automaticRecoveryAction, + automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay, + automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile, configurationID, + creationTime, logDataRoot, recoveryFile, snapshotDataRoot, suspendDataRoot, swapFileDataRoot, + virtualSystemIdentifier, virtualSystemTypes, notes); + } + + public Builder fromVirtualSystemSettingData(VirtualSystemSettingData in) { + return fromManagedElement(in).automaticRecoveryAction(in.getAutomaticRecoveryAction()) + .automaticShutdownAction(in.getAutomaticShutdownAction()).automaticStartupAction( + in.getAutomaticStartupAction()).automaticStartupActionDelay( + in.getAutomaticStartupActionDelay()).automaticStartupActionSequenceNumber( + in.getAutomaticStartupActionSequenceNumber()).configurationDataRoot( + in.getConfigurationDataRoot()).configurationFile(in.getConfigurationFile()).configurationID( + in.getConfigurationID()).creationTime(in.getCreationTime()).logDataRoot(in.getLogDataRoot()) + .recoveryFile(in.getRecoveryFile()).snapshotDataRoot(in.getSnapshotDataRoot()).suspendDataRoot( + in.getSuspendDataRoot()).swapFileDataRoot(in.getSwapFileDataRoot()).virtualSystemIdentifier( + in.getVirtualSystemIdentifier()).virtualSystemTypes(in.getVirtualSystemTypes()).notes( + in.getNotes()); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder fromManagedElement(ManagedElement in) { + return Builder.class.cast(super.fromManagedElement(in)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder caption(String caption) { + return Builder.class.cast(super.caption(caption)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder description(String description) { + return Builder.class.cast(super.description(description)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder elementName(String elementName) { + return Builder.class.cast(super.elementName(elementName)); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder instanceID(String instanceID) { + return Builder.class.cast(super.instanceID(instanceID)); + } + + } + + /** + * Action to take for the virtual system when the software executed by the virtual system fails. + * Failures in this case means a failure that is detectable by the host platform, such as a + * non-interuptable wait state condition. + */ + public static enum AutomaticRecoveryAction { + + NONE(2), + + RESTART(3), + + REVERT_TO_SNAPSHOT(4); + + protected final int code; + + AutomaticRecoveryAction(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map AUTOMATIC_RECOVERY_ACTION_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(AutomaticRecoveryAction.values()), new Function() { + + @Override + public Integer apply(AutomaticRecoveryAction input) { + return input.code; + } + + }); + + public static AutomaticRecoveryAction fromValue(String automaticRecoveryAction) { + return AUTOMATIC_RECOVERY_ACTION_BY_ID.get(new Integer(checkNotNull(automaticRecoveryAction, + "automaticRecoveryAction"))); + } + } + + /** + * Action to take for the virtual system when the host is shut down. + */ + public static enum AutomaticShutdownAction { + + TURN_OFF(2), + + SAVE_STATE(3), + + SHUTDOWN(4); + + protected final int code; + + AutomaticShutdownAction(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map AUTOMATIC_SHUTDOWN_ACTION_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(AutomaticShutdownAction.values()), new Function() { + + @Override + public Integer apply(AutomaticShutdownAction input) { + return input.code; + } + + }); + + public static AutomaticShutdownAction fromValue(String automaticShutdownAction) { + return AUTOMATIC_SHUTDOWN_ACTION_BY_ID.get(new Integer(checkNotNull(automaticShutdownAction, + "automaticShutdownAction"))); + } + } + + /** + * Action to take for the virtual system when the host is started. + */ + public static enum AutomaticStartupAction { + + NONE(2), + + RESTART_IF_PREVIOUSLY_ACTIVE(3), + + ALWAYS_STARTUP(4); + + protected final int code; + + AutomaticStartupAction(int code) { + this.code = code; + } + + public String value() { + return code + ""; + } + + protected final static Map AUTOMATIC_STARTUP_ACTION_BY_ID = Maps.uniqueIndex( + ImmutableSet.copyOf(AutomaticStartupAction.values()), new Function() { + + @Override + public Integer apply(AutomaticStartupAction input) { + return input.code; + } + + }); + + public static AutomaticStartupAction fromValue(String automaticStartupAction) { + return AUTOMATIC_STARTUP_ACTION_BY_ID.get(new Integer(checkNotNull(automaticStartupAction, + "automaticStartupAction"))); + } + } + + private final AutomaticRecoveryAction automaticRecoveryAction; + private final AutomaticShutdownAction automaticShutdownAction; + private final AutomaticStartupAction automaticStartupAction; + private final Long automaticStartupActionDelay; + private final Integer automaticStartupActionSequenceNumber; + private final URI configurationDataRoot; + private final URI configurationFile; + private final String configurationID; + private final Date creationTime; + private final URI logDataRoot; + private final URI recoveryFile; + private final URI snapshotDataRoot; + private final URI suspendDataRoot; + private final URI swapFileDataRoot; + private final String virtualSystemIdentifier; + private final Set virtualSystemTypes; + private final String notes; + + public VirtualSystemSettingData(String elementName, String instanceID, String caption, String description, + AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction, + AutomaticStartupAction automaticStartupAction, Long automaticStartupActionDelay, + Integer automaticStartupActionSequenceNumber, URI configurationDataRoot, URI configurationFile, + String configurationID, Date creationTime, URI logDataRoot, URI recoveryFile, URI snapshotDataRoot, + URI suspendDataRoot, URI swapFileDataRoot, String virtualSystemIdentifier, + Iterable virtualSystemTypes, String notes) { + super(elementName, instanceID, caption, description); + this.automaticRecoveryAction = automaticRecoveryAction; + this.automaticShutdownAction = automaticShutdownAction; + this.automaticStartupAction = automaticStartupAction; + this.automaticStartupActionDelay = automaticStartupActionDelay; + this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber; + this.configurationDataRoot = configurationDataRoot; + this.configurationFile = configurationFile; + this.configurationID = configurationID; + this.creationTime = creationTime; + this.logDataRoot = logDataRoot; + this.recoveryFile = recoveryFile; + this.snapshotDataRoot = snapshotDataRoot; + this.suspendDataRoot = suspendDataRoot; + this.swapFileDataRoot = swapFileDataRoot; + this.virtualSystemIdentifier = virtualSystemIdentifier; + this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes")); + this.notes = notes; + } + + /** + * Action to take for the virtual system when the software executed by the virtual system fails. + * Failures in this case means a failure that is detectable by the host platform, such as a + * non-interuptable wait state condition. + */ + public AutomaticRecoveryAction getAutomaticRecoveryAction() { + return automaticRecoveryAction; + } + + /** + * Action to take for the virtual system when the host is shut down. + */ + public AutomaticShutdownAction getAutomaticShutdownAction() { + return automaticShutdownAction; + } + + /** + * Action to take for the virtual system when the host is started. + */ + public AutomaticStartupAction getAutomaticStartupAction() { + return automaticStartupAction; + } + + /** + * Delay applicable to startup action. The value shall be in the interval variant of the datetime + * datatype. + */ + public Long getAutomaticStartupActionDelay() { + return automaticStartupActionDelay; + } + + /** + * Number indicating the relative sequence of virtual system activation when the host system is + * started. A lower number indicates earlier activation. If one or more configurations show the + * same value, the sequence is implementation dependent. A value of 0 indicates that the sequence + * is implementation dependent. + */ + public Integer getAutomaticStartupActionSequenceNumber() { + return automaticStartupActionSequenceNumber; + } + + /** + * Filepath of a directory where information about the virtual system configuration is + * stored.Format shall be URI based on RFC 2079. + */ + public URI getConfigurationDataRoot() { + return configurationDataRoot; + } + + /** + * Filepath of a file where information about the virtual system configuration is stored. A + * relative path appends to the value of the ConfigurationDataRoot property.Format shall be URI + * based on RFC 2079. + */ + public URI getConfigurationFile() { + return configurationFile; + } + + /** + * Unique id of the virtual system configuration. Note that the ConfigurationID is different from + * the InstanceID as it is assigned by the implementation to a virtual system or a virtual system + * configuration. It is not a key, and the same value may occur within more than one instance. + */ + public String getConfigurationID() { + return configurationID; + } + + /** + * Time when the virtual system configuration was created. + */ + public Date getCreationTime() { + return creationTime; + } + + /** + * Filepath of a directory where log information about the virtual system is stored. A relative + * path appends to the value of the ConfigurationDataRoot property.Format shall be URI based on + * RFC 2079. + */ + public URI getLogDataRoot() { + return logDataRoot; + } + + /** + * Filepath of a file where recovery relateded information of the virtual system is stored.Format + * shall be URI based on RFC 2079. + */ + public URI getRecoveryFile() { + return recoveryFile; + } + + /** + * Filepath of a directory where information about virtual system snapshots is stored. A relative + * path appends to the value of the ConfigurationDataRoot property.Format shall be URI based on + * RFC 2079. + */ + public URI getSnapshotDataRoot() { + return snapshotDataRoot; + } + + /** + * Filepath of a directory where suspend related information about the virtual system is stored. + * A relative path appends to the value of the ConfigurationDataRoot property.Format shall be URI + * based on RFC 2079. + */ + public URI getSuspendDataRoot() { + return suspendDataRoot; + } + + /** + * Filepath of a directory where swapfiles of the virtual system are stored. A relative path + * appends to the value of the ConfigurationDataRoot property.Format shall be URI based on RFC + * 2079. + */ + public URI getSwapFileDataRoot() { + return swapFileDataRoot; + } + + /** + * VirtualSystemIdentifier shall reflect a unique name for the system as it is used within the + * virtualization platform. Note that the VirtualSystemIdentifier is not the hostname assigned to + * the operating system instance running within the virtual system, nor is it an IP address or + * MAC address assigned to any of its network ports. On create requests VirtualSystemIdentifier + * may contain implementation specific rules (like simple patterns or regular expresssion) that + * may be interpreted by the implementation when assigning a VirtualSystemIdentifier. + */ + public String getVirtualSystemIdentifier() { + return virtualSystemIdentifier; + } + + /** + * VirtualSystemType shall reflect a particular type of virtual system. + */ + public Set getVirtualSystemTypes() { + return virtualSystemTypes; + } + + /** + * End-user supplied notes that are related to the virtual system. + */ + public String getNotes() { + return notes; + } + + public Builder toBuilder() { + return builder().fromVirtualSystemSettingData(this); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((virtualSystemIdentifier == null) ? 0 : virtualSystemIdentifier.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + VirtualSystemSettingData other = (VirtualSystemSettingData) obj; + if (virtualSystemIdentifier == null) { + if (other.virtualSystemIdentifier != null) + return false; + } else if (!virtualSystemIdentifier.equals(other.virtualSystemIdentifier)) + return false; + return true; + } + + @Override + public String toString() { + return String + .format( + "[elementName=%s, instanceID=%s, caption=%s, description=%s, automaticRecoveryAction=%s, automaticShutdownAction=%s, automaticStartupAction=%s, automaticStartupActionDelay=%s, automaticStartupActionSequenceNumber=%s, configurationDataRoot=%s, configurationFile=%s, configurationID=%s, creationTime=%s, logDataRoot=%s, notes=%s, recoveryFile=%s, snapshotDataRoot=%s, suspendDataRoot=%s, swapFileDataRoot=%s, virtualSystemIdentifier=%s, virtualSystemTypes=%s]", + elementName, instanceID, caption, description, automaticRecoveryAction, + automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay, + automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile, + configurationID, creationTime, logDataRoot, notes, recoveryFile, snapshotDataRoot, + suspendDataRoot, swapFileDataRoot, virtualSystemIdentifier, virtualSystemTypes); + } + +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java b/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java new file mode 100644 index 0000000000..52065d278d --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/functions/HardwareBuilderFromResourceAllocations.java @@ -0,0 +1,76 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim.functions; + +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.find; +import static com.google.common.collect.Iterables.transform; + +import javax.inject.Singleton; + +import org.jclouds.cim.CIMPredicates; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.domain.Processor; +import org.jclouds.compute.domain.Volume; +import org.jclouds.compute.domain.internal.VolumeImpl; + +import com.google.common.base.Function; + +/** + * @author Adrian Cole + */ +@Singleton +public class HardwareBuilderFromResourceAllocations implements + Function, HardwareBuilder> { + @Override + public HardwareBuilder apply(Iterable from) { + HardwareBuilder builder = new HardwareBuilder(); + builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE, + ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)), + new Function() { + + @Override + public Volume apply(ResourceAllocationSettingData from) { + return HardwareBuilderFromResourceAllocations.this.apply(from); + } + + })); + + builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue()); + + builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)), + new Function() { + + @Override + public Processor apply(ResourceAllocationSettingData arg0) { + return new Processor(arg0.getVirtualQuantity(), 1); + } + })); + return builder; + } + + public Volume apply(ResourceAllocationSettingData from) { + return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null + : from.getVirtualQuantity() / 1024 / 1024f, null, "0".equals(from.getAddressOnParent()) + || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true); + } +} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandler.java b/compute/src/main/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandler.java new file mode 100644 index 0000000000..35f2a5b5bb --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/xml/ResourceAllocationSettingDataHandler.java @@ -0,0 +1,130 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim.xml; + +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ConsumerVisibility; +import org.jclouds.cim.ResourceAllocationSettingData.MappingBehavior; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class ResourceAllocationSettingDataHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + + protected ResourceAllocationSettingData.Builder builder = ResourceAllocationSettingData.builder(); + + public ResourceAllocationSettingData getResult() { + try { + return builder.build(); + } finally { + builder = ResourceAllocationSettingData.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + } + + @Override + public void endElement(String uri, String localName, String qName) { + String current = currentOrNull(currentText); + if (current != null) { + if (equalsOrSuffix(qName, "ElementName")) { + builder.elementName(current); + } else if (equalsOrSuffix(qName, "InstanceID")) { + builder.instanceID(current); + } else if (equalsOrSuffix(qName, "Caption")) { + builder.caption(current); + } else if (equalsOrSuffix(qName, "Description")) { + builder.description(current); + } else if (equalsOrSuffix(qName, "Address")) { + builder.address(current); + } else if (equalsOrSuffix(qName, "AddressOnParent")) { + builder.addressOnParent(current); + } else if (equalsOrSuffix(qName, "AllocationUnits")) { + builder.allocationUnits(current); + } else if (equalsOrSuffix(qName, "AutomaticAllocation")) { + builder.automaticAllocation(new Boolean(current)); + } else if (equalsOrSuffix(qName, "AutomaticDeallocation")) { + builder.automaticDeallocation(new Boolean(current)); + } else if (equalsOrSuffix(qName, "ConsumerVisibility")) { + builder.consumerVisibility(ConsumerVisibility.fromValue(current)); + } else if (equalsOrSuffix(qName, "Limit")) { + builder.limit(new Long(current)); + } else if (equalsOrSuffix(qName, "MappingBehavior")) { + builder.mappingBehavior(MappingBehavior.fromValue(current)); + } else if (equalsOrSuffix(qName, "OtherResourceType")) { + builder.otherResourceType(current); + } else if (equalsOrSuffix(qName, "Parent")) { + builder.parent(current); + } else if (equalsOrSuffix(qName, "PoolID")) { + builder.poolID(current); + } else if (equalsOrSuffix(qName, "Reservation")) { + builder.reservation(new Long(current)); + } else if (equalsOrSuffix(qName, "ResourceSubType")) { + builder.resourceSubType(current); + } else if (equalsOrSuffix(qName, "ResourceType")) { + builder.resourceType(ResourceType.fromValue(current)); + } else if (equalsOrSuffix(qName, "VirtualQuantity")) { + builder.virtualQuantity(new Long(current)); + } else if (equalsOrSuffix(qName, "VirtualQuantityUnits")) { + builder.virtualQuantityUnits(current); + } else if (equalsOrSuffix(qName, "Weight")) { + builder.weight(new Integer(current)); + } else if (equalsOrSuffix(qName, "Connection")) { + builder.connection(current); + } else if (equalsOrSuffix(qName, "HostResource")) { + builder.hostResource(current); + } + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + +} diff --git a/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java b/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java new file mode 100644 index 0000000000..ff9554b765 --- /dev/null +++ b/compute/src/main/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandler.java @@ -0,0 +1,125 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim.xml; + +import static com.google.common.base.Predicates.equalTo; +import static com.google.common.base.Predicates.not; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.transform; +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +import java.net.URI; + +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.VirtualSystemSettingData.AutomaticRecoveryAction; +import org.jclouds.cim.VirtualSystemSettingData.AutomaticShutdownAction; +import org.jclouds.cim.VirtualSystemSettingData.AutomaticStartupAction; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import com.google.common.base.Function; +import com.google.common.base.Splitter; + +/** + * @author Adrian Cole + */ +public class VirtualSystemSettingDataHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + + protected VirtualSystemSettingData.Builder builder = VirtualSystemSettingData.builder(); + + public VirtualSystemSettingData getResult() { + try { + return builder.build(); + } finally { + builder = VirtualSystemSettingData.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + } + + @Override + public void endElement(String uri, String localName, String qName) { + String current = currentOrNull(currentText); + if (current != null) { + if (equalsOrSuffix(qName, "ElementName")) { + builder.elementName(current); + } else if (equalsOrSuffix(qName, "InstanceID")) { + builder.instanceID(current); + } else if (equalsOrSuffix(qName, "Caption")) { + builder.caption(current); + } else if (equalsOrSuffix(qName, "Description")) { + builder.description(current); + } else if (equalsOrSuffix(qName, "AutomaticRecoveryAction")) { + builder.automaticRecoveryAction(AutomaticRecoveryAction.fromValue(current)); + } else if (equalsOrSuffix(qName, "AutomaticShutdownAction")) { + builder.automaticShutdownAction(AutomaticShutdownAction.fromValue(current)); + } else if (equalsOrSuffix(qName, "AutomaticStartupAction")) { + builder.automaticStartupAction(AutomaticStartupAction.fromValue(current)); + } else if (equalsOrSuffix(qName, "AutomaticStartupActionDelay")) { + // TODO parse the format for intervals: ddddddddhhmmss.mmmmmm:000 + builder.automaticStartupActionDelay(null); + } else if (equalsOrSuffix(qName, "AutomaticStartupActionSequenceNumber")) { + builder.automaticStartupActionSequenceNumber(new Integer(current)); + } else if (equalsOrSuffix(qName, "ConfigurationDataRoot")) { + builder.configurationDataRoot(URI.create(current)); + } else if (equalsOrSuffix(qName, "ConfigurationFile")) { + builder.configurationFile(URI.create(current)); + } else if (equalsOrSuffix(qName, "ConfigurationID")) { + builder.configurationID(current); + } else if (equalsOrSuffix(qName, "CreationTime")) { + // TODO parse the format for timestamps: yyyymmddhhmmss.mmmmmmsutc + builder.creationTime(null); + } else if (equalsOrSuffix(qName, "LogDataRoot")) { + builder.logDataRoot(URI.create(current)); + } else if (equalsOrSuffix(qName, "RecoveryFile")) { + builder.recoveryFile(URI.create(current)); + } else if (equalsOrSuffix(qName, "RecoveryFile")) { + builder.recoveryFile(URI.create(current)); + } else if (equalsOrSuffix(qName, "SuspendDataRoot")) { + builder.suspendDataRoot(URI.create(current)); + } else if (equalsOrSuffix(qName, "SwapFileDataRoot")) { + builder.swapFileDataRoot(URI.create(current)); + } else if (equalsOrSuffix(qName, "VirtualSystemIdentifier")) { + builder.virtualSystemIdentifier(current); + } else if (equalsOrSuffix(qName, "VirtualSystemType")) { + builder.virtualSystemTypes(filter(transform(Splitter.on(',').split(current), + new Function() { + + @Override + public String apply(String input) { + return input.trim(); + } + + }), not(equalTo("")))); + } else if (equalsOrSuffix(qName, "Notes")) { + builder.notes(current); + } + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java b/compute/src/main/java/org/jclouds/compute/domain/CIMOperatingSystem.java similarity index 92% rename from compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java rename to compute/src/main/java/org/jclouds/compute/domain/CIMOperatingSystem.java index df217d3385..ef56c29382 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/os/CIMOperatingSystem.java +++ b/compute/src/main/java/org/jclouds/compute/domain/CIMOperatingSystem.java @@ -17,10 +17,9 @@ * ==================================================================== */ -package org.jclouds.compute.domain.os; +package org.jclouds.compute.domain; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; +import org.jclouds.ovf.OvfEnvelope; import com.google.common.annotations.Beta; @@ -33,6 +32,14 @@ import com.google.common.annotations.Beta; @Beta public class CIMOperatingSystem extends OperatingSystem { + public static CIMOperatingSystem toComputeOs(org.jclouds.ovf.OperatingSystemSection os) { + return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), "", null, os.getDescription()); + } + + public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) { + return toComputeOs(ovf.getVirtualSystem().getOperatingSystem()); + } + public enum OSType { /** * Other @@ -201,9 +208,12 @@ public class CIMOperatingSystem extends OperatingSystem { /** * Oracle Enterprise Linux 64-bit */ - ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true), UNRECOGNIZED( - Integer.MAX_VALUE, "UNRECOGNIZED", null, true); - + ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true), + /** + * eComStation 32-bitx + */ + ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), UNRECOGNIZED(Integer.MAX_VALUE, + "UNRECOGNIZED", null, true); private final int code; public int getCode() { diff --git a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java index 353b855c2a..063db06d54 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/HardwareBuilder.java @@ -32,6 +32,7 @@ import org.jclouds.compute.predicates.ImagePredicates; import org.jclouds.domain.Location; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; /** @@ -48,8 +49,8 @@ public class HardwareBuilder extends ComputeMetadataBuilder { super(ComputeType.HARDWARE); } - public HardwareBuilder processors(List processors) { - this.processors = checkNotNull(processors, "processors"); + public HardwareBuilder processors(Iterable processors) { + this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors")); return this; } @@ -58,8 +59,8 @@ public class HardwareBuilder extends ComputeMetadataBuilder { return this; } - public HardwareBuilder volumes(List volumes) { - this.volumes = checkNotNull(volumes, "volumes"); + public HardwareBuilder volumes(Iterable volumes) { + this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes")); return this; } diff --git a/compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java b/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java similarity index 96% rename from compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java rename to compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java index e015b580e6..5cd49d7a8c 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/os/OsFamilyVersion64Bit.java +++ b/compute/src/main/java/org/jclouds/compute/domain/OsFamilyVersion64Bit.java @@ -17,9 +17,8 @@ * ==================================================================== */ -package org.jclouds.compute.domain.os; +package org.jclouds.compute.domain; -import org.jclouds.compute.domain.OsFamily; /** * diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/network/Network.java b/compute/src/main/java/org/jclouds/ovf/Network.java similarity index 97% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/network/Network.java rename to compute/src/main/java/org/jclouds/ovf/Network.java index 809c00de77..2012350414 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/network/Network.java +++ b/compute/src/main/java/org/jclouds/ovf/Network.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf.network; +package org.jclouds.ovf; /** * diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/NetworkSection.java b/compute/src/main/java/org/jclouds/ovf/NetworkSection.java similarity index 89% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/NetworkSection.java rename to compute/src/main/java/org/jclouds/ovf/NetworkSection.java index a56f96a0b1..35f2520ec5 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/NetworkSection.java +++ b/compute/src/main/java/org/jclouds/ovf/NetworkSection.java @@ -17,14 +17,11 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf; +package org.jclouds.ovf; import java.util.Set; -import org.jclouds.vcloud.domain.ovf.network.Network; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet; /** * The NetworkSection element shall list all logical networks used in the OVF package. @@ -33,11 +30,11 @@ import com.google.common.collect.Sets; */ public class NetworkSection { private final String info; - private final Set networks = Sets.newLinkedHashSet(); + private final Set networks; public NetworkSection(String info, Iterable networks) { this.info = info; - Iterables.addAll(this.networks, networks); + this.networks = ImmutableSet. copyOf(networks); } public String getInfo() { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystemSection.java b/compute/src/main/java/org/jclouds/ovf/OperatingSystemSection.java similarity index 98% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystemSection.java rename to compute/src/main/java/org/jclouds/ovf/OperatingSystemSection.java index 1b6b022c2f..951705d5cc 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystemSection.java +++ b/compute/src/main/java/org/jclouds/ovf/OperatingSystemSection.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf; +package org.jclouds.ovf; import javax.annotation.Nullable; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java b/compute/src/main/java/org/jclouds/ovf/OvfEnvelope.java similarity index 98% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java rename to compute/src/main/java/org/jclouds/ovf/OvfEnvelope.java index bd947e9c0d..b4527e61e8 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java +++ b/compute/src/main/java/org/jclouds/ovf/OvfEnvelope.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf; +package org.jclouds.ovf; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualHardwareSection.java b/compute/src/main/java/org/jclouds/ovf/VirtualHardwareSection.java similarity index 80% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualHardwareSection.java rename to compute/src/main/java/org/jclouds/ovf/VirtualHardwareSection.java index da90b5507e..ffb0d6749b 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualHardwareSection.java +++ b/compute/src/main/java/org/jclouds/ovf/VirtualHardwareSection.java @@ -17,15 +17,16 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf; +package org.jclouds.ovf; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet; /** * @@ -38,25 +39,25 @@ import com.google.common.collect.Sets; public class VirtualHardwareSection { protected final String info; - protected final System virtualSystem; - protected final Set resourceAllocations = Sets.newLinkedHashSet(); + protected final VirtualSystemSettingData virtualSystem; + protected final Set resourceAllocations; - public VirtualHardwareSection(String info, System virtualSystem, - Iterable resourceAllocations) { + public VirtualHardwareSection(String info, VirtualSystemSettingData virtualSystem, + Iterable resourceAllocations) { this.info = info; this.virtualSystem = virtualSystem; - Iterables.addAll(this.resourceAllocations, checkNotNull(resourceAllocations, "resourceAllocations")); + this.resourceAllocations = ImmutableSet.copyOf(checkNotNull(resourceAllocations, "resourceAllocations")); } public String getInfo() { return info; } - public System getSystem() { + public VirtualSystemSettingData getSystem() { return virtualSystem; } - public Set getResourceAllocations() { + public Set getResourceAllocations() { return resourceAllocations; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java b/compute/src/main/java/org/jclouds/ovf/VirtualSystem.java similarity index 99% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java rename to compute/src/main/java/org/jclouds/ovf/VirtualSystem.java index 0afc741bc6..2ef005430e 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java +++ b/compute/src/main/java/org/jclouds/ovf/VirtualSystem.java @@ -17,13 +17,14 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain.ovf; +package org.jclouds.ovf; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Set; + import com.google.common.collect.Iterables; import com.google.common.collect.Sets; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/NetworkSectionHandler.java b/compute/src/main/java/org/jclouds/ovf/xml/NetworkSectionHandler.java similarity index 74% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/NetworkSectionHandler.java rename to compute/src/main/java/org/jclouds/ovf/xml/NetworkSectionHandler.java index d0a7d7e7a9..935891af51 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/NetworkSectionHandler.java +++ b/compute/src/main/java/org/jclouds/ovf/xml/NetworkSectionHandler.java @@ -17,15 +17,18 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml.ovf; +package org.jclouds.ovf.xml; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; import java.util.Map; import java.util.Set; import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ovf.NetworkSection; -import org.jclouds.vcloud.domain.ovf.network.Network; -import org.jclouds.vcloud.util.Utils; +import org.jclouds.ovf.Network; +import org.jclouds.ovf.NetworkSection; +import org.jclouds.util.SaxUtils; import org.xml.sax.Attributes; import com.google.common.collect.Sets; @@ -50,19 +53,19 @@ public class NetworkSectionHandler extends ParseSax.HandlerWithResult attributes = Utils.cleanseAttributes(attrs); - if (qName.endsWith("Network")) { + Map attributes = SaxUtils.cleanseAttributes(attrs); + if (equalsOrSuffix(qName, "Network")) { name = attributes.get("name"); } } @Override public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("Info")) { - this.info = currentOrNull(); - } else if (qName.endsWith("Description")) { - this.description = currentOrNull(); - } else if (qName.endsWith("Network")) { + if (equalsOrSuffix(qName, "Info")) { + this.info = currentOrNull(currentText); + } else if (equalsOrSuffix(qName, "Description")) { + this.description = currentOrNull(currentText); + } else if (equalsOrSuffix(qName, "Network")) { this.networks.add(new Network(name, description)); } currentText = new StringBuilder(); @@ -72,8 +75,4 @@ public class NetworkSectionHandler extends ParseSax.HandlerWithResult attributes = Utils.cleanseAttributes(attrs); - if (qName.endsWith("OperatingSystemSection")) { + Map attributes = cleanseAttributes(attrs); + if (equalsOrSuffix(qName, "OperatingSystemSection")) { if (attributes.containsKey("id")) this.id = Integer.parseInt(attributes.get("id")); } @@ -55,10 +58,10 @@ public class OperatingSystemSectionHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); - private final SystemHandler systemHandler; - private final VCloudResourceAllocationHandler allocationHandler; + private final VirtualSystemSettingDataHandler systemHandler; + private final ResourceAllocationSettingDataHandler allocationHandler; @Inject - public VirtualHardwareSectionHandler(SystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) { + public VirtualHardwareSectionHandler(VirtualSystemSettingDataHandler systemHandler, + ResourceAllocationSettingDataHandler allocationHandler) { this.systemHandler = systemHandler; this.allocationHandler = allocationHandler; } private String info; - protected System system; - protected Set allocations = Sets.newLinkedHashSet(); + protected VirtualSystemSettingData system; + protected Set allocations = Sets.newLinkedHashSet(); private boolean inItem; private boolean inSystem; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandler.java b/compute/src/main/java/org/jclouds/ovf/xml/VirtualSystemHandler.java similarity index 79% rename from apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandler.java rename to compute/src/main/java/org/jclouds/ovf/xml/VirtualSystemHandler.java index 63e69c1e77..dbfb795f03 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandler.java +++ b/compute/src/main/java/org/jclouds/ovf/xml/VirtualSystemHandler.java @@ -17,9 +17,10 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml.ovf; +package org.jclouds.ovf.xml; -import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.cleanseAttributes; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; import java.util.Map; import java.util.Set; @@ -27,10 +28,9 @@ import java.util.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ovf.OperatingSystemSection; -import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection; -import org.jclouds.vcloud.domain.ovf.VirtualSystem; -import org.jclouds.vcloud.xml.VirtualHardwareSectionHandler; +import org.jclouds.ovf.OperatingSystemSection; +import org.jclouds.ovf.VirtualHardwareSection; +import org.jclouds.ovf.VirtualSystem; import org.xml.sax.Attributes; import com.google.common.collect.Sets; @@ -72,13 +72,13 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult attributes = cleanseAttributes(attrs); - if (qName.endsWith("VirtualHardwareSection")) { + if (equalsOrSuffix(qName, "VirtualHardwareSection")) { inHardware = true; - } else if (qName.endsWith("OperatingSystemSection")) { + } else if (equalsOrSuffix(qName, "OperatingSystemSection")) { inOs = true; - } else if (qName.endsWith("NetworkConnectionSection")) { + } else if (equalsOrSuffix(qName, "NetworkConnectionSection")) { inNetwork = true; - } else if (qName.endsWith("GuestCustomizationSection")) { + } else if (equalsOrSuffix(qName, "GuestCustomizationSection")) { inGuest = true; } @@ -90,7 +90,7 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult + * + * ==================================================================== + * 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.cim.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; + +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code ResourceAllocationSettingDataHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "ResourceAllocationSettingDataHandlerTest") +public class ResourceAllocationSettingDataHandlerTest extends BaseHandlerTest { + + public void testNormal() { + InputStream is = getClass().getResourceAsStream("/resourceallocation.xml"); + + ResourceAllocationSettingData result = factory.create( + injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); + + ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().allocationUnits("Gigabytes") + .caption("1234568").description("Hard Disk").elementName("D:\\").hostResource("data").instanceID("6") + .resourceType(ResourceAllocationSettingData.ResourceType.PARTITIONABLE_UNIT).virtualQuantity(50l) + .build(); + assertEquals(result.toString(), expects.toString()); + } + + public void testHosting() { + InputStream is = getClass().getResourceAsStream("/resourceallocation-hosting.xml"); + + ResourceAllocationSettingData result = factory.create( + injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is); + + ResourceAllocationSettingData expects = ResourceAllocationSettingData.builder().elementName("1 virtual CPU(s)") + .allocationUnits("hertz * 10^6").instanceID("1").resourceType(ResourceAllocationSettingData.ResourceType.PROCESSOR) + .virtualQuantity(1l).description("Number of Virtual CPUs").virtualQuantityUnits("count").build(); + assertEquals(result.toString(), expects.toString()); + + } +} diff --git a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java new file mode 100644 index 0000000000..1f0f3e97bb --- /dev/null +++ b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java @@ -0,0 +1,131 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.cim.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; + +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; +import org.jclouds.cim.xml.VirtualSystemSettingDataHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.ovf.OperatingSystemSection; +import org.jclouds.ovf.VirtualHardwareSection; +import org.jclouds.ovf.VirtualSystem; +import org.jclouds.ovf.xml.VirtualSystemHandler; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code VirtualSystemSettingDataHandler} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "VirtualSystemSettingDataHandlerTest") +public class VirtualSystemSettingDataHandlerTest extends BaseHandlerTest { + + public void testApplyInputStream() { + InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml"); + + VirtualSystemSettingData result = factory.create(injector.getInstance(VirtualSystemSettingDataHandler.class)) + .parse(is); + + VirtualSystemSettingData expects = VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("SimpleVM").virtualSystemType("vmx-04").build(); + assertEquals(result, expects); + + } + + public void testVCloud1_0() { + InputStream is = getClass().getResourceAsStream("/virtualsystem.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)).parse(is); + checkVirtualSystem(result); + } + + @Test(enabled = false) + public static void checkVirtualSystem(VirtualSystem result) { + assertEquals(result.getId(), "Ubuntu1004"); + assertEquals(result.getName(), "Ubuntu1004"); + assertEquals(result.getInfo(), "A virtual machine:"); + checkHardware(Iterables.get(result.getHardware(), 0)); + checkOs(result.getOperatingSystem()); + } + + @Test(enabled = false) + public static void checkHardware(VirtualHardwareSection result) { + assertEquals(result.getSystem(), VirtualSystemSettingData.builder().instanceID("0").elementName( + "Virtual Hardware Family").virtualSystemIdentifier("Ubuntu1004").virtualSystemType("vmx-07").build()); + assertEquals(result.getInfo(), "Virtual hardware requirements"); + + assertEquals(Iterables.get(result.getResourceAllocations(), 0).toString(), ResourceAllocationSettingData + .builder().instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter") + .resourceType(ResourceType.ETHERNET_ADAPTER).resourceSubType("PCNet32").address("00:50:56:8c:00:13") + .automaticAllocation(true).connection("vAppNet-vApp Internal").addressOnParent("0").build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 1).toString(), ResourceAllocationSettingData + .builder().instanceID("2").elementName("SCSI Controller 0").description("SCSI Controller").resourceType( + ResourceType.PARALLEL_SCSI_HBA).resourceSubType("lsilogic").address("0").build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 2).toString(), ResourceAllocationSettingData + .builder().instanceID("2000").elementName("Hard disk 1").description("Hard disk").resourceType( + ResourceType.DISK_DRIVE).addressOnParent("0").parent("2").build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 3).toString(), ResourceAllocationSettingData + .builder().instanceID("3").elementName("IDE Controller 0").description("IDE Controller").resourceType( + ResourceType.IDE_CONTROLLER).address("0").build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 4).toString(), ResourceAllocationSettingData + .builder().instanceID("3002").elementName("CD/DVD Drive 1").description("CD/DVD Drive").resourceType( + ResourceType.CD_DRIVE).addressOnParent("0").parent("3").automaticAllocation(false).build() + .toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 5).toString(), ResourceAllocationSettingData + .builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType( + ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 6).toString(), ResourceAllocationSettingData + .builder().instanceID("4").elementName("1 virtual CPU(s)").description("Number of Virtual CPUs") + .resourceType(ResourceType.PROCESSOR).virtualQuantity(1l).allocationUnits("hertz * 10^6") + .reservation(0l).weight(0).build().toString()); + + assertEquals(Iterables.get(result.getResourceAllocations(), 7).toString(), ResourceAllocationSettingData + .builder().instanceID("5").elementName("512 MB of memory").description("Memory Size").resourceType( + ResourceType.MEMORY).virtualQuantity(512l).allocationUnits("byte * 2^20").reservation(0l) + .weight(0).build().toString()); + } + + @Test(enabled = false) + public static void checkOs(OperatingSystemSection result) { + assertEquals(result.getDescription(), "Ubuntu Linux (64-bit)"); + assertEquals(result.getId(), new Integer(94)); + assertEquals(result.getInfo(), "Specifies the operating system installed"); + } +} diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index efe574ff5b..17e857c56b 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -35,9 +35,9 @@ import java.util.concurrent.TimeoutException; import org.jclouds.Constants; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; diff --git a/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java index 63c1374481..0954233946 100755 --- a/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/OperatingSystemPredicatesTest.java @@ -23,10 +23,10 @@ import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsA import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsYum; import static org.jclouds.compute.predicates.OperatingSystemPredicates.supportsZypper; +import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.os.CIMOperatingSystem; -import org.jclouds.compute.domain.os.CIMOperatingSystem.OSType; +import org.jclouds.compute.domain.CIMOperatingSystem.OSType; import org.testng.annotations.Test; /** diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java b/compute/src/test/java/org/jclouds/ovf/xml/OvfEnvelopeHandlerTest.java similarity index 86% rename from apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java rename to compute/src/test/java/org/jclouds/ovf/xml/OvfEnvelopeHandlerTest.java index 789014a721..9968887ee9 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java +++ b/compute/src/test/java/org/jclouds/ovf/xml/OvfEnvelopeHandlerTest.java @@ -17,14 +17,16 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml.ovf; +package org.jclouds.ovf.xml; import java.io.InputStream; +import org.jclouds.cim.xml.VirtualSystemSettingDataHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.ovf.OvfEnvelope; +import org.jclouds.ovf.OvfEnvelope; +import org.jclouds.ovf.xml.OvfEnvelopeHandler; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -46,7 +48,7 @@ public class OvfEnvelopeHandlerTest { } static void checkOvfEnvelope(OvfEnvelope result) { - VirtualSystemHandlerTest.checkVirtualSystem(result.getVirtualSystem()); + VirtualSystemSettingDataHandlerTest.checkVirtualSystem(result.getVirtualSystem()); } } diff --git a/compute/src/test/resources/os.xml b/compute/src/test/resources/os.xml new file mode 100644 index 0000000000..3196a272f6 --- /dev/null +++ b/compute/src/test/resources/os.xml @@ -0,0 +1,11 @@ + + Specifies the operating system installed + Red Hat Enterprise Linux 5 (64-bit) + + \ No newline at end of file diff --git a/apis/vcloud/src/test/resources/ovf.xml b/compute/src/test/resources/ovf.xml similarity index 100% rename from apis/vcloud/src/test/resources/ovf.xml rename to compute/src/test/resources/ovf.xml diff --git a/common/vcloud/src/test/resources/resourceallocation-hosting.xml b/compute/src/test/resources/resourceallocation-hosting.xml similarity index 100% rename from common/vcloud/src/test/resources/resourceallocation-hosting.xml rename to compute/src/test/resources/resourceallocation-hosting.xml diff --git a/sandbox-providers/savvis-symphonyvpdc/src/test/resources/resourceallocation.xml b/compute/src/test/resources/resourceallocation.xml similarity index 100% rename from sandbox-providers/savvis-symphonyvpdc/src/test/resources/resourceallocation.xml rename to compute/src/test/resources/resourceallocation.xml diff --git a/compute/src/test/resources/virtualhardwaresection.xml b/compute/src/test/resources/virtualhardwaresection.xml new file mode 100644 index 0000000000..24a0dd6e53 --- /dev/null +++ b/compute/src/test/resources/virtualhardwaresection.xml @@ -0,0 +1,118 @@ + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + RHEL5 + vmx-07 + + + 00:50:56:01:01:f2 + 0 + true + internet01 + PCNet32 ethernet adapter + Network adapter 0 + 1 + PCNet32 + 10 + + + 0 + SCSI Controller + SCSI Controller 0 + 2 + lsilogic + 6 + + + 0 + Hard disk + Hard disk 1 + + 2000 + 2 + 17 + + + 0 + IDE Controller + IDE Controller 0 + 3 + 5 + + + 0 + false + CD/DVD Drive + CD/DVD Drive 1 + + 3002 + 3 + 15 + + + 0 + false + Floppy Drive + Floppy Drive 1 + + 8000 + 14 + + + hertz * 10^6 + Number of Virtual CPUs + 1 virtual CPU(s) + 4 + 0 + 3 + 1 + 0 + + + + byte * 2^20 + Memory Size + 384 MB of memory + 5 + 0 + 4 + 384 + 0 + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/vcloud/src/test/resources/virtualsystem-hosting.xml b/compute/src/test/resources/virtualsystem-hosting.xml similarity index 100% rename from common/vcloud/src/test/resources/virtualsystem-hosting.xml rename to compute/src/test/resources/virtualsystem-hosting.xml diff --git a/apis/vcloud/src/test/resources/virtualsystem.xml b/compute/src/test/resources/virtualsystem.xml similarity index 100% rename from apis/vcloud/src/test/resources/virtualsystem.xml rename to compute/src/test/resources/virtualsystem.xml diff --git a/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java b/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java index 419f16f284..89f221709a 100755 --- a/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java +++ b/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java @@ -50,6 +50,8 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Inject; import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Provides; import com.google.inject.TypeLiteral; @Singleton @@ -73,7 +75,7 @@ public class AsyncRestClientProxy implements InvocationHandler { @SuppressWarnings("unchecked") @Inject public AsyncRestClientProxy(Injector injector, Factory factory, RestAnnotationProcessor util, - TypeLiteral typeLiteral, @Named("async") ConcurrentMap delegateMap) { + TypeLiteral typeLiteral, @Named("async") ConcurrentMap delegateMap) { this.injector = injector; this.annotationProcessor = util; this.declaring = (Class) typeLiteral.getRawType(); @@ -88,24 +90,24 @@ public class AsyncRestClientProxy implements InvocationHandler { return this.toString(); } else if (method.getName().equals("hashCode")) { return this.hashCode(); - } else if (method.getName().startsWith("new")) { - return injector.getInstance(method.getReturnType()); + } else if (method.isAnnotationPresent(Provides.class)) { + return injector.getInstance(Key.get(method.getGenericReturnType())); } else if (method.isAnnotationPresent(Delegate.class)) { return delegateMap.get(new ClassMethodArgs(method.getReturnType(), method, args)); } else if (annotationProcessor.getDelegateOrNull(method) != null - && ListenableFuture.class.isAssignableFrom(method.getReturnType())) { + && ListenableFuture.class.isAssignableFrom(method.getReturnType())) { return createListenableFuture(method, args); } else { throw new RuntimeException("method is intended solely to set constants: " + method); } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings( { "unchecked", "rawtypes" }) private ListenableFuture createListenableFuture(Method method, Object[] args) throws ExecutionException { method = annotationProcessor.getDelegateOrNull(method); logger.trace("Converting %s.%s", declaring.getSimpleName(), method.getName()); Function exceptionParser = annotationProcessor - .createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method); + .createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method); // in case there is an exception creating the request, we should at least // pass in args if (exceptionParser instanceof InvocationContext) { @@ -121,7 +123,7 @@ public class AsyncRestClientProxy implements InvocationHandler { Function transformer = annotationProcessor.createResponseParser(method, request); logger.trace("Response from %s.%s is parsed by %s", declaring.getSimpleName(), method.getName(), transformer - .getClass().getSimpleName()); + .getClass().getSimpleName()); logger.debug("Invoking %s.%s", declaring.getSimpleName(), method.getName()); result = commandFactory.create(request, transformer).execute(); @@ -142,7 +144,7 @@ public class AsyncRestClientProxy implements InvocationHandler { if (exceptionParser != null) { logger.trace("Exceptions from %s.%s are parsed by %s", declaring.getSimpleName(), method.getName(), - exceptionParser.getClass().getSimpleName()); + exceptionParser.getClass().getSimpleName()); result = new ExceptionParsingListenableFuture(result, exceptionParser); } return result; diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index 544eedc73d..c3172079ab 100755 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -145,6 +145,7 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; +import com.google.inject.Provides; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; import com.google.inject.util.Types; @@ -327,7 +328,9 @@ public class RestAnnotationProcessor { logger.trace("skipping potentially overridden method %s", method); } else if (method.isAnnotationPresent(Delegate.class)) { logger.trace("skipping delegate method %s", method); - } else if (!method.getName().startsWith("new")) { + } else if (method.isAnnotationPresent(Provides.class)) { + logger.trace("skipping provider method %s", method); + } else { logger.trace("Method is not annotated as either http or constant: %s", method); } } diff --git a/core/src/main/java/org/jclouds/util/SaxUtils.java b/core/src/main/java/org/jclouds/util/SaxUtils.java index d6a20265be..3d0f327dd2 100644 --- a/core/src/main/java/org/jclouds/util/SaxUtils.java +++ b/core/src/main/java/org/jclouds/util/SaxUtils.java @@ -19,28 +19,37 @@ package org.jclouds.util; - import java.util.Map; - import org.xml.sax.Attributes; -import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; /** * * @author Adrian Cole */ public class SaxUtils { + + public static boolean equalsOrSuffix(String val, String expected) { + return expected.equals(val) || val.endsWith(":" + expected); + } + public static Map cleanseAttributes(Attributes in) { - Map attrs = Maps.newLinkedHashMap(); + Builder attrs = ImmutableMap. builder(); for (int i = 0; i < in.getLength(); i++) { String name = in.getQName(i); if (name.indexOf(':') != -1) name = name.substring(name.indexOf(':') + 1); attrs.put(name, in.getValue(i)); } - return attrs; + return attrs.build(); + } + + public static String currentOrNull(StringBuilder currentText) { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; } } diff --git a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java index 30f5e96f19..23a070ac66 100644 --- a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java +++ b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -37,7 +38,9 @@ import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Tests behavior of ListenableFutureExceptionParser @@ -58,6 +61,9 @@ public class SyncProxyTest { String newString(); + @Provides + Set string(); + String getRuntimeException(); String getTypedException() throws FileNotFoundException; @@ -112,6 +118,11 @@ public class SyncProxyTest { return "new"; } + @Provides + public Set string() { + return ImmutableSet.of("new"); + } + public ListenableFuture take20Milliseconds() { return Futures.makeListenable(executorService.submit(new Callable() { @@ -153,7 +164,7 @@ public class SyncProxyTest { @BeforeTest public void setUp() throws IllegalArgumentException, SecurityException, NoSuchMethodException { sync = SyncProxy.proxy(Sync.class, new SyncProxy(Sync.class, new Async(), - new ConcurrentHashMap(), ImmutableMap., Class> of())); + new ConcurrentHashMap(), ImmutableMap., Class> of())); } @Test @@ -164,6 +175,7 @@ public class SyncProxyTest { @Test public void testPassSync() { assertEquals(sync.newString(), "new"); + assertEquals(sync.string(), ImmutableSet.of("new")); } @Test diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java b/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java index 91c8cbda9b..524f841210 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestAsyncClient.java @@ -54,6 +54,7 @@ import org.jclouds.util.Strings2; import com.google.common.base.Function; import com.google.common.collect.Multimap; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Sample test for the behaviour of our Integration Test jetty server. @@ -199,6 +200,7 @@ public interface IntegrationTestAsyncClient { } + @Provides StringBuffer newStringBuffer(); } diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestClient.java b/core/src/test/java/org/jclouds/http/IntegrationTestClient.java index 065732974b..011ca9d6fc 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestClient.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestClient.java @@ -27,6 +27,7 @@ import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.io.Payload; import com.google.common.collect.Multimap; +import com.google.inject.Provides; /** * Sample test for the behaviour of our Integration Test jetty server. @@ -67,5 +68,6 @@ public interface IntegrationTestClient { String downloadAndParse(String id); + @Provides StringBuffer newStringBuffer(); } diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index ac60d1cf47..61750a9e81 100755 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -107,6 +107,7 @@ import org.jclouds.io.Payload; import org.jclouds.io.PayloadEnclosing; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.InvocationContext; @@ -156,6 +157,8 @@ import com.google.inject.ConfigurationException; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; import com.sun.jersey.api.uri.UriBuilderImpl; /** @@ -212,7 +215,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @SuppressWarnings("unchecked") public void testDelegateAsyncIncludesVersion() throws SecurityException, NoSuchMethodException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { Injector child = injectorForClient(); TransformingHttpCommandExecutorService mock = child.getInstance(TransformingHttpCommandExecutorService.class); @@ -227,7 +230,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { AsyncCaller caller = child.getInstance(AsyncCaller.class); expect(mock.submit(requestLineEquals("GET http://localhost:9999/client/1/foo HTTP/1.1"), eq(function))) - .andReturn(createNiceMock(ListenableFuture.class)).atLeastOnce(); + .andReturn(createNiceMock(ListenableFuture.class)).atLeastOnce(); replay(mock); caller.getCallee().onePath("foo"); @@ -256,7 +259,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } public void testDelegateWithOverridingEndpoint() throws SecurityException, NoSuchMethodException, - InterruptedException, ExecutionException { + InterruptedException, ExecutionException { Injector child = injectorForClient(); TransformingHttpCommandExecutorService mock = child.getInstance(TransformingHttpCommandExecutorService.class); @@ -271,7 +274,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { Caller caller = child.getInstance(Caller.class); expect(mock.submit(requestLineEquals("GET http://localhost:1111/client/1/foo HTTP/1.1"), eq(function))) - .andReturn(Futures. immediateFuture(null)).atLeastOnce(); + .andReturn(Futures. immediateFuture(null)).atLeastOnce(); replay(mock); caller.getCallee().onePath("foo"); @@ -283,8 +286,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { private Injector injectorForClient() { RestContextSpec contextSpec = contextSpec("test", "http://localhost:9999", "1", "", - "userfoo", null, Caller.class, AsyncCaller.class, - ImmutableSet. of(new MockModule(), new NullLoggingModule(), new CallerCalleeModule())); + "userfoo", null, Caller.class, AsyncCaller.class, ImmutableSet. of(new MockModule(), + new NullLoggingModule(), new CallerCalleeModule())); return createContextBuilder(contextSpec).buildInjector(); @@ -299,7 +302,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { }; - @Target({ ElementType.METHOD }) + @Target( { ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @javax.ws.rs.HttpMethod("FOO") public @interface FOO { @@ -334,10 +337,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testUnEncodeQuery() { URI expects = URI - .create("http://services.nirvanix.com/ws/Metadata/SetMetadata.ashx?output=json&path=adriancole-compute.testObjectOperations&metadata=chef:sushi&metadata=foo:bar&sessionToken=775ef26e-0740-4707-ad92-afe9814bc436"); + .create("http://services.nirvanix.com/ws/Metadata/SetMetadata.ashx?output=json&path=adriancole-compute.testObjectOperations&metadata=chef:sushi&metadata=foo:bar&sessionToken=775ef26e-0740-4707-ad92-afe9814bc436"); URI start = URI - .create("http://services.nirvanix.com/ws/Metadata/SetMetadata.ashx?output=json&path=adriancole-compute.testObjectOperations&metadata=chef%3Asushi&metadata=foo%3Abar&sessionToken=775ef26e-0740-4707-ad92-afe9814bc436"); + .create("http://services.nirvanix.com/ws/Metadata/SetMetadata.ashx?output=json&path=adriancole-compute.testObjectOperations&metadata=chef%3Asushi&metadata=foo%3Abar&sessionToken=775ef26e-0740-4707-ad92-afe9814bc436"); URI value = RestAnnotationProcessor.replaceQuery(uriBuilderProvider, start, start.getQuery(), null, '/', ':'); assertEquals(value, expects); } @@ -408,7 +411,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testPayloadParamVarargs() throws SecurityException, NoSuchMethodException, IOException { Method method = TestPayloadParamVarargs.class.getMethod("varargs", Array.newInstance(HttpRequestOptions.class, 0) - .getClass()); + .getClass()); verifyTestPostOptions(method); } @@ -501,7 +504,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testOverriddenEndpointParameter() throws SecurityException, NoSuchMethodException { Method method = TestOverriddenEndpoint.class.getMethod("foo", URI.class); HttpRequest request = factory(TestOverriddenEndpoint.class).createRequest(method, - new Object[] { URI.create("http://wowsa:8001") }); + new Object[] { URI.create("http://wowsa:8001") }); assertEquals(request.getEndpoint().getHost(), "wowsa"); assertEquals(request.getEndpoint().getPort(), 8001); assertEquals(request.getEndpoint().getPath(), ""); @@ -622,44 +625,44 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @POST void withParamFileBinaryPart(@FormParam("name") String name, - @PartParam(name = "file", contentType = MediaType.APPLICATION_OCTET_STREAM) File path); + @PartParam(name = "file", contentType = MediaType.APPLICATION_OCTET_STREAM) File path); @POST void withParamByteArrayBinaryPart( - @FormParam("name") String name, - @PartParam(name = "file", contentType = MediaType.APPLICATION_OCTET_STREAM, filename = "{name}.tar.gz") byte[] content); + @FormParam("name") String name, + @PartParam(name = "file", contentType = MediaType.APPLICATION_OCTET_STREAM, filename = "{name}.tar.gz") byte[] content); } public void testMultipartWithStringPart() throws SecurityException, NoSuchMethodException, IOException { Method method = TestMultipartForm.class.getMethod("withStringPart", String.class); GeneratedHttpRequest httpRequest = factory(TestMultipartForm.class).createRequest(method, - "foobledata"); + "foobledata"); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest,// - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"fooble\"\r\n" + // - "\r\n" + // - "foobledata\r\n" + // - "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"fooble\"\r\n" + // + "\r\n" + // + "foobledata\r\n" + // + "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); } public void testMultipartWithParamStringPart() throws SecurityException, NoSuchMethodException, IOException { Method method = TestMultipartForm.class.getMethod("withParamStringPart", String.class, String.class); GeneratedHttpRequest httpRequest = factory(TestMultipartForm.class).createRequest(method, - "name", "foobledata"); + "name", "foobledata"); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest,// - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"name\"\r\n" + // - "\r\n" + // - "name\r\n" + // / - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"file\"\r\n" + // - "\r\n" + // - "foobledata\r\n" + // - "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"name\"\r\n" + // + "\r\n" + // + "name\r\n" + // / + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"file\"\r\n" + // + "\r\n" + // + "foobledata\r\n" + // + "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); } public void testMultipartWithParamFilePart() throws SecurityException, NoSuchMethodException, IOException { @@ -669,38 +672,38 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { file.deleteOnExit(); GeneratedHttpRequest httpRequest = factory(TestMultipartForm.class).createRequest(method, - "name", file); + "name", file); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest,// - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"name\"\r\n" + // - "\r\n" + // - "name\r\n" + // / - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + // - "\r\n" + // - "foobledata\r\n" + // - "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"name\"\r\n" + // + "\r\n" + // + "name\r\n" + // / + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + // + "\r\n" + // + "foobledata\r\n" + // + "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); } public void testMultipartWithParamByteArrayPart() throws SecurityException, NoSuchMethodException, IOException { Method method = TestMultipartForm.class.getMethod("withParamByteArrayBinaryPart", String.class, byte[].class); GeneratedHttpRequest httpRequest = factory(TestMultipartForm.class).createRequest(method, - "name", "goo".getBytes()); + "name", "goo".getBytes()); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest,// - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"name\"\r\n" + // - "\r\n" + // - "name\r\n" + // / - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"file\"; filename=\"name.tar.gz\"\r\n" + // - "Content-Type: application/octet-stream\r\n" + // - "\r\n" + // - "goo\r\n" + // - "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"name\"\r\n" + // + "\r\n" + // + "name\r\n" + // / + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"file\"; filename=\"name.tar.gz\"\r\n" + // + "Content-Type: application/octet-stream\r\n" + // + "\r\n" + // + "goo\r\n" + // + "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); }; public void testMultipartWithParamFileBinaryPart() throws SecurityException, NoSuchMethodException, IOException { @@ -710,20 +713,20 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { file.deleteOnExit(); GeneratedHttpRequest httpRequest = factory(TestMultipartForm.class).createRequest(method, - "name", file); + "name", file); assertRequestLineEquals(httpRequest, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest,// - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"name\"\r\n" + // - "\r\n" + // - "name\r\n" + // / - "----JCLOUDS--\r\n" + // - "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + // - "Content-Type: application/octet-stream\r\n" + // - "\r\n" + // - "'(2\r\n" + // - "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"name\"\r\n" + // + "\r\n" + // + "name\r\n" + // / + "----JCLOUDS--\r\n" + // + "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n" + // + "Content-Type: application/octet-stream\r\n" + // + "\r\n" + // + "'(2\r\n" + // + "----JCLOUDS----\r\n", "multipart/form-data; boundary=--JCLOUDS--", false); } public interface TestPut { @@ -800,7 +803,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Consumes(MediaType.APPLICATION_JSON) ListenableFuture testUnwrapDepth3(); - @Target({ ElementType.METHOD }) + @Target( { ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) @HttpMethod("ROWDY") public @interface ROWDY { @@ -855,7 +858,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function parser = (Function) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))).foo, "bar"); @@ -870,10 +873,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); - assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), - ImmutableMap.of("foo", "bar")); + assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), ImmutableMap.of( + "foo", "bar")); } @@ -886,10 +889,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); - assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), - ImmutableMap.of("foo", "bar")); + assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), ImmutableMap.of( + "foo", "bar")); } @@ -902,10 +905,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); - assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), - ImmutableMap.of("foo", "bar")); + assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), ImmutableMap.of( + "foo", "bar")); } @@ -918,7 +921,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), "bar"); @@ -933,7 +936,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{ foo:\"bar\"}"))), "bar"); @@ -948,10 +951,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":[\"0.7.0\",\"0.7.1\"]}"))), - ImmutableSet.of("0.7.0", "0.7.1")); + ImmutableSet.of("0.7.0", "0.7.1")); } @SuppressWarnings("unchecked") @@ -963,10 +966,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":[\"0.7.0\",\"0.7.1\"]}"))), - ImmutableSet.of("0.7.0", "0.7.1")); + ImmutableSet.of("0.7.0", "0.7.1")); } @SuppressWarnings("unchecked") @@ -978,13 +981,13 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", - newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\",\"0.7.1\"]}}"))), ImmutableSet.of("0.7.0", "0.7.1")); + newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\",\"0.7.1\"]}}"))), ImmutableSet.of("0.7.0", "0.7.1")); - assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{}}"))), - ImmutableSet. of()); + assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{}}"))), ImmutableSet + . of()); } @SuppressWarnings("unchecked") @@ -996,10 +999,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", - newStringPayload("{ \"destroyvirtualmachineresponse\" : {\"jobid\":4} }"))), new Long(4)); + newStringPayload("{ \"destroyvirtualmachineresponse\" : {\"jobid\":4} }"))), new Long(4)); } @SuppressWarnings("unchecked") @@ -1011,10 +1014,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\"]}}"))), - "0.7.0"); + "0.7.0"); } @SuppressWarnings("unchecked") @@ -1026,7 +1029,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{\"runit\":[]}}"))), null); assertEquals(parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{}}"))), null); @@ -1043,7 +1046,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { // now test that it works! Function> parser = (Function>) RestAnnotationProcessor - .createResponseParser(parserFactory, injector, method, request); + .createResponseParser(parserFactory, injector, method, request); parser.apply(new HttpResponse(200, "ok", newStringPayload("{\"runit\":{\"runit\":[\"0.7.0\",\"0.7.1\"]}}"))); } @@ -1095,9 +1098,9 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testRequestFilterOverrideOnRequest() throws SecurityException, NoSuchMethodException { Method method = TestRequestFilter.class.getMethod("getOverride", HttpRequest.class); HttpRequest request = factory(TestRequestFilter.class).createRequest( - method, - HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")) - .headers(ImmutableMultimap.of("foo", "bar")).build()); + method, + HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).headers( + ImmutableMultimap.of("foo", "bar")).build()); assertEquals(request.getFilters().size(), 1); assertEquals(request.getHeaders().size(), 1); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter2.class); @@ -1145,7 +1148,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testConstantPathParam() throws SecurityException, NoSuchMethodException, IOException { Method method = TestConstantPathParam.class.getMethod("twoPaths", String.class, String.class); HttpRequest request = factory(TestConstantPathParam.class).createRequest(method, - new Object[] { "1", "localhost" }); + new Object[] { "1", "localhost" }); assertRequestLineEquals(request, "GET http://localhost:9999/v1/ralphie/1/localhost HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); @@ -1282,7 +1285,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoHeader() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneHeader = TestHeader.class.getMethod("twoHeader", String.class); Multimap headers = factory(TestHeader.class).createRequest(oneHeader, new Object[] { "robot" }) - .getHeaders(); + .getHeaders(); assertEquals(headers.size(), 2); assertEquals(headers.get("slash"), Collections.singletonList("/robot")); assertEquals(headers.get("hyphen"), Collections.singletonList("-robot")); @@ -1300,7 +1303,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneClassHeader() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneHeader = TestClassHeader.class.getMethod("oneHeader", String.class); Multimap headers = factory(TestClassHeader.class).createRequest(oneHeader, - new Object[] { "robot" }).getHeaders(); + new Object[] { "robot" }).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), Collections.singletonList("/robot")); } @@ -1309,7 +1312,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneHeader() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneHeader = TestHeader.class.getMethod("oneHeader", String.class); Multimap headers = factory(TestHeader.class).createRequest(oneHeader, new Object[] { "robot" }) - .getHeaders(); + .getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), Collections.singletonList("/robot")); } @@ -1318,17 +1321,17 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoHeaders() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method twoHeaders = TestHeader.class.getMethod("twoHeaders", String.class, String.class); Multimap headers = factory(TestHeader.class).createRequest(twoHeaders, - new Object[] { "robot", "eggs" }).getHeaders(); + new Object[] { "robot", "eggs" }).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), Collections.singletonList("/robot/eggs")); } @Test public void testBuildTwoHeadersOutOfOrder() throws SecurityException, NoSuchMethodException, - UnsupportedEncodingException { + UnsupportedEncodingException { Method twoHeadersOutOfOrder = TestHeader.class.getMethod("twoHeadersOutOfOrder", String.class, String.class); Multimap headers = factory(TestHeader.class).createRequest(twoHeadersOutOfOrder, - new Object[] { "robot", "eggs" }).getHeaders(); + new Object[] { "robot", "eggs" }).getHeaders(); assertEquals(headers.size(), 1); assertEquals(headers.get("x-amz-copy-source"), Collections.singletonList("/eggs/robot")); } @@ -1342,8 +1345,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Test public void testQueryInOptions() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneQuery = TestQueryReplace.class.getMethod("queryInOptions", String.class, TestReplaceQueryOptions.class); - String query = factory(TestQueryReplace.class) - .createRequest(oneQuery, new Object[] { "robot", new TestReplaceQueryOptions() }).getEndpoint().getQuery(); + String query = factory(TestQueryReplace.class).createRequest(oneQuery, + new Object[] { "robot", new TestReplaceQueryOptions() }).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); } @@ -1351,13 +1354,13 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @POST @Path("/objects/{id}/action/{action}") ListenableFuture action(@PathParam("id") String id, @PathParam("action") String action, - @BinderParam(BindMapToMatrixParams.class) Map options); + @BinderParam(BindMapToMatrixParams.class) Map options); } public void testTestMapMatrixParams() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method method = TestMapMatrixParams.class.getMethod("action", String.class, String.class, Map.class); HttpRequest request = factory(TestMapMatrixParams.class).createRequest(method, - new Object[] { "robot", "kill", ImmutableMap.of("death", "slow") }); + new Object[] { "robot", "kill", ImmutableMap.of("death", "slow") }); assertRequestLineEquals(request, "POST http://localhost:9999/objects/robot/action/kill;death=slow HTTP/1.1"); assertEquals(request.getHeaders().size(), 0); } @@ -1399,7 +1402,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoQuery() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneQuery = TestQueryReplace.class.getMethod("twoQuery", String.class); String query = factory(TestQueryReplace.class).createRequest(oneQuery, new Object[] { "robot" }).getEndpoint() - .getQuery(); + .getQuery(); assertEquals(query, "slash=/robot&hyphen=-robot"); } @@ -1415,7 +1418,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneClassQuery() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneQuery = TestClassQuery.class.getMethod("oneQuery", String.class); String query = factory(TestClassQuery.class).createRequest(oneQuery, new Object[] { "robot" }).getEndpoint() - .getQuery(); + .getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); } @@ -1423,7 +1426,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneQuery() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneQuery = TestQueryReplace.class.getMethod("oneQuery", String.class); String query = factory(TestQueryReplace.class).createRequest(oneQuery, new Object[] { "robot" }).getEndpoint() - .getQuery(); + .getQuery(); assertEquals(query, "x-amz-copy-source=/robot"); } @@ -1431,16 +1434,16 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoQuerys() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method twoQuerys = TestQueryReplace.class.getMethod("twoQuerys", String.class, String.class); String query = factory(TestQueryReplace.class).createRequest(twoQuerys, new Object[] { "robot", "eggs" }) - .getEndpoint().getQuery(); + .getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/robot/eggs"); } @Test public void testBuildTwoQuerysOutOfOrder() throws SecurityException, NoSuchMethodException, - UnsupportedEncodingException { + UnsupportedEncodingException { Method twoQuerysOutOfOrder = TestQueryReplace.class.getMethod("twoQuerysOutOfOrder", String.class, String.class); - String query = factory(TestQueryReplace.class) - .createRequest(twoQuerysOutOfOrder, new Object[] { "robot", "eggs" }).getEndpoint().getQuery(); + String query = factory(TestQueryReplace.class).createRequest(twoQuerysOutOfOrder, + new Object[] { "robot", "eggs" }).getEndpoint().getQuery(); assertEquals(query, "x-amz-copy-source=/eggs/robot"); } @@ -1453,9 +1456,9 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Test public void testMatrixInOptions() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneMatrix = TestMatrixReplace.class.getMethod("matrixInOptions", String.class, - TestReplaceMatrixOptions.class); - String path = factory(TestMatrixReplace.class) - .createRequest(oneMatrix, new Object[] { "robot", new TestReplaceMatrixOptions() }).getEndpoint().getPath(); + TestReplaceMatrixOptions.class); + String path = factory(TestMatrixReplace.class).createRequest(oneMatrix, + new Object[] { "robot", new TestReplaceMatrixOptions() }).getEndpoint().getPath(); assertEquals(path, "/;x-amz-copy-source=/robot"); } @@ -1496,7 +1499,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoMatrix() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneMatrix = TestMatrixReplace.class.getMethod("twoMatrix", String.class); String path = factory(TestMatrixReplace.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); + .getPath(); assertEquals(path, "/;slash=/robot;hyphen=-robot"); } @@ -1513,7 +1516,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneClassMatrix() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneMatrix = TestClassMatrix.class.getMethod("oneMatrix", String.class); String path = factory(TestClassMatrix.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); + .getPath(); assertEquals(path, "/;x-amz-copy-source=/robot"); } @@ -1521,7 +1524,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildOneMatrix() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method oneMatrix = TestMatrixReplace.class.getMethod("oneMatrix", String.class); String path = factory(TestMatrixReplace.class).createRequest(oneMatrix, new Object[] { "robot" }).getEndpoint() - .getPath(); + .getPath(); assertEquals(path, "/;x-amz-copy-source=/robot"); } @@ -1529,17 +1532,17 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoMatrixs() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method twoMatrixs = TestMatrixReplace.class.getMethod("twoMatrixs", String.class, String.class); String path = factory(TestMatrixReplace.class).createRequest(twoMatrixs, new Object[] { "robot", "eggs" }) - .getEndpoint().getPath(); + .getEndpoint().getPath(); assertEquals(path, "/;x-amz-copy-source=/robot/eggs"); } @Test public void testBuildTwoMatrixsOutOfOrder() throws SecurityException, NoSuchMethodException, - UnsupportedEncodingException { + UnsupportedEncodingException { Method twoMatrixsOutOfOrder = TestMatrixReplace.class.getMethod("twoMatrixsOutOfOrder", String.class, - String.class); - String path = factory(TestMatrixReplace.class) - .createRequest(twoMatrixsOutOfOrder, new Object[] { "robot", "eggs" }).getEndpoint().getPath(); + String.class); + String path = factory(TestMatrixReplace.class).createRequest(twoMatrixsOutOfOrder, + new Object[] { "robot", "eggs" }).getEndpoint().getPath(); assertEquals(path, "/;x-amz-copy-source=/eggs/robot"); } @@ -1581,7 +1584,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testPutPayloadEnclosing() throws SecurityException, NoSuchMethodException, IOException { Method method = TestTransformers.class.getMethod("put", PayloadEnclosing.class); HttpRequest request = factory(TestQuery.class).createRequest(method, - new PayloadEnclosingImpl(newStringPayload("whoops"))); + new PayloadEnclosingImpl(newStringPayload("whoops"))); assertRequestLineEquals(request, "PUT http://localhost:9999?x-ms-version=2009-07-17 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", false); @@ -1599,10 +1602,10 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } public void testPutInputStreamPayloadEnclosingGenerateMD5() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Method method = TestTransformers.class.getMethod("put", PayloadEnclosing.class); - PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl( - newInputStreamPayload(Strings2.toInputStream("whoops"))); + PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl(newInputStreamPayload(Strings2 + .toInputStream("whoops"))); calculateMD5(payloadEnclosing, crypto.md5()); HttpRequest request = factory(TestQuery.class).createRequest(method, payloadEnclosing); @@ -1659,7 +1662,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } public void testPutPayloadWithGeneratedMD5AndNoContentType() throws SecurityException, NoSuchMethodException, - IOException { + IOException { Payload payload = newStringPayload("whoops"); calculateMD5(payload, crypto.md5()); Method method = TestTransformers.class.getMethod("put", Payload.class); @@ -1680,7 +1683,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } public void testPutInputStreamPayloadWithMD5() throws NoSuchAlgorithmException, IOException, SecurityException, - NoSuchMethodException { + NoSuchMethodException { Payload payload = newStringPayload("whoops"); calculateMD5(payload, crypto.md5()); Method method = TestTransformers.class.getMethod("put", Payload.class); @@ -1704,9 +1707,9 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @SuppressWarnings("unchecked") public static Class> unwrap(RestAnnotationProcessor processor, - Method method) { + Method method) { return (Class>) RestAnnotationProcessor.getParserOrThrowException(method) - .getTypeLiteral().getRawType(); + .getTypeLiteral().getRawType(); } public void testURI() throws SecurityException, NoSuchMethodException { @@ -1722,7 +1725,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { } public static class ReturnStringIf200Context extends ReturnStringIf2xx implements - InvocationContext { + InvocationContext { public HttpRequest request; @@ -1744,8 +1747,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { RestAnnotationProcessor processor = factory(TestTransformers.class); Method method = TestTransformers.class.getMethod("oneTransformerWithContext"); GeneratedHttpRequest request = GeneratedHttpRequest. builder().method("GET") - .endpoint(URI.create("http://localhost")).declaring(TestTransformers.class).javaMethod(method) - .args(new Object[] {}).build(); + .endpoint(URI.create("http://localhost")).declaring(TestTransformers.class).javaMethod(method).args( + new Object[] {}).build(); Function transformer = processor.createResponseParser(method, request); assertEquals(transformer.getClass(), ReturnStringIf200Context.class); assertEquals(((ReturnStringIf200Context) transformer).request, request); @@ -1786,7 +1789,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @PUT @Path("/{id}") ListenableFuture put(@PathParam("id") @ParamParser(FirstCharacter.class) String id, - @BinderParam(BindToStringPayload.class) String payload); + @BinderParam(BindToStringPayload.class) String payload); @PUT @Path("/{id}") @@ -1798,7 +1801,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Headers(keys = "foo", values = "--{id}--") @ResponseParser(ReturnTrueIf2xx.class) ListenableFuture putHeader(@PathParam("id") String id, - @BinderParam(BindToStringPayload.class) String payload); + @BinderParam(BindToStringPayload.class) String payload); } public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { @@ -1812,8 +1815,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 2); assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999")); - assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE), - Collections.singletonList(dateService.rfc822DateFormat(date))); + assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE), Collections.singletonList(dateService + .rfc822DateFormat(date))); } public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException { @@ -1826,8 +1829,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 2); assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections.singletonList("localhost:9999")); - assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE), - Collections.singletonList(dateService.rfc822DateFormat(date))); + assertEquals(request.getHeaders().get(HttpHeaders.IF_MODIFIED_SINCE), Collections.singletonList(dateService + .rfc822DateFormat(date))); } public class PrefixOptions extends BaseHttpRequestOptions { @@ -1890,7 +1893,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @Test(dataProvider = "strings") public void testCreateGetRequest(String key) throws SecurityException, NoSuchMethodException, - UnsupportedEncodingException { + UnsupportedEncodingException { Method method = TestRequest.class.getMethod("get", String.class, String.class); HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { key, "localhost" }); assertEquals(request.getEndpoint().getHost(), "localhost"); @@ -1933,7 +1936,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testVirtualHostMethod() throws SecurityException, NoSuchMethodException { Method method = TestVirtualHostMethod.class.getMethod("get", String.class, String.class); HttpRequest request = factory(TestVirtualHostMethod.class).createRequest(method, - new Object[] { "1", "localhost" }); + new Object[] { "1", "localhost" }); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); @@ -1998,7 +2001,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testOneHeader() throws SecurityException, NoSuchMethodException { Method method = TestHeaders.class.getMethod("oneHeader", String.class); Multimap headers = factory(TestHeaders.class).buildHeaders( - ImmutableMultimap. of().entries(), method, "robot"); + ImmutableMultimap. of().entries(), method, "robot"); assertEquals(headers.size(), 1); assertEquals(headers.get("header"), Collections.singletonList("robot")); } @@ -2007,7 +2010,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testOneIntHeader() throws SecurityException, NoSuchMethodException { Method method = TestHeaders.class.getMethod("oneIntHeader", int.class); Multimap headers = factory(TestHeaders.class).buildHeaders( - ImmutableMultimap. of().entries(), method, 1); + ImmutableMultimap. of().entries(), method, 1); assertEquals(headers.size(), 1); assertEquals(headers.get("header"), Collections.singletonList("1")); } @@ -2016,7 +2019,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testTwoDifferentHeaders() throws SecurityException, NoSuchMethodException { Method method = TestHeaders.class.getMethod("twoDifferentHeaders", String.class, String.class); Multimap headers = factory(TestHeaders.class).buildHeaders( - ImmutableMultimap. of().entries(), method, "robot", "egg"); + ImmutableMultimap. of().entries(), method, "robot", "egg"); assertEquals(headers.size(), 2); assertEquals(headers.get("header1"), Collections.singletonList("robot")); assertEquals(headers.get("header2"), Collections.singletonList("egg")); @@ -2026,7 +2029,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testTwoSameHeaders() throws SecurityException, NoSuchMethodException { Method method = TestHeaders.class.getMethod("twoSameHeaders", String.class, String.class); Multimap headers = factory(TestHeaders.class).buildHeaders( - ImmutableMultimap. of().entries(), method, "robot", "egg"); + ImmutableMultimap. of().entries(), method, "robot", "egg"); assertEquals(headers.size(), 2); Collection values = headers.get("header"); assert values.contains("robot"); @@ -2049,7 +2052,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @GET void twoEndpointParams(@EndpointParam(parser = ConvertTwoToURI.class) String EndpointParam1, - @EndpointParam(parser = ConvertTwoToURI.class) String EndpointParam2); + @EndpointParam(parser = ConvertTwoToURI.class) String EndpointParam2); @Singleton public static class ConvertTwoToURI implements Function { @@ -2069,7 +2072,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testOneEndpointParam() throws SecurityException, NoSuchMethodException { Method method = TestEndpointParams.class.getMethod("oneEndpointParam", String.class); URI uri = factory(TestEndpointParams.class).getEndpointInParametersOrNull(method, new Object[] { "robot" }, - injector); + injector); assertEquals(uri, URI.create("robot")); } @@ -2079,7 +2082,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testTwoDifferentEndpointParams() throws SecurityException, NoSuchMethodException { Method method = TestEndpointParams.class.getMethod("twoEndpointParams", String.class, String.class); URI uri = factory(TestEndpointParams.class).getEndpointInParametersOrNull(method, - new Object[] { "robot", "egg" }, injector); + new Object[] { "robot", "egg" }, injector); assertEquals(uri, URI.create("robot/egg")); } @@ -2090,11 +2093,11 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @PUT @Path("/{foo}") public ListenableFuture putWithPath(@PathParam("foo") String path, - @BinderParam(BindToStringPayload.class) String content); + @BinderParam(BindToStringPayload.class) String content); @PUT public void twoEntities(@BinderParam(BindToStringPayload.class) String payload1, - @BinderParam(BindToStringPayload.class) String payload2); + @BinderParam(BindToStringPayload.class) String payload2); } @Test @@ -2167,11 +2170,19 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @FormParams(keys = "x-amz-copy-source", values = "/{bucket}") @SkipEncoding('/') - public class TestClassForm { + public interface TestClassForm { + @Provides + Set set(); + @POST @Path("/") - public void oneForm(@PathParam("bucket") String path) { - } + void oneForm(@PathParam("bucket") String path); + } + + @Test + public void testProvidesWithGeneric() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { + Set set = injector.getInstance(AsyncClientFactory.class).create(TestClassForm.class).set(); + assertEquals(set, ImmutableSet.of("foo")); } @Test @@ -2192,23 +2203,23 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { public void testBuildTwoForms() throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Method twoForms = TestFormReplace.class.getMethod("twoForms", String.class, String.class); Object form = factory(TestFormReplace.class).createRequest(twoForms, "robot", "eggs").getPayload() - .getRawContent(); + .getRawContent(); assertEquals(form, "x-amz-copy-source=/robot/eggs"); } @Test public void testBuildTwoFormsOutOfOrder() throws SecurityException, NoSuchMethodException, - UnsupportedEncodingException { + UnsupportedEncodingException { Method twoFormsOutOfOrder = TestFormReplace.class.getMethod("twoFormsOutOfOrder", String.class, String.class); Object form = factory(TestFormReplace.class).createRequest(twoFormsOutOfOrder, "robot", "eggs").getPayload() - .getRawContent(); + .getRawContent(); assertEquals(form, "x-amz-copy-source=/eggs/robot"); } @SuppressWarnings("unchecked") private RestAnnotationProcessor factory(Class clazz) { return ((RestAnnotationProcessor) injector.getInstance(Key.get(newParameterizedType( - RestAnnotationProcessor.class, clazz)))); + RestAnnotationProcessor.class, clazz)))); } DateService dateService = new SimpleDateFormatDateService(); @@ -2216,15 +2227,18 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { @BeforeClass void setupFactory() { RestContextSpec contextSpec = contextSpec("test", "http://localhost:9999", "1", "", "userfoo", - null, String.class, Integer.class, - ImmutableSet. of(new MockModule(), new NullLoggingModule(), new AbstractModule() { + null, String.class, Integer.class, ImmutableSet. of(new MockModule(), new NullLoggingModule(), + new AbstractModule() { - @Override - protected void configure() { - bind(URI.class).annotatedWith(Localhost2.class).toInstance(URI.create("http://localhost:1111")); - } + @Override + protected void configure() { + bind(new TypeLiteral>() { + }).toInstance(ImmutableSet.of("foo")); + bind(URI.class).annotatedWith(Localhost2.class).toInstance( + URI.create("http://localhost:1111")); + } - })); + })); injector = createContextBuilder(contextSpec).buildInjector(); parserFactory = injector.getInstance(ParseSax.Factory.class); 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 afc232ca5a..a551deb453 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 @@ -32,8 +32,8 @@ import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.reference.EC2Constants; import org.jclouds.logging.log4j.config.Log4JLoggingModule; diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java index be91b98c72..ddd1bd6fb3 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java @@ -68,6 +68,7 @@ import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides asynchronous access to Azure Blob via their REST API. @@ -85,7 +86,7 @@ import com.google.common.util.concurrent.ListenableFuture; @Headers(keys = AzureStorageHeaders.VERSION, values = "2009-09-19") @Path("/") public interface AzureBlobAsyncClient { - + @Provides public org.jclouds.azureblob.domain.AzureBlob newBlob(); /** diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobClient.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobClient.java index 9a58952f7f..b953a59fb1 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobClient.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobClient.java @@ -34,6 +34,8 @@ import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.concurrent.Timeout; import org.jclouds.http.options.GetOptions; +import com.google.inject.Provides; + import java.util.concurrent.Future; /** @@ -48,6 +50,7 @@ import java.util.concurrent.Future; */ @Timeout(duration = 90, timeUnit = TimeUnit.SECONDS) public interface AzureBlobClient { + @Provides public org.jclouds.azureblob.domain.AzureBlob newBlob(); /** 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 index f3f9501cba..80cc0b1b70 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 @@ -8,8 +8,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 c103555616..c85103d35a 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 ce5f4f90e2..79662b2f66 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 913e4bdcae..b6b71268ad 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 @@ -46,9 +46,9 @@ import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.Volume; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; 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 a86f2a32e3..69bb0d85c7 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 @@ -30,7 +30,7 @@ import java.util.regex.Pattern; import javax.inject.Singleton; import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import com.google.common.base.Function; diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java index 29ab7b77ec..ffe7018296 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java @@ -26,7 +26,7 @@ import org.jclouds.cloudsigma.domain.DriveInfo; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystemBuilder; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; 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 66982c9005..9508c62efe 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 ee320568db..09a10866f2 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 @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Map.Entry; import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.json.Json; import org.jclouds.json.internal.GsonWrapper; import org.jclouds.util.Strings2; 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 41ce845c0d..e289afe114 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 dfc8f57bcf..21bf46dd40 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 c85c7d8f98..86eb88660f 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 e4b42d70a0..bf40a8036b 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 7e0b9ab3f4..272bf81c43 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 8c4fe33b93..e9186ecab4 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 039143c896..b164a2287d 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 @@ -26,8 +26,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 f347c4d877..afc27df9d2 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 c1bff655c4..7418ed3929 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; 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 6111bf97c4..4690612ec4 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 @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index d38f57d425..68ec70543a 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/vcloud/terremark/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -27,8 +27,8 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAsyncClient.java b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAsyncClient.java index 10e2504f29..7dc4de92a1 100644 --- a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAsyncClient.java +++ b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNAsyncClient.java @@ -46,6 +46,7 @@ import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.SkipEncoding; import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Provides; /** * Provides asynchronous access to Nirvanix SDN resources via their REST API. @@ -59,7 +60,7 @@ import com.google.common.util.concurrent.ListenableFuture; @SkipEncoding( { '/', ':' }) @QueryParams(keys = SDNQueryParams.OUTPUT, values = "json") public interface SDNAsyncClient { - + @Provides public Blob newBlob(); /** diff --git a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNClient.java b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNClient.java index 3dd35c342b..aaa5985f64 100644 --- a/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNClient.java +++ b/sandbox-apis/nirvanix/src/main/java/org/jclouds/nirvanix/sdn/SDNClient.java @@ -27,6 +27,8 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.concurrent.Timeout; import org.jclouds.nirvanix.sdn.domain.UploadInfo; +import com.google.inject.Provides; + /** * Provides access to Nirvanix SDN resources via their REST API. *

@@ -37,7 +39,7 @@ import org.jclouds.nirvanix.sdn.domain.UploadInfo; */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface SDNClient { - + @Provides public Blob newBlob(); /** diff --git a/sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudTemplateBuilderLiveTest.java b/sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudTemplateBuilderLiveTest.java index 2c4d048546..0929e0c2c0 100644 --- a/sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudTemplateBuilderLiveTest.java +++ b/sandbox-providers/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudTemplateBuilderLiveTest.java @@ -4,7 +4,7 @@ import java.util.Set; import org.jclouds.compute.BaseTemplateBuilderLiveTest; import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.os.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.testng.annotations.Test; import com.google.common.base.Predicate; diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java deleted file mode 100644 index d87527b9c7..0000000000 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/ResourceAllocation.java +++ /dev/null @@ -1,279 +0,0 @@ -package org.jclouds.savvis.vpdc.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * @author Adrian Cole - * - */ -public class ResourceAllocation { - public enum Type { - /** - * 3 GHz equals 1 vCPU - *

- * 1.5 Ghz equals 0.5 vCPU - */ - PROCESSOR, - /** - * Gigabytes - */ - MEMORY, ETHERNET_ADAPTER, - /** - * Gigabytes - */ - BOOT_DISK, - /** - * Gigabytes - */ - DATA_DISK, UNRECOGNIZED; - - public String value() { - switch (this) { - case PROCESSOR: - return "3"; - case MEMORY: - return "4"; - case ETHERNET_ADAPTER: - return "10"; - case BOOT_DISK: - return "27"; - case DATA_DISK: - return "26"; - default: - return "UNRECOGNIZED"; - } - } - - public static Type fromValue(String type) { - try { - return fromValue(Integer.parseInt(checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - public static Type fromValue(int v) { - switch (v) { - case 3: - return PROCESSOR; - case 4: - return MEMORY; - case 10: - return ETHERNET_ADAPTER; - case 27: - return BOOT_DISK; - case 26: - return DATA_DISK; - default: - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - protected int id; - protected Type type; - protected String name; - protected String description; - protected String allocationUnits; - protected long virtualQuantity; - protected String connection; - protected String caption; - protected String hostResource; - - public Builder id(int id) { - this.id = id; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder connection(String connection) { - this.connection = connection; - return this; - } - - public Builder caption(String caption) { - this.caption = caption; - return this; - } - - public Builder hostResource(String hostResource) { - this.hostResource = hostResource; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder allocationUnits(String allocationUnits) { - this.allocationUnits = allocationUnits; - return this; - } - - public Builder type(Type type) { - this.type = type; - return this; - } - - public Builder virtualQuantity(long virtualQuantity) { - this.virtualQuantity = virtualQuantity; - return this; - } - - public ResourceAllocation build() { - return new ResourceAllocation(id, type, name, description, allocationUnits, virtualQuantity, connection, - caption, hostResource); - } - - public static Builder fromResourceAllocation(ResourceAllocation in) { - return new Builder().id(in.getId()).type(in.getType()).name(in.getName()).description(in.getDescription()) - .allocationUnits(in.getAllocationUnits()).virtualQuantity(in.getVirtualQuantity()) - .connection(in.getConnection()).caption(in.getCaption()).hostResource(in.getHostResource()); - } - } - - protected final int id; - protected final Type type; - protected final String name; - protected final String description; - protected final String allocationUnits; - protected final long virtualQuantity; - protected final String connection; - protected final String caption; - protected final String hostResource; - - public ResourceAllocation(int id, Type type, String name, String description, String allocationUnits, - long virtualQuantity, String connection, String caption, String hostResource) { - this.id = id; - this.type = checkNotNull(type, "type"); - this.name = checkNotNull(name, "name"); - this.description = description; - this.allocationUnits = allocationUnits; - this.virtualQuantity = virtualQuantity; - this.connection = connection; - this.caption = caption; - this.hostResource = hostResource; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public Type getType() { - return type; - } - - public String getAllocationUnits() { - return allocationUnits; - } - - public String getConnection() { - return connection; - } - - public String getCaption() { - return caption; - } - - public long getVirtualQuantity() { - return virtualQuantity; - } - - public String getHostResource() { - return hostResource; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((allocationUnits == null) ? 0 : allocationUnits.hashCode()); - result = prime * result + ((caption == null) ? 0 : caption.hashCode()); - result = prime * result + ((connection == null) ? 0 : connection.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((hostResource == null) ? 0 : hostResource.hashCode()); - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ResourceAllocation other = (ResourceAllocation) obj; - if (allocationUnits == null) { - if (other.allocationUnits != null) - return false; - } else if (!allocationUnits.equals(other.allocationUnits)) - return false; - if (caption == null) { - if (other.caption != null) - return false; - } else if (!caption.equals(other.caption)) - return false; - if (connection == null) { - if (other.connection != null) - return false; - } else if (!connection.equals(other.connection)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (hostResource == null) { - if (other.hostResource != null) - return false; - } else if (!hostResource.equals(other.hostResource)) - return false; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (type != other.type) - return false; - if (virtualQuantity != other.virtualQuantity) - return false; - return true; - } - - public Builder toBuilder() { - return Builder.fromResourceAllocation(this); - } - - @Override - public String toString() { - return "[id=" + id + ", type=" + type + ", name=" + name + ", description=" + description + ", allocationUnits=" - + allocationUnits + ", virtualQuantity=" + virtualQuantity + ", connection=" + connection + ", caption=" - + caption + ", hostResource=" + hostResource + "]"; - } - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java index 69f566d013..310fef5f02 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/VApp.java @@ -5,7 +5,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Set; -import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection; +import org.jclouds.cim.ResourceAllocationSettingData; +import org.jclouds.ovf.NetworkSection; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; @@ -122,7 +123,7 @@ public class VApp extends Resource { private Integer osType; private String osDescripton; private NetworkSection networkSection; - private Set resourceAllocations = Sets.newLinkedHashSet(); + private Set resourceAllocations = Sets.newLinkedHashSet(); public Builder ipAddress(String ipAddress) { this.ipAddress = ipAddress; @@ -149,12 +150,12 @@ public class VApp extends Resource { return this; } - public Builder resourceAllocation(ResourceAllocation in) { + public Builder resourceAllocation(ResourceAllocationSettingData in) { this.resourceAllocations.add(checkNotNull(in, "resourceAllocation")); return this; } - public Builder resourceAllocations(Set resourceAllocations) { + public Builder resourceAllocations(Set resourceAllocations) { this.resourceAllocations.addAll(checkNotNull(resourceAllocations, "resourceAllocations")); return this; } @@ -199,10 +200,10 @@ public class VApp extends Resource { private final Integer osType; private final String osDescripton; private final NetworkSection networkSection; - private final Set resourceAllocations; + private final Set resourceAllocations; public VApp(String id, String name, String type, URI href, Status status, String ipAddress, Integer osType, - String osDescripton, NetworkSection networkSection, Set resourceAllocations) { + String osDescripton, NetworkSection networkSection, Set resourceAllocations) { super(id, name, type, href); this.status = status; this.ipAddress = ipAddress; @@ -232,7 +233,7 @@ public class VApp extends Resource { return networkSection; } - public Set getResourceAllocations() { + public Set getResourceAllocations() { return resourceAllocations; } diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java deleted file mode 100644 index b99c363bd5..0000000000 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/domain/vapp/NetworkSection.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.jclouds.savvis.vpdc.domain.vapp; - -import java.util.Set; - -import com.google.common.collect.ImmutableSet; - -/** - * The NetworkSection element shall list all logical networks used in the OVF package. - * - * @author Adrian Cole - */ -public class NetworkSection { - private final String info; - private final Set networks; - - public NetworkSection(String info, Iterable networks) { - this.info = info; - this.networks = ImmutableSet. copyOf(networks); - } - - public String getInfo() { - return info; - } - - /** - * All networks referred to from Connection elements in all {@link VirtualHardwareSection} - * elements shall be defined in the NetworkSection. - * - * @return - */ - public Set getNetworks() { - return networks; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result + ((networks == null) ? 0 : networks.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; - NetworkSection other = (NetworkSection) obj; - if (info == null) { - if (other.info != null) - return false; - } else if (!info.equals(other.info)) - return false; - if (networks == null) { - if (other.networks != null) - return false; - } else if (!networks.equals(other.networks)) - return false; - return true; - } - - @Override - public String toString() { - return "[info=" + info + ", networks=" + networks + "]"; - } - -} \ No newline at end of file diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java index fed2ed8f91..4fdf388210 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClient.java @@ -24,6 +24,7 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.RequestFilters; @@ -36,6 +37,8 @@ import org.jclouds.savvis.vpdc.domain.VApp; import org.jclouds.savvis.vpdc.domain.VDC; import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie; import org.jclouds.savvis.vpdc.functions.DefaultOrgIfNull; +import org.jclouds.savvis.vpdc.options.BindGetVAppOptions; +import org.jclouds.savvis.vpdc.options.GetVAppOptions; import org.jclouds.savvis.vpdc.xml.NetworkHandler; import org.jclouds.savvis.vpdc.xml.OrgHandler; import org.jclouds.savvis.vpdc.xml.TaskHandler; @@ -96,7 +99,8 @@ public interface BrowsingAsyncClient { @Path("org/{billingSiteId}/vdc/{vpdcId}/vApp/{vAppId}") ListenableFuture getVAppInOrgAndVDC( @PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId, - @PathParam("vpdcId") String vpdcId, @PathParam("vAppId") String vAppId); + @PathParam("vpdcId") String vpdcId, @PathParam("vAppId") String vAppId, + @BinderParam(BindGetVAppOptions.class) GetVAppOptions... options); /** * @see BrowsingClient#getTask diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java index 3e7ce324d1..ca2037b12a 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/features/BrowsingClient.java @@ -29,6 +29,7 @@ import org.jclouds.savvis.vpdc.domain.Org; import org.jclouds.savvis.vpdc.domain.Task; import org.jclouds.savvis.vpdc.domain.VApp; import org.jclouds.savvis.vpdc.domain.VDC; +import org.jclouds.savvis.vpdc.options.GetVAppOptions; /** * Provides access to Symphony VPDC resources via their REST API. @@ -84,12 +85,14 @@ public interface BrowsingClient { * vpdc Id * @param vAppId * vApp ID + * @param options + * control whether or not to get real time state * * @return A virtual application (vApp) is a software solution comprising one or more virtual * machines, all of which are deployed, managed, and maintained as a unit, or null if not * present */ - VApp getVAppInOrgAndVDC(String billingSiteId, String vpdcId, String vAppId); + VApp getVAppInOrgAndVDC(String billingSiteId, String vpdcId, String vAppId, GetVAppOptions... options); /** * Gets an existing task. diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/BindGetVAppOptions.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/BindGetVAppOptions.java new file mode 100644 index 0000000000..d5ccb99437 --- /dev/null +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/BindGetVAppOptions.java @@ -0,0 +1,37 @@ +package org.jclouds.savvis.vpdc.options; + +import static com.google.common.base.Preconditions.checkArgument; + +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Singleton; +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.Binder; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class BindGetVAppOptions implements Binder { + private final Provider uriBuilder; + + @Inject + public BindGetVAppOptions(Provider uriBuilder) { + this.uriBuilder = uriBuilder; + } + + @SuppressWarnings("unchecked") + @Override + public R bindToRequest(R request, Object input) { + checkArgument(input instanceof GetVAppOptions[], "this binder is only valid for GetVAppOptions!"); + GetVAppOptions[] options = GetVAppOptions[].class.cast(input); + if (options.length > 0 && options[0].isWithPowerState()) + return (R) request.toBuilder().endpoint( + uriBuilder.get().uri(request.getEndpoint()).path("withpowerstate").build()).build(); + else + return request; + } +} diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/GetVAppOptions.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/GetVAppOptions.java new file mode 100644 index 0000000000..587c919ca7 --- /dev/null +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/options/GetVAppOptions.java @@ -0,0 +1,67 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.savvis.vpdc.options; + + +/** + * Contains options supported for the GetVApp operation.

+ * Usage

The recommended way to instantiate a GetVAppOptions object is to statically import + * GetVAppOptions.Builder.* and invoke a static creation method followed by an instance mutator (if + * needed): + *

+ * + * import static org.jclouds.savvis.vpdc.options.GetVAppOptions.Builder.* + *

+ * + * vApp = context.getApi().getBrowsingClient().getVAppInOrgAndVDC(orgId, vdcId, vAppId, withPowerState()); + * + * + * @author Adrian Cole + * @see + */ +public class GetVAppOptions { + public static final GetVAppOptions NONE = new GetVAppOptions(); + private boolean withPowerState; + + /** + * The VM State is the real time state. + */ + public GetVAppOptions withPowerState() { + this.withPowerState = true; + return this; + } + + public boolean isWithPowerState() { + return withPowerState; + } + + public static class Builder { + + /** + * @see GetVAppOptions#withPowerState() + */ + public static GetVAppOptions withPowerState() { + GetVAppOptions options = new GetVAppOptions(); + return options.withPowerState(); + } + + } +} diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java deleted file mode 100644 index eb05aec977..0000000000 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/NetworkSectionHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.jclouds.savvis.vpdc.xml; - -import java.util.Map; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.savvis.vpdc.domain.vapp.Network; -import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection; -import org.jclouds.savvis.vpdc.util.Utils; -import org.xml.sax.Attributes; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; - -/** - * @author Adrian Cole - */ -public class NetworkSectionHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - - protected String info; - protected String name; - protected String description; - - protected Builder networks = ImmutableSet. builder(); - - public NetworkSection getResult() { - try { - return new NetworkSection(info, networks.build()); - } finally { - this.info = null; - this.networks = ImmutableSet. builder(); - } - } - - public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = Utils.cleanseAttributes(attrs); - if (qName.endsWith("Network")) { - name = attributes.get("name"); - } - } - - @Override - public void endElement(String uri, String localName, String qName) { - if (qName.endsWith("Info")) { - this.info = Utils.currentOrNull(currentText); - } else if (qName.endsWith("Description")) { - this.description = Utils.currentOrNull(currentText); - } else if (qName.endsWith("Network")) { - this.networks.add(new Network(name, description)); - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java deleted file mode 100644 index 112445d639..0000000000 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/ResourceAllocationHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.jclouds.savvis.vpdc.xml; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.savvis.vpdc.domain.ResourceAllocation; -import org.jclouds.savvis.vpdc.util.Utils; -import org.xml.sax.Attributes; - -/** - * @author Adrian Cole - */ -public class ResourceAllocationHandler extends ParseSax.HandlerWithResult { - protected StringBuilder currentText = new StringBuilder(); - - protected ResourceAllocation.Builder builder = ResourceAllocation.builder(); - - public ResourceAllocation getResult() { - try { - return builder.build(); - } finally { - builder = ResourceAllocation.builder(); - } - } - - @Override - public void startElement(String uri, String localName, String qName, Attributes attrs) { - } - - @Override - public void endElement(String uri, String localName, String qName) { - String current = Utils.currentOrNull(currentText); - if (current != null) { - if (qName.endsWith("AllocationUnits")) { - builder.allocationUnits(current); - } else if (qName.endsWith("Description")) { - builder.description(current); - } else if (qName.endsWith("ElementName")) { - builder.name(current); - } else if (qName.endsWith("InstanceID")) { - builder.id(Integer.parseInt(current)); - } else if (qName.endsWith("ResourceType")) { - builder.type(ResourceAllocation.Type.fromValue(current)); - } else if (qName.endsWith("VirtualQuantity")) { - builder.virtualQuantity(Long.parseLong(current)); - } else if (qName.endsWith("Caption")) { - builder.caption(current); - } else if (qName.endsWith("Connection")) { - builder.connection(current); - } else if (qName.endsWith("HostResource")) { - builder.hostResource(current); - } - } - currentText = new StringBuilder(); - } - - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java index b78ba99f80..4b812fea78 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/xml/VAppHandler.java @@ -25,7 +25,9 @@ import java.util.Map; import javax.inject.Inject; +import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.http.functions.ParseSax; +import org.jclouds.ovf.xml.NetworkSectionHandler; import org.jclouds.savvis.vpdc.domain.Resource; import org.jclouds.savvis.vpdc.domain.VApp; import org.jclouds.savvis.vpdc.util.Utils; @@ -40,10 +42,10 @@ import com.google.common.collect.ImmutableMap; public class VAppHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); private final NetworkSectionHandler networkSectionHandler; - private final ResourceAllocationHandler allocationHandler; + private final ResourceAllocationSettingDataHandler allocationHandler; @Inject - public VAppHandler(NetworkSectionHandler networkSectionHandler, ResourceAllocationHandler allocationHandler) { + public VAppHandler(NetworkSectionHandler networkSectionHandler, ResourceAllocationSettingDataHandler allocationHandler) { this.networkSectionHandler = networkSectionHandler; this.allocationHandler = allocationHandler; } diff --git a/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index 1f3aec75ec..4492b891e4 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -53,18 +53,19 @@ public class BaseVPDCClientLiveTest { 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"); + endpoint = System.getProperty("test." + provider + ".endpoint"); + apiversion = System.getProperty("test." + provider + ".apiversion"); } protected Properties setupProperties() { Properties overrides = new Properties(); overrides.setProperty(provider + ".identity", identity); overrides.setProperty(provider + ".credential", credential); - overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".apiversion", apiversion); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); return overrides; } @@ -73,7 +74,7 @@ public class BaseVPDCClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides); + overrides); } @AfterGroups(groups = "live") diff --git a/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java index 3c509c1ee4..69d72ac7a8 100644 --- a/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java +++ b/sandbox-providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncClientTest.java @@ -26,6 +26,7 @@ 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.savvis.vpdc.options.GetVAppOptions; import org.jclouds.savvis.vpdc.xml.NetworkHandler; import org.jclouds.savvis.vpdc.xml.OrgHandler; import org.jclouds.savvis.vpdc.xml.TaskHandler; @@ -105,11 +106,11 @@ public class BrowsingAsyncClientTest extends BaseVPDCAsyncClientTest Date: Sun, 20 Mar 2011 22:34:40 -0700 Subject: [PATCH 5/5] fixed bad test annotation that always breaks the build --- .../java/org/jclouds/s3/options/CopyObjectOptionsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/s3/src/test/java/org/jclouds/s3/options/CopyObjectOptionsTest.java b/apis/s3/src/test/java/org/jclouds/s3/options/CopyObjectOptionsTest.java index e5a453450a..5d57b5a891 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/options/CopyObjectOptionsTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/options/CopyObjectOptionsTest.java @@ -42,7 +42,7 @@ import java.util.Map; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.s3.domain.CannedAccessPolicy; -import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -61,7 +61,7 @@ public class CopyObjectOptionsTest { private String nowExpected; private Map goodMeta; - @BeforeMethod + @BeforeTest void setUp() { goodMeta = ImmutableMap.of(USER_METADATA_PREFIX + "adrian", "foo"); Date date = new Date();