mirror of https://github.com/apache/jclouds.git
Issue 280: converged vcloud 0.8 and 1.0 OrgNetwork objects
This commit is contained in:
parent
44c294f76a
commit
13c9828345
|
@ -46,13 +46,13 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TasksList;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||
|
@ -63,8 +63,8 @@ import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint;
|
|||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.jclouds.vcloud.xml.NetworkHandler;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
@ -169,9 +169,9 @@ public interface CommonVCloudAsyncClient {
|
|||
*/
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
@XMLResponseParser(NetworkHandler.class)
|
||||
@XMLResponseParser(OrgNetworkHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends Network> findNetworkInOrgVDCNamed(
|
||||
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||
|
@ -181,9 +181,9 @@ public interface CommonVCloudAsyncClient {
|
|||
*/
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
@XMLResponseParser(NetworkHandler.class)
|
||||
@XMLResponseParser(OrgNetworkHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI network);
|
||||
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#getVDC(URI)
|
||||
|
|
|
@ -28,21 +28,19 @@ import javax.annotation.Nullable;
|
|||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TasksList;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
|
||||
/**
|
||||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a
|
||||
* href="http://communities.vmware.com/community/developer/forums/vcloudapi"
|
||||
* />
|
||||
* @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -51,8 +49,8 @@ public interface CommonVCloudClient {
|
|||
Org getOrg(URI orgId);
|
||||
|
||||
/**
|
||||
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and
|
||||
* task lists within the organization.
|
||||
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within
|
||||
* the organization.
|
||||
*
|
||||
* @param name
|
||||
* organization name, or null for the default
|
||||
|
@ -64,8 +62,8 @@ public interface CommonVCloudClient {
|
|||
Catalog getCatalog(URI catalogId);
|
||||
|
||||
/**
|
||||
* returns the catalog in the organization associated with the specified
|
||||
* name. Note that both parameters can be null to choose default.
|
||||
* returns the catalog in the organization associated with the specified name. Note that both
|
||||
* parameters can be null to choose default.
|
||||
*
|
||||
* @param orgName
|
||||
* organization name, or null for the default
|
||||
|
@ -79,9 +77,8 @@ public interface CommonVCloudClient {
|
|||
CatalogItem getCatalogItem(URI catalogItem);
|
||||
|
||||
/**
|
||||
* returns the catalog item in the catalog associated with the specified
|
||||
* name. Note that the org and catalog parameters can be null to choose
|
||||
* default.
|
||||
* returns the catalog item in the catalog associated with the specified name. Note that the org
|
||||
* and catalog parameters can be null to choose default.
|
||||
*
|
||||
* @param orgName
|
||||
* organization name, or null for the default
|
||||
|
@ -91,17 +88,15 @@ public interface CommonVCloudClient {
|
|||
* item you wish to lookup
|
||||
*
|
||||
* @throws NoSuchElementException
|
||||
* if you specified an org, catalog, or catalog item name that
|
||||
* isn't present
|
||||
* if you specified an org, catalog, or catalog item name that isn't present
|
||||
*/
|
||||
CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName);
|
||||
|
||||
VAppTemplate getVAppTemplate(URI vAppTemplate);
|
||||
|
||||
/**
|
||||
* returns the vapp template corresponding to a catalog item in the catalog
|
||||
* associated with the specified name. Note that the org and catalog
|
||||
* parameters can be null to choose default.
|
||||
* returns the vapp template corresponding to a catalog item in the catalog associated with the
|
||||
* specified name. Note that the org and catalog parameters can be null to choose default.
|
||||
*
|
||||
* @param orgName
|
||||
* organization name, or null for the default
|
||||
|
@ -111,21 +106,20 @@ public interface CommonVCloudClient {
|
|||
* item you wish to lookup
|
||||
*
|
||||
* @throws NoSuchElementException
|
||||
* if you specified an org, catalog, or catalog item name that
|
||||
* isn't present
|
||||
* if you specified an org, catalog, or catalog item name that isn't present
|
||||
*/
|
||||
VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
|
||||
String itemName);
|
||||
|
||||
Network findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName);
|
||||
OrgNetwork findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName);
|
||||
|
||||
Network getNetwork(URI network);
|
||||
OrgNetwork getNetwork(URI network);
|
||||
|
||||
VDC getVDC(URI vdc);
|
||||
|
||||
/**
|
||||
* returns the VDC in the organization associated with the specified name.
|
||||
* Note that both parameters can be null to choose default.
|
||||
* returns the VDC in the organization associated with the specified name. Note that both
|
||||
* parameters can be null to choose default.
|
||||
*
|
||||
* @param orgName
|
||||
* organization name, or null for the default
|
||||
|
@ -147,14 +141,12 @@ public interface CommonVCloudClient {
|
|||
Task undeployVApp(URI vAppId);
|
||||
|
||||
/**
|
||||
* This call powers on the vApp, as specified in the vApp's ovf:Startup
|
||||
* element.
|
||||
* This call powers on the vApp, as specified in the vApp's ovf:Startup element.
|
||||
*/
|
||||
Task powerOnVApp(URI vAppId);
|
||||
|
||||
/**
|
||||
* This call powers off the vApp, as specified in the vApp's ovf:Startup
|
||||
* element.
|
||||
* This call powers off the vApp, as specified in the vApp's ovf:Startup element.
|
||||
*/
|
||||
Task powerOffVApp(URI vAppId);
|
||||
|
||||
|
|
|
@ -19,30 +19,38 @@
|
|||
|
||||
package org.jclouds.vcloud;
|
||||
|
||||
import static org.jclouds.vcloud.VCloudMediaType.NETWORK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.predicates.validators.DnsNameValidator;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.MapPayloadParam;
|
||||
import org.jclouds.rest.annotations.ParamValidators;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
||||
|
@ -57,6 +65,28 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
*/
|
||||
@RequestFilters(SetVCloudTokenCookie.class)
|
||||
public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
||||
/**
|
||||
* @see VCloudClient#findNetworkInOrgVDCNamed
|
||||
*/
|
||||
@Override
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
@XMLResponseParser(OrgNetworkFromVCloudExpressNetworkHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#getNetwork
|
||||
*/
|
||||
@Override
|
||||
@GET
|
||||
@Consumes(NETWORK_XML)
|
||||
@XMLResponseParser(OrgNetworkFromVCloudExpressNetworkHandler.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
|
||||
|
||||
/**
|
||||
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
|
||||
|
|
|
@ -30,7 +30,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_S
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
|
||||
/**
|
||||
* Builds properties used in VCloud Clients
|
||||
|
@ -67,7 +67,7 @@ public class VCloudExpressPropertiesBuilder extends PropertiesBuilder {
|
|||
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);
|
||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_S
|
|||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.PropertiesBuilder;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
|
||||
/**
|
||||
* Builds properties used in VCloud Clients
|
||||
|
@ -44,11 +44,10 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
|||
properties.setProperty(PROPERTY_API_VERSION, "1.0");
|
||||
properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1.0");
|
||||
properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
|
||||
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
|
||||
"http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
||||
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
|
||||
properties.setProperty("jclouds.dns_name_length_min", "1");
|
||||
properties.setProperty("jclouds.dns_name_length_max", "80");
|
||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED);
|
||||
properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString());
|
||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 180l * 1000l + "");
|
||||
return properties;
|
||||
}
|
||||
|
@ -63,7 +62,6 @@ public class VCloudPropertiesBuilder extends PropertiesBuilder {
|
|||
+ properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
|
||||
}
|
||||
|
||||
|
||||
public VCloudPropertiesBuilder withApiVersion(String version) {
|
||||
properties.setProperty(PROPERTY_API_VERSION, "1.0");
|
||||
return this;
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.jclouds.vcloud.binders;
|
|||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||
|
@ -63,21 +64,19 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
protected final String ns;
|
||||
protected final String schema;
|
||||
private final BindToStringPayload stringBinder;
|
||||
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap
|
||||
.of(ResourceType.PROCESSOR, "1", ResourceType.MEMORY, "2",
|
||||
ResourceType.DISK_DRIVE, "9");
|
||||
protected final Map<ResourceType, String> virtualHardwareToInstanceId = ImmutableMap.of(ResourceType.PROCESSOR, "1",
|
||||
ResourceType.MEMORY, "2", ResourceType.DISK_DRIVE, "9");
|
||||
private final URI defaultNetwork;
|
||||
private final String defaultFenceMode;
|
||||
private final String apiVersion;
|
||||
|
||||
@Inject
|
||||
public BindInstantiateVAppTemplateParamsToXmlPayload(
|
||||
BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode
|
||||
) {
|
||||
public BindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_API_VERSION) String apiVersion, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
|
||||
this.ns = ns;
|
||||
this.apiVersion = apiVersion;
|
||||
this.schema = schema;
|
||||
this.stringBinder = stringBinder;
|
||||
this.defaultNetwork = URI.create(network);
|
||||
|
@ -86,17 +85,14 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||
checkArgument(
|
||||
checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
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 template = checkNotNull(postParams.remove("template"), "template");
|
||||
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity = Maps
|
||||
.newTreeMap();
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity = Maps.newTreeMap();
|
||||
|
||||
InstantiateVAppTemplateOptions options = findOptionsInArgsOrNull(gRequest);
|
||||
Map<String, String> properties = Maps.newTreeMap();
|
||||
|
@ -106,14 +102,15 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
if (options != null) {
|
||||
network = ifNullDefaultTo(options.getNetwork(), network);
|
||||
fenceMode = ifNullDefaultTo(options.getFenceMode(), defaultFenceMode);
|
||||
if (apiVersion.indexOf("0.8") != -1 && fenceMode.equals("bridged"))
|
||||
fenceMode = "allowInOut";
|
||||
networkName = ifNullDefaultTo(options.getNetworkName(), networkName);
|
||||
addQuantity(options, virtualHardwareQuantity);
|
||||
properties.putAll(options.getProperties());
|
||||
}
|
||||
try {
|
||||
stringBinder.bindToRequest(request, generateXml(name, template,
|
||||
properties, virtualHardwareQuantity, networkName, fenceMode, URI
|
||||
.create(network)));
|
||||
stringBinder.bindToRequest(request, generateXml(name, template, properties, virtualHardwareQuantity,
|
||||
networkName, fenceMode, URI.create(network)));
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (FactoryConfigurationError e) {
|
||||
|
@ -124,99 +121,73 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
|
||||
}
|
||||
|
||||
protected String generateXml(String name, String template,
|
||||
Map<String, String> properties,
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity,
|
||||
String networkName, @Nullable String fenceMode, URI network)
|
||||
throws ParserConfigurationException, FactoryConfigurationError,
|
||||
TransformerException {
|
||||
protected String generateXml(String name, String template, Map<String, String> properties,
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity, String networkName, @Nullable String fenceMode,
|
||||
URI network) throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
||||
XMLBuilder rootBuilder = buildRoot(name);
|
||||
|
||||
rootBuilder.e("VAppTemplate").a("href", template);
|
||||
|
||||
XMLBuilder instantiationParamsBuilder = rootBuilder
|
||||
.e("InstantiationParams");
|
||||
XMLBuilder instantiationParamsBuilder = rootBuilder.e("InstantiationParams");
|
||||
addPropertiesifPresent(instantiationParamsBuilder, properties);
|
||||
addVirtualQuantityIfPresent(instantiationParamsBuilder,
|
||||
virtualHardwareQuantity);
|
||||
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode,
|
||||
network);
|
||||
addVirtualQuantityIfPresent(instantiationParamsBuilder, virtualHardwareQuantity);
|
||||
addNetworkConfig(instantiationParamsBuilder, networkName, fenceMode, network);
|
||||
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);
|
||||
}
|
||||
|
||||
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder,
|
||||
Map<String, String> properties) {
|
||||
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder, Map<String, String> properties) {
|
||||
if (properties.size() > 0) {
|
||||
XMLBuilder productSectionBuilder = instantiationParamsBuilder.e(
|
||||
"ProductSection").a("xmlns:q1", ns).a("xmlns:ovf",
|
||||
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||
XMLBuilder productSectionBuilder = instantiationParamsBuilder.e("ProductSection").a("xmlns:q1", ns).a(
|
||||
"xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
|
||||
for (Entry<String, String> entry : properties.entrySet()) {
|
||||
productSectionBuilder.e("Property").a("xmlns",
|
||||
"http://schemas.dmtf.org/ovf/envelope/1").a("ovf:key",
|
||||
productSectionBuilder.e("Property").a("xmlns", "http://schemas.dmtf.org/ovf/envelope/1").a("ovf:key",
|
||||
entry.getKey()).a("ovf:value", entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder,
|
||||
String name, @Nullable String fenceMode, URI network) {
|
||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e(
|
||||
"NetworkConfigSection").e("NetworkConfig").a("name", name);
|
||||
protected void addNetworkConfig(XMLBuilder instantiationParamsBuilder, String name, @Nullable String fenceMode,
|
||||
URI network) {
|
||||
XMLBuilder networkConfigBuilder = instantiationParamsBuilder.e("NetworkConfigSection").e("NetworkConfig").a(
|
||||
"name", name);
|
||||
if (fenceMode != null) {
|
||||
XMLBuilder featuresBuilder = networkConfigBuilder.e("Features");
|
||||
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(XMLBuilder instantiationParamsBuilder,
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity) {
|
||||
if (virtualHardwareQuantity.size() > 0) {
|
||||
XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder
|
||||
.e("VirtualHardwareSection").a("xmlns:q1", ns);
|
||||
for (Entry<ResourceType, String> entry : virtualHardwareQuantity
|
||||
.entrySet()) {
|
||||
XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a(
|
||||
"xmlns", "http://schemas.dmtf.org/ovf/envelope/1");
|
||||
itemBuilder
|
||||
.e("InstanceID")
|
||||
.a(
|
||||
"xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||
.t(virtualHardwareToInstanceId.get(entry.getKey()));
|
||||
itemBuilder
|
||||
.e("ResourceType")
|
||||
.a(
|
||||
"xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||
.t(entry.getKey().value());
|
||||
itemBuilder
|
||||
.e("VirtualQuantity")
|
||||
.a(
|
||||
"xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData")
|
||||
.t(entry.getValue());
|
||||
XMLBuilder virtualHardwareSectionBuilder = instantiationParamsBuilder.e("VirtualHardwareSection").a(
|
||||
"xmlns:q1", ns);
|
||||
for (Entry<ResourceType, String> entry : virtualHardwareQuantity.entrySet()) {
|
||||
XMLBuilder itemBuilder = virtualHardwareSectionBuilder.e("Item").a("xmlns",
|
||||
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||
itemBuilder.e("InstanceID").a("xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData").t(
|
||||
virtualHardwareToInstanceId.get(entry.getKey()));
|
||||
itemBuilder.e("ResourceType").a("xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData").t(
|
||||
entry.getKey().value());
|
||||
itemBuilder.e("VirtualQuantity").a("xmlns",
|
||||
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData").t(
|
||||
entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected XMLBuilder buildRoot(String name)
|
||||
throws ParserConfigurationException, FactoryConfigurationError {
|
||||
XMLBuilder rootBuilder = XMLBuilder.create(
|
||||
"InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns).a(
|
||||
"xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance").a(
|
||||
"xsi:schemaLocation", ns + " " + schema).a("xmlns:ovf",
|
||||
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||
protected XMLBuilder buildRoot(String name) throws ParserConfigurationException, FactoryConfigurationError {
|
||||
XMLBuilder rootBuilder = XMLBuilder.create("InstantiateVAppTemplateParams").a("name", name).a("xmlns", ns).a(
|
||||
"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;
|
||||
}
|
||||
|
||||
protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(
|
||||
GeneratedHttpRequest<?> gRequest) {
|
||||
protected InstantiateVAppTemplateOptions findOptionsInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
|
||||
for (Object arg : gRequest.getArgs()) {
|
||||
if (arg instanceof InstantiateVAppTemplateOptions) {
|
||||
return (InstantiateVAppTemplateOptions) arg;
|
||||
|
@ -228,28 +199,23 @@ public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder
|
|||
return null;
|
||||
}
|
||||
|
||||
private void addQuantity(InstantiateVAppTemplateOptions options,
|
||||
Map<ResourceType, String> virtualHardwareQuantity) {
|
||||
private void addQuantity(InstantiateVAppTemplateOptions options, Map<ResourceType, String> virtualHardwareQuantity) {
|
||||
if (options.getCpuCount() != null) {
|
||||
virtualHardwareQuantity.put(ResourceType.PROCESSOR, options
|
||||
.getCpuCount());
|
||||
virtualHardwareQuantity.put(ResourceType.PROCESSOR, options.getCpuCount());
|
||||
}
|
||||
if (options.getMemorySizeMegabytes() != null) {
|
||||
virtualHardwareQuantity.put(ResourceType.MEMORY, options
|
||||
.getMemorySizeMegabytes());
|
||||
virtualHardwareQuantity.put(ResourceType.MEMORY, options.getMemorySizeMegabytes());
|
||||
}
|
||||
if (options.getDiskSizeKilobytes() != null) {
|
||||
virtualHardwareQuantity.put(ResourceType.DISK_DRIVE, options
|
||||
.getDiskSizeKilobytes());
|
||||
virtualHardwareQuantity.put(ResourceType.DISK_DRIVE, options.getDiskSizeKilobytes());
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
return value != null ? value : checkNotNull(defaultValue, "defaultValue");
|
||||
protected String ifNullDefaultTo(Object value, String defaultValue) {
|
||||
return value != null ? value.toString() : checkNotNull(defaultValue, "defaultValue");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class FirewallRule {
|
||||
public static enum Policy {
|
||||
DENY, ALLOW;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static Policy fromValue(String policy) {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy,
|
||||
"policy")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static enum Protocol {
|
||||
TCP, UDP, ICMP;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static Protocol fromValue(String protocol) {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(
|
||||
protocol, "protocol")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Policy policy;
|
||||
private final Protocol protocol;
|
||||
private final String sourceIP;
|
||||
private final String sourcePort;
|
||||
|
||||
public FirewallRule(Policy policy, Protocol protocol, String sourceIP, String sourcePort) {
|
||||
this.policy = policy;
|
||||
this.protocol = protocol;
|
||||
this.sourceIP = sourceIP;
|
||||
this.sourcePort = sourcePort;
|
||||
}
|
||||
|
||||
/**
|
||||
* One of deny, allow
|
||||
*/
|
||||
public Policy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* An attribute that specifies the protocol to which the rule applies. One of tcp, udp, icmp
|
||||
*/
|
||||
public Protocol getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* An IP address to which this rule applies
|
||||
*/
|
||||
public String getSourceIP() {
|
||||
return sourceIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* An IP port or port range to which this rule applies. A value of * specifies all ports.
|
||||
*/
|
||||
public String getSourcePort() {
|
||||
return sourcePort;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* The MappingMode element specifies how IP address mapping is implemented by the NAT service.
|
||||
*
|
||||
*/
|
||||
public enum MappingMode {
|
||||
/**
|
||||
* the external IP address is specified in the ExternalIP element
|
||||
*/
|
||||
MANUAL,
|
||||
/**
|
||||
* the external IP address is assigned automatically
|
||||
*/
|
||||
AUTOMATIC;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static MappingMode fromValue(String mode) {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(mode, "mode")));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
|
||||
/**
|
||||
* Specifies a set of Network Address Translation rules using a pair of IP addresses and a pair of
|
||||
* IP port numbers.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NatRule {
|
||||
private final String externalIP;
|
||||
private final Integer externalPort;
|
||||
private final String internalIP;
|
||||
private final Integer internalPort;
|
||||
|
||||
public NatRule(String externalIP, Integer externalPort, String IntegerernalIP,
|
||||
Integer IntegerernalPort) {
|
||||
this.externalIP = externalIP;
|
||||
this.externalPort = externalPort;
|
||||
this.internalIP = IntegerernalIP;
|
||||
this.internalPort = IntegerernalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* The externally‐visible IP address.
|
||||
*/
|
||||
public String getExternalIP() {
|
||||
return externalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* The externally‐visible IP port.
|
||||
*/
|
||||
public Integer getExternalPort() {
|
||||
return externalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Integerernally‐visible (non‐routable) IP address.
|
||||
*/
|
||||
public String getInternalIP() {
|
||||
return internalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Integerernally‐visible IP port.
|
||||
*/
|
||||
public Integer getInternalPort() {
|
||||
return internalPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode());
|
||||
result = prime * result + ((externalPort == null) ? 0 : externalPort.hashCode());
|
||||
result = prime * result + ((internalIP == null) ? 0 : internalIP.hashCode());
|
||||
result = prime * result + ((internalPort == null) ? 0 : internalPort.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NatRule other = (NatRule) obj;
|
||||
if (externalIP == null) {
|
||||
if (other.externalIP != null)
|
||||
return false;
|
||||
} else if (!externalIP.equals(other.externalIP))
|
||||
return false;
|
||||
if (externalPort == null) {
|
||||
if (other.externalPort != null)
|
||||
return false;
|
||||
} else if (!externalPort.equals(other.externalPort))
|
||||
return false;
|
||||
if (internalIP == null) {
|
||||
if (other.internalIP != null)
|
||||
return false;
|
||||
} else if (!internalIP.equals(other.internalIP))
|
||||
return false;
|
||||
if (internalPort == null) {
|
||||
if (other.internalPort != null)
|
||||
return false;
|
||||
} else if (!internalPort.equals(other.internalPort))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NatRule [externalIP=" + externalIP + ", externalPort=" + externalPort
|
||||
+ ", internalIP=" + internalIP + ", internalPort=" + internalPort + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -55,8 +55,7 @@ public int hashCode() {
|
|||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + id;
|
||||
result = prime * result
|
||||
+ ((identifier == null) ? 0 : identifier.hashCode());
|
||||
result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
|
@ -93,8 +92,7 @@ public boolean equals(Object obj) {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name
|
||||
+ ", type=" + type + "]";
|
||||
return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name + ", type=" + type + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* specifies the properties of the network’s DHCP service
|
||||
*/
|
||||
public class DhcpService {
|
||||
private final boolean enabled;
|
||||
@Nullable
|
||||
private final Integer defaultLeaseTime;
|
||||
@Nullable
|
||||
private final Integer maxLeaseTime;
|
||||
@Nullable
|
||||
private final IpRange ipRange;
|
||||
|
||||
public DhcpService(boolean enabled, @Nullable Integer defaultLeaseTime, @Nullable Integer maxLeaseTime,
|
||||
@Nullable IpRange ipRange) {
|
||||
this.enabled = enabled;
|
||||
this.defaultLeaseTime = defaultLeaseTime;
|
||||
this.maxLeaseTime = maxLeaseTime;
|
||||
this.ipRange = ipRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the service is enabled
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* default duration of a DCHP address lease
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public Integer getDefaultLeaseTime() {
|
||||
return defaultLeaseTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* maximum duration of a DCHP address lease.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public Integer getMaxLeaseTime() {
|
||||
return maxLeaseTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return range of IP addresses available to DHCP clients
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public IpRange getIpRange() {
|
||||
return ipRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((defaultLeaseTime == null) ? 0 : defaultLeaseTime.hashCode());
|
||||
result = prime * result + (enabled ? 1231 : 1237);
|
||||
result = prime * result + ((ipRange == null) ? 0 : ipRange.hashCode());
|
||||
result = prime * result + ((maxLeaseTime == null) ? 0 : maxLeaseTime.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
DhcpService other = (DhcpService) obj;
|
||||
if (defaultLeaseTime == null) {
|
||||
if (other.defaultLeaseTime != null)
|
||||
return false;
|
||||
} else if (!defaultLeaseTime.equals(other.defaultLeaseTime))
|
||||
return false;
|
||||
if (enabled != other.enabled)
|
||||
return false;
|
||||
if (ipRange == null) {
|
||||
if (other.ipRange != null)
|
||||
return false;
|
||||
} else if (!ipRange.equals(other.ipRange))
|
||||
return false;
|
||||
if (maxLeaseTime == null) {
|
||||
if (other.maxLeaseTime != null)
|
||||
return false;
|
||||
} else if (!maxLeaseTime.equals(other.maxLeaseTime))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[defaultLeaseTime=" + defaultLeaseTime + ", enabled=" + enabled + ", ipRange=" + ipRange
|
||||
+ ", maxLeaseTime=" + maxLeaseTime + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The Features element defines the DHCP and firewall features of a network.
|
||||
*/
|
||||
public class Features {
|
||||
@Nullable
|
||||
private final DhcpService dhcpService;
|
||||
@Nullable
|
||||
private final FirewallService firewallService;
|
||||
@Nullable
|
||||
private final NatService natService;
|
||||
|
||||
public Features(@Nullable DhcpService dhcpService, @Nullable FirewallService firewallService,
|
||||
@Nullable NatService natService) {
|
||||
this.dhcpService = dhcpService;
|
||||
this.firewallService = firewallService;
|
||||
this.natService = natService;
|
||||
}
|
||||
|
||||
/**
|
||||
* specifies the properties of the network’s DHCP service
|
||||
*
|
||||
* @since vcloud api 0.9, but emulated for 0.8
|
||||
*/
|
||||
@Nullable
|
||||
public DhcpService getDhcpService() {
|
||||
return dhcpService;
|
||||
}
|
||||
|
||||
/**
|
||||
* defines the firewall service capabilities of the network
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
@Nullable
|
||||
public FirewallService getFirewallService() {
|
||||
return firewallService;
|
||||
}
|
||||
|
||||
/**
|
||||
* defines the NAT service capabilities of the network
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
@Nullable
|
||||
public NatService getNatService() {
|
||||
return natService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((dhcpService == null) ? 0 : dhcpService.hashCode());
|
||||
result = prime * result + ((firewallService == null) ? 0 : firewallService.hashCode());
|
||||
result = prime * result + ((natService == null) ? 0 : natService.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Features other = (Features) obj;
|
||||
if (dhcpService == null) {
|
||||
if (other.dhcpService != null)
|
||||
return false;
|
||||
} else if (!dhcpService.equals(other.dhcpService))
|
||||
return false;
|
||||
if (firewallService == null) {
|
||||
if (other.firewallService != null)
|
||||
return false;
|
||||
} else if (!firewallService.equals(other.firewallService))
|
||||
return false;
|
||||
if (natService == null) {
|
||||
if (other.natService != null)
|
||||
return false;
|
||||
} else if (!natService.equals(other.natService))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[dhcpService=" + dhcpService + ", firewallService=" + firewallService + ", natService=" + natService
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* The FenceMode element contains one of the following strings that specify how a network is
|
||||
* connected to its parent network.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public enum FenceMode {
|
||||
/**
|
||||
* The two networks are bridged.
|
||||
* <p/>
|
||||
* Note that in vcloud 0.8 this was called ALLOW_IN_OUT, and so our implementation automatically
|
||||
* converts this for you. Use bridged instead of allowInOut.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
BRIDGED,
|
||||
/**
|
||||
* The two networks are not connected.
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
ISOLATED,
|
||||
/**
|
||||
* The two networks are connected as specified in their NatService elements.
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
NAT_ROUTED;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static FenceMode fromValue(String fenceMode) {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(fenceMode, "fenceMode")));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* The FirewallService element defines the firewall service capabilities of a network.
|
||||
*/
|
||||
public class FirewallService {
|
||||
private final boolean enabled;
|
||||
|
||||
List<FirewallRule> firewallRules = Lists.newArrayList();
|
||||
|
||||
public FirewallService(boolean enabled, Iterable<? extends FirewallRule> firewallRules) {
|
||||
this.enabled = enabled;
|
||||
Iterables.addAll(this.firewallRules, checkNotNull(firewallRules, "firewallRules"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Firewall rules for the network
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
public List<? extends FirewallRule> getFirewallRules() {
|
||||
return firewallRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the service is enabled
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (enabled ? 1231 : 1237);
|
||||
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FirewallService other = (FirewallService) obj;
|
||||
if (enabled != other.enabled)
|
||||
return false;
|
||||
if (firewallRules == null) {
|
||||
if (other.firewallRules != null)
|
||||
return false;
|
||||
} else if (!firewallRules.equals(other.firewallRules))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[enabled=" + enabled + ", firewallRules=" + firewallRules + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* The IpRange element defines a range of IP addresses available on a network.
|
||||
*
|
||||
*/
|
||||
public class IpRange {
|
||||
private final String startAddress;
|
||||
private final String endAddress;
|
||||
|
||||
public IpRange(String startAddress, String endAddress) {
|
||||
this.startAddress = checkNotNull(startAddress, "startAddress");
|
||||
this.endAddress = checkNotNull(endAddress, "endAddress");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return lowest IP address in the range
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public String getStartAddress() {
|
||||
return startAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return highest IP address in the range
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public String getEndAddress() {
|
||||
return endAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((endAddress == null) ? 0 : endAddress.hashCode());
|
||||
result = prime * result + ((startAddress == null) ? 0 : startAddress.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IpRange other = (IpRange) obj;
|
||||
if (endAddress == null) {
|
||||
if (other.endAddress != null)
|
||||
return false;
|
||||
} else if (!endAddress.equals(other.endAddress))
|
||||
return false;
|
||||
if (startAddress == null) {
|
||||
if (other.startAddress != null)
|
||||
return false;
|
||||
} else if (!startAddress.equals(other.startAddress))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[startAddress=" + startAddress + ", endAddress=" + endAddress + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The IpScope element defines the address range, gateway, netmask, and other properties of the
|
||||
* network.
|
||||
*
|
||||
*/
|
||||
public class IpScope {
|
||||
private final boolean inherited;
|
||||
@Nullable
|
||||
private final String gateway;
|
||||
@Nullable
|
||||
private final String netmask;
|
||||
@Nullable
|
||||
private final String dns1;
|
||||
@Nullable
|
||||
private final String dns2;
|
||||
@Nullable
|
||||
private final String dnsSuffix;
|
||||
private final Set<IpRange> ipRanges = Sets.newLinkedHashSet();
|
||||
private final Set<String> allocatedIpAddresses = Sets.newLinkedHashSet();
|
||||
|
||||
public IpScope(boolean inherited, @Nullable String gateway, @Nullable String netmask, @Nullable String dns1,
|
||||
@Nullable String dns2, @Nullable String dnsSuffix, Iterable<IpRange> ipRanges,
|
||||
Iterable<String> allocatedIpAddresses) {
|
||||
this.inherited = inherited;
|
||||
this.gateway = gateway;
|
||||
this.netmask = netmask;
|
||||
this.dns1 = dns1;
|
||||
this.dns2 = dns2;
|
||||
this.dnsSuffix = dnsSuffix;
|
||||
Iterables.addAll(this.ipRanges, checkNotNull(ipRanges, "ipRanges"));
|
||||
Iterables.addAll(this.allocatedIpAddresses, checkNotNull(allocatedIpAddresses, "allocatedIpAddresses"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true of the values in this IpScope element are inherited from the ParentNetwork of the
|
||||
* containing Configuration
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public boolean isInherited() {
|
||||
return inherited;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IP address of the network gateway
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
@Nullable
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return netmask to apply to addresses on the network
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
@Nullable
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IP address of the primary DNS server for this network
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public String getDns1() {
|
||||
return dns1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IP address of the secondary DNS server for this network
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public String getDns2() {
|
||||
return dns2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return suffix to be applied when resolving hostnames that are not fully‐qualified.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public String getDnsSuffix() {
|
||||
return dnsSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A container for IpRange elements.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public Set<IpRange> getIpRanges() {
|
||||
return ipRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A list of addresses allocated from any of the specified IpRanges
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public Set<String> getAllocatedIpAddresses() {
|
||||
return allocatedIpAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((allocatedIpAddresses == null) ? 0 : allocatedIpAddresses.hashCode());
|
||||
result = prime * result + ((dns1 == null) ? 0 : dns1.hashCode());
|
||||
result = prime * result + ((dns2 == null) ? 0 : dns2.hashCode());
|
||||
result = prime * result + ((dnsSuffix == null) ? 0 : dnsSuffix.hashCode());
|
||||
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
||||
result = prime * result + (inherited ? 1231 : 1237);
|
||||
result = prime * result + ((ipRanges == null) ? 0 : ipRanges.hashCode());
|
||||
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IpScope other = (IpScope) obj;
|
||||
if (allocatedIpAddresses == null) {
|
||||
if (other.allocatedIpAddresses != null)
|
||||
return false;
|
||||
} else if (!allocatedIpAddresses.equals(other.allocatedIpAddresses))
|
||||
return false;
|
||||
if (dns1 == null) {
|
||||
if (other.dns1 != null)
|
||||
return false;
|
||||
} else if (!dns1.equals(other.dns1))
|
||||
return false;
|
||||
if (dns2 == null) {
|
||||
if (other.dns2 != null)
|
||||
return false;
|
||||
} else if (!dns2.equals(other.dns2))
|
||||
return false;
|
||||
if (dnsSuffix == null) {
|
||||
if (other.dnsSuffix != null)
|
||||
return false;
|
||||
} else if (!dnsSuffix.equals(other.dnsSuffix))
|
||||
return false;
|
||||
if (gateway == null) {
|
||||
if (other.gateway != null)
|
||||
return false;
|
||||
} else if (!gateway.equals(other.gateway))
|
||||
return false;
|
||||
if (inherited != other.inherited)
|
||||
return false;
|
||||
if (ipRanges == null) {
|
||||
if (other.ipRanges != null)
|
||||
return false;
|
||||
} else if (!ipRanges.equals(other.ipRanges))
|
||||
return false;
|
||||
if (netmask == null) {
|
||||
if (other.netmask != null)
|
||||
return false;
|
||||
} else if (!netmask.equals(other.netmask))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[allocatedIpAddresses=" + allocatedIpAddresses + ", dns1=" + dns1 + ", dns2=" + dns2 + ", dnsSuffix="
|
||||
+ dnsSuffix + ", gateway=" + gateway + ", inherited=" + inherited + ", ipRanges=" + ipRanges
|
||||
+ ", netmask=" + netmask + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.nat.NatPolicy;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatType;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* The NatService element defines the network address translation capabilities of a network.
|
||||
*/
|
||||
public class NatService {
|
||||
private final boolean enabled;
|
||||
@Nullable
|
||||
private final NatType type;
|
||||
@Nullable
|
||||
private final NatPolicy policy;
|
||||
private final List<NatRule> natRules = Lists.newArrayList();
|
||||
|
||||
public NatService(boolean enabled, @Nullable NatType type, @Nullable NatPolicy policy,
|
||||
Iterable<? extends NatRule> natRules) {
|
||||
this.enabled = enabled;
|
||||
this.type = type;
|
||||
this.policy = policy;
|
||||
Iterables.addAll(this.natRules, checkNotNull(natRules, "natRules"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Nat rules for the network
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
public List<? extends NatRule> getNatRules() {
|
||||
return natRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the service is enabled
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies how Network Address Translation is implemented by the NAT service
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public NatType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies how packets are handled by the NAT service.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public NatPolicy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (enabled ? 1231 : 1237);
|
||||
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
|
||||
result = prime * result + ((policy == null) ? 0 : policy.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NatService other = (NatService) obj;
|
||||
if (enabled != other.enabled)
|
||||
return false;
|
||||
if (natRules == null) {
|
||||
if (other.natRules != null)
|
||||
return false;
|
||||
} else if (!natRules.equals(other.natRules))
|
||||
return false;
|
||||
if (policy == null) {
|
||||
if (other.policy != null)
|
||||
return false;
|
||||
} else if (!policy.equals(other.policy))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[enabled=" + enabled + ", natRules=" + natRules + ", policy=" + policy + ", type=" + type + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
* A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@org.jclouds.vcloud.endpoints.Network
|
||||
@ImplementedBy(VDCImpl.class)
|
||||
public interface OrgNetwork extends NamedResource {
|
||||
/**
|
||||
* The org this network belongs to.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
NamedResource getOrg();
|
||||
|
||||
/**
|
||||
* optional description
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
@Nullable
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* read‐only container for Task elements. Each element in the container represents a queued,
|
||||
* running, or failed task owned by this object.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
List<Task> getTasks();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return properties of the network
|
||||
*
|
||||
* @since vcloud api 0.9, but emulated for 0.8
|
||||
*/
|
||||
Configuration getConfiguration();
|
||||
|
||||
/**
|
||||
* A reference the network pool from which this network is provisioned. This element, which is
|
||||
* required when creating a NatRouted or Isolated network, is returned in response to a creation
|
||||
* request but not shown in subsequent GET requests.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
NamedResource getNetworkPool();
|
||||
|
||||
/**
|
||||
* list of external IP addresses that this network can use for NAT.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
Set<String> getAllowedExternalIpAddresses();
|
||||
|
||||
/**
|
||||
* The Configuration element specifies properties of a network.
|
||||
*/
|
||||
interface Configuration {
|
||||
/**
|
||||
* defines the address range, gateway, netmask, and other properties of the network.
|
||||
*
|
||||
* @since vcloud api 0.9, but emulated for 0.8
|
||||
*/
|
||||
@Nullable
|
||||
IpScope getIpScope();
|
||||
|
||||
/**
|
||||
* reference to a network to which this network connects
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
@Nullable
|
||||
NamedResource getParentNetwork();
|
||||
|
||||
/**
|
||||
* defines how this network is connected to its ParentNetwork
|
||||
*
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
FenceMode getFenceMode();
|
||||
|
||||
/**
|
||||
* defines a set of network features.
|
||||
*
|
||||
* @since vcloud api 0.9, but emulated for 0.8
|
||||
*/
|
||||
@Nullable Features getFeatures();
|
||||
}
|
||||
|
||||
}
|
|
@ -17,19 +17,23 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
package org.jclouds.vcloud.domain.network;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||
|
||||
/**
|
||||
*
|
||||
* A network that is available in a vDC.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface Network extends NamedResource {
|
||||
public interface VCloudExpressNetwork extends NamedResource {
|
||||
/**
|
||||
*
|
||||
* @return Description of the network
|
||||
|
@ -58,7 +62,7 @@ public interface Network extends NamedResource {
|
|||
/**
|
||||
* return the network’s fence modes.
|
||||
*/
|
||||
Set<String> getFenceModes();
|
||||
Set<FenceMode> getFenceModes();
|
||||
|
||||
/**
|
||||
* return True if the network provides DHCP services
|
||||
|
@ -70,7 +74,7 @@ public interface Network extends NamedResource {
|
|||
*
|
||||
* @return Network Address Translation rules for the network
|
||||
*/
|
||||
Set<NatRule> getNatRules();
|
||||
Set<PortForwardingRule> getNatRules();
|
||||
|
||||
/**
|
||||
* @return Firewall rules for the network
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.firewall;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* specifies how packets are handled by the firewall
|
||||
*
|
||||
*/
|
||||
public enum FirewallPolicy {
|
||||
/**
|
||||
* drop packets of this type
|
||||
*/
|
||||
DROP,
|
||||
/**
|
||||
* allow packets of this type to pass through the firewall
|
||||
*/
|
||||
ALLOW;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static FirewallPolicy fromValue(String policy) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return DROP;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.jclouds.vcloud.domain.network.firewall;
|
||||
|
||||
/**
|
||||
* The Protocols element specifies the protocols to which firewall rules apply.
|
||||
*
|
||||
* @since vcloud api 0.9 emulated for 0.8
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class FirewallProtocols {
|
||||
private final boolean tcp;
|
||||
private final boolean udp;
|
||||
|
||||
public FirewallProtocols(boolean tcp, boolean udp) {
|
||||
this.tcp = tcp;
|
||||
this.udp = udp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the firewall rules apply to the TCP protocol
|
||||
*/
|
||||
public boolean isTcp() {
|
||||
return tcp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the firewall rules apply to the UDP protocol
|
||||
*/
|
||||
public boolean isUdp() {
|
||||
return udp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (tcp ? 1231 : 1237);
|
||||
result = prime * result + (udp ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FirewallProtocols other = (FirewallProtocols) obj;
|
||||
if (tcp != other.tcp)
|
||||
return false;
|
||||
if (udp != other.udp)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Protocols [tcp=" + tcp + ", udp=" + udp + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.firewall;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The FirewallRule element defines a single firewall rule.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @since vcloud api 0.8
|
||||
*/
|
||||
public class FirewallRule {
|
||||
|
||||
private final boolean enabled;
|
||||
@Nullable
|
||||
private final String description;
|
||||
@Nullable
|
||||
private final FirewallPolicy policy;
|
||||
@Nullable
|
||||
private final FirewallProtocols protocols;
|
||||
private final int port;
|
||||
private final String destinationIp;
|
||||
|
||||
public FirewallRule(boolean enabled, @Nullable String description, @Nullable FirewallPolicy policy,
|
||||
@Nullable FirewallProtocols protocols, int port, String destinationIp) {
|
||||
this.enabled = enabled;
|
||||
this.description = description;
|
||||
this.policy = policy;
|
||||
this.protocols = protocols;
|
||||
this.port = port;
|
||||
this.destinationIp = checkNotNull(destinationIp, "destinationIp");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the rule is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return description of the rule
|
||||
*/
|
||||
@Nullable
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies how packets are handled by the firewall
|
||||
*/
|
||||
@Nullable
|
||||
public FirewallPolicy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies the protocols to which this firewall rule applies
|
||||
*/
|
||||
@Nullable
|
||||
public FirewallProtocols getProtocols() {
|
||||
return protocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies the network port to which this firewall rule applies. A value of ‐1 matches
|
||||
* any port.
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return specifies the destination IP address, inside the firewall, to which this firewall rule
|
||||
* applies
|
||||
*/
|
||||
public String getDestinationIp() {
|
||||
return destinationIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((destinationIp == null) ? 0 : destinationIp.hashCode());
|
||||
result = prime * result + (enabled ? 1231 : 1237);
|
||||
result = prime * result + ((policy == null) ? 0 : policy.hashCode());
|
||||
result = prime * result + port;
|
||||
result = prime * result + ((protocols == null) ? 0 : protocols.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FirewallRule other = (FirewallRule) obj;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (destinationIp == null) {
|
||||
if (other.destinationIp != null)
|
||||
return false;
|
||||
} else if (!destinationIp.equals(other.destinationIp))
|
||||
return false;
|
||||
if (enabled != other.enabled)
|
||||
return false;
|
||||
if (policy == null) {
|
||||
if (other.policy != null)
|
||||
return false;
|
||||
} else if (!policy.equals(other.policy))
|
||||
return false;
|
||||
if (port != other.port)
|
||||
return false;
|
||||
if (protocols == null) {
|
||||
if (other.protocols != null)
|
||||
return false;
|
||||
} else if (!protocols.equals(other.protocols))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[description=" + description + ", destinationIp=" + destinationIp + ", enabled=" + enabled + ", policy="
|
||||
+ policy + ", port=" + port + ", protocols=" + protocols + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.domain.network.Features;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.IpScope;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrgNetworkImpl extends NamedResourceImpl implements OrgNetwork {
|
||||
@Nullable
|
||||
private final NamedResource org;
|
||||
@Nullable
|
||||
private final String description;
|
||||
private final List<Task> tasks = Lists.newArrayList();
|
||||
private final Configuration configuration;
|
||||
@Nullable
|
||||
private final NamedResource networkPool;
|
||||
private final Set<String> allowedExternalIpAddresses = Sets.newLinkedHashSet();
|
||||
|
||||
public OrgNetworkImpl(String name, String type, URI id, @Nullable NamedResource org, @Nullable String description,
|
||||
Iterable<Task> tasks, Configuration configuration, @Nullable NamedResource networkPool,
|
||||
Iterable<String> allowedExternalIpAddresses) {
|
||||
super(name, type, id);
|
||||
this.org = org;
|
||||
this.description = description;
|
||||
Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
|
||||
this.configuration = checkNotNull(configuration, "configuration");
|
||||
this.networkPool = networkPool;
|
||||
Iterables.addAll(this.allowedExternalIpAddresses, checkNotNull(allowedExternalIpAddresses,
|
||||
"allowedExternalIpAddresses"));
|
||||
}
|
||||
|
||||
public static class ConfigurationImpl implements Configuration {
|
||||
|
||||
@Nullable
|
||||
private final IpScope ipScope;
|
||||
@Nullable
|
||||
private final NamedResource parentNetwork;
|
||||
private final FenceMode fenceMode;
|
||||
private final Features features;
|
||||
|
||||
public ConfigurationImpl(@Nullable IpScope ipScope, @Nullable NamedResource parentNetwork, FenceMode fenceMode,
|
||||
@Nullable Features features) {
|
||||
this.ipScope = ipScope;
|
||||
this.parentNetwork = parentNetwork;
|
||||
this.fenceMode = checkNotNull(fenceMode, "fenceMode");
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IpScope getIpScope() {
|
||||
return ipScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public NamedResource getParentNetwork() {
|
||||
return parentNetwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public FenceMode getFenceMode() {
|
||||
return fenceMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Features getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((features == null) ? 0 : features.hashCode());
|
||||
result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode());
|
||||
result = prime * result + ((ipScope == null) ? 0 : ipScope.hashCode());
|
||||
result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ConfigurationImpl other = (ConfigurationImpl) obj;
|
||||
if (features == null) {
|
||||
if (other.features != null)
|
||||
return false;
|
||||
} else if (!features.equals(other.features))
|
||||
return false;
|
||||
if (fenceMode == null) {
|
||||
if (other.fenceMode != null)
|
||||
return false;
|
||||
} else if (!fenceMode.equals(other.fenceMode))
|
||||
return false;
|
||||
if (ipScope == null) {
|
||||
if (other.ipScope != null)
|
||||
return false;
|
||||
} else if (!ipScope.equals(other.ipScope))
|
||||
return false;
|
||||
if (parentNetwork == null) {
|
||||
if (other.parentNetwork != null)
|
||||
return false;
|
||||
} else if (!parentNetwork.equals(other.parentNetwork))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[features=" + features + ", fenceMode=" + fenceMode + ", ipScope=" + ipScope + ", parentNetwork="
|
||||
+ parentNetwork + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public NamedResource getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Task> getTasks() {
|
||||
return tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public NamedResource getNetworkPool() {
|
||||
return networkPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getAllowedExternalIpAddresses() {
|
||||
return allowedExternalIpAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((allowedExternalIpAddresses == null) ? 0 : allowedExternalIpAddresses.hashCode());
|
||||
result = prime * result + ((configuration == null) ? 0 : configuration.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((networkPool == null) ? 0 : networkPool.hashCode());
|
||||
result = prime * result + ((org == null) ? 0 : org.hashCode());
|
||||
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
OrgNetworkImpl other = (OrgNetworkImpl) obj;
|
||||
if (allowedExternalIpAddresses == null) {
|
||||
if (other.allowedExternalIpAddresses != null)
|
||||
return false;
|
||||
} else if (!allowedExternalIpAddresses.equals(other.allowedExternalIpAddresses))
|
||||
return false;
|
||||
if (configuration == null) {
|
||||
if (other.configuration != null)
|
||||
return false;
|
||||
} else if (!configuration.equals(other.configuration))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (networkPool == null) {
|
||||
if (other.networkPool != null)
|
||||
return false;
|
||||
} else if (!networkPool.equals(other.networkPool))
|
||||
return false;
|
||||
if (org == null) {
|
||||
if (other.org != null)
|
||||
return false;
|
||||
} else if (!org.equals(other.org))
|
||||
return false;
|
||||
if (tasks == null) {
|
||||
if (other.tasks != null)
|
||||
return false;
|
||||
} else if (!tasks.equals(other.tasks))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[allowedExternalIpAddresses=" + allowedExternalIpAddresses + ", configuration=" + configuration
|
||||
+ ", description=" + description + ", networkPool=" + networkPool + ", org=" + org + ", tasks=" + tasks
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -17,16 +17,17 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.internal;
|
||||
package org.jclouds.vcloud.domain.network.internal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
||||
import org.jclouds.vcloud.domain.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.NatRule;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.VCloudExpressNetwork;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.internal.Nullable;
|
||||
|
@ -37,7 +38,7 @@ import com.google.inject.internal.Nullable;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class NetworkImpl extends NamedResourceImpl implements Network {
|
||||
public class VCloudExpressNetworkImpl extends NamedResourceImpl implements VCloudExpressNetwork {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 8464716396538298809L;
|
||||
|
@ -45,15 +46,16 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
|||
private final Set<String> dnsServers = Sets.newHashSet();
|
||||
private final String gateway;
|
||||
private final String netmask;
|
||||
private final Set<String> fenceModes = Sets.newHashSet();
|
||||
private final Set<FenceMode> fenceModes = Sets.newHashSet();
|
||||
@Nullable
|
||||
private final Boolean dhcp;
|
||||
private final Set<NatRule> natRules = Sets.newHashSet();
|
||||
private final Set<PortForwardingRule> natRules = Sets.newHashSet();
|
||||
private final Set<FirewallRule> firewallRules = Sets.newHashSet();
|
||||
|
||||
public NetworkImpl(String name, URI id, String description, Set<String> dnsServers, String gateway,
|
||||
String netmask, Set<String> fenceModes, Boolean dhcp, Set<NatRule> natRules, Set<FirewallRule> firewallRules) {
|
||||
super(name, VCloudExpressMediaType.NETWORK_XML, id);
|
||||
public VCloudExpressNetworkImpl(String name, String type, URI id, String description, Set<String> dnsServers,
|
||||
String gateway, String netmask, Set<FenceMode> fenceModes, Boolean dhcp, Set<PortForwardingRule> natRules,
|
||||
Set<FirewallRule> firewallRules) {
|
||||
super(name, type, id);
|
||||
this.description = description;
|
||||
this.dnsServers.addAll(dnsServers);
|
||||
this.gateway = gateway;
|
||||
|
@ -95,7 +97,7 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Set<String> getFenceModes() {
|
||||
public Set<FenceMode> getFenceModes() {
|
||||
return fenceModes;
|
||||
}
|
||||
|
||||
|
@ -109,7 +111,7 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Set<NatRule> getNatRules() {
|
||||
public Set<PortForwardingRule> getNatRules() {
|
||||
return natRules;
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,7 @@ public class NetworkImpl extends NamedResourceImpl implements Network {
|
|||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NetworkImpl other = (NetworkImpl) obj;
|
||||
VCloudExpressNetworkImpl other = (VCloudExpressNetworkImpl) obj;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.internal;
|
||||
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.network.DhcpService;
|
||||
import org.jclouds.vcloud.domain.network.Features;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FirewallService;
|
||||
import org.jclouds.vcloud.domain.network.IpRange;
|
||||
import org.jclouds.vcloud.domain.network.IpScope;
|
||||
import org.jclouds.vcloud.domain.network.NatService;
|
||||
import org.jclouds.vcloud.domain.network.VCloudExpressNetwork;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VCloudExpressOrgNetworkAdapter extends OrgNetworkImpl {
|
||||
|
||||
public VCloudExpressOrgNetworkAdapter(VCloudExpressNetwork in) {
|
||||
super(in.getName(), in.getType(), in.getId(), null, in.getDescription(), ImmutableSet.<Task> of(),
|
||||
parseConfiguration(in), null, ImmutableSet.<String> of());
|
||||
}
|
||||
|
||||
static Configuration parseConfiguration(VCloudExpressNetwork in) {
|
||||
|
||||
String dns1 = (in.getDnsServers().size() > 0) ? Iterables.get(in.getDnsServers(), 0) : null;
|
||||
String dns2 = (in.getDnsServers().size() > 1) ? Iterables.get(in.getDnsServers(), 1) : null;
|
||||
|
||||
String gateway = in.getGateway();
|
||||
|
||||
String netmask = in.getNetmask();
|
||||
|
||||
FenceMode mode = in.getFenceModes().size() > 0 ? Iterables.get(in.getFenceModes(), 0) : FenceMode.BRIDGED;
|
||||
|
||||
DhcpService dhcp = in.isDhcp() != null && in.isDhcp() ? new DhcpService(true, null, null, null) : null;
|
||||
|
||||
NatService nat = in.getNatRules().size() > 0 ? new NatService(true, null, null, in.getNatRules()) : null;
|
||||
|
||||
FirewallService firewall = in.getFirewallRules().size() > 0 ? new FirewallService(true, in.getFirewallRules())
|
||||
: null;
|
||||
return new OrgNetworkImpl.ConfigurationImpl(new IpScope(true, gateway, netmask, dns1, dns2, null, ImmutableSet
|
||||
.<IpRange> of(), ImmutableSet.<String> of()), null, mode, new Features(dhcp, firewall, nat));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* The Policy element of a NatService element specifies how packets are handled by the NAT service.
|
||||
*
|
||||
*/
|
||||
public enum NatPolicy {
|
||||
/**
|
||||
* packets of this type pass through the firewall in both directions
|
||||
*/
|
||||
ALLOW_TRAFFIC,
|
||||
/**
|
||||
* only inbound packets of this type pass through the firewall
|
||||
*/
|
||||
ALLOW_TRAFFIC_IN;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static NatPolicy fromValue(String policy) {
|
||||
try {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(policy, "policy")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return ALLOW_TRAFFIC_IN;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,26 +17,35 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain;
|
||||
package org.jclouds.vcloud.domain.network.nat;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The FenceMode element contains one of the following strings that specify how
|
||||
* a network is connected to its parent network.
|
||||
* The Protocol specifies the network protocol to which this rule applies
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface FenceMode {
|
||||
public enum NatProtocol {
|
||||
/**
|
||||
* The two networks are bridged.
|
||||
* the rule applies to the TCP protocol
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public static final String BRIDGED = "bridged";
|
||||
TCP,
|
||||
/**
|
||||
* The two networks are not connected.
|
||||
* the rule applies to the UDP protocol
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public static final String ISOLATED = "isolated";
|
||||
UDP,
|
||||
/**
|
||||
* The two networks are connected as specified in their NatService elements.
|
||||
* the rule applies to the TCP and UDP protocols.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
public static final String NAT_ROUTED = "natRouted";
|
||||
TCP_UDP;
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines a rule associated with Nat
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface NatRule {
|
||||
/**
|
||||
* IP address to which this NAT rule maps the IP address specified in the InternalIp element.
|
||||
*/
|
||||
@Nullable
|
||||
String getExternalIP();
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* The NatType element specifies how network address translation is implemented by the NAT service.
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public enum NatType {
|
||||
/**
|
||||
* NAT service implemented by IP address translation
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
IP_TRANSLATION,
|
||||
/**
|
||||
* NAT service implemented by network port forwarding
|
||||
*
|
||||
* @since vcloud api 0.9
|
||||
*/
|
||||
PORT_FORWARDING;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value();
|
||||
}
|
||||
|
||||
public static NatType fromValue(String natType) {
|
||||
return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(natType, "natType")));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat.rules;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.MappingMode;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatRule;
|
||||
|
||||
/**
|
||||
* The OneToOneVmRule element describes a NAT rule that specifies network address translation
|
||||
* details for a single virtual machine. The external IP address can be specified manually or
|
||||
* assigned automatically at deployment time. The internal IP address is discovered by looking up
|
||||
* the specified VmReference and NIC ID.
|
||||
*
|
||||
* @since vcloud 0.9
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OneToOneVmRule implements NatRule {
|
||||
private final MappingMode mappingMode;
|
||||
@Nullable
|
||||
private final String externalIP;
|
||||
@Nullable
|
||||
private final String vAppScopedVmId;
|
||||
private final int vmNicId;
|
||||
|
||||
public OneToOneVmRule(MappingMode mappingMode, @Nullable String externalIp, @Nullable String vAppScopedVmId,
|
||||
int vmNicId) {
|
||||
this.mappingMode = checkNotNull(mappingMode, "mappingMode");
|
||||
this.externalIP = externalIp;
|
||||
this.vAppScopedVmId = vAppScopedVmId;
|
||||
this.vmNicId = vmNicId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return how IP address mapping is implemented by the NAT service
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
public MappingMode getMappingMode() {
|
||||
return mappingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if MappingMode is manual, specifies the external IP address of this Vm, otherwise
|
||||
* null.
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public String getExternalIP() {
|
||||
return externalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return read‐only identifier created on import
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public String getVAppScopedVmId() {
|
||||
return vAppScopedVmId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return device number of the NIC on the referenced virtual machine
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
public int getVmNicId() {
|
||||
return vmNicId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat.rules;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatRule;
|
||||
|
||||
/**
|
||||
* The PortForwardingRule element describes a NAT rule that maps an IP address and port in an
|
||||
* organization network to an external IP address and port.
|
||||
*
|
||||
* @since vcloud 0.8
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class PortForwardingRule implements NatRule {
|
||||
private final String externalIP;
|
||||
private final int externalPort;
|
||||
private final String internalIP;
|
||||
private final int internalPort;
|
||||
private final NatProtocol protocol;
|
||||
|
||||
public PortForwardingRule(String externalIP, int externalPort, String internalIP, int internalPort,
|
||||
NatProtocol protocol) {
|
||||
this.externalIP = checkNotNull(externalIP, "externalIP");
|
||||
this.externalPort = externalPort;
|
||||
this.internalIP = checkNotNull(internalIP, "internalIP");
|
||||
this.internalPort = internalPort;
|
||||
this.protocol = checkNotNull(protocol, "protocol");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* IP address to which this NAT rule maps the IP address specified in the InternalIp element.
|
||||
*/
|
||||
@Override
|
||||
public String getExternalIP() {
|
||||
return externalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* network port to which this NAT rule maps the port number specified in the InternalPort element
|
||||
*/
|
||||
public int getExternalPort() {
|
||||
return externalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP address to which this NAT rule maps the IP address specified in the ExternalIp element.
|
||||
*/
|
||||
public String getInternalIP() {
|
||||
return internalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* network port to which this NAT rule maps the port number specified in the ExternalPort
|
||||
* element.
|
||||
*/
|
||||
public int getInternalPort() {
|
||||
return internalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* specifies the network protocol to which this rule applies
|
||||
*/
|
||||
public NatProtocol getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode());
|
||||
result = prime * result + externalPort;
|
||||
result = prime * result + ((internalIP == null) ? 0 : internalIP.hashCode());
|
||||
result = prime * result + internalPort;
|
||||
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PortForwardingRule other = (PortForwardingRule) obj;
|
||||
if (externalIP == null) {
|
||||
if (other.externalIP != null)
|
||||
return false;
|
||||
} else if (!externalIP.equals(other.externalIP))
|
||||
return false;
|
||||
if (externalPort != other.externalPort)
|
||||
return false;
|
||||
if (internalIP == null) {
|
||||
if (other.internalIP != null)
|
||||
return false;
|
||||
} else if (!internalIP.equals(other.internalIP))
|
||||
return false;
|
||||
if (internalPort != other.internalPort)
|
||||
return false;
|
||||
if (protocol == null) {
|
||||
if (other.protocol != null)
|
||||
return false;
|
||||
} else if (!protocol.equals(other.protocol))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[externalIP=" + externalIP + ", externalPort=" + externalPort + ", internalIP=" + internalIP
|
||||
+ ", internalPort=" + internalPort + ", protocol=" + protocol + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.nat.rules;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatRule;
|
||||
|
||||
/**
|
||||
* The VmRule element describes a NAT rule that maps an IP address and port in a vApp network to an
|
||||
* external IP address and port. The external IP address, external port, and internal port are
|
||||
* specified in the element. The internal IP address is discovered by looking up the specified
|
||||
* VmReference and VmNicId.
|
||||
*
|
||||
* @since vcloud 0.9
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class VmRule implements NatRule {
|
||||
@Nullable
|
||||
private final String externalIP;
|
||||
private final int externalPort;
|
||||
@Nullable
|
||||
private final String vAppScopedLocalId;
|
||||
private final int vmNicId;
|
||||
private final int internalPort;
|
||||
private final NatProtocol protocol;
|
||||
|
||||
public VmRule(@Nullable String externalIP, int externalPort, @Nullable String vAppScopedLocalId, int vmNicId,
|
||||
int internalPort, NatProtocol protocol) {
|
||||
this.externalIP = externalIP;
|
||||
this.externalPort = externalPort;
|
||||
this.vAppScopedLocalId = vAppScopedLocalId;
|
||||
this.vmNicId = vmNicId;
|
||||
this.internalPort = internalPort;
|
||||
this.protocol = checkNotNull(protocol, "protocol");
|
||||
}
|
||||
|
||||
/**
|
||||
* IP address to which this NAT rule maps the IP address specified in the InternalIp element.
|
||||
*/
|
||||
@Nullable
|
||||
public String getExternalIP() {
|
||||
return externalIP;
|
||||
}
|
||||
|
||||
/**
|
||||
* network port to which this NAT rule maps the port number specified in the InternalPort element
|
||||
*/
|
||||
public Integer getExternalPort() {
|
||||
return externalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return read‐only identifier created on import
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
@Nullable
|
||||
public String getVAppScopedLocalId() {
|
||||
return vAppScopedLocalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return device number of the NIC on the referenced virtual machine
|
||||
* @since vcloud 0.9
|
||||
*/
|
||||
public int getVmNicId() {
|
||||
return vmNicId;
|
||||
}
|
||||
|
||||
/**
|
||||
* network port to which this NAT rule maps the port number specified in the ExternalPort
|
||||
* element.
|
||||
*/
|
||||
public Integer getInternalPort() {
|
||||
return internalPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* specifies the network protocol to which this rule applies
|
||||
*/
|
||||
public NatProtocol getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode());
|
||||
result = prime * result + externalPort;
|
||||
result = prime * result + internalPort;
|
||||
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
|
||||
result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode());
|
||||
result = prime * result + vmNicId;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VmRule other = (VmRule) obj;
|
||||
if (externalIP == null) {
|
||||
if (other.externalIP != null)
|
||||
return false;
|
||||
} else if (!externalIP.equals(other.externalIP))
|
||||
return false;
|
||||
if (externalPort != other.externalPort)
|
||||
return false;
|
||||
if (internalPort != other.internalPort)
|
||||
return false;
|
||||
if (protocol == null) {
|
||||
if (other.protocol != null)
|
||||
return false;
|
||||
} else if (!protocol.equals(other.protocol))
|
||||
return false;
|
||||
if (vAppScopedLocalId == null) {
|
||||
if (other.vAppScopedLocalId != null)
|
||||
return false;
|
||||
} else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId))
|
||||
return false;
|
||||
if (vmNicId != other.vmNicId)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[externalIP=" + externalIP + ", externalPort=" + externalPort + ", internalPort=" + internalPort
|
||||
+ ", protocol=" + protocol + ", vAppScopedLocalId=" + vAppScopedLocalId + ", vmNicId=" + vmNicId + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class InstantiateVAppTemplateOptions {
|
|||
private String memorySizeMegabytes;
|
||||
private String diskSizeKilobytes;
|
||||
private String network;
|
||||
private String fenceMode;
|
||||
private FenceMode fenceMode;
|
||||
private String networkName;
|
||||
private boolean blockOnDeploy = true;
|
||||
private Map<String, String> properties = Maps.newTreeMap();
|
||||
|
@ -75,8 +75,8 @@ public class InstantiateVAppTemplateOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
public InstantiateVAppTemplateOptions fenceMode(String fenceMode) {
|
||||
this.fenceMode = checkNotNull(fenceMode, "fenceMode").toString();
|
||||
public InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||
this.fenceMode = checkNotNull(fenceMode, "fenceMode");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class InstantiateVAppTemplateOptions {
|
|||
return networkName;
|
||||
}
|
||||
|
||||
public String getFenceMode() {
|
||||
public FenceMode getFenceMode() {
|
||||
return fenceMode;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public class InstantiateVAppTemplateOptions {
|
|||
/**
|
||||
* @see InstantiateVAppTemplateOptions#fenceMode(FenceMode)
|
||||
*/
|
||||
public static InstantiateVAppTemplateOptions fenceMode(String fenceMode) {
|
||||
public static InstantiateVAppTemplateOptions fenceMode(FenceMode fenceMode) {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
return options.fenceMode(fenceMode);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.jclouds.vcloud.domain.network.internal.VCloudExpressOrgNetworkAdapter;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrgNetworkFromVCloudExpressNetworkHandler extends ParseSax.HandlerWithResult<OrgNetwork> {
|
||||
|
||||
protected final VCloudExpressNetworkHandler vcxHandler;
|
||||
|
||||
@Inject
|
||||
public OrgNetworkFromVCloudExpressNetworkHandler(VCloudExpressNetworkHandler vcxHandler) {
|
||||
this.vcxHandler = vcxHandler;
|
||||
}
|
||||
|
||||
public OrgNetwork getResult() {
|
||||
return new VCloudExpressOrgNetworkAdapter(vcxHandler.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
vcxHandler.startElement(uri, localName, qName, attributes);
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
vcxHandler.endElement(uri, name, qName);
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
vcxHandler.characters(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,325 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.jclouds.vcloud.util.Utils.newNamedResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.vcloud.domain.MappingMode;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.network.DhcpService;
|
||||
import org.jclouds.vcloud.domain.network.Features;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FirewallService;
|
||||
import org.jclouds.vcloud.domain.network.IpRange;
|
||||
import org.jclouds.vcloud.domain.network.IpScope;
|
||||
import org.jclouds.vcloud.domain.network.NatService;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallProtocols;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatPolicy;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatType;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.OneToOneVmRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.VmRule;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class OrgNetworkHandler extends ParseSax.HandlerWithResult<OrgNetwork> {
|
||||
|
||||
protected final TaskHandler taskHandler;
|
||||
|
||||
@Inject
|
||||
public OrgNetworkHandler(TaskHandler taskHandler) {
|
||||
this.taskHandler = taskHandler;
|
||||
}
|
||||
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected NamedResource network;
|
||||
protected NamedResource org;
|
||||
protected String orgDescription;
|
||||
protected List<Task> tasks = Lists.newArrayList();
|
||||
|
||||
protected String startAddress;
|
||||
protected String endAddress;
|
||||
|
||||
protected boolean inherited;
|
||||
protected String gateway;
|
||||
protected String netmask;
|
||||
protected String dns1;
|
||||
protected String dns2;
|
||||
protected String dnsSuffix;
|
||||
protected Set<IpRange> ipRanges = Sets.newLinkedHashSet();
|
||||
protected Set<String> allocatedIpAddresses = Sets.newLinkedHashSet();
|
||||
|
||||
protected IpScope ipScope;
|
||||
protected NamedResource parentNetwork;
|
||||
protected FenceMode fenceMode;
|
||||
|
||||
protected boolean serviceEnabled;
|
||||
protected Integer defaultLeaseTime;
|
||||
protected Integer maxLeaseTime;
|
||||
|
||||
protected DhcpService dhcpService;
|
||||
|
||||
protected boolean inFirewallRule;
|
||||
protected boolean firewallRuleEnabled;
|
||||
protected String firewallRuleDescription;
|
||||
protected FirewallPolicy firewallPolicy;
|
||||
|
||||
protected boolean tcp;
|
||||
protected boolean udp;
|
||||
protected FirewallProtocols protocols;
|
||||
protected int port;
|
||||
protected String destinationIp;
|
||||
|
||||
protected List<FirewallRule> firewallRules = Lists.newArrayList();
|
||||
protected FirewallService firewallService;
|
||||
|
||||
protected NatType natType;
|
||||
protected NatPolicy natPolicy;
|
||||
|
||||
protected MappingMode mappingMode;
|
||||
protected String externalIP;
|
||||
protected String vAppScopedVmId;
|
||||
protected int vmNicId;
|
||||
|
||||
protected int externalPort;
|
||||
protected String internalIP;
|
||||
protected int internalPort;
|
||||
protected NatProtocol natProtocol;
|
||||
|
||||
protected String vAppScopedLocalId;
|
||||
|
||||
protected List<NatRule> natRules = Lists.newArrayList();
|
||||
protected NatService natService;
|
||||
|
||||
protected Features features;
|
||||
protected OrgNetwork.Configuration configuration;
|
||||
|
||||
protected NamedResource networkPool;
|
||||
protected Set<String> allowedExternalIpAddresses = Sets.newLinkedHashSet();
|
||||
|
||||
public OrgNetwork getResult() {
|
||||
return new OrgNetworkImpl(network.getName(), network.getType(), network.getId(), org, orgDescription, tasks,
|
||||
configuration, networkPool, allowedExternalIpAddresses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
if (qName.equals("OrgNetwork")) {
|
||||
network = newNamedResource(attributes);
|
||||
} else if (qName.equals("FirewallRule")) {
|
||||
this.inFirewallRule = true;
|
||||
} else if (qName.equals("ParentNetwork")) {
|
||||
parentNetwork = newNamedResource(attributes);
|
||||
} else if (qName.equals("Link") && "up".equals(Utils.attrOrNull(attributes, "rel"))) {
|
||||
org = newNamedResource(attributes);
|
||||
} else {
|
||||
taskHandler.startElement(uri, localName, qName, attributes);
|
||||
}
|
||||
int typeIndex = attributes.getIndex("type");
|
||||
if (typeIndex != -1) {
|
||||
if (attributes.getValue(typeIndex).indexOf("networkPool+xml") != -1) {
|
||||
networkPool = newNamedResource(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
taskHandler.endElement(uri, name, qName);
|
||||
if (qName.equals("Task")) {
|
||||
this.tasks.add(taskHandler.getResult());
|
||||
} else if (qName.equals("Description")) {
|
||||
if (inFirewallRule)
|
||||
firewallRuleDescription = currentOrNull();
|
||||
else
|
||||
orgDescription = currentOrNull();
|
||||
} else if (qName.equals("FenceMode")) {
|
||||
fenceMode = FenceMode.fromValue(currentOrNull());
|
||||
} else if (qName.equals("StartAddress")) {
|
||||
startAddress = currentOrNull();
|
||||
} else if (qName.equals("EndAddress")) {
|
||||
endAddress = currentOrNull();
|
||||
} else if (qName.equals("AllocatedIpAddress")) {
|
||||
allocatedIpAddresses.add(currentOrNull());
|
||||
} else if (qName.equals("IpRange")) {
|
||||
ipRanges.add(new IpRange(startAddress, endAddress));
|
||||
this.startAddress = null;
|
||||
this.endAddress = null;
|
||||
} else if (qName.equals("IsInherited")) {
|
||||
inherited = Boolean.parseBoolean(currentOrNull());
|
||||
} else if (qName.equals("Gateway")) {
|
||||
gateway = currentOrNull();
|
||||
} else if (qName.equals("Netmask")) {
|
||||
netmask = currentOrNull();
|
||||
} else if (qName.equals("Dns1")) {
|
||||
dns1 = currentOrNull();
|
||||
} else if (qName.equals("Dns2")) {
|
||||
dns2 = currentOrNull();
|
||||
} else if (qName.equals("DnsSuffix")) {
|
||||
dnsSuffix = currentOrNull();
|
||||
} else if (qName.equals("IpScope")) {
|
||||
ipScope = new IpScope(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses);
|
||||
this.inherited = false;
|
||||
this.gateway = null;
|
||||
this.netmask = null;
|
||||
this.dns1 = null;
|
||||
this.dns2 = null;
|
||||
this.dnsSuffix = null;
|
||||
this.ipRanges = Sets.newLinkedHashSet();
|
||||
this.allocatedIpAddresses = Sets.newLinkedHashSet();
|
||||
} else if (qName.equals("IsEnabled")) {
|
||||
if (inFirewallRule)
|
||||
firewallRuleEnabled = Boolean.parseBoolean(currentOrNull());
|
||||
else
|
||||
serviceEnabled = Boolean.parseBoolean(currentOrNull());
|
||||
} else if (qName.equals("DefaultLeaseTime")) {
|
||||
defaultLeaseTime = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equals("MaxLeaseTime")) {
|
||||
maxLeaseTime = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equals("DhcpService")) {
|
||||
this.dhcpService = new DhcpService(serviceEnabled, defaultLeaseTime, maxLeaseTime, Iterables
|
||||
.getOnlyElement(ipRanges));
|
||||
this.serviceEnabled = false;
|
||||
this.defaultLeaseTime = null;
|
||||
this.maxLeaseTime = null;
|
||||
this.ipRanges = Sets.newLinkedHashSet();
|
||||
} else if (qName.equals("Policy")) {
|
||||
if (inFirewallRule)
|
||||
firewallPolicy = FirewallPolicy.fromValue(currentOrNull());
|
||||
else
|
||||
natPolicy = NatPolicy.fromValue(currentOrNull());
|
||||
} else if (qName.equals("Tcp")) {
|
||||
tcp = Boolean.parseBoolean(currentOrNull());
|
||||
} else if (qName.equals("Udp")) {
|
||||
udp = Boolean.parseBoolean(currentOrNull());
|
||||
} else if (qName.equals("Protocols")) {
|
||||
this.protocols = new FirewallProtocols(tcp, udp);
|
||||
this.tcp = false;
|
||||
this.udp = false;
|
||||
} else if (qName.equals("DestinationIp")) {
|
||||
this.destinationIp = currentOrNull();
|
||||
} else if (qName.equals("FirewallRule")) {
|
||||
this.inFirewallRule = false;
|
||||
this.firewallRules.add(new FirewallRule(firewallRuleEnabled, firewallRuleDescription, firewallPolicy,
|
||||
protocols, port, destinationIp));
|
||||
this.firewallRuleEnabled = false;
|
||||
this.firewallRuleDescription = null;
|
||||
this.firewallPolicy = null;
|
||||
this.protocols = null;
|
||||
this.port = -1;
|
||||
this.destinationIp = null;
|
||||
} else if (qName.equals("FirewallService")) {
|
||||
firewallService = new FirewallService(serviceEnabled, firewallRules);
|
||||
this.serviceEnabled = false;
|
||||
this.firewallRules = Lists.newArrayList();
|
||||
} else if (qName.equals("NatType")) {
|
||||
natType = NatType.fromValue(currentOrNull());
|
||||
} else if (qName.equals("MappingMode")) {
|
||||
mappingMode = MappingMode.fromValue(currentOrNull());
|
||||
} else if (qName.equalsIgnoreCase("ExternalIP")) {
|
||||
externalIP = currentOrNull();
|
||||
} else if (qName.equalsIgnoreCase("VAppScopedVmId")) {
|
||||
vAppScopedVmId = currentOrNull();
|
||||
} else if (qName.equalsIgnoreCase("VAppScopedLocalId")) {
|
||||
vAppScopedLocalId = currentOrNull();
|
||||
} else if (qName.equalsIgnoreCase("vmNicId")) {
|
||||
vmNicId = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equals("OneToOneVmRule")) {
|
||||
natRules.add(new OneToOneVmRule(mappingMode, externalIP, vAppScopedVmId, vmNicId));
|
||||
this.mappingMode = null;
|
||||
this.externalIP = null;
|
||||
this.vAppScopedVmId = null;
|
||||
this.vmNicId = -1;
|
||||
} else if (qName.equalsIgnoreCase("ExternalPort")) {
|
||||
externalPort = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equalsIgnoreCase("IxternalIP")) {
|
||||
internalIP = currentOrNull();
|
||||
} else if (qName.equalsIgnoreCase("InternalPort")) {
|
||||
internalPort = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equals("NatProtocol")) {
|
||||
natProtocol = NatProtocol.valueOf(currentOrNull());
|
||||
} else if (qName.equals("PortForwardingRule")) {
|
||||
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, natProtocol));
|
||||
this.externalIP = null;
|
||||
this.externalPort = -1;
|
||||
this.internalIP = null;
|
||||
this.internalPort = -1;
|
||||
this.natProtocol = null;
|
||||
} else if (qName.equals("VmRule")) {
|
||||
natRules.add(new VmRule(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, natProtocol));
|
||||
this.externalIP = null;
|
||||
this.externalPort = -1;
|
||||
this.vAppScopedLocalId = null;
|
||||
this.vmNicId = -1;
|
||||
this.internalPort = -1;
|
||||
this.natProtocol = null;
|
||||
} else if (qName.equals("NatService")) {
|
||||
this.natService = new NatService(serviceEnabled, natType, natPolicy, natRules);
|
||||
this.serviceEnabled = false;
|
||||
this.natType = null;
|
||||
this.natPolicy = null;
|
||||
this.natRules = Lists.newArrayList();
|
||||
} else if (qName.equals("Features")) {
|
||||
this.features = new Features(dhcpService, firewallService, natService);
|
||||
this.dhcpService = null;
|
||||
this.firewallService = null;
|
||||
this.natService = null;
|
||||
} else if (qName.equals("Configuration")) {
|
||||
configuration = new OrgNetworkImpl.ConfigurationImpl(ipScope, parentNetwork, fenceMode, features);
|
||||
this.ipScope = null;
|
||||
this.parentNetwork = null;
|
||||
this.fenceMode = null;
|
||||
this.features = null;
|
||||
} else if (qName.equals("AllowedExternalIpAddress")) {
|
||||
allowedExternalIpAddresses.add(currentOrNull());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
}
|
|
@ -25,13 +25,14 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.domain.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.NatRule;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.FirewallRule.Policy;
|
||||
import org.jclouds.vcloud.domain.FirewallRule.Protocol;
|
||||
import org.jclouds.vcloud.domain.internal.NetworkImpl;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.VCloudExpressNetwork;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.network.internal.VCloudExpressNetworkImpl;
|
||||
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -41,7 +42,7 @@ import com.google.common.collect.Sets;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||
public class VCloudExpressNetworkHandler extends ParseSax.HandlerWithResult<VCloudExpressNetwork> {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
@ -55,9 +56,9 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
|||
private Set<String> dnsServers = Sets.newLinkedHashSet();
|
||||
private String gateway;
|
||||
private String netmask;
|
||||
private Set<String> fenceModes = Sets.newLinkedHashSet();
|
||||
private Set<FenceMode> fenceModes = Sets.newLinkedHashSet();
|
||||
private Boolean dhcp;
|
||||
private Set<NatRule> natRules = Sets.newLinkedHashSet();
|
||||
private Set<PortForwardingRule> natRules = Sets.newLinkedHashSet();
|
||||
private Set<FirewallRule> firewallRules = Sets.newLinkedHashSet();
|
||||
|
||||
private String externalIP;
|
||||
|
@ -65,14 +66,13 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
|||
private String internalIP;
|
||||
private Integer internalPort;
|
||||
|
||||
private Policy policy;
|
||||
private Protocol protocol;
|
||||
private FirewallPolicy policy;
|
||||
private String sourceIP;
|
||||
private String sourcePort;
|
||||
private int sourcePort;
|
||||
|
||||
public Network getResult() {
|
||||
return new NetworkImpl(network.getName(), network.getId(), description, dnsServers, gateway, netmask,
|
||||
fenceModes, dhcp, natRules, firewallRules);
|
||||
public VCloudExpressNetwork getResult() {
|
||||
return new VCloudExpressNetworkImpl(network.getName(), network.getType(), network.getId(), description,
|
||||
dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,11 +92,15 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
|||
} else if (qName.equals("Netmask")) {
|
||||
netmask = currentOrNull();
|
||||
} else if (qName.equals("FenceMode")) {
|
||||
fenceModes.add(currentOrNull());
|
||||
try {
|
||||
fenceModes.add(FenceMode.fromValue(currentOrNull()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
fenceModes.add(FenceMode.BRIDGED);
|
||||
}
|
||||
} else if (qName.equals("Dhcp")) {
|
||||
dhcp = new Boolean(currentOrNull());
|
||||
} else if (qName.equals("NatRule")) {
|
||||
natRules.add(new NatRule(externalIP, externalPort, internalIP, internalPort));
|
||||
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP));
|
||||
externalIP = null;
|
||||
externalPort = null;
|
||||
internalIP = null;
|
||||
|
@ -110,19 +114,16 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
|||
} else if (qName.equals("InternalPort")) {
|
||||
internalPort = Integer.parseInt(currentOrNull());
|
||||
} else if (qName.equals("FirewallRule")) {
|
||||
firewallRules.add(new FirewallRule(policy, protocol, sourceIP, sourcePort));
|
||||
firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP));
|
||||
policy = null;
|
||||
protocol = null;
|
||||
sourceIP = null;
|
||||
sourcePort = null;
|
||||
sourcePort = -1;
|
||||
} else if (qName.equals("Policy")) {
|
||||
policy = Policy.fromValue(currentOrNull());
|
||||
} else if (qName.equals("Policy")) {
|
||||
protocol = Protocol.fromValue(currentOrNull());
|
||||
policy = FirewallPolicy.fromValue(currentOrNull());
|
||||
} else if (qName.equals("SourceIp")) {
|
||||
sourceIP = currentOrNull();
|
||||
} else if (qName.equals("SourcePort")) {
|
||||
sourcePort = currentOrNull();
|
||||
sourcePort = Integer.parseInt(currentOrNull());
|
||||
}
|
||||
|
||||
currentText = new StringBuilder();
|
|
@ -30,11 +30,11 @@ import org.jclouds.rest.RestContext;
|
|||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.Org;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -80,7 +80,7 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
|
|||
VDC response = connection.findVDCInOrgNamed(null, null);
|
||||
for (NamedResource resource : response.getAvailableNetworks().values()) {
|
||||
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
|
||||
Network item = connection.getNetwork(resource.getId());
|
||||
OrgNetwork item = connection.getNetwork(resource.getId());
|
||||
assertNotNull(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ import org.jclouds.vcloud.options.CloneVAppOptions;
|
|||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.jclouds.vcloud.xml.NetworkHandler;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
@ -254,7 +254,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NetworkHandler.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgNetworkHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
|
|
@ -57,13 +57,14 @@ import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
|||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||
import org.jclouds.vcloud.xml.NetworkHandler;
|
||||
import org.jclouds.vcloud.xml.OrgHandler;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
@ -116,7 +117,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp", processorCount(1)
|
||||
.memory(512).disk(1024).fenceMode("allowInOut").inNetwork(
|
||||
.memory(512).disk(1024).fenceMode(FenceMode.BRIDGED).inNetwork(
|
||||
URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
|
@ -254,7 +255,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NetworkHandler.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgNetworkFromVCloudExpressNetworkHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Properties;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
map.put("template", "https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3");
|
||||
map.put("network", "https://vcenterprise.bluelock.com/api/v1.0/network/1990");
|
||||
map.put("networkName", "aloha");
|
||||
map.put("fenceMode", FenceMode.BRIDGED);
|
||||
map.put("fenceMode", FenceMode.BRIDGED.toString());
|
||||
|
||||
binder.bindToRequest(request, map);
|
||||
verify(request);
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Properties;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class VCloudExpressBindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
map.put("template", "https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3");
|
||||
map.put("network", "https://vcloud.safesecureweb.com/network/1990");
|
||||
map.put("networkName", "aloha");
|
||||
map.put("fenceMode", FenceMode.BRIDGED);
|
||||
map.put("fenceMode", FenceMode.BRIDGED.toString());
|
||||
|
||||
binder.bindToRequest(request, map);
|
||||
verify(request);
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.domain.network.internal;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.IpRange;
|
||||
import org.jclouds.vcloud.domain.network.IpScope;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.jclouds.vcloud.domain.network.VCloudExpressNetwork;
|
||||
import org.jclouds.vcloud.xml.VCloudExpressNetworkHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudExpressOrgNetworkAdapter}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudExpressOrgNetworkAdapterTest")
|
||||
public class VCloudExpressOrgNetworkAdapterTest {
|
||||
|
||||
public void testTerremark() {
|
||||
InputStream is = getClass().getResourceAsStream("/express/network-terremark.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
VCloudExpressNetwork in = factory.create(injector.getInstance(VCloudExpressNetworkHandler.class)).parse(is);
|
||||
OrgNetwork result = new VCloudExpressOrgNetworkAdapter(in);
|
||||
assertEquals(result.getName(), "10.114.34.128/26");
|
||||
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/network/1708"));
|
||||
assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
|
||||
assertEquals(result.getOrg(), null);
|
||||
assertEquals(result.getDescription(), null);
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assert result.getConfiguration() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "10.114.34.129", "255.255.255.192", null,
|
||||
null, null, ImmutableSet.<IpRange> of(), ImmutableSet.<String> of()));
|
||||
|
||||
assertEquals(result.getConfiguration().getParentNetwork(), null);
|
||||
assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED);
|
||||
assert result.getConfiguration().getFeatures() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getFeatures().getDhcpService(), null);
|
||||
assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
|
||||
assertEquals(result.getConfiguration().getFeatures().getNatService(), null);
|
||||
|
||||
assertEquals(result.getNetworkPool(), null);
|
||||
assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
|
||||
|
||||
}
|
||||
|
||||
public void testBluelock() {
|
||||
InputStream is = getClass().getResourceAsStream("/express/network-bluelock.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
VCloudExpressNetwork in = factory.create(injector.getInstance(VCloudExpressNetworkHandler.class)).parse(is);
|
||||
OrgNetwork result = new VCloudExpressOrgNetworkAdapter(in);
|
||||
assertEquals(result.getName(), "Pod03_Private");
|
||||
assertEquals(result.getId(), URI.create("https://express3.bluelock.com/api/v0.8/network/1"));
|
||||
assertEquals(result.getType(), null);
|
||||
assertEquals(result.getOrg(), null);
|
||||
assertEquals(result.getDescription(), "Pod 03 Private Network");
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assert result.getConfiguration() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "172.18.8.1", "255.255.248.0",
|
||||
"66.133.112.131", "24.172.173.113", null, ImmutableSet.<IpRange> of(), ImmutableSet.<String> of()));
|
||||
|
||||
assertEquals(result.getConfiguration().getParentNetwork(), null);
|
||||
assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED);
|
||||
assert result.getConfiguration().getFeatures() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getFeatures().getDhcpService(), null);
|
||||
assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
|
||||
assertEquals(result.getConfiguration().getFeatures().getNatService(), null);
|
||||
|
||||
assertEquals(result.getNetworkPool(), null);
|
||||
assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
|
||||
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
|
@ -121,13 +121,13 @@ public class InstantiateVAppTemplateOptionsTest {
|
|||
public void testFenceMode() {
|
||||
InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions();
|
||||
options.fenceMode(FenceMode.BRIDGED);
|
||||
assertEquals(options.getFenceMode(), "bridged");
|
||||
assertEquals(options.getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFenceModeStatic() {
|
||||
InstantiateVAppTemplateOptions options = fenceMode(FenceMode.BRIDGED);
|
||||
assertEquals(options.getFenceMode(), "bridged");
|
||||
assertEquals(options.getFenceMode(), FenceMode.BRIDGED);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.FenceMode;
|
||||
import org.jclouds.vcloud.domain.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.NatRule;
|
||||
import org.jclouds.vcloud.domain.Network;
|
||||
import org.jclouds.vcloud.domain.internal.NetworkImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NetworkHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.NetworkHandlerTest")
|
||||
public class NetworkHandlerTest {
|
||||
|
||||
private Injector injector;
|
||||
|
||||
private Factory factory;
|
||||
|
||||
public void testTerremark() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/network-terremark.xml");
|
||||
injector = Guice.createInjector(new SaxParserModule());
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
||||
assertEquals(result, new NetworkImpl("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 {
|
||||
InputStream is = getClass().getResourceAsStream("/network-hosting.xml");
|
||||
injector = Guice.createInjector(new SaxParserModule());
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
Network result = (Network) factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
||||
assertEquals(result, new NetworkImpl("188849 trust", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"), "188849 trust", ImmutableSet
|
||||
.<String> of("76.12.32.110", "208.112.89.187"), "204.12.53.89", "255.255.255.248", ImmutableSet
|
||||
.<String> of(), null, ImmutableSet.<NatRule> of(), ImmutableSet.<FirewallRule> of()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.jclouds.vcloud.domain.network.DhcpService;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.IpRange;
|
||||
import org.jclouds.vcloud.domain.network.IpScope;
|
||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code OrgNetworkHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.OrgNetworkHandlerTest")
|
||||
public class OrgNetworkHandlerTest {
|
||||
public void testIsolated() {
|
||||
InputStream is = getClass().getResourceAsStream("/orgnetwork-isolated.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "isolation01");
|
||||
assertEquals(result.getId(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/990419644"));
|
||||
assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
|
||||
assertEquals(result.getOrg(), new NamedResourceImpl(null, VCloudMediaType.ORG_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
|
||||
assertEquals(result.getDescription(), null);
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assert result.getConfiguration() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getIpScope(), new IpScope(false, "192.168.15.1", "255.255.255.0",
|
||||
"23.172.173.113", null, null,
|
||||
ImmutableSet.<IpRange> of(new IpRange("192.168.15.100", "192.168.15.199")), ImmutableSet.<String> of()));
|
||||
assertEquals(result.getConfiguration().getParentNetwork(), null);
|
||||
assertEquals(result.getConfiguration().getFenceMode(), FenceMode.ISOLATED);
|
||||
assert result.getConfiguration().getFeatures() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getFeatures().getDhcpService(), new DhcpService(false, 3600, 7200,
|
||||
new IpRange("192.168.15.2", "192.168.15.99")));
|
||||
assertEquals(result.getConfiguration().getFeatures().getFirewallService(), null);
|
||||
assertEquals(result.getConfiguration().getFeatures().getNatService(), null);
|
||||
|
||||
assertEquals(result.getNetworkPool(), null);
|
||||
assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
|
||||
|
||||
}
|
||||
|
||||
public void testBridged() {
|
||||
InputStream is = getClass().getResourceAsStream("/orgnetwork-bridged.xml");
|
||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||
OrgNetwork result = factory.create(injector.getInstance(OrgNetworkHandler.class)).parse(is);
|
||||
assertEquals(result.getName(), "internet01");
|
||||
assertEquals(result.getId(), URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/758634723"));
|
||||
assertEquals(result.getType(), "application/vnd.vmware.vcloud.network+xml");
|
||||
assertEquals(result.getOrg(), new NamedResourceImpl(null, VCloudMediaType.ORG_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
|
||||
assertEquals(result.getDescription(), null);
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assert result.getConfiguration() != null;
|
||||
|
||||
assertEquals(result.getConfiguration().getIpScope(), new IpScope(true, "174.47.101.161", "255.255.255.224",
|
||||
"24.172.173.113", null, null,
|
||||
ImmutableSet.<IpRange> of(new IpRange("174.47.101.164", "174.47.101.190")), ImmutableSet.<String> of()));
|
||||
assertEquals(result.getConfiguration().getParentNetwork(), null);
|
||||
assertEquals(result.getConfiguration().getFenceMode(), FenceMode.BRIDGED);
|
||||
assert result.getConfiguration().getFeatures() == null;
|
||||
assertEquals(result.getNetworkPool(), null);
|
||||
assertEquals(result.getAllowedExternalIpAddresses(), ImmutableSet.<String> of());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.xml;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||
import org.jclouds.vcloud.domain.network.VCloudExpressNetwork;
|
||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
||||
import org.jclouds.vcloud.domain.network.internal.VCloudExpressNetworkImpl;
|
||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudExpressNetworkHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudExpressNetworkHandlerTest")
|
||||
public class VCloudExpressNetworkHandlerTest {
|
||||
|
||||
private Injector injector;
|
||||
|
||||
private Factory factory;
|
||||
|
||||
public void testTerremark() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/express/network-terremark.xml");
|
||||
injector = Guice.createInjector(new SaxParserModule());
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
VCloudExpressNetwork result = factory.create(injector.getInstance(VCloudExpressNetworkHandler.class)).parse(is);
|
||||
assertEquals(result, new VCloudExpressNetworkImpl("10.114.34.128/26",
|
||||
"application/vnd.vmware.vcloud.network+xml", 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
|
||||
.<FenceMode> of(FenceMode.ISOLATED), null, ImmutableSet.<PortForwardingRule> of(), ImmutableSet
|
||||
.<FirewallRule> of()));
|
||||
}
|
||||
|
||||
public void testHosting() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/express/network-hosting.xml");
|
||||
injector = Guice.createInjector(new SaxParserModule());
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
VCloudExpressNetwork result = (VCloudExpressNetwork) factory.create(
|
||||
injector.getInstance(VCloudExpressNetworkHandler.class)).parse(is);
|
||||
assertEquals(result, new VCloudExpressNetworkImpl("188849 trust", null, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/network/1183"), "188849 trust", ImmutableSet
|
||||
.<String> of("76.12.32.110", "208.112.89.187"), "204.12.53.89", "255.255.255.248", ImmutableSet
|
||||
.<FenceMode> of(), null, ImmutableSet.<PortForwardingRule> of(), ImmutableSet.<FirewallRule> of()));
|
||||
}
|
||||
|
||||
public void testBluelock() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/express/network-bluelock.xml");
|
||||
injector = Guice.createInjector(new SaxParserModule());
|
||||
factory = injector.getInstance(ParseSax.Factory.class);
|
||||
VCloudExpressNetwork result = (VCloudExpressNetwork) factory.create(
|
||||
injector.getInstance(VCloudExpressNetworkHandler.class)).parse(is);
|
||||
assertEquals(result, new VCloudExpressNetworkImpl("Pod03_Private", null, URI
|
||||
.create("https://express3.bluelock.com/api/v0.8/network/1"), "Pod 03 Private Network", ImmutableSet
|
||||
.<String> of("24.172.173.113", "66.133.112.131"), "172.18.8.1", "255.255.248.0", ImmutableSet
|
||||
.<FenceMode> of(), null, ImmutableSet.<PortForwardingRule> of(), ImmutableSet.<FirewallRule> of()));
|
||||
}
|
||||
|
||||
}
|
|
@ -37,6 +37,7 @@ import org.jclouds.vcloud.domain.VDCStatus;
|
|||
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
@ -60,6 +61,7 @@ public class VDCHandlerTest {
|
|||
assertEquals(result.getOrg(), new NamedResourceImpl(null, VCloudMediaType.ORG_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")));
|
||||
assertEquals(result.getDescription(), null);
|
||||
assertEquals(result.getTasks(), ImmutableList.of());
|
||||
assertEquals(result.getAllocationModel(), AllocationModel.ALLOCATION_POOL);
|
||||
assertEquals(result.getStorageCapacity(), new Capacity("MB", 1024000, 1024000, 0, 0));
|
||||
assertEquals(result.getCpuCapacity(), new Capacity("MHz", 20000, 20000, 0, 0));
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Network href="https://express3.bluelock.com/api/v0.8/network/1"
|
||||
name="Pod03_Private"
|
||||
xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 https://express3.bluelock.com/api/v0.8/schemas/vcloud/network.xsd"
|
||||
xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Description>Pod 03 Private Network</Description>
|
||||
<Configuration>
|
||||
<Dns>24.172.173.113</Dns>
|
||||
<Dns>66.133.112.131</Dns>
|
||||
<Gateway>172.18.8.1</Gateway>
|
||||
<Netmask>255.255.248.0</Netmask>
|
||||
</Configuration>
|
||||
</Network>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1" name="internet01" type="application/vnd.vmware.vcloud.network+xml" href="https://vcenterprise.bluelock.com/api/v1.0/network/758634723" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
|
||||
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
|
||||
<Description/>
|
||||
<Configuration>
|
||||
<IpScope>
|
||||
<IsInherited>true</IsInherited>
|
||||
<Gateway>174.47.101.161</Gateway>
|
||||
<Netmask>255.255.255.224</Netmask>
|
||||
<Dns1>24.172.173.113</Dns1>
|
||||
<IpRanges>
|
||||
<IpRange>
|
||||
<StartAddress>174.47.101.164</StartAddress>
|
||||
<EndAddress>174.47.101.190</EndAddress>
|
||||
</IpRange>
|
||||
</IpRanges>
|
||||
</IpScope>
|
||||
<FenceMode>bridged</FenceMode>
|
||||
</Configuration>
|
||||
</OrgNetwork>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1" name="isolation01" type="application/vnd.vmware.vcloud.network+xml" href="https://vcenterprise.bluelock.com/api/v1.0/network/990419644" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
|
||||
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
|
||||
<Description/>
|
||||
<Configuration>
|
||||
<IpScope>
|
||||
<IsInherited>false</IsInherited>
|
||||
<Gateway>192.168.15.1</Gateway>
|
||||
<Netmask>255.255.255.0</Netmask>
|
||||
<Dns1>23.172.173.113</Dns1>
|
||||
<IpRanges>
|
||||
<IpRange>
|
||||
<StartAddress>192.168.15.100</StartAddress>
|
||||
<EndAddress>192.168.15.199</EndAddress>
|
||||
</IpRange>
|
||||
</IpRanges>
|
||||
</IpScope>
|
||||
<FenceMode>isolated</FenceMode>
|
||||
<Features>
|
||||
<DhcpService>
|
||||
<IsEnabled>false</IsEnabled>
|
||||
<DefaultLeaseTime>3600</DefaultLeaseTime>
|
||||
<MaxLeaseTime>7200</MaxLeaseTime>
|
||||
<IpRange>
|
||||
<StartAddress>192.168.15.2</StartAddress>
|
||||
<EndAddress>192.168.15.99</EndAddress>
|
||||
</IpRange>
|
||||
</DhcpService>
|
||||
</Features>
|
||||
</Configuration>
|
||||
</OrgNetwork>
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.vcloud.terremark.binders;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK;
|
||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
|
||||
|
@ -52,32 +53,25 @@ public class TerremarkBindInstantiateVAppTemplateParamsToXmlPayload extends
|
|||
BindInstantiateVAppTemplateParamsToXmlPayload {
|
||||
|
||||
@Inject
|
||||
public TerremarkBindInstantiateVAppTemplateParamsToXmlPayload(
|
||||
BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||
public TerremarkBindInstantiateVAppTemplateParamsToXmlPayload(BindToStringPayload stringBinder,
|
||||
@Named(PROPERTY_API_VERSION) String apiVersion, @Named(PROPERTY_VCLOUD_XML_NAMESPACE) String ns,
|
||||
@Named(PROPERTY_VCLOUD_XML_SCHEMA) String schema, @Named(PROPERTY_VCLOUD_DEFAULT_NETWORK) String network,
|
||||
@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
|
||||
super(stringBinder, ns, schema, network, fenceMode);
|
||||
super(stringBinder, apiVersion, ns, schema, network, fenceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String generateXml(String name, String template,
|
||||
Map<String, String> properties,
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity,
|
||||
String networkName, @Nullable String fenceMode, URI network)
|
||||
throws ParserConfigurationException, FactoryConfigurationError,
|
||||
TransformerException {
|
||||
return super.generateXml(name, template, properties,
|
||||
virtualHardwareQuantity, networkName, fenceMode, network);
|
||||
protected String generateXml(String name, String template, Map<String, String> properties,
|
||||
SortedMap<ResourceType, String> virtualHardwareQuantity, String networkName, @Nullable String fenceMode,
|
||||
URI network) throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
||||
return super.generateXml(name, template, properties, virtualHardwareQuantity, networkName, fenceMode, network);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder,
|
||||
Map<String, String> properties) {
|
||||
protected void addPropertiesifPresent(XMLBuilder instantiationParamsBuilder, Map<String, String> properties) {
|
||||
if (properties.size() == 0) { // terremark requires the product section.
|
||||
instantiationParamsBuilder.e("ProductSection").a("xmlns:q1", ns).a(
|
||||
"xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1");
|
||||
instantiationParamsBuilder.e("ProductSection").a("xmlns:q1", ns).a("xmlns:ovf",
|
||||
"http://schemas.dmtf.org/ovf/envelope/1");
|
||||
} else {
|
||||
super.addPropertiesifPresent(instantiationParamsBuilder, properties);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue