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