Merge remote branch 'origin'

This commit is contained in:
Andrew Phillips 2010-08-26 00:54:29 +02:00
commit 744d828416
60 changed files with 1574 additions and 271 deletions

View File

@ -54,10 +54,10 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS
@Test @Test
public void testTemplateBuilder() { public void testTemplateBuilder() {
Template defaultTemplate = client.templateBuilder().build(); Template defaultTemplate = client.templateBuilder().build();
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem()); assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem());
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Template"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)");
assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation(); assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation();
assertEquals(defaultTemplate.getSize().getCores(), 1.0d); assertEquals(defaultTemplate.getSize().getCores(), 1.0d);
} }

View File

@ -34,6 +34,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.jclouds.predicates.validators.DnsNameValidator; import org.jclouds.predicates.validators.DnsNameValidator;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
@ -53,6 +54,7 @@ import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.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.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
@ -62,6 +64,7 @@ import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.VAppHandler; import org.jclouds.vcloud.xml.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;
@ -84,6 +87,16 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate); ListenableFuture<? extends VAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
/**
* @see VCloudClient#getOvfEnvelopeForVAppTemplate
*/
@GET
@Consumes(MediaType.TEXT_XML)
@Path("/ovf")
@XMLResponseParser(OvfEnvelopeHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends OvfEnvelope> getOvfEnvelopeForVAppTemplate(@EndpointParam URI vAppTemplate);
/** /**
* @see VCloudClient#findVAppTemplateInOrgCatalogNamed * @see VCloudClient#findVAppTemplateInOrgCatalogNamed
*/ */

View File

@ -30,6 +30,7 @@ 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.CloneVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
@ -49,6 +50,8 @@ public interface VCloudClient extends CommonVCloudClient {
VAppTemplate getVAppTemplate(URI vAppTemplate); VAppTemplate getVAppTemplate(URI vAppTemplate);
OvfEnvelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate);
/** /**
* returns the vapp template corresponding to a catalog item in the catalog associated with the * returns the vapp template corresponding to a catalog item in the catalog associated with the
* specified name. Note that the org and catalog parameters can be null to choose default. * specified name. Note that the org and catalog parameters can be null to choose default.

View File

@ -45,7 +45,7 @@ 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.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;

View File

@ -31,12 +31,12 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VCloudHardDisk;
import org.jclouds.vcloud.domain.VCloudNetworkAdapter;
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.VCloudHardDisk;
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;

View File

@ -32,9 +32,9 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl; import org.jclouds.vcloud.compute.internal.VCloudExpressComputeClientImpl;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.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;

View File

@ -20,18 +20,19 @@
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.compute.util.ComputeServiceUtils.parseOsFamilyOrNull; import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
import javax.inject.Inject; import javax.inject.Inject;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy; import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.domain.VCloudImage; import org.jclouds.vcloud.compute.domain.VCloudImage;
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;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -40,13 +41,15 @@ import com.google.common.collect.ImmutableMap;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ImageForVAppTemplate implements Function<VAppTemplate, Image> { public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
private final VCloudClient client;
private final FindLocationForResource findLocationForResource; private final FindLocationForResource findLocationForResource;
private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider; private final PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider;
private ReferenceType parent; private ReferenceType parent;
@Inject @Inject
protected ImageForVAppTemplate(FindLocationForResource findLocationForResource, protected ImageForVAppTemplate(VCloudClient client, FindLocationForResource findLocationForResource,
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) { PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider) {
this.client = checkNotNull(client, "client");
this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource"); this.findLocationForResource = checkNotNull(findLocationForResource, "findLocationForResource");
this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider"); this.credentialsProvider = checkNotNull(credentialsProvider, "credentialsProvider");
} }
@ -58,19 +61,15 @@ public class ImageForVAppTemplate implements Function<VAppTemplate, Image> {
@Override @Override
public Image apply(VAppTemplate from) { public Image apply(VAppTemplate from) {
OsFamily osFamily = parseOsFamilyOrNull(checkNotNull(from, "vapp template").getName());
String osName = null; OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref());
String osArch = null; OperatingSystem os = toComputeOs(ovf);
String osVersion = null;
String osDescription = from.getName();
boolean is64Bit = from.getName().indexOf("64") != -1;
OperatingSystem os = new OperatingSystem(osFamily, osName, osVersion, osArch, osDescription, is64Bit);
Location location = findLocationForResource.apply(checkNotNull(parent, "parent")); Location location = findLocationForResource.apply(checkNotNull(parent, "parent"));
String name = getName(from.getName()); String name = getName(from.getName());
String desc = from.getDescription() != null ? from.getDescription() : from.getName(); String desc = from.getDescription() != null ? from.getDescription() : from.getName();
return new VCloudImage(from, from.getHref().toASCIIString(), name, from.getHref().toASCIIString(), location, from return new VCloudImage(from, from.getHref().toASCIIString(), name, from.getHref().toASCIIString(), location, from
.getHref(), ImmutableMap.<String, String> of(), os, desc, "", credentialsProvider.execute(from)); .getHref(), ImmutableMap.<String, String> of(), os, desc, "", credentialsProvider.execute(from));
} }
protected String getName(String name) { protected String getName(String name) {

View File

@ -33,15 +33,15 @@ import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.Task; 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.VCloudNetworkAdapter;
import org.jclouds.vcloud.domain.VDC; import org.jclouds.vcloud.domain.VDC;
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.VCloudNetworkAdapter;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.compute.strategy; package org.jclouds.vcloud.compute.strategy;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import java.net.URI; import java.net.URI;
@ -29,10 +30,8 @@ import javax.inject.Singleton;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.strategy.AddNodeWithTagStrategy; import org.jclouds.compute.strategy.AddNodeWithTagStrategy;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
@ -73,20 +72,12 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
} }
protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) { protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) {
return new NodeMetadataImpl(vApp.getHref().toASCIIString(), vApp.getName(), vApp.getHref().toASCIIString(), template return new NodeMetadataImpl(vApp.getHref().toASCIIString(), vApp.getName(), vApp.getHref().toASCIIString(),
.getLocation(), vApp.getHref(), ImmutableMap.<String, String> of(), tag, template.getImage().getId(), template.getLocation(), vApp.getHref(), ImmutableMap.<String, String> of(), tag, template.getImage()
getOperatingSystemForVAppOrDefaultTo(vApp, template.getImage().getOperatingSystem()), .getId(), toComputeOs(vApp, template.getImage().getOperatingSystem()), vAppStatusToNodeState
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getHref()), .get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getHref()), computeClient
computeClient.getPrivateAddresses(vApp.getHref()), ImmutableMap.<String, String> of(), new Credentials( .getPrivateAddresses(vApp.getHref()), ImmutableMap.<String, String> of(), new Credentials(
metaMap.get("username"), metaMap.get("password"))); metaMap.get("username"), metaMap.get("password")));
} }
private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) {
// TODO
return new CIMOperatingSystem(CIMOperatingSystem.OSType.UBUNTU_64, null, null, vApp.getDescription());
// return vApp.getOsType() != null ? new
// CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(vApp.getOsType()),
// null, null, vApp.getOperatingSystemDescription()) : operatingSystem;
}
} }

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.compute.strategy;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName; import static org.jclouds.compute.util.ComputeServiceUtils.parseTagFromName;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.toComputeOs;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
@ -34,9 +35,7 @@ import javax.inject.Singleton;
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.NodeState; import org.jclouds.compute.domain.NodeState;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.internal.NodeMetadataImpl; import org.jclouds.compute.domain.internal.NodeMetadataImpl;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
@ -47,11 +46,9 @@ import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.GetExtraFromVApp; import org.jclouds.vcloud.compute.functions.GetExtraFromVApp;
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.domain.Vm;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -88,17 +85,8 @@ public class VCloudGetNodeMetadataStrategy implements GetNodeMetadataStrategy {
String tag = parseTagFromName(from.getName()); String tag = parseTagFromName(from.getName());
Location location = findLocationForResourceInVDC.apply(from.getVDC()); Location location = findLocationForResourceInVDC.apply(from.getVDC());
return new NodeMetadataImpl(in, from.getName(), in, location, from.getHref(), ImmutableMap.<String, String> of(), return new NodeMetadataImpl(in, from.getName(), in, location, from.getHref(), ImmutableMap.<String, String> of(),
tag, null, getOperatingSystemForVAppOrDefaultTo(from, null), tag, null, toComputeOs(from, null), vAppStatusToNodeState.get(from.getStatus()), computeClient
vAppStatusToNodeState.get(from.getStatus()), computeClient.getPublicAddresses(id), computeClient .getPublicAddresses(id), computeClient.getPrivateAddresses(id), getExtra.apply(from), null);
.getPrivateAddresses(id), getExtra.apply(from), null);
}
private OperatingSystem getOperatingSystemForVAppOrDefaultTo(VApp vApp, OperatingSystem operatingSystem) {
// TODO we need to change the design so that it doesn't assume single-vms
Vm vm = Iterables.get(vApp.getChildren(), 0);
return vm.getOperatingSystem() != null && vm.getOperatingSystem().getId() != null ? new CIMOperatingSystem(
CIMOperatingSystem.OSType.fromValue(vm.getOperatingSystem().getId()), null, null, vm
.getOperatingSystem().getDescription()) : operatingSystem;
} }
} }

View File

@ -0,0 +1,57 @@
/**
*
* 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.util;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.os.CIMOperatingSystem;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.Vm;
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
import com.google.common.collect.Iterables;
/**
*
* @author Adrian Cole
*/
public class VCloudComputeUtils {
public static OperatingSystem toComputeOs(VApp vApp, OperatingSystem defaultOs) {
CIMOperatingSystem cimOs = toComputeOs(vApp);
return cimOs != null ? cimOs : defaultOs;
}
public static CIMOperatingSystem toComputeOs(VApp vApp) {
// TODO we need to change the design so that it doesn't assume single-vms
return toComputeOs(Iterables.get(vApp.getChildren(), 0));
}
public static CIMOperatingSystem toComputeOs(OvfEnvelope ovf) {
return toComputeOs(ovf.getVirtualSystem().getOperatingSystem());
}
public static CIMOperatingSystem toComputeOs(Vm vm) {
return toComputeOs(vm.getOperatingSystem());
}
public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystem os) {
return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), null, null, os.getDescription());
}
}

View File

@ -24,6 +24,8 @@ import java.util.Set;
import javax.annotation.Nullable; import javax.annotation.Nullable;
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;
@ -60,7 +62,7 @@ public interface VCloudExpressVApp extends ReferenceType {
@Nullable @Nullable
String getOperatingSystemDescription(); String getOperatingSystemDescription();
VirtualSystem getSystem(); System getSystem();
Set<ResourceAllocation> getResourceAllocations(); Set<ResourceAllocation> getResourceAllocations();

View File

@ -0,0 +1,85 @@
/**
*
* 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;
import java.net.URI;
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ovf.System;
/**
* A description of the virtual hardware supported by a virtual machine.
*/
public class VCloudVirtualHardware extends VirtualHardware {
protected final String type;
protected final URI href;
public VCloudVirtualHardware(String type, URI href, String info, System virtualSystem,
Iterable<? extends ResourceAllocation> resourceAllocations) {
super(info, virtualSystem, resourceAllocations);
this.type = type;
this.href = href;
}
public String getType() {
return type;
}
public URI getHref() {
return href;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((href == null) ? 0 : href.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
VCloudVirtualHardware other = (VCloudVirtualHardware) obj;
if (href == null) {
if (other.href != null)
return false;
} else if (!href.equals(other.href))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
@Override
public String toString() {
return "[href=" + getHref() + ", type=" + getType() + ", info=" + getInfo() + ", virtualSystem=" + getSystem()
+ "]";
}
}

View File

@ -19,10 +19,10 @@
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Set; import java.util.Set;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ovf.System;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -30,14 +30,13 @@ import com.google.common.collect.Sets;
/** /**
* A description of the virtual hardware supported by a virtual machine. * A description of the virtual hardware supported by a virtual machine.
*/ */
public class VirtualHardware extends ReferenceTypeImpl { public class VirtualHardware {
private final String info;
private final VirtualSystem virtualSystem;
private final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
public VirtualHardware(String name, String type, URI href, String info, VirtualSystem virtualSystem, protected final String info;
Iterable<? extends ResourceAllocation> resourceAllocations) { protected final System virtualSystem;
super(name, type, href); protected final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
public VirtualHardware(String info, System virtualSystem, Iterable<? extends ResourceAllocation> resourceAllocations) {
this.info = info; this.info = info;
this.virtualSystem = virtualSystem; this.virtualSystem = virtualSystem;
Iterables.addAll(this.resourceAllocations, resourceAllocations); Iterables.addAll(this.resourceAllocations, resourceAllocations);
@ -47,7 +46,7 @@ public class VirtualHardware extends ReferenceTypeImpl {
return info; return info;
} }
public VirtualSystem getSystem() { public System getSystem() {
return virtualSystem; return virtualSystem;
} }
@ -57,7 +56,44 @@ public class VirtualHardware extends ReferenceTypeImpl {
@Override @Override
public String toString() { public String toString() {
return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", info=" + getInfo() return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]";
+ ", virtualSystem=" + getSystem() + "]";
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((info == null) ? 0 : info.hashCode());
result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
VirtualHardware other = (VirtualHardware) obj;
if (info == null) {
if (other.info != null)
return false;
} else if (!info.equals(other.info))
return false;
if (resourceAllocations == null) {
if (other.resourceAllocations != null)
return false;
} else if (!resourceAllocations.equals(other.resourceAllocations))
return false;
if (virtualSystem == null) {
if (other.virtualSystem != null)
return false;
} else if (!virtualSystem.equals(other.virtualSystem))
return false;
return true;
}
} }

View File

@ -24,6 +24,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.internal.VmImpl; import org.jclouds.vcloud.domain.internal.VmImpl;
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -74,7 +75,7 @@ public interface Vm extends ReferenceType {
* @since vcloud api 1.0 * @since vcloud api 1.0
*/ */
@Nullable @Nullable
VirtualHardware getHardware(); VCloudVirtualHardware getHardware();
/** /**
* @return operating system on this VM, or null, if part of a vApp template * @return operating system on this VM, or null, if part of a vApp template
@ -82,7 +83,7 @@ public interface Vm extends ReferenceType {
* @since vcloud api 1.0 * @since vcloud api 1.0
*/ */
@Nullable @Nullable
OperatingSystem getOperatingSystem(); VCloudOperatingSystem getOperatingSystem();
/** /**
* read-only identifier created on import * read-only identifier created on import

View File

@ -26,10 +26,10 @@ import java.util.Set;
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.ResourceAllocation;
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.VirtualSystem; 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,7 +46,7 @@ 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 VirtualSystem system; private final System system;
private final Set<ResourceAllocation> resourceAllocations; private final Set<ResourceAllocation> resourceAllocations;
private final Integer osType; private final Integer osType;
@ -55,7 +55,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp {
public VCloudExpressVAppImpl(String name, URI href, Status status, Long size, ReferenceType vDC, 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,
VirtualSystem system, Set<ResourceAllocation> resourceAllocations) { System system, Set<ResourceAllocation> 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,7 +89,7 @@ public class VCloudExpressVAppImpl implements VCloudExpressVApp {
} }
@Override @Override
public VirtualSystem getSystem() { public System getSystem() {
return system; return system;
} }

View File

@ -26,12 +26,12 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.OperatingSystem;
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;
import org.jclouds.vcloud.domain.VirtualHardware; import org.jclouds.vcloud.domain.VCloudVirtualHardware;
import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.Vm;
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -51,13 +51,13 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
private final String description; private final String description;
private final List<Task> tasks = Lists.newArrayList(); private final List<Task> tasks = Lists.newArrayList();
@Nullable @Nullable
private final VirtualHardware hardware; private final VCloudVirtualHardware hardware;
private final String vAppScopedLocalId; private final String vAppScopedLocalId;
private final OperatingSystem os; private final VCloudOperatingSystem os;
public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp, public VmImpl(String name, String type, URI id, @Nullable Status status, ReferenceType vApp,
@Nullable String description, Iterable<Task> tasks, @Nullable VirtualHardware hardware, @Nullable String description, Iterable<Task> tasks, @Nullable VCloudVirtualHardware hardware,
@Nullable OperatingSystem os, @Nullable String vAppScopedLocalId) { @Nullable VCloudOperatingSystem os, @Nullable String vAppScopedLocalId) {
super(name, type, id); super(name, type, id);
this.status = status; this.status = status;
this.vApp = vApp;// TODO: once <1.0 is killed check not null this.vApp = vApp;// TODO: once <1.0 is killed check not null
@ -105,7 +105,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public VirtualHardware getHardware() { public VCloudVirtualHardware getHardware() {
return hardware; return hardware;
} }
@ -113,7 +113,7 @@ public class VmImpl extends ReferenceTypeImpl implements Vm {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public OperatingSystem getOperatingSystem() { public VCloudOperatingSystem getOperatingSystem() {
return os; return os;
} }

View File

@ -17,7 +17,9 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
import org.jclouds.vcloud.domain.ReferenceType;
/** /**
* @author Adrian Cole * @author Adrian Cole

View File

@ -17,39 +17,24 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; public class OperatingSystem {
/**
* A description of the operating system supported by a virtual machine.
*/
public class OperatingSystem extends ReferenceTypeImpl {
@Nullable @Nullable
private final Integer id; protected final Integer id;
@Nullable @Nullable
private final String info; protected final String info;
@Nullable
private final String vmwOsType;
@Nullable
private final String description;
private final ReferenceType edit;
public OperatingSystem(@Nullable String name, String type, URI href, @Nullable Integer id, @Nullable String info, @Nullable
@Nullable String vmwOsType, @Nullable String description, ReferenceType edit) { protected final String description;
super(name, type, href);
public OperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description) {
this.id = id; this.id = id;
this.info = info; this.info = info;
this.vmwOsType = vmwOsType;
this.description = description; this.description = description;
this.edit = checkNotNull(edit, "edit");
} }
/** /**
@ -68,14 +53,6 @@ public class OperatingSystem extends ReferenceTypeImpl {
return info; return info;
} }
/**
*
* @return VMware osType, if running on VMware
*/
public String getVmwOsType() {
return vmwOsType;
}
/** /**
* *
* @return description or null * @return description or null
@ -84,23 +61,13 @@ public class OperatingSystem extends ReferenceTypeImpl {
return description; return description;
} }
/**
*
* @return edit link
*/
public ReferenceType getEdit() {
return edit;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = super.hashCode(); int result = 1;
result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((edit == null) ? 0 : edit.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode()); result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((info == null) ? 0 : info.hashCode()); result = prime * result + ((info == null) ? 0 : info.hashCode());
result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.hashCode());
return result; return result;
} }
@ -108,7 +75,7 @@ public class OperatingSystem extends ReferenceTypeImpl {
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
return true; return true;
if (!super.equals(obj)) if (obj == null)
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
@ -118,11 +85,6 @@ public class OperatingSystem extends ReferenceTypeImpl {
return false; return false;
} else if (!description.equals(other.description)) } else if (!description.equals(other.description))
return false; return false;
if (edit == null) {
if (other.edit != null)
return false;
} else if (!edit.equals(other.edit))
return false;
if (id == null) { if (id == null) {
if (other.id != null) if (other.id != null)
return false; return false;
@ -133,17 +95,12 @@ public class OperatingSystem extends ReferenceTypeImpl {
return false; return false;
} else if (!info.equals(other.info)) } else if (!info.equals(other.info))
return false; return false;
if (vmwOsType == null) {
if (other.vmwOsType != null)
return false;
} else if (!vmwOsType.equals(other.vmwOsType))
return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" return "[id=" + getId() + ", info=" + getInfo() + ", description=" + getDescription() + "]";
+ getVmwOsType() + ", description=" + getDescription() + "]";
} }
} }

View File

@ -0,0 +1,69 @@
/**
*
* 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 OvfEnvelope {
private final VirtualSystem virtualSystem;
public OvfEnvelope(VirtualSystem virtualSystem) {
this.virtualSystem = checkNotNull(virtualSystem, "virtualSystem");
}
public VirtualSystem getVirtualSystem() {
return virtualSystem;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
OvfEnvelope other = (OvfEnvelope) obj;
if (virtualSystem == null) {
if (other.virtualSystem != null)
return false;
} else if (!virtualSystem.equals(other.virtualSystem))
return false;
return true;
}
@Override
public String toString() {
return "[virtualSystem=" + virtualSystem + "]";
}
}

View File

@ -17,7 +17,7 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -17,7 +17,7 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -17,17 +17,17 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class VirtualSystem { public class System {
protected final int id; protected final int id;
protected final String name; protected final String name;
protected final String identifier; protected final String identifier;
protected final String type; protected final String type;
public VirtualSystem(int id, String name, String identifier, String type) { public System(int id, String name, String identifier, String type) {
this.id = id; this.id = id;
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.identifier = checkNotNull(identifier, "identifier"); this.identifier = checkNotNull(identifier, "identifier");
@ -69,7 +69,7 @@ public class VirtualSystem {
return false; return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
VirtualSystem other = (VirtualSystem) obj; System other = (System) obj;
if (id != other.id) if (id != other.id)
return false; return false;
if (identifier == null) { if (identifier == null) {

View File

@ -17,7 +17,8 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
/** /**
* @author Adrian Cole * @author Adrian Cole

View File

@ -17,7 +17,7 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.domain; package org.jclouds.vcloud.domain.ovf;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -88,9 +88,8 @@ public class VCloudNetworkAdapter extends ResourceAllocation {
@Override @Override
public String toString() { public String toString() {
return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType() return "[id=" + getId() + ", name=" + getName() + ", description=" + getDescription() + ", type=" + getType()
+ ", virtualQuantity=" + getVirtualQuantity() + ", virtualQuantityUnits=" + getVirtualQuantityUnits() + ", address=" + getAddress() + ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode
+ ", ipAddress=" + ipAddress + ", ipAddressingMode=" + ipAddressingMode + ", primaryNetworkConnection=" + ", primaryNetworkConnection=" + primaryNetworkConnection + "]";
+ primaryNetworkConnection + "]";
} }
} }

View File

@ -0,0 +1,121 @@
/**
*
* 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.net.URI;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.ReferenceType;
/**
* A description of the operating system supported by a virtual machine.
*/
public class VCloudOperatingSystem extends OperatingSystem {
protected final String type;
protected final URI href;
@Nullable
protected final String vmwOsType;
protected final ReferenceType edit;
public VCloudOperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description, String type,
URI href, @Nullable String vmwOsType, ReferenceType edit) {
super(id, info, description);
this.type = type;
this.href = href;
this.vmwOsType = vmwOsType;
this.edit = checkNotNull(edit, "edit");
}
public String getType() {
return type;
}
public URI getHref() {
return href;
}
/**
*
* @return VMware osType, if running on VMware
*/
public String getVmwOsType() {
return vmwOsType;
}
/**
*
* @return edit link
*/
public ReferenceType getEdit() {
return edit;
}
@Override
public String toString() {
return "[href=" + getHref() + ", type=" + getType() + ", id=" + getId() + ", vmwOsType=" + getVmwOsType()
+ ", description=" + getDescription() + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((edit == null) ? 0 : edit.hashCode());
result = prime * result + ((href == null) ? 0 : href.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((vmwOsType == null) ? 0 : vmwOsType.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
VCloudOperatingSystem other = (VCloudOperatingSystem) obj;
if (edit == null) {
if (other.edit != null)
return false;
} else if (!edit.equals(other.edit))
return false;
if (href == null) {
if (other.href != null)
return false;
} else if (!href.equals(other.href))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
if (vmwOsType == null) {
if (other.vmwOsType != null)
return false;
} else if (!vmwOsType.equals(other.vmwOsType))
return false;
return true;
}
}

View File

@ -0,0 +1,118 @@
/**
*
* 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 org.jclouds.vcloud.domain.VirtualHardware;
/**
* @author Adrian Cole
*/
public class VirtualSystem {
private final String id;
private final String info;
private final String name;
private final OperatingSystem operatingSystem;
private final VirtualHardware hardware;
public VirtualSystem(String id, String info, String name, OperatingSystem operatingSystem, VirtualHardware hardware) {
this.id = id;
this.info = info;
this.name = name;
this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
this.hardware = checkNotNull(hardware, "hardware");
}
public String getId() {
return id;
}
public String getInfo() {
return info;
}
public String getName() {
return name;
}
public OperatingSystem getOperatingSystem() {
return operatingSystem;
}
public VirtualHardware getHardware() {
return hardware;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((info == null) ? 0 : info.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
VirtualSystem other = (VirtualSystem) obj;
if (hardware == null) {
if (other.hardware != null)
return false;
} else if (!hardware.equals(other.hardware))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (info == null) {
if (other.info != null)
return false;
} else if (!info.equals(other.info))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (operatingSystem == null) {
if (other.operatingSystem != null)
return false;
} else if (!operatingSystem.equals(other.operatingSystem))
return false;
return true;
}
@Override
public String toString() {
return "[id=" + getId() + ", name=" + getName() + ", info=" + getInfo() + ", os=" + getOperatingSystem()
+ ", hardware=" + getHardware() + "]";
}
}

View File

@ -21,8 +21,8 @@ package org.jclouds.vcloud.predicates;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;

View File

@ -35,6 +35,7 @@ import com.google.common.collect.Maps;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class Utils { public class Utils {
public static ReferenceType newReferenceType(Map<String, String> attributes, String defaultType) { public static ReferenceType newReferenceType(Map<String, String> attributes, String defaultType) {
String uri = attributes.get("href"); String uri = attributes.get("href");
String type = attributes.get("type"); String type = attributes.get("type");

View File

@ -35,11 +35,13 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
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.ResourceAllocation;
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.VirtualSystem;
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;
@ -52,20 +54,20 @@ 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 VirtualSystemHandler systemHandler; private final SystemHandler systemHandler;
private final ResourceAllocationHandler allocationHandler; private final ResourceAllocationHandler allocationHandler;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, VirtualSystemHandler systemHandler, public VCloudExpressVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler,
ResourceAllocationHandler allocationHandler) { ResourceAllocationHandler allocationHandler) {
this.apiVersion = apiVersion; this.apiVersion = apiVersion;
this.systemHandler = systemHandler; this.systemHandler = systemHandler;
this.allocationHandler = allocationHandler; this.allocationHandler = allocationHandler;
} }
protected VirtualSystem system; protected System system;
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet(); protected Set<ResourceAllocation> 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();

View File

@ -0,0 +1,74 @@
/**
*
* 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;
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
import static org.jclouds.vcloud.util.Utils.newReferenceType;
import java.util.Map;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VCloudVirtualHardware;
import org.jclouds.vcloud.domain.VirtualHardware;
import org.xml.sax.Attributes;
/**
* @author Adrian Cole
*/
public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardware> {
private final VirtualHardwareHandler hardwareHandler;
private ReferenceType hardware;
@Inject
public VCloudVirtualHardwareHandler(VirtualHardwareHandler hardwareHandler) {
this.hardwareHandler = hardwareHandler;
}
public VCloudVirtualHardware getResult() {
VirtualHardware hardware = hardwareHandler.getResult();
return new VCloudVirtualHardware(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware
.getSystem(), hardware.getResourceAllocations());
}
public void startElement(String uri, String localName, String qName, Attributes attrs) {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("VirtualHardwareSection")) {
hardware = newReferenceType(attributes);
}
hardwareHandler.startElement(uri, localName, qName, attrs);
}
@Override
public void endElement(String uri, String localName, String qName) {
hardwareHandler.endElement(uri, localName, qName);
}
@Override
public void characters(char ch[], int start, int length) {
hardwareHandler.characters(ch, start, length);
}
}

View File

@ -19,19 +19,16 @@
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 java.util.Map;
import java.util.Set; 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.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.VirtualHardware; import org.jclouds.vcloud.domain.VirtualHardware;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ovf.System;
import org.jclouds.vcloud.xml.ovf.SystemHandler;
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationHandler;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -42,33 +39,27 @@ import com.google.common.collect.Sets;
public class VirtualHardwareHandler extends ParseSax.HandlerWithResult<VirtualHardware> { public class VirtualHardwareHandler extends ParseSax.HandlerWithResult<VirtualHardware> {
protected StringBuilder currentText = new StringBuilder(); protected StringBuilder currentText = new StringBuilder();
private final VirtualSystemHandler systemHandler; private final SystemHandler systemHandler;
private final VCloudResourceAllocationHandler allocationHandler; private final VCloudResourceAllocationHandler allocationHandler;
@Inject @Inject
public VirtualHardwareHandler(VirtualSystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) { public VirtualHardwareHandler(SystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) {
this.systemHandler = systemHandler; this.systemHandler = systemHandler;
this.allocationHandler = allocationHandler; this.allocationHandler = allocationHandler;
} }
private ReferenceType hardware;
private String info; private String info;
protected VirtualSystem system; protected System system;
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet(); protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
private boolean inItem; private boolean inItem;
private boolean inSystem; private boolean inSystem;
public VirtualHardware getResult() { public VirtualHardware getResult() {
return new VirtualHardware(hardware.getName(), hardware.getType(), hardware.getHref(), info, system, allocations); return new VirtualHardware(info, system, allocations);
} }
public void startElement(String uri, String localName, String qName, Attributes attrs) { public void startElement(String uri, String localName, String qName, Attributes attrs) {
Map<String, String> attributes = cleanseAttributes(attrs);
if (attributes.containsKey("href") && attributes.get("href").endsWith("/")) {
String href = attributes.get("href");
attributes.put("href", href.substring(0, href.lastIndexOf('/')));
}
if (qName.endsWith("System")) { if (qName.endsWith("System")) {
inSystem = true; inSystem = true;
} else if (!inSystem && qName.endsWith("Item")) { } else if (!inSystem && qName.endsWith("Item")) {
@ -78,10 +69,7 @@ public class VirtualHardwareHandler extends ParseSax.HandlerWithResult<VirtualHa
systemHandler.startElement(uri, localName, qName, attrs); systemHandler.startElement(uri, localName, qName, attrs);
} else if (inItem) { } else if (inItem) {
allocationHandler.startElement(uri, localName, qName, attrs); allocationHandler.startElement(uri, localName, qName, attrs);
} else if (qName.endsWith("VirtualHardwareSection")) {
hardware = newReferenceType(attributes);
} }
} }
@Override @Override

View File

@ -28,13 +28,14 @@ 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.vcloud.domain.OperatingSystem;
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;
import org.jclouds.vcloud.domain.VirtualHardware; import org.jclouds.vcloud.domain.VCloudVirtualHardware;
import org.jclouds.vcloud.domain.Vm; import org.jclouds.vcloud.domain.Vm;
import org.jclouds.vcloud.domain.internal.VmImpl; import org.jclouds.vcloud.domain.internal.VmImpl;
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -46,12 +47,12 @@ import com.google.common.collect.Lists;
public class VmHandler extends ParseSax.HandlerWithResult<Vm> { public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
protected final TaskHandler taskHandler; protected final TaskHandler taskHandler;
protected final VirtualHardwareHandler virtualHardwareHandler; protected final VCloudVirtualHardwareHandler virtualHardwareHandler;
protected final OperatingSystemHandler operatingSystemHandler; protected final VCloudOperatingSystemHandler operatingSystemHandler;
@Inject @Inject
public VmHandler(TaskHandler taskHandler, VirtualHardwareHandler virtualHardwareHandler, public VmHandler(TaskHandler taskHandler, VCloudVirtualHardwareHandler virtualHardwareHandler,
OperatingSystemHandler operatingSystemHandler) { VCloudOperatingSystemHandler operatingSystemHandler) {
this.taskHandler = taskHandler; this.taskHandler = taskHandler;
this.virtualHardwareHandler = virtualHardwareHandler; this.virtualHardwareHandler = virtualHardwareHandler;
this.operatingSystemHandler = operatingSystemHandler; this.operatingSystemHandler = operatingSystemHandler;
@ -64,8 +65,8 @@ public class VmHandler extends ParseSax.HandlerWithResult<Vm> {
protected ReferenceType vdc; protected ReferenceType vdc;
protected String description; protected String description;
protected List<Task> tasks = Lists.newArrayList(); protected List<Task> tasks = Lists.newArrayList();
protected VirtualHardware hardware; protected VCloudVirtualHardware hardware;
protected OperatingSystem os; protected VCloudOperatingSystem os;
protected String vAppScopedLocalId; protected String vAppScopedLocalId;
private boolean inTasks; private boolean inTasks;

View File

@ -0,0 +1,69 @@
/**
*
* 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.OperatingSystem;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
/**
* @author Adrian Cole
*/
public class OperatingSystemHandler extends ParseSax.HandlerWithResult<OperatingSystem> {
private StringBuilder currentText = new StringBuilder();
protected Integer id;
protected String info;
protected String description;
public OperatingSystem getResult() {
OperatingSystem system = new OperatingSystem(id, info, description);
id = null;
info = null;
description = null;
return system;
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) {
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
if (qName.endsWith("OperatingSystemSection")) {
if (attributes.containsKey("id"))
this.id = Integer.parseInt(attributes.get("id"));
}
}
@Override
public void endElement(String uri, String localName, String qName) {
if (qName.endsWith("Info")) {
this.info = currentText.toString().trim();
} else if (qName.endsWith("Description")) {
this.description = currentText.toString().trim();
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
currentText.append(ch, start, length);
}
}

View File

@ -0,0 +1,87 @@
/**
*
* 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.vdc/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.vcloud.xml.ovf;
//import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* @author Adrian Cole
*/
public class OvfEnvelopeHandler extends ParseSax.HandlerWithResult<OvfEnvelope> {
protected final VirtualSystemHandler virtualSystemHandler;
@Inject
public OvfEnvelopeHandler(VirtualSystemHandler virtualSystemHandler) {
this.virtualSystemHandler = virtualSystemHandler;
}
protected StringBuilder currentText = new StringBuilder();
private VirtualSystem virtualSystem;
private boolean inVirtualSystem;
public OvfEnvelope getResult() {
return new OvfEnvelope(virtualSystem);
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
// Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("VirtualSystem")) {
inVirtualSystem = true;
}
if (inVirtualSystem) {
virtualSystemHandler.startElement(uri, localName, qName, attrs);
}
}
public void endElement(String uri, String name, String qName) {
if (qName.endsWith("VirtualSystem")) {
inVirtualSystem = false;
virtualSystem = virtualSystemHandler.getResult();
}
if (inVirtualSystem) {
virtualSystemHandler.endElement(uri, name, qName);
}
currentText = new StringBuilder();
}
public void characters(char ch[], int start, int length) {
if (inVirtualSystem)
virtualSystemHandler.characters(ch, start, length);
else
currentText.append(ch, start, length);
}
protected String currentOrNull() {
String returnVal = currentText.toString().trim();
return returnVal.equals("") ? null : returnVal;
}
}

View File

@ -17,11 +17,11 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
/** /**
@ -45,7 +45,7 @@ public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<Resour
protected long virtualQuantity = 1; protected long virtualQuantity = 1;
protected String virtualQuantityUnits; protected String virtualQuantityUnits;
public org.jclouds.vcloud.domain.ResourceAllocation getResult() { public org.jclouds.vcloud.domain.ovf.ResourceAllocation getResult() {
if (allocationUnits != null) if (allocationUnits != null)
virtualQuantityUnits = allocationUnits; virtualQuantityUnits = allocationUnits;
ResourceAllocation allocation = newResourceAllocation(); ResourceAllocation allocation = newResourceAllocation();

View File

@ -17,16 +17,16 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.ovf.System;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSystem> { public class SystemHandler extends ParseSax.HandlerWithResult<System> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private String elementName; private String elementName;
@ -34,9 +34,9 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSyst
private String virtualSystemIdentifier; private String virtualSystemIdentifier;
private String virtualSystemType; private String virtualSystemType;
public VirtualSystem getResult() { public System getResult() {
VirtualSystem system = new org.jclouds.vcloud.domain.VirtualSystem(instanceID, elementName, System system = new org.jclouds.vcloud.domain.ovf.System(instanceID, elementName, virtualSystemIdentifier,
virtualSystemIdentifier, virtualSystemType); virtualSystemType);
this.elementName = null; this.elementName = null;
this.instanceID = -1; this.instanceID = -1;
this.virtualSystemIdentifier = null; this.virtualSystemIdentifier = null;

View File

@ -17,22 +17,22 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
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.vcloud.domain.OperatingSystem;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
import org.jclouds.vcloud.util.Utils; import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class OperatingSystemHandler extends ParseSax.HandlerWithResult<OperatingSystem> { public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult<VCloudOperatingSystem> {
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
protected ReferenceType os; protected ReferenceType os;
@ -42,9 +42,9 @@ public class OperatingSystemHandler extends ParseSax.HandlerWithResult<Operating
protected String description; protected String description;
protected ReferenceType edit; protected ReferenceType edit;
public OperatingSystem getResult() { public VCloudOperatingSystem getResult() {
OperatingSystem system = new OperatingSystem(os.getName(), os.getType(), os.getHref(), id, info, vmwOsType, VCloudOperatingSystem system = new VCloudOperatingSystem(id, info, description, os.getType(), os.getHref(),
description, edit); vmwOsType, edit);
os = null; os = null;
id = null; id = null;
info = null; info = null;
@ -60,10 +60,6 @@ public class OperatingSystemHandler extends ParseSax.HandlerWithResult<Operating
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")) {
if (attributes.containsKey("href") && attributes.get("href").endsWith("/")) {
String href = attributes.get("href");
attributes.put("href", href.substring(0, href.lastIndexOf('/')));
}
os = newReferenceType(attributes); os = newReferenceType(attributes);
vmwOsType = attributes.get("osType"); vmwOsType = attributes.get("osType");
if (attributes.containsKey("id")) if (attributes.containsKey("id"))

View File

@ -17,15 +17,15 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import java.util.Map; import java.util.Map;
import org.jclouds.vcloud.domain.EditableResourceAllocation;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation;
import org.jclouds.vcloud.domain.VCloudHardDisk; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.VCloudNetworkAdapter; import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
import org.jclouds.vcloud.util.Utils; import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;

View File

@ -0,0 +1,138 @@
/**
*
* 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.jclouds.vcloud.util.Utils.cleanseAttributes;
import java.util.Map;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.VirtualHardware;
import org.jclouds.vcloud.domain.ovf.OperatingSystem;
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
import org.jclouds.vcloud.xml.VirtualHardwareHandler;
import org.xml.sax.Attributes;
/**
* @author Adrian Cole
*/
public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSystem> {
protected StringBuilder currentText = new StringBuilder();
private final OperatingSystemHandler osHandler;
private final VirtualHardwareHandler hardwareHandler;
@Inject
public VirtualSystemHandler(OperatingSystemHandler osHandler, VirtualHardwareHandler hardwareHandler) {
this.osHandler = osHandler;
this.hardwareHandler = hardwareHandler;
}
protected String id;
protected String info;
protected String name;
protected OperatingSystem operatingSystem;
protected VirtualHardware hardware;
private boolean inHardware;
private boolean inOs;
private boolean inNetwork;
private boolean inGuest;
public VirtualSystem getResult() {
VirtualSystem vs = new VirtualSystem(id, info, name, operatingSystem, hardware);
id = null;
info = null;
name = null;
operatingSystem = null;
hardware = null;
return vs;
}
public void startElement(String uri, String localName, String qName, Attributes attrs) {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("VirtualHardwareSection")) {
inHardware = true;
} else if (qName.endsWith("OperatingSystemSection")) {
inOs = true;
} else if (qName.endsWith("NetworkConnectionSection")) {
inNetwork = true;
} else if (qName.endsWith("GuestCustomizationSection")) {
inGuest = true;
}
if (inHardware) {
hardwareHandler.startElement(uri, localName, qName, attrs);
} else if (inOs) {
osHandler.startElement(uri, localName, qName, attrs);
} else if (inNetwork) {
// TODO
} else if (inGuest) {
// TODO
} else if (qName.endsWith("VirtualSystem")) {
id = attributes.get("id");
}
}
@Override
public void endElement(String uri, String localName, String qName) {
if (qName.endsWith("VirtualHardwareSection")) {
inHardware = false;
hardware = hardwareHandler.getResult();
} else if (qName.endsWith("OperatingSystemSection")) {
inOs = false;
operatingSystem = osHandler.getResult();
} else if (qName.endsWith("NetworkConnectionSection")) {
inNetwork = false;
// TODO
} else if (qName.endsWith("GuestCustomizationSection")) {
inNetwork = false;
// TODO
}
if (inHardware) {
hardwareHandler.endElement(uri, localName, qName);
} else if (inOs) {
osHandler.endElement(uri, localName, qName);
} else if (inNetwork) {
// TODO
} else if (inGuest) {
// TODO
} else if (qName.endsWith("Info")) {
info = currentText.toString().trim();
} else if (qName.endsWith("Name")) {
name = currentText.toString().trim();
}
currentText = new StringBuilder();
}
@Override
public void characters(char ch[], int start, int length) {
if (inHardware)
hardwareHandler.characters(ch, start, length);
else if (inOs)
osHandler.characters(ch, start, length);
else
currentText.append(ch, start, length);
}
}

View File

@ -71,6 +71,7 @@ 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;
@ -327,6 +328,22 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
checkFilters(request); checkFilters(request);
} }
public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class);
HttpRequest request = processor.createRequest(method, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"));
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, OvfEnvelopeHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException { public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class); Method method = VCloudAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
HttpRequest request = processor.createRequest(method, "org", "vdc"); HttpRequest request = processor.createRequest(method, "org", "vdc");

View File

@ -67,6 +67,26 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest<VCloudClien
} }
} }
@Test
public void testGetOvfEnvelopeForVAppTemplate() throws Exception {
Org org = connection.findOrgNamed(null);
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getHref());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
try {
assertNotNull(connection.getOvfEnvelopeForVAppTemplate(item.getEntity().getHref()));
} catch (AuthorizationException e) {
}
}
}
}
}
}
@Test @Test
public void testGetVApp() throws Exception { public void testGetVApp() throws Exception {
Org org = connection.findOrgNamed(null); Org org = connection.findOrgNamed(null);

View File

@ -35,10 +35,10 @@ import org.jclouds.compute.domain.OsFamily;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.vcloud.VCloudExpressClient; import org.jclouds.vcloud.VCloudExpressClient;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate; import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.testng.annotations.AfterTest; import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;

View File

@ -31,13 +31,13 @@ import org.jclouds.Constants;
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;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
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.VirtualSystem;
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.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -90,7 +90,7 @@ 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");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "centos53", "vmx-07"); System system = new System(0, "Virtual Hardware Family", "centos53", "vmx-07");
Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1, Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
@ -125,7 +125,7 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
ListMultimap<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");
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "m1", "vmx-07"); System system = new System(0, "Virtual Hardware Family", "m1", "vmx-07");
Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1, Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, "1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,

View File

@ -26,41 +26,41 @@ import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.EditableResourceAllocation; import org.jclouds.vcloud.domain.VCloudVirtualHardware;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.VCloudHardDisk;
import org.jclouds.vcloud.domain.VCloudNetworkAdapter;
import org.jclouds.vcloud.domain.VirtualHardware;
import org.jclouds.vcloud.domain.VirtualSystem;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation;
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.domain.ovf.System;
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
/** /**
* Tests behavior of {@code VirtualHardwareHandler} * Tests behavior of {@code VCloudVirtualHardwareHandler}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloud.VirtualHardwareHandlerTest") @Test(groups = "unit", testName = "vcloud.VCloudVirtualHardwareHandlerTest")
public class VirtualHardwareHandlerTest extends BaseHandlerTest { public class VCloudVirtualHardwareHandlerTest extends BaseHandlerTest {
public void testDefault() throws UnknownHostException { public void testDefault() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml"); InputStream is = getClass().getResourceAsStream("/virtualhardwaresection.xml");
VirtualHardware result = factory.create(injector.getInstance(VirtualHardwareHandler.class)).parse(is); VCloudVirtualHardware result = factory.create(injector.getInstance(VCloudVirtualHardwareHandler.class)).parse(is);
checkHardware(result); checkHardware(result);
} }
static void checkHardware(VirtualHardware result) { @Test(enabled = false)
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "RHEL5", "vmx-07"); public static void checkHardware(VCloudVirtualHardware result) {
System system = new System(0, "Virtual Hardware Family", "RHEL5", "vmx-07");
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.getName(), null);
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(), system);
assertEquals(result.getInfo(), "Virtual hardware requirements"); assertEquals(result.getInfo(), "Virtual hardware requirements");

View File

@ -31,6 +31,7 @@ import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Status; 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.VCloudOperatingSystemHandlerTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -62,8 +63,8 @@ public class VmHandlerTest {
assertEquals(result.getDescription(), null); assertEquals(result.getDescription(), null);
assertEquals(result.getTasks(), ImmutableList.of()); assertEquals(result.getTasks(), ImmutableList.of());
assertEquals(result.getVAppScopedLocalId(), "10_rhel_template"); assertEquals(result.getVAppScopedLocalId(), "10_rhel_template");
VirtualHardwareHandlerTest.checkHardware(result.getHardware()); VCloudVirtualHardwareHandlerTest.checkHardware(result.getHardware());
OperatingSystemHandlerTest.checkOs(result.getOperatingSystem()); VCloudOperatingSystemHandlerTest.checkOs(result.getOperatingSystem());
} }
} }

View File

@ -0,0 +1,52 @@
/**
*
* 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.io.InputStream;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
import org.testng.annotations.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Tests behavior of {@code OvfEnvelopeHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.OvfEnvelopeHandlerTest")
public class OvfEnvelopeHandlerTest {
public void testVCloud1_0() {
InputStream is = getClass().getResourceAsStream("/ovf.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
OvfEnvelope result = factory.create(injector.getInstance(OvfEnvelopeHandler.class)).parse(is);
checkOvfEnvelope(result);
}
static void checkOvfEnvelope(OvfEnvelope result) {
VirtualSystemHandlerTest.checkVirtualSystem(result.getVirtualSystem());
}
}

View File

@ -17,15 +17,16 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**

View File

@ -17,31 +17,30 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.ovf.System;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code VirtualSystemHandler} * Tests behavior of {@code SystemHandler}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloud.VirtualSystemHandlerTest") @Test(groups = "unit", testName = "vcloud.SystemHandlerTest")
public class VirtualSystemHandlerTest extends BaseHandlerTest { public class SystemHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml"); InputStream is = getClass().getResourceAsStream("/virtualsystem-hosting.xml");
VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)) System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is);
.parse(is);
VirtualSystem expects = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-04"); System expects = new System(0, "Virtual Hardware Family", "SimpleVM", "vmx-04");
assertEquals(result, expects); assertEquals(result, expects);
} }

View File

@ -17,7 +17,7 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.xml; package org.jclouds.vcloud.xml.ovf;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -26,37 +26,38 @@ import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.OperatingSystem;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code OperatingSystemHandler} * Tests behavior of {@code VCloudOperatingSystemHandler}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "vcloud.OperatingSystemHandlerTest") @Test(groups = "unit", testName = "vcloud.VCloudOperatingSystemHandlerTest")
public class OperatingSystemHandlerTest extends BaseHandlerTest { public class VCloudOperatingSystemHandlerTest extends BaseHandlerTest {
public void testDefault() throws UnknownHostException { public void testDefault() throws UnknownHostException {
InputStream is = getClass().getResourceAsStream("/os.xml"); InputStream is = getClass().getResourceAsStream("/os.xml");
OperatingSystem result = factory.create(injector.getInstance(OperatingSystemHandler.class)).parse(is); VCloudOperatingSystem result = factory.create(injector.getInstance(VCloudOperatingSystemHandler.class)).parse(is);
checkOs(result); checkOs(result);
} }
static void checkOs(OperatingSystem result) { @Test(enabled = false)
public static void checkOs(VCloudOperatingSystem result) {
assertEquals(result.getHref(), URI assertEquals(result.getHref(), URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection")); .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"));
assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)"); assertEquals(result.getDescription(), "Red Hat Enterprise Linux 5 (64-bit)");
assertEquals(result.getEdit(), new ReferenceTypeImpl(null, assertEquals(result.getEdit(), new ReferenceTypeImpl(null,
"application/vnd.vmware.vcloud.operatingSystemSection+xml", "application/vnd.vmware.vcloud.operatingSystemSection+xml",
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/"))); URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/operatingSystemSection/")));
assertEquals(result.getId(), new Integer(80)); assertEquals(result.getId(), new Integer(80));
assertEquals(result.getVmwOsType(), "rhel5_64Guest"); assertEquals(result.getVmwOsType(), "rhel5_64Guest");
assertEquals(result.getName(), null);
assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml"); assertEquals(result.getType(), "application/vnd.vmware.vcloud.operatingSystemSection+xml");
assertEquals(result.getInfo(), "Specifies the operating system installed"); assertEquals(result.getInfo(), "Specifies the operating system installed");
} }

View File

@ -0,0 +1,105 @@
/**
*
* 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.VirtualHardware;
import org.jclouds.vcloud.domain.ovf.OperatingSystem;
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.domain.ovf.System;
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
import org.jclouds.vcloud.xml.ovf.VirtualSystemHandler;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Tests behavior of {@code VirtualSystemHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.VirtualSystemHandlerTest")
public class VirtualSystemHandlerTest {
public void testVCloud1_0() {
InputStream is = getClass().getResourceAsStream("/virtualsystem.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
VirtualSystem result = factory.create(injector.getInstance(VirtualSystemHandler.class)).parse(is);
checkVirtualSystem(result);
}
static void checkVirtualSystem(VirtualSystem result) {
assertEquals(result.getId(), "Ubuntu1004");
assertEquals(result.getName(), "Ubuntu1004");
assertEquals(result.getInfo(), "A virtual machine:");
checkHardware(result.getHardware());
checkOs(result.getOperatingSystem());
}
@Test(enabled = false)
public static void checkHardware(VirtualHardware result) {
assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "Ubuntu1004", "vmx-07"));
assertEquals(result.getInfo(), "Virtual hardware requirements");
assertEquals(Iterables.get(result.getResourceAllocations(), 0), new VCloudNetworkAdapter(1, "Network adapter 0",
"PCNet32 ethernet adapter", ResourceType.ETHERNET_ADAPTER, "PCNet32", null, "00:50:56:8c:00:13", 0,
null, false, 1, null, "192.168.2.100", true, "POOL"));
assertEquals(Iterables.get(result.getResourceAllocations(), 1), new ResourceAllocation(2, "SCSI Controller 0",
"SCSI Controller", ResourceType.SCSI_CONTROLLER, "lsilogic", null, "0", null, null, null, 1, null));
assertEquals(Iterables.get(result.getResourceAllocations(), 2), new VCloudHardDisk(2000, "Hard disk 1",
"Hard disk", ResourceType.DISK_DRIVE, null, null, null, 0, 2, null, 1, null, 30720, 6, "lsilogic"));
assertEquals(Iterables.get(result.getResourceAllocations(), 3), new ResourceAllocation(3, "IDE Controller 0",
"IDE Controller", ResourceType.IDE_CONTROLLER, null, null, "0", null, null, null, 1, null));
assertEquals(Iterables.get(result.getResourceAllocations(), 4), new ResourceAllocation(3002, "CD/DVD Drive 1",
"CD/DVD Drive", ResourceType.CD_DRIVE, null, null, null, 0, 3, null, 1, null));
assertEquals(Iterables.get(result.getResourceAllocations(), 5), new ResourceAllocation(8000, "Floppy Drive 1",
"Floppy Drive", ResourceType.FLOPPY_DRIVE, null, null, null, 0, null, null, 1, null));
assertEquals(Iterables.get(result.getResourceAllocations(), 6), new ResourceAllocation(4, "1 virtual CPU(s)",
"Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null, null, 1, "hertz * 10^6"));
assertEquals(Iterables.get(result.getResourceAllocations(), 7), new ResourceAllocation(5, "512 MB of memory",
"Memory Size", ResourceType.MEMORY, null, null, null, null, null, null, 512, "byte * 2^20"));
}
@Test(enabled = false)
public static void checkOs(OperatingSystem result) {
assertEquals(result.getDescription(), "Ubuntu Linux (64-bit)");
assertEquals(result.getId(), new Integer(94));
assertEquals(result.getInfo(), "Specifies the operating system installed");
}
}

View File

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<ovf:Envelope xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
<ovf:References/>
<ovf:NetworkSection>
<ovf:Info>The list of logical networks</ovf:Info>
<ovf:Network ovf:name="vAppNet-vApp Internal">
<ovf:Description/>
</ovf:Network>
</ovf:NetworkSection>
<vcloud:NetworkConfigSection ovf:required="false">
<ovf:Info>The configuration parameters for logical networks</ovf:Info>
<vcloud:NetworkConfig networkName="vAppNet-vApp Internal">
<vcloud:Description/>
<vcloud:Configuration>
<vcloud:IpScope>
<vcloud:IsInherited>false</vcloud:IsInherited>
<vcloud:Gateway>192.168.2.1</vcloud:Gateway>
<vcloud:Netmask>255.255.255.0</vcloud:Netmask>
<vcloud:Dns1>8.8.8.8</vcloud:Dns1>
<vcloud:IpRanges>
<vcloud:IpRange>
<vcloud:StartAddress>192.168.2.100</vcloud:StartAddress>
<vcloud:EndAddress>192.168.2.199</vcloud:EndAddress>
</vcloud:IpRange>
</vcloud:IpRanges>
<vcloud:AllocatedIpAddresses>
<vcloud:IpAddress>192.168.2.100</vcloud:IpAddress>
</vcloud:AllocatedIpAddresses>
</vcloud:IpScope>
<vcloud:FenceMode>isolated</vcloud:FenceMode>
<vcloud:Features>
<vcloud:DhcpService>
<vcloud:IsEnabled>false</vcloud:IsEnabled>
<vcloud:DefaultLeaseTime>7200</vcloud:DefaultLeaseTime>
<vcloud:MaxLeaseTime>7200</vcloud:MaxLeaseTime>
<vcloud:IpRange/>
</vcloud:DhcpService>
<vcloud:FirewallService>
<vcloud:IsEnabled>true</vcloud:IsEnabled>
</vcloud:FirewallService>
<vcloud:NatService>
<vcloud:IsEnabled>true</vcloud:IsEnabled>
<vcloud:NatType>ipTranslation</vcloud:NatType>
<vcloud:Policy>allowTraffic</vcloud:Policy>
<vcloud:NatRule>
<vcloud:OneToOneVmRule>
<vcloud:MappingMode>automatic</vcloud:MappingMode>
<vcloud:VAppScopedVmId>02_ubuntu_template</vcloud:VAppScopedVmId>
<vcloud:VmNicId>0</vcloud:VmNicId>
</vcloud:OneToOneVmRule>
</vcloud:NatRule>
</vcloud:NatService>
</vcloud:Features>
</vcloud:Configuration>
<vcloud:IsDeployed>false</vcloud:IsDeployed>
</vcloud:NetworkConfig>
</vcloud:NetworkConfigSection>
<vcloud:LeaseSettingsSection ovf:required="false">
<ovf:Info>Lease settings section</ovf:Info>
<vcloud:DeploymentLeaseInSeconds>0</vcloud:DeploymentLeaseInSeconds>
<vcloud:StorageLeaseInSeconds>0</vcloud:StorageLeaseInSeconds>
</vcloud:LeaseSettingsSection>
<vcloud:CustomizationSection ovf:required="false">
<ovf:Info>VApp template customization section</ovf:Info>
<vcloud:CustomizeOnInstantiate>true</vcloud:CustomizeOnInstantiate>
</vcloud:CustomizationSection>
<ovf:VirtualSystem ovf:id="Ubuntu1004">
<ovf:Info>A virtual machine:</ovf:Info>
<ovf:Name>Ubuntu1004</ovf:Name>
<ovf:OperatingSystemSection xmlns:vmw="http://www.vmware.com/schema/ovf" ovf:id="94" vmw:osType="ubuntu64Guest">
<ovf:Info>Specifies the operating system installed</ovf:Info>
<ovf:Description>Ubuntu Linux (64-bit)</ovf:Description>
</ovf:OperatingSystemSection>
<ovf:VirtualHardwareSection>
<ovf:Info>Virtual hardware requirements</ovf:Info>
<ovf:System>
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<vssd:InstanceID>0</vssd:InstanceID>
<vssd:VirtualSystemIdentifier>Ubuntu1004</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
</ovf:System>
<ovf:Item>
<rasd:Address>00:50:56:8c:00:13</rasd:Address>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:Connection vcloud:ipAddress="192.168.2.100" vcloud:primaryNetworkConnection="true" vcloud:ipAddressingMode="POOL">vAppNet-vApp Internal</rasd:Connection>
<rasd:Description>PCNet32 ethernet adapter</rasd:Description>
<rasd:ElementName>Network adapter 0</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:Description>Hard disk</rasd:Description>
<rasd:ElementName>Hard disk 1</rasd:ElementName>
<rasd:HostResource vcloud:capacity="30720" vcloud:busType="6" vcloud:busSubType="lsilogic"/>
<rasd:InstanceID>2000</rasd:InstanceID>
<rasd:Parent>2</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE Controller 0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:Description>CD/DVD Drive</rasd:Description>
<rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
<rasd:HostResource/>
<rasd:InstanceID>3002</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>15</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:Description>Floppy Drive</rasd:Description>
<rasd:ElementName>Floppy Drive 1</rasd:ElementName>
<rasd:HostResource/>
<rasd:InstanceID>8000</rasd:InstanceID>
<rasd:ResourceType>14</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
</ovf:Item>
<ovf:Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>512 MB of memory</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>512</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
</ovf:Item>
</ovf:VirtualHardwareSection>
<vcloud:NetworkConnectionSection ovf:required="false">
<ovf:Info>Specifies the available VM network connections</ovf:Info>
<vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
<vcloud:NetworkConnection network="vAppNet-vApp Internal">
<vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
<vcloud:IpAddress>192.168.2.100</vcloud:IpAddress>
<vcloud:IsConnected>true</vcloud:IsConnected>
<vcloud:MACAddress>00:50:56:8c:00:13</vcloud:MACAddress>
<vcloud:IpAddressAllocationMode>POOL</vcloud:IpAddressAllocationMode>
</vcloud:NetworkConnection>
</vcloud:NetworkConnectionSection>
<vcloud:GuestCustomizationSection ovf:required="false">
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
<vcloud:Enabled>true</vcloud:Enabled>
<vcloud:ChangeSid>false</vcloud:ChangeSid>
<vcloud:VirtualMachineId>172837194</vcloud:VirtualMachineId>
<vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
<vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
<vcloud:AdminPasswordEnabled>true</vcloud:AdminPasswordEnabled>
<vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
<vcloud:AdminPassword>%3eD%gmF</vcloud:AdminPassword>
<vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
<vcloud:CustomizationScript>#!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi</vcloud:CustomizationScript>
<vcloud:ComputerName>Ubuntu1004</vcloud:ComputerName>
</vcloud:GuestCustomizationSection>
</ovf:VirtualSystem>
</ovf:Envelope>

View File

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<ovf:VirtualSystem ovf:id="Ubuntu1004"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1"
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
<ovf:Info>A virtual machine:</ovf:Info>
<ovf:Name>Ubuntu1004</ovf:Name>
<ovf:OperatingSystemSection xmlns:vmw="http://www.vmware.com/schema/ovf"
ovf:id="94" vmw:osType="ubuntu64Guest">
<ovf:Info>Specifies the operating system installed</ovf:Info>
<ovf:Description>Ubuntu Linux (64-bit)</ovf:Description>
</ovf:OperatingSystemSection>
<ovf:VirtualHardwareSection>
<ovf:Info>Virtual hardware requirements</ovf:Info>
<ovf:System>
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<vssd:InstanceID>0</vssd:InstanceID>
<vssd:VirtualSystemIdentifier>Ubuntu1004</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
</ovf:System>
<ovf:Item>
<rasd:Address>00:50:56:8c:00:13</rasd:Address>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:Connection vcloud:ipAddress="192.168.2.100"
vcloud:primaryNetworkConnection="true"
vcloud:ipAddressingMode="POOL">vAppNet-vApp Internal</rasd:Connection>
<rasd:Description>PCNet32 ethernet adapter</rasd:Description>
<rasd:ElementName>Network adapter 0</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceSubType>PCNet32</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>SCSI Controller 0</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:Description>Hard disk</rasd:Description>
<rasd:ElementName>Hard disk 1</rasd:ElementName>
<rasd:HostResource vcloud:capacity="30720"
vcloud:busType="6" vcloud:busSubType="lsilogic" />
<rasd:InstanceID>2000</rasd:InstanceID>
<rasd:Parent>2</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE Controller 0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:Description>CD/DVD Drive</rasd:Description>
<rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
<rasd:HostResource />
<rasd:InstanceID>3002</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>15</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:Description>Floppy Drive</rasd:Description>
<rasd:ElementName>Floppy Drive 1</rasd:ElementName>
<rasd:HostResource />
<rasd:InstanceID>8000</rasd:InstanceID>
<rasd:ResourceType>14</rasd:ResourceType>
</ovf:Item>
<ovf:Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
</ovf:Item>
<ovf:Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>512 MB of memory</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>512</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
</ovf:Item>
</ovf:VirtualHardwareSection>
<vcloud:NetworkConnectionSection ovf:required="false">
<ovf:Info>Specifies the available VM network connections</ovf:Info>
<vcloud:PrimaryNetworkConnectionIndex>0</vcloud:PrimaryNetworkConnectionIndex>
<vcloud:NetworkConnection network="vAppNet-vApp Internal">
<vcloud:NetworkConnectionIndex>0</vcloud:NetworkConnectionIndex>
<vcloud:IpAddress>192.168.2.100</vcloud:IpAddress>
<vcloud:IsConnected>true</vcloud:IsConnected>
<vcloud:MACAddress>00:50:56:8c:00:13</vcloud:MACAddress>
<vcloud:IpAddressAllocationMode>POOL</vcloud:IpAddressAllocationMode>
</vcloud:NetworkConnection>
</vcloud:NetworkConnectionSection>
<vcloud:GuestCustomizationSection
ovf:required="false">
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
<vcloud:Enabled>true</vcloud:Enabled>
<vcloud:ChangeSid>false</vcloud:ChangeSid>
<vcloud:VirtualMachineId>172837194</vcloud:VirtualMachineId>
<vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
<vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
<vcloud:AdminPasswordEnabled>true</vcloud:AdminPasswordEnabled>
<vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
<vcloud:AdminPassword>%3eD%gmF</vcloud:AdminPassword>
<vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
<vcloud:CustomizationScript>#!/bin/bash if [ "$1" = "postcustomization" ]; then echo "post customization" touch /root/.postcustomization sleep 30 #regenerate keys /bin/rm /etc/ssh/ssh_host_* /usr/sbin/dpkg-reconfigure openssh-server echo "completed" fi</vcloud:CustomizationScript>
<vcloud:ComputerName>Ubuntu1004</vcloud:ComputerName>
</vcloud:GuestCustomizationSection>
</ovf:VirtualSystem>

View File

@ -43,10 +43,10 @@ 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.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
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;

View File

@ -39,7 +39,7 @@ import javax.xml.transform.TransformerException;
import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.binders.BindToStringPayload;
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import com.jamesmurty.utils.XMLBuilder; import com.jamesmurty.utils.XMLBuilder;

View File

@ -51,13 +51,13 @@ import org.jclouds.vcloud.VCloudExpressClientLiveTest;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.Task; 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;

View File

@ -32,10 +32,10 @@ import java.util.Properties;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.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.TerremarkVCloudExpressPropertiesBuilder; import org.jclouds.vcloud.terremark.TerremarkVCloudExpressPropertiesBuilder;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
import org.testng.annotations.Test; import org.testng.annotations.Test;

View File

@ -24,9 +24,9 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.ResourceAllocation; import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType; import org.jclouds.vcloud.domain.ovf.ResourceType;
import org.jclouds.vcloud.xml.ResourceAllocationHandler; 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;

View File

@ -35,12 +35,12 @@ 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;
import org.jclouds.vcloud.VCloudExpressMediaType; import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Status; import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VCloudExpressVApp; import org.jclouds.vcloud.domain.VCloudExpressVApp;
import org.jclouds.vcloud.domain.VirtualSystem;
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;
@ -109,7 +109,7 @@ 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 VirtualSystem(0, "Virtual Hardware Family", "centos-53", "vmx-07")); assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "centos-53", "vmx-07"));
assertEquals(result.getNetworkToAddresses().get("Internal"), ImmutableList.<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", ResourceAllocation cpu = new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
@ -147,7 +147,7 @@ public class VAppHandlerTest extends BaseHandlerTest {
assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI 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")));
assertEquals(vApp.getSystem(), new VirtualSystem(0, "Virtual Hardware Family", "eduardo", "vmx-07")); assertEquals(vApp.getSystem(), new System(0, "Virtual Hardware Family", "eduardo", "vmx-07"));
assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131")); assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131"));
ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs", ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs",

View File

@ -24,8 +24,8 @@ import static org.testng.Assert.assertEquals;
import java.io.InputStream; import java.io.InputStream;
import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.BaseHandlerTest;
import org.jclouds.vcloud.domain.VirtualSystem; import org.jclouds.vcloud.domain.ovf.System;
import org.jclouds.vcloud.xml.VirtualSystemHandler; 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;
@ -46,8 +46,7 @@ public class VirtualSystemHandlerTest extends BaseHandlerTest {
public void testApplyInputStream() { public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/terremark/system.xml"); InputStream is = getClass().getResourceAsStream("/terremark/system.xml");
VirtualSystem result = factory.create( System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is);
injector.getInstance(VirtualSystemHandler.class)).parse(is);
assertEquals(result.getName(), "Virtual Hardware Family"); assertEquals(result.getName(), "Virtual Hardware Family");
assertEquals(result.getId(), 0); assertEquals(result.getId(), 0);
assertEquals(result.getIdentifier(), "adriantest1"); assertEquals(result.getIdentifier(), "adriantest1");