mirror of https://github.com/apache/jclouds.git
Issue 112: updated support for terremark, adding ability to remove public ip addresses no longer in use
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2403 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
193de5814e
commit
0703d20b8c
|
@ -40,6 +40,7 @@ import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.MapBinder;
|
import org.jclouds.rest.annotations.MapBinder;
|
||||||
import org.jclouds.rest.annotations.MapEntityParam;
|
import org.jclouds.rest.annotations.MapEntityParam;
|
||||||
import org.jclouds.rest.annotations.ParamParser;
|
import org.jclouds.rest.annotations.ParamParser;
|
||||||
|
@ -52,15 +53,23 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.functions.CatalogIdToUri;
|
import org.jclouds.vcloud.functions.CatalogIdToUri;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.vcloud.terremark.binders.TerremarkBindInstantiateVAppTemplateParamsToXmlEntity;
|
import org.jclouds.vcloud.terremark.binders.TerremarkBindInstantiateVAppTemplateParamsToXmlEntity;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.options.ReturnVoidOnDeleteDefaultIp;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.ComputeOptionsHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.CustomizationParametersHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVAppHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
|
|
||||||
|
@ -73,13 +82,18 @@ import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
*/
|
*/
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getDefaultVDC
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
@XMLResponseParser(TerremarkVDCHandler.class)
|
@XMLResponseParser(TerremarkVDCHandler.class)
|
||||||
@Consumes(VDC_XML)
|
@Consumes(VDC_XML)
|
||||||
Future<? extends VDC> getDefaultVDC();
|
Future<? extends VDC> getDefaultVDC();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#instantiateVAppTemplate
|
||||||
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
@Path("/action/instantiatevAppTemplate")
|
@Path("/action/instantiatevAppTemplate")
|
||||||
|
@ -91,6 +105,9 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@MapEntityParam("template") @ParamParser(CatalogIdToUri.class) String templateId,
|
@MapEntityParam("template") @ParamParser(CatalogIdToUri.class) String templateId,
|
||||||
InstantiateVAppTemplateOptions... options);
|
InstantiateVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetService
|
||||||
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
@Path("/internetServices")
|
@Path("/internetServices")
|
||||||
|
@ -98,15 +115,21 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
@MapBinder(AddInternetServiceOptions.class)
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
Future<? extends InternetService> addInternetService(@MapEntityParam("name") String serviceName,
|
Future<? extends InternetService> addInternetService(@MapEntityParam("name") String serviceName,
|
||||||
@MapEntityParam("protocol") String protocol, @MapEntityParam("port") int port,
|
@MapEntityParam("protocol") Protocol protocol, @MapEntityParam("port") int port,
|
||||||
AddInternetServiceOptions... options);
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getAllInternetServices
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
@Path("/internetServices")
|
@Path("/internetServices")
|
||||||
@XMLResponseParser(InternetServicesHandler.class)
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
Future<? extends SortedSet<InternetService>> getAllInternetServices();
|
Future<? extends SortedSet<InternetService>> getAllInternetServices();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetServiceToExistingIp
|
||||||
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/publicIps/{ipId}/InternetServices")
|
@Path("/publicIps/{ipId}/InternetServices")
|
||||||
|
@ -114,22 +137,59 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
@MapBinder(AddInternetServiceOptions.class)
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
Future<? extends InternetService> addInternetServiceToExistingIp(
|
Future<? extends InternetService> addInternetServiceToExistingIp(
|
||||||
@PathParam("ipId") String existingIpId, @MapEntityParam("name") String serviceName,
|
@PathParam("ipId") int existingIpId, @MapEntityParam("name") String serviceName,
|
||||||
@MapEntityParam("protocol") String protocol, @MapEntityParam("port") int port,
|
@MapEntityParam("protocol") Protocol protocol, @MapEntityParam("port") int port,
|
||||||
AddInternetServiceOptions... options);
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deletePublicIp
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/PublicIps/{ipId}")
|
||||||
|
@ExceptionParser(ReturnVoidOnDeleteDefaultIp.class)
|
||||||
|
Future<Void> deletePublicIp(@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetServicesOnPublicIP
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/publicIps/{ipId}/InternetServices")
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
Future<? extends SortedSet<InternetService>> getInternetServicesOnPublicIp(
|
||||||
|
@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getPublicIpsAssociatedWithVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
|
@Path("/publicIps")
|
||||||
|
@XMLResponseParser(PublicIpAddressesHandler.class)
|
||||||
|
Future<? extends SortedSet<PublicIpAddress>> getPublicIpsAssociatedWithVDC();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deleteInternetService
|
||||||
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/internetServices/{internetServiceId}")
|
@Path("/internetServices/{internetServiceId}")
|
||||||
Future<Void> deleteInternetService(@PathParam("internetServiceId") String internetServiceId);
|
Future<Void> deleteInternetService(@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetService
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/internetServices/{internetServiceId}")
|
@Path("/internetServices/{internetServiceId}")
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
Future<? extends InternetService> getInternetService(
|
Future<? extends InternetService> getInternetService(
|
||||||
@PathParam("internetServiceId") String internetServiceId);
|
@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addNode
|
||||||
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/internetServices/{internetServiceId}/nodes")
|
@Path("/internetServices/{internetServiceId}/nodes")
|
||||||
|
@ -137,29 +197,40 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@XMLResponseParser(NodeHandler.class)
|
@XMLResponseParser(NodeHandler.class)
|
||||||
@MapBinder(AddNodeOptions.class)
|
@MapBinder(AddNodeOptions.class)
|
||||||
Future<? extends Node> addNode(
|
Future<? extends Node> addNode(
|
||||||
@PathParam("internetServiceId") String internetServiceId,
|
@PathParam("internetServiceId") int internetServiceId,
|
||||||
@MapEntityParam("ipAddress") @ParamParser(InetAddressToHostAddress.class) InetAddress ipAddress,
|
@MapEntityParam("ipAddress") @ParamParser(InetAddressToHostAddress.class) InetAddress ipAddress,
|
||||||
@MapEntityParam("name") String name, @MapEntityParam("port") int port,
|
@MapEntityParam("name") String name, @MapEntityParam("port") int port,
|
||||||
AddNodeOptions... options);
|
AddNodeOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getNodes
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/internetServices/{internetServiceId}/nodes")
|
@Path("/internetServices/{internetServiceId}/nodes")
|
||||||
@XMLResponseParser(NodesHandler.class)
|
@XMLResponseParser(NodesHandler.class)
|
||||||
Future<? extends SortedSet<InternetService>> getNodes(
|
Future<? extends SortedSet<Node>> getNodes(@PathParam("internetServiceId") int internetServiceId);
|
||||||
@PathParam("internetServiceId") String internetServiceId);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getNode
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/nodeServices/{nodeId}")
|
@Path("/nodeServices/{nodeId}")
|
||||||
@XMLResponseParser(NodeHandler.class)
|
@XMLResponseParser(NodeHandler.class)
|
||||||
Future<? extends Node> getNode(@PathParam("nodeId") String nodeId);
|
Future<? extends Node> getNode(@PathParam("nodeId") int nodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deleteNode
|
||||||
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/nodeServices/{nodeId}")
|
@Path("/nodeServices/{nodeId}")
|
||||||
Future<Void> deleteNode(@PathParam("nodeId") String nodeId);
|
Future<Void> deleteNode(@PathParam("nodeId") int nodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getVApp
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Consumes(VAPP_XML)
|
@Consumes(VAPP_XML)
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@ -168,9 +239,22 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
||||||
@Override
|
@Override
|
||||||
Future<? extends TerremarkVApp> getVApp(@PathParam("vAppId") String vAppId);
|
Future<? extends TerremarkVApp> getVApp(@PathParam("vAppId") String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getComputeOptions
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Consumes(VAPP_XML)
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
@Path("/vapp/{vAppId}")
|
@Path("/vapp/{vAppId}/options/compute")
|
||||||
Future<String> getVAppString(@PathParam("vAppId") String vAppId);
|
@XMLResponseParser(ComputeOptionsHandler.class)
|
||||||
|
Future<? extends SortedSet<ComputeOption>> getComputeOptions(@PathParam("vAppId") String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getCustomizationOptions
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/vapp/{vAppId}/options/customization")
|
||||||
|
@XMLResponseParser(CustomizationParametersHandler.class)
|
||||||
|
Future<? extends CustomizationParameters> getCustomizationOptions(
|
||||||
|
@PathParam("vAppId") String vAppId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,12 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
|
@ -50,28 +54,89 @@ public interface TerremarkVCloudClient extends VCloudClient {
|
||||||
TerremarkVApp instantiateVAppTemplate(String appName, String templateId,
|
TerremarkVApp instantiateVAppTemplate(String appName, String templateId,
|
||||||
InstantiateVAppTemplateOptions... options);
|
InstantiateVAppTemplateOptions... options);
|
||||||
|
|
||||||
InternetService addInternetService(String serviceName, String protocol, int port,
|
|
||||||
AddInternetServiceOptions... options);
|
|
||||||
|
|
||||||
InternetService addInternetServiceToExistingIp(String existingIpId, String serviceName,
|
|
||||||
String protocol, int port, AddInternetServiceOptions... options);
|
|
||||||
|
|
||||||
void deleteInternetService(String internetServiceId);
|
|
||||||
|
|
||||||
InternetService getInternetService(String internetServiceId);
|
|
||||||
|
|
||||||
Node addNode(String internetServiceId, InetAddress ipAddress, String name, int port,
|
|
||||||
AddNodeOptions... options);
|
|
||||||
|
|
||||||
Node getNode(String nodeId);
|
|
||||||
|
|
||||||
void deleteNode(String nodeId);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
TerremarkVApp getVApp(String vAppId);
|
TerremarkVApp getVApp(String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call returns the compute options for the vApp. The compute options are the CPU and memory
|
||||||
|
* configurations supported by Terremark and by the guest operating system of the vApp. This call
|
||||||
|
* also returns the cost per hour for each configuration.
|
||||||
|
*/
|
||||||
|
SortedSet<ComputeOption> getComputeOptions(String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call returns the customization options for the vApp. The response lists which
|
||||||
|
* customization options are supported for this particular vApp. The possible customization
|
||||||
|
* options are Network and Password.
|
||||||
|
*/
|
||||||
|
CustomizationParameters getCustomizationOptions(String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call returns a list of public IP addresses.
|
||||||
|
*/
|
||||||
|
SortedSet<PublicIpAddress> getPublicIpsAssociatedWithVDC();
|
||||||
|
|
||||||
|
void deletePublicIp(int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The call creates a new internet server, including protocol and port information. The public IP
|
||||||
|
* is dynamically allocated.
|
||||||
|
*
|
||||||
|
* @param serviceName
|
||||||
|
* @param protocol
|
||||||
|
* @param port
|
||||||
|
* @param options
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
InternetService addInternetService(String serviceName, Protocol protocol, int port,
|
||||||
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call adds an internet service to a known, existing public IP. This call is identical to
|
||||||
|
* Add Internet Service except you specify the public IP in the request.
|
||||||
|
*
|
||||||
|
* @param existingIpId
|
||||||
|
* @param serviceName
|
||||||
|
* @param protocol
|
||||||
|
* @param port
|
||||||
|
* @param options
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
InternetService addInternetServiceToExistingIp(int existingIpId, String serviceName,
|
||||||
|
Protocol protocol, int port, AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
void deleteInternetService(int internetServiceId);
|
||||||
|
|
||||||
|
InternetService getInternetService(int internetServiceId);
|
||||||
|
|
||||||
SortedSet<InternetService> getAllInternetServices();
|
SortedSet<InternetService> getAllInternetServices();
|
||||||
|
|
||||||
SortedSet<Node> getNodes(String internetServiceId);
|
/**
|
||||||
|
* This call returns information about the internet service on a public IP.
|
||||||
|
*/
|
||||||
|
SortedSet<InternetService> getInternetServicesOnPublicIp(int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call adds a node to an existing internet service.
|
||||||
|
* <p/>
|
||||||
|
* Every vDC is assigned a network of 60 IP addresses that can be used as nodes. Each node can
|
||||||
|
* associated with multiple internet service. You can get a list of the available IP addresses by
|
||||||
|
* calling Get IP Addresses for a Network.
|
||||||
|
*
|
||||||
|
* @param internetServiceId
|
||||||
|
* @param ipAddress
|
||||||
|
* @param name
|
||||||
|
* @param port
|
||||||
|
* @param options
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Node addNode(int internetServiceId, InetAddress ipAddress, String name, int port,
|
||||||
|
AddNodeOptions... options);
|
||||||
|
|
||||||
|
Node getNode(int nodeId);
|
||||||
|
|
||||||
|
void deleteNode(int nodeId);
|
||||||
|
|
||||||
|
SortedSet<Node> getNodes(int internetServiceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
@ -43,6 +44,7 @@ import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
|
@ -50,6 +52,7 @@ import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOpti
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -115,23 +118,35 @@ public class TerremarkVCloudComputeClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public InetAddress createPublicAddressMappedToPorts(VApp vApp, int... ports) {
|
public InetAddress createPublicAddressMappedToPorts(VApp vApp, int... ports) {
|
||||||
PublicIpAddress sshIp = null;
|
PublicIpAddress ip = null;
|
||||||
InetAddress privateAddress = Iterables.getLast(vApp.getNetworkToAddresses().values());
|
InetAddress privateAddress = Iterables.getLast(vApp.getNetworkToAddresses().values());
|
||||||
for (int port : ports) {
|
for (int port : ports) {
|
||||||
InternetService is = null;
|
InternetService is = null;
|
||||||
if (sshIp == null) {
|
Protocol protocol;
|
||||||
|
switch (port) {
|
||||||
|
case 22:
|
||||||
|
protocol = Protocol.TCP;
|
||||||
|
case 80:
|
||||||
|
case 8080:
|
||||||
|
protocol = Protocol.HTTP;
|
||||||
|
case 443:
|
||||||
|
protocol = Protocol.HTTPS;
|
||||||
|
default:
|
||||||
|
protocol = Protocol.HTTP;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ip == null) {
|
||||||
logger.debug(">> creating InternetService %d", port);
|
logger.debug(">> creating InternetService %d", port);
|
||||||
is = tmClient.addInternetService(vApp.getName() + "-" + port, "TCP", port,
|
is = tmClient.addInternetService(vApp.getName() + "-" + port, protocol, port,
|
||||||
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
||||||
vApp.getId(), vApp.getName())));
|
vApp.getId(), vApp.getName())));
|
||||||
sshIp = is.getPublicIpAddress();
|
ip = is.getPublicIpAddress();
|
||||||
} else {
|
} else {
|
||||||
logger.debug(">> adding InternetService %s:%d", sshIp.getAddress().getHostAddress(),
|
logger.debug(">> adding InternetService %s:%d", ip.getAddress().getHostAddress(), port);
|
||||||
port);
|
is = tmClient.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port,
|
||||||
is = tmClient.addInternetServiceToExistingIp(sshIp.getId() + "", vApp.getName() + "-"
|
protocol, port, withDescription(String.format(
|
||||||
+ port, "TCP", port,
|
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||||
withDescription(String.format("port %d access to serverId: %s name: %s", port,
|
.getName())));
|
||||||
vApp.getId(), vApp.getName())));
|
|
||||||
}
|
}
|
||||||
logger.debug("<< created InternetService(%s) %s:%d", is.getId(), is.getPublicIpAddress()
|
logger.debug("<< created InternetService(%s) %s:%d", is.getId(), is.getPublicIpAddress()
|
||||||
.getAddress().getHostAddress(), is.getPort());
|
.getAddress().getHostAddress(), is.getPort());
|
||||||
|
@ -141,15 +156,33 @@ public class TerremarkVCloudComputeClient {
|
||||||
.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
|
.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
|
||||||
logger.debug("<< added Node(%s)", node.getId());
|
logger.debug("<< added Node(%s)", node.getId());
|
||||||
}
|
}
|
||||||
return sshIp.getAddress();
|
return ip.getAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(String id) {
|
public void stop(String id) {
|
||||||
TerremarkVApp vApp = tmClient.getVApp(id);
|
TerremarkVApp vApp = tmClient.getVApp(id);
|
||||||
|
|
||||||
|
Set<PublicIpAddress> ipAddresses = deleteInternetServicesAndNodesAssociatedWithVApp(vApp);
|
||||||
|
|
||||||
|
deletePublicIpAddressesWithNoServicesAttached(ipAddresses);
|
||||||
|
|
||||||
|
if (vApp.getStatus() != VAppStatus.OFF) {
|
||||||
|
logger.debug(">> powering off vApp(%s)", vApp.getId());
|
||||||
|
blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOffVApp(vApp.getId()),
|
||||||
|
"powerOff", VAppStatus.OFF);
|
||||||
|
logger.debug("<< off vApp(%s)", vApp.getId());
|
||||||
|
}
|
||||||
|
logger.debug(">> deleting vApp(%s)", vApp.getId());
|
||||||
|
tmClient.deleteVApp(id);
|
||||||
|
logger.debug("<< deleted vApp(%s)", vApp.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<PublicIpAddress> deleteInternetServicesAndNodesAssociatedWithVApp(TerremarkVApp vApp) {
|
||||||
|
Set<PublicIpAddress> ipAddresses = Sets.newHashSet();
|
||||||
SERVICE: for (InternetService service : tmClient.getAllInternetServices()) {
|
SERVICE: for (InternetService service : tmClient.getAllInternetServices()) {
|
||||||
for (Node node : tmClient.getNodes(service.getId())) {
|
for (Node node : tmClient.getNodes(service.getId())) {
|
||||||
if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
|
if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
|
||||||
|
ipAddresses.add(service.getPublicIpAddress());
|
||||||
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getId(), service
|
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getId(), service
|
||||||
.getPublicIpAddress().getAddress().getHostAddress(), service.getPort(),
|
.getPublicIpAddress().getAddress().getHostAddress(), service.getPort(),
|
||||||
node.getIpAddress().getHostAddress(), node.getPort());
|
node.getIpAddress().getHostAddress(), node.getPort());
|
||||||
|
@ -166,16 +199,21 @@ public class TerremarkVCloudComputeClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ipAddresses;
|
||||||
if (vApp.getStatus() != VAppStatus.OFF) {
|
}
|
||||||
logger.debug(">> powering off vApp(%s)", vApp.getId());
|
|
||||||
blockUntilVAppStatusOrThrowException(vApp, tmClient.powerOffVApp(vApp.getId()),
|
private void deletePublicIpAddressesWithNoServicesAttached(Set<PublicIpAddress> ipAddresses) {
|
||||||
"powerOff", VAppStatus.OFF);
|
IPADDRESS: for (PublicIpAddress address : ipAddresses) {
|
||||||
logger.debug("<< off vApp(%s)", vApp.getId());
|
SortedSet<InternetService> services = tmClient.getInternetServicesOnPublicIp(address
|
||||||
|
.getId());
|
||||||
|
if (services.size() == 0) {
|
||||||
|
logger.debug(">> deleting PublicIpAddress(%s) %s", address.getId(), address
|
||||||
|
.getAddress().getHostAddress());
|
||||||
|
tmClient.deleteInternetService(address.getId());
|
||||||
|
logger.debug("<< deleted PublicIpAddress(%s)", address.getId());
|
||||||
|
continue IPADDRESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logger.debug(">> deleting vApp(%s)", vApp.getId());
|
|
||||||
tmClient.deleteVApp(id);
|
|
||||||
logger.debug("<< deleted vApp(%s)", vApp.getId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TerremarkVApp blockUntilVAppStatusOrThrowException(TerremarkVApp vApp, Task deployTask,
|
private TerremarkVApp blockUntilVAppStatusOrThrowException(TerremarkVApp vApp, Task deployTask,
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class TerremarkVCloudComputeService implements ComputeService {
|
||||||
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
public CreateServerResponse createServer(String name, Profile profile, Image image) {
|
||||||
String id = computeClient.start(name, 1, 512, image);
|
String id = computeClient.start(name, 1, 512, image);
|
||||||
VApp vApp = tmClient.getVApp(id);
|
VApp vApp = tmClient.getVApp(id);
|
||||||
InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22);
|
InetAddress publicIp = computeClient.createPublicAddressMappedToPorts(vApp, 22, 80, 8080);
|
||||||
return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), ImmutableSet
|
return new CreateServerResponseImpl(vApp.getId(), vApp.getName(), ImmutableSet
|
||||||
.<InetAddress> of(publicIp), vApp.getNetworkToAddresses().values(), 22,
|
.<InetAddress> of(publicIp), vApp.getNetworkToAddresses().values(), 22,
|
||||||
LoginType.SSH, new Credentials("vcloud", "p4ssw0rd"));
|
LoginType.SSH, new Credentials("vcloud", "p4ssw0rd"));
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The compute options are the CPU and memory configurations supported by Terremark and by the guest
|
||||||
|
* operating system of the vApp.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/6-using-the-vcloud-express-api.aspx"
|
||||||
|
* >Terremark documentation</a>
|
||||||
|
*/
|
||||||
|
public class ComputeOption implements Comparable<ComputeOption> {
|
||||||
|
private final int processorCount;
|
||||||
|
private final long memory;
|
||||||
|
private final float costPerHour;
|
||||||
|
|
||||||
|
public ComputeOption(int processorCount, long memory, float costPerHour) {
|
||||||
|
this.processorCount = processorCount;
|
||||||
|
this.memory = memory;
|
||||||
|
this.costPerHour = costPerHour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProcessorCount() {
|
||||||
|
return processorCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getMemory() {
|
||||||
|
return memory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCostPerHour() {
|
||||||
|
return costPerHour;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* orders processor, memory, then cost.
|
||||||
|
*/
|
||||||
|
public int compareTo(ComputeOption that) {
|
||||||
|
if (this == that)
|
||||||
|
return 0;
|
||||||
|
double compareThis = compare(this);
|
||||||
|
double compareThat = compare(that);
|
||||||
|
if (compareThis < compareThat)
|
||||||
|
return -1;
|
||||||
|
if (compareThis > compareThat)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double compare(ComputeOption option) {
|
||||||
|
double comparison = processorCount * 20000;
|
||||||
|
comparison += memory;
|
||||||
|
comparison += costPerHour;
|
||||||
|
return comparison;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + Float.floatToIntBits(costPerHour);
|
||||||
|
result = prime * result + (int) (memory ^ (memory >>> 32));
|
||||||
|
result = prime * result + processorCount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ComputeOption other = (ComputeOption) obj;
|
||||||
|
if (Float.floatToIntBits(costPerHour) != Float.floatToIntBits(other.costPerHour))
|
||||||
|
return false;
|
||||||
|
if (memory != other.memory)
|
||||||
|
return false;
|
||||||
|
if (processorCount != other.processorCount)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ComputeOption [costPerHour=" + costPerHour + ", memory=" + memory
|
||||||
|
+ ", processorCount=" + processorCount + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The response lists which customization options are supported for this particular vApp. The
|
||||||
|
* possible customization options are Network and Password.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see <a
|
||||||
|
* href="https://community.vcloudexpress.terremark.com/en-us/product_docs/w/wiki/6-using-the-vcloud-express-api.aspx"
|
||||||
|
* >Terremark documentation</a>
|
||||||
|
*/
|
||||||
|
public class CustomizationParameters {
|
||||||
|
private final boolean customizeNetwork;
|
||||||
|
private final boolean customizePassword;
|
||||||
|
|
||||||
|
public CustomizationParameters(boolean customizeNetwork, boolean customizePassword) {
|
||||||
|
this.customizeNetwork = customizeNetwork;
|
||||||
|
this.customizePassword = customizePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomizeNetwork() {
|
||||||
|
return customizeNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCustomizePassword() {
|
||||||
|
return customizePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + (customizeNetwork ? 1231 : 1237);
|
||||||
|
result = prime * result + (customizePassword ? 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;
|
||||||
|
CustomizationParameters other = (CustomizationParameters) obj;
|
||||||
|
if (customizeNetwork != other.customizeNetwork)
|
||||||
|
return false;
|
||||||
|
if (customizePassword != other.customizePassword)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CustomizationParameters [customizeNetwork=" + customizeNetwork
|
||||||
|
+ ", customizePassword=" + customizePassword + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,18 +29,18 @@ import java.net.URI;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class InternetService implements Comparable<InternetService> {
|
public class InternetService implements Comparable<InternetService> {
|
||||||
private final String id;
|
private final int id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final URI location;
|
private final URI location;
|
||||||
private final PublicIpAddress publicIpAddress;
|
private final PublicIpAddress publicIpAddress;
|
||||||
private final int port;
|
private final int port;
|
||||||
private final String protocol;
|
private final Protocol protocol;
|
||||||
private final boolean enabled;
|
private final boolean enabled;
|
||||||
private final int timeout;
|
private final int timeout;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
public InternetService(String id, String name, URI location, PublicIpAddress publicIpAddress,
|
public InternetService(int id, String name, URI location, PublicIpAddress publicIpAddress,
|
||||||
int port, String protocol, boolean enabled, int timeout, String description) {
|
int port, Protocol protocol, boolean enabled, int timeout, String description) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
|
@ -60,7 +60,7 @@ public class InternetService implements Comparable<InternetService> {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProtocol() {
|
public Protocol getProtocol() {
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,13 +76,42 @@ public class InternetService implements Comparable<InternetService> {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(InternetService that) {
|
||||||
|
if (this == that)
|
||||||
|
return 0;
|
||||||
|
if (this.id < that.id)
|
||||||
|
return -1;
|
||||||
|
if (this.id > that.id)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "InternetService [description=" + description + ", enabled=" + enabled + ", id=" + id
|
||||||
|
+ ", location=" + location + ", name=" + name + ", port=" + port + ", protocol="
|
||||||
|
+ protocol + ", publicIpAddress=" + publicIpAddress + ", timeout=" + timeout + "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + (enabled ? 1231 : 1237);
|
result = prime * result + (enabled ? 1231 : 1237);
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + id;
|
||||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
result = prime * result + port;
|
result = prime * result + port;
|
||||||
|
@ -108,10 +137,7 @@ public class InternetService implements Comparable<InternetService> {
|
||||||
return false;
|
return false;
|
||||||
if (enabled != other.enabled)
|
if (enabled != other.enabled)
|
||||||
return false;
|
return false;
|
||||||
if (id == null) {
|
if (id != other.id)
|
||||||
if (other.id != null)
|
|
||||||
return false;
|
|
||||||
} else if (!id.equals(other.id))
|
|
||||||
return false;
|
return false;
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
if (other.location != null)
|
if (other.location != null)
|
||||||
|
@ -140,27 +166,4 @@ public class InternetService implements Comparable<InternetService> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(InternetService that) {
|
|
||||||
return (this == that) ? 0 : this.getId().compareTo(that.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URI getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "InternetService [description=" + description + ", enabled=" + enabled + ", id=" + id
|
|
||||||
+ ", location=" + location + ", name=" + name + ", port=" + port + ", protocol="
|
|
||||||
+ protocol + ", publicIpAddress=" + publicIpAddress + ", timeout=" + timeout + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ import java.net.URI;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class Node implements Comparable<Node> {
|
public class Node implements Comparable<Node> {
|
||||||
private final String id;
|
private final int id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final URI location;
|
private final URI location;
|
||||||
private final InetAddress ipAddress;
|
private final InetAddress ipAddress;
|
||||||
|
@ -38,7 +38,7 @@ public class Node implements Comparable<Node> {
|
||||||
private final boolean enabled;
|
private final boolean enabled;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
|
||||||
public Node(String id, String name, URI location, InetAddress ipAddress, int port,
|
public Node(int id, String name, URI location, InetAddress ipAddress, int port,
|
||||||
boolean enabled, String description) {
|
boolean enabled, String description) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -61,7 +61,7 @@ public class Node implements Comparable<Node> {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,21 +73,34 @@ public class Node implements Comparable<Node> {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Node that) {
|
|
||||||
return (this == that) ? 0 : this.getId().compareTo(that.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public InetAddress getIpAddress() {
|
public InetAddress getIpAddress() {
|
||||||
return ipAddress;
|
return ipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Node that) {
|
||||||
|
if (this == that)
|
||||||
|
return 0;
|
||||||
|
if (this.id < that.id)
|
||||||
|
return -1;
|
||||||
|
if (this.id > that.id)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Node [id=" + id + ", name=" + name + ", description=" + description + ", ipAddress="
|
||||||
|
+ ipAddress + ", port=" + port + ", location=" + location + ", enabled=" + enabled
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
result = prime * result + (enabled ? 1231 : 1237);
|
result = prime * result + (enabled ? 1231 : 1237);
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + id;
|
||||||
result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
|
result = prime * result + ((ipAddress == null) ? 0 : ipAddress.hashCode());
|
||||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
@ -111,10 +124,7 @@ public class Node implements Comparable<Node> {
|
||||||
return false;
|
return false;
|
||||||
if (enabled != other.enabled)
|
if (enabled != other.enabled)
|
||||||
return false;
|
return false;
|
||||||
if (id == null) {
|
if (id != other.id)
|
||||||
if (other.id != null)
|
|
||||||
return false;
|
|
||||||
} else if (!id.equals(other.id))
|
|
||||||
return false;
|
return false;
|
||||||
if (ipAddress == null) {
|
if (ipAddress == null) {
|
||||||
if (other.ipAddress != null)
|
if (other.ipAddress != null)
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Protocol for an {@link InternetService}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum Protocol {
|
||||||
|
|
||||||
|
FTP, HTTP, HTTPS, TCP, UDP;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.options;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There's no current way to determine if an IP is the default outbound one. In this case, we may
|
||||||
|
* get errors on deleting an IP, which are ok.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ReturnVoidOnDeleteDefaultIp implements Function<Exception, Void> {
|
||||||
|
|
||||||
|
static final Void v;
|
||||||
|
static {
|
||||||
|
Constructor<Void> cv;
|
||||||
|
try {
|
||||||
|
cv = Void.class.getDeclaredConstructor();
|
||||||
|
cv.setAccessible(true);
|
||||||
|
v = cv.newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Error("Error setting up class", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Void apply(Exception from) {
|
||||||
|
if (from instanceof HttpResponseException) {
|
||||||
|
HttpResponseException hre = (HttpResponseException) from;
|
||||||
|
if (hre.getResponse().getStatusCode() == 503
|
||||||
|
|| hre.getMessage().matches(
|
||||||
|
".*Cannot release this Public IP as it is default oubound IP.*"))
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ComputeOptionHandler extends HandlerWithResult<ComputeOption> {
|
||||||
|
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
int processorCount;
|
||||||
|
int memory;
|
||||||
|
float costPerHour;
|
||||||
|
|
||||||
|
protected String currentOrNull() {
|
||||||
|
String returnVal = currentText.toString().trim();
|
||||||
|
return returnVal.equals("") ? null : returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ComputeOption getResult() {
|
||||||
|
return new ComputeOption(processorCount, memory, costPerHour);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.equals("ProcessorCount")) {
|
||||||
|
processorCount = Integer.parseInt(currentOrNull());
|
||||||
|
} else if (qName.equals("Memory")) {
|
||||||
|
memory = Integer.parseInt(currentOrNull());
|
||||||
|
} else if (qName.equals("CostPerHour")) {
|
||||||
|
costPerHour = Float.parseFloat(currentOrNull());
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ComputeOptionsHandler extends HandlerWithResult<SortedSet<ComputeOption>> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
private final ComputeOptionHandler handler;
|
||||||
|
SortedSet<ComputeOption> result = Sets.newTreeSet();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public ComputeOptionsHandler(ComputeOptionHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<ComputeOption> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
throws SAXException {
|
||||||
|
handler.startElement(uri, localName, qName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
handler.endElement(uri, name, qName);
|
||||||
|
if (qName.equals("ComputeOption")) {
|
||||||
|
result.add(handler.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
handler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class CustomizationParametersHandler extends HandlerWithResult<CustomizationParameters> {
|
||||||
|
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
boolean customizeNetwork;
|
||||||
|
boolean customizePassword;
|
||||||
|
|
||||||
|
protected String currentOrNull() {
|
||||||
|
String returnVal = currentText.toString().trim();
|
||||||
|
return returnVal.equals("") ? null : returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomizationParameters getResult() {
|
||||||
|
return new CustomizationParameters(customizeNetwork, customizePassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.equals("CustomizeNetwork")) {
|
||||||
|
customizeNetwork = Boolean.parseBoolean(currentOrNull());
|
||||||
|
} else if (qName.equals("CustomizePassword")) {
|
||||||
|
customizePassword = Boolean.parseBoolean(currentOrNull());
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ import javax.annotation.Resource;
|
||||||
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
@ -47,7 +48,7 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
|
||||||
|
|
||||||
private boolean inPublicIpAddress;
|
private boolean inPublicIpAddress;
|
||||||
private int addressId;
|
private int addressId;
|
||||||
private String id;
|
private int id;
|
||||||
private URI location;
|
private URI location;
|
||||||
private URI addressLocation;
|
private URI addressLocation;
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
|
@ -57,7 +58,7 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
|
||||||
private String description;
|
private String description;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private String protocol;
|
private Protocol protocol;
|
||||||
|
|
||||||
protected String currentOrNull() {
|
protected String currentOrNull() {
|
||||||
String returnVal = currentText.toString().trim();
|
String returnVal = currentText.toString().trim();
|
||||||
|
@ -83,7 +84,7 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
|
||||||
if (inPublicIpAddress)
|
if (inPublicIpAddress)
|
||||||
addressId = Integer.parseInt(currentOrNull());
|
addressId = Integer.parseInt(currentOrNull());
|
||||||
else
|
else
|
||||||
id = currentOrNull();
|
id = Integer.parseInt(currentOrNull());
|
||||||
} else if (qName.equals("Href") && currentOrNull() != null) {
|
} else if (qName.equals("Href") && currentOrNull() != null) {
|
||||||
if (inPublicIpAddress)
|
if (inPublicIpAddress)
|
||||||
addressLocation = URI.create(currentOrNull());
|
addressLocation = URI.create(currentOrNull());
|
||||||
|
@ -103,7 +104,7 @@ public class InternetServiceHandler extends HandlerWithResult<InternetService> {
|
||||||
} else if (qName.equals("Port")) {
|
} else if (qName.equals("Port")) {
|
||||||
port = Integer.parseInt(currentOrNull());
|
port = Integer.parseInt(currentOrNull());
|
||||||
} else if (qName.equals("Protocol")) {
|
} else if (qName.equals("Protocol")) {
|
||||||
protocol = currentOrNull();
|
protocol = Protocol.valueOf(currentOrNull());
|
||||||
} else if (qName.equals("Enabled")) {
|
} else if (qName.equals("Enabled")) {
|
||||||
enabled = Boolean.parseBoolean(currentOrNull());
|
enabled = Boolean.parseBoolean(currentOrNull());
|
||||||
} else if (qName.equals("Timeout")) {
|
} else if (qName.equals("Timeout")) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class NodeHandler extends HandlerWithResult<Node> {
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
private String id;
|
private int id;
|
||||||
private URI location;
|
private URI location;
|
||||||
private String serviceName;
|
private String serviceName;
|
||||||
private InetAddress address;
|
private InetAddress address;
|
||||||
|
@ -62,7 +62,7 @@ public class NodeHandler extends HandlerWithResult<Node> {
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
public void endElement(String uri, String name, String qName) {
|
||||||
if (qName.equals("Id")) {
|
if (qName.equals("Id")) {
|
||||||
id = currentOrNull();
|
id = Integer.parseInt(currentOrNull());
|
||||||
} else if (qName.equals("Href") && currentOrNull() != null) {
|
} else if (qName.equals("Href") && currentOrNull() != null) {
|
||||||
location = URI.create(currentOrNull());
|
location = URI.create(currentOrNull());
|
||||||
} else if (qName.equals("Name")) {
|
} else if (qName.equals("Name")) {
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class PublicIpAddressHandler extends HandlerWithResult<PublicIpAddress> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private InetAddress address;
|
||||||
|
|
||||||
|
private URI location;
|
||||||
|
|
||||||
|
protected String currentOrNull() {
|
||||||
|
String returnVal = currentText.toString().trim();
|
||||||
|
return returnVal.equals("") ? null : returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PublicIpAddress getResult() {
|
||||||
|
return new PublicIpAddress(id, address, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.equals("Id")) {
|
||||||
|
id = Integer.parseInt(currentOrNull());
|
||||||
|
} else if (qName.equals("Href") && currentOrNull() != null) {
|
||||||
|
location = URI.create(currentOrNull());
|
||||||
|
} else if (qName.equals("Name")) {
|
||||||
|
address = parseInetAddress(currentOrNull());
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
private InetAddress parseInetAddress(String string) {
|
||||||
|
String[] byteStrings = string.split("\\.");
|
||||||
|
byte[] bytes = new byte[4];
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
bytes[i] = (byte) Integer.parseInt(byteStrings[i]);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return InetAddress.getByAddress(bytes);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
logger.warn(e, "error parsing ipAddress", currentText);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class PublicIpAddressesHandler extends HandlerWithResult<SortedSet<PublicIpAddress>> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
private final PublicIpAddressHandler handler;
|
||||||
|
SortedSet<PublicIpAddress> result = Sets.newTreeSet();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PublicIpAddressesHandler(PublicIpAddressHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortedSet<PublicIpAddress> getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
throws SAXException {
|
||||||
|
handler.startElement(uri, localName, qName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
handler.endElement(uri, name, qName);
|
||||||
|
if (qName.equals("PublicIPAddress")) {
|
||||||
|
result.add(handler.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
handler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code TerremarkVCloudClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
||||||
|
public class InternetServiceLiveTest {
|
||||||
|
TerremarkVCloudClient tmClient;
|
||||||
|
|
||||||
|
private SortedSet<InternetService> services = Sets.newTreeSet();
|
||||||
|
|
||||||
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllInternetServices() throws Exception {
|
||||||
|
SortedSet<InternetService> set = tmClient.getAllInternetServices();
|
||||||
|
print(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddInternetService() {
|
||||||
|
|
||||||
|
InternetService is = tmClient.addInternetService("test-" + 22, Protocol.TCP, 22);
|
||||||
|
services.add(is);
|
||||||
|
PublicIpAddress ip = is.getPublicIpAddress();
|
||||||
|
for (int port : new int[] { 80, 8080 }) {
|
||||||
|
services.add(tmClient.addInternetServiceToExistingIp(ip.getId(), "test-" + port,
|
||||||
|
Protocol.HTTP, port));
|
||||||
|
}
|
||||||
|
print(tmClient.getInternetServicesOnPublicIp(ip.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print(SortedSet<InternetService> set) {
|
||||||
|
for (InternetService service : set) {
|
||||||
|
System.out.printf("%d (%s:%d%n)", service.getId(), service.getPublicIpAddress()
|
||||||
|
.getAddress().getHostAddress(), service.getPort());
|
||||||
|
for (Node node : tmClient.getNodes(service.getId())) {
|
||||||
|
System.out.printf(" %d (%s:%d%n)", node.getId(),
|
||||||
|
node.getIpAddress().getHostAddress(), node.getPort());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void delete(SortedSet<InternetService> set) {
|
||||||
|
for (InternetService service : set) {
|
||||||
|
for (Node node : tmClient.getNodes(service.getId())) {
|
||||||
|
tmClient.deleteNode(node.getId());
|
||||||
|
}
|
||||||
|
tmClient.deleteInternetService(service.getId());
|
||||||
|
tmClient.deletePublicIp(service.getPublicIpAddress().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllPublicIps() throws Exception {
|
||||||
|
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC()) {
|
||||||
|
SortedSet<InternetService> set = tmClient.getInternetServicesOnPublicIp(ip.getId());
|
||||||
|
print(set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
delete(services);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
String account = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||||
|
Injector injector = new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(
|
||||||
|
account, key).relaxSSLHostname().build()).withModules(new Log4JLoggingModule(),
|
||||||
|
new JschSshClientModule()).buildInjector();
|
||||||
|
|
||||||
|
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,8 +61,11 @@ import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
|
||||||
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
|
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.ComputeOptionsHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.CustomizationParametersHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||||
|
@ -147,10 +150,10 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||||
String.class, String.class, int.class, Array.newInstance(
|
String.class, Protocol.class, int.class, Array.newInstance(
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"name", "tcp", 22);
|
"name", Protocol.TCP, 22);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
assertHeadersEqual(httpMethod, "Content-Length: 303\nContent-Type: application/xml\n");
|
||||||
|
@ -167,10 +170,10 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
public void testAddInternetServiceOptions() throws SecurityException, NoSuchMethodException,
|
public void testAddInternetServiceOptions() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetService",
|
||||||
String.class, String.class, int.class, Array.newInstance(
|
String.class, Protocol.class, int.class, Array.newInstance(
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
"name", "tcp", 22, disabled().withDescription("yahoo"));
|
"name", Protocol.TCP, 22, disabled().withDescription("yahoo"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
assertRequestLineEquals(httpMethod, "POST http://vdc/internetServices HTTP/1.1");
|
||||||
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
assertHeadersEqual(httpMethod, "Content-Length: 341\nContent-Type: application/xml\n");
|
||||||
|
@ -201,8 +204,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
|
|
||||||
public void testGetInternetService() throws SecurityException, NoSuchMethodException,
|
public void testGetInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getInternetService", int.class);
|
||||||
.getMethod("getInternetService", String.class);
|
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
|
@ -219,8 +221,8 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
|
|
||||||
public void testDeleteInternetService() throws SecurityException, NoSuchMethodException,
|
public void testDeleteInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteInternetService",
|
Method method = TerremarkVCloudAsyncClient.class
|
||||||
String.class);
|
.getMethod("deleteInternetService", int.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
|
@ -238,10 +240,10 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
public void testAddInternetServiceToExistingIp() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||||
String.class, String.class, String.class, int.class, Array.newInstance(
|
int.class, String.class, Protocol.class, int.class, Array.newInstance(
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12, "name", "tcp", 22);
|
12, "name", Protocol.TCP, 22);
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||||
|
@ -259,10 +261,10 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
public void testAddInternetServiceToExistingIpOptions() throws SecurityException,
|
public void testAddInternetServiceToExistingIpOptions() throws SecurityException,
|
||||||
NoSuchMethodException, IOException {
|
NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToExistingIp",
|
||||||
String.class, String.class, String.class, int.class, Array.newInstance(
|
int.class, String.class, Protocol.class, int.class, Array.newInstance(
|
||||||
AddInternetServiceOptions.class, 0).getClass());
|
AddInternetServiceOptions.class, 0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12, "name", "tcp", 22, disabled().withDescription("yahoo"));
|
12, "name", Protocol.TCP, 22, disabled().withDescription("yahoo"));
|
||||||
|
|
||||||
assertRequestLineEquals(httpMethod,
|
assertRequestLineEquals(httpMethod,
|
||||||
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
"POST http://vcloud/publicIps/12/InternetServices HTTP/1.1");
|
||||||
|
@ -277,7 +279,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddNode() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAddNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", int.class,
|
||||||
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||||
0).getClass());
|
0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
@ -296,7 +298,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", String.class,
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addNode", int.class,
|
||||||
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
InetAddress.class, String.class, int.class, Array.newInstance(AddNodeOptions.class,
|
||||||
0).getClass());
|
0).getClass());
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
@ -315,7 +317,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNode() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode", String.class);
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNode", int.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
|
@ -331,7 +333,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNodes() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetNodes() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNodes", String.class);
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getNodes", int.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
|
@ -347,7 +349,7 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException {
|
public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteNode", String.class);
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("deleteNode", int.class);
|
||||||
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
12);
|
12);
|
||||||
|
|
||||||
|
@ -362,6 +364,41 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
checkFilters(httpMethod);
|
checkFilters(httpMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testGetComputeOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getComputeOptions", String.class);
|
||||||
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
12);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod, "GET http://vcloud/vapp/12/options/compute HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod, "");
|
||||||
|
assertEntityEquals(httpMethod, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, ComputeOptionsHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetCustomizationOptions() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("getCustomizationOptions",
|
||||||
|
String.class);
|
||||||
|
GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod = processor.createRequest(method,
|
||||||
|
12);
|
||||||
|
|
||||||
|
assertRequestLineEquals(httpMethod,
|
||||||
|
"GET http://vcloud/vapp/12/options/customization HTTP/1.1");
|
||||||
|
assertHeadersEqual(httpMethod, "");
|
||||||
|
assertEntityEquals(httpMethod, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, CustomizationParametersHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
||||||
|
checkFilters(httpMethod);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
protected void checkFilters(GeneratedHttpRequest<TerremarkVCloudAsyncClient> httpMethod) {
|
||||||
assertEquals(httpMethod.getFilters().size(), 1);
|
assertEquals(httpMethod.getFilters().size(), 1);
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVApp;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
|
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
|
@ -127,6 +128,7 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
||||||
assertEquals(deployTask.getLocation(), deployTask.getLocation());
|
assertEquals(deployTask.getLocation(), deployTask.getLocation());
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.CREATING);
|
assertEquals(vApp.getStatus(), VAppStatus.CREATING);
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
|
@ -147,13 +149,14 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
System.out.println(tmClient.getComputeOptions(vApp.getId()));
|
||||||
|
System.out.println(tmClient.getCustomizationOptions(vApp.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddInternetService() throws InterruptedException, ExecutionException,
|
public void testAddInternetService() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException, IOException {
|
TimeoutException, IOException {
|
||||||
is = tmClient.addInternetService("SSH", "TCP", 22);
|
is = tmClient.addInternetService("SSH", Protocol.TCP, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
@Test(dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
||||||
|
|
|
@ -119,7 +119,8 @@ public class TerremarkVCloudComputeClientLiveTest {
|
||||||
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
@Test(dependsOnMethods = "testGetAnyPrivateAddress")
|
||||||
public void testSshLoadBalanceIp() {
|
public void testSshLoadBalanceIp() {
|
||||||
|
|
||||||
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22);
|
InetAddress publicIp = client.createPublicAddressMappedToPorts(tmClient.getVApp(id), 22, 80,
|
||||||
|
8080);
|
||||||
assert addressTester.apply(publicIp);
|
assert addressTester.apply(publicIp);
|
||||||
// client.exec(publicIp, "uname -a");
|
// client.exec(publicIp, "uname -a");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ComputeOptionServiceHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.ComputeOptionHandlerTest")
|
||||||
|
public class ComputeOptionHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/ComputeOption.xml");
|
||||||
|
|
||||||
|
ComputeOption result = (ComputeOption) factory.create(
|
||||||
|
injector.getInstance(ComputeOptionHandler.class)).parse(is);
|
||||||
|
assertEquals(result, new ComputeOption(1, 512, 0.039f));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.ComputeOption;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ComputeOptionsHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.ComputeOptionsHandlerTest")
|
||||||
|
public class ComputeOptionsHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/ComputeOptions.xml");
|
||||||
|
|
||||||
|
SortedSet<ComputeOption> result = factory.create(
|
||||||
|
injector.getInstance(ComputeOptionsHandler.class)).parse(is);
|
||||||
|
assertEquals(result, ImmutableSortedSet.of(new ComputeOption(1, 512, 0.039f),
|
||||||
|
new ComputeOption(8, 16384, 1.61f)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code CustomizationParametersHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.CustomizationParametersHandlerTest")
|
||||||
|
public class CustomizationParametersHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/CustomizationParameters.xml");
|
||||||
|
|
||||||
|
CustomizationParameters result = (CustomizationParameters) factory.create(
|
||||||
|
injector.getInstance(CustomizationParametersHandler.class)).parse(is);
|
||||||
|
assertEquals(result, new CustomizationParameters(true, false));
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ import java.net.UnknownHostException;
|
||||||
|
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -55,8 +56,8 @@ public class InternetServiceHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
InternetService result = (InternetService) factory.create(
|
InternetService result = (InternetService) factory.create(
|
||||||
injector.getInstance(InternetServiceHandler.class)).parse(is);
|
injector.getInstance(InternetServiceHandler.class)).parse(is);
|
||||||
assertEquals(result, new InternetService(523 + "", "IS_for_Jim", null, new PublicIpAddress(
|
assertEquals(result, new InternetService(523, "IS_for_Jim", null, new PublicIpAddress(4208,
|
||||||
4208, InetAddress.getByName("10.1.22.159"), null), 80, "HTTP", false, 1,
|
InetAddress.getByName("10.1.22.159"), null), 80, Protocol.HTTP, false, 1,
|
||||||
"Some test service"));
|
"Some test service"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ public class InternetServiceHandlerTest extends BaseHandlerTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
result,
|
result,
|
||||||
new InternetService(
|
new InternetService(
|
||||||
524 + "",
|
524,
|
||||||
"IS_for_Jim2",
|
"IS_for_Jim2",
|
||||||
URI
|
URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
|
||||||
|
@ -77,6 +78,6 @@ public class InternetServiceHandlerTest extends BaseHandlerTest {
|
||||||
InetAddress.getByName("10.1.22.159"),
|
InetAddress.getByName("10.1.22.159"),
|
||||||
URI
|
URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")),
|
||||||
45, "HTTP", false, 1, "Some test service"));
|
45, Protocol.HTTP, false, 1, "Some test service"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.SortedSet;
|
||||||
|
|
||||||
import org.jclouds.http.functions.BaseHandlerTest;
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public class InternetServicesHandlerTest extends BaseHandlerTest {
|
||||||
result,
|
result,
|
||||||
ImmutableSortedSet
|
ImmutableSortedSet
|
||||||
.of(new InternetService(
|
.of(new InternetService(
|
||||||
524 + "",
|
524,
|
||||||
"IS_for_Jim2",
|
"IS_for_Jim2",
|
||||||
URI
|
URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/InternetServices/524"),
|
||||||
|
@ -64,6 +65,6 @@ public class InternetServicesHandlerTest extends BaseHandlerTest {
|
||||||
InetAddress.getByName("10.1.22.159"),
|
InetAddress.getByName("10.1.22.159"),
|
||||||
URI
|
URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/4208")),
|
||||||
45, "HTTP", false, 1, "Some test service")));
|
45, Protocol.HTTP, false, 1, "Some test service")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class NodeHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/terremark/NodeService.xml");
|
InputStream is = getClass().getResourceAsStream("/terremark/NodeService.xml");
|
||||||
|
|
||||||
Node result = (Node) factory.create(injector.getInstance(NodeHandler.class)).parse(is);
|
Node result = (Node) factory.create(injector.getInstance(NodeHandler.class)).parse(is);
|
||||||
assertEquals(result, new Node(242 + "", "Node for Jim", URI
|
assertEquals(result, new Node(242, "Node for Jim", URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242"),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242"),
|
||||||
InetAddress.getByName("172.16.20.3"), 80, false, "Some test node"));
|
InetAddress.getByName("172.16.20.3"), 80, false, "Some test node"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class NodesHandlerTest extends BaseHandlerTest {
|
||||||
InputStream is = getClass().getResourceAsStream("/terremark/NodeServices.xml");
|
InputStream is = getClass().getResourceAsStream("/terremark/NodeServices.xml");
|
||||||
|
|
||||||
SortedSet<Node> result = factory.create(injector.getInstance(NodesHandler.class)).parse(is);
|
SortedSet<Node> result = factory.create(injector.getInstance(NodesHandler.class)).parse(is);
|
||||||
assertEquals(result, ImmutableSortedSet.of(new Node(242 + "", "Node for Jim", URI
|
assertEquals(result, ImmutableSortedSet.of(new Node(242, "Node for Jim", URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242"),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/NodeServices/242"),
|
||||||
InetAddress.getByName("172.16.20.3"), 80, false, "Some test node")));
|
InetAddress.getByName("172.16.20.3"), 80, false, "Some test node")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code PublicIpAddressHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "vcloud.PublicIpAddressHandlerTest")
|
||||||
|
public class PublicIpAddressHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/PublicIpAddress.xml");
|
||||||
|
|
||||||
|
PublicIpAddress result = factory.create(injector.getInstance(PublicIpAddressHandler.class))
|
||||||
|
.parse(is);
|
||||||
|
assertEquals(result, new PublicIpAddress(8720, InetAddress.getByName("204.51.112.91"), URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720")));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you 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.terremark.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSortedSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code PublicIpAddressesHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "terremark.PublicIpAddressesHandlerTest")
|
||||||
|
public class PublicIpAddressesHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void test1() throws UnknownHostException {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/terremark/PublicIpAddresses.xml");
|
||||||
|
|
||||||
|
SortedSet<PublicIpAddress> result = factory.create(
|
||||||
|
injector.getInstance(PublicIpAddressesHandler.class)).parse(is);
|
||||||
|
assertEquals(
|
||||||
|
result,
|
||||||
|
ImmutableSortedSet
|
||||||
|
.of(
|
||||||
|
new PublicIpAddress(
|
||||||
|
8720,
|
||||||
|
InetAddress.getByName("204.51.112.91"),
|
||||||
|
URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720")),
|
||||||
|
new PublicIpAddress(
|
||||||
|
14965,
|
||||||
|
InetAddress.getByName("204.51.114.79"),
|
||||||
|
URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/14965"))));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
<ComputeOption xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<ProcessorCount>1</ProcessorCount>
|
||||||
|
<Memory>512</Memory>
|
||||||
|
<CostPerHour>0.0390</CostPerHour>
|
||||||
|
</ComputeOption>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<ComputeOptions xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<ComputeOption>
|
||||||
|
<ProcessorCount>1</ProcessorCount>
|
||||||
|
<Memory>512</Memory>
|
||||||
|
<CostPerHour>0.0390</CostPerHour>
|
||||||
|
</ComputeOption>
|
||||||
|
<ComputeOption>
|
||||||
|
<ProcessorCount>8</ProcessorCount>
|
||||||
|
<Memory>16384</Memory>
|
||||||
|
<CostPerHour>1.6100</CostPerHour>
|
||||||
|
</ComputeOption>
|
||||||
|
</ComputeOptions>
|
|
@ -1,7 +1,7 @@
|
||||||
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
|
||||||
<Name>name</Name>
|
<Name>name</Name>
|
||||||
<Protocol>tcp</Protocol>
|
<Protocol>TCP</Protocol>
|
||||||
<Port>22</Port>
|
<Port>22</Port>
|
||||||
<Enabled>false</Enabled>
|
<Enabled>false</Enabled>
|
||||||
<Description>yahoo</Description>
|
<Description>yahoo</Description>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<InternetService xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpress-1.0:request:createInternetService">
|
||||||
<Name>name</Name>
|
<Name>name</Name>
|
||||||
<Protocol>tcp</Protocol>
|
<Protocol>TCP</Protocol>
|
||||||
<Port>22</Port>
|
<Port>22</Port>
|
||||||
<Enabled>true</Enabled>
|
<Enabled>true</Enabled>
|
||||||
</InternetService>
|
</InternetService>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<CustomizationParameters xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<CustomizeNetwork>true</CustomizeNetwork>
|
||||||
|
<CustomizePassword>false</CustomizePassword>
|
||||||
|
</CustomizationParameters>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<PublicIPAddress xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<Id>8720</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720
|
||||||
|
</Href>
|
||||||
|
<Name>204.51.112.91</Name>
|
||||||
|
</PublicIPAddress>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<PublicIpAddresses xmlns="urn:tmrk:vCloudExpress-1.0"
|
||||||
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<PublicIPAddress>
|
||||||
|
<Id>8720</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/8720
|
||||||
|
</Href>
|
||||||
|
<Name>204.51.112.91</Name>
|
||||||
|
</PublicIPAddress>
|
||||||
|
<PublicIPAddress>
|
||||||
|
<Id>14965</Id>
|
||||||
|
<Href>https://services.vcloudexpress.terremark.com/api/v0.8/PublicIps/14965
|
||||||
|
</Href>
|
||||||
|
<Name>204.51.114.79</Name>
|
||||||
|
</PublicIPAddress>
|
||||||
|
</PublicIpAddresses>
|
Loading…
Reference in New Issue