mirror of https://github.com/apache/jclouds.git
Issue 286: started ecloud support
This commit is contained in:
parent
557424aa91
commit
d6c0cbff80
|
@ -50,6 +50,9 @@ rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingProperties
|
||||||
terremark.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudContextBuilder
|
terremark.contextbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudContextBuilder
|
||||||
terremark.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder
|
terremark.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder
|
||||||
|
|
||||||
|
ecloud.contextbuilder=org.jclouds.vcloud.terremark.TerremarkECloudContextBuilder
|
||||||
|
ecloud.propertiesbuilder=org.jclouds.vcloud.terremark.TerremarkECloudPropertiesBuilder
|
||||||
|
|
||||||
hostingdotcom.contextbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudContextBuilder
|
hostingdotcom.contextbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudContextBuilder
|
||||||
hostingdotcom.propertiesbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudPropertiesBuilder
|
hostingdotcom.propertiesbuilder=org.jclouds.vcloud.hostingdotcom.HostingDotComVCloudPropertiesBuilder
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,10 @@ public enum TaskStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TaskStatus fromValue(String status) {
|
public static TaskStatus fromValue(String status) {
|
||||||
|
if ("CANCELED".equals(status.toUpperCase())) {
|
||||||
|
// TODO: ecloud hack
|
||||||
|
status = "CANCELLED";
|
||||||
|
}
|
||||||
return valueOf(checkNotNull(status, "status").toUpperCase());
|
return valueOf(checkNotNull(status, "status").toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class VCloudClientLiveTest {
|
||||||
Organization response = connection.getDefaultOrganization();
|
Organization response = connection.getDefaultOrganization();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getId());
|
assertNotNull(response.getId());
|
||||||
assertNotNull(identity);
|
|
||||||
assert response.getCatalogs().size() >= 1;
|
assert response.getCatalogs().size() >= 1;
|
||||||
assert response.getTasksLists().size() >= 1;
|
assert response.getTasksLists().size() >= 1;
|
||||||
assert response.getVDCs().size() >= 1;
|
assert response.getVDCs().size() >= 1;
|
||||||
|
|
|
@ -0,0 +1,363 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||||
|
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
|
||||||
|
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||||
|
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.CATALOGITEMCUSTOMIZATIONPARAMETERS_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.INTERNETSERVICESLIST_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.INTERNETSERVICE_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.NODESERVICE_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.PUBLICIPSLIST_XML;
|
||||||
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.PUBLICIP_XML;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.DELETE;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.PUT;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import org.jclouds.predicates.validators.DnsNameValidator;
|
||||||
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.MapBinder;
|
||||||
|
import org.jclouds.rest.annotations.MapPayloadParam;
|
||||||
|
import org.jclouds.rest.annotations.ParamParser;
|
||||||
|
import org.jclouds.rest.annotations.ParamValidators;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
|
import org.jclouds.vcloud.domain.Catalog;
|
||||||
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
|
import org.jclouds.vcloud.domain.VDC;
|
||||||
|
import org.jclouds.vcloud.endpoints.Org;
|
||||||
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.vcloud.functions.CatalogIdToUri;
|
||||||
|
import org.jclouds.vcloud.functions.VAppId;
|
||||||
|
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload;
|
||||||
|
import org.jclouds.vcloud.terremark.binders.BindVAppConfigurationToXmlPayload;
|
||||||
|
import org.jclouds.vcloud.terremark.binders.TerremarkBindInstantiateVAppTemplateParamsToXmlPayload;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
||||||
|
import org.jclouds.vcloud.terremark.functions.ParseTaskFromLocationHeader;
|
||||||
|
import org.jclouds.vcloud.terremark.functions.ReturnEmptySetOnResourceNotFoundException;
|
||||||
|
import org.jclouds.vcloud.terremark.functions.ReturnVoidOnDeleteDefaultIp;
|
||||||
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.CustomizationParametersHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
|
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||||
|
import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
/**
|
||||||
|
* Provides access to VCloud resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
|
public interface TerremarkAsyncClient extends VCloudAsyncClient {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Endpoint(Org.class)
|
||||||
|
@Consumes(ORG_XML)
|
||||||
|
@XMLResponseParser(TerremarkOrgHandler.class)
|
||||||
|
ListenableFuture<? extends TerremarkOrganization> getDefaultOrganization();
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/org/{orgId}")
|
||||||
|
@XMLResponseParser(TerremarkOrgHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Consumes(ORG_XML)
|
||||||
|
ListenableFuture<? extends TerremarkOrganization> getOrganization(
|
||||||
|
@PathParam("orgId") String orgId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getDefaultVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
||||||
|
@XMLResponseParser(TerremarkVDCHandler.class)
|
||||||
|
@Consumes(VDC_XML)
|
||||||
|
ListenableFuture<? extends VDC> getDefaultVDC();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terremark does not have multiple catalogs, so we ignore this parameter.
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
||||||
|
@XMLResponseParser(CatalogHandler.class)
|
||||||
|
@Consumes(CATALOG_XML)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends Catalog> getCatalog(String catalogId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/vdc/{vDCId}")
|
||||||
|
@XMLResponseParser(TerremarkVDCHandler.class)
|
||||||
|
@Consumes(VDC_XML)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#instantiateVAppTemplateInVDC
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/vdc/{vDCId}/action/instantiateVAppTemplate")
|
||||||
|
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
||||||
|
@Consumes(VAPP_XML)
|
||||||
|
@XMLResponseParser(VAppHandler.class)
|
||||||
|
@MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||||
|
ListenableFuture<? extends VApp> instantiateVAppTemplateInVDC(@PathParam("vDCId") String vDCId,
|
||||||
|
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
|
||||||
|
@MapPayloadParam("template") @ParamParser(CatalogIdToUri.class) String templateId,
|
||||||
|
InstantiateVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetService
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/vdc/{vDCId}/internetServices")
|
||||||
|
@Produces(INTERNETSERVICE_XML)
|
||||||
|
@Consumes(INTERNETSERVICE_XML)
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
|
ListenableFuture<? extends InternetService> addInternetServiceToVDC(
|
||||||
|
@PathParam("vDCId") String vDCId, @MapPayloadParam("name") String serviceName,
|
||||||
|
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
||||||
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getAllInternetServices
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/vdc/{vDCId}/internetServices")
|
||||||
|
@Consumes(INTERNETSERVICESLIST_XML)
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
ListenableFuture<? extends SortedSet<InternetService>> getAllInternetServicesInVDC(
|
||||||
|
@PathParam("vDCId") String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetServiceToExistingIp
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}/internetServices")
|
||||||
|
@Produces(INTERNETSERVICE_XML)
|
||||||
|
@Consumes(INTERNETSERVICE_XML)
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
|
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(
|
||||||
|
@PathParam("ipId") int existingIpId, @MapPayloadParam("name") String serviceName,
|
||||||
|
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
||||||
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deletePublicIp
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}")
|
||||||
|
@ExceptionParser(ReturnVoidOnDeleteDefaultIp.class)
|
||||||
|
ListenableFuture<Void> deletePublicIp(@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetServicesOnPublicIP
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}/internetServices")
|
||||||
|
@Consumes(INTERNETSERVICESLIST_XML)
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
ListenableFuture<? extends SortedSet<InternetService>> getInternetServicesOnPublicIp(
|
||||||
|
@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getPublicIp
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}")
|
||||||
|
@Consumes(PUBLICIP_XML)
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends SortedSet<InternetService>> getPublicIp(@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getPublicIpsAssociatedWithVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/vdc/{vDCId}/publicIps")
|
||||||
|
@Consumes(PUBLICIPSLIST_XML)
|
||||||
|
@XMLResponseParser(PublicIpAddressesHandler.class)
|
||||||
|
ListenableFuture<? extends SortedSet<PublicIpAddress>> getPublicIpsAssociatedWithVDC(
|
||||||
|
@PathParam("vDCId") String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#activatePublicIpInVDC
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/{vDCId}/publicIps")
|
||||||
|
@XMLResponseParser(PublicIpAddressesHandler.class)
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<PublicIpAddress> activatePublicIpInVDC(@PathParam("vDCId") String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deleteInternetService
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/internetService/{internetServiceId}")
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Void> deleteInternetService(
|
||||||
|
@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetService
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/internetService/{internetServiceId}")
|
||||||
|
@Consumes(INTERNETSERVICESLIST_XML)
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends InternetService> getInternetService(
|
||||||
|
@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addNode
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
|
||||||
|
@Produces(NODESERVICE_XML)
|
||||||
|
@Consumes(NODESERVICE_XML)
|
||||||
|
@XMLResponseParser(NodeHandler.class)
|
||||||
|
@MapBinder(AddNodeOptions.class)
|
||||||
|
ListenableFuture<? extends Node> addNode(@PathParam("internetServiceId") int internetServiceId,
|
||||||
|
@MapPayloadParam("ipAddress") String ipAddress, @MapPayloadParam("name") String name,
|
||||||
|
@MapPayloadParam("port") int port, AddNodeOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getNodes
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
|
||||||
|
@XMLResponseParser(NodesHandler.class)
|
||||||
|
@ExceptionParser(ReturnEmptySetOnResourceNotFoundException.class)
|
||||||
|
@Consumes(NODESERVICE_XML)
|
||||||
|
ListenableFuture<? extends SortedSet<Node>> getNodes(
|
||||||
|
@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getNode
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/nodeService/{nodeId}")
|
||||||
|
@XMLResponseParser(NodeHandler.class)
|
||||||
|
@Consumes(NODESERVICE_XML)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<? extends Node> getNode(@PathParam("nodeId") int nodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#configureNode
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/nodeService/{nodeId}")
|
||||||
|
@Produces(NODESERVICE_XML)
|
||||||
|
@Consumes(NODESERVICE_XML)
|
||||||
|
@XMLResponseParser(NodeHandler.class)
|
||||||
|
ListenableFuture<? extends Node> configureNode(
|
||||||
|
@PathParam("nodeId") int nodeId,
|
||||||
|
@BinderParam(BindNodeConfigurationToXmlPayload.class) NodeConfiguration nodeConfiguration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#deleteNode
|
||||||
|
*/
|
||||||
|
@DELETE
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/nodeService/{nodeId}")
|
||||||
|
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Void> deleteNode(@PathParam("nodeId") int nodeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#configureVApp
|
||||||
|
*/
|
||||||
|
@PUT
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/vapp/{vAppId}")
|
||||||
|
@Produces(VAPP_XML)
|
||||||
|
@Consumes(VAPP_XML)
|
||||||
|
@MapBinder(BindVAppConfigurationToXmlPayload.class)
|
||||||
|
@ResponseParser(ParseTaskFromLocationHeader.class)
|
||||||
|
ListenableFuture<? extends Task> configureVApp(
|
||||||
|
@PathParam("vAppId") @ParamParser(VAppId.class) VApp vApp,
|
||||||
|
VAppConfiguration configuration);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getCustomizationOptionsOfCatalogItem
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/template/{catalogItemId}/options/customization")
|
||||||
|
@XMLResponseParser(CustomizationParametersHandler.class)
|
||||||
|
@Consumes(CATALOGITEMCUSTOMIZATIONPARAMETERS_XML)
|
||||||
|
ListenableFuture<? extends CustomizationParameters> getCustomizationOptionsOfCatalogItem(
|
||||||
|
@PathParam("catalogItemId") String catalogItemId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
||||||
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to VCloud resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface TerremarkClient extends VCloudClient {
|
||||||
|
|
||||||
|
TerremarkOrganization getDefaultOrganization();
|
||||||
|
|
||||||
|
TerremarkOrganization getOrganization(String orgId);
|
||||||
|
|
||||||
|
CustomizationParameters getCustomizationOptionsOfCatalogItem(String catalogItemId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call returns a list of public IP addresses.
|
||||||
|
*/
|
||||||
|
SortedSet<PublicIpAddress> getPublicIpsAssociatedWithVDC(String vDCId);
|
||||||
|
|
||||||
|
void deletePublicIp(int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate a new public IP
|
||||||
|
*
|
||||||
|
* @param vDCId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PublicIpAddress activatePublicIpInVDC(String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The call creates a new internet server, including protocol and port information. The public IP
|
||||||
|
* is dynamically allocated.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
InternetService addInternetServiceToVDC(String vDCId, 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
InternetService addInternetServiceToExistingIp(int existingIpId, String serviceName,
|
||||||
|
Protocol protocol, int port, AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
void deleteInternetService(int internetServiceId);
|
||||||
|
|
||||||
|
InternetService getInternetService(int internetServiceId);
|
||||||
|
|
||||||
|
SortedSet<InternetService> getAllInternetServicesInVDC(String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call returns information about the internet service on a public IP.
|
||||||
|
*/
|
||||||
|
SortedSet<InternetService> getInternetServicesOnPublicIp(int ipId);
|
||||||
|
|
||||||
|
SortedSet<InternetService> getPublicIp(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, String ipAddress, String name, int port,
|
||||||
|
AddNodeOptions... options);
|
||||||
|
|
||||||
|
Node getNode(int nodeId);
|
||||||
|
|
||||||
|
Node configureNode(int nodeId, NodeConfiguration nodeConfiguration);
|
||||||
|
|
||||||
|
void deleteNode(int nodeId);
|
||||||
|
|
||||||
|
SortedSet<Node> getNodes(int internetServiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This call configures the settings of an existing vApp by passing the new configuration. The
|
||||||
|
* existing vApp must be in a powered off state (status = 2).
|
||||||
|
* <p/>
|
||||||
|
* You can change the following items for a vApp.
|
||||||
|
* <ol>
|
||||||
|
* <li>vApp name Number of virtual CPUs</li>
|
||||||
|
* <li>Amount of virtual memory</li>
|
||||||
|
* <li>Add a virtual disk</li>
|
||||||
|
* <li>Delete a virtual disk</li>
|
||||||
|
* </ol>
|
||||||
|
* You can make more than one change in a single request. For example, you can increase the
|
||||||
|
* number of virtual CPUs and the amount of virtual memory in the same request.
|
||||||
|
*
|
||||||
|
* @param vApp
|
||||||
|
* vApp to change in power state off
|
||||||
|
* @param configuration
|
||||||
|
* (s) to change
|
||||||
|
* @return task of configuration change
|
||||||
|
*/
|
||||||
|
Task configureVApp(VApp vApp, VAppConfiguration configuration);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.MapBinder;
|
||||||
|
import org.jclouds.rest.annotations.MapPayloadParam;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
||||||
|
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to eCloud resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="http://support.theenterprisecloud.com/kb/default.asp?id=645&Lang=1&SID=" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
|
public interface TerremarkECloudAsyncClient extends TerremarkAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetService
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/vdc/{vDCId}/internetServices")
|
||||||
|
@Produces("application/vnd.tmrk.ecloud.internetService+xml")
|
||||||
|
@Consumes("application/vnd.tmrk.ecloud.internetService+xml")
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
|
@Override
|
||||||
|
ListenableFuture<? extends InternetService> addInternetServiceToVDC(
|
||||||
|
@PathParam("vDCId") String vDCId, @MapPayloadParam("name") String serviceName,
|
||||||
|
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
||||||
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getAllInternetServices
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/vdc/{vDCId}/internetServices")
|
||||||
|
@Consumes("application/vnd.tmrk.ecloud.internetServicesList+xml")
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
@Override
|
||||||
|
ListenableFuture<? extends SortedSet<InternetService>> getAllInternetServicesInVDC(
|
||||||
|
@PathParam("vDCId") String vDCId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#addInternetServiceToExistingIp
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}/internetServices")
|
||||||
|
@Produces("application/vnd.tmrk.ecloud.internetService+xml")
|
||||||
|
@Consumes("application/vnd.tmrk.ecloud.internetService+xml")
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@MapBinder(AddInternetServiceOptions.class)
|
||||||
|
@Override
|
||||||
|
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(
|
||||||
|
@PathParam("ipId") int existingIpId, @MapPayloadParam("name") String serviceName,
|
||||||
|
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
||||||
|
AddInternetServiceOptions... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetServicesOnPublicIP
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/publicIp/{ipId}/internetServices")
|
||||||
|
@Consumes("application/vnd.tmrk.ecloud.internetServicesList+xml")
|
||||||
|
@XMLResponseParser(InternetServicesHandler.class)
|
||||||
|
@Override
|
||||||
|
ListenableFuture<? extends SortedSet<InternetService>> getInternetServicesOnPublicIp(
|
||||||
|
@PathParam("ipId") int ipId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see TerremarkVCloudClient#getInternetService
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||||
|
@Path("/extensions/internetService/{internetServiceId}")
|
||||||
|
@Consumes("application/vnd.tmrk.ecloud.internetServicesList+xml")
|
||||||
|
@XMLResponseParser(InternetServiceHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Override
|
||||||
|
ListenableFuture<? extends InternetService> getInternetService(
|
||||||
|
@PathParam("internetServiceId") int internetServiceId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to VCloud resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="http://support.theenterprisecloud.com/kb/default.asp?id=645&Lang=1&SID=" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface TerremarkECloudClient extends TerremarkClient {
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||||
|
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||||
|
import org.jclouds.vcloud.VCloudContextBuilder;
|
||||||
|
import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
||||||
|
import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule;
|
||||||
|
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates {@link TerremarkVCloudComputeServiceContext} or {@link Injector} instances based on the
|
||||||
|
* most commonly requested arguments.
|
||||||
|
* <p/>
|
||||||
|
* Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
|
||||||
|
* <p/>
|
||||||
|
* <p/>
|
||||||
|
* If no <code>Module</code>s are specified, the default {@link JDKLoggingModule logging} and
|
||||||
|
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
* @see TerremarkVCloudComputeServiceContext
|
||||||
|
*/
|
||||||
|
public class TerremarkECloudContextBuilder extends VCloudContextBuilder {
|
||||||
|
|
||||||
|
public TerremarkECloudContextBuilder(Properties props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addContextModule(List<Module> modules) {
|
||||||
|
// TODO make ecloud version which retrieves passwords from the vapptemplate description
|
||||||
|
modules.add(new VCloudComputeServiceContextModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addClientModule(List<Module> modules) {
|
||||||
|
modules.add(new TerremarkECloudRestClientModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds properties used in Terremark VCloud Clients
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TerremarkECloudPropertiesBuilder extends TerremarkVCloudPropertiesBuilder {
|
||||||
|
@Override
|
||||||
|
protected Properties defaultProperties() {
|
||||||
|
Properties properties = super.defaultProperties();
|
||||||
|
properties.setProperty(PROPERTY_API_VERSION, "v0.8b-ext2.3");
|
||||||
|
properties.setProperty(PROPERTY_ENDPOINT, "https://services.enterprisecloud.terremark.com/api");
|
||||||
|
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions");
|
||||||
|
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.3");
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TerremarkECloudPropertiesBuilder(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,84 +19,32 @@
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
|
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
|
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
|
||||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.CATALOGITEMCUSTOMIZATIONPARAMETERS_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.INTERNETSERVICESLIST_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.INTERNETSERVICE_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.KEYSLIST_XML;
|
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.KEYSLIST_XML;
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.NODESERVICE_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.PUBLICIPSLIST_XML;
|
|
||||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.PUBLICIP_XML;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.PUT;
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
|
||||||
import org.jclouds.predicates.validators.DnsNameValidator;
|
|
||||||
import org.jclouds.rest.annotations.BinderParam;
|
|
||||||
import org.jclouds.rest.annotations.Endpoint;
|
import org.jclouds.rest.annotations.Endpoint;
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
import org.jclouds.rest.annotations.MapBinder;
|
import org.jclouds.rest.annotations.MapBinder;
|
||||||
import org.jclouds.rest.annotations.MapPayloadParam;
|
import org.jclouds.rest.annotations.MapPayloadParam;
|
||||||
import org.jclouds.rest.annotations.ParamParser;
|
|
||||||
import org.jclouds.rest.annotations.ParamValidators;
|
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.ResponseParser;
|
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
|
||||||
import org.jclouds.vcloud.endpoints.Org;
|
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||||
import org.jclouds.vcloud.functions.CatalogIdToUri;
|
|
||||||
import org.jclouds.vcloud.functions.VAppId;
|
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload;
|
import org.jclouds.vcloud.terremark.binders.BindCreateKeyToXmlPayload;
|
||||||
import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload;
|
|
||||||
import org.jclouds.vcloud.terremark.binders.BindVAppConfigurationToXmlPayload;
|
|
||||||
import org.jclouds.vcloud.terremark.binders.TerremarkBindInstantiateVAppTemplateParamsToXmlPayload;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
|
||||||
import org.jclouds.vcloud.terremark.endpoints.KeysList;
|
import org.jclouds.vcloud.terremark.endpoints.KeysList;
|
||||||
import org.jclouds.vcloud.terremark.functions.ParseTaskFromLocationHeader;
|
|
||||||
import org.jclouds.vcloud.terremark.functions.ReturnEmptySetOnResourceNotFoundException;
|
|
||||||
import org.jclouds.vcloud.terremark.functions.ReturnVoidOnDeleteDefaultIp;
|
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.CustomizationParametersHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServiceHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.KeyPairHandler;
|
import org.jclouds.vcloud.terremark.xml.KeyPairHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.KeyPairsHandler;
|
import org.jclouds.vcloud.terremark.xml.KeyPairsHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.NodeHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.NodesHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler;
|
|
||||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VAppHandler;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
@ -108,262 +56,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
public interface TerremarkVCloudAsyncClient extends TerremarkAsyncClient {
|
||||||
|
|
||||||
@GET
|
|
||||||
@Endpoint(Org.class)
|
|
||||||
@Consumes(ORG_XML)
|
|
||||||
@XMLResponseParser(TerremarkOrgHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends TerremarkOrganization> getDefaultOrganization();
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/org/{orgId}")
|
|
||||||
@XMLResponseParser(TerremarkOrgHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Consumes(ORG_XML)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends TerremarkOrganization> getOrganization(
|
|
||||||
@PathParam("orgId") String orgId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getDefaultVDC
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
|
|
||||||
@XMLResponseParser(TerremarkVDCHandler.class)
|
|
||||||
@Consumes(VDC_XML)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VDC> getDefaultVDC();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terremark does not have multiple catalogs, so we ignore this parameter.
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
|
|
||||||
@XMLResponseParser(CatalogHandler.class)
|
|
||||||
@Consumes(CATALOG_XML)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Catalog> getCatalog(String catalogId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getVDC
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/vdc/{vDCId}")
|
|
||||||
@XMLResponseParser(TerremarkVDCHandler.class)
|
|
||||||
@Consumes(VDC_XML)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#instantiateVAppTemplateInVDC
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/vdc/{vDCId}/action/instantiateVAppTemplate")
|
|
||||||
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
|
||||||
@Consumes(VAPP_XML)
|
|
||||||
@XMLResponseParser(VAppHandler.class)
|
|
||||||
@MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VApp> instantiateVAppTemplateInVDC(@PathParam("vDCId") String vDCId,
|
|
||||||
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
|
|
||||||
@MapPayloadParam("template") @ParamParser(CatalogIdToUri.class) String templateId,
|
|
||||||
InstantiateVAppTemplateOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#addInternetService
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/vdc/{vDCId}/internetServices")
|
|
||||||
@Produces(INTERNETSERVICE_XML)
|
|
||||||
@Consumes(INTERNETSERVICE_XML)
|
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
|
||||||
@MapBinder(AddInternetServiceOptions.class)
|
|
||||||
ListenableFuture<? extends InternetService> addInternetServiceToVDC(
|
|
||||||
@PathParam("vDCId") String vDCId, @MapPayloadParam("name") String serviceName,
|
|
||||||
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
|
||||||
AddInternetServiceOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getAllInternetServices
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/vdc/{vDCId}/internetServices")
|
|
||||||
@Consumes(INTERNETSERVICESLIST_XML)
|
|
||||||
@XMLResponseParser(InternetServicesHandler.class)
|
|
||||||
ListenableFuture<? extends SortedSet<InternetService>> getAllInternetServicesInVDC(
|
|
||||||
@PathParam("vDCId") String vDCId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#addInternetServiceToExistingIp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/publicIp/{ipId}/internetServices")
|
|
||||||
@Produces(INTERNETSERVICE_XML)
|
|
||||||
@Consumes(INTERNETSERVICE_XML)
|
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
|
||||||
@MapBinder(AddInternetServiceOptions.class)
|
|
||||||
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(
|
|
||||||
@PathParam("ipId") int existingIpId, @MapPayloadParam("name") String serviceName,
|
|
||||||
@MapPayloadParam("protocol") Protocol protocol, @MapPayloadParam("port") int port,
|
|
||||||
AddInternetServiceOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#deletePublicIp
|
|
||||||
*/
|
|
||||||
@DELETE
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/publicIp/{ipId}")
|
|
||||||
@ExceptionParser(ReturnVoidOnDeleteDefaultIp.class)
|
|
||||||
ListenableFuture<Void> deletePublicIp(@PathParam("ipId") int ipId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getInternetServicesOnPublicIP
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/publicIp/{ipId}/internetServices")
|
|
||||||
@Consumes(INTERNETSERVICESLIST_XML)
|
|
||||||
@XMLResponseParser(InternetServicesHandler.class)
|
|
||||||
ListenableFuture<? extends SortedSet<InternetService>> getInternetServicesOnPublicIp(
|
|
||||||
@PathParam("ipId") int ipId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getPublicIp
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/publicIp/{ipId}")
|
|
||||||
@Consumes(PUBLICIP_XML)
|
|
||||||
@XMLResponseParser(InternetServicesHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends SortedSet<InternetService>> getPublicIp(@PathParam("ipId") int ipId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getPublicIpsAssociatedWithVDC
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/vdc/{vDCId}/publicIps")
|
|
||||||
@Consumes(PUBLICIPSLIST_XML)
|
|
||||||
@XMLResponseParser(PublicIpAddressesHandler.class)
|
|
||||||
ListenableFuture<? extends SortedSet<PublicIpAddress>> getPublicIpsAssociatedWithVDC(
|
|
||||||
@PathParam("vDCId") String vDCId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#deleteInternetService
|
|
||||||
*/
|
|
||||||
@DELETE
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/internetService/{internetServiceId}")
|
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<Void> deleteInternetService(
|
|
||||||
@PathParam("internetServiceId") int internetServiceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getInternetService
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/internetService/{internetServiceId}")
|
|
||||||
@Consumes(INTERNETSERVICESLIST_XML)
|
|
||||||
@XMLResponseParser(InternetServiceHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends InternetService> getInternetService(
|
|
||||||
@PathParam("internetServiceId") int internetServiceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#addNode
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
|
|
||||||
@Produces(NODESERVICE_XML)
|
|
||||||
@Consumes(NODESERVICE_XML)
|
|
||||||
@XMLResponseParser(NodeHandler.class)
|
|
||||||
@MapBinder(AddNodeOptions.class)
|
|
||||||
ListenableFuture<? extends Node> addNode(@PathParam("internetServiceId") int internetServiceId,
|
|
||||||
@MapPayloadParam("ipAddress") String ipAddress, @MapPayloadParam("name") String name,
|
|
||||||
@MapPayloadParam("port") int port, AddNodeOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getNodes
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/internetService/{internetServiceId}/nodeServices")
|
|
||||||
@XMLResponseParser(NodesHandler.class)
|
|
||||||
@ExceptionParser(ReturnEmptySetOnResourceNotFoundException.class)
|
|
||||||
@Consumes(NODESERVICE_XML)
|
|
||||||
ListenableFuture<? extends SortedSet<Node>> getNodes(
|
|
||||||
@PathParam("internetServiceId") int internetServiceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getNode
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/nodeService/{nodeId}")
|
|
||||||
@XMLResponseParser(NodeHandler.class)
|
|
||||||
@Consumes(NODESERVICE_XML)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<? extends Node> getNode(@PathParam("nodeId") int nodeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#configureNode
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/nodeService/{nodeId}")
|
|
||||||
@Produces(NODESERVICE_XML)
|
|
||||||
@Consumes(NODESERVICE_XML)
|
|
||||||
@XMLResponseParser(NodeHandler.class)
|
|
||||||
ListenableFuture<? extends Node> configureNode(
|
|
||||||
@PathParam("nodeId") int nodeId,
|
|
||||||
@BinderParam(BindNodeConfigurationToXmlPayload.class) NodeConfiguration nodeConfiguration);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#deleteNode
|
|
||||||
*/
|
|
||||||
@DELETE
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/nodeService/{nodeId}")
|
|
||||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
|
||||||
ListenableFuture<Void> deleteNode(@PathParam("nodeId") int nodeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#configureVApp
|
|
||||||
*/
|
|
||||||
@PUT
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/vapp/{vAppId}")
|
|
||||||
@Produces(VAPP_XML)
|
|
||||||
@Consumes(VAPP_XML)
|
|
||||||
@MapBinder(BindVAppConfigurationToXmlPayload.class)
|
|
||||||
@ResponseParser(ParseTaskFromLocationHeader.class)
|
|
||||||
ListenableFuture<? extends Task> configureVApp(
|
|
||||||
@PathParam("vAppId") @ParamParser(VAppId.class) VApp vApp,
|
|
||||||
VAppConfiguration configuration);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TerremarkVCloudClient#getCustomizationOptionsOfCatalogItem
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
|
||||||
@Path("/extensions/template/{catalogItemId}/options/customization")
|
|
||||||
@XMLResponseParser(CustomizationParametersHandler.class)
|
|
||||||
@Consumes(CATALOGITEMCUSTOMIZATIONPARAMETERS_XML)
|
|
||||||
ListenableFuture<? extends CustomizationParameters> getCustomizationOptionsOfCatalogItem(
|
|
||||||
@PathParam("catalogItemId") String catalogItemId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TerremarkVCloudClient#listKeyPairs
|
* @see TerremarkVCloudClient#listKeyPairs
|
||||||
|
|
|
@ -19,132 +19,20 @@
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
|
|
||||||
import org.jclouds.vcloud.terremark.options.AddInternetServiceOptions;
|
|
||||||
import org.jclouds.vcloud.terremark.options.AddNodeOptions;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to VCloud resources via their REST API.
|
* Provides access to VCloud resources via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||||
* />
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface TerremarkVCloudClient extends VCloudClient {
|
public interface TerremarkVCloudClient extends TerremarkClient {
|
||||||
|
|
||||||
@Override
|
|
||||||
TerremarkOrganization getDefaultOrganization();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
TerremarkOrganization getOrganization(String orgId);
|
|
||||||
|
|
||||||
CustomizationParameters getCustomizationOptionsOfCatalogItem(
|
|
||||||
String catalogItemId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This call returns a list of public IP addresses.
|
|
||||||
*/
|
|
||||||
SortedSet<PublicIpAddress> getPublicIpsAssociatedWithVDC(String vDCId);
|
|
||||||
|
|
||||||
void deletePublicIp(int ipId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The call creates a new internet server, including protocol and port
|
|
||||||
* information. The public IP is dynamically allocated.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
InternetService addInternetServiceToVDC(String vDCId, 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
InternetService addInternetServiceToExistingIp(int existingIpId,
|
|
||||||
String serviceName, Protocol protocol, int port,
|
|
||||||
AddInternetServiceOptions... options);
|
|
||||||
|
|
||||||
void deleteInternetService(int internetServiceId);
|
|
||||||
|
|
||||||
InternetService getInternetService(int internetServiceId);
|
|
||||||
|
|
||||||
SortedSet<InternetService> getAllInternetServicesInVDC(String vDCId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This call returns information about the internet service on a public IP.
|
|
||||||
*/
|
|
||||||
SortedSet<InternetService> getInternetServicesOnPublicIp(int ipId);
|
|
||||||
|
|
||||||
SortedSet<InternetService> getPublicIp(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, String ipAddress, String name, int port,
|
|
||||||
AddNodeOptions... options);
|
|
||||||
|
|
||||||
Node getNode(int nodeId);
|
|
||||||
|
|
||||||
Node configureNode(int nodeId, NodeConfiguration nodeConfiguration);
|
|
||||||
|
|
||||||
void deleteNode(int nodeId);
|
|
||||||
|
|
||||||
SortedSet<Node> getNodes(int internetServiceId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This call configures the settings of an existing vApp by passing the new
|
|
||||||
* configuration. The existing vApp must be in a powered off state (status =
|
|
||||||
* 2).
|
|
||||||
* <p/>
|
|
||||||
* You can change the following items for a vApp.
|
|
||||||
* <ol>
|
|
||||||
* <li>vApp name Number of virtual CPUs</li>
|
|
||||||
* <li>Amount of virtual memory</li>
|
|
||||||
* <li>Add a virtual disk</li>
|
|
||||||
* <li>Delete a virtual disk</li>
|
|
||||||
* </ol>
|
|
||||||
* You can make more than one change in a single request. For example, you
|
|
||||||
* can increase the number of virtual CPUs and the amount of virtual memory
|
|
||||||
* in the same request.
|
|
||||||
*
|
|
||||||
* @param vApp
|
|
||||||
* vApp to change in power state off
|
|
||||||
* @param configuration
|
|
||||||
* (s) to change
|
|
||||||
* @return task of configuration change
|
|
||||||
*/
|
|
||||||
Task configureVApp(VApp vApp, VAppConfiguration configuration);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This call returns the keys previously created for your organization.
|
* This call returns the keys previously created for your organization.
|
||||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.vcloud.terremark;
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -36,10 +39,12 @@ public class TerremarkVCloudPropertiesBuilder extends VCloudPropertiesBuilder {
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6");
|
properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6");
|
||||||
|
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions");
|
||||||
|
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api");
|
||||||
properties.setProperty("jclouds.dns_name_length_min", "1");
|
properties.setProperty("jclouds.dns_name_length_min", "1");
|
||||||
properties.setProperty("jclouds.dns_name_length_max", "15");
|
properties.setProperty("jclouds.dns_name_length_max", "15");
|
||||||
// with ssh key injection comes another reboot. allowing more time
|
// with ssh key injection comes another reboot. allowing more time
|
||||||
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 360l * 1000l + "");
|
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 360l * 1000l + "");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -48,4 +53,17 @@ public class TerremarkVCloudPropertiesBuilder extends VCloudPropertiesBuilder {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Properties build() {
|
||||||
|
setExtensions();
|
||||||
|
return super.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setExtensions() {
|
||||||
|
if (properties.getProperty(PROPERTY_TERREMARK_EXTENSION_NS) == null) {
|
||||||
|
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NS, String.format("urn:tmrk:%s-%s",
|
||||||
|
properties.getProperty(PROPERTY_TERREMARK_EXTENSION_NAME), properties
|
||||||
|
.getProperty(PROPERTY_TERREMARK_EXTENSION_VERSION)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.util.Utils.replaceTokens;
|
import static org.jclouds.util.Utils.replaceTokens;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -42,12 +43,14 @@ import com.google.common.collect.ImmutableMap;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindAddInternetServiceToXmlPayload implements MapBinder {
|
public class BindAddInternetServiceToXmlPayload implements MapBinder {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("CreateInternetService")
|
@Named("CreateInternetService")
|
||||||
private String xmlTemplate;
|
private String xmlTemplate;
|
||||||
@Inject
|
@Inject
|
||||||
private BindToStringPayload stringBinder;
|
private BindToStringPayload stringBinder;
|
||||||
|
@Inject
|
||||||
|
@Named(PROPERTY_TERREMARK_EXTENSION_NS)
|
||||||
|
private String ns;
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ public class BindAddInternetServiceToXmlPayload implements MapBinder {
|
||||||
String enabled = checkNotNull(postParams.get("enabled"), "enabled parameter not present");
|
String enabled = checkNotNull(postParams.get("enabled"), "enabled parameter not present");
|
||||||
String description = postParams.get("description");
|
String description = postParams.get("description");
|
||||||
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name, "protocol",
|
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name, "protocol",
|
||||||
protocol, "port", port, "enabled", enabled));
|
protocol, "port", port, "enabled", enabled, "ns", ns));
|
||||||
payload = Utils.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"),
|
payload = Utils.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"),
|
||||||
description == null ? "" : String.format("\n <Description>%s</Description>",
|
description == null ? "" : String.format("\n <Description>%s</Description>",
|
||||||
description));
|
description));
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.util.Utils.replaceTokens;
|
import static org.jclouds.util.Utils.replaceTokens;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -48,6 +49,9 @@ public class BindAddNodeServiceToXmlPayload implements MapBinder {
|
||||||
private String xmlTemplate;
|
private String xmlTemplate;
|
||||||
@Inject
|
@Inject
|
||||||
private BindToStringPayload stringBinder;
|
private BindToStringPayload stringBinder;
|
||||||
|
@Inject
|
||||||
|
@Named(PROPERTY_TERREMARK_EXTENSION_NS)
|
||||||
|
private String ns;
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
String ipAddress = checkNotNull(postParams.get("ipAddress"),
|
String ipAddress = checkNotNull(postParams.get("ipAddress"),
|
||||||
|
@ -58,7 +62,7 @@ public class BindAddNodeServiceToXmlPayload implements MapBinder {
|
||||||
String description = postParams.get("description");
|
String description = postParams.get("description");
|
||||||
|
|
||||||
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name, "ipAddress",
|
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name, "ipAddress",
|
||||||
ipAddress, "port", port, "enabled", enabled));
|
ipAddress, "port", port, "enabled", enabled, "ns", ns));
|
||||||
payload = Utils.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"),
|
payload = Utils.replaceAll(payload, Patterns.TOKEN_TO_PATTERN.get("description"),
|
||||||
description == null ? "" : String.format("\n <Description>%s</Description>",
|
description == null ? "" : String.format("\n <Description>%s</Description>",
|
||||||
description));
|
description));
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static org.jclouds.util.Utils.replaceTokens;
|
import static org.jclouds.util.Utils.replaceTokens;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -41,20 +42,25 @@ import com.google.common.collect.ImmutableMap;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindCreateKeyToXmlPayload implements MapBinder {
|
public class BindCreateKeyToXmlPayload implements MapBinder {
|
||||||
|
|
||||||
|
private final String xmlTemplate;
|
||||||
|
private final BindToStringPayload stringBinder;
|
||||||
|
private final String ns;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("CreateKey")
|
BindCreateKeyToXmlPayload(@Named(PROPERTY_TERREMARK_EXTENSION_NS) String ns,
|
||||||
private String xmlTemplate;
|
@Named("CreateKey") String xmlTemplate, BindToStringPayload stringBinder) {
|
||||||
@Inject
|
this.ns = ns;
|
||||||
private BindToStringPayload stringBinder;
|
this.xmlTemplate = xmlTemplate;
|
||||||
|
this.stringBinder = stringBinder;
|
||||||
|
}
|
||||||
|
|
||||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
String name = checkNotNull(postParams.get("name"),
|
String name = checkNotNull(postParams.get("name"), "name parameter not present");
|
||||||
"name parameter not present");
|
|
||||||
String isDefault = checkNotNull(postParams.get("isDefault"),
|
String isDefault = checkNotNull(postParams.get("isDefault"),
|
||||||
"isDefault parameter not present");
|
"isDefault parameter not present");
|
||||||
|
|
||||||
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name,
|
String payload = replaceTokens(xmlTemplate, ImmutableMap.of("name", name, "isDefault",
|
||||||
"isDefault", isDefault));
|
isDefault, "ns", ns));
|
||||||
stringBinder.bindToRequest(request, payload);
|
stringBinder.bindToRequest(request, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,9 +20,12 @@ package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.xml.parsers.FactoryConfigurationError;
|
import javax.xml.parsers.FactoryConfigurationError;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
@ -42,6 +45,13 @@ import com.jamesmurty.utils.XMLBuilder;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindNodeConfigurationToXmlPayload extends BindToStringPayload {
|
public class BindNodeConfigurationToXmlPayload extends BindToStringPayload {
|
||||||
|
|
||||||
|
private final String ns;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BindNodeConfigurationToXmlPayload(@Named(PROPERTY_TERREMARK_EXTENSION_NS) String ns) {
|
||||||
|
this.ns = ns;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindToRequest(HttpRequest request, Object input) {
|
public void bindToRequest(HttpRequest request, Object input) {
|
||||||
NodeConfiguration nodeConfiguration = (NodeConfiguration) checkNotNull(input,
|
NodeConfiguration nodeConfiguration = (NodeConfiguration) checkNotNull(input,
|
||||||
|
@ -63,9 +73,9 @@ public class BindNodeConfigurationToXmlPayload extends BindToStringPayload {
|
||||||
|
|
||||||
protected String generateXml(NodeConfiguration nodeConfiguration)
|
protected String generateXml(NodeConfiguration nodeConfiguration)
|
||||||
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
throws ParserConfigurationException, FactoryConfigurationError, TransformerException {
|
||||||
XMLBuilder rootBuilder = XMLBuilder.create("NodeService").a("xmlns",
|
XMLBuilder rootBuilder = XMLBuilder.create("NodeService").a("xmlns", ns).a("xmlns:xsi",
|
||||||
"urn:tmrk:vCloudExpressExtensions-1.6").a("xmlns:i",
|
"http://www.w3.org/2001/XMLSchema-instance").a("xmlns:xsd",
|
||||||
"http://www.w3.org/2001/XMLSchema-instance");
|
"http://www.w3.org/2001/XMLSchema");
|
||||||
if (nodeConfiguration.getDescription() != null)
|
if (nodeConfiguration.getDescription() != null)
|
||||||
rootBuilder.e("Description").t(nodeConfiguration.getDescription());
|
rootBuilder.e("Description").t(nodeConfiguration.getDescription());
|
||||||
if (nodeConfiguration.getName() != null)
|
if (nodeConfiguration.getName() != null)
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule;
|
||||||
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
import org.jclouds.vcloud.compute.strategy.VCloudDestroyNodeStrategy;
|
||||||
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
|
import org.jclouds.vcloud.compute.strategy.VCloudListNodesStrategy;
|
||||||
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
|
import org.jclouds.vcloud.compute.strategy.VCloudRebootNodeStrategy;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkClient;
|
||||||
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient;
|
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeClient;
|
||||||
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeService;
|
import org.jclouds.vcloud.terremark.compute.TerremarkVCloudComputeService;
|
||||||
import org.jclouds.vcloud.terremark.compute.config.providers.QueryCatalogForVAppTemplatesAndConvertToImagesProvider;
|
import org.jclouds.vcloud.terremark.compute.config.providers.QueryCatalogForVAppTemplatesAndConvertToImagesProvider;
|
||||||
|
@ -96,13 +96,13 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class TerremarkVCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
public static class TerremarkVCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
||||||
protected final TerremarkVCloudClient client;
|
protected final TerremarkClient client;
|
||||||
protected final TerremarkVCloudComputeClient computeClient;
|
protected final TerremarkVCloudComputeClient computeClient;
|
||||||
protected final GetNodeMetadataStrategy getNode;
|
protected final GetNodeMetadataStrategy getNode;
|
||||||
protected final TemplateToInstantiateOptions getOptions;
|
protected final TemplateToInstantiateOptions getOptions;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected TerremarkVCloudAddNodeWithTagStrategy(TerremarkVCloudClient client,
|
protected TerremarkVCloudAddNodeWithTagStrategy(TerremarkClient client,
|
||||||
TerremarkVCloudComputeClient computeClient, GetNodeMetadataStrategy getNode,
|
TerremarkVCloudComputeClient computeClient, GetNodeMetadataStrategy getNode,
|
||||||
TemplateToInstantiateOptions getOptions) {
|
TemplateToInstantiateOptions getOptions) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark.config;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkAsyncClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkECloudAsyncClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkECloudClient;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequiresHttp
|
||||||
|
@ConfiguresRestClient
|
||||||
|
public class TerremarkECloudRestClientModule extends
|
||||||
|
TerremarkRestClientModule<TerremarkECloudClient, TerremarkECloudAsyncClient> {
|
||||||
|
|
||||||
|
public TerremarkECloudRestClientModule() {
|
||||||
|
super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected VCloudAsyncClient provideVCloudAsyncClient(TerremarkECloudAsyncClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected VCloudClient provideVCloudClient(TerremarkECloudClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected TerremarkAsyncClient provideTerremarkAsyncClient(TerremarkECloudAsyncClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected TerremarkClient provideTerremarkClient(TerremarkECloudClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.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.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
|
import org.jclouds.http.annotation.ClientError;
|
||||||
|
import org.jclouds.http.annotation.Redirection;
|
||||||
|
import org.jclouds.http.annotation.ServerError;
|
||||||
|
import org.jclouds.util.Utils;
|
||||||
|
import org.jclouds.vcloud.config.BaseVCloudRestClientModule;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkAsyncClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkClient;
|
||||||
|
import org.jclouds.vcloud.terremark.handlers.ParseTerremarkVCloudErrorFromHttpResponse;
|
||||||
|
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
public abstract class TerremarkRestClientModule<S extends TerremarkClient, A extends TerremarkAsyncClient>
|
||||||
|
extends BaseVCloudRestClientModule<S, A> {
|
||||||
|
|
||||||
|
public TerremarkRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||||
|
super(syncClientType, asyncClientType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@Named("CreateInternetService")
|
||||||
|
String provideCreateInternetService() throws IOException {
|
||||||
|
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateInternetService.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
@Named("CreateNodeService")
|
||||||
|
String provideCreateNodeService() throws IOException {
|
||||||
|
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||||
|
"/terremark/CreateNodeService.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindErrorHandlers() {
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||||
|
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||||
|
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||||
|
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -24,36 +24,30 @@ import java.net.URI;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.http.HttpErrorHandler;
|
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
|
||||||
import org.jclouds.http.annotation.Redirection;
|
|
||||||
import org.jclouds.http.annotation.ServerError;
|
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.jclouds.vcloud.VCloudAsyncClient;
|
import org.jclouds.vcloud.VCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.config.BaseVCloudRestClientModule;
|
|
||||||
import org.jclouds.vcloud.domain.Organization;
|
import org.jclouds.vcloud.domain.Organization;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkAsyncClient;
|
||||||
|
import org.jclouds.vcloud.terremark.TerremarkClient;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
|
||||||
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
||||||
import org.jclouds.vcloud.terremark.endpoints.KeysList;
|
import org.jclouds.vcloud.terremark.endpoints.KeysList;
|
||||||
import org.jclouds.vcloud.terremark.handlers.ParseTerremarkVCloudErrorFromHttpResponse;
|
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the VCloud authentication service connection, including logging
|
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||||
* and http transport.
|
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@RequiresHttp
|
@RequiresHttp
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
public class TerremarkVCloudRestClientModule
|
public class TerremarkVCloudRestClientModule extends
|
||||||
extends
|
TerremarkRestClientModule<TerremarkVCloudClient, TerremarkVCloudAsyncClient> {
|
||||||
BaseVCloudRestClientModule<TerremarkVCloudClient, TerremarkVCloudAsyncClient> {
|
|
||||||
|
|
||||||
public TerremarkVCloudRestClientModule() {
|
public TerremarkVCloudRestClientModule() {
|
||||||
super(TerremarkVCloudClient.class, TerremarkVCloudAsyncClient.class);
|
super(TerremarkVCloudClient.class, TerremarkVCloudAsyncClient.class);
|
||||||
|
@ -61,8 +55,7 @@ public class TerremarkVCloudRestClientModule
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected VCloudAsyncClient provideVCloudAsyncClient(
|
protected VCloudAsyncClient provideVCloudAsyncClient(TerremarkVCloudAsyncClient in) {
|
||||||
TerremarkVCloudAsyncClient in) {
|
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +65,18 @@ public class TerremarkVCloudRestClientModule
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected TerremarkAsyncClient provideTerremarkAsyncClient(TerremarkVCloudAsyncClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected TerremarkClient provideTerremarkClient(TerremarkVCloudClient in) {
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@KeysList
|
@KeysList
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -79,38 +84,11 @@ public class TerremarkVCloudRestClientModule
|
||||||
return TerremarkOrganization.class.cast(org).getKeysList().getLocation();
|
return TerremarkOrganization.class.cast(org).getKeysList().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
@Named("CreateInternetService")
|
|
||||||
String provideCreateInternetService() throws IOException {
|
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
|
||||||
"/terremark/CreateInternetService.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
@Named("CreateNodeService")
|
|
||||||
String provideCreateNodeService() throws IOException {
|
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
|
||||||
"/terremark/CreateNodeService.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Provides
|
@Provides
|
||||||
@Named("CreateKey")
|
@Named("CreateKey")
|
||||||
String provideCreateKey() throws IOException {
|
String provideCreateKey() throws IOException {
|
||||||
return Utils.toStringAndClose(getClass().getResourceAsStream(
|
return Utils.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateKey.xml"));
|
||||||
"/terremark/CreateKey.xml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void bindErrorHandlers() {
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
|
||||||
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
|
||||||
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
|
||||||
ParseTerremarkVCloudErrorFromHttpResponse.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.jclouds.vcloud.terremark.reference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration properties and constants used in Terremark connections.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public interface TerremarkConstants {
|
||||||
|
public static final String PROPERTY_TERREMARK_EXTENSION_NAME = "jclouds.terremark.extension.name";
|
||||||
|
public static final String PROPERTY_TERREMARK_EXTENSION_VERSION = "jclouds.terremark.extension.version";
|
||||||
|
public static final String PROPERTY_TERREMARK_EXTENSION_NS = "jclouds.terremark.extension.ns";
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<InternetService xmlns="urn:tmrk:vCloudExpress-1.0"
|
<InternetService xmlns="{ns}"
|
||||||
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<Id>{id}</Id>{options}
|
<Id>{id}</Id>{options}
|
||||||
</InternetService>
|
</InternetService>
|
|
@ -1,6 +1,6 @@
|
||||||
<CreateInternetServiceRequest
|
<CreateInternetServiceRequest
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns="urn:tmrk:vCloudExpressExtensions-1.6">
|
xmlns="{ns}">
|
||||||
<Name>{name}</Name>
|
<Name>{name}</Name>
|
||||||
<Protocol>{protocol}</Protocol>
|
<Protocol>{protocol}</Protocol>
|
||||||
<Port>{port}</Port>
|
<Port>{port}</Port>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<CreateKeyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<CreateKeyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpressExtensions-1.6">
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="{ns}">
|
||||||
<Name>{name}</Name>
|
<Name>{name}</Name>
|
||||||
<IsDefault>{isDefault}</IsDefault>
|
<IsDefault>{isDefault}</IsDefault>
|
||||||
</CreateKeyRequest>
|
</CreateKeyRequest>
|
|
@ -1,5 +1,5 @@
|
||||||
<CreateNodeServiceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<CreateNodeServiceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpressExtensions-1.6">
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="{ns}">
|
||||||
<IpAddress>{ipAddress}</IpAddress>
|
<IpAddress>{ipAddress}</IpAddress>
|
||||||
<Name>{name}</Name>
|
<Name>{name}</Name>
|
||||||
<Port>{port}</Port>
|
<Port>{port}</Port>
|
||||||
|
|
|
@ -18,12 +18,16 @@ public class ProvidersInPropertiesTest {
|
||||||
public void testSupportedProviders() {
|
public void testSupportedProviders() {
|
||||||
Iterable<String> providers = Utils.getSupportedProviders();
|
Iterable<String> providers = Utils.getSupportedProviders();
|
||||||
assert Iterables.contains(providers, "terremark") : providers;
|
assert Iterables.contains(providers, "terremark") : providers;
|
||||||
|
assert Iterables.contains(providers, "ecloud") : providers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSupportedComputeServiceProviders() {
|
public void testSupportedComputeServiceProviders() {
|
||||||
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
|
Iterable<String> providers = ComputeServiceUtils.getSupportedProviders();
|
||||||
assert Iterables.contains(providers, "terremark") : providers;
|
assert Iterables.contains(providers, "terremark") : providers;
|
||||||
|
assert Iterables.contains(providers, "ecloud") : providers;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,484 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.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 static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy;
|
||||||
|
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.changeNameTo;
|
||||||
|
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.net.IPSocket;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.predicates.SocketOpen;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.ssh.SshClient;
|
||||||
|
import org.jclouds.ssh.SshException;
|
||||||
|
import org.jclouds.ssh.SshClient.Factory;
|
||||||
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
import org.jclouds.vcloud.VCloudClientLiveTest;
|
||||||
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
|
import org.jclouds.vcloud.domain.Catalog;
|
||||||
|
import org.jclouds.vcloud.domain.CatalogItem;
|
||||||
|
import org.jclouds.vcloud.domain.NamedResource;
|
||||||
|
import org.jclouds.vcloud.domain.ResourceAllocation;
|
||||||
|
import org.jclouds.vcloud.domain.ResourceType;
|
||||||
|
import org.jclouds.vcloud.domain.Task;
|
||||||
|
import org.jclouds.vcloud.domain.VApp;
|
||||||
|
import org.jclouds.vcloud.domain.VAppStatus;
|
||||||
|
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||||
|
import org.jclouds.vcloud.predicates.TaskSuccess;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.InternetService;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Node;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
||||||
|
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
|
||||||
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
||||||
|
|
||||||
|
protected String provider = "terremark";
|
||||||
|
protected String expectedOs = "Ubuntu Linux (32-bit)";
|
||||||
|
protected String itemName = "Ubuntu JeOS 9.10 (32-bit)";
|
||||||
|
|
||||||
|
protected TerremarkClient tmClient;
|
||||||
|
protected Factory sshFactory;
|
||||||
|
private String publicIp;
|
||||||
|
private InternetService is;
|
||||||
|
private Node node;
|
||||||
|
private VApp vApp;
|
||||||
|
private RetryablePredicate<IPSocket> socketTester;
|
||||||
|
private RetryablePredicate<String> successTester;
|
||||||
|
private VApp clone;
|
||||||
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
|
@Test(expectedExceptions = NullPointerException.class)
|
||||||
|
@Override
|
||||||
|
public void testDefaultTasksList() throws Exception {
|
||||||
|
super.testDefaultTasksList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllInternetServices() throws Exception {
|
||||||
|
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.getDefaultVDC()
|
||||||
|
.getId())) {
|
||||||
|
assertNotNull(tmClient.getNodes(service.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
|
||||||
|
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.getDefaultVDC()
|
||||||
|
.getId())) {
|
||||||
|
assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId()));
|
||||||
|
assertNotNull(tmClient.getPublicIp(ip.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetConfigCustomizationOptions() throws Exception {
|
||||||
|
Catalog response = connection.getDefaultCatalog();
|
||||||
|
for (NamedResource resource : response.values()) {
|
||||||
|
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
||||||
|
CatalogItem item = connection.getCatalogItem(resource.getId());
|
||||||
|
assert tmClient.getCustomizationOptionsOfCatalogItem(item.getId()) != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultVDC() throws Exception {
|
||||||
|
super.testDefaultVDC();
|
||||||
|
TerremarkVDC response = (TerremarkVDC) tmClient.getDefaultVDC();
|
||||||
|
assertNotNull(response);
|
||||||
|
assertNotNull(response.getCatalog());
|
||||||
|
assertNotNull(response.getInternetServices());
|
||||||
|
assertNotNull(response.getPublicIps());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true)
|
||||||
|
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException,
|
||||||
|
TimeoutException, IOException {
|
||||||
|
prepare();
|
||||||
|
StringBuffer name = new StringBuffer();
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
name.append("a");
|
||||||
|
String serverName = name.toString();// "adriantest";
|
||||||
|
|
||||||
|
long hardDisk = 4194304;
|
||||||
|
|
||||||
|
// long hardDisk = 4194304 / 4 * 10;
|
||||||
|
// String catalogOs = "CentOS 5.3 (32-bit)";
|
||||||
|
// String expectedOs = "Red Hat Enterprise Linux 5 (32-bit)";
|
||||||
|
|
||||||
|
// lookup the id of the datacenter you are deploying into
|
||||||
|
String vDCId = tmClient.getDefaultVDC().getId();
|
||||||
|
|
||||||
|
// lookup the id of the item in the catalog you wish to deploy by name
|
||||||
|
Catalog catalog = tmClient.getDefaultCatalog();
|
||||||
|
String itemId = catalog.get(itemName).getId();
|
||||||
|
// create an options object to collect the configuration we want.
|
||||||
|
TerremarkInstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions();
|
||||||
|
|
||||||
|
// if this template supports setting the root password, let's add it to
|
||||||
|
// our options
|
||||||
|
CustomizationParameters customizationOptions = tmClient
|
||||||
|
.getCustomizationOptionsOfCatalogItem(itemId);
|
||||||
|
if (customizationOptions.canCustomizePassword())
|
||||||
|
instantiateOptions.withPassword("robotsarefun");
|
||||||
|
|
||||||
|
// the vAppTemplateId tends to be the same as the itemId, but just in
|
||||||
|
// case, convert
|
||||||
|
String vAppTemplateId = tmClient.getCatalogItem(itemId).getEntity().getId();
|
||||||
|
|
||||||
|
// instantiate, noting vApp returned has minimal details
|
||||||
|
vApp = tmClient.instantiateVAppTemplateInVDC(vDCId, serverName, vAppTemplateId,
|
||||||
|
instantiateOptions);
|
||||||
|
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED);
|
||||||
|
|
||||||
|
// in terremark, this should be a no-op, as it should simply return the
|
||||||
|
// above task, which is
|
||||||
|
// already deploying
|
||||||
|
Task deployTask = tmClient.deployVApp(vApp.getId());
|
||||||
|
|
||||||
|
// check to see the result of calling deploy twice
|
||||||
|
deployTask = tmClient.deployVApp(vApp.getId());
|
||||||
|
assertEquals(deployTask.getLocation(), deployTask.getLocation());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED);
|
||||||
|
|
||||||
|
try {// per docs, this is not supported
|
||||||
|
tmClient.cancelTask(deployTask.getId());
|
||||||
|
} catch (HttpResponseException e) {
|
||||||
|
assertEquals(e.getResponse().getStatusCode(), 501);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert successTester.apply(deployTask.getId());
|
||||||
|
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
|
NamedResource vAppResource = tmClient.getDefaultVDC().getResourceEntities().get(serverName);
|
||||||
|
assertEquals(vAppResource.getId(), vApp.getId());
|
||||||
|
|
||||||
|
int processorCount = 1;
|
||||||
|
long memory = 512;
|
||||||
|
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||||
|
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void prepare() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract TerremarkInstantiateVAppTemplateOptions createInstantiateOptions();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddInternetService() throws InterruptedException, ExecutionException,
|
||||||
|
TimeoutException, IOException {
|
||||||
|
is = tmClient.addInternetServiceToVDC(tmClient.getDefaultVDC().getId(), "SSH", Protocol.TCP,
|
||||||
|
22);
|
||||||
|
publicIp = is.getPublicIpAddress().getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
|
||||||
|
public void testCloneVApp() throws IOException {
|
||||||
|
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||||
|
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
|
// lookup the id of the datacenter you are deploying into
|
||||||
|
String vDCId = tmClient.getDefaultVDC().getId();
|
||||||
|
|
||||||
|
String vAppIdToClone = vApp.getId();
|
||||||
|
|
||||||
|
StringBuffer name = new StringBuffer();
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
name.append("b");
|
||||||
|
String newName = name.toString();
|
||||||
|
|
||||||
|
CloneVAppOptions options = deploy().powerOn()
|
||||||
|
.withDescription("The description of " + newName);
|
||||||
|
|
||||||
|
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
|
||||||
|
Task task = tmClient.cloneVAppInVDC(vDCId, vAppIdToClone, newName, options);
|
||||||
|
|
||||||
|
// wait for the task to complete
|
||||||
|
assert successTester.apply(task.getId());
|
||||||
|
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||||
|
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
|
// refresh task to get the new vApp location
|
||||||
|
task = tmClient.getTask(task.getId());
|
||||||
|
|
||||||
|
clone = tmClient.getVApp(task.getResult().getId());
|
||||||
|
assertEquals(clone.getStatus(), VAppStatus.ON);
|
||||||
|
|
||||||
|
assertEquals(clone.getName(), newName);
|
||||||
|
assertEquals(clone.getNetworkToAddresses().values().size(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
||||||
|
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
|
IOException {
|
||||||
|
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()),
|
||||||
|
vApp.getName() + "-SSH", 22);
|
||||||
|
loopAndCheckPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loopAndCheckPass() throws IOException {
|
||||||
|
for (int i = 0; i < 5; i++) {// retry loop TODO replace with predicate.
|
||||||
|
try {
|
||||||
|
doCheckPass(publicIp);
|
||||||
|
return;
|
||||||
|
} catch (SshException e) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(10 * 1000);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||||
|
public void testConfigureNode() throws InterruptedException, ExecutionException,
|
||||||
|
TimeoutException, IOException {
|
||||||
|
node = tmClient.configureNode(node.getId(), new NodeConfiguration()
|
||||||
|
.changeDescriptionTo("holy cow"));
|
||||||
|
assertEquals(node.getDescription(), "holy cow");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||||
|
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
|
IOException {
|
||||||
|
|
||||||
|
try {// per docs, this is not supported
|
||||||
|
tmClient.undeployVApp(vApp.getId());
|
||||||
|
} catch (HttpResponseException e) {
|
||||||
|
assertEquals(e.getResponse().getStatusCode(), 501);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {// per docs, this is not supported
|
||||||
|
tmClient.suspendVApp(vApp.getId());
|
||||||
|
} catch (HttpResponseException e) {
|
||||||
|
assertEquals(e.getResponse().getStatusCode(), 501);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.resetVApp(vApp.getId()).getId());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
|
||||||
|
// TODO we need to determine whether shutdown is supported before invoking
|
||||||
|
// it.
|
||||||
|
// tmClient.shutdownVApp(vApp.getId());
|
||||||
|
// vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
|
||||||
|
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
|
IOException {
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
|
||||||
|
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536)
|
||||||
|
.changeProcessorCountTo(1).addDisk(25 * 1048576).addDisk(25 * 1048576));
|
||||||
|
|
||||||
|
assert successTester.apply(task.getId());
|
||||||
|
|
||||||
|
vApp = tmClient.getVApp(vApp.getId());
|
||||||
|
assertEquals(vApp.getName(), "eduardo");
|
||||||
|
assertEquals(
|
||||||
|
Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||||
|
.getVirtualQuantity(), 1);
|
||||||
|
assertEquals(Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
||||||
|
1536);
|
||||||
|
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE).size(), 3);
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||||
|
|
||||||
|
loopAndCheckPass();
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||||
|
|
||||||
|
// extract the disks on the vApp sorted by addressOnParent
|
||||||
|
List<ResourceAllocation> disks = Lists.newArrayList(vApp.getResourceAllocationByType().get(
|
||||||
|
ResourceType.DISK_DRIVE));
|
||||||
|
|
||||||
|
// delete the second disk
|
||||||
|
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1)
|
||||||
|
.getAddressOnParent()));
|
||||||
|
|
||||||
|
assert successTester.apply(task.getId());
|
||||||
|
|
||||||
|
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||||
|
loopAndCheckPass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs,
|
||||||
|
int processorCount, long memory, long hardDisk) {
|
||||||
|
assertEquals(vApp.getName(), serverName);
|
||||||
|
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||||
|
assertEquals(
|
||||||
|
Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||||
|
.getVirtualQuantity(), processorCount);
|
||||||
|
assertEquals(Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
||||||
|
.getVirtualQuantity(), 1);
|
||||||
|
assertEquals(Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
||||||
|
memory);
|
||||||
|
assertEquals(Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||||
|
.getVirtualQuantity(), hardDisk);
|
||||||
|
assertEquals(vApp.getSize().longValue(), Iterables.getOnlyElement(
|
||||||
|
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||||
|
.getVirtualQuantity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doCheckPass(String address) throws IOException {
|
||||||
|
IPSocket socket = new IPSocket(address, 22);
|
||||||
|
|
||||||
|
System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(),
|
||||||
|
socket);
|
||||||
|
assert socketTester.apply(socket);
|
||||||
|
System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), socket);
|
||||||
|
|
||||||
|
SshClient connection = getConnectionFor(socket);
|
||||||
|
try {
|
||||||
|
connection.connect();
|
||||||
|
System.out.printf("%d: %s ssh connection made%n", System.currentTimeMillis(), socket);
|
||||||
|
System.out.println(connection.exec("df -h"));
|
||||||
|
System.out.println(connection.exec("ls -al /dev/sd*"));
|
||||||
|
System.out.println(connection.exec("echo '$Ep455l0ud!2'|sudo -S fdisk -l"));
|
||||||
|
} finally {
|
||||||
|
if (connection != null)
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract SshClient getConnectionFor(IPSocket socket);
|
||||||
|
|
||||||
|
@AfterTest
|
||||||
|
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
if (node != null)
|
||||||
|
tmClient.deleteNode(node.getId());
|
||||||
|
if (is != null)
|
||||||
|
tmClient.deleteInternetService(is.getId());
|
||||||
|
if (vApp != null) {
|
||||||
|
try {
|
||||||
|
successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
tmClient.deleteVApp(vApp.getId());
|
||||||
|
}
|
||||||
|
if (clone != null) {
|
||||||
|
try {
|
||||||
|
successTester.apply(tmClient.powerOffVApp(clone.getId()).getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
tmClient.deleteVApp(clone.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
@Override
|
||||||
|
public void setupClient() {
|
||||||
|
String identity = checkNotNull(System.getProperty("jclouds.test.identity"),
|
||||||
|
"jclouds.test.identity");
|
||||||
|
String credential = checkNotNull(System.getProperty("jclouds.test.credential"),
|
||||||
|
"jclouds.test.credential");
|
||||||
|
|
||||||
|
String endpoint = System.getProperty("jclouds.test.endpoint");
|
||||||
|
Properties props = new Properties();
|
||||||
|
if (endpoint != null && !"".equals(endpoint))
|
||||||
|
props.setProperty("terremark.endpoint", endpoint);
|
||||||
|
Injector injector = new RestContextFactory()
|
||||||
|
.createContextBuilder(
|
||||||
|
provider,
|
||||||
|
identity,
|
||||||
|
credential,
|
||||||
|
ImmutableSet.<Module> of(new Log4JLoggingModule(),
|
||||||
|
new JschSshClientModule()), props).buildInjector();
|
||||||
|
|
||||||
|
connection = tmClient = injector.getInstance(TerremarkClient.class);
|
||||||
|
|
||||||
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
|
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 130,
|
||||||
|
10, TimeUnit.SECONDS);// make
|
||||||
|
// it
|
||||||
|
// longer
|
||||||
|
// then
|
||||||
|
// default internet
|
||||||
|
// service timeout
|
||||||
|
successTester = new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), 650,
|
||||||
|
10, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
|
||||||
|
import org.jclouds.net.IPSocket;
|
||||||
|
import org.jclouds.ssh.SshClient;
|
||||||
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code TerremarkVCloudClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkECloudClientLiveTest")
|
||||||
|
public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest {
|
||||||
|
@BeforeClass
|
||||||
|
void setProvider() {
|
||||||
|
this.provider = "ecloud";
|
||||||
|
this.itemName = "Ubuntu 8.04 LTS (x86)";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
TerremarkInstantiateVAppTemplateOptions createInstantiateOptions() {
|
||||||
|
return processorCount(1).memory(512);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SshClient getConnectionFor(IPSocket socket) {
|
||||||
|
return sshFactory.create(socket, "ecloud", "$Ep455l0ud!2");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -64,6 +64,7 @@ import org.jclouds.vcloud.terremark.xml.InternetServicesHandler;
|
||||||
import org.jclouds.vcloud.terremark.xml.KeyPairsHandler;
|
import org.jclouds.vcloud.terremark.xml.KeyPairsHandler;
|
||||||
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.TerremarkVDCHandler;
|
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||||
import org.jclouds.vcloud.xml.VAppHandler;
|
import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
|
@ -175,6 +176,23 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException,
|
||||||
|
IOException {
|
||||||
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("activatePublicIpInVDC",
|
||||||
|
String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "1");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "POST https://vcloud/extensions/1/publicIps HTTP/1.1");
|
||||||
|
assertHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, PublicIpAddressesHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
public void testAddInternetService() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToVDC",
|
Method method = TerremarkVCloudAsyncClient.class.getMethod("addInternetServiceToVDC",
|
||||||
|
@ -382,10 +400,10 @@ public class TerremarkVCloudAsyncClientTest extends RestClientTest<TerremarkVClo
|
||||||
assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1");
|
assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1");
|
||||||
assertHeadersEqual(
|
assertHeadersEqual(
|
||||||
request,
|
request,
|
||||||
"Accept: application/vnd.tmrk.vCloud.nodeService+xml\nContent-Length: 155\nContent-Type: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
"Accept: application/vnd.tmrk.vCloud.nodeService+xml\nContent-Length: 202\nContent-Type: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
||||||
assertPayloadEquals(
|
assertPayloadEquals(
|
||||||
request,
|
request,
|
||||||
"<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Description>eggs</Description></NodeService>");
|
"<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Description>eggs</Description></NodeService>");
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||||
assertExceptionParserClassEquals(method, null);
|
assertExceptionParserClassEquals(method, null);
|
||||||
|
|
|
@ -18,493 +18,72 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark;
|
package org.jclouds.vcloud.terremark;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy;
|
|
||||||
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.changeNameTo;
|
|
||||||
import static org.jclouds.vcloud.terremark.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
|
||||||
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.http.HttpResponseException;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
|
||||||
import org.jclouds.predicates.SocketOpen;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
|
||||||
import org.jclouds.vcloud.VCloudClientLiveTest;
|
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
|
||||||
import org.jclouds.vcloud.domain.CatalogItem;
|
|
||||||
import org.jclouds.vcloud.domain.NamedResource;
|
|
||||||
import org.jclouds.vcloud.domain.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ResourceType;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VApp;
|
|
||||||
import org.jclouds.vcloud.domain.VAppStatus;
|
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.CustomizationParameters;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.InternetService;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
import org.jclouds.vcloud.terremark.domain.KeyPair;
|
||||||
import org.jclouds.vcloud.terremark.domain.Node;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.PublicIpAddress;
|
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
||||||
import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
|
|
||||||
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
import org.jclouds.vcloud.terremark.options.TerremarkInstantiateVAppTemplateOptions;
|
||||||
import org.testng.annotations.AfterTest;
|
import org.testng.annotations.AfterTest;
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code TerremarkVCloudClient}
|
* Tests behavior of {@code TerremarkVCloudClient}
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
@Test(groups = "live", sequential = true, testName = "vcloud.TerremarkVCloudClientLiveTest")
|
||||||
public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
|
public class TerremarkVCloudClientLiveTest extends TerremarkClientLiveTest {
|
||||||
TerremarkVCloudClient tmClient;
|
|
||||||
|
|
||||||
private Factory sshFactory;
|
KeyPair key;
|
||||||
|
|
||||||
private String publicIp;
|
|
||||||
private InternetService is;
|
|
||||||
private Node node;
|
|
||||||
private VApp vApp;
|
|
||||||
|
|
||||||
private RetryablePredicate<IPSocket> socketTester;
|
|
||||||
|
|
||||||
private RetryablePredicate<String> successTester;
|
|
||||||
|
|
||||||
private VApp clone;
|
|
||||||
|
|
||||||
private KeyPair key;
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
|
||||||
|
|
||||||
// task list doesn't have a unique id like in regular vcloud
|
|
||||||
@Test(expectedExceptions = NullPointerException.class)
|
|
||||||
@Override
|
|
||||||
public void testDefaultTasksList() throws Exception {
|
|
||||||
super.testDefaultTasksList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetAllInternetServices() throws Exception {
|
|
||||||
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.getDefaultVDC()
|
|
||||||
.getId())) {
|
|
||||||
assertNotNull(tmClient.getNodes(service.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
|
|
||||||
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.getDefaultVDC()
|
|
||||||
.getId())) {
|
|
||||||
assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId()));
|
|
||||||
assertNotNull(tmClient.getPublicIp(ip.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetConfigCustomizationOptions() throws Exception {
|
|
||||||
Catalog response = connection.getDefaultCatalog();
|
|
||||||
for (NamedResource resource : response.values()) {
|
|
||||||
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
|
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getId());
|
|
||||||
assert tmClient.getCustomizationOptionsOfCatalogItem(item.getId()) != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultVDC() throws Exception {
|
|
||||||
super.testDefaultVDC();
|
|
||||||
TerremarkVDC response = (TerremarkVDC) tmClient.getDefaultVDC();
|
|
||||||
assertNotNull(response);
|
|
||||||
assertNotNull(response.getCatalog());
|
|
||||||
assertNotNull(response.getInternetServices());
|
|
||||||
assertNotNull(response.getPublicIps());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeysList() throws Exception {
|
public void testKeysList() throws Exception {
|
||||||
TerremarkOrganization org = tmClient.getDefaultOrganization();
|
TerremarkVCloudClient tmVCloudClient = TerremarkVCloudClient.class.cast(tmClient);
|
||||||
Set<KeyPair> response = tmClient.listKeyPairs();
|
TerremarkOrganization org = tmVCloudClient.getDefaultOrganization();
|
||||||
|
Set<KeyPair> response = tmVCloudClient.listKeyPairs();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
System.err.println(response);
|
System.err.println(response);
|
||||||
assertEquals(response, tmClient.listKeyPairsInOrg(org.getId()));
|
assertEquals(response, tmVCloudClient.listKeyPairsInOrg(org.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
public void testGenerateKeyPair() throws Exception {
|
protected void prepare() {
|
||||||
TerremarkOrganization org = tmClient.getDefaultOrganization();
|
TerremarkVCloudClient tmVCloudClient = TerremarkVCloudClient.class.cast(tmClient);
|
||||||
key = tmClient.generateKeyPairInOrg(org.getId(), "livetest", false);
|
|
||||||
|
TerremarkOrganization org = tmVCloudClient.getDefaultOrganization();
|
||||||
|
key = tmVCloudClient.generateKeyPairInOrg(org.getId(), "livetest", false);
|
||||||
assertNotNull(key);
|
assertNotNull(key);
|
||||||
System.err.println(key);
|
System.err.println(key);
|
||||||
assertEquals(key.getName(), "livetest");
|
assertEquals(key.getName(), "livetest");
|
||||||
assertNotNull(key.getPrivateKey());
|
assertNotNull(key.getPrivateKey());
|
||||||
assertNotNull(key.getFingerPrint());
|
assertNotNull(key.getFingerPrint());
|
||||||
assertEquals(key.isDefault(), false);
|
assertEquals(key.isDefault(), false);
|
||||||
assertEquals(key.getFingerPrint(), tmClient.getKeyPair(key.getId()).getFingerPrint());
|
assertEquals(key.getFingerPrint(), tmVCloudClient.getKeyPair(key.getId()).getFingerPrint());
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testGenerateKeyPair")
|
|
||||||
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException,
|
|
||||||
TimeoutException, IOException {
|
|
||||||
StringBuffer name = new StringBuffer();
|
|
||||||
for (int i = 0; i < 15; i++)
|
|
||||||
name.append("a");
|
|
||||||
String serverName = name.toString();// "adriantest";
|
|
||||||
|
|
||||||
long hardDisk = 4194304;
|
|
||||||
|
|
||||||
String expectedOs = "Ubuntu Linux (32-bit)";
|
|
||||||
// long hardDisk = 4194304 / 4 * 10;
|
|
||||||
// String catalogOs = "CentOS 5.3 (32-bit)";
|
|
||||||
// String expectedOs = "Red Hat Enterprise Linux 5 (32-bit)";
|
|
||||||
|
|
||||||
// lookup the id of the datacenter you are deploying into
|
|
||||||
String vDCId = tmClient.getDefaultVDC().getId();
|
|
||||||
|
|
||||||
// lookup the id of the item in the catalog you wish to deploy by name
|
|
||||||
Catalog catalog = tmClient.getDefaultCatalog();
|
|
||||||
String itemId = catalog.get("Ubuntu JeOS 9.10 (32-bit)").getId();
|
|
||||||
|
|
||||||
// create an options object to collect the configuration we want.
|
|
||||||
TerremarkInstantiateVAppTemplateOptions instantiateOptions = processorCount(1).memory(512)
|
|
||||||
.sshKeyFingerprint(key.getFingerPrint());
|
|
||||||
|
|
||||||
// if this template supports setting the root password, let's add it to
|
|
||||||
// our options
|
|
||||||
CustomizationParameters customizationOptions = tmClient
|
|
||||||
.getCustomizationOptionsOfCatalogItem(itemId);
|
|
||||||
if (customizationOptions.canCustomizePassword())
|
|
||||||
instantiateOptions.withPassword("robotsarefun");
|
|
||||||
|
|
||||||
// the vAppTemplateId tends to be the same as the itemId, but just in
|
|
||||||
// case, convert
|
|
||||||
String vAppTemplateId = tmClient.getCatalogItem(itemId).getEntity().getId();
|
|
||||||
|
|
||||||
// instantiate, noting vApp returned has minimal details
|
|
||||||
vApp = tmClient.instantiateVAppTemplateInVDC(vDCId, serverName, vAppTemplateId,
|
|
||||||
instantiateOptions);
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED);
|
|
||||||
|
|
||||||
// in terremark, this should be a no-op, as it should simply return the
|
|
||||||
// above task, which is
|
|
||||||
// already deploying
|
|
||||||
Task deployTask = tmClient.deployVApp(vApp.getId());
|
|
||||||
|
|
||||||
// check to see the result of calling deploy twice
|
|
||||||
deployTask = tmClient.deployVApp(vApp.getId());
|
|
||||||
assertEquals(deployTask.getLocation(), deployTask.getLocation());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED);
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
tmClient.cancelTask(deployTask.getId());
|
|
||||||
} catch (HttpResponseException e) {
|
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert successTester.apply(deployTask.getId());
|
|
||||||
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
|
|
||||||
NamedResource vAppResource = tmClient.getDefaultVDC().getResourceEntities().get(serverName);
|
|
||||||
assertEquals(vAppResource.getId(), vApp.getId());
|
|
||||||
|
|
||||||
int processorCount = 1;
|
|
||||||
long memory = 512;
|
|
||||||
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddInternetService() throws InterruptedException, ExecutionException,
|
|
||||||
TimeoutException, IOException {
|
|
||||||
is = tmClient.addInternetServiceToVDC(tmClient.getDefaultVDC().getId(), "SSH", Protocol.TCP,
|
|
||||||
22);
|
|
||||||
publicIp = is.getPublicIpAddress().getAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
|
|
||||||
public void testCloneVApp() throws IOException {
|
|
||||||
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
|
||||||
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
// lookup the id of the datacenter you are deploying into
|
|
||||||
String vDCId = tmClient.getDefaultVDC().getId();
|
|
||||||
|
|
||||||
String vAppIdToClone = vApp.getId();
|
|
||||||
|
|
||||||
StringBuffer name = new StringBuffer();
|
|
||||||
for (int i = 0; i < 15; i++)
|
|
||||||
name.append("b");
|
|
||||||
String newName = name.toString();
|
|
||||||
|
|
||||||
CloneVAppOptions options = deploy().powerOn()
|
|
||||||
.withDescription("The description of " + newName);
|
|
||||||
|
|
||||||
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
|
|
||||||
Task task = tmClient.cloneVAppInVDC(vDCId, vAppIdToClone, newName, options);
|
|
||||||
|
|
||||||
// wait for the task to complete
|
|
||||||
assert successTester.apply(task.getId());
|
|
||||||
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
// refresh task to get the new vApp location
|
|
||||||
task = tmClient.getTask(task.getId());
|
|
||||||
|
|
||||||
clone = tmClient.getVApp(task.getResult().getId());
|
|
||||||
assertEquals(clone.getStatus(), VAppStatus.ON);
|
|
||||||
|
|
||||||
assertEquals(clone.getName(), newName);
|
|
||||||
assertEquals(clone.getNetworkToAddresses().values().size(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
|
||||||
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException,
|
|
||||||
IOException {
|
|
||||||
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()),
|
|
||||||
vApp.getName() + "-SSH", 22);
|
|
||||||
loopAndCheckPass();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loopAndCheckPass() throws IOException {
|
|
||||||
for (int i = 0; i < 5; i++) {// retry loop TODO replace with predicate.
|
|
||||||
try {
|
|
||||||
doCheckPass(publicIp);
|
|
||||||
return;
|
|
||||||
} catch (SshException e) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(10 * 1000);
|
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO this fails
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
|
||||||
public void testConfigureNode() throws InterruptedException, ExecutionException,
|
|
||||||
TimeoutException, IOException {
|
|
||||||
node = tmClient.configureNode(node.getId(), new NodeConfiguration()
|
|
||||||
.changeDescriptionTo("holy cow"));
|
|
||||||
assertEquals(node.getDescription(), "holy cow");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
|
||||||
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException,
|
|
||||||
IOException {
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
tmClient.undeployVApp(vApp.getId());
|
|
||||||
} catch (HttpResponseException e) {
|
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
tmClient.suspendVApp(vApp.getId());
|
|
||||||
} catch (HttpResponseException e) {
|
|
||||||
assertEquals(e.getResponse().getStatusCode(), 501);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.resetVApp(vApp.getId()).getId());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
|
||||||
|
|
||||||
// TODO we need to determine whether shutdown is supported before invoking
|
|
||||||
// it.
|
|
||||||
// tmClient.shutdownVApp(vApp.getId());
|
|
||||||
// vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
|
|
||||||
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException,
|
|
||||||
IOException {
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
|
|
||||||
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536)
|
|
||||||
.changeProcessorCountTo(1).addDisk(25 * 1048576).addDisk(25 * 1048576));
|
|
||||||
|
|
||||||
assert successTester.apply(task.getId());
|
|
||||||
|
|
||||||
vApp = tmClient.getVApp(vApp.getId());
|
|
||||||
assertEquals(vApp.getName(), "eduardo");
|
|
||||||
assertEquals(
|
|
||||||
Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
|
||||||
.getVirtualQuantity(), 1);
|
|
||||||
assertEquals(Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
|
||||||
1536);
|
|
||||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE).size(), 3);
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
|
||||||
|
|
||||||
loopAndCheckPass();
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
|
||||||
|
|
||||||
// extract the disks on the vApp sorted by addressOnParent
|
|
||||||
List<ResourceAllocation> disks = Lists.newArrayList(vApp.getResourceAllocationByType().get(
|
|
||||||
ResourceType.DISK_DRIVE));
|
|
||||||
|
|
||||||
// delete the second disk
|
|
||||||
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1)
|
|
||||||
.getAddressOnParent()));
|
|
||||||
|
|
||||||
assert successTester.apply(task.getId());
|
|
||||||
|
|
||||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
|
||||||
loopAndCheckPass();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs,
|
|
||||||
int processorCount, long memory, long hardDisk) {
|
|
||||||
assertEquals(vApp.getName(), serverName);
|
|
||||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
|
||||||
assertEquals(
|
|
||||||
Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
|
||||||
.getVirtualQuantity(), processorCount);
|
|
||||||
assertEquals(Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
|
||||||
.getVirtualQuantity(), 1);
|
|
||||||
assertEquals(Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
|
||||||
memory);
|
|
||||||
assertEquals(Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
|
||||||
.getVirtualQuantity(), hardDisk);
|
|
||||||
assertEquals(vApp.getSize().longValue(), Iterables.getOnlyElement(
|
|
||||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
|
||||||
.getVirtualQuantity());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doCheckPass(String address) throws IOException {
|
|
||||||
IPSocket socket = new IPSocket(address, 22);
|
|
||||||
|
|
||||||
System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(),
|
|
||||||
socket);
|
|
||||||
assert socketTester.apply(socket);
|
|
||||||
System.out.printf("%d: %s ssh service started%n", System.currentTimeMillis(), socket);
|
|
||||||
|
|
||||||
SshClient connection = sshFactory.create(socket, "vcloud", key.getPrivateKey().getBytes());
|
|
||||||
try {
|
|
||||||
connection.connect();
|
|
||||||
System.out.printf("%d: %s ssh connection made%n", System.currentTimeMillis(), socket);
|
|
||||||
System.out.println(connection.exec("df -h"));
|
|
||||||
System.out.println(connection.exec("ls -al /dev/sd*"));
|
|
||||||
System.out.println(connection.exec("echo '$Ep455l0ud!2'|sudo -S fdisk -l"));
|
|
||||||
} finally {
|
|
||||||
if (connection != null)
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
void cleanup1() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
if (node != null)
|
if (key != null) {
|
||||||
tmClient.deleteNode(node.getId());
|
TerremarkVCloudClient tmVCloudClient = TerremarkVCloudClient.class.cast(tmClient);
|
||||||
if (is != null)
|
tmVCloudClient.deleteKeyPair(key.getId());
|
||||||
tmClient.deleteInternetService(is.getId());
|
|
||||||
if (vApp != null) {
|
|
||||||
try {
|
|
||||||
successTester.apply(tmClient.powerOffVApp(vApp.getId()).getId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
tmClient.deleteVApp(vApp.getId());
|
|
||||||
}
|
}
|
||||||
if (clone != null) {
|
|
||||||
try {
|
|
||||||
successTester.apply(tmClient.powerOffVApp(clone.getId()).getId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
tmClient.deleteVApp(clone.getId());
|
|
||||||
}
|
|
||||||
if (key != null)
|
|
||||||
tmClient.deleteKeyPair(key.getId());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
@Override
|
@Override
|
||||||
public void setupClient() {
|
protected SshClient getConnectionFor(IPSocket socket) {
|
||||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
return sshFactory.create(socket, "vcloud", key.getPrivateKey().getBytes());
|
||||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
|
||||||
|
|
||||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
|
||||||
Properties props = new Properties();
|
|
||||||
if (endpoint != null && !"".equals(endpoint))
|
|
||||||
props.setProperty("terremark.endpoint", endpoint);
|
|
||||||
Injector injector = new RestContextFactory()
|
|
||||||
.createContextBuilder(
|
|
||||||
"terremark",
|
|
||||||
identity,
|
|
||||||
credential,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(),
|
|
||||||
new JschSshClientModule()), props).buildInjector();
|
|
||||||
|
|
||||||
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
|
||||||
|
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
|
||||||
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 130,
|
|
||||||
10, TimeUnit.SECONDS);// make
|
|
||||||
// it
|
|
||||||
// longer
|
|
||||||
// then
|
|
||||||
// default internet
|
|
||||||
// service timeout
|
|
||||||
successTester = new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), 650,
|
|
||||||
10, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TerremarkInstantiateVAppTemplateOptions createInstantiateOptions() {
|
||||||
|
return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark.binders;
|
package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -38,6 +39,7 @@ import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindAddInternetServiceToXmlPayload}
|
* Tests behavior of {@code BindAddInternetServiceToXmlPayload}
|
||||||
|
@ -50,6 +52,8 @@ public class BindAddInternetServiceToXmlPayloadTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
bindConstant().annotatedWith(Names.named(PROPERTY_TERREMARK_EXTENSION_NS)).to(
|
||||||
|
"urn:tmrk:vCloudExpressExtensions-1.6");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.terremark.binders;
|
package org.jclouds.vcloud.terremark.binders;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.terremark.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -38,6 +39,7 @@ import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindAddNodeServiceToXmlPayload}
|
* Tests behavior of {@code BindAddNodeServiceToXmlPayload}
|
||||||
|
@ -50,6 +52,8 @@ public class BindAddNodeServiceToXmlPayloadTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
bindConstant().annotatedWith(Names.named(PROPERTY_TERREMARK_EXTENSION_NS)).to(
|
||||||
|
"urn:tmrk:vCloudExpressExtensions-1.6");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
import org.jclouds.vcloud.terremark.TerremarkVCloudPropertiesBuilder;
|
||||||
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
import org.jclouds.vcloud.terremark.domain.NodeConfiguration;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -53,45 +53,45 @@ public class BindNodeConfigurationToXmlPayloadTest {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(),
|
Names.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(),
|
||||||
"properties"));
|
"properties"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
public void testChangeName() throws IOException {
|
public void testChangeName() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration().changeNameTo("willie");
|
NodeConfiguration config = new NodeConfiguration().changeNameTo("willie");
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChangeDescription() throws IOException {
|
public void testChangeDescription() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration().changeDescriptionTo("description");
|
NodeConfiguration config = new NodeConfiguration().changeDescriptionTo("description");
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Description>description</Description></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Description>description</Description></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnableTraffic() throws IOException {
|
public void testEnableTraffic() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration().enableTraffic();
|
NodeConfiguration config = new NodeConfiguration().enableTraffic();
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Enabled>true</Enabled></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Enabled>true</Enabled></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDisableTraffic() throws IOException {
|
public void testDisableTraffic() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration().disableTraffic();
|
NodeConfiguration config = new NodeConfiguration().disableTraffic();
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Enabled>false</Enabled></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Enabled>false</Enabled></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTwoOptions() throws IOException {
|
public void testTwoOptions() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration().disableTraffic().changeNameTo("willie");
|
NodeConfiguration config = new NodeConfiguration().disableTraffic().changeNameTo("willie");
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testNoOptions() throws IOException {
|
public void testNoOptions() throws IOException {
|
||||||
NodeConfiguration config = new NodeConfiguration();
|
NodeConfiguration config = new NodeConfiguration();
|
||||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
|
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
|
||||||
assertConfigMakesPayload(config, expectedPayload);
|
assertConfigMakesPayload(config, expectedPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue