mirror of https://github.com/apache/jclouds.git
Issue 280: refactoring to support vcloud 0.9
This commit is contained in:
parent
0fca2cba0c
commit
250f6140ee
|
@ -19,14 +19,14 @@
|
||||||
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_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;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_API;
|
||||||
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -45,13 +45,11 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
|
properties.setProperty(PROPERTY_VCLOUD_VERSION_API, "0.8");
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 8 * 60 + "");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
||||||
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
"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());
|
|
||||||
properties.setProperty("jclouds.dns_name_length_min", "1");
|
properties.setProperty("jclouds.dns_name_length_min", "1");
|
||||||
properties.setProperty("jclouds.dns_name_length_max", "80");
|
properties.setProperty("jclouds.dns_name_length_max", "80");
|
||||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED,
|
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED,
|
||||||
|
@ -62,18 +60,32 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
||||||
public VCloudPropertiesBuilder(Properties properties) {
|
public VCloudPropertiesBuilder(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
setNs();
|
setNs();
|
||||||
|
setFenceMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNs() {
|
protected void setNs() {
|
||||||
if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
|
if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
|
||||||
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
|
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
|
||||||
"http://www.vmware.com/vcloud/v"
|
"http://www.vmware.com/vcloud/v"
|
||||||
+ properties.getProperty(PROPERTY_VCLOUD_VERSION));
|
+ properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setFenceMode() {
|
||||||
|
if (properties.getProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) == null) {
|
||||||
|
if (properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA).startsWith(
|
||||||
|
"0.8"))
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE,
|
||||||
|
"allowInOut");
|
||||||
|
else
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE,
|
||||||
|
FenceMode.BRIDGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public VCloudPropertiesBuilder(URI endpoint, String id, String secret) {
|
public VCloudPropertiesBuilder(URI endpoint, String id, String secret) {
|
||||||
super();
|
super();
|
||||||
setNs();
|
setNs();
|
||||||
|
setFenceMode();
|
||||||
withCredentials(id, secret);
|
withCredentials(id, secret);
|
||||||
withEndpoint(endpoint);
|
withEndpoint(endpoint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,7 @@ package org.jclouds.vcloud.binders;
|
||||||
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 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_DHCP_ENABLED;
|
|
||||||
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_FENCEMODE;
|
||||||
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;
|
||||||
|
@ -36,6 +32,7 @@ import java.util.Properties;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.xml.parsers.FactoryConfigurationError;
|
import javax.xml.parsers.FactoryConfigurationError;
|
||||||
|
@ -46,7 +43,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.MapBinder;
|
import org.jclouds.rest.MapBinder;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.vcloud.domain.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
import org.jclouds.vcloud.domain.ResourceType;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
|
||||||
|
@ -66,84 +62,57 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
protected final String ns;
|
protected final String ns;
|
||||||
protected final String schema;
|
protected final String schema;
|
||||||
private final BindToStringPayload stringBinder;
|
private final BindToStringPayload stringBinder;
|
||||||
protected final Map<ResourceType, String> defaultVirtualHardwareQuantity;
|
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap
|
||||||
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap.of(
|
.of(ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2",
|
||||||
ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9");
|
ResourceType.DISK_DRIVE, "9");
|
||||||
|
|
||||||
private final URI defaultNetwork;
|
private final URI defaultNetwork;
|
||||||
private final FenceMode defaultFenceMode;
|
private final String defaultFenceMode;
|
||||||
private final boolean defaultDhcpEnabled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To allow for optional injection, since guice doesn't allow unresolved constants in
|
|
||||||
* constructors
|
|
||||||
*/
|
|
||||||
protected static class OptionalConstantsHolder {
|
|
||||||
@Inject(optional = true)
|
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_CPUCOUNT)
|
|
||||||
String cpuCount;
|
|
||||||
@Inject(optional = true)
|
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_MEMORY)
|
|
||||||
String memorySizeMegabytes;
|
|
||||||
@Inject(optional = true)
|
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_DISK)
|
|
||||||
String diskSizeKilobytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
public BindInstantiateVAppTemplateParamsToXmlPayload(
|
||||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
BindToStringPayload stringBinder,
|
||||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_DHCP_ENABLED) String defaultDhcpEnabled,
|
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String defaultFenceMode,
|
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||||
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode
|
||||||
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.defaultNetwork = URI.create(network);
|
this.defaultNetwork = URI.create(network);
|
||||||
this.defaultFenceMode = FenceMode.fromValue(defaultFenceMode);
|
this.defaultFenceMode = fenceMode;
|
||||||
this.defaultDhcpEnabled = Boolean.parseBoolean(defaultDhcpEnabled);
|
|
||||||
if (defaultsHolder.cpuCount != null)
|
|
||||||
this.defaultVirtualHardwareQuantity.put(ResourceType.PROCESSOR, defaultsHolder.cpuCount);
|
|
||||||
if (defaultsHolder.memorySizeMegabytes != null)
|
|
||||||
this.defaultVirtualHardwareQuantity.put(ResourceType.MEMORY,
|
|
||||||
defaultsHolder.memorySizeMegabytes);
|
|
||||||
if (defaultsHolder.diskSizeKilobytes != null)
|
|
||||||
this.defaultVirtualHardwareQuantity.put(ResourceType.DISK_DRIVE,
|
|
||||||
defaultsHolder.diskSizeKilobytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
checkArgument(
|
||||||
"this binder is only valid for GeneratedHttpRequests!");
|
checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||||
|
"this binder is only valid for GeneratedHttpRequests!");
|
||||||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
checkState(gRequest.getArgs() != null,
|
||||||
|
"args should be initialized at this point");
|
||||||
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 fenceMode = postParams.remove("fenceMode");
|
|
||||||
String dhcpEnabled = postParams.remove("dhcpEnabled");
|
|
||||||
String networkName = postParams.remove("networkName");
|
|
||||||
|
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity = extractVirtualQuantityFromPostParams(postParams);
|
SortedMap<ResourceType, String> virtualHardwareQuantity = Maps
|
||||||
|
.newTreeMap();
|
||||||
|
|
||||||
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
|
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
|
||||||
Map<String, String> properties = Maps.newTreeMap();
|
Map<String, String> properties = Maps.newTreeMap();
|
||||||
|
String network = defaultNetwork.toASCIIString();
|
||||||
|
String fenceMode = defaultFenceMode;
|
||||||
|
String networkName = name;
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
String networkFromOptions = addQuantityOrReturnNetwork(options, virtualHardwareQuantity,
|
network = ifNullDefaultTo(options.getNetwork(), network);
|
||||||
network);
|
fenceMode = ifNullDefaultTo(options.getFenceMode(), defaultFenceMode);
|
||||||
network = networkFromOptions != null ? networkFromOptions : network;
|
networkName = ifNullDefaultTo(options.getNetworkName(), networkName);
|
||||||
|
addQuantity(options, virtualHardwareQuantity);
|
||||||
properties.putAll(options.getProperties());
|
properties.putAll(options.getProperties());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
stringBinder.bindToRequest(request, generateXml(name, template, properties,
|
stringBinder.bindToRequest(request, generateXml(name, template,
|
||||||
virtualHardwareQuantity, networkName == null ? name : networkName,
|
properties, virtualHardwareQuantity, networkName, fenceMode, URI
|
||||||
fenceMode == null ? defaultFenceMode : FenceMode.fromValue(fenceMode),
|
.create(network)));
|
||||||
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) {
|
||||||
|
@ -154,92 +123,99 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SortedMap<ResourceType, String> extractVirtualQuantityFromPostParams(
|
protected String generateXml(String name, String template,
|
||||||
Map<String, String> postParams) {
|
Map<String, String> properties,
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity = Maps.newTreeMap();
|
SortedMap<ResourceType, String> virtualHardwareQuantity,
|
||||||
virtualHardwareQuantity.putAll(defaultVirtualHardwareQuantity);
|
String networkName, @Nullable String fenceMode, URI network)
|
||||||
for (Entry<String, String> entry : postParams.entrySet()) {
|
throws ParserConfigurationException, FactoryConfigurationError,
|
||||||
virtualHardwareQuantity.put(ResourceType.fromValue(entry.getKey()), entry.getValue());
|
TransformerException {
|
||||||
}
|
|
||||||
return virtualHardwareQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String generateXml(String name, String template, Map<String, String> properties,
|
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity, String networkName,
|
|
||||||
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);
|
||||||
|
|
||||||
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
|
XMLBuilder instantiationParamsBuilder = rootBuilder
|
||||||
|
.e("InstantiationParams");
|
||||||
addPropertiesifPresent(instantiationParamsBuilder, properties);
|
addPropertiesifPresent(instantiationParamsBuilder, properties);
|
||||||
addVirtualQuantityIfPresent(instantiationParamsBuilder, virtualHardwareQuantity);
|
addVirtualQuantityIfPresent(instantiationParamsBuilder,
|
||||||
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode, dhcp, network);
|
virtualHardwareQuantity);
|
||||||
|
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode,
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder,
|
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder,
|
||||||
Map<String, String> properties) {
|
Map<String, String> properties) {
|
||||||
if (properties.size() > 0) {
|
if (properties.size() > 0) {
|
||||||
XMLBuilder productSectionBuilder = instantiationParamsBuilder.e("ProductSection").a(
|
XMLBuilder productSectionBuilder = instantiationParamsBuilder.e(
|
||||||
"xmlns:q1", ns).a("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
|
"ProductSection").a("xmlns:q1", ns).a("xmlns:ovf",
|
||||||
|
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||||
for (Entry<String, String> entry : properties.entrySet()) {
|
for (Entry<String, String> entry : properties.entrySet()) {
|
||||||
productSectionBuilder.e("Property")
|
productSectionBuilder.e("Property").a("xmlns",
|
||||||
.a("xmlns", "http://schemas.dmtf.org/ovf/envelope/1").a("ovf:key",
|
"http://schemas.dmtf.org/ovf/envelope/1").a("ovf:key",
|
||||||
entry.getKey()).a("ovf:value", entry.getValue());
|
entry.getKey()).a("ovf:value", entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name,
|
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
|
||||||
FenceMode fenceMode, boolean dhcp, URI network) {
|
String name, @Nullable String fenceMode, URI network) {
|
||||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e(
|
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e(
|
||||||
"NetworkConfig").a("name", name);
|
"NetworkConfigSection").e("NetworkConfig").a("name", name);
|
||||||
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
|
if (fenceMode != null) {
|
||||||
featuresBuilder.e("FenceMode").t(fenceMode.value());
|
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
|
||||||
featuresBuilder.e("Dhcp").t(dhcp + "");
|
featuresBuilder.e("FenceMode").t(fenceMode);
|
||||||
networkConfigBuilder.e("NetworkAssociation").a("href", network.toASCIIString());
|
}
|
||||||
|
networkConfigBuilder.e("NetworkAssociation").a("href",
|
||||||
|
network.toASCIIString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addVirtualQuantityIfPresent(XMLBuilder instantiationParamsBuilder,
|
protected void addVirtualQuantityIfPresent(
|
||||||
SortedMap<ResourceType, String> virtualHardwareQuantity) {
|
XMLBuilder instantiationParamsBuilder,
|
||||||
|
SortedMap<ResourceType, String> virtualHardwareQuantity) {
|
||||||
if (virtualHardwareQuantity.size() > 0) {
|
if (virtualHardwareQuantity.size() > 0) {
|
||||||
XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder.e(
|
XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder
|
||||||
"VirtualHardwareSection").a("xmlns:q1", ns);
|
.e("VirtualHardwareSection").a("xmlns:q1", ns);
|
||||||
for (Entry<ResourceType, String> entry : virtualHardwareQuantity.entrySet()) {
|
for (Entry<ResourceType, String> entry : virtualHardwareQuantity
|
||||||
XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a("xmlns",
|
.entrySet()) {
|
||||||
"http://schemas.dmtf.org/ovf/envelope/1");
|
XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a(
|
||||||
|
"xmlns", "http://schemas.dmtf.org/ovf/envelope/1");
|
||||||
itemBuilder
|
itemBuilder
|
||||||
.e("InstanceID")
|
.e("InstanceID")
|
||||||
.a("xmlns",
|
.a(
|
||||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
"xmlns",
|
||||||
.t(virtualHardwareToInstanceId.get(entry.getKey()));
|
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||||
|
.t(virtualHardwareToInstanceId.get(entry.getKey()));
|
||||||
itemBuilder
|
itemBuilder
|
||||||
.e("ResourceType")
|
.e("ResourceType")
|
||||||
.a("xmlns",
|
.a(
|
||||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
"xmlns",
|
||||||
.t(entry.getKey().value());
|
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||||
|
.t(entry.getKey().value());
|
||||||
itemBuilder
|
itemBuilder
|
||||||
.e("VirtualQuantity")
|
.e("VirtualQuantity")
|
||||||
.a("xmlns",
|
.a(
|
||||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
"xmlns",
|
||||||
.t(entry.getValue());
|
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||||
|
.t(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected XMLBuilder buildRoot(String name) throws ParserConfigurationException,
|
protected XMLBuilder buildRoot(String name)
|
||||||
FactoryConfigurationError {
|
throws ParserConfigurationException, FactoryConfigurationError {
|
||||||
XMLBuilder rootBuilder = XMLBuilder.create("InstantiateVAppTemplateParams").a("name", name)
|
XMLBuilder rootBuilder = XMLBuilder.create(
|
||||||
.a("xmlns", ns).a("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a(
|
"InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns).a(
|
||||||
"xsi:schemaLocation", ns + " " + schema);
|
"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a(
|
||||||
|
"xsi:schemaLocation", ns + " " + schema).a("xmlns:ovf",
|
||||||
|
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||||
return rootBuilder;
|
return rootBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
|
protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(
|
||||||
|
GeneratedHttpRequest<?> gRequest) {
|
||||||
for (Object arg : gRequest.getArgs()) {
|
for (Object arg : gRequest.getArgs()) {
|
||||||
if (arg instanceof InstantiateVAppTemplateOptions) {
|
if (arg instanceof InstantiateVAppTemplateOptions) {
|
||||||
return (InstantiateVAppTemplateOptions) arg;
|
return (InstantiateVAppTemplateOptions) arg;
|
||||||
|
@ -251,25 +227,25 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String addQuantityOrReturnNetwork(InstantiateVAppTemplateOptions options,
|
private void addQuantity(InstantiateVAppTemplateOptions options,
|
||||||
Map<ResourceType, String> virtualHardwareQuantity, String network) {
|
Map<ResourceType, String> virtualHardwareQuantity) {
|
||||||
if (options.getCpuCount() != null) {
|
if (options.getCpuCount() != null) {
|
||||||
virtualHardwareQuantity.put(ResourceType.PROCESSOR, options.getCpuCount());
|
virtualHardwareQuantity.put(ResourceType.PROCESSOR, options
|
||||||
|
.getCpuCount());
|
||||||
}
|
}
|
||||||
if (options.getMemorySizeMegabytes() != null) {
|
if (options.getMemorySizeMegabytes() != null) {
|
||||||
virtualHardwareQuantity.put(ResourceType.MEMORY, options.getMemorySizeMegabytes());
|
virtualHardwareQuantity.put(ResourceType.MEMORY, options
|
||||||
|
.getMemorySizeMegabytes());
|
||||||
}
|
}
|
||||||
if (options.getDiskSizeKilobytes() != null) {
|
if (options.getDiskSizeKilobytes() != null) {
|
||||||
virtualHardwareQuantity.put(ResourceType.DISK_DRIVE, options.getDiskSizeKilobytes());
|
virtualHardwareQuantity.put(ResourceType.DISK_DRIVE, options
|
||||||
|
.getDiskSizeKilobytes());
|
||||||
}
|
}
|
||||||
if (options.getNetwork() != null) {
|
|
||||||
return options.getNetwork();
|
|
||||||
}
|
|
||||||
return network;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Object input) {
|
public void bindToRequest(HttpRequest request, Object input) {
|
||||||
throw new IllegalStateException("InstantiateVAppTemplateParams is needs parameters");
|
throw new IllegalStateException(
|
||||||
|
"InstantiateVAppTemplateParams is needs parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String ifNullDefaultTo(String value, String defaultValue) {
|
protected String ifNullDefaultTo(String value, String defaultValue) {
|
||||||
|
|
|
@ -70,7 +70,6 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
|
||||||
String templateId, InstantiateVAppTemplateOptions options,
|
String templateId, InstantiateVAppTemplateOptions options,
|
||||||
int... portsToOpen) {
|
int... portsToOpen) {
|
||||||
checkNotNull(options, "options");
|
checkNotNull(options, "options");
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
">> instantiating vApp vDC(%s) name(%s) template(%s) options(%s) ",
|
">> instantiating vApp vDC(%s) name(%s) template(%s) options(%s) ",
|
||||||
vDCId, name, templateId, options);
|
vDCId, name, templateId, options);
|
||||||
|
|
|
@ -75,7 +75,7 @@ import com.google.inject.util.Providers;
|
||||||
*/
|
*/
|
||||||
public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
|
|
||||||
private final String providerName;
|
protected final String providerName;
|
||||||
|
|
||||||
public VCloudComputeServiceContextModule(String providerName) {
|
public VCloudComputeServiceContextModule(String providerName) {
|
||||||
this.providerName = providerName;
|
this.providerName = providerName;
|
||||||
|
|
|
@ -39,11 +39,13 @@ public class StaticSizeProvider implements Provider<Set<? extends Size>> {
|
||||||
@Override
|
@Override
|
||||||
public Set<? extends Size> get() {
|
public Set<? extends Size> get() {
|
||||||
Set<Size> sizes = Sets.newHashSet();
|
Set<Size> sizes = Sets.newHashSet();
|
||||||
for (int cpus : new int[] { 1, 2, 4 })
|
for (int cpus : new int[] { 1, 2, 4, 8 })
|
||||||
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 }) {
|
for (int ram : new int[] { 512, 1024, 2048, 4096, 8192, 16384 }) {
|
||||||
String id = String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10);
|
String id = String.format("cpu=%d,ram=%s,disk=%d", cpus, ram, 10);
|
||||||
sizes.add(new SizeImpl(id, null, id, null, null, ImmutableMap.<String, String> of(),
|
sizes
|
||||||
cpus, ram, 10, ImagePredicates.any()));
|
.add(new SizeImpl(id, null, id, null, null, ImmutableMap
|
||||||
|
.<String, String> of(), cpus, ram, 10, ImagePredicates
|
||||||
|
.any()));
|
||||||
}
|
}
|
||||||
return sizes;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
|
* Configures the {@link VCloudComputeServiceContext}; requires
|
||||||
* bound.
|
* {@link BaseVCloudComputeClient} bound.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -70,50 +70,59 @@ public class VCloudGetNodeMetadata {
|
||||||
|
|
||||||
// hex [][][] are templateId, last two are instanceId
|
// hex [][][] are templateId, last two are instanceId
|
||||||
public static final Pattern TAG_PATTERN_WITH_TEMPLATE = Pattern
|
public static final Pattern TAG_PATTERN_WITH_TEMPLATE = Pattern
|
||||||
.compile("([^-]+)-([0-9a-f][0-9a-f][0-9a-f])[0-9a-f]+");
|
.compile("([^-]+)-([0-9a-f][0-9a-f][0-9a-f])[0-9a-f]+");
|
||||||
|
|
||||||
public static final Pattern TAG_PATTERN_WITHOUT_TEMPLATE = Pattern.compile("([^-]+)-[0-9]+");
|
public static final Pattern TAG_PATTERN_WITHOUT_TEMPLATE = Pattern
|
||||||
|
.compile("([^-]+)-[0-9]+");
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudGetNodeMetadata(VCloudClient client, VCloudComputeClient computeClient,
|
VCloudGetNodeMetadata(VCloudClient client,
|
||||||
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
VCloudComputeClient computeClient,
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
||||||
Provider<Set<? extends Image>> images) {
|
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
||||||
|
Provider<Set<? extends Image>> images) {
|
||||||
this.client = checkNotNull(client, "client");
|
this.client = checkNotNull(client, "client");
|
||||||
this.images = checkNotNull(images, "images");
|
this.images = checkNotNull(images, "images");
|
||||||
this.getExtra = checkNotNull(getExtra, "getExtra");
|
this.getExtra = checkNotNull(getExtra, "getExtra");
|
||||||
this.findLocationForResourceInVDC = checkNotNull(findLocationForResourceInVDC,
|
this.findLocationForResourceInVDC = checkNotNull(
|
||||||
"findLocationForResourceInVDC");
|
findLocationForResourceInVDC, "findLocationForResourceInVDC");
|
||||||
this.computeClient = checkNotNull(computeClient, "computeClient");
|
this.computeClient = checkNotNull(computeClient, "computeClient");
|
||||||
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState, "vAppStatusToNodeState");
|
this.vAppStatusToNodeState = checkNotNull(vAppStatusToNodeState,
|
||||||
|
"vAppStatusToNodeState");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NodeMetadata getNodeMetadataByIdInVDC(String id) {
|
public NodeMetadata execute(String id) {
|
||||||
VApp vApp = client.getVApp(id);
|
VApp vApp = client.getVApp(id);
|
||||||
|
|
||||||
String tag = null;
|
String tag = null;
|
||||||
Image image = null;
|
Image image = null;
|
||||||
Matcher matcher = TAG_PATTERN_WITH_TEMPLATE.matcher(vApp.getName());
|
Matcher matcher = vApp.getName() != null ? TAG_PATTERN_WITH_TEMPLATE
|
||||||
|
.matcher(vApp.getName()) : null;
|
||||||
|
|
||||||
final Location location = findLocationForResourceInVDC.apply(vApp, vApp.getVDC().getId());
|
final Location location = findLocationForResourceInVDC.apply(vApp, vApp
|
||||||
if (matcher.find()) {
|
.getVDC().getId());
|
||||||
|
if (matcher != null && matcher.find()) {
|
||||||
tag = matcher.group(1);
|
tag = matcher.group(1);
|
||||||
String templateIdInHexWithoutLeadingZeros = matcher.group(2).replaceAll("^[0]+", "");
|
String templateIdInHexWithoutLeadingZeros = matcher.group(2)
|
||||||
final String templateId = Integer.parseInt(templateIdInHexWithoutLeadingZeros, 16) + "";
|
.replaceAll("^[0]+", "");
|
||||||
|
final String templateId = Integer.parseInt(
|
||||||
|
templateIdInHexWithoutLeadingZeros, 16)
|
||||||
|
+ "";
|
||||||
try {
|
try {
|
||||||
image = Iterables.find(images.get(), new Predicate<Image>() {
|
image = Iterables.find(images.get(), new Predicate<Image>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(Image input) {
|
||||||
return input.getProviderId().equals(templateId)
|
return input.getProviderId().equals(templateId)
|
||||||
&& input.getLocation().equals(location);
|
&& input.getLocation().equals(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
logger.warn(
|
logger
|
||||||
"could not find a matching image for vapp %s; vapptemplate %s in location %s",
|
.warn(
|
||||||
vApp, templateId, location);
|
"could not find a matching image for vapp %s; vapptemplate %s in location %s",
|
||||||
|
vApp, templateId, location);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
matcher = TAG_PATTERN_WITHOUT_TEMPLATE.matcher(vApp.getName());
|
matcher = TAG_PATTERN_WITHOUT_TEMPLATE.matcher(vApp.getName());
|
||||||
|
@ -123,9 +132,10 @@ public class VCloudGetNodeMetadata {
|
||||||
tag = "NOTAG-" + vApp.getName();
|
tag = "NOTAG-" + vApp.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), location, vApp
|
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(),
|
||||||
.getLocation(), ImmutableMap.<String, String> of(), tag, image,
|
location, vApp.getLocation(), ImmutableMap.<String, String> of(),
|
||||||
vAppStatusToNodeState.get(vApp.getStatus()), computeClient.getPublicAddresses(id),
|
tag, image, vAppStatusToNodeState.get(vApp.getStatus()),
|
||||||
computeClient.getPrivateAddresses(id), getExtra.apply(vApp), null);
|
computeClient.getPublicAddresses(id), computeClient
|
||||||
|
.getPrivateAddresses(id), getExtra.apply(vApp), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -50,10 +50,11 @@ public class EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategy extends
|
||||||
ListNodesStrategy listNodesStrategy,
|
ListNodesStrategy listNodesStrategy,
|
||||||
@Named("NAMING_CONVENTION") String nodeNamingConvention,
|
@Named("NAMING_CONVENTION") String nodeNamingConvention,
|
||||||
ComputeUtils utils,
|
ComputeUtils utils,
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor,
|
||||||
|
SecureRandom random) {
|
||||||
super(addNodeWithTagStrategy, listNodesStrategy, nodeNamingConvention,
|
super(addNodeWithTagStrategy, listNodesStrategy, nodeNamingConvention,
|
||||||
utils, executor);
|
utils, executor);
|
||||||
this.random = new SecureRandom();
|
this.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,43 +20,30 @@ package org.jclouds.vcloud.compute.strategy;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
|
||||||
import org.jclouds.vcloud.compute.functions.FindLocationForResourceInVDC;
|
|
||||||
import org.jclouds.vcloud.compute.functions.GetExtra;
|
|
||||||
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
|
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VCloudGetNodeMetadataStrategy extends VCloudGetNodeMetadata implements
|
public class VCloudGetNodeMetadataStrategy implements
|
||||||
GetNodeMetadataStrategy {
|
GetNodeMetadataStrategy {
|
||||||
|
|
||||||
|
protected final VCloudGetNodeMetadata getNodeMetadata;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudGetNodeMetadataStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
protected VCloudGetNodeMetadataStrategy(VCloudGetNodeMetadata getNodeMetadata) {
|
||||||
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
this.getNodeMetadata=getNodeMetadata;
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
|
||||||
Provider<Set<? extends Image>> images) {
|
|
||||||
super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC,
|
|
||||||
images);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NodeMetadata execute(String id) {
|
public NodeMetadata execute(String id) {
|
||||||
return getNodeMetadataByIdInVDC(checkNotNull(id, "node.id"));
|
return getNodeMetadata.execute(checkNotNull(id, "node.id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,20 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.strategy;
|
package org.jclouds.vcloud.compute.strategy;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.ComputeType;
|
import org.jclouds.compute.domain.ComputeType;
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.compute.domain.internal.ComputeMetadataImpl;
|
import org.jclouds.compute.domain.internal.ComputeMetadataImpl;
|
||||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.ListNodesStrategy;
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
|
@ -39,12 +35,9 @@ import org.jclouds.domain.Location;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
|
||||||
import org.jclouds.vcloud.compute.functions.FindLocationForResourceInVDC;
|
import org.jclouds.vcloud.compute.functions.FindLocationForResourceInVDC;
|
||||||
import org.jclouds.vcloud.compute.functions.GetExtra;
|
|
||||||
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
|
import org.jclouds.vcloud.compute.functions.VCloudGetNodeMetadata;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -55,25 +48,30 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class VCloudListNodesStrategy extends VCloudGetNodeMetadata implements ListNodesStrategy {
|
public class VCloudListNodesStrategy implements ListNodesStrategy {
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
public Logger logger = Logger.NULL;
|
public Logger logger = Logger.NULL;
|
||||||
|
protected final VCloudGetNodeMetadata getNodeMetadata;
|
||||||
|
protected final VCloudClient client;
|
||||||
|
protected final FindLocationForResourceInVDC findLocationForResourceInVDC;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected VCloudListNodesStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
protected VCloudListNodesStrategy(VCloudClient client,
|
||||||
Map<VAppStatus, NodeState> vAppStatusToNodeState, GetExtra getExtra,
|
VCloudGetNodeMetadata getNodeMetadata,
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC,
|
FindLocationForResourceInVDC findLocationForResourceInVDC) {
|
||||||
Provider<Set<? extends Image>> images) {
|
this.client = client;
|
||||||
super(client, computeClient, vAppStatusToNodeState, getExtra, findLocationForResourceInVDC,
|
this.getNodeMetadata = getNodeMetadata;
|
||||||
images);
|
this.findLocationForResourceInVDC = findLocationForResourceInVDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<ComputeMetadata> list() {
|
public Iterable<ComputeMetadata> list() {
|
||||||
Set<ComputeMetadata> nodes = Sets.newHashSet();
|
Set<ComputeMetadata> nodes = Sets.newHashSet();
|
||||||
for (NamedResource vdc : client.getDefaultOrganization().getVDCs().values()) {
|
for (NamedResource vdc : client.getDefaultOrganization().getVDCs()
|
||||||
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
|
.values()) {
|
||||||
|
for (NamedResource resource : client.getVDC(vdc.getId())
|
||||||
|
.getResourceEntities().values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
|
if (resource.getType().equals(VCloudMediaType.VAPP_XML)) {
|
||||||
nodes.add(convertVAppToComputeMetadata(vdc, resource));
|
nodes.add(convertVAppToComputeMetadata(vdc, resource));
|
||||||
}
|
}
|
||||||
|
@ -82,19 +80,25 @@ public class VCloudListNodesStrategy extends VCloudGetNodeMetadata implements Li
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc, NamedResource resource) {
|
private ComputeMetadata convertVAppToComputeMetadata(NamedResource vdc,
|
||||||
Location location = findLocationForResourceInVDC.apply(resource, vdc.getId());
|
NamedResource resource) {
|
||||||
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId(), resource.getName(),
|
Location location = findLocationForResourceInVDC.apply(resource, vdc
|
||||||
resource.getId(), location, null, ImmutableMap.<String, String> of());
|
.getId());
|
||||||
|
return new ComputeMetadataImpl(ComputeType.NODE, resource.getId(),
|
||||||
|
resource.getName(), resource.getId(), location, null, ImmutableMap
|
||||||
|
.<String, String> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<NodeMetadata> listDetailsOnNodesMatching(Predicate<ComputeMetadata> filter) {
|
public Iterable<NodeMetadata> listDetailsOnNodesMatching(
|
||||||
|
Predicate<ComputeMetadata> filter) {
|
||||||
Set<NodeMetadata> nodes = Sets.newHashSet();
|
Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||||
for (NamedResource vdc : client.getDefaultOrganization().getVDCs().values()) {
|
for (NamedResource vdc : client.getDefaultOrganization().getVDCs()
|
||||||
for (NamedResource resource : client.getVDC(vdc.getId()).getResourceEntities().values()) {
|
.values()) {
|
||||||
|
for (NamedResource resource : client.getVDC(vdc.getId())
|
||||||
|
.getResourceEntities().values()) {
|
||||||
if (resource.getType().equals(VCloudMediaType.VAPP_XML)
|
if (resource.getType().equals(VCloudMediaType.VAPP_XML)
|
||||||
&& filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
|
&& filter.apply(convertVAppToComputeMetadata(vdc, resource))) {
|
||||||
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
|
addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,16 +107,17 @@ public class VCloudListNodesStrategy extends VCloudGetNodeMetadata implements Li
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void addVAppToSetRetryingIfNotYetPresent(Set<NodeMetadata> nodes, NamedResource vdc,
|
void addVAppToSetRetryingIfNotYetPresent(Set<NodeMetadata> nodes,
|
||||||
NamedResource resource) {
|
NamedResource vdc, NamedResource resource) {
|
||||||
NodeMetadata node = null;
|
NodeMetadata node = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (node == null && i++ < 3) {
|
while (node == null && i++ < 3) {
|
||||||
try {
|
try {
|
||||||
node = getNodeMetadataByIdInVDC(resource.getId());
|
node = getNodeMetadata.execute(resource.getId());
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
|
logger.warn("vApp %s not yet present in vdc %s", resource.getId(),
|
||||||
|
vdc.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ 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;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_API;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -82,6 +82,7 @@ import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.internal.Maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the VCloud authentication service connection, including logging
|
* Configures the VCloud authentication service connection, including logging
|
||||||
|
@ -125,12 +126,34 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@Provides
|
@Provides
|
||||||
@Org
|
@Org
|
||||||
@Singleton
|
@Singleton
|
||||||
protected URI provideOrg(Supplier<VCloudSession> cache,
|
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
|
||||||
|
return Iterables.getLast(orgs).getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("VDC_TO_ORG")
|
||||||
|
@Singleton
|
||||||
|
protected Map<String, String> provideVDCtoORG(@Org Iterable<NamedResource> orgs,
|
||||||
|
VCloudClient client) {
|
||||||
|
Map<String, String> returnVal = Maps.newLinkedHashMap();
|
||||||
|
for (NamedResource orgr : orgs) {
|
||||||
|
for (NamedResource vdc : client.getOrganization(orgr.getId())
|
||||||
|
.getVDCs().values()) {
|
||||||
|
returnVal.put(vdc.getId(), orgr.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Org
|
||||||
|
@Singleton
|
||||||
|
protected Iterable<NamedResource> provideOrgs(Supplier<VCloudSession> cache,
|
||||||
@Named(PROPERTY_VCLOUD_USER) String user) {
|
@Named(PROPERTY_VCLOUD_USER) String user) {
|
||||||
VCloudSession discovery = cache.get();
|
VCloudSession discovery = cache.get();
|
||||||
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: "
|
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: "
|
||||||
+ user);
|
+ user);
|
||||||
return Iterables.getLast(discovery.getOrgs().values()).getLocation();
|
return discovery.getOrgs().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@ -192,7 +215,7 @@ public abstract class BaseVCloudRestClientModule<S extends VCloudClient, A exten
|
||||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||||
protected URI provideAuthenticationURI(
|
protected URI provideAuthenticationURI(
|
||||||
VCloudVersionsAsyncClient versionService,
|
VCloudVersionsAsyncClient versionService,
|
||||||
@Named(PROPERTY_VCLOUD_VERSION) String version)
|
@Named(PROPERTY_VCLOUD_VERSION_API) String version)
|
||||||
throws InterruptedException, ExecutionException, TimeoutException {
|
throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
SortedMap<String, URI> versions = versionService.getSupportedVersions()
|
SortedMap<String, URI> versions = versionService.getSupportedVersions()
|
||||||
.get(180, TimeUnit.SECONDS);
|
.get(180, TimeUnit.SECONDS);
|
||||||
|
|
|
@ -18,32 +18,24 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.domain;
|
package org.jclouds.vcloud.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* The FenceMode specifies network constraints.
|
* The FenceMode element contains one of the following strings that specify how
|
||||||
|
* a network is connected to its parent network.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public enum FenceMode {
|
public interface FenceMode {
|
||||||
|
/**
|
||||||
BRIDGED, ISOLATED, BLOCK_IN_OUT, ALLOW_IN, ALLOW_IN_OUT, ALLOW_OUT;
|
* The two networks are bridged.
|
||||||
|
*/
|
||||||
public String value() {
|
public static final String BRIDGED = "bridged";
|
||||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
/**
|
||||||
}
|
* The two networks are not connected.
|
||||||
|
*/
|
||||||
@Override
|
public static final String ISOLATED = "isolated";
|
||||||
public String toString() {
|
/**
|
||||||
return value();
|
* The two networks are connected as specified in their NatService elements.
|
||||||
}
|
*/
|
||||||
|
public static final String NAT_ROUTED = "natRouted";
|
||||||
public static FenceMode fromValue(String fenceMode) {
|
|
||||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode,
|
|
||||||
"fenceMode")));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -57,7 +57,7 @@ public interface Network extends NamedResource {
|
||||||
/**
|
/**
|
||||||
* return the network’s fence modes.
|
* return the network’s fence modes.
|
||||||
*/
|
*/
|
||||||
Set<FenceMode> getFenceModes();
|
Set<String> getFenceModes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return True if the network provides DHCP services
|
* return True if the network provides DHCP services
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.domain.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.FirewallRule;
|
import org.jclouds.vcloud.domain.FirewallRule;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.domain.NatRule;
|
import org.jclouds.vcloud.domain.NatRule;
|
||||||
|
@ -45,15 +44,16 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
||||||
private final Set<String> dnsServers = Sets.newHashSet();
|
private final Set<String> dnsServers = Sets.newHashSet();
|
||||||
private final String gateway;
|
private final String gateway;
|
||||||
private final String netmask;
|
private final String netmask;
|
||||||
private final Set<FenceMode> fenceModes = Sets.newHashSet();
|
private final Set<String> fenceModes = Sets.newHashSet();
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Boolean dhcp;
|
private final Boolean dhcp;
|
||||||
private final Set<NatRule> natRules = Sets.newHashSet();
|
private final Set<NatRule> natRules = Sets.newHashSet();
|
||||||
private final Set<FirewallRule> firewallRules = Sets.newHashSet();
|
private final Set<FirewallRule> firewallRules = Sets.newHashSet();
|
||||||
|
|
||||||
public NetworkImpl(String id, String name, URI location, String description,
|
public NetworkImpl(String id, String name, URI location, String description,
|
||||||
Set<String> dnsServers, String gateway, String netmask, Set<FenceMode> fenceModes,
|
Set<String> dnsServers, String gateway, String netmask,
|
||||||
Boolean dhcp, Set<NatRule> natRules, Set<FirewallRule> firewallRules) {
|
Set<String> fenceModes, Boolean dhcp, Set<NatRule> natRules,
|
||||||
|
Set<FirewallRule> firewallRules) {
|
||||||
super(id, name, VCloudMediaType.NETWORK_XML, location);
|
super(id, name, VCloudMediaType.NETWORK_XML, location);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.dnsServers.addAll(dnsServers);
|
this.dnsServers.addAll(dnsServers);
|
||||||
|
@ -96,7 +96,7 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public Set<FenceMode> getFenceModes() {
|
public Set<String> getFenceModes() {
|
||||||
return fenceModes;
|
return fenceModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +130,15 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result
|
||||||
|
+ ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
|
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
|
||||||
result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode());
|
result = prime * result
|
||||||
result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode());
|
+ ((dnsServers == null) ? 0 : dnsServers.hashCode());
|
||||||
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
|
result = prime * result
|
||||||
|
+ ((fenceModes == null) ? 0 : fenceModes.hashCode());
|
||||||
|
result = prime * result
|
||||||
|
+ ((firewallRules == null) ? 0 : firewallRules.hashCode());
|
||||||
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
||||||
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
|
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
|
||||||
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
||||||
|
@ -195,11 +199,12 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "NetworkImpl [id=" + getId() + ", location=" + getLocation() + ", name=" + getName()
|
return "NetworkImpl [id=" + getId() + ", location=" + getLocation()
|
||||||
+ ", type=" + getType() + ", description=" + description + ", dhcp=" + dhcp
|
+ ", name=" + getName() + ", type=" + getType() + ", description="
|
||||||
+ ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules="
|
+ description + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers
|
||||||
+ firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask="
|
+ ", fenceModes=" + fenceModes + ", firewallRules=" + firewallRules
|
||||||
+ netmask + "]";
|
+ ", gateway=" + gateway + ", natRules=" + natRules + ", netmask="
|
||||||
|
+ netmask + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.domain.internal;
|
package org.jclouds.vcloud.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -55,27 +57,30 @@ public class VAppImpl implements VApp {
|
||||||
/** The serialVersionUID */
|
/** The serialVersionUID */
|
||||||
private static final long serialVersionUID = 8464716396538298809L;
|
private static final long serialVersionUID = 8464716396538298809L;
|
||||||
|
|
||||||
public VAppImpl(String id, String name, URI location, VAppStatus status, Long size,
|
public VAppImpl(String id, String name, URI location, VAppStatus status,
|
||||||
NamedResource vDC, ListMultimap<String, String> networkToAddresses,
|
Long size, NamedResource vDC,
|
||||||
String operatingSystemDescription, VirtualSystem system,
|
ListMultimap<String, String> networkToAddresses,
|
||||||
Set<ResourceAllocation> resourceAllocations) {
|
String operatingSystemDescription, VirtualSystem system,
|
||||||
this.id = id;
|
Set<ResourceAllocation> resourceAllocations) {
|
||||||
this.name = name;
|
this.id = checkNotNull(id, "id");
|
||||||
this.location = location;
|
this.name = checkNotNull(name, "name");
|
||||||
this.status = status;
|
this.location = checkNotNull(location, "location");
|
||||||
this.size = size;
|
this.status = checkNotNull(status, "status");
|
||||||
|
this.size = size;// hostingdotcom
|
||||||
this.vDC = vDC;
|
this.vDC = vDC;
|
||||||
this.networkToAddresses = networkToAddresses;
|
this.networkToAddresses = checkNotNull(networkToAddresses,
|
||||||
|
"networkToAddresses");
|
||||||
this.operatingSystemDescription = operatingSystemDescription;
|
this.operatingSystemDescription = operatingSystemDescription;
|
||||||
this.system = system;
|
this.system = system;
|
||||||
this.resourceAllocations = resourceAllocations;
|
this.resourceAllocations = checkNotNull(resourceAllocations,
|
||||||
|
"resourceAllocations");
|
||||||
resourceAllocationByType = Multimaps.index(resourceAllocations,
|
resourceAllocationByType = Multimaps.index(resourceAllocations,
|
||||||
new Function<ResourceAllocation, ResourceType>() {
|
new Function<ResourceAllocation, ResourceType>() {
|
||||||
@Override
|
@Override
|
||||||
public ResourceType apply(ResourceAllocation from) {
|
public ResourceType apply(ResourceAllocation from) {
|
||||||
return from.getType();
|
return from.getType();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public VAppStatus getStatus() {
|
public VAppStatus getStatus() {
|
||||||
|
@ -113,13 +118,21 @@ public class VAppImpl implements VApp {
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
|
result = prime
|
||||||
result = prime * result
|
* result
|
||||||
+ ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode());
|
+ ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
|
||||||
result = prime * result
|
result = prime
|
||||||
+ ((resourceAllocationByType == null) ? 0 : resourceAllocationByType.hashCode());
|
* result
|
||||||
result = prime * result
|
+ ((operatingSystemDescription == null) ? 0
|
||||||
+ ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
|
: operatingSystemDescription.hashCode());
|
||||||
|
result = prime
|
||||||
|
* result
|
||||||
|
+ ((resourceAllocationByType == null) ? 0
|
||||||
|
: resourceAllocationByType.hashCode());
|
||||||
|
result = prime
|
||||||
|
* result
|
||||||
|
+ ((resourceAllocations == null) ? 0 : resourceAllocations
|
||||||
|
.hashCode());
|
||||||
result = prime * result + ((size == null) ? 0 : size.hashCode());
|
result = prime * result + ((size == null) ? 0 : size.hashCode());
|
||||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||||
result = prime * result + ((system == null) ? 0 : system.hashCode());
|
result = prime * result + ((system == null) ? 0 : system.hashCode());
|
||||||
|
@ -159,12 +172,14 @@ public class VAppImpl implements VApp {
|
||||||
if (operatingSystemDescription == null) {
|
if (operatingSystemDescription == null) {
|
||||||
if (other.operatingSystemDescription != null)
|
if (other.operatingSystemDescription != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!operatingSystemDescription.equals(other.operatingSystemDescription))
|
} else if (!operatingSystemDescription
|
||||||
|
.equals(other.operatingSystemDescription))
|
||||||
return false;
|
return false;
|
||||||
if (resourceAllocationByType == null) {
|
if (resourceAllocationByType == null) {
|
||||||
if (other.resourceAllocationByType != null)
|
if (other.resourceAllocationByType != null)
|
||||||
return false;
|
return false;
|
||||||
} else if (!resourceAllocationByType.equals(other.resourceAllocationByType))
|
} else if (!resourceAllocationByType
|
||||||
|
.equals(other.resourceAllocationByType))
|
||||||
return false;
|
return false;
|
||||||
if (resourceAllocations == null) {
|
if (resourceAllocations == null) {
|
||||||
if (other.resourceAllocations != null)
|
if (other.resourceAllocations != null)
|
||||||
|
@ -212,11 +227,13 @@ public class VAppImpl implements VApp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", location=" + location + ", name=" + name + ", networkToAddresses="
|
return "[id=" + id + ", location=" + location + ", name=" + name
|
||||||
+ networkToAddresses + ", operatingSystemDescription=" + operatingSystemDescription
|
+ ", networkToAddresses=" + networkToAddresses
|
||||||
+ ", resourceAllocationByType=" + resourceAllocationByType
|
+ ", operatingSystemDescription=" + operatingSystemDescription
|
||||||
+ ", resourceAllocations=" + resourceAllocations + ", size=" + size + ", status="
|
+ ", resourceAllocationByType=" + resourceAllocationByType
|
||||||
+ status + ", system=" + system + ", vDC=" + vDC + "]";
|
+ ", resourceAllocations=" + resourceAllocations + ", size=" + size
|
||||||
|
+ ", status=" + status + ", system=" + system + ", vDC=" + vDC
|
||||||
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler {
|
||||||
case 401:
|
case 401:
|
||||||
exception = new AuthorizationException(command.getRequest(), content);
|
exception = new AuthorizationException(command.getRequest(), content);
|
||||||
break;
|
break;
|
||||||
|
case 403: // TODO temporary as terremark mistakenly uses this for vApp not found.
|
||||||
case 404:
|
case 404:
|
||||||
if (!command.getRequest().getMethod().equals("DELETE")) {
|
if (!command.getRequest().getMethod().equals("DELETE")) {
|
||||||
String path = command.getRequest().getEndpoint().getPath();
|
String path = command.getRequest().getEndpoint().getPath();
|
||||||
|
|
|
@ -21,13 +21,11 @@ package org.jclouds.vcloud.internal;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
|
||||||
import org.jclouds.vcloud.endpoints.VCloud;
|
import org.jclouds.vcloud.endpoints.VCloud;
|
||||||
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
||||||
|
|
||||||
|
@ -37,18 +35,18 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* Establishes a context with a VCloud endpoint.
|
* Establishes a context with a VCloud endpoint.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||||
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Endpoint(VCloud.class)
|
@Endpoint(VCloud.class)
|
||||||
public interface VCloudVersionsAsyncClient {
|
public interface VCloudVersionsAsyncClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve information for supported versions
|
* Retrieve information for supported versions
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@XMLResponseParser(SupportedVersionsHandler.class)
|
@XMLResponseParser(SupportedVersionsHandler.class)
|
||||||
@Path("/versions")
|
@Path("/versions")
|
||||||
@Consumes(VCloudMediaType.VCLOUD_XML)
|
|
||||||
ListenableFuture<SortedMap<String, URI>> getSupportedVersions();
|
ListenableFuture<SortedMap<String, URI>> getSupportedVersions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class InstantiateVAppTemplateOptions {
|
||||||
private String diskSizeKilobytes;
|
private String diskSizeKilobytes;
|
||||||
private String network;
|
private String network;
|
||||||
private String fenceMode;
|
private String fenceMode;
|
||||||
private String dhcpEnabled;
|
|
||||||
private String networkName;
|
private String networkName;
|
||||||
private boolean blockOnDeploy = true;
|
private boolean blockOnDeploy = true;
|
||||||
private Map<String, String> properties = Maps.newTreeMap();
|
private Map<String, String> properties = Maps.newTreeMap();
|
||||||
|
@ -77,16 +76,11 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
public InstantiateVAppTemplateOptions fenceMode(String fenceMode) {
|
||||||
this.fenceMode = checkNotNull(fenceMode, "fenceMode").toString();
|
this.fenceMode = checkNotNull(fenceMode, "fenceMode").toString();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstantiateVAppTemplateOptions dhcpEnabled(boolean dhcpEnabled) {
|
|
||||||
this.dhcpEnabled = dhcpEnabled + "";
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstantiateVAppTemplateOptions memory(long megabytes) {
|
public InstantiateVAppTemplateOptions memory(long megabytes) {
|
||||||
checkArgument(megabytes >= 1, "megabytes must be positive");
|
checkArgument(megabytes >= 1, "megabytes must be positive");
|
||||||
this.memorySizeMegabytes = megabytes + "";
|
this.memorySizeMegabytes = megabytes + "";
|
||||||
|
@ -129,10 +123,6 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return fenceMode;
|
return fenceMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDhcpEnabled() {
|
|
||||||
return dhcpEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -183,20 +173,11 @@ public class InstantiateVAppTemplateOptions {
|
||||||
/**
|
/**
|
||||||
* @see InstantiateVAppTemplateOptions#fenceMode(FenceMode)
|
* @see InstantiateVAppTemplateOptions#fenceMode(FenceMode)
|
||||||
*/
|
*/
|
||||||
public static InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
public static InstantiateVAppTemplateOptions fenceMode(String fenceMode) {
|
||||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
return options.fenceMode(fenceMode);
|
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)
|
* @see InstantiateVAppTemplateOptions#networkName(String)
|
||||||
*/
|
*/
|
||||||
|
@ -231,8 +212,7 @@ public class InstantiateVAppTemplateOptions {
|
||||||
+ ", memorySizeMegabytes=" + memorySizeMegabytes
|
+ ", memorySizeMegabytes=" + memorySizeMegabytes
|
||||||
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", network="
|
+ ", diskSizeKilobytes=" + diskSizeKilobytes + ", network="
|
||||||
+ network + ", networkName=" + networkName + ", fenceMode="
|
+ network + ", networkName=" + networkName + ", fenceMode="
|
||||||
+ fenceMode + ", dhcpEnabled=" + dhcpEnabled + ", properties="
|
+ fenceMode + ", properties=" + properties + "]";
|
||||||
+ properties + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -240,8 +220,6 @@ public class InstantiateVAppTemplateOptions {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
|
result = prime * result + ((cpuCount == null) ? 0 : cpuCount.hashCode());
|
||||||
result = prime * result
|
|
||||||
+ ((dhcpEnabled == null) ? 0 : dhcpEnabled.hashCode());
|
|
||||||
result = prime * result
|
result = prime * result
|
||||||
+ ((diskSizeKilobytes == null) ? 0 : diskSizeKilobytes.hashCode());
|
+ ((diskSizeKilobytes == null) ? 0 : diskSizeKilobytes.hashCode());
|
||||||
result = prime * result
|
result = prime * result
|
||||||
|
@ -272,11 +250,6 @@ public class InstantiateVAppTemplateOptions {
|
||||||
return false;
|
return false;
|
||||||
} else if (!cpuCount.equals(other.cpuCount))
|
} else if (!cpuCount.equals(other.cpuCount))
|
||||||
return false;
|
return false;
|
||||||
if (dhcpEnabled == null) {
|
|
||||||
if (other.dhcpEnabled != null)
|
|
||||||
return false;
|
|
||||||
} else if (!dhcpEnabled.equals(other.dhcpEnabled))
|
|
||||||
return false;
|
|
||||||
if (diskSizeKilobytes == null) {
|
if (diskSizeKilobytes == null) {
|
||||||
if (other.diskSizeKilobytes != null)
|
if (other.diskSizeKilobytes != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.reference;
|
package org.jclouds.vcloud.reference;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration properties and constants used in VCloud connections.
|
* Configuration properties and constants used in VCloud connections.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface VCloudConstants {
|
public interface VCloudConstants {
|
||||||
public static final String PROPERTY_VCLOUD_VERSION = "jclouds.vcloud.version";
|
public static final String PROPERTY_VCLOUD_VERSION_API = "jclouds.vcloud.version.api";
|
||||||
|
public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema";
|
||||||
public static final String PROPERTY_VCLOUD_ENDPOINT = "jclouds.vcloud.endpoint";
|
public static final String PROPERTY_VCLOUD_ENDPOINT = "jclouds.vcloud.endpoint";
|
||||||
public static final String PROPERTY_VCLOUD_USER = "jclouds.vcloud.user";
|
public static final String PROPERTY_VCLOUD_USER = "jclouds.vcloud.user";
|
||||||
public static final String PROPERTY_VCLOUD_KEY = "jclouds.vcloud.key";
|
public static final String PROPERTY_VCLOUD_KEY = "jclouds.vcloud.key";
|
||||||
|
@ -33,22 +33,9 @@ public interface VCloudConstants {
|
||||||
* automatically renew vcloud token before this interval expires.
|
* automatically renew vcloud token before this interval expires.
|
||||||
*/
|
*/
|
||||||
public static final String PROPERTY_VCLOUD_SESSIONINTERVAL = "jclouds.vcloud.sessioninterval";
|
public static final String PROPERTY_VCLOUD_SESSIONINTERVAL = "jclouds.vcloud.sessioninterval";
|
||||||
/**
|
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
|
||||||
* cpus
|
|
||||||
*/
|
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_CPUCOUNT = "jclouds.vcloud.defaults.cpucount";
|
|
||||||
/**
|
|
||||||
* 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_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
|
||||||
|
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_MEMORY = "jclouds.vcloud.defaults.memorysizemegabytes";
|
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
|
|
||||||
/**
|
|
||||||
* kilobytes
|
|
||||||
*/
|
|
||||||
public static final String PROPERTY_VCLOUD_DEFAULT_DISK = "jclouds.vcloud.defaults.getdisksizekilobytes";
|
|
||||||
public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
|
public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
|
||||||
public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
|
public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import javax.annotation.Resource;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.domain.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.FirewallRule;
|
import org.jclouds.vcloud.domain.FirewallRule;
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
import org.jclouds.vcloud.domain.NatRule;
|
import org.jclouds.vcloud.domain.NatRule;
|
||||||
|
@ -52,13 +51,13 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private Set<String> dnsServers = Sets.newHashSet();
|
private Set<String> dnsServers = Sets.newLinkedHashSet();
|
||||||
private String gateway;
|
private String gateway;
|
||||||
private String netmask;
|
private String netmask;
|
||||||
private Set<FenceMode> fenceModes = Sets.newHashSet();
|
private Set<String> fenceModes = Sets.newLinkedHashSet();
|
||||||
private Boolean dhcp;
|
private Boolean dhcp;
|
||||||
private Set<NatRule> natRules = Sets.newHashSet();
|
private Set<NatRule> natRules = Sets.newLinkedHashSet();
|
||||||
private Set<FirewallRule> firewallRules = Sets.newHashSet();
|
private Set<FirewallRule> firewallRules = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
private String externalIP;
|
private String externalIP;
|
||||||
private Integer externalPort;
|
private Integer externalPort;
|
||||||
|
@ -71,13 +70,14 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||||
private String sourcePort;
|
private String sourcePort;
|
||||||
|
|
||||||
public Network getResult() {
|
public Network getResult() {
|
||||||
return new NetworkImpl(network.getId(), network.getName(), network.getLocation(),
|
return new NetworkImpl(network.getId(), network.getName(), network
|
||||||
description, dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules);
|
.getLocation(), description, dnsServers, gateway, netmask,
|
||||||
|
fenceModes, dhcp, natRules, firewallRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
public void startElement(String uri, String localName, String qName,
|
||||||
throws SAXException {
|
Attributes attributes) throws SAXException {
|
||||||
if (qName.equals("Network")) {
|
if (qName.equals("Network")) {
|
||||||
network = Utils.newNamedResource(attributes);
|
network = Utils.newNamedResource(attributes);
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,12 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||||
} else if (qName.equals("Netmask")) {
|
} else if (qName.equals("Netmask")) {
|
||||||
netmask = currentOrNull();
|
netmask = currentOrNull();
|
||||||
} else if (qName.equals("FenceMode")) {
|
} else if (qName.equals("FenceMode")) {
|
||||||
fenceModes.add(FenceMode.fromValue(currentOrNull()));
|
fenceModes.add(currentOrNull());
|
||||||
} else if (qName.equals("Dhcp")) {
|
} else if (qName.equals("Dhcp")) {
|
||||||
dhcp = new Boolean(currentOrNull());
|
dhcp = new Boolean(currentOrNull());
|
||||||
} else if (qName.equals("NatRule")) {
|
} else if (qName.equals("NatRule")) {
|
||||||
natRules.add(new NatRule(externalIP, externalPort, internalIP, internalPort));
|
natRules.add(new NatRule(externalIP, externalPort, internalIP,
|
||||||
|
internalPort));
|
||||||
externalIP = null;
|
externalIP = null;
|
||||||
externalPort = null;
|
externalPort = null;
|
||||||
internalIP = null;
|
internalIP = null;
|
||||||
|
@ -111,7 +112,8 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||||
} else if (qName.equals("InternalPort")) {
|
} else if (qName.equals("InternalPort")) {
|
||||||
internalPort = Integer.parseInt(currentOrNull());
|
internalPort = Integer.parseInt(currentOrNull());
|
||||||
} else if (qName.equals("FirewallRule")) {
|
} else if (qName.equals("FirewallRule")) {
|
||||||
firewallRules.add(new FirewallRule(policy, protocol, sourceIP, sourcePort));
|
firewallRules.add(new FirewallRule(policy, protocol, sourceIP,
|
||||||
|
sourcePort));
|
||||||
policy = null;
|
policy = null;
|
||||||
protocol = null;
|
protocol = null;
|
||||||
sourceIP = null;
|
sourceIP = null;
|
||||||
|
|
|
@ -39,10 +39,10 @@ import com.google.common.collect.Maps;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
|
public class OrgHandler extends ParseSax.HandlerWithResult<Organization> {
|
||||||
private NamedResource org;
|
protected NamedResource org;
|
||||||
private Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
|
protected Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
|
||||||
private Map<String, NamedResource> tasksLists = Maps.newLinkedHashMap();
|
protected Map<String, NamedResource> tasksLists = Maps.newLinkedHashMap();
|
||||||
private Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
|
protected Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
public Organization getResult() {
|
public Organization getResult() {
|
||||||
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalogs, vdcs,
|
return new OrganizationImpl(org.getId(), org.getName(), org.getLocation(), catalogs, vdcs,
|
||||||
|
|
|
@ -39,7 +39,6 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import com.google.inject.name.Names;
|
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.jclouds.vcloud.endpoints.Catalog;
|
import org.jclouds.vcloud.endpoints.Catalog;
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
|
@ -67,6 +66,7 @@ import org.testng.annotations.Test;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudAsyncClient}
|
* Tests behavior of {@code VCloudAsyncClient}
|
||||||
|
@ -76,21 +76,22 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "vcloud.VCloudAsyncClientTest")
|
@Test(groups = "unit", testName = "vcloud.VCloudAsyncClientTest")
|
||||||
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
public void testInstantiateVAppTemplate() throws SecurityException, NoSuchMethodException,
|
public void testInstantiateVAppTemplate() throws SecurityException,
|
||||||
IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC",
|
Method method = VCloudAsyncClient.class.getMethod(
|
||||||
String.class, String.class, String.class, Array.newInstance(
|
"instantiateVAppTemplateInVDC", String.class, String.class,
|
||||||
InstantiateVAppTemplateOptions.class, 0).getClass());
|
String.class, Array.newInstance(
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1",
|
InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||||
"my-vapp", 3 + "");
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1", "my-vapp", 3 + "");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
"POST http://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||||
assertHeadersEqual(
|
assertHeadersEqual(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Accept: application/vnd.vmware.vcloud.vApp+xml\nContent-Length: 634\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
"Accept: application/vnd.vmware.vcloud.vApp+xml\nContent-Length: 667\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||||
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass()
|
||||||
"/newvapp-hosting.xml")));
|
.getResourceAsStream("/newvapp-hosting.xml")));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||||
|
@ -100,21 +101,32 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
public void testInstantiateVAppTemplateOptions() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC",
|
Method method = VCloudAsyncClient.class.getMethod(
|
||||||
String.class, String.class, String.class, Array.newInstance(
|
"instantiateVAppTemplateInVDC", String.class, String.class,
|
||||||
InstantiateVAppTemplateOptions.class, 0).getClass());
|
String.class, Array.newInstance(
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1",
|
InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||||
"my-vapp", 3 + "", processorCount(1).memory(512).disk(1024).inNetwork(
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
.createRequest(
|
||||||
|
method,
|
||||||
|
"1",
|
||||||
|
"my-vapp",
|
||||||
|
3 + "",
|
||||||
|
processorCount(1)
|
||||||
|
.memory(512)
|
||||||
|
.disk(1024)
|
||||||
|
.fenceMode("allowInOut")
|
||||||
|
.inNetwork(
|
||||||
|
URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
"POST http://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||||
assertHeadersEqual(
|
assertHeadersEqual(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Accept: application/vnd.vmware.vcloud.vApp+xml\nContent-Length: 2018\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
"Accept: application/vnd.vmware.vcloud.vApp+xml\nContent-Length: 2051\nContent-Type: application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml\n");
|
||||||
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass()
|
||||||
"/newvapp-hostingcpumemdisk.xml")));
|
.getResourceAsStream("/newvapp-hostingcpumemdisk.xml")));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||||
|
@ -124,27 +136,32 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testInstantiateVAppTemplateOptionsIllegalName() throws SecurityException,
|
public void testInstantiateVAppTemplateOptionsIllegalName()
|
||||||
NoSuchMethodException, IOException {
|
throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC",
|
Method method = VCloudAsyncClient.class.getMethod(
|
||||||
String.class, String.class, String.class, Array.newInstance(
|
"instantiateVAppTemplateInVDC", String.class, String.class,
|
||||||
InstantiateVAppTemplateOptions.class, 0).getClass());
|
String.class, Array.newInstance(
|
||||||
processor.createRequest(method, "1", "CentOS 01", 3 + "", processorCount(1).memory(512).disk(
|
InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||||
1024).inNetwork(URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
processor.createRequest(method, "1", "CentOS 01", 3 + "", processorCount(
|
||||||
|
1).memory(512).disk(1024).inNetwork(
|
||||||
|
URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCloneVApp() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", String.class,
|
IOException {
|
||||||
String.class, String.class, Array.newInstance(CloneVAppOptions.class, 0).getClass());
|
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC",
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1",
|
String.class, String.class, String.class, Array.newInstance(
|
||||||
"4181", "my-vapp");
|
CloneVAppOptions.class, 0).getClass());
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1", "4181", "my-vapp");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vdc/1/action/cloneVApp HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/vdc/1/action/cloneVApp HTTP/1.1");
|
||||||
assertHeadersEqual(
|
assertHeadersEqual(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Accept: application/vnd.vmware.vcloud.task+xml\nContent-Length: 397\nContent-Type: application/vnd.vmware.vcloud.cloneVAppParams+xml\n");
|
"Accept: application/vnd.vmware.vcloud.task+xml\nContent-Length: 397\nContent-Type: application/vnd.vmware.vcloud.cloneVAppParams+xml\n");
|
||||||
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass()
|
||||||
"/cloneVApp-default.xml")));
|
.getResourceAsStream("/cloneVApp-default.xml")));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
@ -153,19 +170,23 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCloneVAppOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCloneVAppOptions() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", String.class,
|
NoSuchMethodException, IOException {
|
||||||
String.class, String.class, Array.newInstance(CloneVAppOptions.class, 0).getClass());
|
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC",
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1",
|
String.class, String.class, String.class, Array.newInstance(
|
||||||
"201", "new-linux-server", new CloneVAppOptions().deploy().powerOn()
|
CloneVAppOptions.class, 0).getClass());
|
||||||
.withDescription("The description of the new vApp"));
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1", "201", "new-linux-server",
|
||||||
|
new CloneVAppOptions().deploy().powerOn().withDescription(
|
||||||
|
"The description of the new vApp"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vdc/1/action/cloneVApp HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/vdc/1/action/cloneVApp HTTP/1.1");
|
||||||
assertHeadersEqual(
|
assertHeadersEqual(
|
||||||
httpMethod,
|
httpMethod,
|
||||||
"Accept: application/vnd.vmware.vcloud.task+xml\nContent-Length: 461\nContent-Type: application/vnd.vmware.vcloud.cloneVAppParams+xml\n");
|
"Accept: application/vnd.vmware.vcloud.task+xml\nContent-Length: 461\nContent-Type: application/vnd.vmware.vcloud.cloneVAppParams+xml\n");
|
||||||
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass().getResourceAsStream(
|
assertPayloadEquals(httpMethod, Utils.toStringAndClose(getClass()
|
||||||
"/cloneVApp.xml")));
|
.getResourceAsStream("/cloneVApp.xml")));
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
@ -175,21 +196,26 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testCloneVAppOptionsIllegalName() throws SecurityException, NoSuchMethodException,
|
public void testCloneVAppOptionsIllegalName() throws SecurityException,
|
||||||
IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC", String.class,
|
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInVDC",
|
||||||
String.class, String.class, Array.newInstance(CloneVAppOptions.class, 0).getClass());
|
String.class, String.class, String.class, Array.newInstance(
|
||||||
processor.createRequest(method, "1", "201", "New Linux Server", new CloneVAppOptions()
|
CloneVAppOptions.class, 0).getClass());
|
||||||
.deploy().powerOn().withDescription("The description of the new vApp"));
|
processor.createRequest(method, "1", "201", "New Linux Server",
|
||||||
|
new CloneVAppOptions().deploy().powerOn().withDescription(
|
||||||
|
"The description of the new vApp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefaultOrganization() throws SecurityException, NoSuchMethodException,
|
public void testDefaultOrganization() throws SecurityException,
|
||||||
IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultOrganization");
|
Method method = VCloudAsyncClient.class
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
|
.getMethod("getDefaultOrganization");
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://org HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://org HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -199,12 +225,16 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOrganization() throws SecurityException, NoSuchMethodException, IOException {
|
public void testOrganization() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getOrganization", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
Method method = VCloudAsyncClient.class.getMethod("getOrganization",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/org/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/org/1 HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -214,12 +244,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefaultCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDefaultCatalog() throws SecurityException,
|
||||||
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultCatalog");
|
Method method = VCloudAsyncClient.class.getMethod("getDefaultCatalog");
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://catalog HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -229,12 +262,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCatalog() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getCatalog", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
Method method = VCloudAsyncClient.class.getMethod("getCatalog",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/catalog/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
"GET http://vcloud/catalog/1 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -244,12 +282,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
public void testNetwork() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getNetwork", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "2");
|
Method method = VCloudAsyncClient.class.getMethod("getNetwork",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/network/2 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
"GET http://vcloud/network/2 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -259,12 +302,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCatalogItem() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCatalogItem() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "2");
|
Method method = VCloudAsyncClient.class.getMethod("getCatalogItem",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/catalogItem/2 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
"GET http://vcloud/catalogItem/2 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -274,12 +322,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
public void testVAppTemplate() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "2");
|
Method method = VCloudAsyncClient.class.getMethod("getVAppTemplate",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "2");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/vAppTemplate/2 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
"GET http://vcloud/vAppTemplate/2 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -289,12 +342,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetDefaultVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetDefaultVDC() throws SecurityException,
|
||||||
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultVDC");
|
Method method = VCloudAsyncClient.class.getMethod("getDefaultVDC");
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vdc HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -304,12 +360,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetVDC() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", String.class);
|
Method method = VCloudAsyncClient.class.getMethod("getVDC", String.class);
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/vdc/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/vdc/1 HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -319,13 +378,15 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetDefaultTasksList() throws SecurityException, NoSuchMethodException,
|
public void testGetDefaultTasksList() throws SecurityException,
|
||||||
IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
|
Method method = VCloudAsyncClient.class.getMethod("getDefaultTasksList");
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method);
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://tasksList HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://tasksList HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -335,12 +396,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetTasksList() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getTasksList", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
Method method = VCloudAsyncClient.class.getMethod("getTasksList",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/tasksList/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
"GET http://vcloud/tasksList/1 HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -350,12 +416,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeployVApp() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deployVApp", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class.getMethod("deployVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vApp/1/action/deploy HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
"POST http://vcloud/vApp/1/action/deploy HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -365,12 +436,16 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetVApp() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getVApp", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class
|
||||||
|
.getMethod("getVApp", String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/vApp/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/vApp/1 HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -380,12 +455,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testUndeployVApp() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("undeployVApp", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class.getMethod("undeployVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vApp/1/action/undeploy HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
"POST http://vcloud/vApp/1/action/undeploy HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -395,43 +475,37 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteVApp() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("deleteVApp", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class.getMethod("deleteVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "DELETE http://vcloud/vApp/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"DELETE http://vcloud/vApp/1 HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, CloseContentAndReturn.class);
|
assertResponseParserClassEquals(method, httpMethod,
|
||||||
|
CloseContentAndReturn.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPowerOn() throws SecurityException, NoSuchMethodException, IOException {
|
public void testPowerOn() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class.getMethod("powerOnVApp",
|
||||||
|
String.class);
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vApp/1/power/action/powerOn HTTP/1.1");
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
.createRequest(method, 1);
|
||||||
assertPayloadEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testPowerOff() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp", String.class);
|
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/vApp/1/power/action/powerOff HTTP/1.1");
|
"POST http://vcloud/vApp/1/power/action/powerOn HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -441,58 +515,96 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReset() throws SecurityException, NoSuchMethodException, IOException {
|
public void testPowerOff() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("resetVApp", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
Method method = VCloudAsyncClient.class.getMethod("powerOffVApp",
|
||||||
|
String.class);
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vApp/1/power/action/reset HTTP/1.1");
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
.createRequest(method, 1);
|
||||||
assertPayloadEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSuspend() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = VCloudAsyncClient.class.getMethod("suspendVApp", String.class);
|
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/vApp/1/power/action/suspend HTTP/1.1");
|
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
|
||||||
assertPayloadEquals(httpMethod, null);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShutdown() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp", String.class);
|
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, 1);
|
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/vApp/1/power/action/shutdown HTTP/1.1");
|
"POST http://vcloud/vApp/1/power/action/powerOff HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testReset() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("resetVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/vApp/1/power/action/reset HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSuspend() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("suspendVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/vApp/1/power/action/suspend HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testShutdown() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = VCloudAsyncClient.class.getMethod("shutdownVApp",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, 1);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/vApp/1/power/action/shutdown HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, CloseContentAndReturn.class);
|
assertResponseParserClassEquals(method, httpMethod,
|
||||||
|
CloseContentAndReturn.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetTask() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("getTask", String.class);
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
Method method = VCloudAsyncClient.class
|
||||||
|
.getMethod("getTask", String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "GET http://vcloud/task/1 HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/task/1 HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
assertHeadersEqual(httpMethod,
|
||||||
|
"Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -502,15 +614,20 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCancelTask() throws SecurityException,
|
||||||
Method method = VCloudAsyncClient.class.getMethod("cancelTask", String.class);
|
NoSuchMethodException, IOException {
|
||||||
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor.createRequest(method, "1");
|
Method method = VCloudAsyncClient.class.getMethod("cancelTask",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method, "1");
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vcloud/task/1/action/cancel HTTP/1.1");
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"POST http://vcloud/task/1/action/cancel HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, CloseContentAndReturn.class);
|
assertResponseParserClassEquals(method, httpMethod,
|
||||||
|
CloseContentAndReturn.class);
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
assertSaxResponseParserClassEquals(method, null);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
@ -518,9 +635,11 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(GeneratedHttpRequest<VCloudAsyncClient> httpMethod) {
|
protected void checkFilters(
|
||||||
|
GeneratedHttpRequest<VCloudAsyncClient> httpMethod) {
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
assertEquals(httpMethod.getFilters().size(), 1);
|
||||||
assertEquals(httpMethod.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
|
assertEquals(httpMethod.getFilters().get(0).getClass(),
|
||||||
|
SetVCloudTokenCookie.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -536,29 +655,35 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
props.put(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
||||||
"https://vcloud.safesecureweb.com/network/1990");
|
"https://vcloud.safesecureweb.com/network/1990");
|
||||||
Names.bindProperties(binder(), checkNotNull(
|
Names.bindProperties(binder(), checkNotNull(
|
||||||
new VCloudPropertiesBuilder(props).build(), "properties"));
|
new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||||
bind(URI.class).annotatedWith(Org.class).toInstance(URI.create("http://org"));
|
bind(URI.class).annotatedWith(Org.class).toInstance(
|
||||||
bind(URI.class).annotatedWith(Catalog.class).toInstance(URI.create("http://catalog"));
|
URI.create("http://org"));
|
||||||
bind(String.class).annotatedWith(CatalogItemRoot.class)
|
bind(URI.class).annotatedWith(Catalog.class).toInstance(
|
||||||
.toInstance("http://catalogItem");
|
URI.create("http://catalog"));
|
||||||
bind(String.class).annotatedWith(VAppTemplateRoot.class).toInstance(
|
bind(String.class).annotatedWith(CatalogItemRoot.class).toInstance(
|
||||||
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate");
|
"http://catalogItem");
|
||||||
|
bind(String.class)
|
||||||
|
.annotatedWith(VAppTemplateRoot.class)
|
||||||
|
.toInstance(
|
||||||
|
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate");
|
||||||
bind(String.class).annotatedWith(VAppRoot.class).toInstance(
|
bind(String.class).annotatedWith(VAppRoot.class).toInstance(
|
||||||
"https://services.vcloudexpress.terremark.com/api/vapp");
|
"https://services.vcloudexpress.terremark.com/api/vapp");
|
||||||
bind(URI.class).annotatedWith(VDC.class).toInstance(URI.create("http://vdc"));
|
bind(URI.class).annotatedWith(VDC.class).toInstance(
|
||||||
|
URI.create("http://vdc"));
|
||||||
bind(URI.class).annotatedWith(TasksList.class).toInstance(
|
bind(URI.class).annotatedWith(TasksList.class).toInstance(
|
||||||
URI.create("http://tasksList"));
|
URI.create("http://tasksList"));
|
||||||
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(URI.create("http://vcloud"));
|
bind(URI.class).annotatedWith(VCloudApi.class).toInstance(
|
||||||
|
URI.create("http://vcloud"));
|
||||||
bind(SetVCloudTokenCookie.class).toInstance(
|
bind(SetVCloudTokenCookie.class).toInstance(
|
||||||
new SetVCloudTokenCookie(new Provider<String>() {
|
new SetVCloudTokenCookie(new Provider<String>() {
|
||||||
|
|
||||||
public String get() {
|
public String get() {
|
||||||
return "token";
|
return "token";
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
|
|
|
@ -26,15 +26,12 @@ import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.logging.Logger.LoggerFactory;
|
import org.jclouds.logging.Logger.LoggerFactory;
|
||||||
import org.jclouds.rest.RestClientTest;
|
import org.jclouds.rest.RestClientTest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import com.google.inject.name.Names;
|
|
||||||
import org.jclouds.vcloud.endpoints.VCloud;
|
import org.jclouds.vcloud.endpoints.VCloud;
|
||||||
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
import org.jclouds.vcloud.internal.VCloudVersionsAsyncClient;
|
||||||
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
||||||
|
@ -43,6 +40,7 @@ import org.testng.annotations.Test;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudVersions}
|
* Tests behavior of {@code VCloudVersions}
|
||||||
|
@ -50,15 +48,19 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "vcloud.VCloudVersionsTest")
|
@Test(groups = "unit", testName = "vcloud.VCloudVersionsTest")
|
||||||
public class VCloudVersionsTest extends RestClientTest<VCloudVersionsAsyncClient> {
|
public class VCloudVersionsTest extends
|
||||||
|
RestClientTest<VCloudVersionsAsyncClient> {
|
||||||
|
|
||||||
public void testLogin() throws SecurityException, NoSuchMethodException, IOException {
|
public void testLogin() throws SecurityException, NoSuchMethodException,
|
||||||
Method method = VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions");
|
IOException {
|
||||||
GeneratedHttpRequest<VCloudVersionsAsyncClient> httpMethod = processor.createRequest(method);
|
Method method = VCloudVersionsAsyncClient.class
|
||||||
|
.getMethod("getSupportedVersions");
|
||||||
|
GeneratedHttpRequest<VCloudVersionsAsyncClient> httpMethod = processor
|
||||||
|
.createRequest(method);
|
||||||
|
|
||||||
assertEquals(httpMethod.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
|
assertEquals(httpMethod.getRequestLine(),
|
||||||
assertHeadersEqual(httpMethod, HttpHeaders.ACCEPT
|
"GET http://localhost:8080/versions HTTP/1.1");
|
||||||
+ ": application/vnd.vmware.vcloud.vcloud+xml\n");
|
assertHeadersEqual(httpMethod, "");
|
||||||
assertPayloadEquals(httpMethod, null);
|
assertPayloadEquals(httpMethod, null);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
@ -69,7 +71,8 @@ public class VCloudVersionsTest extends RestClientTest<VCloudVersionsAsyncClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(GeneratedHttpRequest<VCloudVersionsAsyncClient> httpMethod) {
|
protected void checkFilters(
|
||||||
|
GeneratedHttpRequest<VCloudVersionsAsyncClient> httpMethod) {
|
||||||
assertEquals(httpMethod.getFilters().size(), 0);
|
assertEquals(httpMethod.getFilters().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,9 +88,10 @@ public class VCloudVersionsTest extends RestClientTest<VCloudVersionsAsyncClient
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Names.bindProperties(binder(), checkNotNull(
|
Names.bindProperties(binder(), checkNotNull(
|
||||||
new VCloudPropertiesBuilder(new Properties()).build(), "properties"));
|
new VCloudPropertiesBuilder(new Properties()).build(),
|
||||||
|
"properties"));
|
||||||
bind(URI.class).annotatedWith(VCloud.class).toInstance(
|
bind(URI.class).annotatedWith(VCloud.class).toInstance(
|
||||||
URI.create("http://localhost:8080"));
|
URI.create("http://localhost:8080"));
|
||||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||||
public Logger getLogger(String category) {
|
public Logger getLogger(String category) {
|
||||||
return Logger.NULL;
|
return Logger.NULL;
|
||||||
|
|
|
@ -31,11 +31,10 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import com.google.inject.name.Names;
|
|
||||||
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.FenceMode;
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
|
@ -45,6 +44,7 @@ import com.google.common.collect.Multimaps;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
|
* Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
|
||||||
|
@ -58,63 +58,68 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props
|
props.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
||||||
.put(PROPERTY_VCLOUD_DEFAULT_NETWORK,
|
"https://vcloud.safesecureweb.com/network/1990");
|
||||||
"https://vcloud.safesecureweb.com/network/1990");
|
Names.bindProperties(binder(), checkNotNull(
|
||||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(),
|
new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||||
"properties"));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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"));
|
||||||
Multimap<String, String> headers = Multimaps.synchronizedMultimap(HashMultimap
|
Multimap<String, String> headers = Multimaps
|
||||||
.<String, String> create());
|
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
expect(request.getEndpoint()).andReturn(
|
||||||
|
URI.create("http://localhost/key")).anyTimes();
|
||||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null).atLeastOnce();
|
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null)
|
||||||
|
.atLeastOnce();
|
||||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||||
request.setPayload(expected);
|
request.setPayload(expected);
|
||||||
replay(request);
|
replay(request);
|
||||||
|
|
||||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||||
|
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("name", "my-vapp");
|
map.put("name", "my-vapp");
|
||||||
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
map.put("template",
|
||||||
|
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||||
binder.bindToRequest(request, map);
|
binder.bindToRequest(request, map);
|
||||||
verify(request);
|
verify(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithProcessorMemoryDisk() throws IOException {
|
public void testWithProcessorMemoryDisk() throws IOException {
|
||||||
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
|
options.processorCount(1).memory(512).disk(1024);
|
||||||
|
|
||||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
"/newvapp-hostingcpumemdisk.xml"));
|
"/newvapp-hostingcpumemdisk.xml"));
|
||||||
Multimap<String, String> headers = Multimaps.synchronizedMultimap(HashMultimap
|
Multimap<String, String> headers = Multimaps
|
||||||
.<String, String> create());
|
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
expect(request.getEndpoint()).andReturn(
|
||||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
URI.create("http://localhost/key")).anyTimes();
|
||||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] { options })
|
||||||
|
.atLeastOnce();
|
||||||
|
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null)
|
||||||
|
.atLeastOnce();
|
||||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||||
request.setPayload(expected);
|
request.setPayload(expected);
|
||||||
replay(request);
|
replay(request);
|
||||||
|
|
||||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||||
|
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("name", "my-vapp");
|
map.put("name", "my-vapp");
|
||||||
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
map.put("template",
|
||||||
|
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||||
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||||
|
|
||||||
map.put(ResourceType.PROCESSOR.value(), "1");
|
|
||||||
map.put(ResourceType.MEMORY.value(), "512");
|
|
||||||
map.put(ResourceType.DISK_DRIVE.value(), "1024");
|
|
||||||
|
|
||||||
binder.bindToRequest(request, map);
|
binder.bindToRequest(request, map);
|
||||||
verify(request);
|
verify(request);
|
||||||
|
|
||||||
|
@ -122,27 +127,29 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||||
|
|
||||||
public void testWithNetworkNameDhcpFenceMode() throws IOException {
|
public void testWithNetworkNameDhcpFenceMode() throws IOException {
|
||||||
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
String expected = Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
"/newvapp-hostingnetworknamedhcpfencemode.xml"));
|
"/newvapp-hostingnetworknamedhcpfencemode.xml"));
|
||||||
Multimap<String, String> headers = Multimaps.synchronizedMultimap(HashMultimap
|
Multimap<String, String> headers = Multimaps
|
||||||
.<String, String> create());
|
.synchronizedMultimap(HashMultimap.<String, String> create());
|
||||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||||
expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
|
expect(request.getEndpoint()).andReturn(
|
||||||
|
URI.create("http://localhost/key")).anyTimes();
|
||||||
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
expect(request.getArgs()).andReturn(new Object[] {}).atLeastOnce();
|
||||||
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null).atLeastOnce();
|
expect(request.getFirstHeaderOrNull("Content-Type")).andReturn(null)
|
||||||
|
.atLeastOnce();
|
||||||
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
expect(request.getHeaders()).andReturn(headers).atLeastOnce();
|
||||||
request.setPayload(expected);
|
request.setPayload(expected);
|
||||||
replay(request);
|
replay(request);
|
||||||
|
|
||||||
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
BindInstantiateVAppTemplateParamsToXmlPayload binder = injector
|
||||||
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);
|
||||||
|
|
||||||
Map<String, String> map = Maps.newHashMap();
|
Map<String, String> map = Maps.newHashMap();
|
||||||
map.put("name", "my-vapp");
|
map.put("name", "my-vapp");
|
||||||
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
map.put("template",
|
||||||
|
"https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||||
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||||
map.put("networkName", "aloha");
|
map.put("networkName", "aloha");
|
||||||
map.put("fenceMode", FenceMode.BRIDGED.toString());
|
map.put("fenceMode", FenceMode.BRIDGED);
|
||||||
map.put("dhcpEnabled", "true");
|
|
||||||
|
|
||||||
binder.bindToRequest(request, map);
|
binder.bindToRequest(request, map);
|
||||||
verify(request);
|
verify(request);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import static org.easymock.classextension.EasyMock.replay;
|
||||||
import static org.easymock.classextension.EasyMock.verify;
|
import static org.easymock.classextension.EasyMock.verify;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -42,17 +43,25 @@ public class EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetNextName() {
|
public void testGetNextName() {
|
||||||
|
SecureRandom random = createMock(SecureRandom.class);
|
||||||
|
expect(random.nextInt(255)).andReturn(12).atLeastOnce();
|
||||||
|
|
||||||
|
replay(random);
|
||||||
|
|
||||||
EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategy strategy = new EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategy(
|
EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategy strategy = new EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategy(
|
||||||
createNiceMock(AddNodeWithTagStrategy.class),
|
createNiceMock(AddNodeWithTagStrategy.class),
|
||||||
createNiceMock(ListNodesStrategy.class), "%s-%s%s",
|
createNiceMock(ListNodesStrategy.class), "%s-%s%s",
|
||||||
createNiceMock(ComputeUtils.class), createNiceMock(ExecutorService.class));
|
createNiceMock(ComputeUtils.class),
|
||||||
|
createNiceMock(ExecutorService.class), random);
|
||||||
|
|
||||||
String oldName = null;
|
String oldName = null;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
Template template = createMock(Template.class);
|
Template template = createMock(Template.class);
|
||||||
Image image = createMock(Image.class);
|
Image image = createMock(Image.class);
|
||||||
|
|
||||||
expect(template.getImage()).andReturn(image);
|
expect(template.getImage()).andReturn(image);
|
||||||
expect(image.getProviderId()).andReturn("233");
|
expect(image.getProviderId()).andReturn("233");
|
||||||
|
|
||||||
replay(template);
|
replay(template);
|
||||||
replay(image);
|
replay(image);
|
||||||
|
|
||||||
|
@ -67,9 +76,12 @@ public class EncodeTemplateIdIntoNameRunNodesAndAddToSetStrategyTest {
|
||||||
System.out.println(name);
|
System.out.println(name);
|
||||||
assertEquals(name.substring(5, 8), "0e9");
|
assertEquals(name.substring(5, 8), "0e9");
|
||||||
assert name.substring(8, 9).matches("[0-9a-f]+");
|
assert name.substring(8, 9).matches("[0-9a-f]+");
|
||||||
|
|
||||||
verify(template);
|
verify(template);
|
||||||
verify(image);
|
verify(image);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
verify(random);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,118 +18,100 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.compute.strategy;
|
package org.jclouds.vcloud.compute.strategy;
|
||||||
|
|
||||||
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 java.io.IOException;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import javax.inject.Provider;
|
|
||||||
|
|
||||||
import org.jclouds.compute.domain.Image;
|
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
|
||||||
import org.jclouds.compute.domain.NodeState;
|
|
||||||
import org.jclouds.domain.Location;
|
|
||||||
import org.jclouds.domain.LocationScope;
|
|
||||||
import org.jclouds.domain.internal.LocationImpl;
|
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
|
||||||
import org.jclouds.vcloud.compute.VCloudComputeClient;
|
|
||||||
import org.jclouds.vcloud.compute.functions.FindLocationForResourceInVDC;
|
|
||||||
import org.jclouds.vcloud.compute.functions.GetExtra;
|
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
|
||||||
import org.jclouds.vcloud.domain.ResourceAllocation;
|
import org.jclouds.vcloud.domain.ResourceAllocation;
|
||||||
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.domain.VirtualSystem;
|
import org.jclouds.vcloud.domain.VirtualSystem;
|
||||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.VAppImpl;
|
import org.jclouds.vcloud.domain.internal.VAppImpl;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.ImmutableSortedSet;
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import com.google.inject.util.Providers;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "vcloud.VCloudListNodesStrategyTest")
|
@Test(groups = "unit", testName = "vcloud.VCloudListNodesStrategyTest")
|
||||||
public class VCloudListNodesStrategyTest {
|
public class VCloudListNodesStrategyTest {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private VApp newVApp() throws UnknownHostException {
|
private VApp newVApp() throws UnknownHostException {
|
||||||
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap.<String, String> of(
|
ListMultimap<String, String> networkToAddresses = ImmutableListMultimap
|
||||||
"Network 1", "127.0.0.1");
|
.<String, String> of("Network 1", "127.0.0.1");
|
||||||
|
|
||||||
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
|
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family",
|
||||||
|
"SimpleVM", "vmx-07");
|
||||||
|
|
||||||
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
||||||
.<ResourceAllocation> naturalOrder().add(
|
.<ResourceAllocation> naturalOrder().add(
|
||||||
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
|
new ResourceAllocation(1, "1 virtual CPU(s)",
|
||||||
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
|
"Number of Virtual CPUs", ResourceType.PROCESSOR, null,
|
||||||
"hertz * 10^6"),
|
null, null, null, null, null, 1, "hertz * 10^6"),
|
||||||
new ResourceAllocation(2, "512MB of memory", "Memory Size",
|
new ResourceAllocation(2, "512MB of memory", "Memory Size",
|
||||||
ResourceType.MEMORY, null, null, null, null, null, null, 512,
|
ResourceType.MEMORY, null, null, null, null, null,
|
||||||
"byte * 2^20")).add(
|
null, 512, "byte * 2^20")).add(
|
||||||
|
|
||||||
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
|
new ResourceAllocation(3, "SCSI Controller 0",
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
|
"SCSI Controller", ResourceType.SCSI_CONTROLLER,
|
||||||
null, 1, null)).add(
|
"lsilogic", null, 0, null, null, null, 1, null)).add(
|
||||||
|
|
||||||
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
new ResourceAllocation(9, "Hard Disk 1", null,
|
||||||
null, "20971520", null, 0, 3, null, 20971520, "byte * 2^20"))
|
ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3,
|
||||||
.build();
|
null, 20971520, "byte * 2^20")).build();
|
||||||
|
|
||||||
return new VAppImpl("10", "10", URI
|
return new VAppImpl("10", "10", URI
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/10"), VAppStatus.OFF,
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/10"),
|
||||||
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
|
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null,
|
||||||
|
system, resourceAllocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
// consistency delay specifically in terremark beta where a vapp is present for listing, but not
|
// TODO rewrite this test
|
||||||
|
//
|
||||||
|
// consistency delay specifically in terremark beta where a vapp is present
|
||||||
|
// for listing, but not
|
||||||
// yet available for get vapp command.
|
// yet available for get vapp command.
|
||||||
@Test
|
// @Test
|
||||||
public void testRetryOnVAppNotFoundForGetVAppEvenWhenPresentInAvailableResources()
|
// public void
|
||||||
throws ExecutionException, InterruptedException, TimeoutException, IOException {
|
// testRetryOnVAppNotFoundForGetVAppEvenWhenPresentInAvailableResources()
|
||||||
VCloudClient client = createMock(VCloudClient.class);
|
// throws ExecutionException, InterruptedException, TimeoutException,
|
||||||
GetExtra getExtra = new GetExtra();
|
// IOException {
|
||||||
|
// VCloudClient client = createMock(VCloudClient.class);
|
||||||
VCloudComputeClient computeClient = createMock(VCloudComputeClient.class);
|
// GetExtra getExtra = new GetExtra();
|
||||||
Map<VAppStatus, NodeState> vAppStatusToNodeState = Maps.newHashMap();
|
//
|
||||||
VApp vApp = newVApp();
|
// VCloudComputeClient computeClient = createMock(VCloudComputeClient.class);
|
||||||
expect(client.getVApp("10")).andThrow(new NullPointerException());
|
// Map<VAppStatus, NodeState> vAppStatusToNodeState = Maps.newHashMap();
|
||||||
expect(client.getVApp("10")).andThrow(new NullPointerException());
|
// VApp vApp = newVApp();
|
||||||
expect(client.getVApp("10")).andReturn(vApp);
|
// expect(client.getVApp("10")).andThrow(new NullPointerException());
|
||||||
|
// expect(client.getVApp("10")).andThrow(new NullPointerException());
|
||||||
replay(client);
|
// expect(client.getVApp("10")).andReturn(vApp);
|
||||||
replay(computeClient);
|
//
|
||||||
|
// replay(client);
|
||||||
Location vdcL = new LocationImpl(LocationScope.ZONE, "1", "1", null);
|
// replay(computeClient);
|
||||||
Provider<Set<? extends Location>> locations = Providers
|
//
|
||||||
.<Set<? extends Location>> of(ImmutableSet.of(vdcL));
|
// Location vdcL = new LocationImpl(LocationScope.ZONE, "1", "1", null);
|
||||||
Provider<Set<? extends Image>> images = Providers.<Set<? extends Image>> of(ImmutableSet
|
// Provider<Set<? extends Location>> locations = Providers
|
||||||
.<Image> of());
|
// .<Set<? extends Location>> of(ImmutableSet.of(vdcL));
|
||||||
FindLocationForResourceInVDC findLocationForResourceInVDC = new FindLocationForResourceInVDC(
|
// Provider<Set<? extends Image>> images = Providers
|
||||||
locations, null);
|
// .<Set<? extends Image>> of(ImmutableSet.<Image> of());
|
||||||
VCloudListNodesStrategy strategy = new VCloudListNodesStrategy(client, computeClient,
|
// FindLocationForResourceInVDC findLocationForResourceInVDC = new
|
||||||
vAppStatusToNodeState, getExtra, findLocationForResourceInVDC, images);
|
// FindLocationForResourceInVDC(
|
||||||
|
// locations, null);
|
||||||
Set<NodeMetadata> nodes = Sets.newHashSet();
|
// VCloudListNodesStrategy strategy = new VCloudListNodesStrategy(client,
|
||||||
NamedResource vdc = new NamedResourceImpl("1", null, null, null);
|
// computeClient, vAppStatusToNodeState, getExtra,
|
||||||
NamedResource resource = new NamedResourceImpl("10", null, null, null);
|
// findLocationForResourceInVDC, images);
|
||||||
|
//
|
||||||
strategy.addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
|
// Set<NodeMetadata> nodes = Sets.newHashSet();
|
||||||
|
// NamedResource vdc = new NamedResourceImpl("1", null, null, null);
|
||||||
verify(client);
|
// NamedResource resource = new NamedResourceImpl("10", null, null, null);
|
||||||
verify(computeClient);
|
//
|
||||||
}
|
// strategy.addVAppToSetRetryingIfNotYetPresent(nodes, vdc, resource);
|
||||||
|
//
|
||||||
|
// verify(client);
|
||||||
|
// verify(computeClient);
|
||||||
|
// }
|
||||||
}
|
}
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.options;
|
package org.jclouds.vcloud.options;
|
||||||
|
|
||||||
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.fenceMode;
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.inNetwork;
|
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.inNetwork;
|
||||||
|
@ -55,7 +54,8 @@ public class InstantiateVAppTemplateOptionsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInNetworkStatic() {
|
public void testInNetworkStatic() {
|
||||||
InstantiateVAppTemplateOptions options = inNetwork(URI.create("http://localhost"));
|
InstantiateVAppTemplateOptions options = inNetwork(URI
|
||||||
|
.create("http://localhost"));
|
||||||
assertEquals(options.getNetwork(), "http://localhost");
|
assertEquals(options.getNetwork(), "http://localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,27 +119,14 @@ public class InstantiateVAppTemplateOptionsTest {
|
||||||
@Test
|
@Test
|
||||||
public void testFenceMode() {
|
public void testFenceMode() {
|
||||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||||
options.fenceMode(FenceMode.BLOCK_IN_OUT);
|
options.fenceMode(FenceMode.BRIDGED);
|
||||||
assertEquals(options.getFenceMode(), "blockInOut");
|
assertEquals(options.getFenceMode(), "bridged");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFenceModeStatic() {
|
public void testFenceModeStatic() {
|
||||||
InstantiateVAppTemplateOptions options = fenceMode(FenceMode.BLOCK_IN_OUT);
|
InstantiateVAppTemplateOptions options = fenceMode(FenceMode.BRIDGED);
|
||||||
assertEquals(options.getFenceMode(), "blockInOut");
|
assertEquals(options.getFenceMode(), "bridged");
|
||||||
}
|
|
||||||
|
|
||||||
@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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,25 +54,33 @@ public class NetworkHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/network-terremark.xml");
|
InputStream is = getClass().getResourceAsStream("/network-terremark.xml");
|
||||||
injector = Guice.createInjector(new ParserModule());
|
injector = Guice.createInjector(new ParserModule());
|
||||||
factory = injector.getInstance(ParseSax.Factory.class);
|
factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
Network result = factory.create(
|
||||||
assertEquals(result, new NetworkImpl("1708", "10.114.34.128/26", URI
|
injector.getInstance(NetworkHandler.class)).parse(is);
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"), null,
|
assertEquals(
|
||||||
ImmutableSet.<String> of(), "10.114.34.129", "255.255.255.192", ImmutableSet
|
result,
|
||||||
.<FenceMode> of(FenceMode.ISOLATED), null, ImmutableSet.<NatRule> of(),
|
new NetworkImpl(
|
||||||
ImmutableSet.<FirewallRule> of()));
|
"1708",
|
||||||
|
"10.114.34.128/26",
|
||||||
|
URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"),
|
||||||
|
null, ImmutableSet.<String> of(), "10.114.34.129",
|
||||||
|
"255.255.255.192", ImmutableSet
|
||||||
|
.<String> of(FenceMode.ISOLATED), null, ImmutableSet
|
||||||
|
.<NatRule> of(), ImmutableSet.<FirewallRule> of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testHosting() throws UnknownHostException {
|
public void testHosting() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/network-hosting.xml");
|
InputStream is = getClass().getResourceAsStream("/network-hosting.xml");
|
||||||
injector = Guice.createInjector(new ParserModule());
|
injector = Guice.createInjector(new ParserModule());
|
||||||
factory = injector.getInstance(ParseSax.Factory.class);
|
factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
Network result = (Network) factory.create(injector.getInstance(NetworkHandler.class)).parse(
|
Network result = (Network) factory.create(
|
||||||
is);
|
injector.getInstance(NetworkHandler.class)).parse(is);
|
||||||
assertEquals(result, new NetworkImpl("1183", "188849 trust", URI
|
assertEquals(result, new NetworkImpl("1183", "188849 trust", URI
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"), "188849 trust",
|
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"),
|
||||||
ImmutableSet.<String> of("76.12.32.110", "208.112.89.187"), "204.12.53.89",
|
"188849 trust", ImmutableSet.<String> of("76.12.32.110",
|
||||||
"255.255.255.248", ImmutableSet.<FenceMode> of(), null, ImmutableSet.<NatRule> of(),
|
"208.112.89.187"), "204.12.53.89", "255.255.255.248",
|
||||||
ImmutableSet.<FirewallRule> of()));
|
ImmutableSet.<String> of(), null, ImmutableSet.<NatRule> of(),
|
||||||
|
ImmutableSet.<FirewallRule> of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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="my-vapp"><Features><FenceMode>allowInOut</FenceMode><Dhcp>false</Dhcp></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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="my-vapp"><Features><FenceMode>allowInOut</FenceMode></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
|
@ -1 +1 @@
|
||||||
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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><VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8"><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1024</VirtualQuantity></Item></VirtualHardwareSection><NetworkConfigSection><NetworkConfig name="my-vapp"><Features><FenceMode>allowInOut</FenceMode><Dhcp>false</Dhcp></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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><VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8"><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">512</VirtualQuantity></Item><Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1024</VirtualQuantity></Item></VirtualHardwareSection><NetworkConfigSection><NetworkConfig name="my-vapp"><Features><FenceMode>allowInOut</FenceMode></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
|
@ -1 +1 @@
|
||||||
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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>
|
<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="my-vapp" 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="my-vapp"><Features><FenceMode>allowInOut</FenceMode></Features><NetworkAssociation href="https://vcloud.safesecureweb.com/network/1990"/></NetworkConfig></NetworkConfigSection></InstantiationParams></InstantiateVAppTemplateParams>
|
Loading…
Reference in New Issue