mirror of https://github.com/apache/jclouds.git
Issue 229: added network name, dhcp, and fencmode
This commit is contained in:
parent
31d2b08b71
commit
ea3f0b1fcd
|
@ -19,6 +19,8 @@
|
||||||
package org.jclouds.vcloud;
|
package org.jclouds.vcloud;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
|
||||||
|
@ -31,6 +33,7 @@ import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in VCloud Clients
|
* Builds properties used in VCloud Clients
|
||||||
|
@ -44,7 +47,10 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
|
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v0.8");
|
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v0.8");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
||||||
|
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED, "false");
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.ALLOW_IN_OUT.toString());
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,15 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CPUCOUNT;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CPUCOUNT;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DISK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DISK;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_MEMORY;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_MEMORY;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
@ -67,7 +70,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap.of(
|
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap.of(
|
||||||
ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9");
|
ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9");
|
||||||
|
|
||||||
private final String defaultNetwork;
|
private final URI defaultNetwork;
|
||||||
|
private final FenceMode defaultFenceMode;
|
||||||
|
private final boolean defaultDhcpEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To allow for optional injection, since guice doesn't allow unresolved constants in
|
* To allow for optional injection, since guice doesn't allow unresolved constants in
|
||||||
|
@ -89,13 +94,17 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||||
|
@Named(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED) String defaultDhcpEnabled,
|
||||||
|
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String defaultFenceMode,
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||||
OptionalConstantsHolder defaultsHolder) {
|
OptionalConstantsHolder defaultsHolder) {
|
||||||
this.ns = ns;
|
this.ns = ns;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
this.stringBinder = stringBinder;
|
this.stringBinder = stringBinder;
|
||||||
this.defaultVirtualHardwareQuantity = Maps.newHashMap();
|
this.defaultVirtualHardwareQuantity = Maps.newHashMap();
|
||||||
this.defaultNetwork = network;
|
this.defaultNetwork = URI.create(network);
|
||||||
|
this.defaultFenceMode = FenceMode.fromValue(defaultFenceMode);
|
||||||
|
this.defaultDhcpEnabled = Boolean.parseBoolean(defaultDhcpEnabled);
|
||||||
if (defaultsHolder.cpuCount != null)
|
if (defaultsHolder.cpuCount != null)
|
||||||
this.defaultVirtualHardwareQuantity.put(ResourceType.PROCESSOR, defaultsHolder.cpuCount);
|
this.defaultVirtualHardwareQuantity.put(ResourceType.PROCESSOR, defaultsHolder.cpuCount);
|
||||||
if (defaultsHolder.memorySizeMegabytes != null)
|
if (defaultsHolder.memorySizeMegabytes != null)
|
||||||
|
@ -115,6 +124,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
String name = checkNotNull(postParams.remove("name"), "name");
|
String name = checkNotNull(postParams.remove("name"), "name");
|
||||||
String template = checkNotNull(postParams.remove("template"), "template");
|
String template = checkNotNull(postParams.remove("template"), "template");
|
||||||
String network = postParams.remove("network");
|
String network = postParams.remove("network");
|
||||||
|
String fenceMode = postParams.remove("fenceMode");
|
||||||
|
String dhcpEnabled = postParams.remove("dhcpEnabled");
|
||||||
|
String networkName = postParams.remove("networkName");
|
||||||
|
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity = extractVirtualQuantityFromPostParams(postParams);
|
SortedMap<ResourceType, String> virtualHardwareQuantity = extractVirtualQuantityFromPostParams(postParams);
|
||||||
|
|
||||||
|
@ -126,10 +138,12 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
network = networkFromOptions != null ? networkFromOptions : network;
|
network = networkFromOptions != null ? networkFromOptions : network;
|
||||||
properties.putAll(options.getProperties());
|
properties.putAll(options.getProperties());
|
||||||
}
|
}
|
||||||
network = network == null ? defaultNetwork : network;
|
|
||||||
try {
|
try {
|
||||||
stringBinder.bindToRequest(request, generateXml(name, template, properties,
|
stringBinder.bindToRequest(request, generateXml(name, template, properties,
|
||||||
virtualHardwareQuantity, network));
|
virtualHardwareQuantity, networkName == null ? name : networkName,
|
||||||
|
fenceMode == null ? defaultFenceMode : FenceMode.fromValue(fenceMode),
|
||||||
|
dhcpEnabled == null ? defaultDhcpEnabled : Boolean.parseBoolean(dhcpEnabled),
|
||||||
|
network == null ? defaultNetwork : URI.create(network)));
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (FactoryConfigurationError e) {
|
} catch (FactoryConfigurationError e) {
|
||||||
|
@ -151,8 +165,9 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String generateXml(String name, String template, Map<String, String> properties,
|
protected String generateXml(String name, String template, Map<String, String> properties,
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity, String network)
|
SortedMap<ResourceType, String> virtualHardwareQuantity, String networkName,
|
||||||
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
FenceMode fenceMode, boolean dhcp, URI network) throws ParserConfigurationException,
|
||||||
|
FactoryConfigurationError, TransformerException {
|
||||||
XMLBuilder rootBuilder = buildRoot(name);
|
XMLBuilder rootBuilder = buildRoot(name);
|
||||||
|
|
||||||
rootBuilder.e("VAppTemplate").a("href", template);
|
rootBuilder.e("VAppTemplate").a("href", template);
|
||||||
|
@ -160,7 +175,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
|
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
|
||||||
addPropertiesifPresent(instantiationParamsBuilder, properties);
|
addPropertiesifPresent(instantiationParamsBuilder, properties);
|
||||||
addVirtualQuantityIfPresent(instantiationParamsBuilder, virtualHardwareQuantity);
|
addVirtualQuantityIfPresent(instantiationParamsBuilder, virtualHardwareQuantity);
|
||||||
addNetworkConfig(instantiationParamsBuilder, name, network);
|
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode, dhcp, network);
|
||||||
Properties outputProperties = new Properties();
|
Properties outputProperties = new Properties();
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
return rootBuilder.asString(outputProperties);
|
return rootBuilder.asString(outputProperties);
|
||||||
|
@ -180,13 +195,13 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name,
|
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name,
|
||||||
String network) {
|
FenceMode fenceMode, boolean dhcp, URI network) {
|
||||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e(
|
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e(
|
||||||
"NetworkConfig").a("name", name);
|
"NetworkConfig").a("name", name);
|
||||||
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
|
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
|
||||||
featuresBuilder.e("FenceMode").t(FenceMode.ALLOW_IN_OUT.value());
|
featuresBuilder.e("FenceMode").t(fenceMode.value());
|
||||||
featuresBuilder.e("Dhcp").t("false");
|
featuresBuilder.e("Dhcp").t(dhcp + "");
|
||||||
networkConfigBuilder.e("NetworkAssociation").a("href", network);
|
networkConfigBuilder.e("NetworkAssociation").a("href", network.toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addVirtualQuantityIfPresent(XMLBuilder instantiationParamsBuilder,
|
protected void addVirtualQuantityIfPresent(XMLBuilder instantiationParamsBuilder,
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute;
|
package org.jclouds.vcloud.compute;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -69,16 +69,14 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
|
||||||
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
this.vAppStatusToNodeState = vAppStatusToNodeState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> start(String vDCId, String name, String templateId, int minCores,
|
@Override
|
||||||
int minMegs, Long diskSize, Map<String, String> properties, int... portsToOpen) {
|
public Map<String, String> start(String vDCId, String name, String templateId,
|
||||||
logger
|
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||||
.debug(
|
checkNotNull(options, "options");
|
||||||
">> instantiating vApp vDC(%s) name(%s) template(%s) minCores(%d) minMegs(%d) diskSize(%d) properties(%s) ",
|
|
||||||
vDCId, name, templateId, minCores, minMegs, diskSize, properties);
|
logger.debug(">> instantiating vApp vDC(%s) name(%s) template(%s) options(%s) ", vDCId, name,
|
||||||
InstantiateVAppTemplateOptions options = processorCount(minCores).memory(minMegs)
|
templateId, options);
|
||||||
.productProperties(properties);
|
|
||||||
if (diskSize != null)
|
|
||||||
options.disk(diskSize);
|
|
||||||
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vDCId, name, templateId, options);
|
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vDCId, name, templateId, options);
|
||||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
@ -50,10 +50,8 @@ public interface VCloudComputeClient {
|
||||||
* amount of virtual cpu cores
|
* amount of virtual cpu cores
|
||||||
* @param megs
|
* @param megs
|
||||||
* amount of ram in megabytes
|
* amount of ram in megabytes
|
||||||
* @param diskSizeKilobytes
|
* @param options
|
||||||
* size of disk in kilobytes, null is ok
|
* options for instantiating the vApp; null is ok
|
||||||
* @param properties
|
|
||||||
* sets product properties on the vApp
|
|
||||||
* @param portsToOpen
|
* @param portsToOpen
|
||||||
* opens the following ports on the public ip address
|
* opens the following ports on the public ip address
|
||||||
* @return map contains at least the following properties
|
* @return map contains at least the following properties
|
||||||
|
@ -62,8 +60,8 @@ public interface VCloudComputeClient {
|
||||||
* login password</li>
|
* login password</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
Map<String, String> start(String vDCId, String name, String templateId, int cores, int megs,
|
Map<String, String> start(String vDCId, String name, String templateId,
|
||||||
@Nullable Long diskSizeKilobytes, Map<String, String> properties, int... portsToOpen);
|
InstantiateVAppTemplateOptions options, int... portsToOpen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a set of addresses that are only visible to the private network.
|
* returns a set of addresses that are only visible to the private network.
|
||||||
|
|
|
@ -21,9 +21,12 @@ package org.jclouds.vcloud.compute.config;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
|
||||||
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
@ -83,6 +86,7 @@ import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
import org.jclouds.vcloud.domain.VDC;
|
||||||
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -188,11 +192,15 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(String tag, String name, Template template) {
|
public NodeMetadata execute(String tag, String name, Template template) {
|
||||||
|
|
||||||
|
InstantiateVAppTemplateOptions options = processorCount(
|
||||||
|
Double.valueOf(template.getSize().getCores()).intValue()).memory(
|
||||||
|
template.getSize().getRam()).disk(template.getSize().getDisk() * 1024 * 1024l);
|
||||||
|
|
||||||
|
options.networkName("templateId=" + template.getImage().getId());
|
||||||
|
|
||||||
Map<String, String> metaMap = computeClient.start(template.getLocation().getId(), name,
|
Map<String, String> metaMap = computeClient.start(template.getLocation().getId(), name,
|
||||||
template.getImage().getId(), Double.valueOf(template.getSize().getCores())
|
template.getImage().getId(), options, template.getOptions().getInboundPorts());
|
||||||
.intValue(), template.getSize().getRam(),
|
|
||||||
template.getSize().getDisk() * 1024 * 1024l, ImmutableMap.<String, String> of(),
|
|
||||||
template.getOptions().getInboundPorts());
|
|
||||||
VApp vApp = client.getVApp(metaMap.get("id"));
|
VApp vApp = client.getVApp(metaMap.get("id"));
|
||||||
return newCreateNodeResponse(tag, template, metaMap, vApp);
|
return newCreateNodeResponse(tag, template, metaMap, vApp);
|
||||||
}
|
}
|
||||||
|
@ -305,10 +313,13 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
extra.put("processor/count", Iterables.getOnlyElement(
|
extra.put("processor/count", Iterables.getOnlyElement(
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)).getVirtualQuantity()
|
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)).getVirtualQuantity()
|
||||||
+ "");
|
+ "");
|
||||||
|
|
||||||
for (ResourceAllocation disk : vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)) {
|
for (ResourceAllocation disk : vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)) {
|
||||||
extra.put(String.format("disk_drive/%s/kb", disk.getId()), disk.getVirtualQuantity() + "");
|
extra.put(String.format("disk_drive/%s/kb", disk.getId()), disk.getVirtualQuantity() + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Entry<String, InetAddress> net : vApp.getNetworkToAddresses().entries()) {
|
||||||
|
extra.put(String.format("network/%s/ip", net.getKey()), net.getValue().getHostAddress());
|
||||||
|
}
|
||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +40,9 @@ public class InstantiateVAppTemplateOptions {
|
||||||
private String diskSizeKilobytes;
|
private String diskSizeKilobytes;
|
||||||
private String network;
|
private String network;
|
||||||
private Map<String, String> properties = Maps.newTreeMap();
|
private Map<String, String> properties = Maps.newTreeMap();
|
||||||
|
private String fenceMode;
|
||||||
|
private String dhcpEnabled;
|
||||||
|
private String networkName;
|
||||||
|
|
||||||
public InstantiateVAppTemplateOptions productProperty(String key, String value) {
|
public InstantiateVAppTemplateOptions productProperty(String key, String value) {
|
||||||
properties.put(checkNotNull(key, "key"), checkNotNull(value, "value"));
|
properties.put(checkNotNull(key, "key"), checkNotNull(value, "value"));
|
||||||
|
@ -55,6 +60,21 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InstantiateVAppTemplateOptions networkName(String networkName) {
|
||||||
|
this.networkName = checkNotNull(networkName, "networkName");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||||
|
this.fenceMode = checkNotNull(fenceMode, "fenceMode").toString();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstantiateVAppTemplateOptions dhcpEnabled(boolean dhcpEnabled) {
|
||||||
|
this.dhcpEnabled = dhcpEnabled + "";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public InstantiateVAppTemplateOptions memory(long megabytes) {
|
public InstantiateVAppTemplateOptions memory(long megabytes) {
|
||||||
checkArgument(megabytes % 512 == 0, "megabytes must be in an increment of 512");
|
checkArgument(megabytes % 512 == 0, "megabytes must be in an increment of 512");
|
||||||
this.memorySizeMegabytes = megabytes + "";
|
this.memorySizeMegabytes = megabytes + "";
|
||||||
|
@ -88,6 +108,18 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return network;
|
return network;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNetworkName() {
|
||||||
|
return networkName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFenceMode() {
|
||||||
|
return fenceMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDhcpEnabled() {
|
||||||
|
return dhcpEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +158,30 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return options.inNetwork(networkLocation);
|
return options.inNetwork(networkLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#fenceMode(FenceMode)
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.fenceMode(fenceMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#dhcpEnabled(boolean)
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions dhcpEnabled(boolean dhcpEnabled) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.dhcpEnabled(dhcpEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see InstantiateVAppTemplateOptions#networkName(String)
|
||||||
|
*/
|
||||||
|
public static InstantiateVAppTemplateOptions networkName(String networkName) {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
return options.networkName(networkName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see InstantiateVAppTemplateOptions#productProperty(String,String)
|
* @see InstantiateVAppTemplateOptions#productProperty(String,String)
|
||||||
*/
|
*/
|
||||||
|
@ -143,4 +199,12 @@ public class InstantiateVAppTemplateOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InstantiateVAppTemplateOptions [cpuCount=" + cpuCount + ", memorySizeMegabytes="
|
||||||
|
+ memorySizeMegabytes + ", diskSizeKilobytes=" + diskSizeKilobytes + ", network="
|
||||||
|
+ network + ", networkName=" + networkName + ", fenceMode=" + fenceMode
|
||||||
|
+ ", dhcpEnabled=" + dhcpEnabled + ", properties=" + properties + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,9 @@ public interface VCloudConstants {
|
||||||
/**
|
/**
|
||||||
* megabytes
|
* megabytes
|
||||||
*/
|
*/
|
||||||
|
public static final String PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED = "jclouds.vcloud.defaults.dhcpenabled";
|
||||||
|
public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
|
||||||
|
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_MEMORY = "jclouds.vcloud.defaults.memorysizemegabytes";
|
public static final String PROPERTY_VCLOUD_DEFAULT_MEMORY = "jclouds.vcloud.defaults.memorysizemegabytes";
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
|
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
package org.jclouds.vcloud;
|
package org.jclouds.vcloud;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
||||||
|
@ -43,6 +45,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
import org.jclouds.vcloud.endpoints.Catalog;
|
import org.jclouds.vcloud.endpoints.Catalog;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
import org.jclouds.vcloud.endpoints.TasksList;
|
import org.jclouds.vcloud.endpoints.TasksList;
|
||||||
|
@ -517,6 +520,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED, "false");
|
||||||
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.ALLOW_IN_OUT.toString());
|
||||||
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
||||||
"https://vcloud.safesecureweb.com/network/1990");
|
"https://vcloud.safesecureweb.com/network/1990");
|
||||||
props.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v0.8");
|
props.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v0.8");
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
import org.jclouds.vcloud.domain.ResourceType;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -65,7 +66,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
public void testDefault() throws IOException {
|
public void testDefault() throws IOException {
|
||||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
"/newvapp-hosting.xml"));
|
"/newvapp-hosting.xml"));
|
||||||
|
@ -90,7 +90,6 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWithProcessorMemoryDisk() throws IOException {
|
public void testWithProcessorMemoryDisk() throws IOException {
|
||||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
"/newvapp-hostingcpumemdisk.xml"));
|
"/newvapp-hostingcpumemdisk.xml"));
|
||||||
|
@ -120,4 +119,33 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
verify(request);
|
verify(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWithNetworkNameDhcpFenceMode() throws IOException {
|
||||||
|
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/newvapp-hostingnetworknamedhcpfencemode.xml"));
|
||||||
|
Multimap<String, String> headers = Multimaps.synchronizedMultimap(HashMultimap
|
||||||
|
.<String, String> create());
|
||||||
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
|
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
||||||
|
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||||
|
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null).atLeastOnce();
|
||||||
|
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||||
|
request.setPayload(expected);
|
||||||
|
replay(request);
|
||||||
|
|
||||||
|
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||||
|
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||||
|
|
||||||
|
Map<String, String> map = Maps.newHashMap();
|
||||||
|
map.put("name", "CentOS 01");
|
||||||
|
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||||
|
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||||
|
map.put("networkName", "aloha");
|
||||||
|
map.put("fenceMode", FenceMode.BRIDGED.toString());
|
||||||
|
map.put("dhcpEnabled", "true");
|
||||||
|
|
||||||
|
binder.bindToRequest(request, map);
|
||||||
|
verify(request);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.vcloud.compute;
|
package org.jclouds.vcloud.compute;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -37,6 +38,7 @@ import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
import org.jclouds.vcloud.domain.ResourceType;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -86,11 +88,12 @@ public class VCloudComputeClientLiveTest {
|
||||||
String serverName = getCompatibleServerName(toTest);
|
String serverName = getCompatibleServerName(toTest);
|
||||||
int processorCount = 1;
|
int processorCount = 1;
|
||||||
int memory = 512;
|
int memory = 512;
|
||||||
long disk = 10 * 1025 * 1024;
|
|
||||||
Map<String, String> properties = ImmutableMap.of("foo", "bar");
|
|
||||||
|
|
||||||
id = computeClient.start(client.getDefaultVDC().getId(), serverName, templateId,
|
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024)
|
||||||
processorCount, memory, disk, properties).get("id");
|
.productProperties(ImmutableMap.of("foo", "bar"));
|
||||||
|
|
||||||
|
id = computeClient.start(client.getDefaultVDC().getId(), serverName, templateId, options)
|
||||||
|
.get("id");
|
||||||
Expectation expectation = expectationMap.get(toTest);
|
Expectation expectation = expectationMap.get(toTest);
|
||||||
|
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
|
@ -150,8 +153,7 @@ public class VCloudComputeClientLiveTest {
|
||||||
client = injector.getInstance(VCloudClient.class);
|
client = injector.getInstance(VCloudClient.class);
|
||||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
||||||
}));
|
}));
|
||||||
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(
|
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(OsFamily.CENTOS,
|
||||||
OsFamily.CENTOS,
|
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
|
||||||
service = "vcloudtest";
|
service = "vcloudtest";
|
||||||
templateId = "3";
|
templateId = "3";
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
assert allData.getExtra().get("processor/count") != null;
|
assert allData.getExtra().get("processor/count") != null;
|
||||||
assert allData.getExtra().get("disk_drive/1/kb") != null;
|
assert allData.getExtra().get("disk_drive/1/kb") != null;
|
||||||
assert allData.getExtra().get("memory/mb") != null;
|
assert allData.getExtra().get("memory/mb") != null;
|
||||||
|
System.out.println(allData.getExtra());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,15 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.options;
|
package org.jclouds.vcloud.options;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.dhcpEnabled;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.disk;
|
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.inNetwork;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.memory;
|
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;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
|
@ -104,4 +108,43 @@ public class InstantiateVAppTemplateOptionsTest {
|
||||||
disk(0);
|
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.BLOCK_IN_OUT);
|
||||||
|
assertEquals(options.getFenceMode(), "blockInOut");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFenceModeStatic() {
|
||||||
|
InstantiateVAppTemplateOptions options = fenceMode(FenceMode.BLOCK_IN_OUT);
|
||||||
|
assertEquals(options.getFenceMode(), "blockInOut");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDhcpEnabled() {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
options.dhcpEnabled(true);
|
||||||
|
assertEquals(options.getDhcpEnabled(), "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDhcpEnabledStatic() {
|
||||||
|
InstantiateVAppTemplateOptions options = dhcpEnabled(true);
|
||||||
|
assertEquals(options.getDhcpEnabled(), "true");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="CentOS 01" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://vcloud.safesecureweb.com/ns/vcloud.xsd"><VAppTemplate href="https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"/><InstantiationParams><NetworkConfigSection><NetworkConfig name="aloha"><Features><FenceMode>bridged</FenceMode><Dhcp>true</Dhcp></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
|
@ -18,12 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark.binders;
|
package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
import org.jclouds.vcloud.domain.ResourceType;
|
||||||
|
|
||||||
import com.jamesmurty.utils.XMLBuilder;
|
import com.jamesmurty.utils.XMLBuilder;
|
||||||
|
@ -53,22 +56,25 @@ public class TerremarkBindInstantiateVAppTemplateParamsToXmlPayload extends
|
||||||
public TerremarkBindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
public TerremarkBindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||||
|
@Named(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED) String defaultDhcpEnabled,
|
||||||
|
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String defaultFenceMode,
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||||
OptionalConstantsHolder optionalDefaults) {
|
OptionalConstantsHolder optionalDefaults) {
|
||||||
super(stringBinder, ns, schema, network, optionalDefaults);
|
super(stringBinder, ns, schema, defaultDhcpEnabled, defaultFenceMode, network,
|
||||||
|
optionalDefaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String generateXml(String name, String template, Map<String, String> properties,
|
protected String generateXml(String name, String template, Map<String, String> properties,
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity, String network)
|
SortedMap<ResourceType, String> virtualHardwareQuantity, String networkName,
|
||||||
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
FenceMode fenceMode, boolean dhcp, URI network) throws ParserConfigurationException,
|
||||||
|
FactoryConfigurationError, TransformerException {
|
||||||
checkNotNull(virtualHardwareQuantity.get(ResourceType.PROCESSOR),
|
checkNotNull(virtualHardwareQuantity.get(ResourceType.PROCESSOR),
|
||||||
"cpuCount must be present in instantiateVapp on terremark");
|
"cpuCount must be present in instantiateVapp on terremark");
|
||||||
checkNotNull(virtualHardwareQuantity.get(ResourceType.MEMORY),
|
checkNotNull(virtualHardwareQuantity.get(ResourceType.MEMORY),
|
||||||
"memorySizeMegabytes must be present in instantiateVapp on terremark");
|
"memorySizeMegabytes must be present in instantiateVapp on terremark");
|
||||||
checkArgument(virtualHardwareQuantity.get(ResourceType.DISK_DRIVE) == null,
|
return super.generateXml(name, template, properties, virtualHardwareQuantity, networkName,
|
||||||
"diskSizeKilobytes no settable on instantiateVapp on terremark");
|
fenceMode, dhcp, network);
|
||||||
return super.generateXml(name, template, properties, virtualHardwareQuantity, network);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
import org.jclouds.vcloud.domain.Task;
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
@ -68,10 +69,12 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> start(String vDCId, String name, String templateId, int minCores,
|
public Map<String, String> start(String vDCId, String name, String templateId,
|
||||||
int minMegs, Long diskSize, Map<String, String> properties, int... portsToOpen) {
|
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||||
Map<String, String> response = super.start(vDCId, name, templateId, minCores, minMegs, null,
|
if (options.getDiskSizeKilobytes() != null) {
|
||||||
properties, portsToOpen);// trmk does not support resizing the primary disk
|
logger.warn("trmk does not support resizing the primary disk; unsetting disk size");
|
||||||
|
}
|
||||||
|
Map<String, String> response = super.start(vDCId, name, templateId, options, portsToOpen);
|
||||||
if (portsToOpen.length > 0)
|
if (portsToOpen.length > 0)
|
||||||
createPublicAddressMappedToPorts(response.get("id"), portsToOpen);
|
createPublicAddressMappedToPorts(response.get("id"), portsToOpen);
|
||||||
return response;
|
return response;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CPUCOUNT;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CPUCOUNT;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_MEMORY;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_MEMORY;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||||
|
@ -48,6 +50,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
|
import org.jclouds.vcloud.domain.FenceMode;
|
||||||
import org.jclouds.vcloud.endpoints.Catalog;
|
import org.jclouds.vcloud.endpoints.Catalog;
|
||||||
import org.jclouds.vcloud.endpoints.Network;
|
import org.jclouds.vcloud.endpoints.Network;
|
||||||
import org.jclouds.vcloud.endpoints.VCloudApi;
|
import org.jclouds.vcloud.endpoints.VCloudApi;
|
||||||
|
@ -561,6 +564,8 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED, "false");
|
||||||
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.ALLOW_IN_OUT.toString());
|
||||||
props.setProperty(PROPERTY_VCLOUD_DEFAULT_CPUCOUNT, "1");
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_CPUCOUNT, "1");
|
||||||
props.setProperty(PROPERTY_VCLOUD_DEFAULT_MEMORY, "512");
|
props.setProperty(PROPERTY_VCLOUD_DEFAULT_MEMORY, "512");
|
||||||
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
||||||
|
|
Loading…
Reference in New Issue