mirror of https://github.com/apache/jclouds.git
Issue 280 remodeled so that network connections can be propertly specified
This commit is contained in:
parent
025b8aa12d
commit
69bbd65c8d
|
@ -101,6 +101,16 @@ public interface VCloudMediaType {
|
|||
public final static MediaType VIRTUALHARDWARESECTION_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.virtualHardwareSection+xml");
|
||||
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.networkSection+xml"
|
||||
*/
|
||||
public final static String NETWORKSECTION_XML = "application/vnd.vmware.vcloud.networkSection+xml";
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.networkSection+xml"
|
||||
*/
|
||||
public final static MediaType NETWORKSECTION_XML_TYPE = new MediaType("application",
|
||||
"vnd.vmware.vcloud.networkSection+xml");
|
||||
|
||||
/**
|
||||
* "application/vnd.vmware.vcloud.task+xml"
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_S
|
|||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
@ -42,10 +43,17 @@ import org.jclouds.logging.Logger;
|
|||
import org.jclouds.rest.MapBinder;
|
||||
import org.jclouds.rest.binders.BindToStringPayload;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
||||
|
@ -64,11 +72,14 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
protected final BindToStringPayload stringBinder;
|
||||
protected final URI defaultNetwork;
|
||||
protected final FenceMode defaultFenceMode;
|
||||
protected final DefaultNetworkNameInTemplate defaultNetworkNameInTemplate;
|
||||
|
||||
@Inject
|
||||
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns, @Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||
@Network URI network, @Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
|
||||
public BindInstantiateVAppTemplateParamsToXmlPayload(DefaultNetworkNameInTemplate defaultNetworkNameInTemplate,
|
||||
BindToStringPayload stringBinder, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Network URI network,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
|
||||
this.defaultNetworkNameInTemplate = defaultNetworkNameInTemplate;
|
||||
this.ns = ns;
|
||||
this.schema = schema;
|
||||
this.stringBinder = stringBinder;
|
||||
|
@ -83,27 +94,32 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||
String name = checkNotNull(postParams.remove("name"), "name");
|
||||
String template = checkNotNull(postParams.remove("template"), "template");
|
||||
final URI template = URI.create(checkNotNull(postParams.remove("template"), "template"));
|
||||
|
||||
String network = defaultNetwork.toASCIIString();
|
||||
FenceMode fenceMode = defaultFenceMode;
|
||||
logger.warn("hack alert; we need to actually get the network name from the vAppTemplate's ovf:Network ovf:name");
|
||||
String networkName = "vAppNet-vApp Internal";
|
||||
boolean deploy = true;
|
||||
boolean powerOn = true;
|
||||
|
||||
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
|
||||
if (options != null) {
|
||||
network = ifNullDefaultTo(options.getNetwork(), network);
|
||||
fenceMode = ifNullDefaultTo(options.getFenceMode(), defaultFenceMode);
|
||||
Set<? extends NetworkConfig> networkConfig = null;
|
||||
|
||||
NetworknetworkConfigDecorator networknetworkConfigDecorator = new NetworknetworkConfigDecorator(template,
|
||||
defaultNetwork, defaultFenceMode, defaultNetworkNameInTemplate);
|
||||
|
||||
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
|
||||
|
||||
if (options != null) {
|
||||
if (options.getNetworkConfig().size() > 0)
|
||||
networkConfig = Sets.newLinkedHashSet(Iterables.transform(options.getNetworkConfig(),
|
||||
networknetworkConfigDecorator));
|
||||
|
||||
networkName = ifNullDefaultTo(options.getNetworkName(), networkName);
|
||||
deploy = ifNullDefaultTo(options.shouldDeploy(), deploy);
|
||||
powerOn = ifNullDefaultTo(options.shouldPowerOn(), powerOn);
|
||||
}
|
||||
|
||||
if (networkConfig == null)
|
||||
networkConfig = ImmutableSet.of(networknetworkConfigDecorator.apply(null));
|
||||
|
||||
try {
|
||||
stringBinder.bindToRequest(request, generateXml(name, deploy, powerOn, template, networkName, fenceMode, URI
|
||||
.create(network)));
|
||||
stringBinder.bindToRequest(request, generateXml(name, deploy, powerOn, template, networkConfig));
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (FactoryConfigurationError e) {
|
||||
|
@ -114,15 +130,68 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
|
||||
}
|
||||
|
||||
protected String generateXml(String name, boolean deploy, boolean powerOn, String template, String networkName,
|
||||
FenceMode fenceMode, URI network) throws ParserConfigurationException, FactoryConfigurationError,
|
||||
TransformerException {
|
||||
protected static final class NetworknetworkConfigDecorator implements Function<NetworkConfig, NetworkConfig> {
|
||||
private final URI template;
|
||||
private final URI defaultNetwork;
|
||||
private final FenceMode defaultFenceMode;
|
||||
private final DefaultNetworkNameInTemplate defaultNetworkNameInTemplate;
|
||||
|
||||
protected NetworknetworkConfigDecorator(URI template, URI defaultNetwork, FenceMode defaultFenceMode,
|
||||
DefaultNetworkNameInTemplate defaultNetworkNameInTemplate) {
|
||||
this.template = checkNotNull(template, "template");
|
||||
this.defaultNetwork = checkNotNull(defaultNetwork, "defaultNetwork");
|
||||
this.defaultFenceMode = checkNotNull(defaultFenceMode, "defaultFenceMode");
|
||||
this.defaultNetworkNameInTemplate = checkNotNull(defaultNetworkNameInTemplate, "defaultNetworkNameInTemplate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkConfig apply(NetworkConfig from) {
|
||||
if (from == null)
|
||||
return new NetworkConfig(defaultNetworkNameInTemplate.apply(template), defaultNetwork, defaultFenceMode);
|
||||
URI network = ifNullDefaultTo(from.getParentNetwork(), defaultNetwork);
|
||||
FenceMode fenceMode = ifNullDefaultTo(from.getFenceMode(), defaultFenceMode);
|
||||
String networkName = from.getNetworkName() != null ? from.getNetworkName() : defaultNetworkNameInTemplate
|
||||
.apply(template);
|
||||
return new NetworkConfig(networkName, network, fenceMode);
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class DefaultNetworkNameInTemplate implements Function<URI, String> {
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final VCloudClient client;
|
||||
|
||||
@Inject
|
||||
DefaultNetworkNameInTemplate(VCloudClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(URI template) {
|
||||
String networkName;
|
||||
VAppTemplate vAppTemplate = client.getVAppTemplate(template);
|
||||
checkArgument(vAppTemplate != null, "vAppTemplate %s not found!", template);
|
||||
Set<org.jclouds.vcloud.domain.ovf.network.Network> networks = vAppTemplate.getNetworkSection().getNetworks();
|
||||
checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
|
||||
if (networks.size() > 1)
|
||||
logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
|
||||
networkName = Iterables.get(networks, 0).getName();
|
||||
return networkName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected String generateXml(String name, boolean deploy, boolean powerOn, URI template,
|
||||
Iterable<? extends NetworkConfig> networkConfig) throws ParserConfigurationException,
|
||||
FactoryConfigurationError, TransformerException {
|
||||
XMLBuilder rootBuilder = buildRoot(name).a("deploy", deploy + "").a("powerOn", powerOn + "");
|
||||
|
||||
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
|
||||
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode, network);
|
||||
addNetworkConfig(instantiationParamsBuilder, networkConfig);
|
||||
|
||||
rootBuilder.e("Source").a("href", template);
|
||||
rootBuilder.e("Source").a("href", template.toASCIIString());
|
||||
rootBuilder.e("AllEULAsAccepted").t("true");
|
||||
|
||||
Properties outputProperties = new Properties();
|
||||
|
@ -130,14 +199,17 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
return rootBuilder.asString(outputProperties);
|
||||
}
|
||||
|
||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name, FenceMode fenceMode, URI network) {
|
||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
|
||||
Iterable<? extends NetworkConfig> networkConfig) {
|
||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection");
|
||||
networkConfigBuilder.e("ovf:Info").t("Configuration parameters for logical networks");
|
||||
XMLBuilder configurationBuilder = networkConfigBuilder.e("NetworkConfig").a("networkName", name).e(
|
||||
"Configuration");
|
||||
configurationBuilder.e("ParentNetwork").a("href", network.toASCIIString());
|
||||
if (fenceMode != null) {
|
||||
configurationBuilder.e("FenceMode").t(fenceMode.toString());
|
||||
for (NetworkConfig n : networkConfig) {
|
||||
XMLBuilder configurationBuilder = networkConfigBuilder.e("NetworkConfig").a("networkName", n.getNetworkName())
|
||||
.e("Configuration");
|
||||
configurationBuilder.e("ParentNetwork").a("href", n.getParentNetwork().toASCIIString());
|
||||
if (n.getFenceMode() != null) {
|
||||
configurationBuilder.e("FenceMode").t(n.getFenceMode().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +234,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
throw new IllegalStateException("InstantiateVAppTemplateParams is needs parameters");
|
||||
}
|
||||
|
||||
protected <T> T ifNullDefaultTo(T value, T defaultValue) {
|
||||
public static <T> T ifNullDefaultTo(T value, T defaultValue) {
|
||||
return value != null ? value : checkNotNull(defaultValue, "defaultValue");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,11 +44,13 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.rest.MapBinder;
|
||||
import org.jclouds.rest.binders.BindToStringPayload;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Inject;
|
||||
import com.jamesmurty.utils.XMLBuilder;
|
||||
|
@ -99,11 +101,14 @@ public class BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload implemen
|
|||
String fenceMode = defaultFenceMode;
|
||||
String networkName = name;
|
||||
if (options != null) {
|
||||
network = ifNullDefaultTo(options.getNetwork(), network);
|
||||
fenceMode = ifNullDefaultTo(options.getFenceMode(), defaultFenceMode);
|
||||
if (options.getNetworkConfig().size() > 0) {
|
||||
NetworkConfig config = Iterables.get(options.getNetworkConfig(), 0);
|
||||
network = ifNullDefaultTo(config.getParentNetwork(), network);
|
||||
fenceMode = ifNullDefaultTo(config.getFenceMode(), defaultFenceMode);
|
||||
if (apiVersion.indexOf("0.8") != -1 && fenceMode.equals("bridged"))
|
||||
fenceMode = "allowInOut";
|
||||
networkName = ifNullDefaultTo(options.getNetworkName(), networkName);
|
||||
networkName = ifNullDefaultTo(config.getNetworkName(), networkName);
|
||||
}
|
||||
addQuantity(options, virtualHardwareQuantity);
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -23,12 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static com.google.common.collect.Iterables.find;
|
||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.compute.domain.Size;
|
||||
import org.jclouds.compute.domain.internal.SizeImpl;
|
||||
import org.jclouds.compute.predicates.ImagePredicates;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
|
@ -36,14 +38,20 @@ import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
|||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SizeForVAppTemplate implements Function<VAppTemplate, Size> {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final VCloudClient client;
|
||||
private final FindLocationForResource findLocationForResource;
|
||||
private ReferenceType parent;
|
||||
|
@ -61,19 +69,36 @@ public class SizeForVAppTemplate implements Function<VAppTemplate, Size> {
|
|||
|
||||
@Override
|
||||
public Size apply(VAppTemplate from) {
|
||||
checkNotNull(from, "VAppTemplate");
|
||||
|
||||
if (!from.isOvfDescriptorUploaded()) {
|
||||
logger.warn("cannot parse size as ovf descriptor for %s is not uploaded", from);
|
||||
return null;
|
||||
}
|
||||
|
||||
OvfEnvelope ovf = client.getOvfEnvelopeForVAppTemplate(from.getHref());
|
||||
if (ovf == null) {
|
||||
logger.warn("cannot parse size as no ovf envelope found for %s", from);
|
||||
return null;
|
||||
}
|
||||
|
||||
Location location = findLocationForResource.apply(checkNotNull(parent, "parent"));
|
||||
int ram = (int) find(ovf.getVirtualSystem().getHardware().getResourceAllocations(),
|
||||
resourceType(ResourceType.MEMORY)).getVirtualQuantity();
|
||||
ResourceAllocation diskR = find(ovf.getVirtualSystem().getHardware().getResourceAllocations(),
|
||||
resourceType(ResourceType.DISK_DRIVE));
|
||||
if (ovf.getVirtualSystem().getHardware().size() == 0) {
|
||||
logger.warn("cannot parse size for %s as no hardware sections exist in ovf %s", ovf);
|
||||
return null;
|
||||
}
|
||||
if (ovf.getVirtualSystem().getHardware().size() > 1) {
|
||||
logger.warn("multiple hardware choices found. using first", ovf);
|
||||
}
|
||||
VirtualHardwareSection hardware = Iterables.get(ovf.getVirtualSystem().getHardware(), 0);
|
||||
|
||||
int ram = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity();
|
||||
ResourceAllocation diskR = find(hardware.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE));
|
||||
int disk = (int) (((diskR instanceof VCloudHardDisk) ? VCloudHardDisk.class.cast(diskR).getCapacity() : diskR
|
||||
.getVirtualQuantity()) / 1024l);
|
||||
|
||||
double cores = (int) find(ovf.getVirtualSystem().getHardware().getResourceAllocations(),
|
||||
resourceType(ResourceType.PROCESSOR)).getVirtualQuantity();
|
||||
double cores = (int) find(hardware.getResourceAllocations(), resourceType(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity();
|
||||
|
||||
return new SizeImpl(from.getHref().toASCIIString(), from.getName()
|
||||
+ String.format(": vpu(%.1f), ram(%d), disk(%d)", cores, ram, disk), from.getHref().toASCIIString(),
|
||||
|
|
|
@ -50,7 +50,7 @@ public class VCloudComputeUtils {
|
|||
return toComputeOs(vm.getOperatingSystem());
|
||||
}
|
||||
|
||||
public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystem os) {
|
||||
public static CIMOperatingSystem toComputeOs(org.jclouds.vcloud.domain.ovf.OperatingSystemSection os) {
|
||||
return new CIMOperatingSystem(CIMOperatingSystem.OSType.fromValue(os.getId()), null, null, os.getDescription());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Set;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
|
@ -88,4 +89,11 @@ public interface VAppTemplate extends ReferenceType {
|
|||
* @since vcloud api 1.0
|
||||
*/
|
||||
Set<? extends Vm> getChildren();
|
||||
|
||||
/**
|
||||
* description of the predefined vApp internal networks in this template
|
||||
*
|
||||
* @since vcloud api 1.0
|
||||
*/
|
||||
VCloudNetworkSection getNetworkSection();
|
||||
}
|
|
@ -25,6 +25,7 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.jclouds.vcloud.domain.internal.VmImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jclouds.vcloud.domain.Status;
|
|||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -53,10 +54,11 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
|||
private final boolean ovfDescriptorUploaded;
|
||||
private final String vAppScopedLocalId;
|
||||
private final Set<Vm> children = Sets.newLinkedHashSet();
|
||||
private final VCloudNetworkSection networkSection;
|
||||
|
||||
public VAppTemplateImpl(String name, String type, URI id, Status status, ReferenceType vdc,
|
||||
@Nullable String description, Iterable<Task> tasks, boolean ovfDescriptorUploaded,
|
||||
@Nullable String vAppScopedLocalId, Iterable<? extends Vm> children) {
|
||||
@Nullable String vAppScopedLocalId, Iterable<? extends Vm> children, VCloudNetworkSection networkSection) {
|
||||
super(name, type, id);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.vdc = vdc;// TODO: once <1.0 is killed check not null
|
||||
|
@ -65,6 +67,7 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
|||
this.vAppScopedLocalId = vAppScopedLocalId;
|
||||
this.ovfDescriptorUploaded = ovfDescriptorUploaded;
|
||||
Iterables.addAll(this.children, checkNotNull(children, "children"));
|
||||
this.networkSection = checkNotNull(networkSection, "networkSection");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,11 +126,21 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
|||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public VCloudNetworkSection getNetworkSection() {
|
||||
return networkSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((children == null) ? 0 : children.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((networkSection == null) ? 0 : networkSection.hashCode());
|
||||
result = prime * result + (ovfDescriptorUploaded ? 1231 : 1237);
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
|
||||
|
@ -145,13 +158,33 @@ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VAppTemplateImpl other = (VAppTemplateImpl) obj;
|
||||
if (children == null) {
|
||||
if (other.children != null)
|
||||
return false;
|
||||
} else if (!children.equals(other.children))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (networkSection == null) {
|
||||
if (other.networkSection != null)
|
||||
return false;
|
||||
} else if (!networkSection.equals(other.networkSection))
|
||||
return false;
|
||||
if (ovfDescriptorUploaded != other.ovfDescriptorUploaded)
|
||||
return false;
|
||||
if (status == null) {
|
||||
if (other.status != null)
|
||||
return false;
|
||||
} else if (!status.equals(other.status))
|
||||
return false;
|
||||
if (tasks == null) {
|
||||
if (other.tasks != null)
|
||||
return false;
|
||||
} else if (!tasks.equals(other.tasks))
|
||||
return false;
|
||||
if (vAppScopedLocalId == null) {
|
||||
if (other.vAppScopedLocalId != null)
|
||||
return false;
|
||||
|
|
|
@ -29,9 +29,9 @@ import javax.annotation.Nullable;
|
|||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
/**
|
||||
*
|
||||
* 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.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.ovf.NetworkSection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkConfig {
|
||||
@Nullable
|
||||
private final String networkName;
|
||||
private final URI parentNetwork;
|
||||
@Nullable
|
||||
private final FenceMode fenceMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* Create a new NetworkConfig.
|
||||
*
|
||||
* @param networkName
|
||||
* a valid {@networkConfig
|
||||
* org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the vapp
|
||||
* template}, or null to have us choose default
|
||||
* @param parentNetwork
|
||||
* a valid {@networkConfig org.jclouds.vcloud.domain.Org#getNetworks in
|
||||
* the Org}
|
||||
* @param fenceMode
|
||||
* how to manage the relationship between the two networks
|
||||
*/
|
||||
public NetworkConfig(String networkName, URI parentNetwork, FenceMode fenceMode) {
|
||||
this.networkName = networkName;
|
||||
this.parentNetwork = checkNotNull(parentNetwork, "parentNetwork");
|
||||
this.fenceMode = fenceMode;
|
||||
}
|
||||
|
||||
public NetworkConfig(URI parentNetwork) {
|
||||
this(null, parentNetwork, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A name for the network. If the {@link org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection} includes a {@link NetworkSection.Network} network
|
||||
* element, the name you specify for the vApp network must match the name specified in that
|
||||
* element’s name attribute.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getNetworkName() {
|
||||
return networkName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return A reference to the organization network to which this network connects.
|
||||
*/
|
||||
public URI getParentNetwork() {
|
||||
return parentNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* A value of bridged indicates that this vApp network is connected directly to the organization
|
||||
* network.
|
||||
*/
|
||||
public FenceMode getFenceMode() {
|
||||
return fenceMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
|
||||
result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode());
|
||||
result = prime * result + ((networkName == null) ? 0 : networkName.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;
|
||||
NetworkConfig other = (NetworkConfig) obj;
|
||||
if (fenceMode == null) {
|
||||
if (other.fenceMode != null)
|
||||
return false;
|
||||
} else if (!fenceMode.equals(other.fenceMode))
|
||||
return false;
|
||||
if (parentNetwork == null) {
|
||||
if (other.parentNetwork != null)
|
||||
return false;
|
||||
} else if (!parentNetwork.equals(other.parentNetwork))
|
||||
return false;
|
||||
if (networkName == null) {
|
||||
if (other.networkName != null)
|
||||
return false;
|
||||
} else if (!networkName.equals(other.networkName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[networkName=" + networkName + ", parentNetwork=" + parentNetwork + ", fenceMode=" + fenceMode + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.ovf;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The NetworkSection element shall list all logical networks used in the OVF package.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkSection {
|
||||
private final String info;
|
||||
private final Set<Network> networks = Sets.newLinkedHashSet();
|
||||
|
||||
public NetworkSection(String info, Iterable<Network> networks) {
|
||||
this.info = info;
|
||||
Iterables.addAll(this.networks, networks);
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* All networks referred to from Connection elements in all {@link VirtualHardwareSection} elements shall
|
||||
* be defined in the NetworkSection.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Network> getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((info == null) ? 0 : info.hashCode());
|
||||
result = prime * result + ((networks == null) ? 0 : networks.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NetworkSection other = (NetworkSection) obj;
|
||||
if (info == null) {
|
||||
if (other.info != null)
|
||||
return false;
|
||||
} else if (!info.equals(other.info))
|
||||
return false;
|
||||
if (networks == null) {
|
||||
if (other.networks != null)
|
||||
return false;
|
||||
} else if (!networks.equals(other.networks))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[info=" + info + ", networks=" + networks + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.jclouds.vcloud.domain.ovf;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class OperatingSystem {
|
||||
public class OperatingSystemSection {
|
||||
|
||||
@Nullable
|
||||
protected final Integer id;
|
||||
|
@ -31,7 +31,7 @@ public class OperatingSystem {
|
|||
@Nullable
|
||||
protected final String description;
|
||||
|
||||
public OperatingSystem(@Nullable Integer id, @Nullable String info, @Nullable String description) {
|
||||
public OperatingSystemSection(@Nullable Integer id, @Nullable String info, @Nullable String description) {
|
||||
this.id = id;
|
||||
this.info = info;
|
||||
this.description = description;
|
||||
|
@ -79,7 +79,7 @@ public class OperatingSystem {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OperatingSystem other = (OperatingSystem) obj;
|
||||
OperatingSystemSection other = (OperatingSystemSection) obj;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
|
@ -21,17 +21,23 @@ package org.jclouds.vcloud.domain.ovf;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class System {
|
||||
protected final int id;
|
||||
protected final String name;
|
||||
protected final String identifier;
|
||||
protected final String type;
|
||||
protected final Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
|
||||
|
||||
public System(int id, String name, String identifier, String type) {
|
||||
public System(int id, String name, String identifier, Iterable<String> virtualSystemTypes) {
|
||||
this.id = id;
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.identifier = checkNotNull(identifier, "identifier");
|
||||
this.type = checkNotNull(type, "type");
|
||||
Iterables.addAll(this.virtualSystemTypes, checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -46,8 +52,17 @@ public class System {
|
|||
return identifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
/**
|
||||
* specifies a virtual system virtualSystemTypes identifier, which is an implementation defined string that
|
||||
* uniquely identifies the virtualSystemTypes of the virtual system.
|
||||
*
|
||||
* <p/>
|
||||
* For example, a virtual system virtualSystemTypes identifier could be vmx-4 for VMware’s fourth-generation
|
||||
* virtual hardware or xen-3 for Xen’s third-generation virtual hardware.
|
||||
*
|
||||
*/
|
||||
public Set<String> getVirtualSystemTypes() {
|
||||
return virtualSystemTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +72,7 @@ public class System {
|
|||
result = prime * result + id;
|
||||
result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((virtualSystemTypes == null) ? 0 : virtualSystemTypes.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -82,17 +97,18 @@ public class System {
|
|||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
if (virtualSystemTypes == null) {
|
||||
if (other.virtualSystemTypes != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
} else if (!virtualSystemTypes.equals(other.virtualSystemTypes))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name + ", type=" + type + "]";
|
||||
return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name + ", virtualSystemTypes="
|
||||
+ virtualSystemTypes + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.ovf;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
||||
|
||||
/**
|
||||
* VCloud extension
|
||||
*/
|
||||
public class VCloudNetworkSection extends NetworkSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
|
||||
public VCloudNetworkSection(String type, URI href, String info, Iterable<Network> networks) {
|
||||
super(info, networks);
|
||||
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;
|
||||
VCloudNetworkSection other = (VCloudNetworkSection) 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() + ", networks=" + getNetworks() + "]";
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.jclouds.vcloud.domain.ReferenceType;
|
|||
/**
|
||||
* A description of the operating system supported by a virtual machine.
|
||||
*/
|
||||
public class VCloudOperatingSystem extends OperatingSystem {
|
||||
public class VCloudOperatingSystem extends OperatingSystemSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
@Nullable
|
||||
|
|
|
@ -17,17 +17,15 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
package org.jclouds.vcloud.domain.ovf;
|
||||
|
||||
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 {
|
||||
public class VCloudVirtualHardware extends VirtualHardwareSection {
|
||||
protected final String type;
|
||||
protected final URI href;
|
||||
|
|
@ -17,29 +17,35 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
package org.jclouds.vcloud.domain.ovf;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* A description of the virtual hardware supported by a virtual machine.
|
||||
*
|
||||
* The virtual hardware required by a virtual machine is specified in VirtualHardwareSection.
|
||||
* <p/>
|
||||
* This specification supports abstract or incomplete hardware descriptions in which only the major
|
||||
* devices are described. The hypervisor is allowed to create additional virtual hardware
|
||||
* controllers and devices, as long as the required devices listed in the descriptor are realized.
|
||||
*/
|
||||
public class VirtualHardware {
|
||||
public class VirtualHardwareSection {
|
||||
|
||||
protected final String info;
|
||||
protected final System virtualSystem;
|
||||
protected final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
|
||||
|
||||
public VirtualHardware(String info, System virtualSystem, Iterable<? extends ResourceAllocation> resourceAllocations) {
|
||||
public VirtualHardwareSection(String info, System virtualSystem,
|
||||
Iterable<? extends ResourceAllocation> resourceAllocations) {
|
||||
this.info = info;
|
||||
this.virtualSystem = virtualSystem;
|
||||
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
||||
Iterables.addAll(this.resourceAllocations, checkNotNull(resourceAllocations, "resourceAllocations"));
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
|
@ -77,7 +83,7 @@ public class VirtualHardware {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VirtualHardware other = (VirtualHardware) obj;
|
||||
VirtualHardwareSection other = (VirtualHardwareSection) obj;
|
||||
if (info == null) {
|
||||
if (other.info != null)
|
||||
return false;
|
|
@ -21,7 +21,11 @@ package org.jclouds.vcloud.domain.ovf;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.vcloud.domain.VirtualHardware;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -30,15 +34,16 @@ public class VirtualSystem {
|
|||
private final String id;
|
||||
private final String info;
|
||||
private final String name;
|
||||
private final OperatingSystem operatingSystem;
|
||||
private final VirtualHardware hardware;
|
||||
private final OperatingSystemSection operatingSystem;
|
||||
private final Set<VirtualHardwareSection> hardware = Sets.newLinkedHashSet();
|
||||
|
||||
public VirtualSystem(String id, String info, String name, OperatingSystem operatingSystem, VirtualHardware hardware) {
|
||||
public VirtualSystem(String id, String info, String name, OperatingSystemSection operatingSystem,
|
||||
Iterable<? extends VirtualHardwareSection> hardware) {
|
||||
this.id = id;
|
||||
this.info = info;
|
||||
this.name = name;
|
||||
this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
|
||||
this.hardware = checkNotNull(hardware, "hardware");
|
||||
Iterables.addAll(this.hardware, checkNotNull(hardware, "hardware"));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -53,11 +58,15 @@ public class VirtualSystem {
|
|||
return name;
|
||||
}
|
||||
|
||||
public OperatingSystem getOperatingSystem() {
|
||||
public OperatingSystemSection getOperatingSystem() {
|
||||
return operatingSystem;
|
||||
}
|
||||
|
||||
public VirtualHardware getHardware() {
|
||||
/**
|
||||
* Each VirtualSystem element may contain one or more VirtualHardwareSection elements, each of
|
||||
* which describes the virtual hardware required by the virtual system.
|
||||
* */
|
||||
public Set<? extends VirtualHardwareSection> getHardware() {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
*
|
||||
* 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.network;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Network {
|
||||
private final String name;
|
||||
private final String description;
|
||||
|
||||
public Network(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Network other = (Network) obj;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Network [name=" + name + ", description=" + description + "]";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
|
@ -22,9 +22,13 @@ package org.jclouds.vcloud.options;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
|
||||
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -32,13 +36,12 @@ import org.jclouds.vcloud.domain.network.FenceMode;
|
|||
*
|
||||
*/
|
||||
public class InstantiateVAppTemplateOptions {
|
||||
private Set<NetworkConfig> networkConfig = Sets.newLinkedHashSet();
|
||||
|
||||
private String cpuCount;
|
||||
private String memorySizeMegabytes;
|
||||
private String diskSizeKilobytes;
|
||||
private String network;
|
||||
private FenceMode fenceMode;
|
||||
private String networkName;
|
||||
|
||||
private boolean block = true;
|
||||
private boolean deploy = true;
|
||||
private boolean powerOn = true;
|
||||
|
@ -85,19 +88,6 @@ public class InstantiateVAppTemplateOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the vApp internal network that you want to connect to a VDC network
|
||||
*/
|
||||
public InstantiateVAppTemplateOptions networkName(String networkName) {
|
||||
this.networkName = checkNotNull(networkName, "networkName");
|
||||
return this;
|
||||
}
|
||||
|
||||
public InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||
this.fenceMode = checkNotNull(fenceMode, "fenceMode");
|
||||
return this;
|
||||
}
|
||||
|
||||
public InstantiateVAppTemplateOptions memory(long megabytes) {
|
||||
checkArgument(megabytes >= 1, "megabytes must be positive");
|
||||
this.memorySizeMegabytes = megabytes + "";
|
||||
|
@ -110,11 +100,28 @@ public class InstantiateVAppTemplateOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
public InstantiateVAppTemplateOptions network(URI networkLocation) {
|
||||
this.network = checkNotNull(networkLocation, "networkLocation").toASCIIString();
|
||||
/**
|
||||
* {@networkConfig VAppTemplate}s have internal networks that can be connected in order to access
|
||||
* the internet or other external networks.
|
||||
*
|
||||
* <h4>default behaviour if you don't use this option</h4> By default, we connect the first
|
||||
* internal {@networkConfig
|
||||
* org.jclouds.vcloud.domain.VAppTemplate#getNetworkSection network in the vapp template}to a
|
||||
* default chosen from the org or specified via {@networkConfig
|
||||
* org.jclouds.vcloud.reference.VCloudConstants#PROPERTY_VCLOUD_DEFAULT_NETWORK} using the
|
||||
* {@networkConfig org.jclouds.vcloud.domain.FenceMode#BRIDGED} or an override
|
||||
* set by the property {@networkConfig
|
||||
* org.jclouds.vcloud.reference.VCloudConstants#PROPERTY_VCLOUD_DEFAULT_FENCEMODE}.
|
||||
*/
|
||||
public InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||
this.networkConfig.add(checkNotNull(networkConfig, "networkConfig"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<NetworkConfig> getNetworkConfig() {
|
||||
return networkConfig;
|
||||
}
|
||||
|
||||
public String getCpuCount() {
|
||||
return cpuCount;
|
||||
}
|
||||
|
@ -127,18 +134,6 @@ public class InstantiateVAppTemplateOptions {
|
|||
return diskSizeKilobytes;
|
||||
}
|
||||
|
||||
public String getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
public String getNetworkName() {
|
||||
return networkName;
|
||||
}
|
||||
|
||||
public FenceMode getFenceMode() {
|
||||
return fenceMode;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
|
@ -190,27 +185,11 @@ public class InstantiateVAppTemplateOptions {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppTemplateOptions#network(URI)
|
||||
* @see InstantiateVAppTemplateOptions#addNetworkConfig
|
||||
*/
|
||||
public static InstantiateVAppTemplateOptions inNetwork(URI networkLocation) {
|
||||
public static InstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
return options.network(networkLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppTemplateOptions#fenceMode(FenceMode)
|
||||
*/
|
||||
public static InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
return options.fenceMode(fenceMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see InstantiateVAppTemplateOptions#networkName(String)
|
||||
*/
|
||||
public static InstantiateVAppTemplateOptions networkName(String networkName) {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
return options.networkName(networkName);
|
||||
return options.addNetworkConfig(networkConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,20 +197,20 @@ public class InstantiateVAppTemplateOptions {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "InstantiateVAppTemplateOptions [cpuCount=" + cpuCount + ", memorySizeMegabytes=" + memorySizeMegabytes
|
||||
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", network=" + network + ", networkName=" + networkName
|
||||
+ ", fenceMode=" + fenceMode + "]";
|
||||
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", networkConfig=" + networkConfig + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (block ? 1231 : 1237);
|
||||
result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
|
||||
result = prime * result + (deploy ? 1231 : 1237);
|
||||
result = prime * result + ((diskSizeKilobytes == null) ? 0 : diskSizeKilobytes.hashCode());
|
||||
result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
|
||||
result = prime * result + ((networkConfig == null) ? 0 : networkConfig.hashCode());
|
||||
result = prime * result + ((memorySizeMegabytes == null) ? 0 : memorySizeMegabytes.hashCode());
|
||||
result = prime * result + ((network == null) ? 0 : network.hashCode());
|
||||
result = prime * result + ((networkName == null) ? 0 : networkName.hashCode());
|
||||
result = prime * result + (powerOn ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -244,35 +223,31 @@ public class InstantiateVAppTemplateOptions {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
InstantiateVAppTemplateOptions other = (InstantiateVAppTemplateOptions) obj;
|
||||
if (block != other.block)
|
||||
return false;
|
||||
if (cpuCount == null) {
|
||||
if (other.cpuCount != null)
|
||||
return false;
|
||||
} else if (!cpuCount.equals(other.cpuCount))
|
||||
return false;
|
||||
if (deploy != other.deploy)
|
||||
return false;
|
||||
if (diskSizeKilobytes == null) {
|
||||
if (other.diskSizeKilobytes != null)
|
||||
return false;
|
||||
} else if (!diskSizeKilobytes.equals(other.diskSizeKilobytes))
|
||||
return false;
|
||||
if (fenceMode == null) {
|
||||
if (other.fenceMode != null)
|
||||
if (networkConfig == null) {
|
||||
if (other.networkConfig != null)
|
||||
return false;
|
||||
} else if (!fenceMode.equals(other.fenceMode))
|
||||
} else if (!networkConfig.equals(other.networkConfig))
|
||||
return false;
|
||||
if (memorySizeMegabytes == null) {
|
||||
if (other.memorySizeMegabytes != null)
|
||||
return false;
|
||||
} else if (!memorySizeMegabytes.equals(other.memorySizeMegabytes))
|
||||
return false;
|
||||
if (network == null) {
|
||||
if (other.network != null)
|
||||
return false;
|
||||
} else if (!network.equals(other.network))
|
||||
return false;
|
||||
if (networkName == null) {
|
||||
if (other.networkName != null)
|
||||
return false;
|
||||
} else if (!networkName.equals(other.networkName))
|
||||
if (powerOn != other.powerOn)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.jclouds.vcloud.domain.Task;
|
|||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.VAppTemplateImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudNetworkSectionHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
@ -48,11 +50,14 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
|
||||
protected final TaskHandler taskHandler;
|
||||
protected final VmHandler vmHandler;
|
||||
protected final VCloudNetworkSectionHandler networkSectionHandler;
|
||||
|
||||
@Inject
|
||||
public VAppTemplateHandler(TaskHandler taskHandler, VmHandler vmHandler) {
|
||||
public VAppTemplateHandler(TaskHandler taskHandler, VmHandler vmHandler,
|
||||
VCloudNetworkSectionHandler networkSectionHandler) {
|
||||
this.taskHandler = taskHandler;
|
||||
this.vmHandler = vmHandler;
|
||||
this.networkSectionHandler = networkSectionHandler;
|
||||
}
|
||||
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
@ -67,11 +72,13 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
|
||||
private boolean inChildren;
|
||||
private boolean inTasks;
|
||||
private boolean inNetworkSection;
|
||||
protected Set<Vm> children = Sets.newLinkedHashSet();
|
||||
private VCloudNetworkSection networkSection;
|
||||
|
||||
public VAppTemplate getResult() {
|
||||
return new VAppTemplateImpl(template.getName(), template.getType(), template.getHref(), status, vdc, description,
|
||||
tasks, ovfDescriptorUploaded, vAppScopedLocalId, children);
|
||||
tasks, ovfDescriptorUploaded, vAppScopedLocalId, children, networkSection);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +88,15 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
inChildren = true;
|
||||
} else if (qName.endsWith("Tasks")) {
|
||||
inTasks = true;
|
||||
} else if (qName.endsWith("NetworkSection")) {
|
||||
inNetworkSection = true;
|
||||
}
|
||||
if (inChildren) {
|
||||
vmHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inTasks) {
|
||||
taskHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (inNetworkSection) {
|
||||
networkSectionHandler.startElement(uri, localName, qName, attrs);
|
||||
} else if (qName.equals("VAppTemplate")) {
|
||||
template = newReferenceType(attributes);
|
||||
if (attributes.containsKey("status"))
|
||||
|
@ -103,11 +114,16 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
} else if (qName.endsWith("Tasks")) {
|
||||
inTasks = false;
|
||||
this.tasks.add(taskHandler.getResult());
|
||||
} else if (qName.endsWith("NetworkSection")) {
|
||||
inNetworkSection = false;
|
||||
this.networkSection = networkSectionHandler.getResult();
|
||||
}
|
||||
if (inChildren) {
|
||||
vmHandler.endElement(uri, name, qName);
|
||||
} else if (inTasks) {
|
||||
taskHandler.endElement(uri, name, qName);
|
||||
} else if (inNetworkSection) {
|
||||
networkSectionHandler.endElement(uri, name, qName);
|
||||
} else if (qName.equals("Description")) {
|
||||
description = currentOrNull();
|
||||
} else if (qName.equals("VAppScopedLocalId")) {
|
||||
|
@ -121,8 +137,11 @@ public class VAppTemplateHandler extends ParseSax.HandlerWithResult<VAppTemplate
|
|||
public void characters(char ch[], int start, int length) {
|
||||
if (inTasks)
|
||||
taskHandler.characters(ch, start, length);
|
||||
if (inChildren)
|
||||
else if (inChildren)
|
||||
vmHandler.characters(ch, start, length);
|
||||
else if (inNetworkSection)
|
||||
networkSectionHandler.characters(ch, start, length);
|
||||
else
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ 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.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
|
@ -37,17 +37,17 @@ import org.xml.sax.Attributes;
|
|||
*/
|
||||
public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult<VCloudVirtualHardware> {
|
||||
|
||||
private final VirtualHardwareHandler hardwareHandler;
|
||||
private final VirtualHardwareSectionHandler hardwareHandler;
|
||||
|
||||
private ReferenceType hardware;
|
||||
|
||||
@Inject
|
||||
public VCloudVirtualHardwareHandler(VirtualHardwareHandler hardwareHandler) {
|
||||
public VCloudVirtualHardwareHandler(VirtualHardwareSectionHandler hardwareHandler) {
|
||||
this.hardwareHandler = hardwareHandler;
|
||||
}
|
||||
|
||||
public VCloudVirtualHardware getResult() {
|
||||
VirtualHardware hardware = hardwareHandler.getResult();
|
||||
VirtualHardwareSection hardware = hardwareHandler.getResult();
|
||||
return new VCloudVirtualHardware(this.hardware.getType(), this.hardware.getHref(), hardware.getInfo(), hardware
|
||||
.getSystem(), hardware.getResourceAllocations());
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ import java.util.Set;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.VirtualHardware;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -36,14 +36,14 @@ import com.google.common.collect.Sets;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VirtualHardwareHandler extends ParseSax.HandlerWithResult<VirtualHardware> {
|
||||
public class VirtualHardwareSectionHandler extends ParseSax.HandlerWithResult<VirtualHardwareSection> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
private final SystemHandler systemHandler;
|
||||
private final VCloudResourceAllocationHandler allocationHandler;
|
||||
|
||||
@Inject
|
||||
public VirtualHardwareHandler(SystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) {
|
||||
public VirtualHardwareSectionHandler(SystemHandler systemHandler, VCloudResourceAllocationHandler allocationHandler) {
|
||||
this.systemHandler = systemHandler;
|
||||
this.allocationHandler = allocationHandler;
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ public class VirtualHardwareHandler extends ParseSax.HandlerWithResult<VirtualHa
|
|||
private boolean inItem;
|
||||
private boolean inSystem;
|
||||
|
||||
public VirtualHardware getResult() {
|
||||
return new VirtualHardware(info, system, allocations);
|
||||
public VirtualHardwareSection getResult() {
|
||||
return new VirtualHardwareSection(info, system, allocations);
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
|
@ -31,10 +31,10 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Status;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.VmImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudOperatingSystem;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
*
|
||||
* 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 java.util.Set;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ovf.NetworkSection;
|
||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkSectionHandler extends ParseSax.HandlerWithResult<NetworkSection> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected String info;
|
||||
protected String name;
|
||||
protected String description;
|
||||
|
||||
protected Set<Network> networks = Sets.newLinkedHashSet();
|
||||
|
||||
public NetworkSection getResult() {
|
||||
NetworkSection system = new NetworkSection(info, networks);
|
||||
this.info = null;
|
||||
this.networks = Sets.newLinkedHashSet();
|
||||
return system;
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
||||
if (qName.endsWith("Network")) {
|
||||
name = attributes.get("name");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
if (qName.endsWith("Info")) {
|
||||
this.info = currentOrNull();
|
||||
} else if (qName.endsWith("Description")) {
|
||||
this.description = currentOrNull();
|
||||
} else if (qName.endsWith("Network")) {
|
||||
this.networks.add(new Network(name, description));
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
}
|
|
@ -22,22 +22,22 @@ 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.domain.ovf.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OperatingSystemHandler extends ParseSax.HandlerWithResult<OperatingSystem> {
|
||||
public class OperatingSystemSectionHandler extends ParseSax.HandlerWithResult<OperatingSystemSection> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected Integer id;
|
||||
protected String info;
|
||||
protected String description;
|
||||
|
||||
public OperatingSystem getResult() {
|
||||
OperatingSystem system = new OperatingSystem(id, info, description);
|
||||
public OperatingSystemSection getResult() {
|
||||
OperatingSystemSection system = new OperatingSystemSection(id, info, description);
|
||||
id = null;
|
||||
info = null;
|
||||
description = null;
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
package org.jclouds.vcloud.xml.ovf;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
|
@ -72,9 +75,10 @@ public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<Resour
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
||||
if (qName.endsWith("Connection")) {
|
||||
connected = new Boolean(attributes.getValue(attributes.getIndex("connected")));
|
||||
connected = new Boolean(attributes.get("connected"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,14 @@
|
|||
|
||||
package org.jclouds.vcloud.xml.ovf;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -32,15 +36,15 @@ public class SystemHandler extends ParseSax.HandlerWithResult<System> {
|
|||
private String elementName;
|
||||
private int instanceID;
|
||||
private String virtualSystemIdentifier;
|
||||
private String virtualSystemType;
|
||||
private Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
|
||||
|
||||
public System getResult() {
|
||||
System system = new org.jclouds.vcloud.domain.ovf.System(instanceID, elementName, virtualSystemIdentifier,
|
||||
virtualSystemType);
|
||||
virtualSystemTypes);
|
||||
this.elementName = null;
|
||||
this.instanceID = -1;
|
||||
this.virtualSystemIdentifier = null;
|
||||
this.virtualSystemType = null;
|
||||
this.virtualSystemTypes = null;
|
||||
return system;
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,7 @@ public class SystemHandler extends ParseSax.HandlerWithResult<System> {
|
|||
} else if (qName.endsWith("VirtualSystemIdentifier")) {
|
||||
this.virtualSystemIdentifier = currentText.toString().trim();
|
||||
} else if (qName.endsWith("VirtualSystemType")) {
|
||||
this.virtualSystemType = currentText.toString().trim();
|
||||
this.virtualSystemTypes.add(currentText.toString().trim());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
*
|
||||
* 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 javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.ovf.NetworkSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult<VCloudNetworkSection> {
|
||||
private final NetworkSectionHandler networkSectionHandler;
|
||||
|
||||
@Inject
|
||||
VCloudNetworkSectionHandler(NetworkSectionHandler networkSectionHandler) {
|
||||
this.networkSectionHandler = networkSectionHandler;
|
||||
}
|
||||
|
||||
private ReferenceType net;
|
||||
|
||||
public VCloudNetworkSection getResult() {
|
||||
NetworkSection system = networkSectionHandler.getResult();
|
||||
return new VCloudNetworkSection(net.getType(), net.getHref(), system.getInfo(), system.getNetworks());
|
||||
}
|
||||
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
||||
if (qName.endsWith("NetworkSection")) {
|
||||
this.net = Utils.newReferenceType(attributes);
|
||||
}
|
||||
networkSectionHandler.startElement(uri, localName, qName, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
networkSectionHandler.endElement(uri, localName, qName);
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
networkSectionHandler.characters(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,26 +22,29 @@ package org.jclouds.vcloud.xml.ovf;
|
|||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
|
||||
import org.jclouds.vcloud.xml.VirtualHardwareHandler;
|
||||
import org.jclouds.vcloud.xml.VirtualHardwareSectionHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSystem> {
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
private final OperatingSystemHandler osHandler;
|
||||
private final VirtualHardwareHandler hardwareHandler;
|
||||
private final OperatingSystemSectionHandler osHandler;
|
||||
private final VirtualHardwareSectionHandler hardwareHandler;
|
||||
|
||||
@Inject
|
||||
public VirtualSystemHandler(OperatingSystemHandler osHandler, VirtualHardwareHandler hardwareHandler) {
|
||||
public VirtualSystemHandler(OperatingSystemSectionHandler osHandler, VirtualHardwareSectionHandler hardwareHandler) {
|
||||
this.osHandler = osHandler;
|
||||
this.hardwareHandler = hardwareHandler;
|
||||
}
|
||||
|
@ -49,8 +52,8 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSyst
|
|||
protected String id;
|
||||
protected String info;
|
||||
protected String name;
|
||||
protected OperatingSystem operatingSystem;
|
||||
protected VirtualHardware hardware;
|
||||
protected OperatingSystemSection operatingSystem;
|
||||
protected Set<VirtualHardwareSection> hardware = Sets.newLinkedHashSet();
|
||||
|
||||
private boolean inHardware;
|
||||
private boolean inOs;
|
||||
|
@ -63,7 +66,7 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSyst
|
|||
info = null;
|
||||
name = null;
|
||||
operatingSystem = null;
|
||||
hardware = null;
|
||||
hardware = Sets.newLinkedHashSet();
|
||||
return vs;
|
||||
}
|
||||
|
||||
|
@ -97,7 +100,7 @@ public class VirtualSystemHandler extends ParseSax.HandlerWithResult<VirtualSyst
|
|||
public void endElement(String uri, String localName, String qName) {
|
||||
if (qName.endsWith("VirtualHardwareSection")) {
|
||||
inHardware = false;
|
||||
hardware = hardwareHandler.getResult();
|
||||
hardware.add(hardwareHandler.getResult());
|
||||
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||
inOs = false;
|
||||
operatingSystem = osHandler.getResult();
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.jclouds.vcloud;
|
|||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.networkName;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -60,6 +60,7 @@ import org.jclouds.vcloud.domain.internal.OrgImpl;
|
|||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
@ -95,35 +96,15 @@ import domain.VCloudVersionsAsyncClient;
|
|||
@Test(groups = "unit", testName = "vcloud.VCloudAsyncClientTest")
|
||||
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||
|
||||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp", networkName("aloha")
|
||||
.fenceMode(FenceMode.NAT_ROUTED).network(
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991")));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), "my-vapp",
|
||||
addNetworkConfig(new NetworkConfig("aloha", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
|
@ -146,7 +127,9 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).network(URI.create("https://vcenterprise.bluelock.com/network/1990")));
|
||||
.disk(1024).addNetworkConfig(
|
||||
new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"),
|
||||
null)));
|
||||
}
|
||||
|
||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
|
|
@ -49,16 +49,17 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogImpl;
|
||||
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
@ -119,9 +120,12 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp", processorCount(1)
|
||||
.memory(512).disk(1024).fenceMode(FenceMode.BRIDGED).network(
|
||||
URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp",
|
||||
processorCount(1).memory(512).disk(1024)
|
||||
.addNetworkConfig(
|
||||
new NetworkConfig(null, URI
|
||||
.create("https://vcloud.safesecureweb.com/network/1990"),
|
||||
FenceMode.BRIDGED)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
|
@ -144,7 +148,9 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).network(URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||
.disk(1024).addNetworkConfig(
|
||||
new NetworkConfig("aloha", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"), null)));
|
||||
}
|
||||
|
||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
@ -750,8 +756,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(),
|
||||
new ReferenceTypeImpl("tasksList", VCloudExpressMediaType.TASKSLIST_XML, URI
|
||||
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
|
||||
VCloudExpressMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), ImmutableList
|
||||
.<Task> of()));
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static org.easymock.EasyMock.expect;
|
|||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -34,12 +35,17 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
|
@ -54,12 +60,19 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.BindInstantiateVAppTemplateParamsToXmlPayloadTest")
|
||||
public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector createInjector(URI vAppTemplate, VAppTemplate value) {
|
||||
final VCloudClient client = createMock(VCloudClient.class);
|
||||
|
||||
expect(client.getVAppTemplate(vAppTemplate)).andReturn(value).anyTimes();
|
||||
replay(client);
|
||||
|
||||
return Guice.createInjector(new AbstractModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
bind(VCloudClient.class).toInstance(client);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -70,8 +83,49 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testDefault() throws IOException {
|
||||
URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
VAppTemplate template = createMock(VAppTemplate.class);
|
||||
VCloudNetworkSection net = createMock(VCloudNetworkSection.class);
|
||||
|
||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||
request.setPayload(expected);
|
||||
|
||||
expect(template.getNetworkSection()).andReturn(net).atLeastOnce();
|
||||
expect(net.getNetworks())
|
||||
.andReturn(
|
||||
ImmutableSet
|
||||
.<org.jclouds.vcloud.domain.ovf.network.Network> of(new org.jclouds.vcloud.domain.ovf.network.Network(
|
||||
"vAppNet-vApp Internal", null)));
|
||||
|
||||
replay(request);
|
||||
replay(template);
|
||||
replay(net);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "my-vapp");
|
||||
map.put("template", templateUri.toASCIIString());
|
||||
binder.bindToRequest(request, map);
|
||||
|
||||
verify(request);
|
||||
verify(template);
|
||||
verify(net);
|
||||
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testWhenTemplateDoesntExist() throws IOException {
|
||||
URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
VAppTemplate template = null;
|
||||
|
||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/instantiationparams.xml"));
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
|
@ -79,12 +133,12 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "my-vapp");
|
||||
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
map.put("template", templateUri.toASCIIString());
|
||||
binder.bindToRequest(request, map);
|
||||
verify(request);
|
||||
|
||||
|
@ -93,6 +147,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
// TODO!!! figure out how to get this to work
|
||||
@Test(enabled = false)
|
||||
public void testWithProcessorMemoryDisk() throws IOException {
|
||||
URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
VAppTemplate template = null;
|
||||
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.processorCount(1).memory(512).disk(1024);
|
||||
|
||||
|
@ -103,8 +160,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "my-vapp");
|
||||
|
@ -116,10 +173,11 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
}
|
||||
|
||||
public void testWithNetworkNameFenceMode() throws IOException {
|
||||
URI templateUri = URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
VAppTemplate template = null;
|
||||
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.networkName("aloha").fenceMode(FenceMode.NAT_ROUTED).network(
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"));
|
||||
InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("aloha", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED));
|
||||
|
||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream("/instantiationparams-network.xml"));
|
||||
|
||||
|
@ -129,8 +187,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
request.setPayload(expected);
|
||||
replay(request);
|
||||
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = createInjector(templateUri, template).getInstance(
|
||||
BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||
|
||||
Map<String, String> map = Maps.newHashMap();
|
||||
map.put("name", "my-vapp");
|
||||
|
|
|
@ -19,11 +19,9 @@
|
|||
|
||||
package org.jclouds.vcloud.options;
|
||||
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.disk;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.fenceMode;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.inNetwork;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.memory;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.networkName;
|
||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -31,8 +29,10 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
@ -47,17 +47,21 @@ public class InstantiateVAppTemplateOptionsTest {
|
|||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
|
||||
@Test
|
||||
public void testInNetwork() {
|
||||
public void testAddNetworkConfig() {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.network(URI.create("http://localhost"));
|
||||
assertEquals(options.getNetwork(), "http://localhost");
|
||||
options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInNetworkStatic() {
|
||||
InstantiateVAppTemplateOptions options = inNetwork(URI
|
||||
.create("http://localhost"));
|
||||
assertEquals(options.getNetwork(), "http://localhost");
|
||||
public void testAddNetworkConfigStatic() {
|
||||
InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default", URI
|
||||
.create("http://localhost"), FenceMode.BRIDGED));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -103,31 +107,4 @@ public class InstantiateVAppTemplateOptionsTest {
|
|||
public void testDiskStaticWrong() {
|
||||
disk(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNetworkName() {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.networkName("network");
|
||||
assertEquals(options.getNetworkName(), "network");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNetworkNameStatic() {
|
||||
InstantiateVAppTemplateOptions options = networkName("network");
|
||||
assertEquals(options.getNetworkName(), "network");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFenceMode() {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.fenceMode(FenceMode.BRIDGED);
|
||||
assertEquals(options.getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFenceModeStatic() {
|
||||
InstantiateVAppTemplateOptions options = fenceMode(FenceMode.BRIDGED);
|
||||
assertEquals(options.getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@ import org.jclouds.vcloud.domain.Status;
|
|||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkSection;
|
||||
import org.jclouds.vcloud.domain.ovf.network.Network;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -73,6 +76,16 @@ public class VAppTemplateHandlerTest {
|
|||
assertEquals(vm.getDescription(), null);
|
||||
assertEquals(vm.getTasks(), ImmutableList.of());
|
||||
assertEquals(vm.getVAppScopedLocalId(), "02_ubuntu_template");
|
||||
|
||||
VCloudNetworkSection network = result.getNetworkSection();
|
||||
assertEquals(
|
||||
network.getHref(),
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-1201908921/networkSection/"));
|
||||
assertEquals(network.getType(), VCloudMediaType.NETWORKSECTION_XML);
|
||||
assertEquals(network.getInfo(), "The list of logical networks");
|
||||
assertEquals(network.getNetworks(), ImmutableSet.of(new Network("vAppNet-vApp Internal", null)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jclouds.vcloud.domain.Status;
|
|||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudOperatingSystemHandlerTest;
|
||||
import org.jclouds.vcloud.xml.ovf.VCloudVirtualHardwareHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.jclouds.http.functions.BaseHandlerTest;
|
|||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SystemHandler}
|
||||
*
|
||||
|
@ -40,7 +42,7 @@ public class SystemHandlerTest extends BaseHandlerTest {
|
|||
|
||||
System result = factory.create(injector.getInstance(SystemHandler.class)).parse(is);
|
||||
|
||||
System expects = new System(0, "Virtual Hardware Family", "SimpleVM", "vmx-04");
|
||||
System expects = new System(0, "Virtual Hardware Family", "SimpleVM", ImmutableSet.of("vmx-04"));
|
||||
assertEquals(result, expects);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
package org.jclouds.vcloud.xml.ovf;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -38,6 +38,7 @@ import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
|||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
|
|||
|
||||
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
||||
"10.150.4.93");
|
||||
System system = new System(0, "Virtual Hardware Family", "centos53", "vmx-07");
|
||||
System system = new System(0, "Virtual Hardware Family", "centos53", ImmutableSet.of("vmx-07"));
|
||||
|
||||
Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
|
||||
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
|
||||
|
@ -125,7 +126,7 @@ public class VCloudExpressVAppHandlerTest extends BaseHandlerTest {
|
|||
|
||||
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of("Public Network",
|
||||
"10.23.119.221");
|
||||
System system = new System(0, "Virtual Hardware Family", "m1", "vmx-07");
|
||||
System system = new System(0, "Virtual Hardware Family", "m1", ImmutableSet.of("vmx-07"));
|
||||
|
||||
Set<ResourceAllocation> resourceAllocations = ImmutableSet.<ResourceAllocation> of(new ResourceAllocation(1,
|
||||
"1 virtual CPU(s)", "Number of Virtual CPUs", ResourceType.PROCESSOR, null, null, null, null, null,
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
package org.jclouds.vcloud.xml.ovf;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -26,7 +26,6 @@ import java.net.URI;
|
|||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.vcloud.domain.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.ovf.EditableResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
|
@ -34,8 +33,11 @@ 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.VCloudVirtualHardware;
|
||||
import org.jclouds.vcloud.xml.VCloudVirtualHardwareHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +59,7 @@ public class VCloudVirtualHardwareHandlerTest extends BaseHandlerTest {
|
|||
|
||||
@Test(enabled = false)
|
||||
public static void checkHardware(VCloudVirtualHardware result) {
|
||||
System system = new System(0, "Virtual Hardware Family", "RHEL5", "vmx-07");
|
||||
System system = new System(0, "Virtual Hardware Family", "RHEL5", ImmutableSet.of("vmx-07"));
|
||||
|
||||
assertEquals(result.getHref(), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/"));
|
|
@ -26,17 +26,17 @@ 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.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudHardDisk;
|
||||
import org.jclouds.vcloud.domain.ovf.VCloudNetworkAdapter;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.domain.ovf.VirtualSystem;
|
||||
import org.jclouds.vcloud.xml.ovf.VirtualSystemHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -61,13 +61,14 @@ public class VirtualSystemHandlerTest {
|
|||
assertEquals(result.getId(), "Ubuntu1004");
|
||||
assertEquals(result.getName(), "Ubuntu1004");
|
||||
assertEquals(result.getInfo(), "A virtual machine:");
|
||||
checkHardware(result.getHardware());
|
||||
checkHardware(Iterables.get(result.getHardware(), 0));
|
||||
checkOs(result.getOperatingSystem());
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkHardware(VirtualHardware result) {
|
||||
assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "Ubuntu1004", "vmx-07"));
|
||||
public static void checkHardware(VirtualHardwareSection result) {
|
||||
assertEquals(result.getSystem(),
|
||||
new System(0, "Virtual Hardware Family", "Ubuntu1004", ImmutableSet.of("vmx-07")));
|
||||
assertEquals(result.getInfo(), "Virtual hardware requirements");
|
||||
|
||||
assertEquals(Iterables.get(result.getResourceAllocations(), 0), new VCloudNetworkAdapter(1, "Network adapter 0",
|
||||
|
@ -97,7 +98,7 @@ public class VirtualSystemHandlerTest {
|
|||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public static void checkOs(OperatingSystem result) {
|
||||
public static void checkOs(OperatingSystemSection result) {
|
||||
assertEquals(result.getDescription(), "Ubuntu Linux (64-bit)");
|
||||
assertEquals(result.getId(), new Integer(94));
|
||||
assertEquals(result.getInfo(), "Specifies the operating system installed");
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
package org.jclouds.vcloud.terremark.options;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.inject.internal.util.Maps;
|
||||
|
@ -92,11 +92,11 @@ public class TerremarkInstantiateVAppTemplateOptions extends InstantiateVAppTemp
|
|||
}
|
||||
|
||||
/**
|
||||
* @see TerremarkInstantiateVAppTemplateOptions#network(URI)
|
||||
* @see TerremarkInstantiateVAppTemplateOptions#addNetworkConfig
|
||||
*/
|
||||
public static TerremarkInstantiateVAppTemplateOptions inNetwork(URI networkLocation) {
|
||||
public static TerremarkInstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
return options.network(networkLocation);
|
||||
return options.addNetworkConfig(networkConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,8 +171,8 @@ public class TerremarkInstantiateVAppTemplateOptions extends InstantiateVAppTemp
|
|||
}
|
||||
|
||||
@Override
|
||||
public TerremarkInstantiateVAppTemplateOptions network(URI networkLocation) {
|
||||
return (TerremarkInstantiateVAppTemplateOptions) super.network(networkLocation);
|
||||
public TerremarkInstantiateVAppTemplateOptions addNetworkConfig(NetworkConfig networkConfig) {
|
||||
return (TerremarkInstantiateVAppTemplateOptions) super.addNetworkConfig(networkConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExt
|
|||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudExpressAsyncClientTest.TerremarkVCloudRestClientModuleExtension.TestOrgNameToKeysListSupplier;
|
||||
|
@ -146,7 +147,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row").network(URI.create("http://network")));
|
||||
.withPassword("password").inRow("row").addNetworkConfig(
|
||||
new NetworkConfig(URI.create("http://network"))));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
|
|
|
@ -54,12 +54,13 @@ import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExt
|
|||
import org.jclouds.vcloud.domain.AllocationModel;
|
||||
import org.jclouds.vcloud.domain.Capacity;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.VDCStatus;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.config.TerremarkVCloudExpressRestClientModule;
|
||||
|
@ -195,7 +196,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row").network(URI.create("http://network")));
|
||||
.withPassword("password").inRow("row").addNetworkConfig(
|
||||
new NetworkConfig(URI.create("http://network"))));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
|
|
|
@ -33,6 +33,7 @@ import javax.inject.Singleton;
|
|||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder;
|
||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||
|
@ -83,8 +84,8 @@ public class TerremarkBindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||
expect(request.getArgs()).andReturn(
|
||||
new Object[] { TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup(
|
||||
"group").withPassword("password").inRow("row").network(URI.create("http://network")) })
|
||||
.atLeastOnce();
|
||||
"group").withPassword("password").inRow("row").addNetworkConfig(
|
||||
new NetworkConfig(URI.create("http://network"))) }).atLeastOnce();
|
||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn("application/unknown").atLeastOnce();
|
||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||
request.setPayload(expected);
|
||||
|
|
|
@ -19,21 +19,23 @@
|
|||
|
||||
package org.jclouds.vcloud.terremark.options;
|
||||
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.addNetworkConfig;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.disk;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.inGroup;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.inNetwork;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.inRow;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.memory;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.disk;
|
||||
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.withPassword;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
|
@ -87,16 +89,21 @@ public class TerremarkInstantiateVAppTemplateOptionsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInNetwork() {
|
||||
public void testAddNetworkConfig() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = new TerremarkInstantiateVAppTemplateOptions();
|
||||
options.network(URI.create("http://localhost"));
|
||||
assertEquals(options.getNetwork(), "http://localhost");
|
||||
options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInNetworkStatic() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = inNetwork(URI.create("http://localhost"));
|
||||
assertEquals(options.getNetwork(), "http://localhost");
|
||||
public void testAddNetworkConfigStatic() {
|
||||
TerremarkInstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default", URI
|
||||
.create("http://localhost"), FenceMode.BRIDGED));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default");
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost"));
|
||||
assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -109,7 +109,7 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
|||
assertEquals(result.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
|
||||
|
||||
assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "centos-53", "vmx-07"));
|
||||
assertEquals(result.getSystem(), new System(0, "Virtual Hardware Family", "centos-53", ImmutableSet.of("vmx-07")));
|
||||
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",
|
||||
|
@ -147,7 +147,7 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
|||
assertEquals(vApp.getVDC(), new ReferenceTypeImpl(null, VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")));
|
||||
|
||||
assertEquals(vApp.getSystem(), new System(0, "Virtual Hardware Family", "eduardo", "vmx-07"));
|
||||
assertEquals(vApp.getSystem(), new System(0, "Virtual Hardware Family", "eduardo", ImmutableSet.of("vmx-07")));
|
||||
assertEquals(vApp.getNetworkToAddresses().get("Internal"), ImmutableList.of("10.114.34.131"));
|
||||
|
||||
ResourceAllocation cpu = new ResourceAllocation(1, "2 virtual CPU(s)", "Number of Virtual CPUs",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.terremark.xml;
|
||||
package org.jclouds.vcloud.terremark.xml.ovf;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -29,6 +29,8 @@ import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
|||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VirtualSystemHandler}
|
||||
*
|
||||
|
@ -50,6 +52,6 @@ public class SystemHandlerTest extends BaseHandlerTest {
|
|||
assertEquals(result.getName(), "Virtual Hardware Family");
|
||||
assertEquals(result.getId(), 0);
|
||||
assertEquals(result.getIdentifier(), "adriantest1");
|
||||
assertEquals(result.getType(), "vmx-07");
|
||||
assertEquals(result.getVirtualSystemTypes(), ImmutableSet.of("vmx-07"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue