From 114d188079ca369cfd658bebfa7ce2689a777aa4 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 25 Aug 2010 12:09:38 -0700 Subject: [PATCH] Issue 280: added support to parse the ovf envelope for a vapp template so that we can get to os and size data --- ...kVCloudDirectorComputeServiceLiveTest.java | 4 +- .../org/jclouds/vcloud/VCloudAsyncClient.java | 13 ++ .../java/org/jclouds/vcloud/VCloudClient.java | 3 + ...ExpressVAppTemplateParamsToXmlPayload.java | 2 +- .../compute/functions/GetExtraFromVApp.java | 8 +- .../GetExtraFromVCloudExpressVApp.java | 4 +- .../functions/ImageForVAppTemplate.java | 23 ++- .../internal/VCloudComputeClientImpl.java | 6 +- .../VCloudAddNodeWithTagStrategy.java | 21 +- .../VCloudGetNodeMetadataStrategy.java | 18 +- .../compute/util/VCloudComputeUtils.java | 57 ++++++ .../vcloud/domain/VCloudExpressVApp.java | 4 +- .../vcloud/domain/VCloudVirtualHardware.java | 85 ++++++++ .../vcloud/domain/VirtualHardware.java | 60 ++++-- .../java/org/jclouds/vcloud/domain/Vm.java | 5 +- .../internal/VCloudExpressVAppImpl.java | 10 +- .../vcloud/domain/internal/VmImpl.java | 16 +- .../{ => ovf}/EditableResourceAllocation.java | 4 +- .../domain/{ => ovf}/OperatingSystem.java | 67 ++----- .../vcloud/domain/ovf/OvfEnvelope.java | 69 +++++++ .../domain/{ => ovf}/ResourceAllocation.java | 2 +- .../vcloud/domain/{ => ovf}/ResourceType.java | 2 +- .../{VirtualSystem.java => ovf/System.java} | 8 +- .../domain/{ => ovf}/VCloudHardDisk.java | 3 +- .../{ => ovf}/VCloudNetworkAdapter.java | 7 +- .../domain/ovf/VCloudOperatingSystem.java | 121 ++++++++++++ .../vcloud/domain/ovf/VirtualSystem.java | 118 +++++++++++ .../vcloud/predicates/VCloudPredicates.java | 4 +- .../java/org/jclouds/vcloud/util/Utils.java | 1 + .../vcloud/xml/VCloudExpressVAppHandler.java | 12 +- .../xml/VCloudVirtualHardwareHandler.java | 74 +++++++ .../vcloud/xml/VirtualHardwareHandler.java | 28 +-- .../org/jclouds/vcloud/xml/VmHandler.java | 17 +- .../xml/ovf/OperatingSystemHandler.java | 69 +++++++ .../vcloud/xml/ovf/OvfEnvelopeHandler.java | 87 +++++++++ .../{ => ovf}/ResourceAllocationHandler.java | 8 +- .../SystemHandler.java} | 12 +- .../VCloudOperatingSystemHandler.java} | 16 +- .../VCloudResourceAllocationHandler.java | 10 +- .../vcloud/xml/ovf/VirtualSystemHandler.java | 138 +++++++++++++ .../jclouds/vcloud/VCloudAsyncClientTest.java | 17 ++ .../jclouds/vcloud/VCloudClientLiveTest.java | 20 ++ .../VCloudExpressComputeClientLiveTest.java | 2 +- .../xml/VCloudExpressVAppHandlerTest.java | 10 +- ... => VCloudVirtualHardwareHandlerTest.java} | 30 +-- .../org/jclouds/vcloud/xml/VmHandlerTest.java | 5 +- .../xml/ovf/OvfEnvelopeHandlerTest.java | 52 +++++ .../ResourceAllocationHandlerTest.java | 7 +- .../SystemHandlerTest.java} | 15 +- .../VCloudOperatingSystemHandlerTest.java} | 19 +- .../xml/ovf/VirtualSystemHandlerTest.java | 105 ++++++++++ vcloud/core/src/test/resources/ovf.xml | 183 ++++++++++++++++++ .../core/src/test/resources/virtualsystem.xml | 127 ++++++++++++ .../BindVAppConfigurationToXmlPayload.java | 4 +- ...antiateVAppTemplateParamsToXmlPayload.java | 2 +- .../terremark/TerremarkClientLiveTest.java | 4 +- ...BindVAppConfigurationToXmlPayloadTest.java | 4 +- .../xml/ResourceAllocationHandlerTest.java | 6 +- .../vcloud/terremark/xml/VAppHandlerTest.java | 10 +- .../xml/VirtualSystemHandlerTest.java | 7 +- 60 files changed, 1574 insertions(+), 271 deletions(-) create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudVirtualHardware.java rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/EditableResourceAllocation.java (96%) rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/OperatingSystem.java (56%) create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/ResourceAllocation.java (99%) rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/ResourceType.java (98%) rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{VirtualSystem.java => ovf/System.java} (93%) rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/VCloudHardDisk.java (98%) rename vcloud/core/src/main/java/org/jclouds/vcloud/domain/{ => ovf}/VCloudNetworkAdapter.java (91%) create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystem.java create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OperatingSystemHandler.java create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandler.java rename vcloud/core/src/main/java/org/jclouds/vcloud/xml/{ => ovf}/ResourceAllocationHandler.java (95%) rename vcloud/core/src/main/java/org/jclouds/vcloud/xml/{VirtualSystemHandler.java => ovf/SystemHandler.java} (85%) rename vcloud/core/src/main/java/org/jclouds/vcloud/xml/{OperatingSystemHandler.java => ovf/VCloudOperatingSystemHandler.java} (80%) rename vcloud/core/src/main/java/org/jclouds/vcloud/xml/{ => ovf}/VCloudResourceAllocationHandler.java (92%) create mode 100644 vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandler.java rename vcloud/core/src/test/java/org/jclouds/vcloud/xml/{VirtualHardwareHandlerTest.java => VCloudVirtualHardwareHandlerTest.java} (83%) create mode 100644 vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java rename vcloud/core/src/test/java/org/jclouds/vcloud/xml/{ => ovf}/ResourceAllocationHandlerTest.java (89%) rename vcloud/core/src/test/java/org/jclouds/vcloud/xml/{VirtualSystemHandlerTest.java => ovf/SystemHandlerTest.java} (70%) rename vcloud/core/src/test/java/org/jclouds/vcloud/xml/{OperatingSystemHandlerTest.java => ovf/VCloudOperatingSystemHandlerTest.java} (76%) create mode 100644 vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java create mode 100644 vcloud/core/src/test/resources/ovf.xml create mode 100644 vcloud/core/src/test/resources/virtualsystem.xml diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java index baee4d9c5f..4866ad11e7 100644 --- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java @@ -54,10 +54,10 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS @Test public void testTemplateBuilder() { Template defaultTemplate = client.templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem()); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Template"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)"); assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation(); assertEquals(defaultTemplate.getSize().getCores(), 1.0d); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java index b7e4972234..02af26b350 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java @@ -34,6 +34,7 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import org.jclouds.predicates.validators.DnsNameValidator; import org.jclouds.rest.annotations.EndpointParam; @@ -53,6 +54,7 @@ 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.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; @@ -62,6 +64,7 @@ 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; @@ -84,6 +87,16 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient { @ExceptionParser(ReturnNullOnNotFoundOr404.class) ListenableFuture getVAppTemplate(@EndpointParam URI vAppTemplate); + /** + * @see VCloudClient#getOvfEnvelopeForVAppTemplate + */ + @GET + @Consumes(MediaType.TEXT_XML) + @Path("/ovf") + @XMLResponseParser(OvfEnvelopeHandler.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOvfEnvelopeForVAppTemplate(@EndpointParam URI vAppTemplate); + /** * @see VCloudClient#findVAppTemplateInOrgCatalogNamed */ diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java index f102a674cf..5aa87eee4c 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java @@ -30,6 +30,7 @@ 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.CloneVAppOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -49,6 +50,8 @@ public interface VCloudClient extends CommonVCloudClient { VAppTemplate getVAppTemplate(URI vAppTemplate); + OvfEnvelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate); + /** * returns the vapp template corresponding to a catalog item in the catalog associated with the * specified name. Note that the org and catalog parameters can be null to choose default. diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java index 10fab06373..844a7e683b 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.java @@ -45,7 +45,7 @@ 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.ResourceType; +import org.jclouds.vcloud.domain.ovf.ResourceType; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.collect.ImmutableMap; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java index 8728b8ca67..f8de43ea33 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVApp.java @@ -31,12 +31,12 @@ import javax.inject.Singleton; import org.jclouds.logging.Logger; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.VCloudHardDisk; -import org.jclouds.vcloud.domain.VCloudNetworkAdapter; 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.VCloudHardDisk; +import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; import com.google.common.base.Function; import com.google.common.collect.Iterables; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java index c41a7917ea..91324261f5 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/GetExtraFromVCloudExpressVApp.java @@ -32,9 +32,9 @@ import javax.inject.Singleton; import org.jclouds.logging.Logger; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; 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; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java index bc41013650..ac8791a926 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java @@ -20,18 +20,19 @@ package org.jclouds.vcloud.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrNull; +import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs; import javax.inject.Inject; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; import org.jclouds.domain.Location; +import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.domain.VCloudImage; 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; import com.google.common.collect.ImmutableMap; @@ -40,13 +41,15 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ public class ImageForVAppTemplate implements Function { + private final VCloudClient client; private final FindLocationForResource findLocationForResource; private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider; private ReferenceType parent; @Inject - protected ImageForVAppTemplate(FindLocationForResource findLocationForResource, - PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) { + protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource, + PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) { + this.client = checkNotNull(client, "client"); this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider"); } @@ -58,19 +61,15 @@ public class ImageForVAppTemplate implements Function { @Override public Image apply(VAppTemplate from) { - OsFamily osFamily = parseOsFamilyOrNull(checkNotNull(from, "vapp template").getName()); - String osName = null; - String osArch = null; - String osVersion = null; - String osDescription = from.getName(); - boolean is64Bit = from.getName().indexOf("64") != -1; - OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit); + + OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref()); + OperatingSystem os = toComputeOs(ovf); Location location = findLocationForResource.apply(checkNotNull(parent, "parent")); String name = getName(from.getName()); String desc = from.getDescription() != null ? from.getDescription() : from.getName(); return new VCloudImage(from, from.getHref().toASCIIString(), name, from.getHref().toASCIIString(), location, from - .getHref(), ImmutableMap. of(), os, desc, "", credentialsProvider.execute(from)); + .getHref(), ImmutableMap. of(), os, desc, "", credentialsProvider.execute(from)); } protected String getName(String name) { diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java index 6eb72f687c..9ab7701b50 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/internal/VCloudComputeClientImpl.java @@ -33,15 +33,15 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeState; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.VCloudComputeClient; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.VCloudNetworkAdapter; import org.jclouds.vcloud.domain.VDC; 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.VCloudNetworkAdapter; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import com.google.common.base.Predicate; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java index 4ccfdcc2bc..d1ba23fcdc 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudAddNodeWithTagStrategy.java @@ -19,6 +19,7 @@ package org.jclouds.vcloud.compute.strategy; +import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount; import java.net.URI; @@ -29,10 +30,8 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.internal.NodeMetadataImpl; -import org.jclouds.compute.domain.os.CIMOperatingSystem; import org.jclouds.compute.strategy.AddNodeWithTagStrategy; import org.jclouds.domain.Credentials; import org.jclouds.vcloud.VCloudClient; @@ -73,20 +72,12 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy { } protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map metaMap, VApp vApp) { - return new NodeMetadataImpl(vApp.getHref().toASCIIString(), vApp.getName(), vApp.getHref().toASCIIString(), template - .getLocation(), vApp.getHref(), ImmutableMap. of(), tag, template.getImage().getId(), - getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()), - vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getHref()), - computeClient.getPrivateAddresses(vApp.getHref()), ImmutableMap. of(), new Credentials( + return new NodeMetadataImpl(vApp.getHref().toASCIIString(), vApp.getName(), vApp.getHref().toASCIIString(), + template.getLocation(), vApp.getHref(), ImmutableMap. of(), tag, template.getImage() + .getId(), toComputeOs(vApp, template.getImage().getOperatingSystem()), vAppStatusToNodeState + .get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getHref()), computeClient + .getPrivateAddresses(vApp.getHref()), ImmutableMap. of(), new Credentials( metaMap.get("username"), metaMap.get("password"))); } - private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) { - // TODO - return new CIMOperatingSystem(CIMOperatingSystem.OSType.UBUNTU_64, null, null, vApp.getDescription()); - // return vApp.getOsType() != null ? new - // CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()), - // null, null, vApp.getOperatingSystemDescription()) : operatingSystem; - } - } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java index e58848876b..07405f4a80 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudGetNodeMetadataStrategy.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.compute.strategy; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; +import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs; import java.net.URI; import java.util.Map; @@ -34,9 +35,7 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.internal.NodeMetadataImpl; -import org.jclouds.compute.domain.os.CIMOperatingSystem; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.domain.Location; @@ -47,11 +46,9 @@ import org.jclouds.vcloud.compute.functions.FindLocationForResource; import org.jclouds.vcloud.compute.functions.GetExtraFromVApp; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VApp; -import org.jclouds.vcloud.domain.Vm; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; /** * @author Adrian Cole @@ -88,17 +85,8 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy { String tag = parseTagFromName(from.getName()); Location location = findLocationForResourceInVDC.apply(from.getVDC()); return new NodeMetadataImpl(in, from.getName(), in, location, from.getHref(), ImmutableMap. of(), - tag, null, getOperatingSystemForVAppOrDefaultTo(from, null), - vAppStatusToNodeState.get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient - .getPrivateAddresses(id), getExtra.apply(from), null); - } - - private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) { - // TODO we need to change the design so that it doesn't assume single-vms - Vm vm = Iterables.get(vApp.getChildren(), 0); - return vm.getOperatingSystem() != null && vm.getOperatingSystem().getId() != null ? new CIMOperatingSystem( - CIMOperatingSystem.OSType.fromValue(vm.getOperatingSystem().getId()), null, null, vm - .getOperatingSystem().getDescription()) : operatingSystem; + tag, null, toComputeOs(from, null), vAppStatusToNodeState.get(from.getStatus()), computeClient + .getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(from), null); } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java new file mode 100644 index 0000000000..ee625513da --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java @@ -0,0 +1,57 @@ +/** + * + * 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.util; + +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.os.CIMOperatingSystem; +import org.jclouds.vcloud.domain.VApp; +import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.domain.ovf.OvfEnvelope; + +import com.google.common.collect.Iterables; + +/** + * + * @author Adrian Cole + */ +public class VCloudComputeUtils { + public static OperatingSystem toComputeOs(VApp vApp, OperatingSystem defaultOs) { + CIMOperatingSystem cimOs = toComputeOs(vApp); + return cimOs != null ? cimOs : defaultOs; + } + + public static CIMOperatingSystem toComputeOs(VApp vApp) { + // TODO we need to change the design so that it doesn't assume single-vms + return toComputeOs(Iterables.get(vApp.getChildren(), 0)); + } + + public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) { + return toComputeOs(ovf.getVirtualSystem().getOperatingSystem()); + } + + public static CIMOperatingSystem toComputeOs(Vm vm) { + return toComputeOs(vm.getOperatingSystem()); + } + + public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystem os) { + return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), null, null, os.getDescription()); + } + +} diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java index 8610a77466..a37092b4de 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudExpressVApp.java @@ -24,6 +24,8 @@ import java.util.Set; import javax.annotation.Nullable; 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; @@ -60,7 +62,7 @@ public interface VCloudExpressVApp extends ReferenceType { @Nullable String getOperatingSystemDescription(); - VirtualSystem getSystem(); + System getSystem(); Set getResourceAllocations(); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudVirtualHardware.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudVirtualHardware.java new file mode 100644 index 0000000000..7682ea7e78 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudVirtualHardware.java @@ -0,0 +1,85 @@ +/** + * + * Copyright (C) 2010 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +package org.jclouds.vcloud.domain; + +import java.net.URI; + +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; + +/** + * A description of the virtual hardware supported by a virtual machine. + */ +public class VCloudVirtualHardware extends VirtualHardware { + protected final String type; + protected final URI href; + + public VCloudVirtualHardware(String type, URI href, String info, System virtualSystem, + Iterable resourceAllocations) { + super(info, virtualSystem, resourceAllocations); + this.type = type; + this.href = href; + } + + public String getType() { + return type; + } + + public URI getHref() { + return href; + } + + @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; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + VCloudVirtualHardware other = (VCloudVirtualHardware) 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; + } + + @Override + public String toString() { + return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", virtualSystem=" + getSystem() + + "]"; + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualHardware.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualHardware.java index 5e73d46ac2..bd9339ea73 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualHardware.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualHardware.java @@ -19,10 +19,10 @@ package org.jclouds.vcloud.domain; -import java.net.URI; import java.util.Set; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; @@ -30,14 +30,13 @@ import com.google.common.collect.Sets; /** * A description of the virtual hardware supported by a virtual machine. */ -public class VirtualHardware extends ReferenceTypeImpl { - private final String info; - private final VirtualSystem virtualSystem; - private final Set resourceAllocations = Sets.newLinkedHashSet(); +public class VirtualHardware { - public VirtualHardware(String name, String type, URI href, String info, VirtualSystem virtualSystem, - Iterable resourceAllocations) { - super(name, type, href); + protected final String info; + protected final System virtualSystem; + protected final Set resourceAllocations = Sets.newLinkedHashSet(); + + public VirtualHardware(String info, System virtualSystem, Iterable resourceAllocations) { this.info = info; this.virtualSystem = virtualSystem; Iterables.addAll(this.resourceAllocations, resourceAllocations); @@ -47,7 +46,7 @@ public class VirtualHardware extends ReferenceTypeImpl { return info; } - public VirtualSystem getSystem() { + public System getSystem() { return virtualSystem; } @@ -57,7 +56,44 @@ public class VirtualHardware extends ReferenceTypeImpl { @Override public String toString() { - return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", info=" + getInfo() - + ", virtualSystem=" + getSystem() + "]"; + return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]"; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((info == null) ? 0 : info.hashCode()); + result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); + result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + VirtualHardware other = (VirtualHardware) obj; + if (info == null) { + if (other.info != null) + return false; + } else if (!info.equals(other.info)) + return false; + if (resourceAllocations == null) { + if (other.resourceAllocations != null) + return false; + } else if (!resourceAllocations.equals(other.resourceAllocations)) + return false; + if (virtualSystem == null) { + if (other.virtualSystem != null) + return false; + } else if (!virtualSystem.equals(other.virtualSystem)) + return false; + return true; + } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Vm.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Vm.java index cd58ada04a..ddaf651055 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Vm.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Vm.java @@ -24,6 +24,7 @@ import java.util.List; import javax.annotation.Nullable; import org.jclouds.vcloud.domain.internal.VmImpl; +import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem; import com.google.inject.ImplementedBy; @@ -74,7 +75,7 @@ public interface Vm extends ReferenceType { * @since vcloud api 1.0 */ @Nullable - VirtualHardware getHardware(); + VCloudVirtualHardware getHardware(); /** * @return operating system on this VM, or null, if part of a vApp template @@ -82,7 +83,7 @@ public interface Vm extends ReferenceType { * @since vcloud api 1.0 */ @Nullable - OperatingSystem getOperatingSystem(); + VCloudOperatingSystem getOperatingSystem(); /** * read-only identifier created on import diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java index 260152f869..c3418c7af5 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VCloudExpressVAppImpl.java @@ -26,10 +26,10 @@ import java.util.Set; import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; import com.google.common.collect.ListMultimap; @@ -46,7 +46,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { private final Long size; private final ListMultimap networkToAddresses; private final String operatingSystemDescription; - private final VirtualSystem system; + private final System system; private final Set resourceAllocations; private final Integer osType; @@ -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, - VirtualSystem system, Set resourceAllocations) { + System system, Set resourceAllocations) { this.name = checkNotNull(name, "name"); this.href = checkNotNull(href, "href"); this.status = checkNotNull(status, "status"); @@ -89,7 +89,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp { } @Override - public VirtualSystem getSystem() { + public System getSystem() { return system; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java index 1c91f86271..6c35028980 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java @@ -26,12 +26,12 @@ import java.util.List; import javax.annotation.Nullable; -import org.jclouds.vcloud.domain.OperatingSystem; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VirtualHardware; +import org.jclouds.vcloud.domain.VCloudVirtualHardware; import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -51,13 +51,13 @@ public class VmImpl extends ReferenceTypeImpl implements Vm { private final String description; private final List tasks = Lists.newArrayList(); @Nullable - private final VirtualHardware hardware; + private final VCloudVirtualHardware hardware; private final String vAppScopedLocalId; - private final OperatingSystem os; + private final VCloudOperatingSystem os; public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp, - @Nullable String description, Iterable tasks, @Nullable VirtualHardware hardware, - @Nullable OperatingSystem os, @Nullable String vAppScopedLocalId) { + @Nullable String description, Iterable tasks, @Nullable VCloudVirtualHardware hardware, + @Nullable VCloudOperatingSystem os, @Nullable String vAppScopedLocalId) { super(name, type, id); this.status = status; this.vApp = vApp;// TODO: once <1.0 is killed check not null @@ -105,7 +105,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm { * {@inheritDoc} */ @Override - public VirtualHardware getHardware() { + public VCloudVirtualHardware getHardware() { return hardware; } @@ -113,7 +113,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm { * {@inheritDoc} */ @Override - public OperatingSystem getOperatingSystem() { + public VCloudOperatingSystem getOperatingSystem() { return os; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/EditableResourceAllocation.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java similarity index 96% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/EditableResourceAllocation.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java index fd31c88dc1..3094f212ad 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/EditableResourceAllocation.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocation.java @@ -17,7 +17,9 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; + +import org.jclouds.vcloud.domain.ReferenceType; /** * @author Adrian Cole diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/OperatingSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystem.java similarity index 56% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/OperatingSystem.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystem.java index d797561aff..f4bb581e88 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/OperatingSystem.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OperatingSystem.java @@ -17,39 +17,24 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; +package org.jclouds.vcloud.domain.ovf; import javax.annotation.Nullable; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; - -/** - * A description of the operating system supported by a virtual machine. - */ -public class OperatingSystem extends ReferenceTypeImpl { +public class OperatingSystem { @Nullable - private final Integer id; + protected final Integer id; @Nullable - private final String info; - @Nullable - private final String vmwOsType; - @Nullable - private final String description; - private final ReferenceType edit; + protected final String info; - public OperatingSystem(@Nullable String name, String type, URI href, @Nullable Integer id, @Nullable String info, - @Nullable String vmwOsType, @Nullable String description, ReferenceType edit) { - super(name, type, href); + @Nullable + protected final String description; + + public OperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description) { this.id = id; this.info = info; - this.vmwOsType = vmwOsType; this.description = description; - this.edit = checkNotNull(edit, "edit"); } /** @@ -68,14 +53,6 @@ public class OperatingSystem extends ReferenceTypeImpl { return info; } - /** - * - * @return VMware osType, if running on VMware - */ - public String getVmwOsType() { - return vmwOsType; - } - /** * * @return description or null @@ -84,23 +61,13 @@ public class OperatingSystem extends ReferenceTypeImpl { return description; } - /** - * - * @return edit link - */ - public ReferenceType getEdit() { - return edit; - } - @Override public int hashCode() { final int prime = 31; - int result = super.hashCode(); + int result = 1; result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((edit == null) ? 0 : edit.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((info == null) ? 0 : info.hashCode()); - result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.hashCode()); return result; } @@ -108,7 +75,7 @@ public class OperatingSystem extends ReferenceTypeImpl { public boolean equals(Object obj) { if (this == obj) return true; - if (!super.equals(obj)) + if (obj == null) return false; if (getClass() != obj.getClass()) return false; @@ -118,11 +85,6 @@ public class OperatingSystem extends ReferenceTypeImpl { return false; } else if (!description.equals(other.description)) return false; - if (edit == null) { - if (other.edit != null) - return false; - } else if (!edit.equals(other.edit)) - return false; if (id == null) { if (other.id != null) return false; @@ -133,17 +95,12 @@ public class OperatingSystem extends ReferenceTypeImpl { return false; } else if (!info.equals(other.info)) return false; - if (vmwOsType == null) { - if (other.vmwOsType != null) - return false; - } else if (!vmwOsType.equals(other.vmwOsType)) - return false; return true; } @Override public String toString() { - return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" - + getVmwOsType() + ", description=" + getDescription() + "]"; + return "[id=" + getId() + ", info=" + getInfo() + ", description=" + getDescription() + "]"; } + } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java new file mode 100644 index 0000000000..bd947e9c0d --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/OvfEnvelope.java @@ -0,0 +1,69 @@ +/** + * + * 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 OvfEnvelope { + private final VirtualSystem virtualSystem; + + public OvfEnvelope(VirtualSystem virtualSystem) { + this.virtualSystem = checkNotNull(virtualSystem, "virtualSystem"); + } + + public VirtualSystem getVirtualSystem() { + return virtualSystem; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OvfEnvelope other = (OvfEnvelope) obj; + if (virtualSystem == null) { + if (other.virtualSystem != null) + return false; + } else if (!virtualSystem.equals(other.virtualSystem)) + return false; + return true; + } + + @Override + public String toString() { + return "[virtualSystem=" + virtualSystem + "]"; + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java similarity index 99% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java index 68771b2608..da760e799d 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceAllocation.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java similarity index 98% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java index 06071d796f..15e05a0592 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/ResourceType.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/System.java similarity index 93% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/System.java index 4a748be3b0..6e629d2000 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/System.java @@ -17,17 +17,17 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; import static com.google.common.base.Preconditions.checkNotNull; -public class VirtualSystem { +public class System { protected final int id; protected final String name; protected final String identifier; protected final String type; - public VirtualSystem(int id, String name, String identifier, String type) { + public System(int id, String name, String identifier, String type) { this.id = id; this.name = checkNotNull(name, "name"); this.identifier = checkNotNull(identifier, "identifier"); @@ -69,7 +69,7 @@ public class VirtualSystem { return false; if (getClass() != obj.getClass()) return false; - VirtualSystem other = (VirtualSystem) obj; + System other = (System) obj; if (id != other.id) return false; if (identifier == null) { diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudHardDisk.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java similarity index 98% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudHardDisk.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java index 1dea40d936..f8b54e6770 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudHardDisk.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java @@ -17,7 +17,8 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; + /** * @author Adrian Cole diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudNetworkAdapter.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java similarity index 91% rename from vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudNetworkAdapter.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java index 7b1c4c387b..9540be1aba 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VCloudNetworkAdapter.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.domain; +package org.jclouds.vcloud.domain.ovf; /** * @author Adrian Cole @@ -88,9 +88,8 @@ public class VCloudNetworkAdapter extends ResourceAllocation { @Override public String toString() { return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType() - + ", virtualQuantity=" + getVirtualQuantity() + ", virtualQuantityUnits=" + getVirtualQuantityUnits() - + ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode + ", primaryNetworkConnection=" - + primaryNetworkConnection + "]"; + + ", address=" + getAddress() + ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode + + ", primaryNetworkConnection=" + primaryNetworkConnection + "]"; } } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystem.java new file mode 100644 index 0000000000..db833acc0b --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystem.java @@ -0,0 +1,121 @@ +/** + * + * 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.net.URI; + +import javax.annotation.Nullable; + +import org.jclouds.vcloud.domain.ReferenceType; + +/** + * A description of the operating system supported by a virtual machine. + */ +public class VCloudOperatingSystem extends OperatingSystem { + protected final String type; + protected final URI href; + @Nullable + protected final String vmwOsType; + protected final ReferenceType edit; + + public VCloudOperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description, String type, + URI href, @Nullable String vmwOsType, ReferenceType edit) { + super(id, info, description); + this.type = type; + this.href = href; + this.vmwOsType = vmwOsType; + this.edit = checkNotNull(edit, "edit"); + } + + public String getType() { + return type; + } + + public URI getHref() { + return href; + } + + /** + * + * @return VMware osType, if running on VMware + */ + public String getVmwOsType() { + return vmwOsType; + } + + /** + * + * @return edit link + */ + public ReferenceType getEdit() { + return edit; + } + + @Override + public String toString() { + return "[href=" + getHref() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" + getVmwOsType() + + ", description=" + getDescription() + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((edit == null) ? 0 : edit.hashCode()); + result = prime * result + ((href == null) ? 0 : href.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.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; + VCloudOperatingSystem other = (VCloudOperatingSystem) obj; + if (edit == null) { + if (other.edit != null) + return false; + } else if (!edit.equals(other.edit)) + return false; + 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; + if (vmwOsType == null) { + if (other.vmwOsType != null) + return false; + } else if (!vmwOsType.equals(other.vmwOsType)) + return false; + return true; + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java new file mode 100644 index 0000000000..64343be6d0 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ovf/VirtualSystem.java @@ -0,0 +1,118 @@ +/** + * + * 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 org.jclouds.vcloud.domain.VirtualHardware; + +/** + * @author Adrian Cole + */ +public class VirtualSystem { + private final String id; + private final String info; + private final String name; + private final OperatingSystem operatingSystem; + private final VirtualHardware hardware; + + public VirtualSystem(String id, String info, String name, OperatingSystem operatingSystem, VirtualHardware hardware) { + this.id = id; + this.info = info; + this.name = name; + this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem"); + this.hardware = checkNotNull(hardware, "hardware"); + } + + public String getId() { + return id; + } + + public String getInfo() { + return info; + } + + public String getName() { + return name; + } + + public OperatingSystem getOperatingSystem() { + return operatingSystem; + } + + public VirtualHardware getHardware() { + return hardware; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((hardware == null) ? 0 : hardware.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((info == null) ? 0 : info.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.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; + VirtualSystem other = (VirtualSystem) obj; + if (hardware == null) { + if (other.hardware != null) + return false; + } else if (!hardware.equals(other.hardware)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (info == null) { + if (other.info != null) + return false; + } else if (!info.equals(other.info)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (operatingSystem == null) { + if (other.operatingSystem != null) + return false; + } else if (!operatingSystem.equals(other.operatingSystem)) + return false; + return true; + } + + @Override + public String toString() { + return "[id=" + getId() + ", name=" + getName() + ", info=" + getInfo() + ", os=" + getOperatingSystem() + + ", hardware=" + getHardware() + "]"; + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java b/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java index c099184293..d5030b01ef 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/VCloudPredicates.java @@ -21,8 +21,8 @@ package org.jclouds.vcloud.predicates; import static com.google.common.base.Preconditions.checkNotNull; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.ResourceType; import com.google.common.base.Predicate; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/util/Utils.java b/vcloud/core/src/main/java/org/jclouds/vcloud/util/Utils.java index aa07a06f9a..69bda52775 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/util/Utils.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/util/Utils.java @@ -35,6 +35,7 @@ import com.google.common.collect.Maps; * @author Adrian Cole */ public class Utils { + public static ReferenceType newReferenceType(Map attributes, String defaultType) { String uri = attributes.get("href"); String type = attributes.get("type"); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java index d30aca60bb..1c5eab2466 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudExpressVAppHandler.java @@ -35,11 +35,13 @@ 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.ResourceAllocation; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.VirtualSystem; 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; @@ -52,20 +54,20 @@ import com.google.common.collect.Sets; */ public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult { private final String apiVersion; - private final VirtualSystemHandler systemHandler; + private final SystemHandler systemHandler; private final ResourceAllocationHandler allocationHandler; @Resource protected Logger logger = Logger.NULL; @Inject - public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, VirtualSystemHandler systemHandler, + public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler, ResourceAllocationHandler allocationHandler) { this.apiVersion = apiVersion; this.systemHandler = systemHandler; this.allocationHandler = allocationHandler; } - protected VirtualSystem system; + protected System system; protected Set allocations = Sets.newLinkedHashSet(); protected Status status; protected final ListMultimap networkToAddresses = ArrayListMultimap.create(); diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java new file mode 100644 index 0000000000..69a68872d5 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java @@ -0,0 +1,74 @@ +/** + * + * 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; + +import static org.jclouds.vcloud.util.Utils.cleanseAttributes; +import static org.jclouds.vcloud.util.Utils.newReferenceType; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.vcloud.domain.ReferenceType; +import org.jclouds.vcloud.domain.VCloudVirtualHardware; +import org.jclouds.vcloud.domain.VirtualHardware; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult { + + private final VirtualHardwareHandler hardwareHandler; + + private ReferenceType hardware; + + @Inject + public VCloudVirtualHardwareHandler(VirtualHardwareHandler hardwareHandler) { + this.hardwareHandler = hardwareHandler; + } + + public VCloudVirtualHardware getResult() { + VirtualHardware hardware = hardwareHandler.getResult(); + return new VCloudVirtualHardware(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware + .getSystem(), hardware.getResourceAllocations()); + } + + public void startElement(String uri, String localName, String qName, Attributes attrs) { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("VirtualHardwareSection")) { + hardware = newReferenceType(attributes); + } + hardwareHandler.startElement(uri, localName, qName, attrs); + } + + @Override + public void endElement(String uri, String localName, String qName) { + hardwareHandler.endElement(uri, localName, qName); + + } + + @Override + public void characters(char ch[], int start, int length) { + hardwareHandler.characters(ch, start, length); + } + +} diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualHardwareHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualHardwareHandler.java index 5ef40280e3..003c1a8284 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualHardwareHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VirtualHardwareHandler.java @@ -19,19 +19,16 @@ 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.Set; import javax.inject.Inject; import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.VirtualHardware; -import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.System; +import org.jclouds.vcloud.xml.ovf.SystemHandler; +import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationHandler; import org.xml.sax.Attributes; import com.google.common.collect.Sets; @@ -42,33 +39,27 @@ import com.google.common.collect.Sets; public class VirtualHardwareHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); - private final VirtualSystemHandler systemHandler; + private final SystemHandler systemHandler; private final VCloudResourceAllocationHandler allocationHandler; @Inject - public VirtualHardwareHandler(VirtualSystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) { + public VirtualHardwareHandler(SystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) { this.systemHandler = systemHandler; this.allocationHandler = allocationHandler; } - private ReferenceType hardware; private String info; - protected VirtualSystem system; + protected System system; protected Set allocations = Sets.newLinkedHashSet(); private boolean inItem; private boolean inSystem; public VirtualHardware getResult() { - return new VirtualHardware(hardware.getName(), hardware.getType(), hardware.getHref(), info, system, allocations); + return new VirtualHardware(info, system, allocations); } public void startElement(String uri, String localName, String qName, Attributes attrs) { - Map attributes = cleanseAttributes(attrs); - if (attributes.containsKey("href") && attributes.get("href").endsWith("/")) { - String href = attributes.get("href"); - attributes.put("href", href.substring(0, href.lastIndexOf('/'))); - } if (qName.endsWith("System")) { inSystem = true; } else if (!inSystem && qName.endsWith("Item")) { @@ -78,10 +69,7 @@ public class VirtualHardwareHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; - protected final VirtualHardwareHandler virtualHardwareHandler; - protected final OperatingSystemHandler operatingSystemHandler; + protected final VCloudVirtualHardwareHandler virtualHardwareHandler; + protected final VCloudOperatingSystemHandler operatingSystemHandler; @Inject - public VmHandler(TaskHandler taskHandler, VirtualHardwareHandler virtualHardwareHandler, - OperatingSystemHandler operatingSystemHandler) { + public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler, + VCloudOperatingSystemHandler operatingSystemHandler) { this.taskHandler = taskHandler; this.virtualHardwareHandler = virtualHardwareHandler; this.operatingSystemHandler = operatingSystemHandler; @@ -64,8 +65,8 @@ public class VmHandler extends ParseSax.HandlerWithResult { protected ReferenceType vdc; protected String description; protected List tasks = Lists.newArrayList(); - protected VirtualHardware hardware; - protected OperatingSystem os; + protected VCloudVirtualHardware hardware; + protected VCloudOperatingSystem os; protected String vAppScopedLocalId; private boolean inTasks; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OperatingSystemHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OperatingSystemHandler.java new file mode 100644 index 0000000000..f1a93fce2d --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OperatingSystemHandler.java @@ -0,0 +1,69 @@ +/** + * + * 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.OperatingSystem; +import org.jclouds.vcloud.util.Utils; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class OperatingSystemHandler extends ParseSax.HandlerWithResult { + private StringBuilder currentText = new StringBuilder(); + + protected Integer id; + protected String info; + protected String description; + + public OperatingSystem getResult() { + OperatingSystem system = new OperatingSystem(id, info, description); + id = null; + info = null; + description = null; + return system; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) { + Map attributes = Utils.cleanseAttributes(attrs); + if (qName.endsWith("OperatingSystemSection")) { + if (attributes.containsKey("id")) + this.id = Integer.parseInt(attributes.get("id")); + } + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (qName.endsWith("Info")) { + this.info = currentText.toString().trim(); + } else if (qName.endsWith("Description")) { + this.description = currentText.toString().trim(); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandler.java new file mode 100644 index 0000000000..92af054aa9 --- /dev/null +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandler.java @@ -0,0 +1,87 @@ +/** + * + * 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.vdc/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.jclouds.vcloud.util.Utils.cleanseAttributes; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.vcloud.domain.ovf.OvfEnvelope; +import org.jclouds.vcloud.domain.ovf.VirtualSystem; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +/** + * @author Adrian Cole + */ +public class OvfEnvelopeHandler extends ParseSax.HandlerWithResult { + + protected final VirtualSystemHandler virtualSystemHandler; + + @Inject + public OvfEnvelopeHandler(VirtualSystemHandler virtualSystemHandler) { + this.virtualSystemHandler = virtualSystemHandler; + } + + protected StringBuilder currentText = new StringBuilder(); + + private VirtualSystem virtualSystem; + + private boolean inVirtualSystem; + + public OvfEnvelope getResult() { + return new OvfEnvelope(virtualSystem); + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { +// Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("VirtualSystem")) { + inVirtualSystem = true; + } + if (inVirtualSystem) { + virtualSystemHandler.startElement(uri, localName, qName, attrs); + } + } + + public void endElement(String uri, String name, String qName) { + if (qName.endsWith("VirtualSystem")) { + inVirtualSystem = false; + virtualSystem = virtualSystemHandler.getResult(); + } + if (inVirtualSystem) { + virtualSystemHandler.endElement(uri, name, qName); + } + currentText = new StringBuilder(); + } + + public void characters(char ch[], int start, int length) { + if (inVirtualSystem) + virtualSystemHandler.characters(ch, start, length); + else + currentText.append(ch, start, length); + } + + protected String currentOrNull() { + String returnVal = currentText.toString().trim(); + return returnVal.equals("") ? null : returnVal; + } +} diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java similarity index 95% rename from vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java rename to vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java index 9ea2c12868..55547cc403 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ResourceAllocationHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandler.java @@ -17,11 +17,11 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml; +package org.jclouds.vcloud.xml.ovf; import org.jclouds.http.functions.ParseSax; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; +import org.jclouds.vcloud.domain.ovf.ResourceAllocation; +import org.jclouds.vcloud.domain.ovf.ResourceType; import org.xml.sax.Attributes; /** @@ -45,7 +45,7 @@ public class ResourceAllocationHandler extends ParseSax.HandlerWithResult { +public class SystemHandler extends ParseSax.HandlerWithResult { private StringBuilder currentText = new StringBuilder(); private String elementName; @@ -34,9 +34,9 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult { +public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult { private StringBuilder currentText = new StringBuilder(); protected ReferenceType os; @@ -42,9 +42,9 @@ public class OperatingSystemHandler 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.vcloud.xml.ovf; + +import static org.jclouds.vcloud.util.Utils.cleanseAttributes; + +import java.util.Map; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.jclouds.vcloud.domain.VirtualHardware; +import org.jclouds.vcloud.domain.ovf.OperatingSystem; +import org.jclouds.vcloud.domain.ovf.VirtualSystem; +import org.jclouds.vcloud.xml.VirtualHardwareHandler; +import org.xml.sax.Attributes; + +/** + * @author Adrian Cole + */ +public class VirtualSystemHandler extends ParseSax.HandlerWithResult { + protected StringBuilder currentText = new StringBuilder(); + private final OperatingSystemHandler osHandler; + private final VirtualHardwareHandler hardwareHandler; + + @Inject + public VirtualSystemHandler(OperatingSystemHandler osHandler, VirtualHardwareHandler hardwareHandler) { + this.osHandler = osHandler; + this.hardwareHandler = hardwareHandler; + } + + protected String id; + protected String info; + protected String name; + protected OperatingSystem operatingSystem; + protected VirtualHardware hardware; + + private boolean inHardware; + private boolean inOs; + private boolean inNetwork; + private boolean inGuest; + + public VirtualSystem getResult() { + VirtualSystem vs = new VirtualSystem(id, info, name, operatingSystem, hardware); + id = null; + info = null; + name = null; + operatingSystem = null; + hardware = null; + return vs; + } + + public void startElement(String uri, String localName, String qName, Attributes attrs) { + Map attributes = cleanseAttributes(attrs); + if (qName.endsWith("VirtualHardwareSection")) { + inHardware = true; + } else if (qName.endsWith("OperatingSystemSection")) { + inOs = true; + } else if (qName.endsWith("NetworkConnectionSection")) { + inNetwork = true; + } else if (qName.endsWith("GuestCustomizationSection")) { + inGuest = true; + } + + if (inHardware) { + hardwareHandler.startElement(uri, localName, qName, attrs); + } else if (inOs) { + osHandler.startElement(uri, localName, qName, attrs); + } else if (inNetwork) { + // TODO + } else if (inGuest) { + // TODO + } else if (qName.endsWith("VirtualSystem")) { + id = attributes.get("id"); + } + + } + + @Override + public void endElement(String uri, String localName, String qName) { + if (qName.endsWith("VirtualHardwareSection")) { + inHardware = false; + hardware = hardwareHandler.getResult(); + } else if (qName.endsWith("OperatingSystemSection")) { + inOs = false; + operatingSystem = osHandler.getResult(); + } else if (qName.endsWith("NetworkConnectionSection")) { + inNetwork = false; + // TODO + } else if (qName.endsWith("GuestCustomizationSection")) { + inNetwork = false; + // TODO + } + if (inHardware) { + hardwareHandler.endElement(uri, localName, qName); + } else if (inOs) { + osHandler.endElement(uri, localName, qName); + } else if (inNetwork) { + // TODO + } else if (inGuest) { + // TODO + } else if (qName.endsWith("Info")) { + info = currentText.toString().trim(); + } else if (qName.endsWith("Name")) { + name = currentText.toString().trim(); + } + currentText = new StringBuilder(); + } + + @Override + public void characters(char ch[], int start, int length) { + if (inHardware) + hardwareHandler.characters(ch, start, length); + else if (inOs) + osHandler.characters(ch, start, length); + else + currentText.append(ch, start, length); + + } + +} diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java index 4b8e708980..0374f2b57b 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java @@ -71,6 +71,7 @@ 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; @@ -327,6 +328,22 @@ public class VCloudAsyncClientTest extends RestClientTest { checkFilters(request); } + public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException { + Method method = VCloudAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class); + HttpRequest request = processor.createRequest(method, URI + .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")); + + assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1"); + assertNonPayloadHeadersEqual(request, "Accept: text/xml\n"); + assertPayloadEquals(request, null, null, false); + + assertResponseParserClassEquals(method, request, ParseSax.class); + assertSaxResponseParserClassEquals(method, OvfEnvelopeHandler.class); + assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class); + + checkFilters(request); + } + public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException { Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); HttpRequest request = processor.createRequest(method, "org", "vdc"); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index e560c3b990..6a4e812fd0 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -67,6 +67,26 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest networkToAddresses = ImmutableListMultimap. of("Public Network", "10.150.4.93"); - VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "centos53", "vmx-07"); + System system = new System(0, "Virtual Hardware Family", "centos53", "vmx-07"); Set resourceAllocations = ImmutableSet. of(new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, @@ -125,7 +125,7 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest { ListMultimap networkToAddresses = ImmutableListMultimap. of("Public Network", "10.23.119.221"); - VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "m1", "vmx-07"); + System system = new System(0, "Virtual Hardware Family", "m1", "vmx-07"); Set resourceAllocations = ImmutableSet. of(new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualHardwareHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandlerTest.java similarity index 83% rename from vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualHardwareHandlerTest.java rename to vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandlerTest.java index 3c1ef4a646..27f0c1ee2b 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualHardwareHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandlerTest.java @@ -26,41 +26,41 @@ import java.net.URI; import java.net.UnknownHostException; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.EditableResourceAllocation; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; -import org.jclouds.vcloud.domain.VCloudHardDisk; -import org.jclouds.vcloud.domain.VCloudNetworkAdapter; -import org.jclouds.vcloud.domain.VirtualHardware; -import org.jclouds.vcloud.domain.VirtualSystem; +import org.jclouds.vcloud.domain.VCloudVirtualHardware; 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.VCloudHardDisk; +import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter; import org.testng.annotations.Test; import com.google.common.collect.Iterables; /** - * Tests behavior of {@code VirtualHardwareHandler} + * Tests behavior of {@code VCloudVirtualHardwareHandler} * * @author Adrian Cole */ -@Test(groups = "unit", testName = "vcloud.VirtualHardwareHandlerTest") -public class VirtualHardwareHandlerTest extends BaseHandlerTest { +@Test(groups = "unit", testName = "vcloud.VCloudVirtualHardwareHandlerTest") +public class VCloudVirtualHardwareHandlerTest extends BaseHandlerTest { public void testDefault() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml"); - VirtualHardware result = factory.create(injector.getInstance(VirtualHardwareHandler.class)).parse(is); + VCloudVirtualHardware result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)).parse(is); checkHardware(result); } - static void checkHardware(VirtualHardware result) { - VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "RHEL5", "vmx-07"); + @Test(enabled = false) + public static void checkHardware(VCloudVirtualHardware result) { + System system = new System(0, "Virtual Hardware Family", "RHEL5", "vmx-07"); assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection")); - assertEquals(result.getName(), null); + .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.getInfo(), "Virtual hardware requirements"); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java index 6d87c7e5f7..8ea6e45ceb 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java @@ -31,6 +31,7 @@ import org.jclouds.vcloud.VCloudMediaType; 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.VCloudOperatingSystemHandlerTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -62,8 +63,8 @@ public class VmHandlerTest { assertEquals(result.getDescription(), null); assertEquals(result.getTasks(), ImmutableList.of()); assertEquals(result.getVAppScopedLocalId(), "10_rhel_template"); - VirtualHardwareHandlerTest.checkHardware(result.getHardware()); - OperatingSystemHandlerTest.checkOs(result.getOperatingSystem()); + VCloudVirtualHardwareHandlerTest.checkHardware(result.getHardware()); + VCloudOperatingSystemHandlerTest.checkOs(result.getOperatingSystem()); } } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java new file mode 100644 index 0000000000..becfc46a7e --- /dev/null +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/OvfEnvelopeHandlerTest.java @@ -0,0 +1,52 @@ +/** + * + * 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.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.OvfEnvelope; +import org.testng.annotations.Test; + +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests behavior of {@code OvfEnvelopeHandler} + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "vcloud.OvfEnvelopeHandlerTest") +public class OvfEnvelopeHandlerTest { + public void testVCloud1_0() { + InputStream is = getClass().getResourceAsStream("/ovf.xml"); + Injector injector = Guice.createInjector(new SaxParserModule()); + Factory factory = injector.getInstance(ParseSax.Factory.class); + OvfEnvelope result = factory.create(injector.getInstance(OvfEnvelopeHandler.class)).parse(is); + checkOvfEnvelope(result); + } + + static void checkOvfEnvelope(OvfEnvelope result) { + VirtualSystemHandlerTest.checkVirtualSystem(result.getVirtualSystem()); + } + +} diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ResourceAllocationHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java similarity index 89% rename from vcloud/core/src/test/java/org/jclouds/vcloud/xml/ResourceAllocationHandlerTest.java rename to vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java index c6ff9455f6..5c01708645 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ResourceAllocationHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/ResourceAllocationHandlerTest.java @@ -17,15 +17,16 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml; +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.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; +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; /** diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualSystemHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java similarity index 70% rename from vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualSystemHandlerTest.java rename to vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java index 0da46903db..8e8e1b748c 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VirtualSystemHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/SystemHandlerTest.java @@ -17,31 +17,30 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml; +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.VirtualSystem; +import org.jclouds.vcloud.domain.ovf.System; import org.testng.annotations.Test; /** - * Tests behavior of {@code VirtualSystemHandler} + * Tests behavior of {@code SystemHandler} * * @author Adrian Cole */ -@Test(groups = "unit", testName = "vcloud.VirtualSystemHandlerTest") -public class VirtualSystemHandlerTest extends BaseHandlerTest { +@Test(groups = "unit", testName = "vcloud.SystemHandlerTest") +public class SystemHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml"); - VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)) - .parse(is); + System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is); - VirtualSystem expects = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-04"); + System expects = new System(0, "Virtual Hardware Family", "SimpleVM", "vmx-04"); assertEquals(result, expects); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/OperatingSystemHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandlerTest.java similarity index 76% rename from vcloud/core/src/test/java/org/jclouds/vcloud/xml/OperatingSystemHandlerTest.java rename to vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandlerTest.java index 8a36f4f979..e4b5b69b56 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/OperatingSystemHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandlerTest.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.jclouds.vcloud.xml; +package org.jclouds.vcloud.xml.ovf; import static org.testng.Assert.assertEquals; @@ -26,37 +26,38 @@ import java.net.URI; import java.net.UnknownHostException; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.OperatingSystem; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; +import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem; +import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler; import org.testng.annotations.Test; /** - * Tests behavior of {@code OperatingSystemHandler} + * Tests behavior of {@code VCloudOperatingSystemHandler} * * @author Adrian Cole */ -@Test(groups = "unit", testName = "vcloud.OperatingSystemHandlerTest") -public class OperatingSystemHandlerTest extends BaseHandlerTest { +@Test(groups = "unit", testName = "vcloud.VCloudOperatingSystemHandlerTest") +public class VCloudOperatingSystemHandlerTest extends BaseHandlerTest { public void testDefault() throws UnknownHostException { InputStream is = getClass().getResourceAsStream("/os.xml"); - OperatingSystem result = factory.create(injector.getInstance(OperatingSystemHandler.class)).parse(is); + VCloudOperatingSystem result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is); checkOs(result); } - static void checkOs(OperatingSystem result) { + @Test(enabled = false) + public static void checkOs(VCloudOperatingSystem result) { assertEquals(result.getHref(), URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection")); + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/")); assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)"); assertEquals(result.getEdit(), new ReferenceTypeImpl(null, "application/vnd.vmware.vcloud.operatingSystemSection+xml", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"))); assertEquals(result.getId(), new Integer(80)); assertEquals(result.getVmwOsType(), "rhel5_64Guest"); - assertEquals(result.getName(), null); assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml"); assertEquals(result.getInfo(), "Specifies the operating system installed"); } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.java new file mode 100644 index 0000000000..d08e97faaf --- /dev/null +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/ovf/VirtualSystemHandlerTest.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.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.VirtualHardware; +import org.jclouds.vcloud.domain.ovf.OperatingSystem; +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.VirtualSystem; +import org.jclouds.vcloud.xml.ovf.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 VirtualSystemHandler} + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "vcloud.VirtualSystemHandlerTest") +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(result.getHardware()); + checkOs(result.getOperatingSystem()); + } + + @Test(enabled = false) + public static void checkHardware(VirtualHardware result) { + assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "Ubuntu1004", "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(OperatingSystem 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/vcloud/core/src/test/resources/ovf.xml b/vcloud/core/src/test/resources/ovf.xml new file mode 100644 index 0000000000..383c27cc71 --- /dev/null +++ b/vcloud/core/src/test/resources/ovf.xml @@ -0,0 +1,183 @@ + + + + + The list of logical networks + + + + + + The configuration parameters for logical networks + + + + + false + 192.168.2.1 + 255.255.255.0 + 8.8.8.8 + + + 192.168.2.100 + 192.168.2.199 + + + + 192.168.2.100 + + + isolated + + + false + 7200 + 7200 + + + + true + + + true + ipTranslation + allowTraffic + + + automatic + 02_ubuntu_template + 0 + + + + + + false + + + + Lease settings section + 0 + 0 + + + VApp template customization section + true + + + A virtual machine: + Ubuntu1004 + + Specifies the operating system installed + Ubuntu Linux (64-bit) + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + Ubuntu1004 + vmx-07 + + + 00:50:56:8c:00:13 + 0 + true + vAppNet-vApp Internal + 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 + 512 MB of memory + 5 + 0 + 4 + 512 + 0 + + + + Specifies the available VM network connections + 0 + + 0 + 192.168.2.100 + true + 00:50:56:8c:00:13 + POOL + + + + Specifies Guest OS Customization Settings + true + false + 172837194 + false + false + true + true + %3eD%gmF + false + #!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi + Ubuntu1004 + + + \ No newline at end of file diff --git a/vcloud/core/src/test/resources/virtualsystem.xml b/vcloud/core/src/test/resources/virtualsystem.xml new file mode 100644 index 0000000000..0eb2a03098 --- /dev/null +++ b/vcloud/core/src/test/resources/virtualsystem.xml @@ -0,0 +1,127 @@ + + + A virtual machine: + Ubuntu1004 + + Specifies the operating system installed + Ubuntu Linux (64-bit) + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + Ubuntu1004 + vmx-07 + + + 00:50:56:8c:00:13 + 0 + true + vAppNet-vApp Internal + 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 + 512 MB of memory + 5 + 0 + 4 + 512 + 0 + + + + Specifies the available VM network connections + 0 + + 0 + 192.168.2.100 + true + 00:50:56:8c:00:13 + POOL + + + + Specifies Guest OS Customization Settings + true + false + 172837194 + false + false + true + true + %3eD%gmF + false + #!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi + Ubuntu1004 + + \ No newline at end of file diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java index 6cebcf6d99..d09ec97ab8 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayload.java @@ -43,10 +43,10 @@ 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.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; 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; diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java index f3db45cc6d..a18b9a4b28 100644 --- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/binders/TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.java @@ -39,7 +39,7 @@ import javax.xml.transform.TransformerException; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; -import org.jclouds.vcloud.domain.ResourceType; +import org.jclouds.vcloud.domain.ovf.ResourceType; import com.jamesmurty.utils.XMLBuilder; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java index 07c986fc8a..19e03d6ed1 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/TerremarkClientLiveTest.java @@ -51,13 +51,13 @@ import org.jclouds.vcloud.VCloudExpressClientLiveTest; import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; 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.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; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java index f13ae53728..67548c28e6 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/binders/BindVAppConfigurationToXmlPayloadTest.java @@ -32,10 +32,10 @@ import java.util.Properties; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Utils; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; 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.TerremarkVCloudExpressPropertiesBuilder; import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.testng.annotations.Test; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java index 7f7af6d3fc..f64a5edec9 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/ResourceAllocationHandlerTest.java @@ -24,9 +24,9 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; -import org.jclouds.vcloud.xml.ResourceAllocationHandler; +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; diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java index 0ca05e6c2c..cc42460b74 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VAppHandlerTest.java @@ -35,12 +35,12 @@ import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.vcloud.VCloudExpressMediaType; -import org.jclouds.vcloud.domain.ResourceAllocation; -import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.VCloudExpressVApp; -import org.jclouds.vcloud.domain.VirtualSystem; 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; @@ -109,7 +109,7 @@ 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 VirtualSystem(0, "Virtual Hardware Family", "centos-53", "vmx-07")); + assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "centos-53", "vmx-07")); assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList. of("10.114.34.132")); ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs", @@ -147,7 +147,7 @@ public class VAppHandlerTest extends BaseHandlerTest { assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32"))); - assertEquals(vApp.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "eduardo", "vmx-07")); + assertEquals(vApp.getSystem(), new System(0, "Virtual Hardware Family", "eduardo", "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", diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandlerTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandlerTest.java index 19da0c2c45..fec3466b4b 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandlerTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/xml/VirtualSystemHandlerTest.java @@ -24,8 +24,8 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.domain.VirtualSystem; -import org.jclouds.vcloud.xml.VirtualSystemHandler; +import org.jclouds.vcloud.domain.ovf.System; +import org.jclouds.vcloud.xml.ovf.SystemHandler; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -46,8 +46,7 @@ public class VirtualSystemHandlerTest extends BaseHandlerTest { public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/terremark/system.xml"); - VirtualSystem result = factory.create( - injector.getInstance(VirtualSystemHandler.class)).parse(is); + System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is); assertEquals(result.getName(), "Virtual Hardware Family"); assertEquals(result.getId(), 0); assertEquals(result.getIdentifier(), "adriantest1");