mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of git://github.com/jclouds/jclouds into large-blob
This commit is contained in:
commit
124b8681dc
|
@ -60,6 +60,7 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
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.
|
* 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
|
* Creates a default implementation of AtmosObject
|
||||||
*/
|
*/
|
||||||
|
@Provides
|
||||||
AtmosObject newObject();
|
AtmosObject newObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.jclouds.atmos.options.ListOptions;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to EMC Atmos Online Storage resources via their REST API.
|
* Provides access to EMC Atmos Online Storage resources via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -44,6 +46,7 @@ public interface AtmosClient {
|
||||||
/**
|
/**
|
||||||
* Creates a default implementation of AtmosObject
|
* Creates a default implementation of AtmosObject
|
||||||
*/
|
*/
|
||||||
|
@Provides
|
||||||
AtmosObject newObject();
|
AtmosObject newObject();
|
||||||
|
|
||||||
BoundedSet<? extends DirectoryEntry> listDirectories(ListOptions... options);
|
BoundedSet<? extends DirectoryEntry> listDirectories(ListOptions... options);
|
||||||
|
|
|
@ -88,6 +88,7 @@ import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to S3 via their REST API.
|
* Provides asynchronous access to S3 via their REST API.
|
||||||
|
@ -110,6 +111,7 @@ public interface S3AsyncClient {
|
||||||
/**
|
/**
|
||||||
* Creates a default implementation of S3Object
|
* Creates a default implementation of S3Object
|
||||||
*/
|
*/
|
||||||
|
@Provides
|
||||||
public S3Object newS3Object();
|
public S3Object newS3Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,8 @@ import org.jclouds.s3.options.PutObjectOptions;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +60,7 @@ public interface S3Client {
|
||||||
/**
|
/**
|
||||||
* Creates a default implementation of S3Object
|
* Creates a default implementation of S3Object
|
||||||
*/
|
*/
|
||||||
|
@Provides
|
||||||
public S3Object newS3Object();
|
public S3Object newS3Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,7 +42,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
@ -61,7 +61,7 @@ public class CopyObjectOptionsTest {
|
||||||
private String nowExpected;
|
private String nowExpected;
|
||||||
private Map<String, String> goodMeta;
|
private Map<String, String> goodMeta;
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeTest
|
||||||
void setUp() {
|
void setUp() {
|
||||||
goodMeta = ImmutableMap.of(USER_METADATA_PREFIX + "adrian", "foo");
|
goodMeta = ImmutableMap.of(USER_METADATA_PREFIX + "adrian", "foo");
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common features between OpenStack Swift and CloudFiles
|
* Common features between OpenStack Swift and CloudFiles
|
||||||
|
@ -76,7 +77,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@RequestFilters(AuthenticateRequest.class)
|
@RequestFilters(AuthenticateRequest.class)
|
||||||
@Endpoint(Storage.class)
|
@Endpoint(Storage.class)
|
||||||
public interface CommonSwiftAsyncClient {
|
public interface CommonSwiftAsyncClient {
|
||||||
|
@Provides
|
||||||
SwiftObject newSwiftObject();
|
SwiftObject newSwiftObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.jclouds.openstack.swift.domain.ObjectInfo;
|
||||||
import org.jclouds.openstack.swift.domain.SwiftObject;
|
import org.jclouds.openstack.swift.domain.SwiftObject;
|
||||||
import org.jclouds.openstack.swift.options.ListContainerOptions;
|
import org.jclouds.openstack.swift.options.ListContainerOptions;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common features between OpenStack Swift and CloudFiles
|
* Common features between OpenStack Swift and CloudFiles
|
||||||
*
|
*
|
||||||
|
@ -42,7 +44,7 @@ import org.jclouds.openstack.swift.options.ListContainerOptions;
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 120, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface CommonSwiftClient {
|
public interface CommonSwiftClient {
|
||||||
|
@Provides
|
||||||
SwiftObject newSwiftObject();
|
SwiftObject newSwiftObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,6 +42,8 @@ import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
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.predicates.validators.DnsNameValidator;
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
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.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.Vm;
|
import org.jclouds.vcloud.domain.Vm;
|
||||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
|
||||||
import org.jclouds.vcloud.endpoints.OrgList;
|
import org.jclouds.vcloud.endpoints.OrgList;
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
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.VAppHandler;
|
||||||
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
||||||
import org.jclouds.vcloud.xml.VmHandler;
|
import org.jclouds.vcloud.xml.VmHandler;
|
||||||
import org.jclouds.vcloud.xml.ovf.OvfEnvelopeHandler;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
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.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.Vm;
|
import org.jclouds.vcloud.domain.Vm;
|
||||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
|
||||||
import org.jclouds.vcloud.options.CaptureVAppOptions;
|
import org.jclouds.vcloud.options.CaptureVAppOptions;
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
String networkName;
|
String networkName;
|
||||||
VAppTemplate vAppTemplate = client.getVAppTemplate(template);
|
VAppTemplate vAppTemplate = client.getVAppTemplate(template);
|
||||||
checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
|
checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
|
||||||
Set<org.jclouds.vcloud.domain.ovf.network.Network> networks = vAppTemplate.getNetworkSection().getNetworks();
|
Set<org.jclouds.ovf.Network> networks = vAppTemplate.getNetworkSection().getNetworks();
|
||||||
checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
|
checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
|
||||||
if (networks.size() > 1)
|
if (networks.size() > 1)
|
||||||
logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
|
logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
|
||||||
|
|
|
@ -20,32 +20,20 @@
|
||||||
package org.jclouds.vcloud.compute.functions;
|
package org.jclouds.vcloud.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
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.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.ovf.VirtualHardwareSection;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.Vm;
|
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.base.Function;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -56,13 +44,13 @@ public class HardwareForVApp implements Function<VApp, Hardware> {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final FindLocationForResource findLocationForResource;
|
private final FindLocationForResource findLocationForResource;
|
||||||
private final ResourceAllocationsToVolumes resourceAllocationsToVolumes;
|
private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected HardwareForVApp(FindLocationForResource findLocationForResource,
|
protected HardwareForVApp(FindLocationForResource findLocationForResource,
|
||||||
ResourceAllocationsToVolumes resourceAllocationsToVolumes) {
|
VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
|
||||||
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
||||||
this.resourceAllocationsToVolumes = checkNotNull(resourceAllocationsToVolumes, "resourceAllocationsToVolumes");
|
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,25 +60,12 @@ public class HardwareForVApp implements Function<VApp, Hardware> {
|
||||||
Vm vm = from.getChildren().size() == 0 ? null : Iterables.get(from.getChildren(), 0);
|
Vm vm = from.getChildren().size() == 0 ? null : Iterables.get(from.getChildren(), 0);
|
||||||
if (vm == null)
|
if (vm == null)
|
||||||
return null;
|
return null;
|
||||||
Location location = findLocationForResource.apply(checkNotNull(from, "from").getVDC());
|
|
||||||
|
|
||||||
VirtualHardwareSection hardware = vm.getVirtualHardwareSection();
|
VirtualHardwareSection hardware = vm.getVirtualHardwareSection();
|
||||||
|
HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getResourceAllocations());
|
||||||
int ram = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity();
|
builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
|
||||||
|
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
|
||||||
List<Processor> processors = Lists.newArrayList(transform(
|
ImagePredicates.idEquals(from.getHref().toASCIIString()));
|
||||||
filter(hardware.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)),
|
return builder.build();
|
||||||
new Function<ResourceAllocation, Processor>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Processor apply(ResourceAllocation arg0) {
|
|
||||||
return new Processor(arg0.getVirtualQuantity(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
List<Volume> 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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,34 +20,22 @@
|
||||||
package org.jclouds.vcloud.compute.functions;
|
package org.jclouds.vcloud.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
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.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
|
import org.jclouds.ovf.VirtualHardwareSection;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
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.base.Function;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -59,16 +47,16 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
|
|
||||||
private final VCloudClient client;
|
private final VCloudClient client;
|
||||||
private final FindLocationForResource findLocationForResource;
|
private final FindLocationForResource findLocationForResource;
|
||||||
private final ResourceAllocationsToVolumes resourceAllocationsToVolumes;
|
private final VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
|
||||||
|
|
||||||
private ReferenceType parent;
|
private ReferenceType parent;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
|
protected HardwareForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
|
||||||
ResourceAllocationsToVolumes resourceAllocationsToVolumes) {
|
VCloudHardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
||||||
this.resourceAllocationsToVolumes = checkNotNull(resourceAllocationsToVolumes, "resourceAllocationsToVolumes");
|
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HardwareForVAppTemplate withParent(ReferenceType parent) {
|
public HardwareForVAppTemplate withParent(ReferenceType parent) {
|
||||||
|
@ -90,8 +78,6 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
logger.warn("cannot parse hardware as no ovf envelope found for %s", from);
|
logger.warn("cannot parse hardware as no ovf envelope found for %s", from);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = findLocationForResource.apply(checkNotNull(parent, "parent"));
|
|
||||||
if (ovf.getVirtualSystem().getHardware().size() == 0) {
|
if (ovf.getVirtualSystem().getHardware().size() == 0) {
|
||||||
logger.warn("cannot parse hardware for %s as no hardware sections exist in ovf %s", ovf);
|
logger.warn("cannot parse hardware for %s as no hardware sections exist in ovf %s", ovf);
|
||||||
return null;
|
return null;
|
||||||
|
@ -100,24 +86,11 @@ public class HardwareForVAppTemplate implements Function<VAppTemplate, Hardware>
|
||||||
logger.warn("multiple hardware choices found. using first", ovf);
|
logger.warn("multiple hardware choices found. using first", ovf);
|
||||||
}
|
}
|
||||||
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getHardware(), 0);
|
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getHardware(), 0);
|
||||||
|
HardwareBuilder builder = rasdToHardwareBuilder.apply(hardware.getResourceAllocations());
|
||||||
int ram = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity();
|
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
|
||||||
|
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
|
||||||
List<Processor> processors = Lists.newArrayList(transform(
|
ImagePredicates.idEquals(from.getHref().toASCIIString()));
|
||||||
filter(hardware.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)),
|
return builder.build();
|
||||||
new Function<ResourceAllocation, Processor>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Processor apply(ResourceAllocation arg0) {
|
|
||||||
return new Processor(arg0.getVirtualQuantity(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
List<Volume> 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();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getName(String name) {
|
protected String getName(String name) {
|
||||||
|
|
|
@ -20,17 +20,17 @@
|
||||||
package org.jclouds.vcloud.compute.functions;
|
package org.jclouds.vcloud.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.ImageBuilder;
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
|
||||||
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
|
builder.location(findLocationForResource.apply(checkNotNull(parent, "parent")));
|
||||||
builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
|
builder.description(from.getDescription() != null ? from.getDescription() : from.getName());
|
||||||
OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref());
|
OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref());
|
||||||
builder.operatingSystem(toComputeOs(ovf));
|
builder.operatingSystem(CIMOperatingSystem.toComputeOs(ovf));
|
||||||
builder.defaultCredentials(credentialsProvider.execute(from));
|
builder.defaultCredentials(credentialsProvider.execute(from));
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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<? extends ResourceAllocation>, Iterable<Volume>> {
|
|
||||||
@Override
|
|
||||||
public Iterable<Volume> apply(Iterable<? extends ResourceAllocation> resourceAllocations) {
|
|
||||||
Iterable<Volume> volumes = transform(filter(resourceAllocations, resourceType(ResourceType.DISK_DRIVE)),
|
|
||||||
new Function<ResourceAllocation, Volume>() {
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,25 +20,24 @@
|
||||||
package org.jclouds.vcloud.compute.util;
|
package org.jclouds.vcloud.compute.util;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
|
||||||
|
|
||||||
import java.util.Set;
|
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.OperatingSystem;
|
||||||
import org.jclouds.compute.domain.os.CIMOperatingSystem;
|
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.Vm;
|
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 org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
|
||||||
import com.google.common.collect.Iterables;
|
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;
|
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) {
|
public static CIMOperatingSystem toComputeOs(Vm vm) {
|
||||||
return toComputeOs(vm.getOperatingSystemSection());
|
return CIMOperatingSystem.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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Credentials getCredentialsFrom(VApp vApp) {
|
public static Credentials getCredentialsFrom(VApp vApp) {
|
||||||
|
@ -106,8 +97,8 @@ public class VCloudComputeUtils {
|
||||||
ips.add(connection.getExternalIpAddress());
|
ips.add(connection.getExternalIpAddress());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ResourceAllocation net : filter(vm.getVirtualHardwareSection().getResourceAllocations(),
|
for (ResourceAllocationSettingData net : filter(vm.getVirtualHardwareSection().getResourceAllocations(),
|
||||||
resourceType(ResourceType.ETHERNET_ADAPTER))) {
|
CIMPredicates.resourceTypeIn(ResourceType.ETHERNET_ADAPTER))) {
|
||||||
if (net instanceof VCloudNetworkAdapter) {
|
if (net instanceof VCloudNetworkAdapter) {
|
||||||
VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
|
VCloudNetworkAdapter vNet = VCloudNetworkAdapter.class.cast(net);
|
||||||
if (vNet.getIpAddress() != null)
|
if (vNet.getIpAddress() != null)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.rest.AsyncClientFactory;
|
import org.jclouds.rest.AsyncClientFactory;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
@ -38,16 +39,15 @@ import org.jclouds.vcloud.domain.CatalogItem;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.VCloudSession;
|
import org.jclouds.vcloud.domain.VCloudSession;
|
||||||
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
|
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the VCloud authentication service connection, including logging
|
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||||
* and http transport.
|
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +65,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
|
bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VAppTemplate>>>() {
|
||||||
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
|
||||||
});
|
});
|
||||||
|
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
||||||
super.configure();
|
super.configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@ package org.jclouds.vcloud.domain;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
import org.jclouds.vcloud.domain.ovf.System;
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -33,10 +33,10 @@ import com.google.common.collect.Sets;
|
||||||
public class InstantiateVAppTemplateParams {
|
public class InstantiateVAppTemplateParams {
|
||||||
|
|
||||||
protected final String info;
|
protected final String info;
|
||||||
protected final System virtualSystem;
|
protected final VirtualSystemSettingData virtualSystem;
|
||||||
protected final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
|
protected final Set<ResourceAllocationSettingData> 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.info = info;
|
||||||
this.virtualSystem = virtualSystem;
|
this.virtualSystem = virtualSystem;
|
||||||
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
||||||
|
@ -46,11 +46,11 @@ public class InstantiateVAppTemplateParams {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public System getSystem() {
|
public VirtualSystemSettingData getSystem() {
|
||||||
return virtualSystem;
|
return virtualSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<? extends ResourceAllocation> getResourceAllocations() {
|
public Set<? extends ResourceAllocationSettingData> getResourceAllocationSettingDatas() {
|
||||||
return resourceAllocations;
|
return resourceAllocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,303 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* 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<String> 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<String> 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<String> connections, List<String> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,21 +19,283 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.vcloud.domain.ovf;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @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<String> 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<String> 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 long capacity;
|
||||||
private final int busType;
|
private final int busType;
|
||||||
private final String busSubType;
|
private final String busSubType;
|
||||||
|
|
||||||
public VCloudHardDisk(int id, String name, String description, ResourceType type, String subType,
|
public VCloudHardDisk(String elementName, String instanceID, String caption, String description, String address,
|
||||||
String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected,
|
String addressOnParent, String allocationUnits, Boolean automaticAllocation, Boolean automaticDeallocation,
|
||||||
long virtualQuantity, String virtualQuantityUnits, long capacity, int busType, String busSubType) {
|
ConsumerVisibility consumerVisibility, Long limit, MappingBehavior mappingBehavior,
|
||||||
super(id, name, description, type, subType, hostResource, address, addressOnParent, parent, connected,
|
String otherResourceType, String parent, String poolID, Long reservation, String resourceSubType,
|
||||||
virtualQuantity, virtualQuantityUnits);
|
org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType, Long virtualQuantity,
|
||||||
|
String virtualQuantityUnits, Integer weight, List<String> connections, List<String> 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.capacity = capacity;
|
||||||
this.busType = busType;
|
this.busType = busType;
|
||||||
this.busSubType = busSubType;
|
this.busSubType = busSubType;
|
||||||
|
@ -52,41 +314,18 @@ public class VCloudHardDisk extends ResourceAllocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public Builder toBuilder() {
|
||||||
final int prime = 31;
|
return builder().fromVCloudHardDisk(this);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType()
|
return String
|
||||||
+ ", virtualQuantity=" + getVirtualQuantity() + ", virtualQuantityUnits=" + getVirtualQuantityUnits()
|
.format(
|
||||||
+ ", capacity=" + capacity + ", busType=" + busType + ", busSubType=" + busSubType + "]";
|
"[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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,21 +19,283 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.vcloud.domain.ovf;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @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<String> 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<String> 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 String ipAddress;
|
||||||
private final boolean primaryNetworkConnection;
|
private final boolean primaryNetworkConnection;
|
||||||
private final String ipAddressingMode;
|
private final String ipAddressingMode;
|
||||||
|
|
||||||
public VCloudNetworkAdapter(int id, String name, String description, ResourceType type, String subType,
|
public VCloudNetworkAdapter(String elementName, String instanceID, String caption, String description,
|
||||||
String hostResource, String address, Integer addressOnParent, Integer parent, Boolean connected,
|
String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation,
|
||||||
long virtualQuantity, String virtualQuantityUnits, String ipAddress, boolean primaryNetworkConnection,
|
Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit,
|
||||||
String ipAddressingMode) {
|
MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation,
|
||||||
super(id, name, description, type, subType, hostResource, address, addressOnParent, parent, connected,
|
String resourceSubType, org.jclouds.cim.ResourceAllocationSettingData.ResourceType resourceType,
|
||||||
virtualQuantity, virtualQuantityUnits);
|
Long virtualQuantity, String virtualQuantityUnits, Integer weight, List<String> connections,
|
||||||
|
List<String> 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.ipAddress = ipAddress;
|
||||||
this.primaryNetworkConnection = primaryNetworkConnection;
|
this.primaryNetworkConnection = primaryNetworkConnection;
|
||||||
this.ipAddressingMode = ipAddressingMode;
|
this.ipAddressingMode = ipAddressingMode;
|
||||||
|
@ -52,44 +314,19 @@ public class VCloudNetworkAdapter extends ResourceAllocation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public Builder toBuilder() {
|
||||||
final int prime = 31;
|
return builder().fromVCloudNetworkAdapter(this);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType()
|
return String
|
||||||
+ ", address=" + getAddress() + ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode
|
.format(
|
||||||
+ ", primaryNetworkConnection=" + primaryNetworkConnection + "]";
|
"[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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,7 +21,8 @@ package org.jclouds.vcloud.domain.ovf;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
import org.jclouds.ovf.Network;
|
||||||
|
import org.jclouds.ovf.NetworkSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VCloud extension
|
* VCloud extension
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.ovf.OperatingSystemSection;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.vcloud.domain.ovf;
|
||||||
|
|
||||||
import java.net.URI;
|
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.
|
* 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 String type;
|
||||||
protected final URI href;
|
protected final URI href;
|
||||||
|
|
||||||
public VCloudVirtualHardwareSection(String type, URI href, String info, System virtualSystem,
|
public VCloudVirtualHardwareSection(String type, URI href, String info, VirtualSystemSettingData virtualSystem,
|
||||||
Iterable<? extends ResourceAllocation> resourceAllocations) {
|
Iterable<? extends ResourceAllocationSettingData> resourceAllocations) {
|
||||||
super(info, virtualSystem, resourceAllocations);
|
super(info, virtualSystem, resourceAllocations);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.href = href;
|
this.href = href;
|
||||||
|
@ -46,11 +49,7 @@ public class VCloudVirtualHardwareSection extends VirtualHardwareSection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
return href.hashCode();
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
|
||||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,17 +61,7 @@ public class VCloudVirtualHardwareSection extends VirtualHardwareSection {
|
||||||
if (getClass() != obj.getClass())
|
if (getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj;
|
VCloudVirtualHardwareSection other = (VCloudVirtualHardwareSection) obj;
|
||||||
if (href == null) {
|
return href.equals(other.href);
|
||||||
if (other.href != null)
|
|
||||||
return false;
|
|
||||||
} else if (!href.equals(other.href))
|
|
||||||
return false;
|
|
||||||
if (type == null) {
|
|
||||||
if (other.type != null)
|
|
||||||
return false;
|
|
||||||
} else if (!type.equals(other.type))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.xml.sax.Attributes;
|
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) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
this.currentText = new StringBuilder();
|
this.currentText = new StringBuilder();
|
||||||
if (qName.endsWith("GuestCustomizationSection")) {
|
if (qName.endsWith("GuestCustomizationSection")) {
|
||||||
guest = newReferenceType(attributes);
|
guest = newReferenceType(attributes);
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||||
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
@ -56,7 +55,7 @@ public class NetworkConnectionHandler extends ParseSax.HandlerWithResult<Network
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("NetworkConnection")) {
|
if (qName.endsWith("NetworkConnection")) {
|
||||||
network = attributes.get("network");
|
network = attributes.get("network");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -28,6 +27,7 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnection;
|
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
@ -62,7 +62,7 @@ public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("NetworkConnection")) {
|
if (qName.endsWith("NetworkConnection")) {
|
||||||
inConnections = true;
|
inConnections = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
@ -75,7 +75,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Children")) {
|
if (qName.endsWith("Children")) {
|
||||||
inChildren = true;
|
inChildren = true;
|
||||||
} else if (qName.endsWith("Tasks")) {
|
} else if (qName.endsWith("Tasks")) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
@ -83,7 +83,7 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Children")) {
|
if (qName.endsWith("Children")) {
|
||||||
inChildren = true;
|
inChildren = true;
|
||||||
} else if (qName.endsWith("Tasks")) {
|
} else if (qName.endsWith("Tasks")) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -27,9 +26,11 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
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.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +54,7 @@ public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("VirtualHardwareSection")) {
|
if (qName.endsWith("VirtualHardwareSection")) {
|
||||||
hardware = newReferenceType(attributes);
|
hardware = newReferenceType(attributes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -28,6 +27,7 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
@ -92,7 +92,7 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("VirtualHardwareSection")) {
|
if (qName.endsWith("VirtualHardwareSection")) {
|
||||||
inHardware = true;
|
inHardware = true;
|
||||||
} else if (qName.endsWith("OperatingSystemSection")) {
|
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
|
|
@ -24,8 +24,10 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
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.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.ovf.NetworkSection;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
import org.jclouds.vcloud.util.Utils;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
@ -49,7 +51,7 @@ public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult<VClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("NetworkSection")) {
|
if (qName.endsWith("NetworkSection")) {
|
||||||
this.net = Utils.newReferenceType(attributes);
|
this.net = Utils.newReferenceType(attributes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystemSection;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
import org.jclouds.vcloud.util.Utils;
|
||||||
|
@ -56,7 +57,7 @@ public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Link")) {
|
if (qName.endsWith("Link")) {
|
||||||
this.edit = Utils.newReferenceType(attributes);
|
this.edit = Utils.newReferenceType(attributes);
|
||||||
} else if (qName.endsWith("OperatingSystemSection")) {
|
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
|
|
@ -21,9 +21,11 @@ package org.jclouds.vcloud.xml.ovf;
|
||||||
|
|
||||||
import java.util.Map;
|
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.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation;
|
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData;
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
|
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
import org.jclouds.vcloud.util.Utils;
|
||||||
|
@ -32,7 +34,7 @@ import org.xml.sax.Attributes;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudResourceAllocationHandler extends ResourceAllocationHandler {
|
public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler {
|
||||||
|
|
||||||
private ReferenceType edit;
|
private ReferenceType edit;
|
||||||
|
|
||||||
|
@ -44,37 +46,35 @@ public class VCloudResourceAllocationHandler extends ResourceAllocationHandler {
|
||||||
private boolean primaryNetworkConnection;
|
private boolean primaryNetworkConnection;
|
||||||
private String ipAddressingMode;
|
private String ipAddressingMode;
|
||||||
|
|
||||||
protected ResourceAllocation newResourceAllocation() {
|
public ResourceAllocationSettingData getResult() {
|
||||||
|
try {
|
||||||
|
ResourceAllocationSettingData from = super.getResult();
|
||||||
if (edit != null) {
|
if (edit != null) {
|
||||||
ResourceAllocation allocation = new EditableResourceAllocation(instanceID, elementName, description,
|
return EditableResourceAllocationSettingData.builder().fromResourceAllocationSettingData(from).edit(edit)
|
||||||
resourceType, resourceSubType, hostResource, address, addressOnParent, parent, connected,
|
.build();
|
||||||
virtualQuantity, virtualQuantityUnits, edit);
|
|
||||||
this.edit = null;
|
|
||||||
return allocation;
|
|
||||||
} else if (busSubType != null) {
|
} else if (busSubType != null) {
|
||||||
ResourceAllocation allocation = new VCloudHardDisk(instanceID, elementName, description, resourceType,
|
return VCloudHardDisk.builder().fromResourceAllocationSettingData(from).capacity(capacity).busType(busType)
|
||||||
resourceSubType, hostResource, address, addressOnParent, parent, connected, virtualQuantity,
|
.busSubType(busSubType).build();
|
||||||
virtualQuantityUnits, capacity, busType, busSubType);
|
|
||||||
capacity = -1;
|
|
||||||
busType = -1;
|
|
||||||
busSubType = null;
|
|
||||||
return allocation;
|
|
||||||
} else if (ipAddress != null) {
|
} else if (ipAddress != null) {
|
||||||
ResourceAllocation allocation = new VCloudNetworkAdapter(instanceID, elementName, description, resourceType,
|
return VCloudNetworkAdapter.builder().fromResourceAllocationSettingData(from).ipAddress(ipAddress)
|
||||||
resourceSubType, hostResource, address, addressOnParent, parent, connected, virtualQuantity,
|
.primaryNetworkConnection(primaryNetworkConnection).ipAddressingMode(ipAddressingMode).build();
|
||||||
virtualQuantityUnits, ipAddress, primaryNetworkConnection, ipAddressingMode);
|
} else {
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
ipAddress = null;
|
ipAddress = null;
|
||||||
primaryNetworkConnection = false;
|
primaryNetworkConnection = false;
|
||||||
ipAddressingMode = null;
|
ipAddressingMode = null;
|
||||||
return allocation;
|
capacity = -1;
|
||||||
} else {
|
busType = -1;
|
||||||
return super.newResourceAllocation();
|
busSubType = null;
|
||||||
|
edit = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Link")) {
|
if (qName.endsWith("Link")) {
|
||||||
this.edit = Utils.newReferenceType(attributes);
|
this.edit = Utils.newReferenceType(attributes);
|
||||||
} else if (qName.endsWith("HostResource") && attributes.size() > 0) {
|
} else if (qName.endsWith("HostResource") && attributes.size() > 0) {
|
|
@ -42,6 +42,7 @@ import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.ReturnInputStream;
|
import org.jclouds.http.functions.ReturnInputStream;
|
||||||
|
import org.jclouds.ovf.xml.OvfEnvelopeHandler;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
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.VAppTemplateHandler;
|
||||||
import org.jclouds.vcloud.xml.VDCHandler;
|
import org.jclouds.vcloud.xml.VDCHandler;
|
||||||
import org.jclouds.vcloud.xml.VmHandler;
|
import org.jclouds.vcloud.xml.VmHandler;
|
||||||
import org.jclouds.vcloud.xml.ovf.OvfEnvelopeHandler;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
expect(net.getNetworks())
|
expect(net.getNetworks())
|
||||||
.andReturn(
|
.andReturn(
|
||||||
ImmutableSet
|
ImmutableSet
|
||||||
.<org.jclouds.vcloud.domain.ovf.network.Network> of(new org.jclouds.vcloud.domain.ovf.network.Network(
|
.<org.jclouds.ovf.Network> of(new org.jclouds.ovf.Network(
|
||||||
"vAppNet-vApp Internal", null)));
|
"vAppNet-vApp Internal", null)));
|
||||||
|
|
||||||
replay(request);
|
replay(request);
|
||||||
|
@ -219,7 +219,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
expect(net.getNetworks())
|
expect(net.getNetworks())
|
||||||
.andReturn(
|
.andReturn(
|
||||||
ImmutableSet
|
ImmutableSet
|
||||||
.<org.jclouds.vcloud.domain.ovf.network.Network> of(new org.jclouds.vcloud.domain.ovf.network.Network(
|
.<org.jclouds.ovf.Network> of(new org.jclouds.ovf.Network(
|
||||||
"vAppNet-vApp Internal", null)));
|
"vAppNet-vApp Internal", null)));
|
||||||
|
|
||||||
replay(request);
|
replay(request);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
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.Status;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.xml.VAppHandler;
|
import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -78,6 +80,7 @@ public class VAppToNodeMetadataTest {
|
||||||
bind(new TypeLiteral<Function<VApp, Hardware>>() {
|
bind(new TypeLiteral<Function<VApp, Hardware>>() {
|
||||||
}).to(new TypeLiteral<HardwareForVApp>() {
|
}).to(new TypeLiteral<HardwareForVApp>() {
|
||||||
});
|
});
|
||||||
|
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -106,8 +109,8 @@ public class VAppToNodeMetadataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWhenVDCIsLocation() {
|
public void testWhenVDCIsLocation() {
|
||||||
Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
|
Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description").scope(
|
||||||
.scope(LocationScope.PROVIDER).build();
|
LocationScope.PROVIDER).build();
|
||||||
Injector injector = createInjectorWithLocation(location);
|
Injector injector = createInjectorWithLocation(location);
|
||||||
InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
|
InputStream is = getClass().getResourceAsStream("/vapp-pool.xml");
|
||||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
@ -120,8 +123,8 @@ public class VAppToNodeMetadataTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGracefulWhenNoIPs() {
|
public void testGracefulWhenNoIPs() {
|
||||||
Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description")
|
Location location = new LocationBuilder().id("https://1.1.1.1/api/v1.0/vdc/1").description("description").scope(
|
||||||
.scope(LocationScope.PROVIDER).build();
|
LocationScope.PROVIDER).build();
|
||||||
Injector injector = createInjectorWithLocation(location);
|
Injector injector = createInjectorWithLocation(location);
|
||||||
InputStream is = getClass().getResourceAsStream("/vapp-none.xml");
|
InputStream is = getClass().getResourceAsStream("/vapp-none.xml");
|
||||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
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.VApp;
|
||||||
import org.jclouds.vcloud.domain.Vm;
|
import org.jclouds.vcloud.domain.Vm;
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -49,7 +51,14 @@ public class VAppHandlerTest {
|
||||||
|
|
||||||
public void testRhelOffStatic() {
|
public void testRhelOffStatic() {
|
||||||
InputStream is = getClass().getResourceAsStream("/vapp-rhel-off-static.xml");
|
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);
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
||||||
assertEquals(result.getName(), "vApp_acole_2");
|
assertEquals(result.getName(), "vApp_acole_2");
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
import org.jclouds.ovf.Network;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
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.ReferenceTypeImpl;
|
||||||
import org.jclouds.vcloud.domain.internal.TaskImpl;
|
import org.jclouds.vcloud.domain.internal.TaskImpl;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
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.Vm;
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest;
|
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemSectionHandlerTest;
|
||||||
|
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest;
|
import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareSectionHandlerTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -48,7 +50,14 @@ import com.google.inject.Injector;
|
||||||
public class VmHandlerTest {
|
public class VmHandlerTest {
|
||||||
public void testVCloud1_0() {
|
public void testVCloud1_0() {
|
||||||
InputStream is = getClass().getResourceAsStream("/vm-rhel-off-static.xml");
|
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);
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is);
|
Vm result = factory.create(injector.getInstance(VmHandler.class)).parse(is);
|
||||||
checkVm(result);
|
checkVm(result);
|
||||||
|
|
|
@ -25,20 +25,24 @@ import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.UnknownHostException;
|
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.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.internal.ReferenceTypeImpl;
|
||||||
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation;
|
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocationSettingData;
|
||||||
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.VCloudHardDisk;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection;
|
||||||
import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
|
import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudVirtualHardwareSectionHandler}
|
* 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
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
@Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest")
|
@Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest")
|
||||||
public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest {
|
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 {
|
public void testDefault() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml");
|
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);
|
checkHardware(result);
|
||||||
|
|
||||||
|
@ -60,73 +77,80 @@ public class VCloudVirtualHardwareSectionHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public static void checkHardware(VCloudVirtualHardwareSection result) {
|
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
|
assertEquals(result.getHref(), URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/"));
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/"));
|
||||||
assertEquals(result.getType(), "application/vnd.vmware.vcloud.virtualHardwareSection+xml");
|
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(result.getInfo(), "Virtual hardware requirements");
|
||||||
|
|
||||||
assertEquals(Iterables.get(result.getResourceAllocations(), 0), new VCloudNetworkAdapter(1, "Network adapter 0",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 0).toString(), VCloudNetworkAdapter.builder()
|
||||||
"PCNet32 ethernet adapter", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, "00:50:56:01:01:f2", 0,
|
.instanceID("1").elementName("Network adapter 0").description("PCNet32 ethernet adapter").resourceType(
|
||||||
null, false, 1, null, "174.47.101.164", true, "POOL"));
|
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",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 1).toString(), ResourceAllocationSettingData
|
||||||
"SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null));
|
.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",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 2).toString(), VCloudHardDisk.builder().instanceID(
|
||||||
"Hard disk", ResourceType.DISK_DRIVE, null, null, null, 0, 2, null, 1, null, 30720, 6, "lsilogic"));
|
"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",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 3).toString(), ResourceAllocationSettingData
|
||||||
"IDE Controller", ResourceType.IDE_CONTROLLER, null, null, "0", null, null, null, 1, null));
|
.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",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 4).toString(), ResourceAllocationSettingData
|
||||||
"CD/DVD Drive", ResourceType.CD_DRIVE, null, null, null, 0, 3, null, 1, null));
|
.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",
|
assertEquals(Iterables.get(result.getResourceAllocations(), 5).toString(), ResourceAllocationSettingData
|
||||||
"Floppy Drive", ResourceType.FLOPPY_DRIVE, null, null, null, 0, null, null, 1, null));
|
.builder().instanceID("8000").elementName("Floppy Drive 1").description("Floppy Drive").resourceType(
|
||||||
|
ResourceType.FLOPPY_DRIVE).addressOnParent("0").automaticAllocation(false).build().toString());
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Iterables.get(result.getResourceAllocations(), 6),
|
Iterables.get(result.getResourceAllocations(), 6).toString(),
|
||||||
new EditableResourceAllocation(
|
EditableResourceAllocationSettingData
|
||||||
4,
|
.builder()
|
||||||
"1 virtual CPU(s)",
|
.instanceID("4")
|
||||||
"Number of Virtual CPUs",
|
.elementName("1 virtual CPU(s)")
|
||||||
ResourceType.PROCESSOR,
|
.description("Number of Virtual CPUs")
|
||||||
null,
|
.resourceType(ResourceType.PROCESSOR)
|
||||||
null,
|
.virtualQuantity(1l)
|
||||||
null,
|
.allocationUnits("hertz * 10^6")
|
||||||
null,
|
.reservation(0l)
|
||||||
null,
|
.weight(0)
|
||||||
null,
|
.edit(
|
||||||
1,
|
|
||||||
"hertz * 10^6",
|
|
||||||
new ReferenceTypeImpl(
|
new ReferenceTypeImpl(
|
||||||
null,
|
null,
|
||||||
"application/vnd.vmware.vcloud.rasdItem+xml",
|
"application/vnd.vmware.vcloud.rasdItem+xml",
|
||||||
URI
|
URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"))));
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu")))
|
||||||
|
.build().toString());
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Iterables.get(result.getResourceAllocations(), 7),
|
Iterables.get(result.getResourceAllocations(), 7).toString(),
|
||||||
new EditableResourceAllocation(
|
EditableResourceAllocationSettingData
|
||||||
5,
|
.builder()
|
||||||
"384 MB of memory",
|
.instanceID("5")
|
||||||
"Memory Size",
|
.elementName("384 MB of memory")
|
||||||
ResourceType.MEMORY,
|
.description("Memory Size")
|
||||||
null,
|
.resourceType(ResourceType.MEMORY)
|
||||||
null,
|
.virtualQuantity(384l)
|
||||||
null,
|
.allocationUnits("byte * 2^20")
|
||||||
null,
|
.reservation(0l)
|
||||||
null,
|
.weight(0)
|
||||||
null,
|
.edit(
|
||||||
384,
|
|
||||||
"byte * 2^20",
|
|
||||||
new ReferenceTypeImpl(
|
new ReferenceTypeImpl(
|
||||||
null,
|
null,
|
||||||
"application/vnd.vmware.vcloud.rasdItem+xml",
|
"application/vnd.vmware.vcloud.rasdItem+xml",
|
||||||
URI
|
URI
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"))));
|
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory")))
|
||||||
|
.build().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -40,12 +40,12 @@ import javax.xml.parsers.FactoryConfigurationError;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.MapBinder;
|
import org.jclouds.rest.MapBinder;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
import org.jclouds.vcloud.endpoints.Network;
|
import org.jclouds.vcloud.endpoints.Network;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
|
|
|
@ -20,30 +20,20 @@
|
||||||
package org.jclouds.vcloud.compute.functions;
|
package org.jclouds.vcloud.compute.functions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
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 java.util.NoSuchElementException;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.cim.functions.HardwareBuilderFromResourceAllocations;
|
||||||
import org.jclouds.compute.domain.Hardware;
|
import org.jclouds.compute.domain.Hardware;
|
||||||
import org.jclouds.compute.domain.HardwareBuilder;
|
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.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
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.base.Function;
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
@ -54,36 +44,24 @@ public class HardwareForVCloudExpressVApp implements Function<VCloudExpressVApp,
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final FindLocationForResource findLocationForResource;
|
private final FindLocationForResource findLocationForResource;
|
||||||
private final ResourceAllocationsToVolumes resourceAllocationsToVolumes;
|
private final HardwareBuilderFromResourceAllocations rasdToHardwareBuilder;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected HardwareForVCloudExpressVApp(FindLocationForResource findLocationForResource,
|
protected HardwareForVCloudExpressVApp(FindLocationForResource findLocationForResource,
|
||||||
ResourceAllocationsToVolumes resourceAllocationsToVolumes) {
|
HardwareBuilderFromResourceAllocations rasdToHardwareBuilder) {
|
||||||
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
|
||||||
this.resourceAllocationsToVolumes = checkNotNull(resourceAllocationsToVolumes, "resourceAllocationsToVolumes");
|
this.rasdToHardwareBuilder = checkNotNull(rasdToHardwareBuilder, "rasdToHardwareBuilder");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hardware apply(VCloudExpressVApp from) {
|
public Hardware apply(VCloudExpressVApp from) {
|
||||||
checkNotNull(from, "VApp");
|
checkNotNull(from, "VApp");
|
||||||
Location location = findLocationForResource.apply(checkNotNull(from, "from").getVDC());
|
|
||||||
try {
|
try {
|
||||||
int ram = (int) find(from.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity();
|
HardwareBuilder builder = rasdToHardwareBuilder.apply(from.getResourceAllocations());
|
||||||
|
builder.location(findLocationForResource.apply(checkNotNull(from, "from").getVDC()));
|
||||||
List<Processor> processors = Lists.newArrayList(transform(
|
builder.ids(from.getHref().toASCIIString()).name(from.getName()).supportsImage(
|
||||||
filter(from.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)),
|
ImagePredicates.idEquals(from.getHref().toASCIIString()));
|
||||||
new Function<ResourceAllocation, Processor>() {
|
return builder.build();
|
||||||
|
|
||||||
@Override
|
|
||||||
public Processor apply(ResourceAllocation arg0) {
|
|
||||||
return new Processor(arg0.getVirtualQuantity(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}));
|
|
||||||
List<Volume> 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();
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
logger.debug("incomplete data to form vApp %s", from.getHref());
|
logger.debug("incomplete data to form vApp %s", from.getHref());
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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<? extends ResourceAllocation>, Iterable<Volume>> {
|
|
||||||
@Override
|
|
||||||
public Iterable<Volume> apply(Iterable<? extends ResourceAllocation> resourceAllocations) {
|
|
||||||
Iterable<Volume> volumes = transform(filter(resourceAllocations, resourceType(ResourceType.DISK_DRIVE)),
|
|
||||||
new Function<ResourceAllocation, Volume>() {
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,11 +29,11 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.collect.Memoized;
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.domain.CIMOperatingSystem;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.os.CIMOperatingSystem;
|
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
import org.jclouds.vcloud.compute.VCloudExpressComputeClient;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
|
|
|
@ -23,9 +23,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
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.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.common.collect.ListMultimap;
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
@ -62,8 +62,8 @@ public interface VCloudExpressVApp extends ReferenceType {
|
||||||
@Nullable
|
@Nullable
|
||||||
String getOperatingSystemDescription();
|
String getOperatingSystemDescription();
|
||||||
|
|
||||||
System getSystem();
|
VirtualSystemSettingData getSystem();
|
||||||
|
|
||||||
Set<ResourceAllocation> getResourceAllocations();
|
Set<ResourceAllocationSettingData> getResourceAllocations();
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,12 +24,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
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;
|
import com.google.common.collect.ListMultimap;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp {
|
||||||
private final Long size;
|
private final Long size;
|
||||||
private final ListMultimap<String, String> networkToAddresses;
|
private final ListMultimap<String, String> networkToAddresses;
|
||||||
private final String operatingSystemDescription;
|
private final String operatingSystemDescription;
|
||||||
private final System system;
|
private final VirtualSystemSettingData system;
|
||||||
private final Set<ResourceAllocation> resourceAllocations;
|
private final Set<ResourceAllocationSettingData> resourceAllocations;
|
||||||
private final Integer osType;
|
private final Integer osType;
|
||||||
|
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
|
@ -55,7 +55,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp {
|
||||||
|
|
||||||
public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC,
|
public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC,
|
||||||
ListMultimap<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
|
ListMultimap<String, String> networkToAddresses, Integer osType, String operatingSystemDescription,
|
||||||
System system, Set<ResourceAllocation> resourceAllocations) {
|
VirtualSystemSettingData system, Set<ResourceAllocationSettingData> resourceAllocations) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.href = checkNotNull(href, "href");
|
this.href = checkNotNull(href, "href");
|
||||||
this.status = checkNotNull(status, "status");
|
this.status = checkNotNull(status, "status");
|
||||||
|
@ -89,12 +89,12 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public System getSystem() {
|
public VirtualSystemSettingData getSystem() {
|
||||||
return system;
|
return system;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ResourceAllocation> getResourceAllocations() {
|
public Set<ResourceAllocationSettingData> getResourceAllocations() {
|
||||||
return resourceAllocations;
|
return resourceAllocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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 static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -88,21 +89,21 @@ public class VCloudExpressNetworkHandler extends ParseSax.HandlerWithResult<VClo
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
public void endElement(String uri, String name, String qName) {
|
||||||
if (qName.equals("Description")) {
|
if (qName.equals("Description")) {
|
||||||
description = currentOrNull();
|
description = currentOrNull(currentText);
|
||||||
} else if (qName.equals("Dns")) {
|
} else if (qName.equals("Dns")) {
|
||||||
dnsServers.add(currentOrNull());
|
dnsServers.add(currentOrNull(currentText));
|
||||||
} else if (qName.equals("Gateway")) {
|
} else if (qName.equals("Gateway")) {
|
||||||
gateway = currentOrNull();
|
gateway = currentOrNull(currentText);
|
||||||
} else if (qName.equals("Netmask")) {
|
} else if (qName.equals("Netmask")) {
|
||||||
netmask = currentOrNull();
|
netmask = currentOrNull(currentText);
|
||||||
} else if (qName.equals("FenceMode")) {
|
} else if (qName.equals("FenceMode")) {
|
||||||
try {
|
try {
|
||||||
fenceModes.add(FenceMode.fromValue(currentOrNull()));
|
fenceModes.add(FenceMode.fromValue(currentOrNull(currentText)));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
fenceModes.add(FenceMode.BRIDGED);
|
fenceModes.add(FenceMode.BRIDGED);
|
||||||
}
|
}
|
||||||
} else if (qName.equals("Dhcp")) {
|
} else if (qName.equals("Dhcp")) {
|
||||||
dhcp = new Boolean(currentOrNull());
|
dhcp = new Boolean(currentOrNull(currentText));
|
||||||
} else if (qName.equals("NatRule")) {
|
} else if (qName.equals("NatRule")) {
|
||||||
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP));
|
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP));
|
||||||
externalIP = null;
|
externalIP = null;
|
||||||
|
@ -110,24 +111,24 @@ public class VCloudExpressNetworkHandler extends ParseSax.HandlerWithResult<VClo
|
||||||
internalIP = null;
|
internalIP = null;
|
||||||
internalPort = null;
|
internalPort = null;
|
||||||
} else if (qName.equals("ExternalIP")) {
|
} else if (qName.equals("ExternalIP")) {
|
||||||
externalIP = currentOrNull();
|
externalIP = currentOrNull(currentText);
|
||||||
} else if (qName.equals("ExternalPort")) {
|
} else if (qName.equals("ExternalPort")) {
|
||||||
externalPort = Integer.parseInt(currentOrNull());
|
externalPort = Integer.parseInt(currentOrNull(currentText));
|
||||||
} else if (qName.equals("InternalIP")) {
|
} else if (qName.equals("InternalIP")) {
|
||||||
internalIP = currentOrNull();
|
internalIP = currentOrNull(currentText);
|
||||||
} else if (qName.equals("InternalPort")) {
|
} else if (qName.equals("InternalPort")) {
|
||||||
internalPort = Integer.parseInt(currentOrNull());
|
internalPort = Integer.parseInt(currentOrNull(currentText));
|
||||||
} else if (qName.equals("FirewallRule")) {
|
} else if (qName.equals("FirewallRule")) {
|
||||||
firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP));
|
firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP));
|
||||||
policy = null;
|
policy = null;
|
||||||
sourceIP = null;
|
sourceIP = null;
|
||||||
sourcePort = -1;
|
sourcePort = -1;
|
||||||
} else if (qName.equals("Policy")) {
|
} else if (qName.equals("Policy")) {
|
||||||
policy = FirewallPolicy.fromValue(currentOrNull());
|
policy = FirewallPolicy.fromValue(currentOrNull(currentText));
|
||||||
} else if (qName.equals("SourceIp")) {
|
} else if (qName.equals("SourceIp")) {
|
||||||
sourceIP = currentOrNull();
|
sourceIP = currentOrNull(currentText);
|
||||||
} else if (qName.equals("SourcePort")) {
|
} else if (qName.equals("SourcePort")) {
|
||||||
sourcePort = Integer.parseInt(currentOrNull());
|
sourcePort = Integer.parseInt(currentOrNull(currentText));
|
||||||
}
|
}
|
||||||
|
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
|
@ -137,9 +138,4 @@ public class VCloudExpressNetworkHandler extends ParseSax.HandlerWithResult<VClo
|
||||||
currentText.append(ch, start, length);
|
currentText.append(ch, start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String currentOrNull() {
|
|
||||||
String returnVal = currentText.toString().trim();
|
|
||||||
return returnVal.equals("") ? null : returnVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -31,17 +30,18 @@ import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
|
import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler;
|
||||||
|
import org.jclouds.cim.xml.VirtualSystemSettingDataHandler;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
||||||
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.System;
|
|
||||||
import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler;
|
|
||||||
import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
@ -54,21 +54,21 @@ import com.google.common.collect.Sets;
|
||||||
*/
|
*/
|
||||||
public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult<VCloudExpressVApp> {
|
public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult<VCloudExpressVApp> {
|
||||||
private final String apiVersion;
|
private final String apiVersion;
|
||||||
private final SystemHandler systemHandler;
|
private final VirtualSystemSettingDataHandler systemHandler;
|
||||||
private final ResourceAllocationHandler allocationHandler;
|
private final ResourceAllocationSettingDataHandler allocationHandler;
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler,
|
public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion,
|
||||||
ResourceAllocationHandler allocationHandler) {
|
VirtualSystemSettingDataHandler systemHandler, ResourceAllocationSettingDataHandler allocationHandler) {
|
||||||
this.apiVersion = apiVersion;
|
this.apiVersion = apiVersion;
|
||||||
this.systemHandler = systemHandler;
|
this.systemHandler = systemHandler;
|
||||||
this.allocationHandler = allocationHandler;
|
this.allocationHandler = allocationHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected System system;
|
protected VirtualSystemSettingData system;
|
||||||
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
|
protected Set<ResourceAllocationSettingData> allocations = Sets.newLinkedHashSet();
|
||||||
protected Status status;
|
protected Status status;
|
||||||
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
|
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
|
||||||
protected StringBuilder currentText = new StringBuilder();
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
@ -87,7 +87,7 @@ public class VCloudExpressVAppHandler extends ParseSax.HandlerWithResult<VCloudE
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("VApp")) {
|
if (qName.equals("VApp")) {
|
||||||
ReferenceType resource = newReferenceType(attributes);
|
ReferenceType resource = newReferenceType(attributes);
|
||||||
name = resource.getName();
|
name = resource.getName();
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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 static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -58,7 +59,7 @@ public class VCloudExpressVAppTemplateHandler extends ParseSax.HandlerWithResult
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
public void endElement(String uri, String name, String qName) {
|
||||||
if (qName.equals("Description")) {
|
if (qName.equals("Description")) {
|
||||||
description = currentOrNull();
|
description = currentOrNull(currentText);
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
@ -66,9 +67,4 @@ public class VCloudExpressVAppTemplateHandler extends ParseSax.HandlerWithResult
|
||||||
public void characters(char ch[], int start, int length) {
|
public void characters(char ch[], int start, int length) {
|
||||||
currentText.append(ch, start, length);
|
currentText.append(ch, start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String currentOrNull() {
|
|
||||||
String returnVal = currentText.toString().trim();
|
|
||||||
return returnVal.equals("") ? null : returnVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
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.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
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.VCloudExpressVApp;
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||||
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
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.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -81,7 +81,8 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
|
||||||
VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI
|
VCloudExpressVApp expects = new VCloudExpressVAppImpl("centos53", URI
|
||||||
.create("http://10.150.4.49/api/v0.8/vApp/10"), Status.RESOLVED, 123456789l, new ReferenceTypeImpl(null,
|
.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")),
|
"application/vnd.vmware.vcloud.vdc+xml", URI.create("http://10.150.4.49/api/v0.8/vdc/4")),
|
||||||
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.<ResourceAllocation> of());
|
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet
|
||||||
|
.<ResourceAllocationSettingData> of());
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,17 +93,31 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
||||||
"10.150.4.93");
|
"10.150.4.93");
|
||||||
System system = new System(0, "Virtual Hardware Family", "centos53", ImmutableSet.of("vmx-07"));
|
|
||||||
|
|
||||||
Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
|
VirtualSystemSettingData system = VirtualSystemSettingData.builder().instanceID("0").elementName(
|
||||||
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
|
"Virtual Hardware Family").virtualSystemIdentifier("centos53").virtualSystemType("vmx-07").build();
|
||||||
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,
|
Set<ResourceAllocationSettingData> resourceAllocations = ImmutableSet.<ResourceAllocationSettingData> of(
|
||||||
"SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null,
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description(
|
||||||
null, 1, null), new ResourceAllocation(8, "Network Adapter 1",
|
"Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l)
|
||||||
"PCNet32 ethernet adapter on \"Internal\" network", ResourceType.ETHERNET_ADAPTER, "PCNet32", null,
|
.allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(),
|
||||||
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"));
|
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
|
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,
|
.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.getName(), expects.getName());
|
||||||
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
|
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
|
||||||
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
|
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
|
||||||
assertEquals(result.getResourceAllocations(), expects.getResourceAllocations());
|
assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString());
|
||||||
assertEquals(result.getSize(), expects.getSize());
|
assertEquals(result.getSize(), expects.getSize());
|
||||||
assertEquals(result.getStatus(), expects.getStatus());
|
assertEquals(result.getStatus(), expects.getStatus());
|
||||||
assertEquals(result.getSystem(), expects.getSystem());
|
assertEquals(result.getSystem().toString(), expects.getSystem().toString());
|
||||||
assertEquals(result.getType(), expects.getType());
|
assertEquals(result.getType(), expects.getType());
|
||||||
assertEquals(result.getVDC(), expects.getVDC());
|
assertEquals(result.getVDC(), expects.getVDC());
|
||||||
}
|
}
|
||||||
|
@ -127,17 +142,30 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
||||||
"10.23.119.221");
|
"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<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
|
Set<ResourceAllocationSettingData> resourceAllocations = ImmutableSet.<ResourceAllocationSettingData> of(
|
||||||
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("1 virtual CPU(s)").description(
|
||||||
null, 1, "hertz * 10^6"), new ResourceAllocation(2, "512MB of memory", "Memory Size",
|
"Number of Virtual CPUs").resourceType(ResourceType.PROCESSOR).virtualQuantity(1l)
|
||||||
ResourceType.MEMORY, null, null, null, null, null, null, 512, "byte * 2^20"), new ResourceAllocation(3,
|
.allocationUnits("hertz * 10^6").virtualQuantityUnits("count").build(),
|
||||||
"SCSI Controller 0", "SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null,
|
|
||||||
null, 1, null), new ResourceAllocation(8, "Network Adapter 1",
|
ResourceAllocationSettingData.builder().instanceID("2").elementName("512MB of memory").description(
|
||||||
"PCNet32 ethernet adapter on \"Internal\" network", ResourceType.ETHERNET_ADAPTER, "PCNet32", null,
|
"Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l).allocationUnits(
|
||||||
null, 7, null, true, 1, null), new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
"byte * 2^20").virtualQuantityUnits("byte * 2^20").build(),
|
||||||
null, "10485760", null, 0, 3, null, 10485760, "byte * 2^20"));
|
|
||||||
|
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"),
|
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
|
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.getName(), expects.getName());
|
||||||
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
|
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
|
||||||
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
|
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
|
||||||
assertEquals(result.getResourceAllocations(), expects.getResourceAllocations());
|
assertEquals(result.getResourceAllocations().toString(), expects.getResourceAllocations().toString());
|
||||||
assertEquals(result.getSize(), expects.getSize());
|
assertEquals(result.getSize(), expects.getSize());
|
||||||
assertEquals(result.getStatus(), expects.getStatus());
|
assertEquals(result.getStatus(), expects.getStatus());
|
||||||
assertEquals(result.getSystem(), expects.getSystem());
|
assertEquals(result.getSystem().toString(), expects.getSystem().toString());
|
||||||
assertEquals(result.getType(), expects.getType());
|
assertEquals(result.getType(), expects.getType());
|
||||||
assertEquals(result.getVDC(), expects.getVDC());
|
assertEquals(result.getVDC(), expects.getVDC());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.filter;
|
||||||
import static com.google.common.collect.Iterables.find;
|
import static com.google.common.collect.Iterables.find;
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
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_NAMESPACE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
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.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
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.http.HttpRequest;
|
||||||
import org.jclouds.rest.MapBinder;
|
import org.jclouds.rest.MapBinder;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
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 org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -101,8 +101,8 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateXml(VCloudExpressVApp vApp, VAppConfiguration configuration) throws ParserConfigurationException,
|
protected String generateXml(VCloudExpressVApp vApp, VAppConfiguration configuration)
|
||||||
FactoryConfigurationError, TransformerException {
|
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
||||||
String name = configuration.getName() != null ? configuration.getName() : vApp.getName();
|
String name = configuration.getName() != null ? configuration.getName() : vApp.getName();
|
||||||
|
|
||||||
XMLBuilder rootBuilder = buildRoot(vApp, name);
|
XMLBuilder rootBuilder = buildRoot(vApp, name);
|
||||||
|
@ -121,46 +121,51 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProcessorItem(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
private void addProcessorItem(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
||||||
ResourceAllocation cpu = find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR));
|
ResourceAllocationSettingData cpu = find(vApp.getResourceAllocations(), CIMPredicates
|
||||||
|
.resourceTypeIn(ResourceType.PROCESSOR));
|
||||||
long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount() : cpu
|
long quantity = configuration.getProcessorCount() != null ? configuration.getProcessorCount() : cpu
|
||||||
.getVirtualQuantity();
|
.getVirtualQuantity();
|
||||||
addResourceWithQuantity(sectionBuilder, cpu, quantity);
|
addResourceWithQuantity(sectionBuilder, cpu, quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMemoryItem(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
private void addMemoryItem(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
||||||
ResourceAllocation memory = find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY));
|
ResourceAllocationSettingData memory = find(vApp.getResourceAllocations(), CIMPredicates
|
||||||
|
.resourceTypeIn(ResourceType.MEMORY));
|
||||||
long quantity = configuration.getMemory() != null ? configuration.getMemory() : memory.getVirtualQuantity();
|
long quantity = configuration.getMemory() != null ? configuration.getMemory() : memory.getVirtualQuantity();
|
||||||
addResourceWithQuantity(sectionBuilder, memory, quantity);
|
addResourceWithQuantity(sectionBuilder, memory, quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addDiskItems(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
private void addDiskItems(XMLBuilder sectionBuilder, VCloudExpressVApp vApp, VAppConfiguration configuration) {
|
||||||
for (ResourceAllocation disk : filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))) {
|
for (ResourceAllocationSettingData disk : filter(vApp.getResourceAllocations(), CIMPredicates
|
||||||
|
.resourceTypeIn(ResourceType.DISK_DRIVE))) {
|
||||||
if (!configuration.getDisksToDelete().contains(disk.getAddressOnParent()))
|
if (!configuration.getDisksToDelete().contains(disk.getAddressOnParent()))
|
||||||
addDiskWithQuantity(sectionBuilder, disk);
|
addDiskWithQuantity(sectionBuilder, disk);
|
||||||
}
|
}
|
||||||
for (Long quantity : configuration.getDisks()) {
|
for (Long quantity : configuration.getDisks()) {
|
||||||
ResourceAllocation disk = new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576",
|
ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9")
|
||||||
null, -1, null, null, quantity, null);
|
.elementName("n/a").resourceType(ResourceType.DISK_DRIVE).virtualQuantity(quantity).build();
|
||||||
addDiskWithQuantity(sectionBuilder, disk);
|
addDiskWithQuantity(sectionBuilder, disk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private XMLBuilder addResourceWithQuantity(XMLBuilder sectionBuilder, ResourceAllocation resource, long quantity) {
|
private XMLBuilder addResourceWithQuantity(XMLBuilder sectionBuilder, ResourceAllocationSettingData resource,
|
||||||
|
long quantity) {
|
||||||
XMLBuilder itemBuilder = sectionBuilder.e("Item");
|
XMLBuilder itemBuilder = sectionBuilder.e("Item");
|
||||||
addCommonElements(itemBuilder, resource, quantity);
|
addCommonElements(itemBuilder, resource, quantity);
|
||||||
return itemBuilder;
|
return itemBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommonElements(XMLBuilder itemBuilder, ResourceAllocation resource, long quantity) {
|
private void addCommonElements(XMLBuilder itemBuilder, ResourceAllocationSettingData resource, long quantity) {
|
||||||
itemBuilder.e("InstanceID").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getId() + "");
|
itemBuilder.e("InstanceID").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getInstanceID() + "");
|
||||||
itemBuilder.e("ResourceType").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getType().value());
|
itemBuilder.e("ResourceType").a("xmlns", RESOURCE_ALLOCATION_NS).t(resource.getResourceType().value());
|
||||||
itemBuilder.e("VirtualQuantity").a("xmlns", RESOURCE_ALLOCATION_NS).t(quantity + "");
|
itemBuilder.e("VirtualQuantity").a("xmlns", RESOURCE_ALLOCATION_NS).t(quantity + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private XMLBuilder addDiskWithQuantity(XMLBuilder sectionBuilder, ResourceAllocation disk) {
|
private XMLBuilder addDiskWithQuantity(XMLBuilder sectionBuilder, ResourceAllocationSettingData disk) {
|
||||||
XMLBuilder itemBuilder = sectionBuilder.e("Item");
|
XMLBuilder itemBuilder = sectionBuilder.e("Item");
|
||||||
itemBuilder.e("AddressOnParent").a("xmlns", RESOURCE_ALLOCATION_NS).t(disk.getAddressOnParent() + "");
|
itemBuilder.e("AddressOnParent").a("xmlns", RESOURCE_ALLOCATION_NS).t(disk.getAddressOnParent() + "");
|
||||||
itemBuilder.e("HostResource").a("xmlns", RESOURCE_ALLOCATION_NS).t(disk.getHostResource());
|
for (String hostResource : disk.getHostResources())
|
||||||
|
itemBuilder.e("HostResource").a("xmlns", RESOURCE_ALLOCATION_NS).t(hostResource);
|
||||||
addCommonElements(itemBuilder, disk, disk.getVirtualQuantity());
|
addCommonElements(itemBuilder, disk, disk.getVirtualQuantity());
|
||||||
return itemBuilder;
|
return itemBuilder;
|
||||||
}
|
}
|
||||||
|
@ -199,6 +204,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function<Ob
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||||
throw new IllegalStateException("BindVAppConfigurationToXmlPayload needs parameters");
|
throw new IllegalStateException("BindVAppConfigurationToXmlPayload needs parameters");
|
||||||
|
|
|
@ -26,18 +26,18 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_S
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
import org.jclouds.vcloud.endpoints.Network;
|
import org.jclouds.vcloud.endpoints.Network;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.xml;
|
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 static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.xml;
|
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 static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.xml;
|
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 static org.jclouds.vcloud.util.Utils.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.xml;
|
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;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -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.find;
|
||||||
import static com.google.common.collect.Iterables.size;
|
import static com.google.common.collect.Iterables.size;
|
||||||
import static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy;
|
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.changeNameTo;
|
||||||
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -33,22 +32,25 @@ import static org.testng.Assert.assertNotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
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.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
|
import org.jclouds.ssh.SshClient.Factory;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.jclouds.vcloud.VCloudExpressClientLiveTest;
|
import org.jclouds.vcloud.VCloudExpressClientLiveTest;
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
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.VCloudExpressVApp;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
|
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
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.options.CloneVAppOptions;
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||||
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
@ -347,9 +347,12 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getHref());
|
vApp = tmClient.getVApp(vApp.getHref());
|
||||||
assertEquals(vApp.getName(), "eduardo");
|
assertEquals(vApp.getName(), "eduardo");
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1);
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1536);
|
.getVirtualQuantity().longValue(), 1);
|
||||||
assertEquals(size(filter(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE))), 3);
|
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());
|
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());
|
assert successTester.apply(tmClient.powerOffVApp(vApp.getHref()).getHref());
|
||||||
|
|
||||||
// extract the disks on the vApp sorted by addressOnParent
|
// extract the disks on the vApp sorted by addressOnParent
|
||||||
List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
List<ResourceAllocationSettingData> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)));
|
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
|
||||||
|
|
||||||
// delete the second disk
|
// 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());
|
assert successTester.apply(task.getHref());
|
||||||
|
|
||||||
|
@ -374,15 +378,16 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
int processorCount, long memory, long hardDisk) {
|
int processorCount, long memory, long hardDisk) {
|
||||||
assertEquals(vApp.getName(), serverName);
|
assertEquals(vApp.getName(), serverName);
|
||||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(),
|
assertEquals((int) find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
||||||
processorCount);
|
.getVirtualQuantity().longValue(), processorCount);
|
||||||
assertEquals(
|
assertEquals((int) find(vApp.getResourceAllocations(),
|
||||||
find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1);
|
CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA)).getVirtualQuantity().longValue(), 1);
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
.getVirtualQuantity().longValue(), memory);
|
||||||
hardDisk);
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))
|
||||||
assertEquals(vApp.getSize().longValue(),
|
.getVirtualQuantity().longValue(), hardDisk);
|
||||||
find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
assertEquals(vApp.getSize().longValue(), find(vApp.getResourceAllocations(),
|
||||||
|
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCheckPass(String address) throws IOException {
|
private void doCheckPass(String address) throws IOException {
|
||||||
|
@ -465,7 +470,8 @@ public abstract class TerremarkClientLiveTest extends VCloudExpressClientLiveTes
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
|
|
||||||
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector();
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides)
|
||||||
|
.buildInjector();
|
||||||
|
|
||||||
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.jclouds.vcloud.domain.Status;
|
import org.jclouds.vcloud.domain.Status;
|
||||||
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
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.TerremarkVCloudPropertiesBuilder;
|
||||||
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -61,19 +61,22 @@ public class BindVAppConfigurationToXmlPayloadTest {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
Names.bindProperties(binder(),
|
Names
|
||||||
checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties"));
|
.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(),
|
||||||
|
"properties"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public void testChangeName() throws IOException {
|
public void testChangeName() throws IOException {
|
||||||
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6",
|
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI
|
||||||
URI.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
||||||
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(new ResourceAllocation(1,
|
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
|
||||||
"n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null),
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
|
||||||
new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024,
|
ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
|
||||||
null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null,
|
.builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
|
||||||
0, null, null, 209152, null)));
|
.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"))
|
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml"))
|
||||||
.replace("eduardo", "roberto");
|
.replace("eduardo", "roberto");
|
||||||
|
@ -94,14 +97,15 @@ public class BindVAppConfigurationToXmlPayloadTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemoveDisk() throws IOException {
|
public void testRemoveDisk() throws IOException {
|
||||||
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6",
|
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI
|
||||||
URI.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
||||||
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(new ResourceAllocation(1,
|
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
|
||||||
"n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null),
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
|
||||||
new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024,
|
ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
|
||||||
null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null,
|
.builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
|
||||||
0, null, null, 209152, null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE,
|
.virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID(
|
||||||
null, "1048576", null, 1, null, null, 209152, null)));
|
"9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType(
|
||||||
|
ResourceType.DISK_DRIVE).virtualQuantity(209152l).build()));
|
||||||
|
|
||||||
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml"))
|
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml"))
|
||||||
.replace("eduardo", "MyAppServer6");
|
.replace("eduardo", "MyAppServer6");
|
||||||
|
@ -122,13 +126,15 @@ public class BindVAppConfigurationToXmlPayloadTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChangeCPUCountTo4() throws IOException {
|
public void testChangeCPUCountTo4() throws IOException {
|
||||||
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("eduardo",
|
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("eduardo", URI
|
||||||
URI.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
||||||
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(new ResourceAllocation(1,
|
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
|
||||||
"n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 4, null),
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
|
||||||
new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1024,
|
ResourceType.PROCESSOR).virtualQuantity(4l).build(), ResourceAllocationSettingData
|
||||||
null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null,
|
.builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
|
||||||
0, null, null, 209152, null)));
|
.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"));
|
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp4.xml"));
|
||||||
|
|
||||||
VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4);
|
VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4);
|
||||||
|
@ -147,13 +153,15 @@ public class BindVAppConfigurationToXmlPayloadTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChangeMemoryTo1536() throws IOException {
|
public void testChangeMemoryTo1536() throws IOException {
|
||||||
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6",
|
VCloudExpressVAppImpl vApp = new VCloudExpressVAppImpl("MyAppServer6", URI
|
||||||
URI.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
.create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
|
||||||
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(new ResourceAllocation(1,
|
ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
|
||||||
"n/a", null, ResourceType.PROCESSOR, null, null, null, null, null, null, 2, null),
|
ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
|
||||||
new ResourceAllocation(2, "n/a", null, ResourceType.MEMORY, null, null, null, null, null, null, 1536,
|
ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
|
||||||
null), new ResourceAllocation(9, "n/a", null, ResourceType.DISK_DRIVE, null, "1048576", null,
|
.builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
|
||||||
0, null, null, 209152, null)));
|
.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"))
|
String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/configureVApp.xml"))
|
||||||
.replace("eduardo", "MyAppServer6").replace("1024", "1536");
|
.replace("eduardo", "MyAppServer6").replace("1024", "1536");
|
||||||
|
|
|
@ -23,10 +23,10 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
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.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.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -48,15 +48,13 @@ public class ResourceAllocationHandlerTest extends BaseHandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
InputStream is = getClass().getResourceAsStream("/terremark/item.xml");
|
InputStream is = getClass().getResourceAsStream("/terremark/item.xml");
|
||||||
|
|
||||||
ResourceAllocation result = (ResourceAllocation) factory.create(
|
ResourceAllocationSettingData result = factory.create(
|
||||||
injector.getInstance(ResourceAllocationHandler.class)).parse(is);
|
injector.getInstance(ResourceAllocationSettingDataHandler.class)).parse(is);
|
||||||
assertEquals(result.getAddress(), "0");
|
assertEquals(result.getAddress(), "0");
|
||||||
assertEquals(result.getDescription(), "SCSI Controller");
|
assertEquals(result.getDescription(), "SCSI Controller");
|
||||||
assertEquals(result.getName(), "SCSI Controller 0");
|
assertEquals(result.getElementName(), "SCSI Controller 0");
|
||||||
assertEquals(result.getId(), 3);
|
assertEquals(result.getInstanceID(), "3");
|
||||||
assertEquals(result.getSubType(), "lsilogic");
|
assertEquals(result.getResourceSubType(), "lsilogic");
|
||||||
assertEquals(result.getType(), ResourceType.SCSI_CONTROLLER);
|
assertEquals(result.getResourceType(), ResourceType.PARALLEL_SCSI_HBA);
|
||||||
assertEquals(result.getVirtualQuantity(), 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.terremark.xml;
|
package org.jclouds.vcloud.terremark.xml;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.filter;
|
|
||||||
import static com.google.common.collect.Iterables.find;
|
import static com.google.common.collect.Iterables.find;
|
||||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -31,6 +29,10 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
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.BaseHandlerTest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
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.Status;
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
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.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -110,27 +110,35 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
|
.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.<String> of("10.114.34.132"));
|
assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<String> of("10.114.34.132"));
|
||||||
|
|
||||||
ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
|
ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName(
|
||||||
ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6");
|
"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",
|
ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName(
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null);
|
"SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA)
|
||||||
ResourceAllocation memory = new ResourceAllocation(2, "512MB of memory", "Memory Size", ResourceType.MEMORY,
|
.resourceSubType("lsilogic").address("0").virtualQuantity(1l).build();
|
||||||
null, null, null, null, null, null, 512, "byte * 2^20");
|
ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName(
|
||||||
ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null,
|
"512MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(512l)
|
||||||
"10485760", null, 0, 3, null, 10485760, "byte * 2^20");
|
.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(result.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk));
|
||||||
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 1);
|
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
||||||
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER))
|
.getVirtualQuantity().intValue(), 1);
|
||||||
.getVirtualQuantity(), 1);
|
find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA));
|
||||||
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 512);
|
|
||||||
assertEquals(find(result.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
|
||||||
10485760);
|
.getVirtualQuantity().intValue(), 512);
|
||||||
|
assertEquals(find(result.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))
|
||||||
|
.getVirtualQuantity().longValue(), 10485760);
|
||||||
assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(),
|
assertEquals(result.getSize().longValue(), find(result.getResourceAllocations(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)).getVirtualQuantity().longValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetVApp2disks() throws UnknownHostException {
|
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.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/15639"));
|
||||||
assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
|
.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"));
|
assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131"));
|
||||||
|
|
||||||
ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs",
|
ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder().instanceID("1").elementName(
|
||||||
ResourceType.PROCESSOR, null, null, null, null, null, null, 2, "hertz * 10^6");
|
"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",
|
ResourceAllocationSettingData controller = ResourceAllocationSettingData.builder().instanceID("3").elementName(
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null);
|
"SCSI Controller 0").description("SCSI Controller").resourceType(ResourceType.PARALLEL_SCSI_HBA)
|
||||||
ResourceAllocation memory = new ResourceAllocation(2, "1024MB of memory", "Memory Size", ResourceType.MEMORY,
|
.resourceSubType("lsilogic").address("0").virtualQuantity(1l).build();
|
||||||
null, null, null, null, null, null, 1024, "byte * 2^20");
|
ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder().instanceID("2").elementName(
|
||||||
ResourceAllocation disk = new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null,
|
"1024MB of memory").description("Memory Size").resourceType(ResourceType.MEMORY).virtualQuantity(1024l)
|
||||||
"4194304", null, 0, 3, null, 4194304, "byte * 2^20");
|
.virtualQuantityUnits("byte * 2^20").build();
|
||||||
ResourceAllocation disk2 = new ResourceAllocation(9, "Hard Disk 2", null, ResourceType.DISK_DRIVE, null,
|
ResourceAllocationSettingData disk = ResourceAllocationSettingData.builder().instanceID("9").elementName(
|
||||||
"26214400", null, 1, 3, null, 26214400, "byte * 2^20");
|
"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(vApp.getResourceAllocations(), ImmutableSet.of(cpu, memory, controller, disk, disk2));
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(), 2);
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
||||||
assertEquals(
|
.getVirtualQuantity().intValue(), 2);
|
||||||
find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1);
|
find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PARALLEL_SCSI_HBA));
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), 1024);
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.MEMORY))
|
||||||
|
.getVirtualQuantity().longValue(), 1024);
|
||||||
|
|
||||||
// extract the disks on the vApp sorted by addressOnParent
|
// extract the disks on the vApp sorted by addressOnParent
|
||||||
List<ResourceAllocation> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
List<ResourceAllocationSettingData> disks = Lists.newArrayList(Iterables.filter(vApp.getResourceAllocations(),
|
||||||
resourceType(ResourceType.DISK_DRIVE)));
|
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
|
||||||
|
|
||||||
assertEquals(disks.get(0).getVirtualQuantity(), 4194304);
|
assertEquals(disks.get(0).getVirtualQuantity().longValue(), 4194304);
|
||||||
assertEquals(disks.get(1).getVirtualQuantity(), 26214400);
|
assertEquals(disks.get(1).getVirtualQuantity().longValue(), 26214400);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
|
import org.jclouds.cim.xml.VirtualSystemSettingDataHandler;
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -48,10 +49,11 @@ public class SystemHandlerTest extends BaseHandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
InputStream is = getClass().getResourceAsStream("/terremark/system.xml");
|
InputStream is = getClass().getResourceAsStream("/terremark/system.xml");
|
||||||
|
|
||||||
org.jclouds.vcloud.domain.ovf.System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is);
|
VirtualSystemSettingData result = factory.create(injector.getInstance(VirtualSystemSettingDataHandler.class))
|
||||||
assertEquals(result.getName(), "Virtual Hardware Family");
|
.parse(is);
|
||||||
assertEquals(result.getId(), 0);
|
assertEquals(result.getElementName(), "Virtual Hardware Family");
|
||||||
assertEquals(result.getIdentifier(), "adriantest1");
|
assertEquals(result.getInstanceID(), "0");
|
||||||
|
assertEquals(result.getVirtualSystemIdentifier(), "adriantest1");
|
||||||
assertEquals(result.getVirtualSystemTypes(), ImmutableSet.of("vmx-07"));
|
assertEquals(result.getVirtualSystemTypes(), ImmutableSet.of("vmx-07"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,201 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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 + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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 <a href="http://blogs.vmware.com/vapp/2009/11/index.html"/>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* 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<String> virtualSystemTypes = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public System(int id, String name, String identifier, Iterable<String> 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.
|
|
||||||
*
|
|
||||||
* <p/>
|
|
||||||
* 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<String> 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 + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -22,14 +22,11 @@ package org.jclouds.vcloud.util;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.VCloudError;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
import org.jclouds.vcloud.domain.VCloudError;
|
||||||
import org.jclouds.vcloud.domain.VCloudError.MinorCode;
|
import org.jclouds.vcloud.domain.VCloudError.MinorCode;
|
||||||
import org.jclouds.vcloud.domain.internal.ErrorImpl;
|
import org.jclouds.vcloud.domain.internal.ErrorImpl;
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
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);
|
return new ReferenceTypeImpl(attributes.get("name"), type != null ? type : defaultType, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> cleanseAttributes(Attributes in) {
|
|
||||||
Map<String, String> 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<String, String> attributes) {
|
public static ReferenceType newReferenceType(Map<String, String> attributes) {
|
||||||
return newReferenceType(attributes, null);
|
return newReferenceType(attributes, null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
||||||
|
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
import org.jclouds.vcloud.domain.Catalog;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
@ -69,7 +69,7 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("Catalog")) {
|
if (qName.equals("Catalog")) {
|
||||||
catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML);
|
catalog = newReferenceType(attributes, VCloudMediaType.CATALOG_XML);
|
||||||
} else if (qName.equals("CatalogItem")) {
|
} else if (qName.equals("CatalogItem")) {
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.CatalogItem;
|
import org.jclouds.vcloud.domain.CatalogItem;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
||||||
|
@ -53,7 +53,7 @@ public class CatalogItemHandler extends ParseSax.HandlerWithResult<CatalogItem>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("CatalogItem")) {
|
if (qName.equals("CatalogItem")) {
|
||||||
catalogItem = newReferenceType(attributes);
|
catalogItem = newReferenceType(attributes);
|
||||||
} else if (qName.equals("Entity")) {
|
} else if (qName.equals("Entity")) {
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.VCloudError;
|
import org.jclouds.vcloud.domain.VCloudError;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
import org.jclouds.vcloud.util.Utils;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
@ -41,7 +40,7 @@ public class ErrorHandler extends ParseSax.HandlerWithResult<VCloudError> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("Error")) {
|
if (qName.equals("Error")) {
|
||||||
error = Utils.newError(attributes);
|
error = Utils.newError(attributes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
||||||
|
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.vcloud.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
@ -70,7 +70,7 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Org")) {
|
if (qName.endsWith("Org")) {
|
||||||
org = newReferenceType(attributes);
|
org = newReferenceType(attributes);
|
||||||
} else if (qName.endsWith("Link")) {
|
} else if (qName.endsWith("Link")) {
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -44,7 +44,7 @@ public class OrgListHandler extends ParseSax.HandlerWithResult<Map<String, Refer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Org")) {
|
if (qName.endsWith("Org")) {
|
||||||
String type = attributes.get("type");
|
String type = attributes.get("type");
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.network.DhcpService;
|
import org.jclouds.vcloud.domain.network.DhcpService;
|
||||||
|
@ -144,7 +144,7 @@ public class OrgNetworkHandler extends ParseSax.HandlerWithResult<OrgNetwork> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("OrgNetwork")) {
|
if (qName.equals("OrgNetwork")) {
|
||||||
network = newReferenceType(attributes);
|
network = newReferenceType(attributes);
|
||||||
} else if (qName.equals("FirewallRule")) {
|
} else if (qName.equals("FirewallRule")) {
|
||||||
|
|
|
@ -19,17 +19,17 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.TaskStatus;
|
import org.jclouds.vcloud.domain.TaskStatus;
|
||||||
|
@ -55,6 +55,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
private VCloudError error;
|
private VCloudError error;
|
||||||
private boolean inOwner;
|
private boolean inOwner;
|
||||||
|
|
||||||
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -68,7 +69,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equalsIgnoreCase("Task")) {
|
if (qName.equalsIgnoreCase("Task")) {
|
||||||
if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
|
if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
|
||||||
// href yet
|
// href yet
|
||||||
|
|
|
@ -19,14 +19,13 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.TasksList;
|
import org.jclouds.vcloud.domain.TasksList;
|
||||||
|
@ -57,7 +56,7 @@ public class TasksListHandler extends ParseSax.HandlerWithResult<TasksList> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.equals("TasksList")) {
|
if (qName.equals("TasksList")) {
|
||||||
resource = Utils.newReferenceType(attributes);
|
resource = Utils.newReferenceType(attributes);
|
||||||
} else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) {
|
} else if (qName.equals("Link") && "self".equals(attributes.get("rel"))) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml;
|
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.newReferenceType;
|
||||||
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
import static org.jclouds.vcloud.util.Utils.putReferenceType;
|
||||||
|
|
||||||
|
@ -29,6 +28,7 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.jclouds.vcloud.domain.AllocationModel;
|
import org.jclouds.vcloud.domain.AllocationModel;
|
||||||
import org.jclouds.vcloud.domain.Capacity;
|
import org.jclouds.vcloud.domain.Capacity;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.vcloud.domain.ReferenceType;
|
||||||
|
@ -97,7 +97,7 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Vdc")) {
|
if (qName.endsWith("Vdc")) {
|
||||||
vDC = newReferenceType(attributes);
|
vDC = newReferenceType(attributes);
|
||||||
String status = attributes.get("status");
|
String status = attributes.get("status");
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
import org.jclouds.vcloud.util.Utils;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<ResourceAllocation> {
|
|
||||||
protected StringBuilder currentText = new StringBuilder();
|
|
||||||
|
|
||||||
protected String address;
|
|
||||||
protected Integer addressOnParent;
|
|
||||||
protected String hostResource;
|
|
||||||
protected String allocationUnits;
|
|
||||||
protected String automaticAllocation;
|
|
||||||
protected Boolean connected;
|
|
||||||
protected String description;
|
|
||||||
protected String elementName;
|
|
||||||
protected int instanceID;
|
|
||||||
protected Integer parent;
|
|
||||||
protected String resourceSubType;
|
|
||||||
protected ResourceType resourceType;
|
|
||||||
protected long virtualQuantity = 1;
|
|
||||||
protected String virtualQuantityUnits;
|
|
||||||
|
|
||||||
public org.jclouds.vcloud.domain.ovf.ResourceAllocation getResult() {
|
|
||||||
if (allocationUnits != null)
|
|
||||||
virtualQuantityUnits = allocationUnits;
|
|
||||||
ResourceAllocation allocation = newResourceAllocation();
|
|
||||||
address = null;
|
|
||||||
addressOnParent = null;
|
|
||||||
allocationUnits = null;
|
|
||||||
automaticAllocation = null;
|
|
||||||
connected = null;
|
|
||||||
description = null;
|
|
||||||
elementName = null;
|
|
||||||
instanceID = -1;
|
|
||||||
parent = null;
|
|
||||||
resourceSubType = null;
|
|
||||||
resourceType = null;
|
|
||||||
virtualQuantity = 1;
|
|
||||||
virtualQuantityUnits = null;
|
|
||||||
hostResource = null;
|
|
||||||
return allocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ResourceAllocation newResourceAllocation() {
|
|
||||||
return new ResourceAllocation(instanceID, elementName, description, resourceType, resourceSubType, hostResource,
|
|
||||||
address, addressOnParent, parent, connected, virtualQuantity, virtualQuantityUnits);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
|
||||||
if (qName.endsWith("Connection")) {
|
|
||||||
connected = new Boolean(attributes.get("connected"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endElement(String uri, String localName, String qName) {
|
|
||||||
String current = currentOrNull();
|
|
||||||
if (current != null) {
|
|
||||||
if (qName.endsWith("Address")) {
|
|
||||||
address = current;
|
|
||||||
} else if (qName.endsWith("AddressOnParent")) {
|
|
||||||
addressOnParent = Integer.parseInt(current);
|
|
||||||
} else if (qName.endsWith("AllocationUnits")) {
|
|
||||||
allocationUnits = current;
|
|
||||||
} else if (qName.endsWith("Description")) {
|
|
||||||
description = current;
|
|
||||||
} else if (qName.endsWith("ElementName")) {
|
|
||||||
elementName = current;
|
|
||||||
} else if (qName.endsWith("InstanceID")) {
|
|
||||||
instanceID = Integer.parseInt(current);
|
|
||||||
} else if (qName.endsWith("Parent")) {
|
|
||||||
parent = Integer.parseInt(current);
|
|
||||||
} else if (qName.endsWith("ResourceSubType")) {
|
|
||||||
resourceSubType = current;
|
|
||||||
} else if (qName.endsWith("ResourceType")) {
|
|
||||||
resourceType = ResourceType.fromValue(current);
|
|
||||||
} else if (qName.endsWith("VirtualQuantity")) {
|
|
||||||
virtualQuantity = Long.parseLong(current);
|
|
||||||
} else if (qName.endsWith("VirtualQuantityUnits")) {
|
|
||||||
virtualQuantityUnits = current;
|
|
||||||
} else if (qName.endsWith("HostResource")) {
|
|
||||||
hostResource = currentText.toString().trim();
|
|
||||||
virtualQuantity = Long.parseLong(current);
|
|
||||||
virtualQuantityUnits = "byte * 2^20";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentText = new StringBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void characters(char ch[], int start, int length) {
|
|
||||||
currentText.append(ch, start, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String currentOrNull() {
|
|
||||||
String returnVal = currentText.toString().trim();
|
|
||||||
return returnVal.equals("") ? null : returnVal;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.System;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class SystemHandler extends ParseSax.HandlerWithResult<System> {
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
|
||||||
|
|
||||||
private String elementName;
|
|
||||||
private int instanceID;
|
|
||||||
private String virtualSystemIdentifier;
|
|
||||||
private Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
public System getResult() {
|
|
||||||
System system = new org.jclouds.vcloud.domain.ovf.System(instanceID, elementName, virtualSystemIdentifier,
|
|
||||||
virtualSystemTypes);
|
|
||||||
this.elementName = null;
|
|
||||||
this.instanceID = -1;
|
|
||||||
this.virtualSystemIdentifier = null;
|
|
||||||
this.virtualSystemTypes = null;
|
|
||||||
return system;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
|
||||||
// no op
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endElement(String uri, String localName, String qName) {
|
|
||||||
if (qName.endsWith("ElementName")) {
|
|
||||||
this.elementName = currentText.toString().trim();
|
|
||||||
} else if (qName.endsWith("InstanceID")) {
|
|
||||||
this.instanceID = Integer.parseInt(currentText.toString().trim());
|
|
||||||
} else if (qName.endsWith("VirtualSystemIdentifier")) {
|
|
||||||
this.virtualSystemIdentifier = currentText.toString().trim();
|
|
||||||
} else if (qName.endsWith("VirtualSystemType")) {
|
|
||||||
this.virtualSystemTypes.add(currentText.toString().trim());
|
|
||||||
}
|
|
||||||
currentText = new StringBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void characters(char ch[], int start, int length) {
|
|
||||||
currentText.append(ch, start, length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests behavior of {@code ResourceAllocationHandler}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
|
||||||
@Test(groups = "unit", testName = "ResourceAllocationHandlerTest")
|
|
||||||
public class ResourceAllocationHandlerTest extends BaseHandlerTest {
|
|
||||||
|
|
||||||
public void testApplyInputStream() {
|
|
||||||
InputStream is = getClass().getResourceAsStream("/resourceallocation-hosting.xml");
|
|
||||||
|
|
||||||
ResourceAllocation result = factory.create(
|
|
||||||
injector.getInstance(ResourceAllocationHandler.class)).parse(is);
|
|
||||||
|
|
||||||
ResourceAllocation expects = new ResourceAllocation(1, "1 virtual CPU(s)",
|
|
||||||
"Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
|
|
||||||
null, 1, "hertz * 10^6");
|
|
||||||
assertEquals(result, expects);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,20 +17,22 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.predicates;
|
package org.jclouds.cim;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
import java.util.Set;
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class VCloudPredicates {
|
public class CIMPredicates {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return resource allocations of the specific type.
|
* Return resource allocations of the specific type.
|
||||||
|
@ -39,17 +41,18 @@ public class VCloudPredicates {
|
||||||
* type to match the items
|
* type to match the items
|
||||||
* @return predicate
|
* @return predicate
|
||||||
*/
|
*/
|
||||||
public static Predicate<ResourceAllocation> resourceType(final ResourceType type) {
|
public static Predicate<ResourceAllocationSettingData> resourceTypeIn(final ResourceType... types) {
|
||||||
checkNotNull(type, "type");
|
checkNotNull(types, "resourceTypes");
|
||||||
return new Predicate<ResourceAllocation>() {
|
final Set<ResourceType> resourceTypes = ImmutableSet.copyOf(types);
|
||||||
|
return new Predicate<ResourceAllocationSettingData>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ResourceAllocation in) {
|
public boolean apply(ResourceAllocationSettingData in) {
|
||||||
return type.equals(in.getType());
|
return resourceTypes.contains(in.getResourceType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "resourceAllocationType(" + type + ")";
|
return "resourceTypeIn(" + resourceTypes + ")";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* ManagedElement is an abstract class that provides a common superclass (or top of the inheritance
|
||||||
|
* tree) for the non-association classes in the CIM Schema.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
|
||||||
|
* />
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ManagedElement extends SettingData {
|
||||||
|
|
||||||
|
public static class Builder extends SettingData.Builder {
|
||||||
|
protected String caption;
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ManagedSettingData#getCaption
|
||||||
|
*/
|
||||||
|
public Builder caption(String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ManagedSettingData#getDescription
|
||||||
|
*/
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromManagedElement(ManagedElement in) {
|
||||||
|
return caption(in.getCaption()).description(in.getDescription()).fromSettingData(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromSettingData(SettingData in) {
|
||||||
|
return Builder.class.cast(super.fromSettingData(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder elementName(String elementName) {
|
||||||
|
return Builder.class.cast(super.elementName(elementName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder instanceID(String instanceID) {
|
||||||
|
return Builder.class.cast(super.instanceID(instanceID));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final String caption;
|
||||||
|
protected final String description;
|
||||||
|
|
||||||
|
public ManagedElement(String elementName, String instanceID, String caption, String description) {
|
||||||
|
super(elementName, instanceID);
|
||||||
|
this.caption = caption;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Caption property is a short textual description (one- line string) of the object.
|
||||||
|
*/
|
||||||
|
public String getCaption() {
|
||||||
|
return caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Description property provides a textual description of the object.
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("[elementName=%s, instanceID=%s, caption=%s, description=%s]", elementName, instanceID,
|
||||||
|
caption, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,708 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The ResourceAllocationSettingData class represents settings specifically related to an allocated
|
||||||
|
* resource that are outside the scope of the CIM class typically used to represent the resource
|
||||||
|
* itself. These settings include information specific to the allocation that may not be visible to
|
||||||
|
* the consumer of the resource itself. For example, a virtual processor may look like a 2 ghz
|
||||||
|
* processor to the consumer (virtual computer system), however the virtualization system may use
|
||||||
|
* time-slicing to schedule the the virtual processor to only allow it to use 1 ghz.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
|
||||||
|
* />
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ResourceAllocationSettingData extends ManagedElement {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends ManagedElement.Builder {
|
||||||
|
|
||||||
|
protected String address;
|
||||||
|
protected String addressOnParent;
|
||||||
|
protected String allocationUnits;
|
||||||
|
protected Boolean automaticAllocation;
|
||||||
|
protected Boolean automaticDeallocation;
|
||||||
|
protected ConsumerVisibility consumerVisibility;
|
||||||
|
protected Long limit;
|
||||||
|
protected MappingBehavior mappingBehavior;
|
||||||
|
protected String otherResourceType;
|
||||||
|
protected String parent;
|
||||||
|
protected String poolID;
|
||||||
|
protected Long reservation;
|
||||||
|
protected String resourceSubType;
|
||||||
|
protected ResourceType resourceType;
|
||||||
|
protected Long virtualQuantity;
|
||||||
|
protected String virtualQuantityUnits;
|
||||||
|
protected Integer weight;
|
||||||
|
protected List<String> connections = Lists.newArrayList();
|
||||||
|
protected List<String> hostResources = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getAddress
|
||||||
|
*/
|
||||||
|
public Builder address(String address) {
|
||||||
|
this.address = address;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getAddressOnParent
|
||||||
|
*/
|
||||||
|
public Builder addressOnParent(String addressOnParent) {
|
||||||
|
this.addressOnParent = addressOnParent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getAllocationUnits
|
||||||
|
*/
|
||||||
|
public Builder allocationUnits(String allocationUnits) {
|
||||||
|
this.allocationUnits = allocationUnits;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getAutomaticAllocation
|
||||||
|
*/
|
||||||
|
public Builder automaticAllocation(Boolean automaticAllocation) {
|
||||||
|
this.automaticAllocation = automaticAllocation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getAutomaticDeallocation
|
||||||
|
*/
|
||||||
|
public Builder automaticDeallocation(Boolean automaticDeallocation) {
|
||||||
|
this.automaticDeallocation = automaticDeallocation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getConsumerVisibility
|
||||||
|
*/
|
||||||
|
public Builder consumerVisibility(ConsumerVisibility consumerVisibility) {
|
||||||
|
this.consumerVisibility = consumerVisibility;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getLimit
|
||||||
|
*/
|
||||||
|
public Builder limit(Long limit) {
|
||||||
|
this.limit = limit;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getMappingBehavior
|
||||||
|
*/
|
||||||
|
public Builder mappingBehavior(MappingBehavior mappingBehavior) {
|
||||||
|
this.mappingBehavior = mappingBehavior;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getOtherResourceType
|
||||||
|
*/
|
||||||
|
public Builder otherResourceType(String otherResourceType) {
|
||||||
|
this.otherResourceType = otherResourceType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getParent
|
||||||
|
*/
|
||||||
|
public Builder parent(String parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getPoolID
|
||||||
|
*/
|
||||||
|
public Builder poolID(String poolID) {
|
||||||
|
this.poolID = poolID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getReservation
|
||||||
|
*/
|
||||||
|
public Builder reservation(Long reservation) {
|
||||||
|
this.reservation = reservation;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getResourceSubType
|
||||||
|
*/
|
||||||
|
public Builder resourceSubType(String resourceSubType) {
|
||||||
|
this.resourceSubType = resourceSubType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getResourceType
|
||||||
|
*/
|
||||||
|
public Builder resourceType(ResourceType resourceType) {
|
||||||
|
this.resourceType = resourceType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getVirtualQuantity
|
||||||
|
*/
|
||||||
|
public Builder virtualQuantity(Long virtualQuantity) {
|
||||||
|
this.virtualQuantity = virtualQuantity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getVirtualQuantityUnits
|
||||||
|
*/
|
||||||
|
public Builder virtualQuantityUnits(String virtualQuantityUnits) {
|
||||||
|
this.virtualQuantityUnits = virtualQuantityUnits;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getWeight
|
||||||
|
*/
|
||||||
|
public Builder weight(Integer weight) {
|
||||||
|
this.weight = weight;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getConnection
|
||||||
|
*/
|
||||||
|
public Builder connection(String connection) {
|
||||||
|
this.connections.add(checkNotNull(connection, "connection"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getHostResource
|
||||||
|
*/
|
||||||
|
public Builder hostResource(String hostResource) {
|
||||||
|
this.hostResources.add(checkNotNull(hostResource, "hostResource"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getConnections
|
||||||
|
*/
|
||||||
|
public Builder connections(List<String> connections) {
|
||||||
|
this.connections.addAll(checkNotNull(connections, "connections"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ResourceAllocationSettingData#getHostResources
|
||||||
|
*/
|
||||||
|
public Builder hostResources(List<String> hostResources) {
|
||||||
|
this.hostResources.addAll(checkNotNull(hostResources, "hostResources"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceAllocationSettingData build() {
|
||||||
|
return new ResourceAllocationSettingData(elementName, instanceID, caption, description, address,
|
||||||
|
addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility,
|
||||||
|
limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType,
|
||||||
|
resourceType, virtualQuantity, virtualQuantityUnits, weight, connections, hostResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) {
|
||||||
|
return elementName(in.getElementName()).instanceID(in.getInstanceID()).caption(in.getCaption()).description(
|
||||||
|
in.getDescription()).address(in.getAddress()).addressOnParent(in.getAddressOnParent())
|
||||||
|
.allocationUnits(in.getAllocationUnits()).automaticAllocation(in.isAutomaticAllocation())
|
||||||
|
.automaticDeallocation(in.isAutomaticDeallocation()).consumerVisibility(in.getConsumerVisibility())
|
||||||
|
.limit(in.getLimit()).mappingBehavior(in.getMappingBehavior()).otherResourceType(
|
||||||
|
in.getOtherResourceType()).parent(in.getParent()).poolID(in.getPoolID()).reservation(
|
||||||
|
in.getReservation()).resourceSubType(in.getResourceSubType()).resourceType(
|
||||||
|
in.getResourceType()).virtualQuantity(in.getVirtualQuantity()).virtualQuantityUnits(
|
||||||
|
in.getVirtualQuantityUnits()).weight(in.getWeight()).connections(in.getConnections())
|
||||||
|
.hostResources(in.getHostResources());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder caption(String caption) {
|
||||||
|
return Builder.class.cast(super.caption(caption));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
return Builder.class.cast(super.description(description));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder elementName(String elementName) {
|
||||||
|
return Builder.class.cast(super.elementName(elementName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder instanceID(String instanceID) {
|
||||||
|
return Builder.class.cast(super.instanceID(instanceID));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of resource this allocation setting represents.
|
||||||
|
*/
|
||||||
|
public static enum ResourceType {
|
||||||
|
|
||||||
|
OTHER(1), COMPUTER_SYSTEM(2), PROCESSOR(3), MEMORY(4), IDE_CONTROLLER(5), PARALLEL_SCSI_HBA(6), FC_HBA(7), ISCSI_HBA(
|
||||||
|
8), IB_HCA(9), ETHERNET_ADAPTER(10), OTHER_NETWORK_ADAPTER(11), IO_SLOT(12), IO_DEVICE(13), FLOPPY_DRIVE(
|
||||||
|
14), CD_DRIVE(15), DVD_DRIVE(16), DISK_DRIVE(17), TAPE_DRIVE(18), STORAGE_EXTENT(19), OTHER_STORAGE_DEVICE(
|
||||||
|
20), SERIAL_PORT(21), PARALLEL_PORT(22), USB_CONTROLLER(23), GRAPHICS_CONTROLLER(24), IEEE_1394_CONTROLLER(
|
||||||
|
25), PARTITIONABLE_UNIT(26), BASE_PARTITIONABLE_UNIT(27), POWER(28), COOLING_CAPACITY(29), ETHERNET_SWITCH_PORT(
|
||||||
|
30), LOGICAL_DISK(31), STORAGE_VOLUME(32), ETHERNET_CONNECTION(33), DMTF_RESERVED(Integer.valueOf(
|
||||||
|
"8000", 16)), VENDOR_RESERVED(Integer.valueOf("FFFF", 16));
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
ResourceType(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, ResourceType> RESOURCE_TYPE_BY_ID = Maps.uniqueIndex(ImmutableSet
|
||||||
|
.copyOf(ResourceType.values()), new Function<ResourceType, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(ResourceType input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static ResourceType fromValue(String type) {
|
||||||
|
return RESOURCE_TYPE_BY_ID.get(new Integer(checkNotNull(type, "type")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the consumers visibility to the allocated resource.
|
||||||
|
*/
|
||||||
|
public static enum ConsumerVisibility {
|
||||||
|
UNKNOWN(0),
|
||||||
|
/**
|
||||||
|
* indicates the underlying or host resource is utilized and passed through to the consumer,
|
||||||
|
* possibly using partitioning. At least one item shall be present in the HostResource
|
||||||
|
* property.
|
||||||
|
*/
|
||||||
|
PASSED_THROUGH(2),
|
||||||
|
/**
|
||||||
|
* indicates the resource is virtualized and may not map directly to an underlying/host
|
||||||
|
* resource. Some implementations may support specific assignment for virtualized resources,
|
||||||
|
* in which case the host resource(s) are exposed using the HostResource property.
|
||||||
|
*/
|
||||||
|
VIRTUALIZED(3),
|
||||||
|
/**
|
||||||
|
* indicates a representation of the resource does not exist within the context of the
|
||||||
|
* resource consumer.
|
||||||
|
*/
|
||||||
|
NOT_REPRESENTED(4), DMTF_RESERVED(32767), VENDOR_RESERVED(65535);
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
ConsumerVisibility(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, ConsumerVisibility> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(ImmutableSet
|
||||||
|
.copyOf(ConsumerVisibility.values()), new Function<ConsumerVisibility, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(ConsumerVisibility input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static ConsumerVisibility fromValue(String behavior) {
|
||||||
|
return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies how this resource maps to underlying resourcesIf the HostResource array contains any
|
||||||
|
* entries, this property reflects how the resource maps to those specific resources.
|
||||||
|
*/
|
||||||
|
public static enum MappingBehavior {
|
||||||
|
UNKNOWN(0), NOT_SUPPORTED(2), DEDICATED(3), SOFT_AFFINITY(4), HARD_AFFINITY(5), DMTF_RESERVED(32767), VENDOR_RESERVED(
|
||||||
|
65535);
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
MappingBehavior(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, MappingBehavior> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(ImmutableSet
|
||||||
|
.copyOf(MappingBehavior.values()), new Function<MappingBehavior, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(MappingBehavior input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static MappingBehavior fromValue(String behavior) {
|
||||||
|
return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final String address;
|
||||||
|
protected final String addressOnParent;
|
||||||
|
protected final String allocationUnits;
|
||||||
|
protected final Boolean automaticAllocation;
|
||||||
|
protected final Boolean automaticDeallocation;
|
||||||
|
protected final ConsumerVisibility consumerVisibility;
|
||||||
|
protected final Long limit;
|
||||||
|
protected final MappingBehavior mappingBehavior;
|
||||||
|
protected final String otherResourceType;
|
||||||
|
protected final String parent;
|
||||||
|
protected final String poolID;
|
||||||
|
protected final Long reservation;
|
||||||
|
protected final String resourceSubType;
|
||||||
|
protected final ResourceType resourceType;
|
||||||
|
protected final Long virtualQuantity;
|
||||||
|
protected final String virtualQuantityUnits;
|
||||||
|
protected final Integer weight;
|
||||||
|
protected final List<String> connections;
|
||||||
|
protected final List<String> hostResources;
|
||||||
|
|
||||||
|
public ResourceAllocationSettingData(String elementName, String instanceID, String caption, String description,
|
||||||
|
String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation,
|
||||||
|
Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit,
|
||||||
|
MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation,
|
||||||
|
String resourceSubType, ResourceType resourceType, Long virtualQuantity, String virtualQuantityUnits,
|
||||||
|
Integer weight, List<String> connections, List<String> hostResources) {
|
||||||
|
super(elementName, instanceID, caption, description);
|
||||||
|
this.address = address;
|
||||||
|
this.addressOnParent = addressOnParent;
|
||||||
|
this.allocationUnits = allocationUnits;
|
||||||
|
this.automaticAllocation = automaticAllocation;
|
||||||
|
this.automaticDeallocation = automaticDeallocation;
|
||||||
|
this.consumerVisibility = consumerVisibility;
|
||||||
|
this.limit = limit;
|
||||||
|
this.mappingBehavior = mappingBehavior;
|
||||||
|
this.otherResourceType = otherResourceType;
|
||||||
|
this.parent = parent;
|
||||||
|
this.poolID = poolID;
|
||||||
|
this.reservation = reservation;
|
||||||
|
this.resourceSubType = resourceSubType;
|
||||||
|
this.resourceType = resourceType;
|
||||||
|
this.virtualQuantity = virtualQuantity;
|
||||||
|
this.virtualQuantityUnits = virtualQuantityUnits;
|
||||||
|
this.weight = weight;
|
||||||
|
this.connections = ImmutableList.copyOf(connections);
|
||||||
|
this.hostResources = ImmutableList.copyOf(hostResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address of the resource. For example, the MAC address of a Ethernet port.
|
||||||
|
*/
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the address of this resource in the context of the Parent. The
|
||||||
|
* Parent/AddressOnParent properties are used to describe the controller relationship as well the
|
||||||
|
* ordering of devices on a controller.For example, if the parent is a PCI Controller, this
|
||||||
|
* property would specify the PCI slot of this child device.
|
||||||
|
*/
|
||||||
|
public String getAddressOnParent() {
|
||||||
|
return addressOnParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies the units of allocation used by the Reservation and Limit properties.
|
||||||
|
* For example, when ResourceType=Processor, AllocationUnits may be set to hertz*10^6 or percent.
|
||||||
|
* When ResourceType=Memory, AllocationUnits may be set to bytes*10^3. It is expected that
|
||||||
|
* profiles constrain the units that apply in context of particular resource types. The value of
|
||||||
|
* this property shall be a legal value of the Programmatic Units qualifier as defined in Annex
|
||||||
|
* C.1 of DSP0004 V2.5 or later.
|
||||||
|
*/
|
||||||
|
public String getAllocationUnits() {
|
||||||
|
return allocationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies if the resource will be automatically allocated. For example when set
|
||||||
|
* to true, when the consuming virtual computer system is powered on, this resource would be
|
||||||
|
* allocated. A value of false indicates the resource must be explicitly allocated. For example,
|
||||||
|
* the setting may represent removable media (cdrom, floppy, etc.) where at power on time, the
|
||||||
|
* media is not present. An explicit operation is required to allocate the resource.
|
||||||
|
*/
|
||||||
|
public Boolean isAutomaticAllocation() {
|
||||||
|
return automaticAllocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies if the resource will be automatically de-allocated. For example, when
|
||||||
|
* set to true, when the consuming virtual computer system is powered off, this resource would be
|
||||||
|
* de-allocated. When set to false, the resource will remain allocated and must be explicitly
|
||||||
|
* de-allocated.
|
||||||
|
*/
|
||||||
|
public Boolean isAutomaticDeallocation() {
|
||||||
|
return automaticDeallocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the consumers visibility to the allocated resource.
|
||||||
|
*/
|
||||||
|
public ConsumerVisibility getConsumerVisibility() {
|
||||||
|
return consumerVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies the upper bound, or maximum amount of resource that will be granted
|
||||||
|
* for this allocation. For example, a system which supports memory paging may support setting
|
||||||
|
* the Limit of a Memory allocation below that of the VirtualQuantity, thus forcing paging to
|
||||||
|
* occur for this allocation. The value of the Limit property is expressed in the unit specified
|
||||||
|
* by the value of the AllocationUnits property.
|
||||||
|
*/
|
||||||
|
public Long getLimit() {
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies how this resource maps to underlying resourcesIf the HostResource array contains any
|
||||||
|
* entries, this property reflects how the resource maps to those specific resources.
|
||||||
|
*/
|
||||||
|
public MappingBehavior getMappingBehavior() {
|
||||||
|
return mappingBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string that describes the resource type when a well defined value is not available and
|
||||||
|
* ResourceType has the value "Other".
|
||||||
|
*/
|
||||||
|
public String getOtherResourceType() {
|
||||||
|
return otherResourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Parent of the resource. For example, a controller for the current allocation
|
||||||
|
*/
|
||||||
|
public String getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies which ResourcePool the resource is currently allocated from, or which
|
||||||
|
* ResourcePool the resource will be allocated from when the allocation occurs.
|
||||||
|
*/
|
||||||
|
public String getPoolID() {
|
||||||
|
return poolID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies the amount of resource guaranteed to be available for this allocation.
|
||||||
|
* On system which support over-commitment of resources, this value is typically used for
|
||||||
|
* admission control to prevent an an allocation from being accepted thus preventing starvation.
|
||||||
|
* The value of the Reservation property is expressed in the unit specified by the value of the
|
||||||
|
* AllocationUnits property.
|
||||||
|
*/
|
||||||
|
public Long getReservation() {
|
||||||
|
return reservation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A string describing an implementation specific sub-type for this resource. F
|
||||||
|
*/
|
||||||
|
public String getResourceSubType() {
|
||||||
|
return resourceSubType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of resource this allocation setting represents.
|
||||||
|
*/
|
||||||
|
public ResourceType getResourceType() {
|
||||||
|
return resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies the quantity of resources presented to the consumer. For example, when
|
||||||
|
* ResourceType=Processor, this property would reflect the number of discrete Processors
|
||||||
|
* presented to the virtual computer system. When ResourceType=Memory, this property could
|
||||||
|
* reflect the number of MB reported to the virtual computer system. The value of the
|
||||||
|
* VirtualQuantity property should be expressed in units as defined by the value of the
|
||||||
|
* VirtualQuantityUnits property.
|
||||||
|
*/
|
||||||
|
public Long getVirtualQuantity() {
|
||||||
|
return virtualQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies the units used by the VirtualQuantity property. For example - if
|
||||||
|
* ResourceType=Processor, the value of the VirtualQuantityUnits property may be set to "count",
|
||||||
|
* indicating that the value of the VirtualQuantity property is expressed as a count. - if
|
||||||
|
* ResourceType=Memory, the value of the VirtualQuantityUnits property may be set to
|
||||||
|
* "bytes*10^3", indicating that the value of the VirtualQuantity property is expressed in
|
||||||
|
* kilobyte. It is expected that profiles constrain the units that apply in context of particular
|
||||||
|
* resource types. The value of this property shall be a legal value of the Programmatic Units
|
||||||
|
* qualifier as defined in Annex C.1 of DSP0004 V2.5 or later.
|
||||||
|
*/
|
||||||
|
public String getVirtualQuantityUnits() {
|
||||||
|
return virtualQuantityUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property specifies a relative priority for this allocation in relation to other
|
||||||
|
* allocations from the same ResourcePool. This property has no unit of measure, and is only
|
||||||
|
* relevant when compared to other allocations vying for the same host resources.
|
||||||
|
*/
|
||||||
|
public Integer getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The thing to which this resource is connected. For example, a named network or switch port.
|
||||||
|
*/
|
||||||
|
public List<String> getConnections() {
|
||||||
|
return connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This property exposes specific assignment of resources. Each non-null value of the
|
||||||
|
* HostResource property shall be formated as a URI per RFC3986. If this resource is modeled then
|
||||||
|
* a value should be a WBEM URI (DSP0207). If the resource is not modeled then see the
|
||||||
|
* appropriate profile. Profiles may further constrain the type of URI. A NULL value or empty
|
||||||
|
* array requests the implementation decide the kind of host resource. If the virtual resource is
|
||||||
|
* mapped to more than oneunderlying resource, this property may be left NULL. If NULL, the
|
||||||
|
* DeviceAllocatedFromPool or ResourceAllocationFromPool associations may be used to determine
|
||||||
|
* the pool of host resources this virtual resource may use. If specific assignment is utilized,
|
||||||
|
* all underlying resources used by this virtual resource should be listed.The kind of dependency
|
||||||
|
* is specified by the ConsumerVisibility and the MappingBehavior properties. Typically the array
|
||||||
|
* contains one item, however multiple host resources may be specified. A client may set the
|
||||||
|
* value(s) to indicate that the requested virtual resource allocation be based on host resources
|
||||||
|
* that are identified by element values.
|
||||||
|
*/
|
||||||
|
public List<String> getHostResources() {
|
||||||
|
return hostResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromResourceAllocationSettingData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String
|
||||||
|
.format(
|
||||||
|
"[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s]",
|
||||||
|
elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
|
||||||
|
automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources,
|
||||||
|
limit, mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType,
|
||||||
|
resourceType, virtualQuantity, virtualQuantityUnits, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((address == null) ? 0 : address.hashCode());
|
||||||
|
result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
|
||||||
|
result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode());
|
||||||
|
result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ResourceAllocationSettingData other = (ResourceAllocationSettingData) obj;
|
||||||
|
if (address == null) {
|
||||||
|
if (other.address != null)
|
||||||
|
return false;
|
||||||
|
} else if (!address.equals(other.address))
|
||||||
|
return false;
|
||||||
|
if (addressOnParent == null) {
|
||||||
|
if (other.addressOnParent != null)
|
||||||
|
return false;
|
||||||
|
} else if (!addressOnParent.equals(other.addressOnParent))
|
||||||
|
return false;
|
||||||
|
if (resourceSubType == null) {
|
||||||
|
if (other.resourceSubType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!resourceSubType.equals(other.resourceSubType))
|
||||||
|
return false;
|
||||||
|
if (resourceType == null) {
|
||||||
|
if (other.resourceType != null)
|
||||||
|
return false;
|
||||||
|
} else if (!resourceType.equals(other.resourceType))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The type of resource this allocation setting represents.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
|
||||||
|
* />
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class SettingData {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
protected String elementName;
|
||||||
|
protected String instanceID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SettingData#getElementName
|
||||||
|
*/
|
||||||
|
public Builder elementName(String elementName) {
|
||||||
|
this.elementName = checkNotNull(elementName, "elementName");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SettingData#getInstanceID
|
||||||
|
*/
|
||||||
|
public Builder instanceID(String instanceID) {
|
||||||
|
this.instanceID = checkNotNull(instanceID, "instanceID");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromSettingData(SettingData in) {
|
||||||
|
return elementName(in.getElementName()).instanceID(in.getInstanceID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final String elementName;
|
||||||
|
protected final String instanceID;
|
||||||
|
|
||||||
|
public SettingData(String elementName, String instanceID) {
|
||||||
|
this.elementName = checkNotNull(elementName, "elementName");
|
||||||
|
this.instanceID = checkNotNull(instanceID, "instanceID");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user-friendly name for this instance of SettingData. In addition, the user-friendly name
|
||||||
|
* can be used as an index property for a search or query. (Note: The name does not have to be
|
||||||
|
* unique within a namespace.)
|
||||||
|
*/
|
||||||
|
public String getElementName() {
|
||||||
|
return elementName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies
|
||||||
|
* an instance of this class.
|
||||||
|
*/
|
||||||
|
public String getInstanceID() {
|
||||||
|
return instanceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((elementName == null) ? 0 : elementName.hashCode());
|
||||||
|
result = prime * result + ((instanceID == null) ? 0 : instanceID.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
SettingData other = (SettingData) obj;
|
||||||
|
if (elementName == null) {
|
||||||
|
if (other.elementName != null)
|
||||||
|
return false;
|
||||||
|
} else if (!elementName.equals(other.elementName))
|
||||||
|
return false;
|
||||||
|
if (instanceID == null) {
|
||||||
|
if (other.instanceID != null)
|
||||||
|
return false;
|
||||||
|
} else if (!instanceID.equals(other.instanceID))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("[elementName=%s, instanceID=%s]", elementName, instanceID);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,575 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* CIM_VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of
|
||||||
|
* virtualization specific properties. CIM_VirtualSystemSettingData is also used as the top level
|
||||||
|
* class of virtual system configurations. Virtual system configurations model configuration
|
||||||
|
* information about virtual systems and their components. A virtual system configuration consists
|
||||||
|
* of one top-level instance of class CIM_VirtualSystemSettingData that aggregates a number of
|
||||||
|
* instances of class CIM_ResourceAllocationSettingData, using association CIM_ConcreteComponent.
|
||||||
|
* Virtual system configurations may for example be used to reflect configurations of - virtual
|
||||||
|
* systems that are defined at a virtualization platform, - virtual systems that are currently
|
||||||
|
* active, - input requests to create new virtual systems, - input requests to modify existing
|
||||||
|
* virtual systems, or - snapshots of virtual systems.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
|
||||||
|
* />
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class VirtualSystemSettingData extends ManagedElement {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends ManagedElement.Builder {
|
||||||
|
private AutomaticRecoveryAction automaticRecoveryAction;
|
||||||
|
private AutomaticShutdownAction automaticShutdownAction;
|
||||||
|
private AutomaticStartupAction automaticStartupAction;
|
||||||
|
private Long automaticStartupActionDelay;
|
||||||
|
private Integer automaticStartupActionSequenceNumber;
|
||||||
|
private URI configurationDataRoot;
|
||||||
|
private URI configurationFile;
|
||||||
|
private String configurationID;
|
||||||
|
private Date creationTime;
|
||||||
|
private URI logDataRoot;
|
||||||
|
private URI recoveryFile;
|
||||||
|
private URI snapshotDataRoot;
|
||||||
|
private URI suspendDataRoot;
|
||||||
|
private URI swapFileDataRoot;
|
||||||
|
private String virtualSystemIdentifier;
|
||||||
|
private Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
|
||||||
|
private String notes;
|
||||||
|
|
||||||
|
public Builder automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) {
|
||||||
|
this.automaticRecoveryAction = automaticRecoveryAction;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) {
|
||||||
|
this.automaticShutdownAction = automaticShutdownAction;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder automaticStartupAction(AutomaticStartupAction automaticStartupAction) {
|
||||||
|
this.automaticStartupAction = automaticStartupAction;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder automaticStartupActionDelay(Long automaticStartupActionDelay) {
|
||||||
|
this.automaticStartupActionDelay = automaticStartupActionDelay;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder automaticStartupActionSequenceNumber(Integer automaticStartupActionSequenceNumber) {
|
||||||
|
this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder configurationDataRoot(URI configurationDataRoot) {
|
||||||
|
this.configurationDataRoot = configurationDataRoot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder configurationFile(URI configurationFile) {
|
||||||
|
this.configurationFile = configurationFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder configurationID(String configurationID) {
|
||||||
|
this.configurationID = configurationID;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder creationTime(Date creationTime) {
|
||||||
|
this.creationTime = creationTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder logDataRoot(URI logDataRoot) {
|
||||||
|
this.logDataRoot = logDataRoot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder recoveryFile(URI recoveryFile) {
|
||||||
|
this.recoveryFile = recoveryFile;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder snapshotDataRoot(URI snapshotDataRoot) {
|
||||||
|
this.snapshotDataRoot = snapshotDataRoot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder suspendDataRoot(URI suspendDataRoot) {
|
||||||
|
this.suspendDataRoot = suspendDataRoot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder swapFileDataRoot(URI swapFileDataRoot) {
|
||||||
|
this.swapFileDataRoot = swapFileDataRoot;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder virtualSystemIdentifier(String virtualSystemIdentifier) {
|
||||||
|
this.virtualSystemIdentifier = virtualSystemIdentifier;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder virtualSystemTypes(Iterable<String> virtualSystemTypes) {
|
||||||
|
this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder virtualSystemType(String virtualSystemType) {
|
||||||
|
this.virtualSystemTypes.add(checkNotNull(virtualSystemType, "virtualSystemType"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder notes(String notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualSystemSettingData build() {
|
||||||
|
return new VirtualSystemSettingData(elementName, instanceID, caption, description, automaticRecoveryAction,
|
||||||
|
automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay,
|
||||||
|
automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile, configurationID,
|
||||||
|
creationTime, logDataRoot, recoveryFile, snapshotDataRoot, suspendDataRoot, swapFileDataRoot,
|
||||||
|
virtualSystemIdentifier, virtualSystemTypes, notes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromVirtualSystemSettingData(VirtualSystemSettingData in) {
|
||||||
|
return fromManagedElement(in).automaticRecoveryAction(in.getAutomaticRecoveryAction())
|
||||||
|
.automaticShutdownAction(in.getAutomaticShutdownAction()).automaticStartupAction(
|
||||||
|
in.getAutomaticStartupAction()).automaticStartupActionDelay(
|
||||||
|
in.getAutomaticStartupActionDelay()).automaticStartupActionSequenceNumber(
|
||||||
|
in.getAutomaticStartupActionSequenceNumber()).configurationDataRoot(
|
||||||
|
in.getConfigurationDataRoot()).configurationFile(in.getConfigurationFile()).configurationID(
|
||||||
|
in.getConfigurationID()).creationTime(in.getCreationTime()).logDataRoot(in.getLogDataRoot())
|
||||||
|
.recoveryFile(in.getRecoveryFile()).snapshotDataRoot(in.getSnapshotDataRoot()).suspendDataRoot(
|
||||||
|
in.getSuspendDataRoot()).swapFileDataRoot(in.getSwapFileDataRoot()).virtualSystemIdentifier(
|
||||||
|
in.getVirtualSystemIdentifier()).virtualSystemTypes(in.getVirtualSystemTypes()).notes(
|
||||||
|
in.getNotes());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder fromManagedElement(ManagedElement in) {
|
||||||
|
return Builder.class.cast(super.fromManagedElement(in));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder caption(String caption) {
|
||||||
|
return Builder.class.cast(super.caption(caption));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder description(String description) {
|
||||||
|
return Builder.class.cast(super.description(description));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder elementName(String elementName) {
|
||||||
|
return Builder.class.cast(super.elementName(elementName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Builder instanceID(String instanceID) {
|
||||||
|
return Builder.class.cast(super.instanceID(instanceID));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the software executed by the virtual system fails.
|
||||||
|
* Failures in this case means a failure that is detectable by the host platform, such as a
|
||||||
|
* non-interuptable wait state condition.
|
||||||
|
*/
|
||||||
|
public static enum AutomaticRecoveryAction {
|
||||||
|
|
||||||
|
NONE(2),
|
||||||
|
|
||||||
|
RESTART(3),
|
||||||
|
|
||||||
|
REVERT_TO_SNAPSHOT(4);
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
AutomaticRecoveryAction(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, AutomaticRecoveryAction> AUTOMATIC_RECOVERY_ACTION_BY_ID = Maps.uniqueIndex(
|
||||||
|
ImmutableSet.copyOf(AutomaticRecoveryAction.values()), new Function<AutomaticRecoveryAction, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(AutomaticRecoveryAction input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static AutomaticRecoveryAction fromValue(String automaticRecoveryAction) {
|
||||||
|
return AUTOMATIC_RECOVERY_ACTION_BY_ID.get(new Integer(checkNotNull(automaticRecoveryAction,
|
||||||
|
"automaticRecoveryAction")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the host is shut down.
|
||||||
|
*/
|
||||||
|
public static enum AutomaticShutdownAction {
|
||||||
|
|
||||||
|
TURN_OFF(2),
|
||||||
|
|
||||||
|
SAVE_STATE(3),
|
||||||
|
|
||||||
|
SHUTDOWN(4);
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
AutomaticShutdownAction(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, AutomaticShutdownAction> AUTOMATIC_SHUTDOWN_ACTION_BY_ID = Maps.uniqueIndex(
|
||||||
|
ImmutableSet.copyOf(AutomaticShutdownAction.values()), new Function<AutomaticShutdownAction, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(AutomaticShutdownAction input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static AutomaticShutdownAction fromValue(String automaticShutdownAction) {
|
||||||
|
return AUTOMATIC_SHUTDOWN_ACTION_BY_ID.get(new Integer(checkNotNull(automaticShutdownAction,
|
||||||
|
"automaticShutdownAction")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the host is started.
|
||||||
|
*/
|
||||||
|
public static enum AutomaticStartupAction {
|
||||||
|
|
||||||
|
NONE(2),
|
||||||
|
|
||||||
|
RESTART_IF_PREVIOUSLY_ACTIVE(3),
|
||||||
|
|
||||||
|
ALWAYS_STARTUP(4);
|
||||||
|
|
||||||
|
protected final int code;
|
||||||
|
|
||||||
|
AutomaticStartupAction(int code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return code + "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final static Map<Integer, AutomaticStartupAction> AUTOMATIC_STARTUP_ACTION_BY_ID = Maps.uniqueIndex(
|
||||||
|
ImmutableSet.copyOf(AutomaticStartupAction.values()), new Function<AutomaticStartupAction, Integer>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer apply(AutomaticStartupAction input) {
|
||||||
|
return input.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
public static AutomaticStartupAction fromValue(String automaticStartupAction) {
|
||||||
|
return AUTOMATIC_STARTUP_ACTION_BY_ID.get(new Integer(checkNotNull(automaticStartupAction,
|
||||||
|
"automaticStartupAction")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final AutomaticRecoveryAction automaticRecoveryAction;
|
||||||
|
private final AutomaticShutdownAction automaticShutdownAction;
|
||||||
|
private final AutomaticStartupAction automaticStartupAction;
|
||||||
|
private final Long automaticStartupActionDelay;
|
||||||
|
private final Integer automaticStartupActionSequenceNumber;
|
||||||
|
private final URI configurationDataRoot;
|
||||||
|
private final URI configurationFile;
|
||||||
|
private final String configurationID;
|
||||||
|
private final Date creationTime;
|
||||||
|
private final URI logDataRoot;
|
||||||
|
private final URI recoveryFile;
|
||||||
|
private final URI snapshotDataRoot;
|
||||||
|
private final URI suspendDataRoot;
|
||||||
|
private final URI swapFileDataRoot;
|
||||||
|
private final String virtualSystemIdentifier;
|
||||||
|
private final Set<String> virtualSystemTypes;
|
||||||
|
private final String notes;
|
||||||
|
|
||||||
|
public VirtualSystemSettingData(String elementName, String instanceID, String caption, String description,
|
||||||
|
AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction,
|
||||||
|
AutomaticStartupAction automaticStartupAction, Long automaticStartupActionDelay,
|
||||||
|
Integer automaticStartupActionSequenceNumber, URI configurationDataRoot, URI configurationFile,
|
||||||
|
String configurationID, Date creationTime, URI logDataRoot, URI recoveryFile, URI snapshotDataRoot,
|
||||||
|
URI suspendDataRoot, URI swapFileDataRoot, String virtualSystemIdentifier,
|
||||||
|
Iterable<String> virtualSystemTypes, String notes) {
|
||||||
|
super(elementName, instanceID, caption, description);
|
||||||
|
this.automaticRecoveryAction = automaticRecoveryAction;
|
||||||
|
this.automaticShutdownAction = automaticShutdownAction;
|
||||||
|
this.automaticStartupAction = automaticStartupAction;
|
||||||
|
this.automaticStartupActionDelay = automaticStartupActionDelay;
|
||||||
|
this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
|
||||||
|
this.configurationDataRoot = configurationDataRoot;
|
||||||
|
this.configurationFile = configurationFile;
|
||||||
|
this.configurationID = configurationID;
|
||||||
|
this.creationTime = creationTime;
|
||||||
|
this.logDataRoot = logDataRoot;
|
||||||
|
this.recoveryFile = recoveryFile;
|
||||||
|
this.snapshotDataRoot = snapshotDataRoot;
|
||||||
|
this.suspendDataRoot = suspendDataRoot;
|
||||||
|
this.swapFileDataRoot = swapFileDataRoot;
|
||||||
|
this.virtualSystemIdentifier = virtualSystemIdentifier;
|
||||||
|
this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the software executed by the virtual system fails.
|
||||||
|
* Failures in this case means a failure that is detectable by the host platform, such as a
|
||||||
|
* non-interuptable wait state condition.
|
||||||
|
*/
|
||||||
|
public AutomaticRecoveryAction getAutomaticRecoveryAction() {
|
||||||
|
return automaticRecoveryAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the host is shut down.
|
||||||
|
*/
|
||||||
|
public AutomaticShutdownAction getAutomaticShutdownAction() {
|
||||||
|
return automaticShutdownAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action to take for the virtual system when the host is started.
|
||||||
|
*/
|
||||||
|
public AutomaticStartupAction getAutomaticStartupAction() {
|
||||||
|
return automaticStartupAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay applicable to startup action. The value shall be in the interval variant of the datetime
|
||||||
|
* datatype.
|
||||||
|
*/
|
||||||
|
public Long getAutomaticStartupActionDelay() {
|
||||||
|
return automaticStartupActionDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number indicating the relative sequence of virtual system activation when the host system is
|
||||||
|
* started. A lower number indicates earlier activation. If one or more configurations show the
|
||||||
|
* same value, the sequence is implementation dependent. A value of 0 indicates that the sequence
|
||||||
|
* is implementation dependent.
|
||||||
|
*/
|
||||||
|
public Integer getAutomaticStartupActionSequenceNumber() {
|
||||||
|
return automaticStartupActionSequenceNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a directory where information about the virtual system configuration is
|
||||||
|
* stored.Format shall be URI based on RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getConfigurationDataRoot() {
|
||||||
|
return configurationDataRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a file where information about the virtual system configuration is stored. A
|
||||||
|
* relative path appends to the value of the ConfigurationDataRoot property.Format shall be URI
|
||||||
|
* based on RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getConfigurationFile() {
|
||||||
|
return configurationFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique id of the virtual system configuration. Note that the ConfigurationID is different from
|
||||||
|
* the InstanceID as it is assigned by the implementation to a virtual system or a virtual system
|
||||||
|
* configuration. It is not a key, and the same value may occur within more than one instance.
|
||||||
|
*/
|
||||||
|
public String getConfigurationID() {
|
||||||
|
return configurationID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time when the virtual system configuration was created.
|
||||||
|
*/
|
||||||
|
public Date getCreationTime() {
|
||||||
|
return creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a directory where log information about the virtual system is stored. A relative
|
||||||
|
* path appends to the value of the ConfigurationDataRoot property.Format shall be URI based on
|
||||||
|
* RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getLogDataRoot() {
|
||||||
|
return logDataRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a file where recovery relateded information of the virtual system is stored.Format
|
||||||
|
* shall be URI based on RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getRecoveryFile() {
|
||||||
|
return recoveryFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a directory where information about virtual system snapshots is stored. A relative
|
||||||
|
* path appends to the value of the ConfigurationDataRoot property.Format shall be URI based on
|
||||||
|
* RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getSnapshotDataRoot() {
|
||||||
|
return snapshotDataRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a directory where suspend related information about the virtual system is stored.
|
||||||
|
* A relative path appends to the value of the ConfigurationDataRoot property.Format shall be URI
|
||||||
|
* based on RFC 2079.
|
||||||
|
*/
|
||||||
|
public URI getSuspendDataRoot() {
|
||||||
|
return suspendDataRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filepath of a directory where swapfiles of the virtual system are stored. A relative path
|
||||||
|
* appends to the value of the ConfigurationDataRoot property.Format shall be URI based on RFC
|
||||||
|
* 2079.
|
||||||
|
*/
|
||||||
|
public URI getSwapFileDataRoot() {
|
||||||
|
return swapFileDataRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VirtualSystemIdentifier shall reflect a unique name for the system as it is used within the
|
||||||
|
* virtualization platform. Note that the VirtualSystemIdentifier is not the hostname assigned to
|
||||||
|
* the operating system instance running within the virtual system, nor is it an IP address or
|
||||||
|
* MAC address assigned to any of its network ports. On create requests VirtualSystemIdentifier
|
||||||
|
* may contain implementation specific rules (like simple patterns or regular expresssion) that
|
||||||
|
* may be interpreted by the implementation when assigning a VirtualSystemIdentifier.
|
||||||
|
*/
|
||||||
|
public String getVirtualSystemIdentifier() {
|
||||||
|
return virtualSystemIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VirtualSystemType shall reflect a particular type of virtual system.
|
||||||
|
*/
|
||||||
|
public Set<String> getVirtualSystemTypes() {
|
||||||
|
return virtualSystemTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End-user supplied notes that are related to the virtual system.
|
||||||
|
*/
|
||||||
|
public String getNotes() {
|
||||||
|
return notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromVirtualSystemSettingData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((virtualSystemIdentifier == null) ? 0 : virtualSystemIdentifier.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
VirtualSystemSettingData other = (VirtualSystemSettingData) obj;
|
||||||
|
if (virtualSystemIdentifier == null) {
|
||||||
|
if (other.virtualSystemIdentifier != null)
|
||||||
|
return false;
|
||||||
|
} else if (!virtualSystemIdentifier.equals(other.virtualSystemIdentifier))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String
|
||||||
|
.format(
|
||||||
|
"[elementName=%s, instanceID=%s, caption=%s, description=%s, automaticRecoveryAction=%s, automaticShutdownAction=%s, automaticStartupAction=%s, automaticStartupActionDelay=%s, automaticStartupActionSequenceNumber=%s, configurationDataRoot=%s, configurationFile=%s, configurationID=%s, creationTime=%s, logDataRoot=%s, notes=%s, recoveryFile=%s, snapshotDataRoot=%s, suspendDataRoot=%s, swapFileDataRoot=%s, virtualSystemIdentifier=%s, virtualSystemTypes=%s]",
|
||||||
|
elementName, instanceID, caption, description, automaticRecoveryAction,
|
||||||
|
automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay,
|
||||||
|
automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile,
|
||||||
|
configurationID, creationTime, logDataRoot, notes, recoveryFile, snapshotDataRoot,
|
||||||
|
suspendDataRoot, swapFileDataRoot, virtualSystemIdentifier, virtualSystemTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim.functions;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.find;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.cim.CIMPredicates;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.internal.VolumeImpl;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class HardwareBuilderFromResourceAllocations implements
|
||||||
|
Function<Iterable<? extends ResourceAllocationSettingData>, HardwareBuilder> {
|
||||||
|
@Override
|
||||||
|
public HardwareBuilder apply(Iterable<? extends ResourceAllocationSettingData> from) {
|
||||||
|
HardwareBuilder builder = new HardwareBuilder();
|
||||||
|
builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE,
|
||||||
|
ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)),
|
||||||
|
new Function<ResourceAllocationSettingData, Volume>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Volume apply(ResourceAllocationSettingData from) {
|
||||||
|
return HardwareBuilderFromResourceAllocations.this.apply(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue());
|
||||||
|
|
||||||
|
builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)),
|
||||||
|
new Function<ResourceAllocationSettingData, Processor>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Processor apply(ResourceAllocationSettingData arg0) {
|
||||||
|
return new Processor(arg0.getVirtualQuantity(), 1);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Volume apply(ResourceAllocationSettingData from) {
|
||||||
|
return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null
|
||||||
|
: from.getVirtualQuantity() / 1024 / 1024f, null, "0".equals(from.getAddressOnParent())
|
||||||
|
|| ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim.xml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||||
|
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ConsumerVisibility;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.MappingBehavior;
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ResourceAllocationSettingDataHandler extends ParseSax.HandlerWithResult<ResourceAllocationSettingData> {
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected ResourceAllocationSettingData.Builder builder = ResourceAllocationSettingData.builder();
|
||||||
|
|
||||||
|
public ResourceAllocationSettingData getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = ResourceAllocationSettingData.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
String current = currentOrNull(currentText);
|
||||||
|
if (current != null) {
|
||||||
|
if (equalsOrSuffix(qName, "ElementName")) {
|
||||||
|
builder.elementName(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "InstanceID")) {
|
||||||
|
builder.instanceID(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Caption")) {
|
||||||
|
builder.caption(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Description")) {
|
||||||
|
builder.description(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Address")) {
|
||||||
|
builder.address(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "AddressOnParent")) {
|
||||||
|
builder.addressOnParent(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "AllocationUnits")) {
|
||||||
|
builder.allocationUnits(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticAllocation")) {
|
||||||
|
builder.automaticAllocation(new Boolean(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticDeallocation")) {
|
||||||
|
builder.automaticDeallocation(new Boolean(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "ConsumerVisibility")) {
|
||||||
|
builder.consumerVisibility(ConsumerVisibility.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "Limit")) {
|
||||||
|
builder.limit(new Long(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "MappingBehavior")) {
|
||||||
|
builder.mappingBehavior(MappingBehavior.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "OtherResourceType")) {
|
||||||
|
builder.otherResourceType(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Parent")) {
|
||||||
|
builder.parent(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "PoolID")) {
|
||||||
|
builder.poolID(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Reservation")) {
|
||||||
|
builder.reservation(new Long(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "ResourceSubType")) {
|
||||||
|
builder.resourceSubType(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "ResourceType")) {
|
||||||
|
builder.resourceType(ResourceType.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "VirtualQuantity")) {
|
||||||
|
builder.virtualQuantity(new Long(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "VirtualQuantityUnits")) {
|
||||||
|
builder.virtualQuantityUnits(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Weight")) {
|
||||||
|
builder.weight(new Integer(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "Connection")) {
|
||||||
|
builder.connection(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "HostResource")) {
|
||||||
|
builder.hostResource(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.cim.xml;
|
||||||
|
|
||||||
|
import static com.google.common.base.Predicates.equalTo;
|
||||||
|
import static com.google.common.base.Predicates.not;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||||
|
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData.AutomaticRecoveryAction;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData.AutomaticShutdownAction;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData.AutomaticStartupAction;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VirtualSystemSettingDataHandler extends ParseSax.HandlerWithResult<VirtualSystemSettingData> {
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected VirtualSystemSettingData.Builder builder = VirtualSystemSettingData.builder();
|
||||||
|
|
||||||
|
public VirtualSystemSettingData getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = VirtualSystemSettingData.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
String current = currentOrNull(currentText);
|
||||||
|
if (current != null) {
|
||||||
|
if (equalsOrSuffix(qName, "ElementName")) {
|
||||||
|
builder.elementName(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "InstanceID")) {
|
||||||
|
builder.instanceID(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Caption")) {
|
||||||
|
builder.caption(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "Description")) {
|
||||||
|
builder.description(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticRecoveryAction")) {
|
||||||
|
builder.automaticRecoveryAction(AutomaticRecoveryAction.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticShutdownAction")) {
|
||||||
|
builder.automaticShutdownAction(AutomaticShutdownAction.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticStartupAction")) {
|
||||||
|
builder.automaticStartupAction(AutomaticStartupAction.fromValue(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticStartupActionDelay")) {
|
||||||
|
// TODO parse the format for intervals: ddddddddhhmmss.mmmmmm:000
|
||||||
|
builder.automaticStartupActionDelay(null);
|
||||||
|
} else if (equalsOrSuffix(qName, "AutomaticStartupActionSequenceNumber")) {
|
||||||
|
builder.automaticStartupActionSequenceNumber(new Integer(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "ConfigurationDataRoot")) {
|
||||||
|
builder.configurationDataRoot(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "ConfigurationFile")) {
|
||||||
|
builder.configurationFile(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "ConfigurationID")) {
|
||||||
|
builder.configurationID(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "CreationTime")) {
|
||||||
|
// TODO parse the format for timestamps: yyyymmddhhmmss.mmmmmmsutc
|
||||||
|
builder.creationTime(null);
|
||||||
|
} else if (equalsOrSuffix(qName, "LogDataRoot")) {
|
||||||
|
builder.logDataRoot(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "RecoveryFile")) {
|
||||||
|
builder.recoveryFile(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "RecoveryFile")) {
|
||||||
|
builder.recoveryFile(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "SuspendDataRoot")) {
|
||||||
|
builder.suspendDataRoot(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "SwapFileDataRoot")) {
|
||||||
|
builder.swapFileDataRoot(URI.create(current));
|
||||||
|
} else if (equalsOrSuffix(qName, "VirtualSystemIdentifier")) {
|
||||||
|
builder.virtualSystemIdentifier(current);
|
||||||
|
} else if (equalsOrSuffix(qName, "VirtualSystemType")) {
|
||||||
|
builder.virtualSystemTypes(filter(transform(Splitter.on(',').split(current),
|
||||||
|
new Function<String, String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(String input) {
|
||||||
|
return input.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
}), not(equalTo(""))));
|
||||||
|
} else if (equalsOrSuffix(qName, "Notes")) {
|
||||||
|
builder.notes(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,10 +17,9 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.compute.domain.os;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.OperatingSystem;
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
|
|
||||||
import com.google.common.annotations.Beta;
|
import com.google.common.annotations.Beta;
|
||||||
|
|
||||||
|
@ -33,6 +32,14 @@ import com.google.common.annotations.Beta;
|
||||||
@Beta
|
@Beta
|
||||||
public class CIMOperatingSystem extends OperatingSystem {
|
public class CIMOperatingSystem extends OperatingSystem {
|
||||||
|
|
||||||
|
public static CIMOperatingSystem toComputeOs(org.jclouds.ovf.OperatingSystemSection os) {
|
||||||
|
return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), "", null, os.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) {
|
||||||
|
return toComputeOs(ovf.getVirtualSystem().getOperatingSystem());
|
||||||
|
}
|
||||||
|
|
||||||
public enum OSType {
|
public enum OSType {
|
||||||
/**
|
/**
|
||||||
* Other
|
* Other
|
||||||
|
@ -201,9 +208,12 @@ public class CIMOperatingSystem extends OperatingSystem {
|
||||||
/**
|
/**
|
||||||
* Oracle Enterprise Linux 64-bit
|
* Oracle Enterprise Linux 64-bit
|
||||||
*/
|
*/
|
||||||
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true), UNRECOGNIZED(
|
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true),
|
||||||
Integer.MAX_VALUE, "UNRECOGNIZED", null, true);
|
/**
|
||||||
|
* eComStation 32-bitx
|
||||||
|
*/
|
||||||
|
ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), UNRECOGNIZED(Integer.MAX_VALUE,
|
||||||
|
"UNRECOGNIZED", null, true);
|
||||||
private final int code;
|
private final int code;
|
||||||
|
|
||||||
public int getCode() {
|
public int getCode() {
|
|
@ -32,6 +32,7 @@ import org.jclouds.compute.predicates.ImagePredicates;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +49,8 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
|
||||||
super(ComputeType.HARDWARE);
|
super(ComputeType.HARDWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HardwareBuilder processors(List<Processor> processors) {
|
public HardwareBuilder processors(Iterable<Processor> processors) {
|
||||||
this.processors = checkNotNull(processors, "processors");
|
this.processors = ImmutableList.copyOf(checkNotNull(processors, "processors"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +59,8 @@ public class HardwareBuilder extends ComputeMetadataBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HardwareBuilder volumes(List<Volume> volumes) {
|
public HardwareBuilder volumes(Iterable<Volume> volumes) {
|
||||||
this.volumes = checkNotNull(volumes, "volumes");
|
this.volumes = ImmutableList.copyOf(checkNotNull(volumes, "volumes"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.compute.domain.os;
|
package org.jclouds.compute.domain;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf.network;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
|
@ -17,14 +17,11 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The NetworkSection element shall list all logical networks used in the OVF package.
|
* The NetworkSection element shall list all logical networks used in the OVF package.
|
||||||
|
@ -33,11 +30,11 @@ import com.google.common.collect.Sets;
|
||||||
*/
|
*/
|
||||||
public class NetworkSection {
|
public class NetworkSection {
|
||||||
private final String info;
|
private final String info;
|
||||||
private final Set<Network> networks = Sets.newLinkedHashSet();
|
private final Set<Network> networks;
|
||||||
|
|
||||||
public NetworkSection(String info, Iterable<Network> networks) {
|
public NetworkSection(String info, Iterable<Network> networks) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
Iterables.addAll(this.networks, networks);
|
this.networks = ImmutableSet.<Network> copyOf(networks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfo() {
|
public String getInfo() {
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
|
@ -17,15 +17,16 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.cim.VirtualSystemSettingData;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -38,25 +39,25 @@ import com.google.common.collect.Sets;
|
||||||
public class VirtualHardwareSection {
|
public class VirtualHardwareSection {
|
||||||
|
|
||||||
protected final String info;
|
protected final String info;
|
||||||
protected final System virtualSystem;
|
protected final VirtualSystemSettingData virtualSystem;
|
||||||
protected final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
|
protected final Set<ResourceAllocationSettingData> resourceAllocations;
|
||||||
|
|
||||||
public VirtualHardwareSection(String info, System virtualSystem,
|
public VirtualHardwareSection(String info, VirtualSystemSettingData virtualSystem,
|
||||||
Iterable<? extends ResourceAllocation> resourceAllocations) {
|
Iterable<? extends ResourceAllocationSettingData> resourceAllocations) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.virtualSystem = virtualSystem;
|
this.virtualSystem = virtualSystem;
|
||||||
Iterables.addAll(this.resourceAllocations, checkNotNull(resourceAllocations, "resourceAllocations"));
|
this.resourceAllocations = ImmutableSet.copyOf(checkNotNull(resourceAllocations, "resourceAllocations"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfo() {
|
public String getInfo() {
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public System getSystem() {
|
public VirtualSystemSettingData getSystem() {
|
||||||
return virtualSystem;
|
return virtualSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<? extends ResourceAllocation> getResourceAllocations() {
|
public Set<? extends ResourceAllocationSettingData> getResourceAllocations() {
|
||||||
return resourceAllocations;
|
return resourceAllocations;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.domain.ovf;
|
package org.jclouds.ovf;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
|
@ -17,15 +17,18 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
package org.jclouds.ovf.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||||
|
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.vcloud.domain.ovf.NetworkSection;
|
import org.jclouds.ovf.Network;
|
||||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
import org.jclouds.ovf.NetworkSection;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
import org.jclouds.util.SaxUtils;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -50,19 +53,19 @@ public class NetworkSectionHandler extends ParseSax.HandlerWithResult<NetworkSec
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("Network")) {
|
if (equalsOrSuffix(qName, "Network")) {
|
||||||
name = attributes.get("name");
|
name = attributes.get("name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) {
|
public void endElement(String uri, String localName, String qName) {
|
||||||
if (qName.endsWith("Info")) {
|
if (equalsOrSuffix(qName, "Info")) {
|
||||||
this.info = currentOrNull();
|
this.info = currentOrNull(currentText);
|
||||||
} else if (qName.endsWith("Description")) {
|
} else if (equalsOrSuffix(qName, "Description")) {
|
||||||
this.description = currentOrNull();
|
this.description = currentOrNull(currentText);
|
||||||
} else if (qName.endsWith("Network")) {
|
} else if (equalsOrSuffix(qName, "Network")) {
|
||||||
this.networks.add(new Network(name, description));
|
this.networks.add(new Network(name, description));
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
|
@ -72,8 +75,4 @@ public class NetworkSectionHandler extends ParseSax.HandlerWithResult<NetworkSec
|
||||||
currentText.append(ch, start, length);
|
currentText.append(ch, start, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String currentOrNull() {
|
|
||||||
String returnVal = currentText.toString().trim();
|
|
||||||
return returnVal.equals("") ? null : returnVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -17,13 +17,16 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
package org.jclouds.ovf.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.util.SaxUtils.cleanseAttributes;
|
||||||
|
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||||
|
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.vcloud.domain.ovf.OperatingSystemSection;
|
import org.jclouds.ovf.OperatingSystemSection;
|
||||||
import org.jclouds.vcloud.util.Utils;
|
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +49,8 @@ public class OperatingSystemSectionHandler extends ParseSax.HandlerWithResult<Op
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
if (qName.endsWith("OperatingSystemSection")) {
|
if (equalsOrSuffix(qName, "OperatingSystemSection")) {
|
||||||
if (attributes.containsKey("id"))
|
if (attributes.containsKey("id"))
|
||||||
this.id = Integer.parseInt(attributes.get("id"));
|
this.id = Integer.parseInt(attributes.get("id"));
|
||||||
}
|
}
|
||||||
|
@ -55,10 +58,10 @@ public class OperatingSystemSectionHandler extends ParseSax.HandlerWithResult<Op
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) {
|
public void endElement(String uri, String localName, String qName) {
|
||||||
if (qName.endsWith("Info")) {
|
if (equalsOrSuffix(qName, "Info")) {
|
||||||
this.info = currentText.toString().trim();
|
this.info = currentOrNull(currentText);
|
||||||
} else if (qName.endsWith("Description")) {
|
} else if (equalsOrSuffix(qName, "Description")) {
|
||||||
this.description = currentText.toString().trim();
|
this.description = currentOrNull(currentText);
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
currentText = new StringBuilder();
|
||||||
}
|
}
|
|
@ -17,15 +17,15 @@
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.vcloud.xml.ovf;
|
package org.jclouds.ovf.xml;
|
||||||
|
|
||||||
//import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
//import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
import org.jclouds.ovf.OvfEnvelope;
|
||||||
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
|
import org.jclouds.ovf.VirtualSystem;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue