mirror of
https://github.com/apache/jclouds.git
synced 2025-02-17 23:46:13 +00:00
Issue 435: refactored savvis code
This commit is contained in:
parent
bbf6ba525d
commit
81f0707382
@ -25,6 +25,7 @@ import java.text.ParseException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
@ -55,6 +56,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||||||
private VCloudError error;
|
private VCloudError error;
|
||||||
private boolean inOwner;
|
private boolean inOwner;
|
||||||
|
|
||||||
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -157,6 +157,9 @@ cloudstack.propertiesbuilder=org.jclouds.cloudstack.CloudStackPropertiesBuilder
|
|||||||
softlayer.contextbuilder=org.jclouds.softlayer.SoftLayerContextBuilder
|
softlayer.contextbuilder=org.jclouds.softlayer.SoftLayerContextBuilder
|
||||||
softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder
|
softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder
|
||||||
|
|
||||||
|
savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder
|
||||||
|
savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder
|
||||||
|
|
||||||
cloudfiles-us.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder
|
cloudfiles-us.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder
|
||||||
cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPropertiesBuilder
|
cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPropertiesBuilder
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
<relativePath>../../project/pom.xml</relativePath>
|
<relativePath>../../project/pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.jclouds.provider</groupId>
|
<groupId>org.jclouds.provider</groupId>
|
||||||
<artifactId>savvis-symphony-vpdc</artifactId>
|
<artifactId>savvis-symphonyvpdc</artifactId>
|
||||||
<name>jclouds savvis core</name>
|
<name>jclouds savvis-vpdc vpdc</name>
|
||||||
<description>jclouds components to access savvis</description>
|
<description>jclouds components to access Savvis Symphony VPDC</description>
|
||||||
|
|
||||||
<!-- bootstrapping: need to fetch the project POM -->
|
<!-- bootstrapping: need to fetch the project POM -->
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -52,34 +52,20 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- when instances are hung, open a ticket and add here -->
|
<!-- when instances are hung, open a ticket and add here -->
|
||||||
<jclouds.compute.blacklist-nodes>node-924</jclouds.compute.blacklist-nodes>
|
<jclouds.compute.blacklist-nodes>node-924</jclouds.compute.blacklist-nodes>
|
||||||
<test.savvis-symphony-vpdc.endpoint>https://api.sandbox.symphonyVPDC.savvis.net/rest/api</test.savvis-symphony-vpdc.endpoint>
|
<test.savvis-symphonyvpdc.endpoint>https://api.symphonyvpdc.savvis.net/rest/api</test.savvis-symphonyvpdc.endpoint>
|
||||||
<test.savvis-symphony-vpdc.apiversion>0.8</test.savvis-symphony-vpdc.apiversion>
|
<test.savvis-symphonyvpdc.apiversion>0.8</test.savvis-symphonyvpdc.apiversion>
|
||||||
<test.savvis-symphony-vpdc.identity>FIXME</test.savvis-symphony-vpdc.identity>
|
<test.savvis-symphonyvpdc.identity>FIXME</test.savvis-symphonyvpdc.identity>
|
||||||
<test.savvis-symphony-vpdc.credential>FIXME</test.savvis-symphony-vpdc.credential>
|
<test.savvis-symphonyvpdc.credential>FIXME</test.savvis-symphonyvpdc.credential>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.api</groupId>
|
|
||||||
<artifactId>vcloudexpress</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jclouds.api</groupId>
|
|
||||||
<artifactId>vcloudexpress</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-compute</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-vcloud</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
@ -133,20 +119,20 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<systemProperties>
|
<systemProperties>
|
||||||
<property>
|
<property>
|
||||||
<name>test.savvis-symphony-vpdc.endpoint</name>
|
<name>test.savvis-symphonyvpdc.endpoint</name>
|
||||||
<value>${test.savvis-symphony-vpdc.endpoint}</value>
|
<value>${test.savvis-symphonyvpdc.endpoint}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.savvis-symphony-vpdc.apiversion</name>
|
<name>test.savvis-symphonyvpdc.apiversion</name>
|
||||||
<value>${test.savvis-symphony-vpdc.apiversion}</value>
|
<value>${test.savvis-symphonyvpdc.apiversion}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.savvis-symphony-vpdc.identity</name>
|
<name>test.savvis-symphonyvpdc.identity</name>
|
||||||
<value>${test.savvis-symphony-vpdc.identity}</value>
|
<value>${test.savvis-symphonyvpdc.identity}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>test.savvis-symphony-vpdc.credential</name>
|
<name>test.savvis-symphonyvpdc.credential</name>
|
||||||
<value>${test.savvis-symphony-vpdc.credential}</value>
|
<value>${test.savvis-symphonyvpdc.credential}</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>jclouds.compute.blacklist-nodes</name>
|
<name>jclouds.compute.blacklist-nodes</name>
|
||||||
|
@ -1,363 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.POST;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
|
|
||||||
import org.jclouds.predicates.validators.DnsNameValidator;
|
|
||||||
import org.jclouds.rest.annotations.EndpointParam;
|
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
|
||||||
import org.jclouds.rest.annotations.MapBinder;
|
|
||||||
import org.jclouds.rest.annotations.ParamValidators;
|
|
||||||
import org.jclouds.rest.annotations.PayloadParam;
|
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
|
||||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVDCHandler;
|
|
||||||
import org.jclouds.vcloud.CommonVCloudClient;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressClient;
|
|
||||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
|
||||||
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
|
|
||||||
import org.jclouds.vcloud.domain.Catalog;
|
|
||||||
import org.jclouds.vcloud.domain.CatalogItem;
|
|
||||||
import org.jclouds.vcloud.domain.Org;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.TasksList;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
|
|
||||||
import org.jclouds.vcloud.domain.network.OrgNetwork;
|
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameAndCatalogNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameToTasksListEndpoint;
|
|
||||||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
|
||||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
|
||||||
import org.jclouds.vcloud.xml.TaskHandler;
|
|
||||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides access to Symphony VPDC resources via their REST API.
|
|
||||||
* <p/>
|
|
||||||
*
|
|
||||||
* @see <a href="TODO PUBLIC DOC REF" />
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@RequestFilters(SetVCloudTokenCookie.class)
|
|
||||||
public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(OrgHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Org> findOrgNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(OrgHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getVDC(URI)
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(SymphonyVPDCVDCHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends SymphonyVPDCVDC> getVDC(@EndpointParam URI vdc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#findVDCInOrgNamed(String, String)
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(SymphonyVPDCVDCHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends SymphonyVPDCVDC> findVDCInOrgNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#findNetworkInOrgVDCNamed
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(SymphonyVPDCNetworkHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
|
||||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getNetwork
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(SymphonyVPDCNetworkHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudClient#getVApp
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(SymphonyVPDCVAppHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VCloudExpressVApp> getVApp(@EndpointParam URI vApp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudClient#getVAppTemplate
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(VCloudExpressVAppTemplateHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VCloudExpressVAppTemplate> getVAppTemplate(@EndpointParam URI vAppTemplate);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudClient#findVAppTemplateInOrgCatalogNamed
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(VCloudExpressVAppTemplateHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VCloudExpressVAppTemplate> findVAppTemplateInOrgCatalogNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String catalogName,
|
|
||||||
@EndpointParam(parser = OrgNameCatalogNameVAppTemplateNameToEndpoint.class) String itemName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudExpressClient#instantiateVAppTemplateInVDC
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Path("/action/instantiateVAppTemplate")
|
|
||||||
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(VCloudExpressVAppHandler.class)
|
|
||||||
@MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VCloudExpressVApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc,
|
|
||||||
@PayloadParam("template") URI template,
|
|
||||||
@PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
|
|
||||||
InstantiateVAppTemplateOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudExpressClient#cloneVAppInVDC
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
@Path("/action/cloneVApp")
|
|
||||||
@Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone,
|
|
||||||
@PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, CloneVAppOptions... options);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see VCloudClient#findVAppInOrgVDCNamed
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(VCloudExpressVAppHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends VCloudExpressVApp> findVAppInOrgVDCNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
|
|
||||||
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String vAppName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#deployVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/action/deploy")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#undeployVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/action/undeploy")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#powerOnVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/power/action/powerOn")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#powerOffVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/power/action/powerOff")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#resetVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/power/action/reset")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#suspendVApp
|
|
||||||
*/
|
|
||||||
@POST
|
|
||||||
// no accept header
|
|
||||||
@Path("/power/action/suspend")
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getCatalog
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@XMLResponseParser(CatalogHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
// no accept header
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Catalog> getCatalog(@EndpointParam URI catalogId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#findCatalogInOrgNamed
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@XMLResponseParser(CatalogHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
// no accept header
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Catalog> findCatalogInOrgNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameAndCatalogNameToEndpoint.class) String catalogName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getCatalogItem
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(CatalogItemHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends CatalogItem> getCatalogItem(@EndpointParam URI catalogItem);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getCatalogItemInOrg
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(CatalogItemHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends CatalogItem> findCatalogItemInOrgCatalogNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String orgName,
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String catalogName,
|
|
||||||
@EndpointParam(parser = OrgNameCatalogNameItemNameToEndpoint.class) String itemName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getTasksList
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(TasksListHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends TasksList> getTasksList(@EndpointParam URI tasksListId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#findTasksListInOrgNamed
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(TasksListHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends TasksList> findTasksListInOrgNamed(
|
|
||||||
@Nullable @EndpointParam(parser = OrgNameToTasksListEndpoint.class) String orgName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CommonVCloudClient#getTask
|
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
// no accept header
|
|
||||||
@XMLResponseParser(TaskHandler.class)
|
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
||||||
@Override
|
|
||||||
ListenableFuture<? extends Task> getTask(@EndpointParam URI taskId);
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
|
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to VPDC via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see VPDCClient
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/index.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public interface VPDCAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides asynchronous access to Browsing features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
BrowsingAsyncClient getBrowsingClient();
|
||||||
|
|
||||||
|
}
|
@ -19,25 +19,27 @@
|
|||||||
|
|
||||||
package org.jclouds.savvis.vpdc;
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.vcloud.VCloudExpressClient;
|
import org.jclouds.savvis.vpdc.features.BrowsingClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to Symphony VPDC resources via their REST API.
|
* Provides synchronous access to VPDC.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @see <a href="TODO PUBLIC DOC REF" />
|
* @see VPDCAsyncClient
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/index.html" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface SymphonyVPDCClient extends VCloudExpressClient {
|
public interface VPDCClient {
|
||||||
@Override
|
|
||||||
SymphonyVPDCVDC findVDCInOrgNamed(String orgName, String vdcName);
|
/**
|
||||||
|
* Provides synchronous access to Browsing features.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
BrowsingClient getBrowsingClient();
|
||||||
|
|
||||||
@Override
|
|
||||||
SymphonyVPDCVDC getVDC(URI vdc);
|
|
||||||
}
|
}
|
@ -23,8 +23,7 @@ import java.util.List;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||||
import org.jclouds.savvis.vpdc.compute.config.SymphonyVPDCComputeServiceContextModule;
|
import org.jclouds.savvis.vpdc.config.VPDCRestClientModule;
|
||||||
import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule;
|
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
@ -32,20 +31,14 @@ import com.google.inject.Module;
|
|||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SymphonyVPDCContextBuilder extends
|
public class VPDCContextBuilder extends ComputeServiceContextBuilder<VPDCClient, VPDCAsyncClient> {
|
||||||
ComputeServiceContextBuilder<SymphonyVPDCClient, SymphonyVPDCAsyncClient> {
|
|
||||||
|
|
||||||
public SymphonyVPDCContextBuilder(Properties props) {
|
public VPDCContextBuilder(Properties props) {
|
||||||
super(SymphonyVPDCClient.class, SymphonyVPDCAsyncClient.class, props);
|
super(VPDCClient.class, VPDCAsyncClient.class, props);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addContextModule(List<Module> modules) {
|
|
||||||
modules.add(new SymphonyVPDCComputeServiceContextModule());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addClientModule(List<Module> modules) {
|
protected void addClientModule(List<Module> modules) {
|
||||||
modules.add(new SymphonyVPDCRestClientModule());
|
modules.add(new VPDCRestClientModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -21,26 +21,28 @@ package org.jclouds.savvis.vpdc;
|
|||||||
|
|
||||||
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.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.vcloud.VCloudExpressPropertiesBuilder;
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in Symphony VPDC Clients
|
* Builds properties used in Symphony VPDC Clients
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SymphonyVPDCPropertiesBuilder extends VCloudExpressPropertiesBuilder {
|
public class VPDCPropertiesBuilder extends PropertiesBuilder {
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "0.8");
|
properties.setProperty(PROPERTY_API_VERSION, "0.8");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "https://api.sandbox.symphonyVPDC.savvis.net/rest/api");
|
properties.setProperty(PROPERTY_ENDPOINT, "https://api.symphonyvpdc.savvis.net/rest/api");
|
||||||
|
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 600l * 1000l + "");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SymphonyVPDCPropertiesBuilder(Properties properties) {
|
public VPDCPropertiesBuilder(Properties properties) {
|
||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.compute.config;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.compute.config.BaseComputeServiceContextModule;
|
||||||
|
import org.jclouds.compute.domain.NodeState;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VApp;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VPDCComputeServiceContextModule extends BaseComputeServiceContextModule {
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static final Map<VApp.Status, NodeState> VAPPSTATUS_TO_NODESTATE = ImmutableMap
|
||||||
|
.<VApp.Status, NodeState> builder().put(VApp.Status.OFF, NodeState.SUSPENDED)
|
||||||
|
.put(VApp.Status.ON, NodeState.RUNNING).put(VApp.Status.RESOLVED, NodeState.PENDING)
|
||||||
|
.put(VApp.Status.UNRECOGNIZED, NodeState.UNRECOGNIZED).put(VApp.Status.UNKNOWN, NodeState.UNRECOGNIZED)
|
||||||
|
.put(VApp.Status.SUSPENDED, NodeState.SUSPENDED).put(VApp.Status.UNRESOLVED, NodeState.PENDING).build();
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Provides
|
||||||
|
protected Map<VApp.Status, NodeState> provideVAppStatusToNodeState() {
|
||||||
|
return VAPPSTATUS_TO_NODESTATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,83 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.config;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
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.savvis.vpdc.SymphonyVPDCAsyncClient;
|
|
||||||
import org.jclouds.savvis.vpdc.SymphonyVPDCClient;
|
|
||||||
import org.jclouds.savvis.vpdc.handlers.SymphonyVPDCErrorHandler;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressAsyncClient;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressClient;
|
|
||||||
import org.jclouds.vcloud.config.BaseVCloudExpressRestClientModule;
|
|
||||||
import org.jclouds.vcloud.domain.Org;
|
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
|
|
||||||
public class SymphonyVPDCRestClientModule extends
|
|
||||||
BaseVCloudExpressRestClientModule<SymphonyVPDCClient, SymphonyVPDCAsyncClient> {
|
|
||||||
|
|
||||||
public SymphonyVPDCRestClientModule() {
|
|
||||||
super(SymphonyVPDCClient.class, SymphonyVPDCAsyncClient.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
protected VCloudExpressAsyncClient provideVCloudAsyncClient(SymphonyVPDCAsyncClient in) {
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
protected VCloudExpressClient provideVCloudClient(SymphonyVPDCClient in) {
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideDefaultTasksList(Org org) {
|
|
||||||
if(org.getTasksList() != null){
|
|
||||||
return org.getTasksList().getHref();
|
|
||||||
}else{
|
|
||||||
return URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
super.configure();
|
|
||||||
// no longer needed.. just here to show an example of how to override an xml handler
|
|
||||||
// bind(OrgListHandler.class).to(SymphonyVPDCOrgListHandler.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void bindErrorHandlers() {
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(SymphonyVPDCErrorHandler.class);
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(SymphonyVPDCErrorHandler.class);
|
|
||||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(SymphonyVPDCErrorHandler.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,143 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.config;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.common.base.Throwables.propagate;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
import static org.jclouds.savvis.vpdc.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
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.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.rest.AsyncClientFactory;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
|
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCClient;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
|
||||||
|
import org.jclouds.savvis.vpdc.features.BrowsingAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.features.BrowsingClient;
|
||||||
|
import org.jclouds.savvis.vpdc.handlers.VPDCErrorHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.internal.LoginAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.internal.VCloudToken;
|
||||||
|
import org.jclouds.savvis.vpdc.predicates.TaskSuccess;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsyncClient> {
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected LoginAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
|
||||||
|
return factory.create(LoginAsyncClient.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VCloudToken
|
||||||
|
@Provides
|
||||||
|
String provideVCloudToken(Supplier<VCloudSession> cache) {
|
||||||
|
return checkNotNull(cache.get().getVCloudToken(), "No token present in session");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@org.jclouds.savvis.vpdc.internal.Org
|
||||||
|
@Singleton
|
||||||
|
protected Iterable<org.jclouds.savvis.vpdc.domain.Resource> provideOrgs(Supplier<VCloudSession> cache,
|
||||||
|
@Named(PROPERTY_IDENTITY) String user) {
|
||||||
|
VCloudSession discovery = cache.get();
|
||||||
|
checkState(discovery.getOrgs().size() > 0, "No orgs present for user: " + user);
|
||||||
|
return discovery.getOrgs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@org.jclouds.savvis.vpdc.internal.Org
|
||||||
|
@Singleton
|
||||||
|
protected String provideDefaultOrgId(@org.jclouds.savvis.vpdc.internal.Org Iterable<Resource> orgs) {
|
||||||
|
return Iterables.get(orgs, 0).getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AtomicReference<AuthorizationException> authException = new AtomicReference<AuthorizationException>();
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Predicate<String> successTester(Injector injector,
|
||||||
|
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long completed) {
|
||||||
|
return new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), completed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||||
|
.put(BrowsingClient.class, BrowsingAsyncClient.class)//
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public VPDCRestClientModule() {
|
||||||
|
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
|
final LoginAsyncClient login) {
|
||||||
|
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
|
||||||
|
new Supplier<VCloudSession>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VCloudSession get() {
|
||||||
|
try {
|
||||||
|
return login.login().get(10, TimeUnit.SECONDS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
propagate(e);
|
||||||
|
assert false : e;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindErrorHandlers() {
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(VPDCErrorHandler.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(VPDCErrorHandler.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(VPDCErrorHandler.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of a Rest resource
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Link extends Resource {
|
||||||
|
protected final String rel;
|
||||||
|
|
||||||
|
public Link( String id,String name, String type, URI href, String rel) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.rel = rel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRel() {
|
||||||
|
return rel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Link that) {
|
||||||
|
return (this == that) ? 0 : getHref().compareTo(that.getHref());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + ((rel == null) ? 0 : rel.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Link other = (Link) obj;
|
||||||
|
if (rel == null) {
|
||||||
|
if (other.rel != null)
|
||||||
|
return false;
|
||||||
|
} else if (!rel.equals(other.rel))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", rel=" + rel + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,147 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Various network features such NAT Public IP, Gateway and Netmask.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Network extends Resource {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends Resource.Builder {
|
||||||
|
private String gateway;
|
||||||
|
private String netmask;
|
||||||
|
private Map<String, String> internalToExternalNATRules = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
|
public Builder gateway(String gateway) {
|
||||||
|
this.gateway = gateway;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder netmask(String netmask) {
|
||||||
|
this.netmask = netmask;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder internalToExternalNATRule(String internalIP, String externalIP) {
|
||||||
|
this.internalToExternalNATRules.put(checkNotNull(internalIP, "internalIP"),
|
||||||
|
checkNotNull(externalIP, "externalIP"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder internalToExternalNATRules(Map<String, String> internalToExternalNATRules) {
|
||||||
|
this.internalToExternalNATRules.putAll(checkNotNull(internalToExternalNATRules, "internalToExternalNATRules"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Network build() {
|
||||||
|
return new Network(id, name, type, href, gateway, netmask, internalToExternalNATRules);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromOrg(Network in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
|
||||||
|
.gateway(in.getGateway()).internalToExternalNATRules(in.getInternalToExternalNATRules())
|
||||||
|
.netmask(in.getNetmask());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
return Builder.class.cast(super.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
return Builder.class.cast(super.type(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
return Builder.class.cast(super.href(href));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final String gateway;
|
||||||
|
private final String netmask;
|
||||||
|
private final Map<String, String> internalToExternalNATRules;
|
||||||
|
|
||||||
|
public Network(String id, String name, String type, URI href, @Nullable String gateway, String netmask,
|
||||||
|
Map<String, String> internalToExternalNATRules) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.gateway = gateway;
|
||||||
|
this.netmask = netmask;
|
||||||
|
this.internalToExternalNATRules = ImmutableMap.copyOf(checkNotNull(internalToExternalNATRules,
|
||||||
|
"internalToExternalNATRules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IP of the network's gateway
|
||||||
|
*/
|
||||||
|
public String getGateway() {
|
||||||
|
return gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return IP of the network's netmask
|
||||||
|
*/
|
||||||
|
public String getNetmask() {
|
||||||
|
return netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return map of internal to external ip when it has any nat1to1 enabled deployed VApp
|
||||||
|
*/
|
||||||
|
public Map<String, String> getInternalToExternalNATRules() {
|
||||||
|
return internalToExternalNATRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromOrg(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", gateway=" + gateway
|
||||||
|
+ ", netmask=" + netmask + ", internalToExternalNATRules=" + internalToExternalNATRules + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,168 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A cloud can contain one or more Organizations. There are two types of Organizations, hard-walled
|
||||||
|
* and soft-walled.
|
||||||
|
* <ul>
|
||||||
|
* <li>A hard-walled Organization provides a secure environment for a single tenant of a
|
||||||
|
* multi-tenant cloud.All resources in a hard-walled Organization are isolated from other
|
||||||
|
* Organizations, hard- or soft-walled,in the cloud.</li>
|
||||||
|
* <li>A soft-walled Organization supports access, by users who have appropriate privileges, to
|
||||||
|
* other soft-walled Organizations in a cloud. Soft-walled Organizations have boundaries similar to
|
||||||
|
* those that separate departments of a corporate entity. In such environments, the Organization
|
||||||
|
* controls the resources owned by a single department. Most users are restricted to the resources
|
||||||
|
* available in a single Organization but a few might have privileges in other Organizations, if
|
||||||
|
* allowed by the administrators of those Organizations.</li>
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Org extends Resource {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends Resource.Builder {
|
||||||
|
private String description;
|
||||||
|
private Set<Link> vDCs = Sets.newLinkedHashSet();
|
||||||
|
private Set<Link> images = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder vDC(Link vDC) {
|
||||||
|
this.vDCs.add(checkNotNull(vDC, "vDC"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder vDCs(Set<Link> vDCs) {
|
||||||
|
this.vDCs.addAll(checkNotNull(vDCs, "vDCs"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder image(Link image) {
|
||||||
|
this.images.add(checkNotNull(image, "image"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder images(Set<Link> images) {
|
||||||
|
this.images.addAll(checkNotNull(images, "images"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Org build() {
|
||||||
|
return new Org(id, name, type, href, description, vDCs, images);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromOrg(Org in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
|
||||||
|
.description(in.getDescription()).images(in.getImages()).vDCs(in.getVDCs());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
return Builder.class.cast(super.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
return Builder.class.cast(super.type(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
return Builder.class.cast(super.href(href));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final String description;
|
||||||
|
private final Set<Link> vDCs;
|
||||||
|
private final Set<Link> images;
|
||||||
|
|
||||||
|
public Org(String id, String name, String type, URI href, @Nullable String description, Set<Link> vDCs,
|
||||||
|
Set<Link> images) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.description = description;
|
||||||
|
this.vDCs = ImmutableSet.copyOf(checkNotNull(vDCs, "vDCs"));
|
||||||
|
this.images = ImmutableSet.copyOf(checkNotNull(images, "images"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<Link> getVDCs() {
|
||||||
|
return vDCs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<Link> getImages() {
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromOrg(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", description=" + description
|
||||||
|
+ ", vDCs=" + vDCs + ", images=" + images + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Location of a Rest resource
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Resource {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
protected String id;
|
||||||
|
protected String name;
|
||||||
|
protected String type;
|
||||||
|
protected URI href;
|
||||||
|
|
||||||
|
public Builder id(String id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder type(String type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder href(URI href) {
|
||||||
|
this.href = href;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource build() {
|
||||||
|
return new Resource(id, name, type, href);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromResource(Resource in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final String id;
|
||||||
|
protected final String name;
|
||||||
|
protected final String type;
|
||||||
|
protected final URI href;
|
||||||
|
|
||||||
|
public Resource(String id, String name, String type, URI href) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
this.href = href;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getHref() {
|
||||||
|
return href;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Resource that) {
|
||||||
|
return (this == that) ? 0 : getHref().compareTo(that.getHref());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||||
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Resource other = (Resource) obj;
|
||||||
|
if (href == null) {
|
||||||
|
if (other.href != null)
|
||||||
|
return false;
|
||||||
|
} else if (!href.equals(other.href))
|
||||||
|
return false;
|
||||||
|
if (id == null) {
|
||||||
|
if (other.id != null)
|
||||||
|
return false;
|
||||||
|
} else if (!id.equals(other.id))
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (type == null) {
|
||||||
|
if (other.type != null)
|
||||||
|
return false;
|
||||||
|
} else if (!type.equals(other.type))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromResource(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + "]";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,279 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ResourceAllocation {
|
||||||
|
public enum Type {
|
||||||
|
/**
|
||||||
|
* 3 GHz equals 1 vCPU
|
||||||
|
* <p/>
|
||||||
|
* 1.5 Ghz equals 0.5 vCPU
|
||||||
|
*/
|
||||||
|
PROCESSOR,
|
||||||
|
/**
|
||||||
|
* Gigabytes
|
||||||
|
*/
|
||||||
|
MEMORY, ETHERNET_ADAPTER,
|
||||||
|
/**
|
||||||
|
* Gigabytes
|
||||||
|
*/
|
||||||
|
BOOT_DISK,
|
||||||
|
/**
|
||||||
|
* Gigabytes
|
||||||
|
*/
|
||||||
|
DATA_DISK, UNRECOGNIZED;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
switch (this) {
|
||||||
|
case PROCESSOR:
|
||||||
|
return "3";
|
||||||
|
case MEMORY:
|
||||||
|
return "4";
|
||||||
|
case ETHERNET_ADAPTER:
|
||||||
|
return "10";
|
||||||
|
case BOOT_DISK:
|
||||||
|
return "27";
|
||||||
|
case DATA_DISK:
|
||||||
|
return "26";
|
||||||
|
default:
|
||||||
|
return "UNRECOGNIZED";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type fromValue(String type) {
|
||||||
|
try {
|
||||||
|
return fromValue(Integer.parseInt(checkNotNull(type, "type")));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type fromValue(int v) {
|
||||||
|
switch (v) {
|
||||||
|
case 3:
|
||||||
|
return PROCESSOR;
|
||||||
|
case 4:
|
||||||
|
return MEMORY;
|
||||||
|
case 10:
|
||||||
|
return ETHERNET_ADAPTER;
|
||||||
|
case 27:
|
||||||
|
return BOOT_DISK;
|
||||||
|
case 26:
|
||||||
|
return DATA_DISK;
|
||||||
|
default:
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
protected int id;
|
||||||
|
protected Type type;
|
||||||
|
protected String name;
|
||||||
|
protected String description;
|
||||||
|
protected String allocationUnits;
|
||||||
|
protected long virtualQuantity;
|
||||||
|
protected String connection;
|
||||||
|
protected String caption;
|
||||||
|
protected String hostResource;
|
||||||
|
|
||||||
|
public Builder id(int id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder connection(String connection) {
|
||||||
|
this.connection = connection;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder caption(String caption) {
|
||||||
|
this.caption = caption;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder hostResource(String hostResource) {
|
||||||
|
this.hostResource = hostResource;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder allocationUnits(String allocationUnits) {
|
||||||
|
this.allocationUnits = allocationUnits;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder type(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder virtualQuantity(long virtualQuantity) {
|
||||||
|
this.virtualQuantity = virtualQuantity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceAllocation build() {
|
||||||
|
return new ResourceAllocation(id, type, name, description, allocationUnits, virtualQuantity, connection,
|
||||||
|
caption, hostResource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromResourceAllocation(ResourceAllocation in) {
|
||||||
|
return new Builder().id(in.getId()).type(in.getType()).name(in.getName()).description(in.getDescription())
|
||||||
|
.allocationUnits(in.getAllocationUnits()).virtualQuantity(in.getVirtualQuantity())
|
||||||
|
.connection(in.getConnection()).caption(in.getCaption()).hostResource(in.getHostResource());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final int id;
|
||||||
|
protected final Type type;
|
||||||
|
protected final String name;
|
||||||
|
protected final String description;
|
||||||
|
protected final String allocationUnits;
|
||||||
|
protected final long virtualQuantity;
|
||||||
|
protected final String connection;
|
||||||
|
protected final String caption;
|
||||||
|
protected final String hostResource;
|
||||||
|
|
||||||
|
public ResourceAllocation(int id, Type type, String name, String description, String allocationUnits,
|
||||||
|
long virtualQuantity, String connection, String caption, String hostResource) {
|
||||||
|
this.id = id;
|
||||||
|
this.type = checkNotNull(type, "type");
|
||||||
|
this.name = checkNotNull(name, "name");
|
||||||
|
this.description = description;
|
||||||
|
this.allocationUnits = allocationUnits;
|
||||||
|
this.virtualQuantity = virtualQuantity;
|
||||||
|
this.connection = connection;
|
||||||
|
this.caption = caption;
|
||||||
|
this.hostResource = hostResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllocationUnits() {
|
||||||
|
return allocationUnits;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCaption() {
|
||||||
|
return caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVirtualQuantity() {
|
||||||
|
return virtualQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostResource() {
|
||||||
|
return hostResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((allocationUnits == null) ? 0 : allocationUnits.hashCode());
|
||||||
|
result = prime * result + ((caption == null) ? 0 : caption.hashCode());
|
||||||
|
result = prime * result + ((connection == null) ? 0 : connection.hashCode());
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((hostResource == null) ? 0 : hostResource.hashCode());
|
||||||
|
result = prime * result + id;
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||||
|
result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
ResourceAllocation other = (ResourceAllocation) obj;
|
||||||
|
if (allocationUnits == null) {
|
||||||
|
if (other.allocationUnits != null)
|
||||||
|
return false;
|
||||||
|
} else if (!allocationUnits.equals(other.allocationUnits))
|
||||||
|
return false;
|
||||||
|
if (caption == null) {
|
||||||
|
if (other.caption != null)
|
||||||
|
return false;
|
||||||
|
} else if (!caption.equals(other.caption))
|
||||||
|
return false;
|
||||||
|
if (connection == null) {
|
||||||
|
if (other.connection != null)
|
||||||
|
return false;
|
||||||
|
} else if (!connection.equals(other.connection))
|
||||||
|
return false;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (hostResource == null) {
|
||||||
|
if (other.hostResource != null)
|
||||||
|
return false;
|
||||||
|
} else if (!hostResource.equals(other.hostResource))
|
||||||
|
return false;
|
||||||
|
if (id != other.id)
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
if (type != other.type)
|
||||||
|
return false;
|
||||||
|
if (virtualQuantity != other.virtualQuantity)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromResourceAllocation(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", type=" + type + ", name=" + name + ", description=" + description + ", allocationUnits="
|
||||||
|
+ allocationUnits + ", virtualQuantity=" + virtualQuantity + ", connection=" + connection + ", caption="
|
||||||
|
+ caption + ", hostResource=" + hostResource + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,85 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.domain;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
|
||||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* A network that is available in a vDC.
|
|
||||||
*
|
|
||||||
* @author Kedar Dave
|
|
||||||
*/
|
|
||||||
public interface SymphonyVPDCNetwork extends ReferenceType {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Description of the network
|
|
||||||
*/
|
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return IP addresses of the network’s DNS servers.
|
|
||||||
*/
|
|
||||||
Set<String> getDnsServers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return The IP address of the network’s primary gateway
|
|
||||||
*/
|
|
||||||
String getGateway();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* *
|
|
||||||
*
|
|
||||||
* @return the network’s subnet mask
|
|
||||||
*/
|
|
||||||
String getNetmask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return the network’s fence modes.
|
|
||||||
*/
|
|
||||||
Set<FenceMode> getFenceModes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return True if the network provides DHCP services
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
Boolean isDhcp();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return Network Address Translation rules for the network
|
|
||||||
*/
|
|
||||||
Set<PortForwardingRule> getNatRules();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Firewall rules for the network
|
|
||||||
*/
|
|
||||||
Set<FirewallRule> getFirewallRules();
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,214 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of a client request cannot be returned immediately, the server creates a task entity
|
||||||
|
* and returns its URL to the client. The client can use this URL in a subsequent GET request to
|
||||||
|
* obtain the current status of the task.
|
||||||
|
*
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/getTask.html" />
|
||||||
|
*/
|
||||||
|
public class Task extends Resource {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends Resource.Builder {
|
||||||
|
private Status status;
|
||||||
|
private Date startTime;
|
||||||
|
private Date endTime;
|
||||||
|
private Resource owner;
|
||||||
|
private Resource result;
|
||||||
|
private TaskError error;
|
||||||
|
|
||||||
|
public Builder status(Status status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder startTime(Date startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder endTime(Date endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder owner(Resource owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder result(Resource result) {
|
||||||
|
this.result = result;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder error(TaskError error) {
|
||||||
|
this.error = error;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
return Builder.class.cast(super.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
return Builder.class.cast(super.type(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
return Builder.class.cast(super.href(href));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Task build() {
|
||||||
|
return new Task(id, name, type, href, status, startTime, endTime, owner, result, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromTask(Task in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
|
||||||
|
.status(in.getStatus()).startTime(in.getStartTime()).endTime(in.getEndTime()).owner(in.getOwner())
|
||||||
|
.error(in.getError()).result(in.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
/**
|
||||||
|
* Savvis VPDC successfully provisioned and available for use.
|
||||||
|
*/
|
||||||
|
SUCCESS,
|
||||||
|
/**
|
||||||
|
* Savvis VPDC is processing the user request, please wait for the provisioning process to
|
||||||
|
* complete.
|
||||||
|
*/
|
||||||
|
RUNNING,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Savvis VPDC is processing the user request, please wait for the provisioning process to
|
||||||
|
* complete.
|
||||||
|
*/
|
||||||
|
QUEUED,
|
||||||
|
/**
|
||||||
|
* Savvis VPDC is failed, please kindly contact Savvis administrator for further
|
||||||
|
* clarification/assistance with the respective request data.
|
||||||
|
*/
|
||||||
|
ERROR,
|
||||||
|
/**
|
||||||
|
* Unexpected Savvus VPDC Status, Savvis VPDC is failed, please kindly contact Savvis
|
||||||
|
* administrator for further clarification/assistance with the respective request data.
|
||||||
|
*/
|
||||||
|
NONE, UNRECOGNIZED;
|
||||||
|
public String value() {
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status fromValue(String status) {
|
||||||
|
try {
|
||||||
|
return valueOf(checkNotNull(status, "status").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Status status;
|
||||||
|
private final Date startTime;
|
||||||
|
private final Date endTime;
|
||||||
|
private final Resource owner;
|
||||||
|
private final Resource result;
|
||||||
|
private final TaskError error;
|
||||||
|
|
||||||
|
public Task(String id, String name, String type, URI href, Status status, Date startTime, Date endTime,
|
||||||
|
Resource result, Resource owner, TaskError error) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.status = status;
|
||||||
|
this.startTime = startTime;
|
||||||
|
this.endTime = endTime;
|
||||||
|
this.owner = owner;
|
||||||
|
this.result = result;
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current status of the task.
|
||||||
|
*/
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* date and time when the task was started.
|
||||||
|
*/
|
||||||
|
public Date getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* date and time when the task completed. Does not appear for running tasks.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Date getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to the object that owns the task. For copy operations, the owner is the copy that is
|
||||||
|
* being created. For delete operations, the owner is the deleted object, so this element is not
|
||||||
|
* included. For all other operations, the owner is the object to which the request was made.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Resource getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result is represent outcome of request url. if any VM related operation, the result will
|
||||||
|
* present as get VApp. if any VMDK related operation, the result will present as get VMKD
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Resource getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* error message or related information returned by the task
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public TaskError getError() {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromTask(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[status=" + status + ", startTime=" + startTime + ", endTime=" + endTime + ", owner=" + owner
|
||||||
|
+ ", result=" + result + ", error=" + error + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,136 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TaskError {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
private int majorErrorCode = -1;
|
||||||
|
private int minorErrorCode = -1;
|
||||||
|
private String vendorSpecificErrorCode;
|
||||||
|
|
||||||
|
public Builder message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder majorErrorCode(int majorErrorCode) {
|
||||||
|
this.majorErrorCode = majorErrorCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder minorErrorCode(int minorErrorCode) {
|
||||||
|
this.minorErrorCode = minorErrorCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder vendorSpecificErrorCode(String vendorSpecificErrorCode) {
|
||||||
|
this.vendorSpecificErrorCode = vendorSpecificErrorCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskError build() {
|
||||||
|
return new TaskError(message, majorErrorCode, minorErrorCode, vendorSpecificErrorCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
private final int majorErrorCode;
|
||||||
|
private final int minorErrorCode;
|
||||||
|
private final String vendorSpecificErrorCode;
|
||||||
|
|
||||||
|
public TaskError(String message, int majorErrorCode, int minorErrorCode, @Nullable String vendorSpecificErrorCode) {
|
||||||
|
this.message = message;
|
||||||
|
this.majorErrorCode = majorErrorCode;
|
||||||
|
this.minorErrorCode = minorErrorCode;
|
||||||
|
this.vendorSpecificErrorCode = vendorSpecificErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return message describing the error
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return matches the HTTP status code
|
||||||
|
*/
|
||||||
|
public int getMajorErrorCode() {
|
||||||
|
return majorErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return matches the minor code, typically -1
|
||||||
|
*/
|
||||||
|
public int getMinorErrorCode() {
|
||||||
|
return minorErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return optional additional information about the source of the error
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getVendorSpecificErrorCode() {
|
||||||
|
return vendorSpecificErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + majorErrorCode;
|
||||||
|
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
||||||
|
result = prime * result + minorErrorCode;
|
||||||
|
result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
TaskError other = (TaskError) obj;
|
||||||
|
if (majorErrorCode != other.majorErrorCode)
|
||||||
|
return false;
|
||||||
|
if (message == null) {
|
||||||
|
if (other.message != null)
|
||||||
|
return false;
|
||||||
|
} else if (!message.equals(other.message))
|
||||||
|
return false;
|
||||||
|
if (minorErrorCode != other.minorErrorCode)
|
||||||
|
return false;
|
||||||
|
if (vendorSpecificErrorCode == null) {
|
||||||
|
if (other.vendorSpecificErrorCode != null)
|
||||||
|
return false;
|
||||||
|
} else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[message=" + message + ", majorErrorCode=" + majorErrorCode + ", minorErrorCode=" + minorErrorCode
|
||||||
|
+ ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,251 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A virtual application (vApp) is a software solution, packaged in OVF containing one or more
|
||||||
|
* virtual machines. A vApp can be authored by Developers at ISVs and VARs or by IT Administrators
|
||||||
|
* in Enterprises and Service Providers.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VApp extends Resource {
|
||||||
|
/**
|
||||||
|
* Objects such as vAppTemplate, vApp, and Vm have a status attribute whose value indicates the
|
||||||
|
* state of the object. Status for an object, such as a vAppTemplate or vApp, whose Children (Vm
|
||||||
|
* objects) each have a status of their own, is computed from the status of the Children.
|
||||||
|
*
|
||||||
|
* <h2>NOTE</h2>
|
||||||
|
* <p/>
|
||||||
|
* The deployment status of an object is indicated by the value of its deployed attribute.
|
||||||
|
*
|
||||||
|
* @since vcloud api 0.8
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public enum Status {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the VM is in Designing,Saved,Inqueue, has issue in pre provisioning or any exception
|
||||||
|
* cases. VM is not in Savvis VPDC (may the VM has been removed) or cannot get VM state due to
|
||||||
|
* unknown exception
|
||||||
|
*/
|
||||||
|
UNRESOLVED,
|
||||||
|
/**
|
||||||
|
* When the Savvis VPDC is in Provisioning, PartiallyDeployed, Failed and the VM failed in
|
||||||
|
* provisioning or pending infrastructure notification
|
||||||
|
*/
|
||||||
|
RESOLVED,
|
||||||
|
/**
|
||||||
|
* When the VM is deployed in vmware and powered off.
|
||||||
|
*/
|
||||||
|
OFF,
|
||||||
|
/**
|
||||||
|
* We do not support suspended state.
|
||||||
|
*/
|
||||||
|
SUSPENDED,
|
||||||
|
/**
|
||||||
|
* When the VM is deployed in vmware and powered on.
|
||||||
|
*/
|
||||||
|
ON,
|
||||||
|
/**
|
||||||
|
* The VM is deployed in vmware but the state of VM may be Uninitialized, Start, Stop, Resume,
|
||||||
|
* Reset, RebootGuest, Error, Failed, Unknown, PoweringOn, PoweringOff, Suspending, Stopping,
|
||||||
|
* Starting, Resetting, RebootingGuest. Please call back the Get VApp Power State API after
|
||||||
|
* few minute.
|
||||||
|
*/
|
||||||
|
UNKNOWN, UNRECOGNIZED;
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
switch (this) {
|
||||||
|
case UNRESOLVED:
|
||||||
|
return "0";
|
||||||
|
case RESOLVED:
|
||||||
|
return "1";
|
||||||
|
case OFF:
|
||||||
|
return "2";
|
||||||
|
case SUSPENDED:
|
||||||
|
return "3";
|
||||||
|
case ON:
|
||||||
|
return "4";
|
||||||
|
case UNKNOWN:
|
||||||
|
return "5";
|
||||||
|
default:
|
||||||
|
return "UNRECOGNIZED";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status fromValue(String status) {
|
||||||
|
try {
|
||||||
|
return fromValue(Integer.parseInt(checkNotNull(status, "status")));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status fromValue(int v) {
|
||||||
|
switch (v) {
|
||||||
|
case 0:
|
||||||
|
return UNRESOLVED;
|
||||||
|
case 1:
|
||||||
|
return RESOLVED;
|
||||||
|
case 2:
|
||||||
|
return OFF;
|
||||||
|
case 3:
|
||||||
|
return SUSPENDED;
|
||||||
|
case 4:
|
||||||
|
return ON;
|
||||||
|
case 5:
|
||||||
|
return UNKNOWN;
|
||||||
|
default:
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends Resource.Builder {
|
||||||
|
private Status status;
|
||||||
|
private String ipAddress;
|
||||||
|
private Integer osType;
|
||||||
|
private String osDescripton;
|
||||||
|
private NetworkSection networkSection;
|
||||||
|
private Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Builder ipAddress(String ipAddress) {
|
||||||
|
this.ipAddress = ipAddress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder status(Status status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder osType(Integer osType) {
|
||||||
|
this.osType = osType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder networkSection(NetworkSection networkSection) {
|
||||||
|
this.networkSection = networkSection;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder osDescripton(String osDescripton) {
|
||||||
|
this.osDescripton = osDescripton;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder resourceAllocation(ResourceAllocation in) {
|
||||||
|
this.resourceAllocations.add(checkNotNull(in, "resourceAllocation"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder resourceAllocations(Set<ResourceAllocation> resourceAllocations) {
|
||||||
|
this.resourceAllocations.addAll(checkNotNull(resourceAllocations, "resourceAllocations"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VApp build() {
|
||||||
|
return new VApp(id, name, type, href, status, ipAddress, osType, osDescripton, networkSection,
|
||||||
|
resourceAllocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromVApp(VApp in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
|
||||||
|
.status(in.getStatus()).ipAddress(in.getIpAddress()).osType(in.getOsType())
|
||||||
|
.networkSection(in.getNetworkSection()).resourceAllocations(in.getResourceAllocations())
|
||||||
|
.osDescripton(in.getOsDescripton());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
return Builder.class.cast(super.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
return Builder.class.cast(super.type(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
return Builder.class.cast(super.href(href));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Status status;
|
||||||
|
private final String ipAddress;
|
||||||
|
private final Integer osType;
|
||||||
|
private final String osDescripton;
|
||||||
|
private final NetworkSection networkSection;
|
||||||
|
private final Set<ResourceAllocation> resourceAllocations;
|
||||||
|
|
||||||
|
public VApp(String id, String name, String type, URI href, Status status, String ipAddress, Integer osType,
|
||||||
|
String osDescripton, NetworkSection networkSection, Set<ResourceAllocation> resourceAllocations) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.status = status;
|
||||||
|
this.ipAddress = ipAddress;
|
||||||
|
this.osType = osType;
|
||||||
|
this.osDescripton = osDescripton;
|
||||||
|
this.networkSection = networkSection;
|
||||||
|
this.resourceAllocations = ImmutableSet.copyOf(checkNotNull(resourceAllocations, "resourceAllocations"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIpAddress() {
|
||||||
|
return ipAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOsType() {
|
||||||
|
return osType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOsDescripton() {
|
||||||
|
return osDescripton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkSection getNetworkSection() {
|
||||||
|
return networkSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ResourceAllocation> getResourceAllocations() {
|
||||||
|
return resourceAllocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromVApp(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", status=" + status
|
||||||
|
+ ", ipAddress=" + ipAddress + ", osType=" + osType + ", osDescripton=" + osDescripton
|
||||||
|
+ ", networkSection=" + networkSection + ", resourceAllocations=" + resourceAllocations + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,218 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VDC is a virtual data center ,the API returns a list of VAPPs own by given bill site Id.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VDC extends Resource {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends Resource.Builder {
|
||||||
|
private String description;
|
||||||
|
private Status status;
|
||||||
|
private Set<Resource> resourceEntities = Sets.newLinkedHashSet();
|
||||||
|
private Set<Resource> availableNetworks = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
|
public Builder description(String description) {
|
||||||
|
this.description = description;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder status(Status status) {
|
||||||
|
this.status = status;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder resourceEntity(Resource resourceEntity) {
|
||||||
|
this.resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder resourceEntities(Set<Resource> resourceEntities) {
|
||||||
|
this.resourceEntities.addAll(checkNotNull(resourceEntities, "resourceEntities"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder availableNetwork(Resource availableNetwork) {
|
||||||
|
this.availableNetworks.add(checkNotNull(availableNetwork, "availableNetwork"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder availableNetworks(Set<Resource> availableNetworks) {
|
||||||
|
this.availableNetworks.addAll(checkNotNull(availableNetworks, "availableNetworks"));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VDC build() {
|
||||||
|
return new VDC(id, name, type, href, description, status, resourceEntities, availableNetworks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder fromVDC(VDC in) {
|
||||||
|
return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref())
|
||||||
|
.status(in.getStatus()).description(in.getDescription()).availableNetworks(in.getAvailableNetworks())
|
||||||
|
.resourceEntities(in.getResourceEntities());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder id(String id) {
|
||||||
|
return Builder.class.cast(super.id(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder name(String name) {
|
||||||
|
return Builder.class.cast(super.name(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder type(String type) {
|
||||||
|
return Builder.class.cast(super.type(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder href(URI href) {
|
||||||
|
return Builder.class.cast(super.href(href));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
/**
|
||||||
|
* Savvis VPDC successfully provisioned and available for use
|
||||||
|
*/
|
||||||
|
DEPLOYED,
|
||||||
|
/**
|
||||||
|
* Savvis VPDC need to be provisioned and cannot invoke any of the VCloud (post request method
|
||||||
|
* type) API's
|
||||||
|
*/
|
||||||
|
DESIGNING,
|
||||||
|
/**
|
||||||
|
* Savvis VPDC need to be provisioned and cannot invoke any of the VCloud (post request method
|
||||||
|
* type) API's
|
||||||
|
*/
|
||||||
|
SAVED,
|
||||||
|
/**
|
||||||
|
* Please wait for the provisioning process to complete and cannot invoke any of the VCloud
|
||||||
|
* (post request method type) API's
|
||||||
|
*/
|
||||||
|
INQUEUE,
|
||||||
|
/**
|
||||||
|
* Please wait for the provisioning process to complete and cannot invoke any of the VCloud
|
||||||
|
* (post request method type) API's
|
||||||
|
*/
|
||||||
|
PROVISIONING,
|
||||||
|
/**
|
||||||
|
* Please kindly contact Savvis administrator for further clarification/assistance with the
|
||||||
|
* respective request data. and cannot invoke any of the VCloud (post request method type)
|
||||||
|
* API's
|
||||||
|
*/
|
||||||
|
PARTIALLY_DEPLOYED,
|
||||||
|
/**
|
||||||
|
* Please kindly contact Savvis administrator for further clarification/assistance with the
|
||||||
|
* respective request data and cannot invoke any of the VCloud (post request method type)
|
||||||
|
* API's
|
||||||
|
*/
|
||||||
|
FAILED, UNRECOGNIZED;
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Status fromValue(String status) {
|
||||||
|
try {
|
||||||
|
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final String description;
|
||||||
|
private final VDC.Status status;
|
||||||
|
private final Set<Resource> resourceEntities;
|
||||||
|
private final Set<Resource> availableNetworks;
|
||||||
|
|
||||||
|
public VDC(String id, String name, String type, URI href, @Nullable String description, VDC.Status status,
|
||||||
|
Set<Resource> resourceEntities, Set<Resource> availableNetworks) {
|
||||||
|
super(id, name, type, href);
|
||||||
|
this.description = description;
|
||||||
|
this.status = checkNotNull(status, "status");
|
||||||
|
this.resourceEntities = ImmutableSet.copyOf(checkNotNull(resourceEntities, "resourceEntities"));
|
||||||
|
this.availableNetworks = ImmutableSet.copyOf(checkNotNull(availableNetworks, "availableNetworks"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public VDC.Status getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<Resource> getResourceEntities() {
|
||||||
|
return resourceEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Set<Resource> getAvailableNetworks() {
|
||||||
|
return availableNetworks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return Builder.fromVDC(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + ", description=" + description
|
||||||
|
+ ", status=" + status + ", resourceEntities=" + resourceEntities + ", availableNetworks="
|
||||||
|
+ availableNetworks + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,205 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.domain.internal;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
|
||||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
|
||||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Locations of resources in vCloud
|
|
||||||
*
|
|
||||||
* @author Kedar Dave
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SymphonyVPDCNetworkImpl extends ReferenceTypeImpl implements SymphonyVPDCNetwork {
|
|
||||||
|
|
||||||
/** The serialVersionUID */
|
|
||||||
private static final long serialVersionUID = 8464716396538298809L;
|
|
||||||
protected final String description;
|
|
||||||
protected final Set<String> dnsServers = Sets.newHashSet();
|
|
||||||
protected final String gateway;
|
|
||||||
protected final String netmask;
|
|
||||||
protected final Set<FenceMode> fenceModes = Sets.newHashSet();
|
|
||||||
@Nullable
|
|
||||||
protected final Boolean dhcp;
|
|
||||||
protected final Set<PortForwardingRule> natRules = Sets.newHashSet();
|
|
||||||
protected final Set<FirewallRule> firewallRules = Sets.newHashSet();
|
|
||||||
|
|
||||||
public SymphonyVPDCNetworkImpl(String name, String type, URI id, String description, Set<String> dnsServers,
|
|
||||||
String gateway, String netmask, Set<FenceMode> fenceModes, Boolean dhcp, Set<PortForwardingRule> natRules,
|
|
||||||
Set<FirewallRule> firewallRules) {
|
|
||||||
super(name, type, id);
|
|
||||||
this.description = description;
|
|
||||||
this.dnsServers.addAll(dnsServers);
|
|
||||||
this.gateway = gateway;
|
|
||||||
this.netmask = netmask;
|
|
||||||
this.fenceModes.addAll(fenceModes);
|
|
||||||
this.dhcp = dhcp;
|
|
||||||
this.natRules.addAll(natRules);
|
|
||||||
this.firewallRules.addAll(firewallRules);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Set<String> getDnsServers() {
|
|
||||||
return dnsServers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getGateway() {
|
|
||||||
return gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public String getNetmask() {
|
|
||||||
return netmask;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Set<FenceMode> getFenceModes() {
|
|
||||||
return fenceModes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Boolean isDhcp() {
|
|
||||||
return dhcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Set<PortForwardingRule> getNatRules() {
|
|
||||||
return natRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Set<FirewallRule> getFirewallRules() {
|
|
||||||
return firewallRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(ReferenceType o) {
|
|
||||||
return (this == o) ? 0 : getHref().compareTo(o.getHref());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
|
||||||
result = prime * result + ((dhcp == null) ? 0 : dhcp.hashCode());
|
|
||||||
result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode());
|
|
||||||
result = prime * result + ((fenceModes == null) ? 0 : fenceModes.hashCode());
|
|
||||||
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode());
|
|
||||||
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode());
|
|
||||||
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode());
|
|
||||||
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (!super.equals(obj))
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
SymphonyVPDCNetworkImpl other = (SymphonyVPDCNetworkImpl) obj;
|
|
||||||
if (description == null) {
|
|
||||||
if (other.description != null)
|
|
||||||
return false;
|
|
||||||
} else if (!description.equals(other.description))
|
|
||||||
return false;
|
|
||||||
if (dhcp == null) {
|
|
||||||
if (other.dhcp != null)
|
|
||||||
return false;
|
|
||||||
} else if (!dhcp.equals(other.dhcp))
|
|
||||||
return false;
|
|
||||||
if (dnsServers == null) {
|
|
||||||
if (other.dnsServers != null)
|
|
||||||
return false;
|
|
||||||
} else if (!dnsServers.equals(other.dnsServers))
|
|
||||||
return false;
|
|
||||||
if (fenceModes == null) {
|
|
||||||
if (other.fenceModes != null)
|
|
||||||
return false;
|
|
||||||
} else if (!fenceModes.equals(other.fenceModes))
|
|
||||||
return false;
|
|
||||||
if (firewallRules == null) {
|
|
||||||
if (other.firewallRules != null)
|
|
||||||
return false;
|
|
||||||
} else if (!firewallRules.equals(other.firewallRules))
|
|
||||||
return false;
|
|
||||||
if (gateway == null) {
|
|
||||||
if (other.gateway != null)
|
|
||||||
return false;
|
|
||||||
} else if (!gateway.equals(other.gateway))
|
|
||||||
return false;
|
|
||||||
if (natRules == null) {
|
|
||||||
if (other.natRules != null)
|
|
||||||
return false;
|
|
||||||
} else if (!natRules.equals(other.natRules))
|
|
||||||
return false;
|
|
||||||
if (netmask == null) {
|
|
||||||
if (other.netmask != null)
|
|
||||||
return false;
|
|
||||||
} else if (!netmask.equals(other.netmask))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description
|
|
||||||
+ ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules="
|
|
||||||
+ firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask=" + netmask + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package org.jclouds.savvis.vpdc.domain.internal;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
|
|
||||||
import org.jclouds.vcloud.domain.AllocationModel;
|
|
||||||
import org.jclouds.vcloud.domain.Capacity;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VDCStatus;
|
|
||||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Locations of resources in SymphonyVPDC vDC
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SymphonyVPDCVDCImpl extends VDCImpl implements SymphonyVPDCVDC {
|
|
||||||
private final String offeringTag;
|
|
||||||
|
|
||||||
/** The serialVersionUID */
|
|
||||||
private static final long serialVersionUID = 8464716396538298809L;
|
|
||||||
|
|
||||||
public SymphonyVPDCVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org,
|
|
||||||
@Nullable String description, Iterable<Task> tasks, AllocationModel allocationModel,
|
|
||||||
@Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity,
|
|
||||||
Map<String, ReferenceType> resourceEntities, Map<String, ReferenceType> availableNetworks, int nicQuota,
|
|
||||||
int networkQuota, int vmQuota, boolean isEnabled, String offeringTag) {
|
|
||||||
super(name, type, id, status, org, description, tasks, allocationModel, storageCapacity, cpuCapacity,
|
|
||||||
memoryCapacity, resourceEntities, availableNetworks, nicQuota, networkQuota, vmQuota, isEnabled);
|
|
||||||
this.offeringTag = checkNotNull(offeringTag, "offeringTag");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOfferingTag() {
|
|
||||||
return offeringTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = super.hashCode();
|
|
||||||
result = prime * result + ((offeringTag == null) ? 0 : offeringTag.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (this == obj)
|
|
||||||
return true;
|
|
||||||
if (!super.equals(obj))
|
|
||||||
return false;
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
return false;
|
|
||||||
SymphonyVPDCVDCImpl other = (SymphonyVPDCVDCImpl) obj;
|
|
||||||
if (offeringTag == null) {
|
|
||||||
if (other.offeringTag != null)
|
|
||||||
return false;
|
|
||||||
} else if (!offeringTag.equals(other.offeringTag))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "[id=" + getHref() + ", name=" + getName() + ", description=" + getDescription() + ", offeringTag="
|
|
||||||
+ offeringTag + "]";
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,14 +17,18 @@
|
|||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.compute.config;
|
package org.jclouds.savvis.vpdc.domain.internal;
|
||||||
|
|
||||||
import org.jclouds.vcloud.compute.config.VCloudExpressComputeServiceContextModule;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class SymphonyVPDCComputeServiceContextModule extends VCloudExpressComputeServiceContextModule {
|
public interface VCloudSession {
|
||||||
|
String getVCloudToken();
|
||||||
|
|
||||||
|
Set<Resource> getOrgs();
|
||||||
}
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain.vapp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Network {
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
public Network(String name, String description) {
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||||
|
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Network other = (Network) obj;
|
||||||
|
if (description == null) {
|
||||||
|
if (other.description != null)
|
||||||
|
return false;
|
||||||
|
} else if (!description.equals(other.description))
|
||||||
|
return false;
|
||||||
|
if (name == null) {
|
||||||
|
if (other.name != null)
|
||||||
|
return false;
|
||||||
|
} else if (!name.equals(other.name))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Network [name=" + name + ", description=" + description + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.domain.vapp;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NetworkSection element shall list all logical networks used in the OVF package.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class NetworkSection {
|
||||||
|
private final String info;
|
||||||
|
private final Set<Network> networks;
|
||||||
|
|
||||||
|
public NetworkSection(String info, Iterable<Network> networks) {
|
||||||
|
this.info = info;
|
||||||
|
this.networks = ImmutableSet.<Network> copyOf(networks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All networks referred to from Connection elements in all {@link VirtualHardwareSection}
|
||||||
|
* elements shall be defined in the NetworkSection.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Set<Network> getNetworks() {
|
||||||
|
return networks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((info == null) ? 0 : info.hashCode());
|
||||||
|
result = prime * result + ((networks == null) ? 0 : networks.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
NetworkSection other = (NetworkSection) obj;
|
||||||
|
if (info == null) {
|
||||||
|
if (other.info != null)
|
||||||
|
return false;
|
||||||
|
} else if (!info.equals(other.info))
|
||||||
|
return false;
|
||||||
|
if (networks == null) {
|
||||||
|
if (other.networks != null)
|
||||||
|
return false;
|
||||||
|
} else if (!networks.equals(other.networks))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[info=" + info + ", networks=" + networks + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
import org.jclouds.rest.annotations.ParamParser;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Org;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VApp;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
|
import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.savvis.vpdc.functions.DefaultOrgIfNull;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.NetworkHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.OrgHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.TaskHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.VAppHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.VDCHandler;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Symphony VPDC resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/index.html" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(SetVCloudTokenCookie.class)
|
||||||
|
@Path("v{jclouds.api-version}")
|
||||||
|
public interface BrowsingAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BrowsingClient#getOrg
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(OrgHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Path("org/{billingSiteId}")
|
||||||
|
ListenableFuture<Org> getOrg(
|
||||||
|
@PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BrowsingClient#getVDCInOrg
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(VDCHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Path("org/{billingSiteId}/vdc/{vpdcId}")
|
||||||
|
ListenableFuture<VDC> getVDCInOrg(
|
||||||
|
@PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId,
|
||||||
|
@PathParam("vpdcId") String vpdcId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BrowsingClient#getNetworkInOrgAndVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(NetworkHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Path("org/{billingSiteId}/vdc/{vpdcId}/network/{network-tier-name}")
|
||||||
|
ListenableFuture<Network> getNetworkInOrgAndVDC(
|
||||||
|
@PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId,
|
||||||
|
@PathParam("vpdcId") String vpdcId, @PathParam("network-tier-name") String networkTierName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BrowsingClient#getVAppInOrgAndVDC
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(VAppHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Path("org/{billingSiteId}/vdc/{vpdcId}/vApp/{vAppId}")
|
||||||
|
ListenableFuture<VApp> getVAppInOrgAndVDC(
|
||||||
|
@PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId,
|
||||||
|
@PathParam("vpdcId") String vpdcId, @PathParam("vAppId") String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see BrowsingClient#getTask
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@XMLResponseParser(TaskHandler.class)
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
@Path("task/{taskId}")
|
||||||
|
ListenableFuture<Task> getTask(@PathParam("taskId") String taskId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Org;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VApp;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to Symphony VPDC resources via their REST API.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="https://api.sandbox.symphonyvpdc.savvis.net/doc/spec/api/" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||||
|
public interface BrowsingClient {
|
||||||
|
/**
|
||||||
|
* Get an organization, which can contain list of vDC entities
|
||||||
|
*
|
||||||
|
* @param billingSiteId
|
||||||
|
* billing site Id, or null for default
|
||||||
|
* @return organization, or null if not present
|
||||||
|
*/
|
||||||
|
Org getOrg(@Nullable String billingSiteId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VDC is a virtual data center ,the API returns a list of VAPPs own by given bill site Id.
|
||||||
|
*
|
||||||
|
* @param billingSiteId
|
||||||
|
* billing site Id, or null for default
|
||||||
|
* @param vpdcId
|
||||||
|
* vpdc Id
|
||||||
|
* @return a list of resource entity and VM configurations, or null if not present
|
||||||
|
*/
|
||||||
|
VDC getVDCInOrg(@Nullable String billingSiteId, String vpdcId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Network API returns network detail
|
||||||
|
*
|
||||||
|
* @param billingSiteId
|
||||||
|
* billing site Id, or null for default
|
||||||
|
* @param vpdcId
|
||||||
|
* vpdc Id
|
||||||
|
* @param networkTierName
|
||||||
|
* network tier name
|
||||||
|
*
|
||||||
|
* @return network detail if it used any one deployed VM and NetworkConfigSection defines various
|
||||||
|
* network features such NAT Public IP, Gateway and Netmask, or null if not present
|
||||||
|
*/
|
||||||
|
Network getNetworkInOrgAndVDC(String billingSiteId, String vpdcId, String networkTierName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VAPP is a software solution, the API returns details of virtual machine configuration such as
|
||||||
|
* CPU,RAM Memory and hard drive. The VM State is from the MW Database.
|
||||||
|
*
|
||||||
|
* @param billingSiteId
|
||||||
|
* billing site Id, or null for default
|
||||||
|
* @param vpdcId
|
||||||
|
* vpdc Id
|
||||||
|
* @param vAppId
|
||||||
|
* vApp ID
|
||||||
|
*
|
||||||
|
* @return A virtual application (vApp) is a software solution comprising one or more virtual
|
||||||
|
* machines, all of which are deployed, managed, and maintained as a unit, or null if not
|
||||||
|
* present
|
||||||
|
*/
|
||||||
|
VApp getVAppInOrgAndVDC(String billingSiteId, String vpdcId, String vAppId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an existing task.
|
||||||
|
*
|
||||||
|
* @param taskId
|
||||||
|
* task id
|
||||||
|
* @return If the request is successful, caller could get the VApp/VMDK details as specified in
|
||||||
|
* the result element and if the request is not successful, caller would get empty
|
||||||
|
* VAPP/VMDK URL and respective validation (error) message.
|
||||||
|
*/
|
||||||
|
Task getTask(String taskId);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.filters;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpException;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpRequestFilter;
|
||||||
|
import org.jclouds.http.utils.ModifyRequest;
|
||||||
|
import org.jclouds.savvis.vpdc.internal.VCloudToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the VCloud Token to the request as a cookie
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class SetVCloudTokenCookie implements HttpRequestFilter {
|
||||||
|
private Provider<String> vcloudTokenProvider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SetVCloudTokenCookie(@VCloudToken Provider<String> authTokenProvider) {
|
||||||
|
this.vcloudTokenProvider = authTokenProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpRequest filter(HttpRequest request) throws HttpException {
|
||||||
|
return ModifyRequest.replaceHeader(request, HttpHeaders.COOKIE, "vcloud-token=" + vcloudTokenProvider.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.internal.Org;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class DefaultOrgIfNull implements Function<Object, String> {
|
||||||
|
|
||||||
|
private Provider<String> defaultOrg;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public DefaultOrgIfNull(@Org Provider<String> defaultOrg) {
|
||||||
|
this.defaultOrg = checkNotNull(defaultOrg, "defaultOrg");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String apply(Object from) {
|
||||||
|
return from == null ? defaultOrg.get() : from.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.http.HttpUtils.releasePayload;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.http.HttpResponseException;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
|
||||||
|
import org.jclouds.savvis.vpdc.internal.VCloudToken;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.OrgListHandler;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This parses {@link VCloudSession} from HTTP headers.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
|
||||||
|
static final Pattern pattern = Pattern.compile("vcloud-token=([^;]+);.*");
|
||||||
|
|
||||||
|
private final ParseSax.Factory factory;
|
||||||
|
private final Provider<OrgListHandler> orgHandlerProvider;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ParseLoginResponseFromHeaders(Factory factory,
|
||||||
|
Provider<OrgListHandler> orgHandlerProvider) {
|
||||||
|
this.factory = factory;
|
||||||
|
this.orgHandlerProvider = orgHandlerProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parses the http response headers to create a new {@link VCloudSession} object.
|
||||||
|
*/
|
||||||
|
public VCloudSession apply(HttpResponse from) {
|
||||||
|
String cookieHeader = checkNotNull(from.getFirstHeaderOrNull(HttpHeaders.SET_COOKIE),
|
||||||
|
HttpHeaders.SET_COOKIE);
|
||||||
|
|
||||||
|
final Matcher matcher = pattern.matcher(cookieHeader);
|
||||||
|
boolean matchFound = matcher.find();
|
||||||
|
try {
|
||||||
|
if (matchFound) {
|
||||||
|
final Set<Resource> org = factory.create(orgHandlerProvider.get()).parse(
|
||||||
|
from.getPayload().getInput());
|
||||||
|
|
||||||
|
return new VCloudSession() {
|
||||||
|
@VCloudToken
|
||||||
|
public String getVCloudToken() {
|
||||||
|
return matcher.group(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Resource> getOrgs() {
|
||||||
|
return org;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
releasePayload(from);
|
||||||
|
}
|
||||||
|
throw new HttpResponseException("not found ", null, from);
|
||||||
|
}
|
||||||
|
}
|
@ -42,7 +42,7 @@ import com.google.common.io.Closeables;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SymphonyVPDCErrorHandler implements HttpErrorHandler {
|
public class VPDCErrorHandler implements HttpErrorHandler {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.internal;
|
||||||
|
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
|
||||||
|
import org.jclouds.savvis.vpdc.functions.ParseLoginResponseFromHeaders;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Establishes a context with a VCloud endpoint.
|
||||||
|
* <p/>
|
||||||
|
*
|
||||||
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@RequestFilters(BasicAuthentication.class)
|
||||||
|
public interface LoginAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This request returns a token to use in subsequent requests. After 30 minutes of inactivity,
|
||||||
|
* the token expires and you have to request a new token with this call.
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@ResponseParser(ParseLoginResponseFromHeaders.class)
|
||||||
|
@Path("v{jclouds.api-version}/login")
|
||||||
|
ListenableFuture<VCloudSession> login();
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.internal;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Related to a VCloud Network.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Qualifier
|
||||||
|
public @interface Network {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.internal;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Related to a VCloud express Org.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Qualifier
|
||||||
|
public @interface Org {
|
||||||
|
|
||||||
|
}
|
@ -17,18 +17,24 @@
|
|||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.domain;
|
package org.jclouds.savvis.vpdc.internal;
|
||||||
|
|
||||||
import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCVDCImpl;
|
import java.lang.annotation.ElementType;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import java.lang.annotation.Retention;
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A VCloud Session Token
|
||||||
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(SymphonyVPDCVDCImpl.class)
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
public interface SymphonyVPDCVDC extends VDC {
|
@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||||
String getOfferingTag();
|
@Qualifier
|
||||||
|
public @interface VCloudToken {
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.internal;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Related to a VCloud express Catalog.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||||
|
@Qualifier
|
||||||
|
public @interface VDC {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.predicates;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCClient;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Tests to see if a task succeeds.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class TaskSuccess implements Predicate<String> {
|
||||||
|
|
||||||
|
private final VPDCClient client;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TaskSuccess(VPDCClient client) {
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean apply(String taskId) {
|
||||||
|
logger.trace("looking for status on task %s", taskId);
|
||||||
|
|
||||||
|
Task task = client.getBrowsingClient().getTask(taskId);
|
||||||
|
logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus());
|
||||||
|
if (task.getStatus() == Task.Status.ERROR || task.getStatus() == Task.Status.NONE)
|
||||||
|
throw new RuntimeException("error on task: " + task.getHref() + " error: " + task.getError());
|
||||||
|
return task.getStatus() == Task.Status.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.reference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration properties and constants used in VCloud connections.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public interface VCloudConstants {
|
||||||
|
public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name of the default network, in the default VDC that your vApp will join.
|
||||||
|
*/
|
||||||
|
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
|
||||||
|
public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
|
||||||
|
|
||||||
|
public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
|
||||||
|
public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
|
||||||
|
|
||||||
|
public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,207 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.reference;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resource Types used in VCloud
|
||||||
|
*
|
||||||
|
* @see MediaType
|
||||||
|
*/
|
||||||
|
public interface VCloudMediaType {
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.error+xml"
|
||||||
|
*/
|
||||||
|
public final static String ERROR_XML = "application/vnd.vmware.vcloud.error+xml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.error+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType ERROR_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.error+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vcloud+xml"
|
||||||
|
*/
|
||||||
|
public final static String VCLOUD_XML = "application/vnd.vmware.vcloud.vcloud+xml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vcloud+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VCLOUD_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vcloud+xml");
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.orgList+xml"
|
||||||
|
*/
|
||||||
|
public final static String ORGLIST_XML = "application/vnd.vmware.vcloud.orgList+xml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.orgList+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType ORGLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.orgList+xml");
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.org+xml"
|
||||||
|
*/
|
||||||
|
public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.org+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType ORG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.org+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
*/
|
||||||
|
public final static String VDC_XML = "application/vnd.vmware.vcloud.vdc+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VDC_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vdc+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.catalog+xml"
|
||||||
|
*/
|
||||||
|
public final static String CATALOG_XML = "application/vnd.vmware.vcloud.catalog+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.catalog+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType CATALOG_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.catalog+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.tasksList+xml"
|
||||||
|
*/
|
||||||
|
public final static String TASKSLIST_XML = "application/vnd.vmware.vcloud.tasksList+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.tasksList+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType TASKSLIST_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.tasksList+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.catalogItem+xml"
|
||||||
|
*/
|
||||||
|
public final static String CATALOGITEM_XML = "application/vnd.vmware.vcloud.catalogItem+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.catalogItem+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType CATALOGITEM_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.catalogItem+xml");
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||||
|
*/
|
||||||
|
public final static String NETWORKCONNECTIONSECTION_XML = "application/vnd.vmware.vcloud.networkConnectionSection+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.networkConnectionSection+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType NETWORKCONNECTIONSECTION_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.networkConnectionSection+xml");
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.virtualHardwareSection+xml"
|
||||||
|
*/
|
||||||
|
public final static String VIRTUALHARDWARESECTION_XML = "application/vnd.vmware.vcloud.virtualHardwareSection+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.virtualHardwareSection+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VIRTUALHARDWARESECTION_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.virtualHardwareSection+xml");
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.guestCustomizationSection+xml"
|
||||||
|
*/
|
||||||
|
public final static String GUESTCUSTOMIZATIONSECTION_XML = "application/vnd.vmware.vcloud.guestCustomizationSection+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.guestCustomizationSection+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType GUESTCUSTOMIZATIONSECTION_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.guestCustomizationSection+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.networkSection+xml"
|
||||||
|
*/
|
||||||
|
public final static String NETWORKSECTION_XML = "application/vnd.vmware.vcloud.networkSection+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.networkSection+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType NETWORKSECTION_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.networkSection+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.task+xml"
|
||||||
|
*/
|
||||||
|
public final static String TASK_XML = "application/vnd.vmware.vcloud.task+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.task+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType TASK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.task+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.undeployVAppParams+xml"
|
||||||
|
*/
|
||||||
|
public final static String UNDEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.undeployVAppParams+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.undeployVAppParams+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType UNDEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.undeployVAppParams+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.deployVAppParams+xml"
|
||||||
|
*/
|
||||||
|
public final static String DEPLOYVAPPPARAMS_XML = "application/vnd.vmware.vcloud.deployVAppParams+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.deployVAppParams+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType DEPLOYVAPPPARAMS_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.deployVAppParams+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
*/
|
||||||
|
public final static String VAPP_XML = "application/vnd.vmware.vcloud.vApp+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VAPP_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vApp+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vm+xml"
|
||||||
|
*/
|
||||||
|
public final static String VM_XML = "application/vnd.vmware.vcloud.vm+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vm+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.vm+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vAppTemplate+xml"
|
||||||
|
*/
|
||||||
|
public final static String VAPPTEMPLATE_XML = "application/vnd.vmware.vcloud.vAppTemplate+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.vAppTemplate+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType VAPPTEMPLATE_XML_TYPE = new MediaType("application",
|
||||||
|
"vnd.vmware.vcloud.vAppTemplate+xml");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.network+xml"
|
||||||
|
*/
|
||||||
|
public final static String NETWORK_XML = "application/vnd.vmware.vcloud.network+xml";
|
||||||
|
/**
|
||||||
|
* "application/vnd.vmware.vcloud.network+xml"
|
||||||
|
*/
|
||||||
|
public final static MediaType NETWORK_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.network+xml");
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.util;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Link;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class Utils {
|
||||||
|
|
||||||
|
public static Resource newResource(Map<String, String> attributes, String defaultType) {
|
||||||
|
String uri = attributes.get("href");
|
||||||
|
String type = attributes.get("type");
|
||||||
|
// savvis org has null href
|
||||||
|
String id = null;
|
||||||
|
URI href = null;
|
||||||
|
if (uri != null) {
|
||||||
|
href = URI.create(uri);
|
||||||
|
id = uri.substring(uri.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
return (attributes.containsKey("rel")) ? new Link(id, attributes.get("name"), type != null ? type : defaultType,
|
||||||
|
href, attributes.get("rel")) : new Resource(id, attributes.get("name"), type != null ? type : defaultType,
|
||||||
|
href);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> cleanseAttributes(Attributes in) {
|
||||||
|
Builder<String, String> attrs = ImmutableMap.<String, String> builder();
|
||||||
|
for (int i = 0; i < in.getLength(); i++) {
|
||||||
|
String name = in.getQName(i);
|
||||||
|
if (name.indexOf(':') != -1)
|
||||||
|
name = name.substring(name.indexOf(':') + 1);
|
||||||
|
attrs.put(name, in.getValue(i));
|
||||||
|
}
|
||||||
|
return attrs.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String currentOrNull(StringBuilder currentText) {
|
||||||
|
String returnVal = currentText.toString().trim();
|
||||||
|
return returnVal.equals("") ? null : returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Resource newResource(Map<String, String> attributes) {
|
||||||
|
return newResource(attributes, null);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
|
||||||
|
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected Network.Builder builder = Network.builder();
|
||||||
|
|
||||||
|
public Network getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = Network.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Network")) {
|
||||||
|
// savvis doesn't add href in the header for some reason
|
||||||
|
if (!attributes.containsKey("href") && getRequest() != null)
|
||||||
|
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
|
||||||
|
.put("href", getRequest().getEndpoint().toASCIIString()).build();
|
||||||
|
Resource org = newResource(attributes);
|
||||||
|
builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref());
|
||||||
|
} else if (qName.endsWith("NatRule")) {
|
||||||
|
builder.internalToExternalNATRule(attributes.get("internalIP"), attributes.get("externalIP"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.endsWith("Gateway")) {
|
||||||
|
builder.gateway(currentOrNull(currentText));
|
||||||
|
} else if (qName.endsWith("Netmask")) {
|
||||||
|
builder.netmask(currentOrNull(currentText));
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.vapp.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.vapp.NetworkSection;
|
||||||
|
import org.jclouds.savvis.vpdc.util.Utils;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class NetworkSectionHandler extends ParseSax.HandlerWithResult<NetworkSection> {
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected String info;
|
||||||
|
protected String name;
|
||||||
|
protected String description;
|
||||||
|
|
||||||
|
protected Builder<Network> networks = ImmutableSet.<Network> builder();
|
||||||
|
|
||||||
|
public NetworkSection getResult() {
|
||||||
|
try {
|
||||||
|
return new NetworkSection(info, networks.build());
|
||||||
|
} finally {
|
||||||
|
this.info = null;
|
||||||
|
this.networks = ImmutableSet.<Network> builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
|
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Network")) {
|
||||||
|
name = attributes.get("name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
if (qName.endsWith("Info")) {
|
||||||
|
this.info = Utils.currentOrNull(currentText);
|
||||||
|
} else if (qName.endsWith("Description")) {
|
||||||
|
this.description = Utils.currentOrNull(currentText);
|
||||||
|
} else if (qName.endsWith("Network")) {
|
||||||
|
this.networks.add(new Network(name, description));
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Link;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Org;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
|
||||||
|
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected Org.Builder builder = Org.builder();
|
||||||
|
|
||||||
|
public Org getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = Org.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Org")) {
|
||||||
|
// savvis doesn't add href in the header for some reason
|
||||||
|
if (!attributes.containsKey("href") && getRequest() != null)
|
||||||
|
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
|
||||||
|
.put("href", getRequest().getEndpoint().toASCIIString()).build();
|
||||||
|
Resource org = newResource(attributes);
|
||||||
|
builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref());
|
||||||
|
} else if (qName.endsWith("Link")) {
|
||||||
|
Link link = Link.class.cast(newResource(attributes));
|
||||||
|
if ("down".equals(link.getRel()))
|
||||||
|
builder.vDC(link);
|
||||||
|
else
|
||||||
|
builder.image(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.endsWith("Description")) {
|
||||||
|
builder.description(currentOrNull(currentText));
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class OrgListHandler extends ParseSax.HandlerWithResult<Set<Resource>> {
|
||||||
|
|
||||||
|
private Builder<Resource> org = ImmutableSet.<Resource> builder();
|
||||||
|
|
||||||
|
public Set<Resource> getResult() {
|
||||||
|
try {
|
||||||
|
return org.build();
|
||||||
|
} finally {
|
||||||
|
org = ImmutableSet.<Resource> builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Org")) {
|
||||||
|
org.add(newResource(attributes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.ResourceAllocation;
|
||||||
|
import org.jclouds.savvis.vpdc.util.Utils;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class ResourceAllocationHandler extends ParseSax.HandlerWithResult<ResourceAllocation> {
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected ResourceAllocation.Builder builder = ResourceAllocation.builder();
|
||||||
|
|
||||||
|
public ResourceAllocation getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = ResourceAllocation.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
String current = Utils.currentOrNull(currentText);
|
||||||
|
if (current != null) {
|
||||||
|
if (qName.endsWith("AllocationUnits")) {
|
||||||
|
builder.allocationUnits(current);
|
||||||
|
} else if (qName.endsWith("Description")) {
|
||||||
|
builder.description(current);
|
||||||
|
} else if (qName.endsWith("ElementName")) {
|
||||||
|
builder.name(current);
|
||||||
|
} else if (qName.endsWith("InstanceID")) {
|
||||||
|
builder.id(Integer.parseInt(current));
|
||||||
|
} else if (qName.endsWith("ResourceType")) {
|
||||||
|
builder.type(ResourceAllocation.Type.fromValue(current));
|
||||||
|
} else if (qName.endsWith("VirtualQuantity")) {
|
||||||
|
builder.virtualQuantity(Long.parseLong(current));
|
||||||
|
} else if (qName.endsWith("Caption")) {
|
||||||
|
builder.caption(current);
|
||||||
|
} else if (qName.endsWith("Connection")) {
|
||||||
|
builder.connection(current);
|
||||||
|
} else if (qName.endsWith("HostResource")) {
|
||||||
|
builder.hostResource(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,154 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.xml;
|
|
||||||
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCNetwork;
|
|
||||||
import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCNetworkImpl;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.network.firewall.FirewallPolicy;
|
|
||||||
import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
|
|
||||||
import org.jclouds.vcloud.domain.network.nat.NatProtocol;
|
|
||||||
import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Kedar Dave
|
|
||||||
*/
|
|
||||||
public class SymphonyVPDCNetworkHandler extends ParseSax.HandlerWithResult<SymphonyVPDCNetwork>{
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
private ReferenceType ips;
|
|
||||||
private ReferenceType extension;
|
|
||||||
|
|
||||||
protected StringBuilder currentText = new StringBuilder();
|
|
||||||
|
|
||||||
protected ReferenceType network;
|
|
||||||
|
|
||||||
protected String description;
|
|
||||||
|
|
||||||
protected Set<String> dnsServers = Sets.newLinkedHashSet();
|
|
||||||
protected String gateway;
|
|
||||||
protected String netmask;
|
|
||||||
protected Set<FenceMode> fenceModes = Sets.newLinkedHashSet();
|
|
||||||
protected Boolean dhcp;
|
|
||||||
protected Set<PortForwardingRule> natRules = Sets.newLinkedHashSet();
|
|
||||||
protected Set<FirewallRule> firewallRules = Sets.newLinkedHashSet();
|
|
||||||
|
|
||||||
protected String externalIP;
|
|
||||||
protected Integer externalPort;
|
|
||||||
protected String internalIP;
|
|
||||||
protected Integer internalPort;
|
|
||||||
|
|
||||||
protected FirewallPolicy policy;
|
|
||||||
protected String sourceIP;
|
|
||||||
protected int sourcePort;
|
|
||||||
|
|
||||||
public SymphonyVPDCNetwork getResult() {
|
|
||||||
return new SymphonyVPDCNetworkImpl(network.getName(), network.getType(), network.getHref(), description,
|
|
||||||
dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
|
||||||
if (qName.endsWith("Network")) {
|
|
||||||
network = newReferenceType(attributes);
|
|
||||||
} else if (qName.endsWith("Link")) {
|
|
||||||
if ("IP Addresses".equals(attributes.get("name"))) {
|
|
||||||
ips = newReferenceType(attributes);
|
|
||||||
} else if ("down".equals(attributes.get("rel"))) {
|
|
||||||
extension = newReferenceType(attributes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
|
||||||
if (qName.equals("Description")) {
|
|
||||||
description = currentOrNull();
|
|
||||||
} else if (qName.equals("Dns")) {
|
|
||||||
dnsServers.add(currentOrNull());
|
|
||||||
} else if (qName.equals("Gateway")) {
|
|
||||||
gateway = currentOrNull();
|
|
||||||
} else if (qName.equals("Netmask")) {
|
|
||||||
netmask = currentOrNull();
|
|
||||||
} else if (qName.equals("FenceMode")) {
|
|
||||||
try {
|
|
||||||
fenceModes.add(FenceMode.fromValue(currentOrNull()));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
fenceModes.add(FenceMode.BRIDGED);
|
|
||||||
}
|
|
||||||
} else if (qName.equals("Dhcp")) {
|
|
||||||
dhcp = new Boolean(currentOrNull());
|
|
||||||
} else if (qName.equals("NatRule")) {
|
|
||||||
natRules.add(new PortForwardingRule(externalIP, externalPort, internalIP, internalPort, NatProtocol.TCP_UDP));
|
|
||||||
externalIP = null;
|
|
||||||
externalPort = null;
|
|
||||||
internalIP = null;
|
|
||||||
internalPort = null;
|
|
||||||
} else if (qName.equals("ExternalIP")) {
|
|
||||||
externalIP = currentOrNull();
|
|
||||||
} else if (qName.equals("ExternalPort")) {
|
|
||||||
externalPort = Integer.parseInt(currentOrNull());
|
|
||||||
} else if (qName.equals("InternalIP")) {
|
|
||||||
internalIP = currentOrNull();
|
|
||||||
} else if (qName.equals("InternalPort")) {
|
|
||||||
internalPort = Integer.parseInt(currentOrNull());
|
|
||||||
} else if (qName.equals("FirewallRule")) {
|
|
||||||
firewallRules.add(new FirewallRule(true, null, policy, null, sourcePort, sourceIP));
|
|
||||||
policy = null;
|
|
||||||
sourceIP = null;
|
|
||||||
sourcePort = -1;
|
|
||||||
} else if (qName.equals("Policy")) {
|
|
||||||
policy = FirewallPolicy.fromValue(currentOrNull());
|
|
||||||
} else if (qName.equals("SourceIp")) {
|
|
||||||
sourceIP = currentOrNull();
|
|
||||||
} else if (qName.equals("SourcePort")) {
|
|
||||||
sourcePort = Integer.parseInt(currentOrNull());
|
|
||||||
}
|
|
||||||
|
|
||||||
currentText = new StringBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void characters(char ch[], int start, int length) {
|
|
||||||
currentText.append(ch, start, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String currentOrNull() {
|
|
||||||
String returnVal = currentText.toString().trim();
|
|
||||||
return returnVal.equals("") ? null : returnVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,147 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.xml;
|
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.vcloud.util.Utils.cleanseAttributes;
|
|
||||||
import static org.jclouds.vcloud.util.Utils.newReferenceType;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.Status;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
|
||||||
import org.jclouds.vcloud.domain.internal.VCloudExpressVAppImpl;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.System;
|
|
||||||
import org.jclouds.vcloud.xml.ovf.ResourceAllocationHandler;
|
|
||||||
import org.jclouds.vcloud.xml.ovf.SystemHandler;
|
|
||||||
import org.xml.sax.Attributes;
|
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
import com.google.common.collect.ListMultimap;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Kedar Dave
|
|
||||||
*/
|
|
||||||
public class SymphonyVPDCVAppHandler extends ParseSax.HandlerWithResult<VCloudExpressVApp> {
|
|
||||||
private final String apiVersion;
|
|
||||||
private final SystemHandler systemHandler;
|
|
||||||
private final ResourceAllocationHandler allocationHandler;
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public SymphonyVPDCVAppHandler(@Named(PROPERTY_API_VERSION) String apiVersion, SystemHandler systemHandler,
|
|
||||||
ResourceAllocationHandler allocationHandler) {
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
this.systemHandler = systemHandler;
|
|
||||||
this.allocationHandler = allocationHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected System system;
|
|
||||||
protected Set<ResourceAllocation> allocations = Sets.newLinkedHashSet();
|
|
||||||
protected Status status;
|
|
||||||
protected final ListMultimap<String, String> networkToAddresses = ArrayListMultimap.create();
|
|
||||||
protected StringBuilder currentText = new StringBuilder();
|
|
||||||
protected String operatingSystemDescription;
|
|
||||||
protected boolean inOs;
|
|
||||||
protected String networkName;
|
|
||||||
protected String name;
|
|
||||||
protected Integer osType;
|
|
||||||
protected URI location;
|
|
||||||
protected Long size;
|
|
||||||
protected ReferenceType vDC;
|
|
||||||
|
|
||||||
public VCloudExpressVApp getResult() {
|
|
||||||
return new VCloudExpressVAppImpl(name, location, status, size, vDC, networkToAddresses, osType,
|
|
||||||
operatingSystemDescription, system, allocations);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
|
||||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
|
||||||
if (qName.endsWith("VApp")) {
|
|
||||||
ReferenceType resource = newReferenceType(attributes);
|
|
||||||
name = resource.getName();
|
|
||||||
location = resource.getHref();
|
|
||||||
String statusString = attributes.get("status");
|
|
||||||
if (apiVersion.indexOf("0.8") != -1 && "2".equals(statusString))
|
|
||||||
status = Status.OFF;
|
|
||||||
else
|
|
||||||
status = Status.fromValue(statusString);
|
|
||||||
if (attributes.containsKey("size"))
|
|
||||||
size = new Long(attributes.get("size"));
|
|
||||||
} else if (qName.equals("Link")) { // type should never be missing
|
|
||||||
if (attributes.containsKey("type") && attributes.get("type").equals(VCloudExpressMediaType.VDC_XML)) {
|
|
||||||
vDC = newReferenceType(attributes);
|
|
||||||
}
|
|
||||||
} else if (qName.endsWith("OperatingSystemSection")) {
|
|
||||||
inOs = true;
|
|
||||||
if (attributes.containsKey("id"))
|
|
||||||
osType = Integer.parseInt(attributes.get("id"));
|
|
||||||
} else if (qName.endsWith("NetworkConnection")) {
|
|
||||||
networkName = attributes.get("Network");
|
|
||||||
} else {
|
|
||||||
systemHandler.startElement(uri, localName, qName, attrs);
|
|
||||||
allocationHandler.startElement(uri, localName, qName, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
|
||||||
if (qName.endsWith("OperatingSystemSection")) {
|
|
||||||
inOs = false;
|
|
||||||
} else if (inOs && qName.endsWith("Description")) {
|
|
||||||
operatingSystemDescription = currentText.toString().trim();
|
|
||||||
} else if (qName.endsWith("IpAddress")) {
|
|
||||||
networkToAddresses.put(networkName, currentText.toString().trim());
|
|
||||||
} else if (qName.equals("System")) {
|
|
||||||
systemHandler.endElement(uri, localName, qName);
|
|
||||||
system = systemHandler.getResult();
|
|
||||||
} else if (qName.equals("Item")) {
|
|
||||||
allocationHandler.endElement(uri, localName, qName);
|
|
||||||
allocations.add(allocationHandler.getResult());
|
|
||||||
} else {
|
|
||||||
systemHandler.endElement(uri, localName, qName);
|
|
||||||
allocationHandler.endElement(uri, localName, qName);
|
|
||||||
}
|
|
||||||
currentText = new StringBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void characters(char ch[], int start, int length) {
|
|
||||||
currentText.append(ch, start, length);
|
|
||||||
systemHandler.characters(ch, start, length);
|
|
||||||
allocationHandler.characters(ch, start, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.xml;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
|
|
||||||
import org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCVDCImpl;
|
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
|
||||||
import org.jclouds.vcloud.xml.TaskHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VDCHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class SymphonyVPDCVDCHandler extends VDCHandler {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public SymphonyVPDCVDCHandler(TaskHandler taskHandler) {
|
|
||||||
super(taskHandler);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String offeringTag;
|
|
||||||
|
|
||||||
public SymphonyVPDCVDC getResult() {
|
|
||||||
VDC vDC = super.getResult();
|
|
||||||
return new SymphonyVPDCVDCImpl(vDC.getName(), vDC.getType(), vDC.getHref(), status, org, description, tasks,
|
|
||||||
allocationModel, storageCapacity, cpuCapacity, memoryCapacity, resourceEntities, availableNetworks,
|
|
||||||
nicQuota, networkQuota, vmQuota, isEnabled, offeringTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void endElement(String uri, String name, String qName) {
|
|
||||||
if (qName.endsWith("OfferingTag")) {
|
|
||||||
this.offeringTag = currentOrNull();
|
|
||||||
}
|
|
||||||
super.endElement(uri, name, qName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.TaskError;
|
||||||
|
import org.jclouds.savvis.vpdc.util.Utils;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
|
@javax.annotation.Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
protected final DateService dateService;
|
||||||
|
|
||||||
|
private Task.Builder builder = Task.builder();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TaskHandler(DateService dateService) {
|
||||||
|
this.dateService = dateService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = Task.builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Task")) {
|
||||||
|
Resource task = newResource(attributes);
|
||||||
|
builder.id(task.getId());
|
||||||
|
builder.type(task.getType());
|
||||||
|
builder.href(task.getHref());
|
||||||
|
if (attributes.containsKey("startTime"))
|
||||||
|
builder.startTime(parseDate(attributes.get("startTime")));
|
||||||
|
if (attributes.containsKey("endTime"))
|
||||||
|
builder.endTime(parseDate(attributes.get("endTime")));
|
||||||
|
builder.status(Task.Status.fromValue(attributes.get("status")));
|
||||||
|
} else if (qName.endsWith("Owner")) {
|
||||||
|
builder.owner(Utils.newResource(attributes));
|
||||||
|
} else if (qName.endsWith("Result")) {
|
||||||
|
builder.result(Utils.newResource(attributes));
|
||||||
|
} else if (qName.endsWith("Error")) {
|
||||||
|
builder.error(new TaskError(attributes.get("message"), Integer.parseInt(attributes.get("majorErrorCode")),
|
||||||
|
Integer.parseInt(attributes.get("minorErrorCode")), attributes.get("vendorSpecificErrorCode")));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Date parseDate(String toParse) {
|
||||||
|
try {
|
||||||
|
return dateService.iso8601DateParse(toParse);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
logger.error(e, "error parsing date, %s", toParse);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TasksListHandler extends ParseSax.HandlerWithResult<Set<Task>> {
|
||||||
|
|
||||||
|
private Builder<Task> tasks = ImmutableSet.<Task> builder();
|
||||||
|
private final TaskHandler taskHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TasksListHandler(TaskHandler taskHandler) {
|
||||||
|
this.taskHandler = taskHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Task> getResult() {
|
||||||
|
try {
|
||||||
|
return tasks.build();
|
||||||
|
} finally {
|
||||||
|
tasks = ImmutableSet.<Task> builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
taskHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
|
taskHandler.endElement(uri, localName, qName);
|
||||||
|
if (qName.equals("Task")) {
|
||||||
|
this.tasks.add(taskHandler.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VApp;
|
||||||
|
import org.jclouds.savvis.vpdc.util.Utils;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Kedar Dave
|
||||||
|
*/
|
||||||
|
public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
private final NetworkSectionHandler networkSectionHandler;
|
||||||
|
private final ResourceAllocationHandler allocationHandler;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public VAppHandler(NetworkSectionHandler networkSectionHandler, ResourceAllocationHandler allocationHandler) {
|
||||||
|
this.networkSectionHandler = networkSectionHandler;
|
||||||
|
this.allocationHandler = allocationHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VApp.Builder builder = VApp.builder();
|
||||||
|
protected boolean inOs;
|
||||||
|
|
||||||
|
public VApp getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = VApp.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("VApp")) {
|
||||||
|
// savvis doesn't add href in the header for some reason
|
||||||
|
if (!attributes.containsKey("href") && getRequest() != null)
|
||||||
|
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
|
||||||
|
.put("href", getRequest().getEndpoint().toASCIIString()).build();
|
||||||
|
Resource vApp = newResource(attributes);
|
||||||
|
builder.name(vApp.getName()).type(vApp.getType()).id(vApp.getId()).href(vApp.getHref());
|
||||||
|
builder.status(VApp.Status.fromValue(attributes.get("status")));
|
||||||
|
} else if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
inOs = true;
|
||||||
|
if (attributes.containsKey("id"))
|
||||||
|
builder.osType(Integer.parseInt(attributes.get("id")));
|
||||||
|
} else {
|
||||||
|
networkSectionHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
allocationHandler.startElement(uri, localName, qName, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
|
if (qName.endsWith("OperatingSystemSection")) {
|
||||||
|
inOs = false;
|
||||||
|
} else if (inOs && qName.endsWith("Description")) {
|
||||||
|
builder.osDescripton(Utils.currentOrNull(currentText));
|
||||||
|
} else if (qName.endsWith("IpAddress")) {
|
||||||
|
builder.ipAddress(Utils.currentOrNull(currentText));
|
||||||
|
} else if (qName.endsWith("NetworkSection")) {
|
||||||
|
networkSectionHandler.endElement(uri, localName, qName);
|
||||||
|
builder.networkSection(networkSectionHandler.getResult());
|
||||||
|
} else if (qName.endsWith("Item")) {
|
||||||
|
allocationHandler.endElement(uri, localName, qName);
|
||||||
|
builder.resourceAllocation(allocationHandler.getResult());
|
||||||
|
} else {
|
||||||
|
networkSectionHandler.endElement(uri, localName, qName);
|
||||||
|
allocationHandler.endElement(uri, localName, qName);
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
networkSectionHandler.characters(ch, start, length);
|
||||||
|
allocationHandler.characters(ch, start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
|
||||||
|
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC.Status;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
|
||||||
|
|
||||||
|
protected StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
|
protected VDC.Builder builder = VDC.builder();
|
||||||
|
|
||||||
|
public VDC getResult() {
|
||||||
|
try {
|
||||||
|
return builder.build();
|
||||||
|
} finally {
|
||||||
|
builder = VDC.builder();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||||
|
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||||
|
if (qName.endsWith("Vdc")) {
|
||||||
|
// savvis doesn't add href in the header for some reason
|
||||||
|
if (!attributes.containsKey("href") && getRequest() != null)
|
||||||
|
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
|
||||||
|
.put("href", getRequest().getEndpoint().toASCIIString()).build();
|
||||||
|
Resource vDC = newResource(attributes);
|
||||||
|
builder.name(vDC.getName()).type(vDC.getType()).id(vDC.getId()).href(vDC.getHref());
|
||||||
|
} else if (qName.endsWith("Network")) {
|
||||||
|
builder.availableNetwork(newResource(attributes));
|
||||||
|
} else if (qName.endsWith("ResourceEntity")) {
|
||||||
|
builder.resourceEntity(newResource(attributes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endElement(String uri, String name, String qName) {
|
||||||
|
if (qName.endsWith("Description")) {
|
||||||
|
builder.description(currentOrNull(currentText));
|
||||||
|
} else if (qName.endsWith("OfferingTag")) {
|
||||||
|
builder.status(Status.fromValue(currentOrNull(currentText)));
|
||||||
|
}
|
||||||
|
currentText = new StringBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void characters(char ch[], int start, int length) {
|
||||||
|
currentText.append(ch, start, length);
|
||||||
|
}
|
||||||
|
}
|
@ -1,903 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc;
|
|
||||||
|
|
||||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
|
||||||
import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.http.RequiresHttp;
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
|
||||||
import org.jclouds.rest.RestClientTest;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.rest.RestContextSpec;
|
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|
||||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.savvis.vpdc.config.SymphonyVPDCRestClientModule;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCNetworkHandler;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVAppHandler;
|
|
||||||
import org.jclouds.savvis.vpdc.xml.SymphonyVPDCVDCHandler;
|
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.jclouds.vcloud.CommonVCloudClient;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressLoginAsyncClient;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressMediaType;
|
|
||||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
|
||||||
import org.jclouds.vcloud.domain.Org;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudSession;
|
|
||||||
import org.jclouds.vcloud.domain.internal.CatalogImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.VDCImpl;
|
|
||||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
|
||||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
|
||||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
|
||||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
|
||||||
import org.jclouds.vcloud.xml.TaskHandler;
|
|
||||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VCloudExpressVAppHandler;
|
|
||||||
import org.jclouds.vcloud.xml.VCloudExpressVAppTemplateHandler;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import com.google.common.base.Suppliers;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests annotation parsing of {@code SymphonyVPDCAsyncClient}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "unit")
|
|
||||||
public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyncClient> {
|
|
||||||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
|
||||||
String.class, InstantiateVAppTemplateOptions[].class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/3"), "my-vapp");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(
|
|
||||||
request,
|
|
||||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hosting.xml")).replace(
|
|
||||||
"vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
|
||||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
|
|
||||||
IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
|
||||||
String.class, InstantiateVAppTemplateOptions[].class);
|
|
||||||
HttpRequest request = processor.createRequest(
|
|
||||||
method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/3"),
|
|
||||||
"my-vapp",
|
|
||||||
processorCount(1)
|
|
||||||
.memory(512)
|
|
||||||
.disk(1024)
|
|
||||||
.addNetworkConfig(
|
|
||||||
new NetworkConfig(null, URI.create("https://vcloud.safesecureweb.com/network/1990"),
|
|
||||||
FenceMode.BRIDGED)));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request,
|
|
||||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml"))
|
|
||||||
.replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
|
||||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
|
||||||
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
|
|
||||||
IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
|
||||||
String.class, InstantiateVAppTemplateOptions[].class);
|
|
||||||
processor.createRequest(
|
|
||||||
method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
"CentOS 01",
|
|
||||||
processorCount(1)
|
|
||||||
.memory(512)
|
|
||||||
.disk(1024)
|
|
||||||
.addNetworkConfig(
|
|
||||||
new NetworkConfig("aloha", URI
|
|
||||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"), null)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
|
||||||
CloneVAppOptions[].class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vapp/4181"), "my-vapp");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(
|
|
||||||
request,
|
|
||||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp-default.xml")).replace(
|
|
||||||
"vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
|
||||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
|
||||||
CloneVAppOptions[].class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vapp/201"), "new-linux-server",
|
|
||||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp.xml"))
|
|
||||||
.replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
|
|
||||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getOrg", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findOrgNamed", String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getCatalog", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org", "catalog");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, CatalogHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getNetwork", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/network/2 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCNetworkHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class,
|
|
||||||
String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
|
|
||||||
String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppTemplateHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppTemplateHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindVDCInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org", "vdc");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expectedExceptions = NoSuchElementException.class)
|
|
||||||
public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
|
||||||
processor.createRequest(method, "org", "vdc1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expectedExceptions = NoSuchElementException.class)
|
|
||||||
public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
|
||||||
processor.createRequest(method, "org1", "vdc");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, null, "vdc");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, null, null);
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getVDC", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getTasksList", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
|
|
||||||
HttpRequest request = processor.createRequest(method, "org");
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TasksListHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("deployVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/deploy HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGet() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, SymphonyVPDCVAppHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("undeployVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/undeploy HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDelete() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("deleteVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"DELETE https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("powerOnVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("powerOffVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("resetVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("suspendVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("shutdownVApp", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/shutdown HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("getTask", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request, "GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1 HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
|
||||||
Method method = SymphonyVPDCAsyncClient.class.getMethod("cancelTask", URI.class);
|
|
||||||
HttpRequest request = processor.createRequest(method,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1"));
|
|
||||||
|
|
||||||
assertRequestLineEquals(request,
|
|
||||||
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/task/1/action/cancel HTTP/1.1");
|
|
||||||
assertNonPayloadHeadersEqual(request, "");
|
|
||||||
assertPayloadEquals(request, null, null, false);
|
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
|
||||||
assertSaxResponseParserClassEquals(method, null);
|
|
||||||
assertExceptionParserClassEquals(method, null);
|
|
||||||
|
|
||||||
checkFilters(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkFilters(HttpRequest request) {
|
|
||||||
assertEquals(request.getFilters().size(), 1);
|
|
||||||
assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SymphonyVPDCAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SymphonyVPDCAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Module createModule() {
|
|
||||||
return new SymphonyVPDCRestClientModuleExtension();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RestContextSpec<?, ?> createContextSpec() {
|
|
||||||
Properties restProperties = new Properties();
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
|
||||||
SymphonyVPDCPropertiesBuilder.class.getName());
|
|
||||||
|
|
||||||
Properties overrides = new Properties();
|
|
||||||
overrides.setProperty("savvis-symphony-vpdc.endpoint",
|
|
||||||
"https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8");
|
|
||||||
return new RestContextFactory(restProperties).createContextSpec("savvis-symphony-vpdc", "identity", "credential",
|
|
||||||
overrides);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequiresHttp
|
|
||||||
@ConfiguresRestClient
|
|
||||||
public static class SymphonyVPDCRestClientModuleExtension extends SymphonyVPDCRestClientModule {
|
|
||||||
@Override
|
|
||||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
|
||||||
@Named(PROPERTY_API_VERSION) String version) {
|
|
||||||
return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/login");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideOrg(@org.jclouds.vcloud.endpoints.Org Iterable<ReferenceType> orgs) {
|
|
||||||
return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String provideOrgName(@org.jclouds.vcloud.endpoints.Org Iterable<ReferenceType> orgs) {
|
|
||||||
return "org";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideCatalog(Org org, @Named(PROPERTY_IDENTITY) String user) {
|
|
||||||
return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Org provideOrg(CommonVCloudClient discovery) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Iterable<ReferenceType> provideOrgs(Supplier<VCloudSession> cache, @Named(PROPERTY_IDENTITY) String user) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideDefaultTasksList(Org org) {
|
|
||||||
return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/taskslist");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideDefaultVDC(Org org, @org.jclouds.vcloud.endpoints.VDC String defaultVDC) {
|
|
||||||
return URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String provideDefaultVDCName(
|
|
||||||
@org.jclouds.vcloud.endpoints.VDC Supplier<Map<String, String>> vDCtoOrgSupplier) {
|
|
||||||
return "vdc";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected URI provideDefaultNetwork(URI vdc, Injector injector) {
|
|
||||||
return URI.create("https://vcloud.safesecureweb.com/network/1990");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
|
||||||
final VCloudExpressLoginAsyncClient login) {
|
|
||||||
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ReferenceType> getOrgs() {
|
|
||||||
return ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"org",
|
|
||||||
new ReferenceTypeImpl("org", VCloudExpressMediaType.ORG_XML, URI
|
|
||||||
.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1")));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVCloudToken() {
|
|
||||||
return "token";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
super.configure();
|
|
||||||
bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class);
|
|
||||||
bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class);
|
|
||||||
bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
|
||||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
|
||||||
|
|
||||||
return Suppliers
|
|
||||||
.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(
|
|
||||||
"org",
|
|
||||||
|
|
||||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
|
|
||||||
"vdc",
|
|
||||||
new VDCImpl(
|
|
||||||
"vdc",
|
|
||||||
null,
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"),
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"description",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"vapp",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"vapp",
|
|
||||||
"application/vnd.vmware.vcloud.vApp+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/188849-1")),
|
|
||||||
"network",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"network",
|
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdcItem/2"))),
|
|
||||||
null, 0, 0, 0, false))));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class TestOrgMapSupplier extends OrgMapSupplier {
|
|
||||||
@Inject
|
|
||||||
protected TestOrgMapSupplier() {
|
|
||||||
super(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Org> get() {
|
|
||||||
return ImmutableMap.<String, Org> of(
|
|
||||||
"org",
|
|
||||||
new OrgImpl("org", null, URI
|
|
||||||
.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/org/1"), "org", null,
|
|
||||||
ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"catalog",
|
|
||||||
new ReferenceTypeImpl("catalog", VCloudExpressMediaType.CATALOG_XML, URI
|
|
||||||
.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1"))),
|
|
||||||
ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"vdc",
|
|
||||||
new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML, URI
|
|
||||||
.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1"))),
|
|
||||||
ImmutableMap.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
|
|
||||||
VCloudExpressMediaType.TASKSLIST_XML, URI
|
|
||||||
.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1")),
|
|
||||||
ImmutableList.<Task> of()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class TestOrgCatalogSupplier extends OrgCatalogSupplier {
|
|
||||||
@Inject
|
|
||||||
protected TestOrgCatalogSupplier() {
|
|
||||||
super(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
|
||||||
return ImmutableMap
|
|
||||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
|
|
||||||
"org",
|
|
||||||
|
|
||||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
|
|
||||||
"catalog",
|
|
||||||
new CatalogImpl(
|
|
||||||
"catalog",
|
|
||||||
"type",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1"),
|
|
||||||
null,
|
|
||||||
"description",
|
|
||||||
ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"item",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"item",
|
|
||||||
"application/vnd.vmware.vcloud.catalogItem+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/1")),
|
|
||||||
"template",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"template",
|
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2"))),
|
|
||||||
ImmutableList.<Task> of(), true)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier {
|
|
||||||
protected TestOrgCatalogItemSupplier() {
|
|
||||||
super(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
|
||||||
return ImmutableMap
|
|
||||||
.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
|
||||||
"org",
|
|
||||||
ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
|
||||||
"catalog",
|
|
||||||
ImmutableMap
|
|
||||||
.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
|
||||||
"template",
|
|
||||||
new CatalogItemImpl(
|
|
||||||
"template",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2"),
|
|
||||||
"description",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"template",
|
|
||||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2")),
|
|
||||||
ImmutableMap.<String, String> of()))));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,326 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc;
|
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.find;
|
|
||||||
import static org.jclouds.vcloud.options.CloneVAppOptions.Builder.deploy;
|
|
||||||
import static org.jclouds.vcloud.predicates.VCloudPredicates.resourceType;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.domain.Credentials;
|
|
||||||
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.SshClient.Factory;
|
|
||||||
import org.jclouds.ssh.SshException;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
|
||||||
import org.jclouds.vcloud.VCloudExpressClientLiveTest;
|
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.Status;
|
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVApp;
|
|
||||||
import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
|
|
||||||
import org.jclouds.vcloud.domain.VDC;
|
|
||||||
import org.jclouds.vcloud.domain.ovf.ResourceType;
|
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
|
||||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.vcloud.predicates.TaskSuccess;
|
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest {
|
|
||||||
public SymphonyVPDCClientLiveTest() {
|
|
||||||
provider = "savvis-symphony-vpdc";
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
|
||||||
@Override
|
|
||||||
public void setupClient() {
|
|
||||||
setupCredentials();
|
|
||||||
Properties overrides = setupProperties();
|
|
||||||
|
|
||||||
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
|
||||||
Properties restProperties = new Properties();
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
|
||||||
SymphonyVPDCPropertiesBuilder.class.getName());
|
|
||||||
|
|
||||||
Injector injector = new RestContextFactory(restProperties).createContextBuilder(provider,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), overrides).buildInjector();
|
|
||||||
|
|
||||||
connection = injector.getInstance(SymphonyVPDCClient.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<URI>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String expectedOs = "Ubuntu Linux (64-bit)";
|
|
||||||
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
|
|
||||||
|
|
||||||
protected Factory sshFactory;
|
|
||||||
private VCloudExpressVApp vApp;
|
|
||||||
private RetryablePredicate<IPSocket> socketTester;
|
|
||||||
private RetryablePredicate<URI> successTester;
|
|
||||||
private VCloudExpressVApp clone;
|
|
||||||
private VDC vdc;
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-savvis";
|
|
||||||
|
|
||||||
@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("c");
|
|
||||||
String serverName = name.toString();// "adriantest";
|
|
||||||
|
|
||||||
long hardDisk = 4194304;
|
|
||||||
|
|
||||||
// long hardDisk = 4194304 / 4 * 10;
|
|
||||||
// String catalogOs = "CentOS 5.3 (64-bit)";
|
|
||||||
// String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
|
|
||||||
|
|
||||||
// lookup the datacenter you are deploying into
|
|
||||||
vdc = connection.findVDCInOrgNamed(null, null);
|
|
||||||
|
|
||||||
ReferenceType vAppTemplateId = Iterables.find(vdc.getResourceEntities().values(), new Predicate<ReferenceType>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(ReferenceType arg0) {
|
|
||||||
return arg0.getType().equals(VCloudMediaType.VAPPTEMPLATE_XML);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
VCloudExpressVAppTemplate vAppTemplate = connection.getVAppTemplate(vAppTemplateId.getHref());
|
|
||||||
|
|
||||||
assert vAppTemplate != null;
|
|
||||||
|
|
||||||
// create an options object to collect the configuration we want.
|
|
||||||
InstantiateVAppTemplateOptions instantiateOptions = new InstantiateVAppTemplateOptions();
|
|
||||||
|
|
||||||
// instantiate, noting vApp returned has minimal details
|
|
||||||
vApp = connection.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
|
|
||||||
instantiateOptions);
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
|
||||||
|
|
||||||
Task deployTask = connection.deployVApp(vApp.getHref());
|
|
||||||
|
|
||||||
// check to see the result of calling deploy twice
|
|
||||||
deployTask = connection.deployVApp(vApp.getHref());
|
|
||||||
assertEquals(deployTask.getHref(), deployTask.getHref());
|
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
connection.cancelTask(deployTask.getHref());
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
assert successTester.apply(deployTask.getHref());
|
|
||||||
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
|
||||||
|
|
||||||
ReferenceType vAppResource = connection.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
|
|
||||||
assertEquals(vAppResource.getHref(), vApp.getHref());
|
|
||||||
|
|
||||||
int processorCount = 1;
|
|
||||||
long memory = 512;
|
|
||||||
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
|
||||||
assertEquals(vApp.getStatus(), Status.OFF);
|
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
|
||||||
assertEquals(vApp.getStatus(), Status.ON);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void prepare() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
|
|
||||||
public void testCloneVApp() throws IOException {
|
|
||||||
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
|
||||||
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
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 = connection.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
|
|
||||||
|
|
||||||
// wait for the task to complete
|
|
||||||
assert successTester.apply(task.getHref());
|
|
||||||
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
|
||||||
|
|
||||||
// refresh task to get the new vApp location
|
|
||||||
task = connection.getTask(task.getHref());
|
|
||||||
|
|
||||||
clone = connection.getVApp(task.getOwner().getHref());
|
|
||||||
assertEquals(clone.getStatus(), Status.ON);
|
|
||||||
|
|
||||||
assertEquals(clone.getName(), newName);
|
|
||||||
assertEquals(clone.getNetworkToAddresses().values().size(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loopAndCheckPass(String publicIp) 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 = "testCloneVApp")
|
|
||||||
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
connection.undeployVApp(vApp.getHref());
|
|
||||||
assert false;
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
|
||||||
connection.suspendVApp(vApp.getHref());
|
|
||||||
assert false;
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
assert successTester.apply(connection.resetVApp(vApp.getHref()).getHref());
|
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.ON);
|
|
||||||
|
|
||||||
// TODO we need to determine whether shutdown is supported before invoking
|
|
||||||
// it.
|
|
||||||
// connection.shutdownVApp(vApp.getId());
|
|
||||||
// vApp = connection.getVApp(vApp.getId());
|
|
||||||
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
|
||||||
assertEquals(vApp.getStatus(), Status.OFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyConfigurationOfVApp(VCloudExpressVApp vApp, String serverName, String expectedOs,
|
|
||||||
int processorCount, long memory, long hardDisk) {
|
|
||||||
assertEquals(vApp.getName(), serverName);
|
|
||||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.PROCESSOR)).getVirtualQuantity(),
|
|
||||||
processorCount);
|
|
||||||
assertEquals(
|
|
||||||
find(vApp.getResourceAllocations(), resourceType(ResourceType.SCSI_CONTROLLER)).getVirtualQuantity(), 1);
|
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.MEMORY)).getVirtualQuantity(), memory);
|
|
||||||
assertEquals(find(vApp.getResourceAllocations(), resourceType(ResourceType.DISK_DRIVE)).getVirtualQuantity(),
|
|
||||||
hardDisk);
|
|
||||||
assertEquals(vApp.getSize().longValue(),
|
|
||||||
find(vApp.getResourceAllocations(), resourceType(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"));
|
|
||||||
} finally {
|
|
||||||
if (connection != null)
|
|
||||||
connection.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SshClient getConnectionFor(IPSocket socket) {
|
|
||||||
// TODO add in the correct login credentials for the vApp template
|
|
||||||
return sshFactory.create(socket, new Credentials("root", "password"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
|
||||||
if (vApp != null) {
|
|
||||||
try {
|
|
||||||
successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
connection.deleteVApp(vApp.getHref());
|
|
||||||
}
|
|
||||||
if (clone != null) {
|
|
||||||
try {
|
|
||||||
successTester.apply(connection.powerOffVApp(clone.getHref()).getHref());
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
connection.deleteVApp(clone.getHref());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.savvis.vpdc.features.BaseVPDCAsyncClientTest;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code VPDCAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "VPDCAsyncClientTest")
|
||||||
|
public class VPDCAsyncClientTest extends BaseVPDCAsyncClientTest<VPDCAsyncClient> {
|
||||||
|
|
||||||
|
private VPDCAsyncClient asyncClient;
|
||||||
|
private VPDCClient syncClient;
|
||||||
|
|
||||||
|
public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
|
||||||
|
assert syncClient.getBrowsingClient() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
|
||||||
|
assert asyncClient.getBrowsingClient() != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<VPDCAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<VPDCAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
@Override
|
||||||
|
protected void setupFactory() throws IOException {
|
||||||
|
super.setupFactory();
|
||||||
|
asyncClient = injector.getInstance(VPDCAsyncClient.class);
|
||||||
|
syncClient = injector.getInstance(VPDCClient.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkFilters(HttpRequest request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.compute;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
|
||||||
import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder;
|
|
||||||
import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder;
|
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Kedar Dave
|
|
||||||
*/
|
|
||||||
@Test(groups = "live", enabled = false, sequential = true)
|
|
||||||
public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|
||||||
public SymphonyVPDCComputeServiceLiveTest() {
|
|
||||||
provider = "savvis-symphony-vpdc";
|
|
||||||
group = "savvis.jclouds";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Properties setupRestProperties() {
|
|
||||||
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
|
||||||
Properties restProperties = new Properties();
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
|
||||||
SymphonyVPDCPropertiesBuilder.class.getName());
|
|
||||||
return restProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected JschSshClientModule getSshModule() {
|
|
||||||
return new JschSshClientModule();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
package org.jclouds.savvis.vpdc.compute;
|
|
||||||
|
|
||||||
import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
|
||||||
import org.jclouds.compute.domain.OsFamily;
|
|
||||||
import org.jclouds.compute.domain.Template;
|
|
||||||
import org.jclouds.compute.domain.os.OsFamilyVersion64Bit;
|
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.savvis.vpdc.SymphonyVPDCContextBuilder;
|
|
||||||
import org.jclouds.savvis.vpdc.SymphonyVPDCPropertiesBuilder;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "live", enabled = false)
|
|
||||||
public class SymphonyVPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|
||||||
|
|
||||||
public SymphonyVPDCTemplateBuilderLiveTest() {
|
|
||||||
provider = "savvis-symphony-vpdc";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeClass
|
|
||||||
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
|
||||||
setupCredentials();
|
|
||||||
// TODO remove these lines when this is registered under jclouds-core/rest.properties
|
|
||||||
Properties restProperties = new Properties();
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.contextbuilder", SymphonyVPDCContextBuilder.class.getName());
|
|
||||||
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
|
|
||||||
SymphonyVPDCPropertiesBuilder.class.getName());
|
|
||||||
|
|
||||||
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), setupProperties());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
|
|
||||||
return new Predicate<OsFamilyVersion64Bit>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(OsFamilyVersion64Bit input) {
|
|
||||||
// TODO it seems there are no base vApp Templates available in Savvis
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultTemplateBuilder() throws IOException {
|
|
||||||
Template defaultTemplate = context.getComputeService().templateBuilder().build();
|
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5.5");
|
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS);
|
|
||||||
assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Set<String> getIso3166Codes() {
|
|
||||||
return ImmutableSet.<String> of("US-FL", "NL-NH");
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 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.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.RequiresHttp;
|
||||||
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
import org.jclouds.rest.RestClientTest;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.rest.RestContextSpec;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCClient;
|
||||||
|
import org.jclouds.savvis.vpdc.config.VPDCRestClientModule;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.internal.VCloudSession;
|
||||||
|
import org.jclouds.savvis.vpdc.filters.SetVCloudTokenCookie;
|
||||||
|
import org.jclouds.savvis.vpdc.internal.LoginAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public abstract class BaseVPDCAsyncClientTest<T> extends RestClientTest<T> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RestContextSpec<VPDCClient, VPDCAsyncClient> createContextSpec() {
|
||||||
|
Properties props = new Properties();
|
||||||
|
return new RestContextFactory().createContextSpec("savvis-symphonyvpdc", "apiKey", "secretKey", props);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void checkFilters(HttpRequest request) {
|
||||||
|
assertEquals(request.getFilters().size(), 1);
|
||||||
|
assertEquals(request.getFilters().get(0).getClass(), SetVCloudTokenCookie.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Module createModule() {
|
||||||
|
return new VPDCRestClientModuleExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresHttp
|
||||||
|
@ConfiguresRestClient
|
||||||
|
public static class VPDCRestClientModuleExtension extends VPDCRestClientModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||||
|
final LoginAsyncClient login) {
|
||||||
|
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Resource> getOrgs() {
|
||||||
|
return ImmutableSet.of(new Resource("1", "org", VCloudMediaType.ORG_XML, URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVCloudToken() {
|
||||||
|
return "token";
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 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.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCAsyncClient;
|
||||||
|
import org.jclouds.savvis.vpdc.VPDCClient;
|
||||||
|
import org.testng.annotations.AfterGroups;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code VPDCClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "live")
|
||||||
|
public class BaseVPDCClientLiveTest {
|
||||||
|
|
||||||
|
protected RestContext<VPDCClient, VPDCAsyncClient> context;
|
||||||
|
protected String provider = "savvis-symphonyvpdc";
|
||||||
|
protected String identity;
|
||||||
|
protected String credential;
|
||||||
|
protected String endpoint;
|
||||||
|
protected String apiversion;
|
||||||
|
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||||
|
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||||
|
+ ".credential");
|
||||||
|
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
||||||
|
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
||||||
|
+ ".apiversion");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Properties setupProperties() {
|
||||||
|
Properties overrides = new Properties();
|
||||||
|
overrides.setProperty(provider + ".identity", identity);
|
||||||
|
overrides.setProperty(provider + ".credential", credential);
|
||||||
|
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||||
|
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||||
|
return overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
setupCredentials();
|
||||||
|
Properties overrides = setupProperties();
|
||||||
|
context = new RestContextFactory().createContext(provider, ImmutableSet.<Module> of(new Log4JLoggingModule()),
|
||||||
|
overrides);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterGroups(groups = "live")
|
||||||
|
protected void tearDown() {
|
||||||
|
if (context != null)
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,195 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.NetworkHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.OrgHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.TaskHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.VAppHandler;
|
||||||
|
import org.jclouds.savvis.vpdc.xml.VDCHandler;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests annotation parsing of {@code BrowsingAsyncClient}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class BrowsingAsyncClientTest extends BaseVPDCAsyncClientTest<BrowsingAsyncClient> {
|
||||||
|
|
||||||
|
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getOrg", String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "11");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOrgNull() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getOrg", String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, (String) null);
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, OrgHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "11", "22");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVDCWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, (String) null, "22");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getNetworkInOrgAndVDC", String.class, String.class,
|
||||||
|
String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "11", "22", "VM-Tier01");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/network/VM-Tier01 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, NetworkHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNetworkWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getNetworkInOrgAndVDC", String.class, String.class,
|
||||||
|
String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, (String) null, "22", "VM-Tier01");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22/network/VM-Tier01 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, NetworkHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getVAppInOrgAndVDC", String.class, String.class,
|
||||||
|
String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "11", "22", "VM-Tier01");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/VM-Tier01 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVAppWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getVAppInOrgAndVDC", String.class, String.class,
|
||||||
|
String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, (String) null, "22", "VM-Tier01");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request,
|
||||||
|
"GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/1/vdc/22/vApp/VM-Tier01 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
|
Method method = BrowsingAsyncClient.class.getMethod("getTask", String.class);
|
||||||
|
HttpRequest request = processor.createRequest(method, "1");
|
||||||
|
|
||||||
|
assertRequestLineEquals(request, "GET https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/1 HTTP/1.1");
|
||||||
|
assertNonPayloadHeadersEqual(request, "");
|
||||||
|
assertPayloadEquals(request, null, null, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||||
|
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeLiteral<RestAnnotationProcessor<BrowsingAsyncClient>> createTypeLiteral() {
|
||||||
|
return new TypeLiteral<RestAnnotationProcessor<BrowsingAsyncClient>>() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.features;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Org;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VApp;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
|
import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
|
||||||
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@Test(groups = "live")
|
||||||
|
public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest {
|
||||||
|
|
||||||
|
private BrowsingClient client;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeGroups(groups = { "live" })
|
||||||
|
public void setupClient() {
|
||||||
|
super.setupClient();
|
||||||
|
client = context.getApi().getBrowsingClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOrg() throws Exception {
|
||||||
|
Org response = client.getOrg(null);
|
||||||
|
assertNotNull(response);
|
||||||
|
assertNotNull(response.getId());
|
||||||
|
assertNotNull(response.getHref());
|
||||||
|
assertNotNull(response.getName());
|
||||||
|
// savvis leaves this null for some reason
|
||||||
|
assertEquals(response.getType(), null);
|
||||||
|
assert response.getImages().size() >= 0;
|
||||||
|
assert response.getDescription() != null;
|
||||||
|
assert response.getVDCs().size() >= 1;
|
||||||
|
assertEquals(client.getOrg(response.getId()).toString(), response.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVDC() throws Exception {
|
||||||
|
Org org = client.getOrg(null);
|
||||||
|
for (Resource vdc : org.getVDCs()) {
|
||||||
|
VDC response = client.getVDCInOrg(null, vdc.getId());
|
||||||
|
assertNotNull(response);
|
||||||
|
assertNotNull(response.getId());
|
||||||
|
assertNotNull(response.getHref());
|
||||||
|
assertNotNull(response.getName());
|
||||||
|
assertNotNull(response.getStatus());
|
||||||
|
assertEquals(response.getType(), "application/vnd.vmware.vcloud.vdc+xml");
|
||||||
|
assertNotNull(response.getDescription());
|
||||||
|
assertNotNull(response.getResourceEntities());
|
||||||
|
assertNotNull(response.getAvailableNetworks());
|
||||||
|
assertEquals(client.getVDCInOrg(null, response.getId()).toString(), response.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNetwork() throws Exception {
|
||||||
|
Org org = client.getOrg(null);
|
||||||
|
for (Resource vdc : org.getVDCs()) {
|
||||||
|
VDC VDC = client.getVDCInOrg(null, vdc.getId());
|
||||||
|
for (Resource vApp : VDC.getAvailableNetworks()) {
|
||||||
|
Network response = client.getNetworkInOrgAndVDC(org.getId(), vdc.getId(), vApp.getId());
|
||||||
|
assertNotNull(response);
|
||||||
|
assertNotNull(response.getId());
|
||||||
|
assertNotNull(response.getHref());
|
||||||
|
assertNotNull(response.getName());
|
||||||
|
assertEquals(response.getType(), VCloudMediaType.NETWORK_XML);
|
||||||
|
assertNotNull(response.getNetmask());
|
||||||
|
assertNotNull(response.getGateway());
|
||||||
|
assertNotNull(response.getInternalToExternalNATRules());
|
||||||
|
assertEquals(client.getNetworkInOrgAndVDC(null, vdc.getId(), response.getId()).toString(),
|
||||||
|
response.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVApp() throws Exception {
|
||||||
|
Org org = client.getOrg(null);
|
||||||
|
for (Resource vdc : org.getVDCs()) {
|
||||||
|
VDC VDC = client.getVDCInOrg(null, vdc.getId());
|
||||||
|
for (Resource vApp : Iterables.filter(VDC.getResourceEntities(), new Predicate<Resource>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Resource arg0) {
|
||||||
|
return VCloudMediaType.VAPP_XML.equals(arg0.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
})) {
|
||||||
|
VApp response = client.getVAppInOrgAndVDC(org.getId(), vdc.getId(), vApp.getId());
|
||||||
|
assertNotNull(response);
|
||||||
|
assertNotNull(response.getId());
|
||||||
|
assertNotNull(response.getHref());
|
||||||
|
assertNotNull(response.getName());
|
||||||
|
assertEquals(response.getType(), "application/vnd.vmware.vcloud.vApp+xml");
|
||||||
|
assertNotNull(response.getIpAddress());
|
||||||
|
assertNotNull(response.getStatus());
|
||||||
|
assertNotNull(response.getOsDescripton());
|
||||||
|
assertNotNull(response.getOsType());
|
||||||
|
assertNotNull(response.getNetworkSection());
|
||||||
|
assertNotNull(response.getResourceAllocations());
|
||||||
|
assertEquals(client.getVAppInOrgAndVDC(null, vdc.getId(), response.getId()).toString(), response.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.filters;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public class SetVCloudTokenCookieTest {
|
||||||
|
|
||||||
|
private SetVCloudTokenCookie filter;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
void setUp() {
|
||||||
|
filter = new SetVCloudTokenCookie(new Provider<String>() {
|
||||||
|
public String get() {
|
||||||
|
return "token";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testApply() {
|
||||||
|
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
|
||||||
|
request = filter.filter(request);
|
||||||
|
assertEquals(request.getHeaders().size(), 1);
|
||||||
|
assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -44,7 +44,7 @@ import com.google.inject.Guice;
|
|||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit" })
|
@Test(groups = { "unit" })
|
||||||
public class SymphonyVPDCErrorHandlerTest {
|
public class VPDCErrorHandlerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test400MakesIllegalArgumentException() {
|
public void test400MakesIllegalArgumentException() {
|
||||||
@ -83,7 +83,7 @@ public class SymphonyVPDCErrorHandlerTest {
|
|||||||
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
|
private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
|
||||||
String content, Class<? extends Exception> expected) {
|
String content, Class<? extends Exception> expected) {
|
||||||
|
|
||||||
SymphonyVPDCErrorHandler function = Guice.createInjector().getInstance(SymphonyVPDCErrorHandler.class);
|
VPDCErrorHandler function = Guice.createInjector().getInstance(VPDCErrorHandler.class);
|
||||||
|
|
||||||
HttpCommand command = createMock(HttpCommand.class);
|
HttpCommand command = createMock(HttpCommand.class);
|
||||||
HttpRequest request = new HttpRequest(method, uri);
|
HttpRequest request = new HttpRequest(method, uri);
|
@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Network;
|
||||||
|
import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code NetworkHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class NetworkHandlerTest {
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/network.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
||||||
|
assertEquals(
|
||||||
|
result.toString(),
|
||||||
|
Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM-Tier01").gateway("1.1.1.1")
|
||||||
|
.netmask("255.255.255.240").build().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNat() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/network-nat.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
||||||
|
assertEquals(result.toString(),
|
||||||
|
Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("1.1.1.1").netmask("2.2.2.2")
|
||||||
|
.internalToExternalNATRule("3.3.3.3", "4.4.4.4").internalToExternalNATRule("3.3.3.4", "4.4.4.5")
|
||||||
|
.build().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tesWhenNoVAppsInNetworkSetsAllZerosToGatewayAndNetmask() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/network-unused.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
|
||||||
|
assertEquals(result.toString(),
|
||||||
|
Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("0.0.0.0").netmask("0.0.0.0")
|
||||||
|
.build().toString());
|
||||||
|
}
|
||||||
|
}
|
@ -27,16 +27,10 @@ import java.net.URI;
|
|||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
import org.jclouds.vcloud.domain.Org;
|
import org.jclouds.savvis.vpdc.domain.Link;
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
import org.jclouds.savvis.vpdc.domain.Org;
|
||||||
import org.jclouds.vcloud.domain.Task;
|
|
||||||
import org.jclouds.vcloud.domain.internal.OrgImpl;
|
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
@ -49,18 +43,18 @@ import com.google.inject.Injector;
|
|||||||
public class OrgHandlerTest {
|
public class OrgHandlerTest {
|
||||||
|
|
||||||
public void testSavvis() {
|
public void testSavvis() {
|
||||||
InputStream is = getClass().getResourceAsStream("/savvis/org.xml");
|
InputStream is = getClass().getResourceAsStream("/org.xml");
|
||||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
|
Org result = factory.create(injector.getInstance(OrgHandler.class)).parse(is);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
result,
|
result.toString(),
|
||||||
new OrgImpl("100000.0", null, null, "100000.0", "SAVVISStation Integration Testing", ImmutableMap
|
Org.builder()
|
||||||
.<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> of(
|
.name("100000.0")
|
||||||
"demo_vpdcname",
|
.description("SAVVISStation Integration Testing")
|
||||||
new ReferenceTypeImpl("demo_vpdcname", "application/vnd.vmware.vcloud.vdc+xml", URI
|
.vDC(new Link("2736", "demo_vpdcname", "application/vnd.vmware.vcloud.vdc+xml", URI
|
||||||
.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))),
|
.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"),
|
||||||
ImmutableMap.<String, ReferenceType> of(), null, ImmutableSet.<Task> of()));
|
"down")).build().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code OrgListHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class OrgListHandlerTest {
|
||||||
|
|
||||||
|
public void testSavvis() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/orglist.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
Set<Resource> result = factory.create(injector.getInstance(OrgListHandler.class)).parse(is);
|
||||||
|
assertEquals(result, ImmutableSet.of(new Resource("100000.0", "SAVVISStation Integration Testing",
|
||||||
|
"application/vnd.vmware.vcloud.org+xml", URI
|
||||||
|
.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"))));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.ResourceAllocation;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code ResourceAllocationHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "ResourceAllocationHandlerTest")
|
||||||
|
public class ResourceAllocationHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
public void testApplyInputStream() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/resourceallocation.xml");
|
||||||
|
|
||||||
|
ResourceAllocation result = factory.create(injector.getInstance(ResourceAllocationHandler.class)).parse(is);
|
||||||
|
|
||||||
|
ResourceAllocation expects = ResourceAllocation.builder()
|
||||||
|
|
||||||
|
.allocationUnits("Gigabytes").caption("1234568").description("Hard Disk").name("D:\\").hostResource("data").id(6)
|
||||||
|
.type(ResourceAllocation.Type.DATA_DISK).virtualQuantity(50)
|
||||||
|
.build();
|
||||||
|
assertEquals(result, expects);
|
||||||
|
}
|
||||||
|
}
|
@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
|
||||||
*
|
|
||||||
* ====================================================================
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
* ====================================================================
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jclouds.savvis.vpdc.xml;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
|
||||||
import org.jclouds.http.functions.ParseSax.Factory;
|
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
|
||||||
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
|
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
|
||||||
import org.jclouds.vcloud.domain.ReferenceType;
|
|
||||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests behavior of {@code SymphonyVPDCVDCHandler}
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Test(groups = "unit")
|
|
||||||
public class SymphonyVPDCVDCHandlerTest {
|
|
||||||
|
|
||||||
public void test() {
|
|
||||||
InputStream is = getClass().getResourceAsStream("/savvis/vdc.xml");
|
|
||||||
Injector injector = Guice.createInjector(new SaxParserModule());
|
|
||||||
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
|
||||||
SymphonyVPDCVDC result = (SymphonyVPDCVDC) factory.create(injector.getInstance(SymphonyVPDCVDCHandler.class))
|
|
||||||
.parse(is);
|
|
||||||
assertEquals(result.getName(), "demo_vpdcname");
|
|
||||||
assertEquals(result.getHref(), null);
|
|
||||||
assertEquals(result.getDescription(),
|
|
||||||
"ServiceProfileName = Balanced; ServiceLocation = North America; Email = jim@company.com;");
|
|
||||||
assertEquals(result.getOfferingTag(), "Deployed");
|
|
||||||
assertEquals(result.getStorageCapacity(), null);
|
|
||||||
assertEquals(result.getCpuCapacity(), null);
|
|
||||||
assertEquals(result.getMemoryCapacity(), null);
|
|
||||||
assertEquals(result.getVmQuota(), 0);
|
|
||||||
assertEquals(
|
|
||||||
result.getResourceEntities(),
|
|
||||||
ImmutableMap.<String, ReferenceType> of(
|
|
||||||
"DemoHost-1",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"DemoHost-1",
|
|
||||||
VCloudMediaType.VAPP_XML,
|
|
||||||
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001")),
|
|
||||||
"DemoHost-2",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"DemoHost-2",
|
|
||||||
VCloudMediaType.VAPP_XML,
|
|
||||||
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")),
|
|
||||||
"DemoHost-3",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"DemoHost-3",
|
|
||||||
VCloudMediaType.VAPP_XML,
|
|
||||||
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003")),
|
|
||||||
"CustomerTemplateName",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"CustomerTemplateName",
|
|
||||||
VCloudMediaType.VAPPTEMPLATE_XML,
|
|
||||||
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234")),
|
|
||||||
"firewall",
|
|
||||||
new ReferenceTypeImpl(
|
|
||||||
"firewall",
|
|
||||||
"api.sandbox.symphonyVPDC.savvis.net+xml",
|
|
||||||
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService"))));
|
|
||||||
assertEquals(result.getAvailableNetworks(), ImmutableMap.of());
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,248 @@
|
|||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.date.DateService;
|
||||||
|
import org.jclouds.http.functions.BaseHandlerTest;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Task;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.TaskError;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code TaskHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||||
|
@Test(groups = "unit", testName = "TaskHandlerTest")
|
||||||
|
public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
|
private DateService dateService;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
@Override
|
||||||
|
protected void setUpInjector() {
|
||||||
|
super.setUpInjector();
|
||||||
|
dateService = injector.getInstance(DateService.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVAppSuccess() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-vapp.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.status(Task.Status.SUCCESS)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002"))
|
||||||
|
.owner(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("2736")
|
||||||
|
.name("mockVpdc8")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
|
||||||
|
.build())
|
||||||
|
.result(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("1002")
|
||||||
|
.name("mock_vpdc_item_007")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"))
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testVMDKSuccess() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-vmdk.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.status(Task.Status.SUCCESS)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002"))
|
||||||
|
.owner(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("2736")
|
||||||
|
.name("mockVpdc8")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
|
||||||
|
.build())
|
||||||
|
.result(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("1234567")
|
||||||
|
.name("mock_vpdc_item_008")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/vdc/2736/vmdk/1234567"))
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRunning() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-running.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.status(Task.Status.RUNNING)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002"))
|
||||||
|
.owner(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("2736")
|
||||||
|
.name("mockVpdc8")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
|
||||||
|
.build())
|
||||||
|
.result(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("1002")
|
||||||
|
.name("mock_vpdc_item_007")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"))
|
||||||
|
.build()).build();
|
||||||
|
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testQueued() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-queued.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.id("6904")
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.status(Task.Status.QUEUED)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904"))
|
||||||
|
.owner(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("2736")
|
||||||
|
.name("mockVpdc8")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
|
||||||
|
.build())
|
||||||
|
.result(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("1002")
|
||||||
|
.name("mock_vpdc_item_007")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"))
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFailed() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-failed.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.id("6904-123")
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
|
||||||
|
.status(Task.Status.ERROR)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123"))
|
||||||
|
.owner(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("2736")
|
||||||
|
.name("mockVpdc8")
|
||||||
|
.type("application/vnd.vmware.vcloud.vdc+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
|
||||||
|
.build())
|
||||||
|
.result(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.id("1002")
|
||||||
|
.name("mock_vpdc_item_007")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"))
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testError() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-error.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.id("6904-123")
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
|
||||||
|
.status(Task.Status.ERROR)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123"))
|
||||||
|
.error(
|
||||||
|
TaskError
|
||||||
|
.builder()
|
||||||
|
.vendorSpecificErrorCode("0")
|
||||||
|
.minorErrorCode(0)
|
||||||
|
.majorErrorCode(0)
|
||||||
|
.message(
|
||||||
|
"There is an internal exception occured in System, please kindly contact savvis support team to get solution.")
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testUnsupported() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-unsupported.xml");
|
||||||
|
|
||||||
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
Task expects = Task
|
||||||
|
.builder()
|
||||||
|
.id("6904-123")
|
||||||
|
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
|
||||||
|
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
|
||||||
|
.status(Task.Status.NONE)
|
||||||
|
.type("application/vnd.vmware.vcloud.task+xml")
|
||||||
|
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123"))
|
||||||
|
.error(
|
||||||
|
TaskError
|
||||||
|
.builder()
|
||||||
|
.vendorSpecificErrorCode("3000")
|
||||||
|
.minorErrorCode(-1)
|
||||||
|
.majorErrorCode(500)
|
||||||
|
.message(
|
||||||
|
"your requested task id is not found. Please contact Savvis Administrator for further assistance/clarification ")
|
||||||
|
.build()).build();
|
||||||
|
assertEquals(result.toString(), expects.toString());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,194 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jclouds.savvis.vpdc.xml;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.http.functions.ParseSax.Factory;
|
||||||
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.Resource;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC;
|
||||||
|
import org.jclouds.savvis.vpdc.domain.VDC.Status;
|
||||||
|
import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code VDCHandler}
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit")
|
||||||
|
public class VDCHandlerTest {
|
||||||
|
|
||||||
|
public void test() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/vdc.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
|
||||||
|
assertEquals(result.getName(), "demo_vpdcname");
|
||||||
|
assertEquals(result.getDescription(),
|
||||||
|
"ServiceProfileName = Balanced; ServiceLocation = North America; Email = jim@company.com;");
|
||||||
|
assertEquals(result.getStatus(), Status.DEPLOYED);
|
||||||
|
assertEquals(
|
||||||
|
result.getResourceEntities(),
|
||||||
|
ImmutableSet.<Resource> of(
|
||||||
|
new Resource(
|
||||||
|
"1001",
|
||||||
|
"DemoHost-1",
|
||||||
|
VCloudMediaType.VAPP_XML,
|
||||||
|
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001")),
|
||||||
|
new Resource(
|
||||||
|
"1002",
|
||||||
|
"DemoHost-2",
|
||||||
|
VCloudMediaType.VAPP_XML,
|
||||||
|
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002")),
|
||||||
|
new Resource(
|
||||||
|
"1003",
|
||||||
|
"DemoHost-3",
|
||||||
|
VCloudMediaType.VAPP_XML,
|
||||||
|
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003")),
|
||||||
|
new Resource(
|
||||||
|
"1234",
|
||||||
|
"CustomerTemplateName",
|
||||||
|
VCloudMediaType.VAPPTEMPLATE_XML,
|
||||||
|
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234")),
|
||||||
|
new Resource(
|
||||||
|
"FirewallService",
|
||||||
|
"firewall",
|
||||||
|
"api.symphonyvpdc.savvis.net+xml",
|
||||||
|
URI.create("https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService"))));
|
||||||
|
assertEquals(result.getAvailableNetworks(), ImmutableSet.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test1net() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/vdc-1net.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
|
||||||
|
assertEquals(result.getName(), "demo6");
|
||||||
|
assertEquals(result.getDescription(),
|
||||||
|
"ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;");
|
||||||
|
assertEquals(result.getStatus(), Status.DEPLOYED);
|
||||||
|
assertEquals(result.getResourceEntities(), ImmutableSet.of(
|
||||||
|
new Resource("1001", "Host1", VCloudMediaType.VAPP_XML, URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1001")),
|
||||||
|
new Resource("1002", "Host2", VCloudMediaType.VAPP_XML, URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1002")),
|
||||||
|
new Resource("1003", "Host3", VCloudMediaType.VAPP_XML, URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1003")),
|
||||||
|
new Resource("1004", "Host4", VCloudMediaType.VAPP_XML, URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1004"))));
|
||||||
|
assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource
|
||||||
|
.builder()
|
||||||
|
.id("VM-Tier01")
|
||||||
|
.name("VM Tier01")
|
||||||
|
.type(VCloudMediaType.NETWORK_XML)
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/network/VM-Tier01"))
|
||||||
|
.build()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFailed() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/vdc-failed.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
|
||||||
|
assertEquals(result.getName(), "Demo7");
|
||||||
|
assertEquals(result.getDescription(),
|
||||||
|
"ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;");
|
||||||
|
assertEquals(result.getStatus(), Status.FAILED);
|
||||||
|
assertEquals(result.getResourceEntities(), ImmutableSet.of(new Resource("1001", "Host1",
|
||||||
|
VCloudMediaType.VAPP_XML, URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/vApp/1001"))));
|
||||||
|
assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource
|
||||||
|
.builder()
|
||||||
|
.id("VM-Tier01")
|
||||||
|
.name("VM Tier01")
|
||||||
|
.type(VCloudMediaType.NETWORK_XML)
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/network/VM-Tier01"))
|
||||||
|
.build()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSaved() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/vdc-saved.xml");
|
||||||
|
Injector injector = Guice.createInjector(new SaxParserModule());
|
||||||
|
Factory factory = injector.getInstance(ParseSax.Factory.class);
|
||||||
|
VDC result = factory.create(injector.getInstance(VDCHandler.class)).parse(is);
|
||||||
|
assertEquals(result.getName(), "CloudBurst1");
|
||||||
|
assertEquals(result.getDescription(),
|
||||||
|
"ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = me@my.com;");
|
||||||
|
assertEquals(result.getStatus(), Status.SAVED);
|
||||||
|
assertEquals(
|
||||||
|
result.getResourceEntities(),
|
||||||
|
ImmutableSet.of(
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.name("templateHost")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.id("1001")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1001"))
|
||||||
|
.build(),
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.name("host-c501")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.id("1037")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1037"))
|
||||||
|
.build(),
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.name("host-c501")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.id("1038")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1038"))
|
||||||
|
.build(),
|
||||||
|
Resource
|
||||||
|
.builder()
|
||||||
|
.name("host-c601")
|
||||||
|
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||||
|
.id("1039")
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1039"))
|
||||||
|
.build()));
|
||||||
|
assertEquals(result.getAvailableNetworks(), ImmutableSet.of(Resource
|
||||||
|
.builder()
|
||||||
|
.id("VM-Tier01")
|
||||||
|
.name("VM Tier01")
|
||||||
|
.type(VCloudMediaType.NETWORK_XML)
|
||||||
|
.href(URI
|
||||||
|
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/network/VM-Tier01"))
|
||||||
|
.build()));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010 Cloud Conscious, LLC.
|
||||||
|
<info@cloudconscious.com>
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
applicable law or agreed to in writing, software distributed
|
||||||
|
under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions
|
||||||
|
and limitations under the License.
|
||||||
|
====================================================================
|
||||||
|
-->
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more configuration infromation and examples see the Apache
|
||||||
|
Log4j website: http://logging.apache.org/log4j/
|
||||||
|
-->
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||||
|
debug="false">
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-wire.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-compute.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="SSHFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds-ssh.log" />
|
||||||
|
<param name="Append" value="true" />
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE" />
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The full pattern: Date MS Priority [Category]
|
||||||
|
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||||
|
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="COMPUTEFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCSSH" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="SSHFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||||
|
<appender-ref ref="WIREFILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNC" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.headers">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.ssh">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCSSH" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.wire">
|
||||||
|
<priority value="DEBUG" />
|
||||||
|
<appender-ref ref="ASYNCWIRE" />
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<category name="jclouds.compute">
|
||||||
|
<priority value="TRACE" />
|
||||||
|
<appender-ref ref="ASYNCCOMPUTE" />
|
||||||
|
</category>
|
||||||
|
<!-- ======================= -->
|
||||||
|
<!-- Setup the Root category -->
|
||||||
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN" />
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Network xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="VM Tier01"
|
||||||
|
type="application/vnd.vmware.vcloud.network+xml">
|
||||||
|
<vApp:Configuration>
|
||||||
|
<vApp:Gateway>1.1.1.1</vApp:Gateway>
|
||||||
|
<vApp:Netmask>2.2.2.2</vApp:Netmask>
|
||||||
|
</vApp:Configuration>
|
||||||
|
<vApp:Features>
|
||||||
|
<vApp:FenceMode>allowInOut</vApp:FenceMode>
|
||||||
|
<vApp:Nat>
|
||||||
|
<vApp:NatRule internalIP="3.3.3.3" externalIP="4.4.4.4"/>
|
||||||
|
<vApp:NatRule internalIP="3.3.3.4" externalIP="4.4.4.5"/>
|
||||||
|
</vApp:Nat>
|
||||||
|
</vApp:Features>
|
||||||
|
</vApp:Network>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Network xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="VM Tier01"
|
||||||
|
type="application/vnd.vmware.vcloud.network+xml">
|
||||||
|
<vApp:Configuration>
|
||||||
|
<vApp:Gateway>0.0.0.0</vApp:Gateway>
|
||||||
|
<vApp:Netmask>0.0.0.0</vApp:Netmask>
|
||||||
|
</vApp:Configuration>
|
||||||
|
<vApp:Features>
|
||||||
|
<vApp:FenceMode>allowInOut</vApp:FenceMode>
|
||||||
|
</vApp:Features>
|
||||||
|
</vApp:Network>
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Network xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="VM-Tier01" type="application/vnd.vmware.vcloud.network+xml">
|
||||||
|
<vApp:Configuration>
|
||||||
|
<vApp:Gateway>1.1.1.1</vApp:Gateway>
|
||||||
|
<vApp:Netmask>255.255.255.240</vApp:Netmask>
|
||||||
|
</vApp:Configuration>
|
||||||
|
<vApp:Features>
|
||||||
|
<vApp:FenceMode>allowInOut</vApp:FenceMode>
|
||||||
|
</vApp:Features>
|
||||||
|
</vApp:Network>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:OrgList xmlns:vApp="http://www.vmware.com/vcloud/v0.8">
|
||||||
|
<vApp:Org name="SAVVISStation Integration Testing" type="application/vnd.vmware.vcloud.org+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0"/>
|
||||||
|
</vApp:OrgList>
|
@ -0,0 +1,26 @@
|
|||||||
|
<ovf:Item>
|
||||||
|
<rasd:Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:AddressOnParent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:AllocationUnits>Gigabytes</rasd:AllocationUnits>
|
||||||
|
<rasd:AutomaticAllocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:AutomaticDeallocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:Caption>1234568</rasd:Caption>
|
||||||
|
<rasd:ChangeableType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:ConfigurationName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:ConsumerVisibility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:Description>Hard Disk</rasd:Description>
|
||||||
|
<rasd:ElementName>D:\</rasd:ElementName>
|
||||||
|
<rasd:Generation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:HostResource>data</rasd:HostResource>
|
||||||
|
<rasd:InstanceID>6</rasd:InstanceID>
|
||||||
|
<rasd:Limit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:MappingBehavior xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:OtherResourceType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:Parent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:PoolID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:Reservation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:ResourceSubType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
<rasd:ResourceType>26</rasd:ResourceType>
|
||||||
|
<rasd:VirtualQuantity>50</rasd:VirtualQuantity>
|
||||||
|
<rasd:Weight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
|
||||||
|
</ovf:Item>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<vApp:Task endTime="2010-05-26T08:09:09.000+08:00" startTime="2010-05-26T08:08:08.000+08:00" status="error">
|
||||||
|
<vApp:Error vendorSpecificErrorCode="0" minorErrorCode="0" majorErrorCode="0"
|
||||||
|
message="There is an internal exception occured in System, please kindly contact savvis support team to get solution."/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<vApp:Task endTime="2010-05-26T08:09:09.000+08:00" startTime="2010-05-26T08:08:08.000+08:00" status="error"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml" href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123">
|
||||||
|
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
|
||||||
|
<vApp:Result name="mock_vpdc_item_007" type="application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<!--If Task status is queued, Savvis is not displaying endTime.-->
|
||||||
|
<vApp:Task startTime="2010-05-26T08:08:08.000+08:00" status="queued" type="application/vnd.vmware.vcloud.task+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904">
|
||||||
|
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
|
||||||
|
<vApp:Result name="mock_vpdc_item_007" type="application/vnd.vmware.vcloud.catalogItem+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<!--If Task status is running, Savvis is not displaying endTime.-->
|
||||||
|
<vApp:Task startTime="2010-05-26T08:08:08.000+08:00" status="running" type="application/vnd.vmware.vcloud.task+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904">
|
||||||
|
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
|
||||||
|
<vApp:Result name="mock_vpdc_item_007" type="application/vnd.vmware.vcloud.catalogItem+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<vApp:Task endTime="2010-05-26T08:09:09.000+08:00" startTime="2010-05-26T08:08:08.000+08:00" status="None"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml" href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/3904-1002">
|
||||||
|
<vApp:Error vendorSpecificErrorCode="3000" minorErrorCode="-1" majorErrorCode="500"
|
||||||
|
message="your requested task id is not found. Please contact Savvis Administrator for further assistance/clarification "/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<vApp:Task endTime="2010-05-26T08:09:09.000+08:00" startTime="2010-05-26T08:08:08.000+08:00" status="success"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml" href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002">
|
||||||
|
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
|
||||||
|
<vApp:Result name="mock_vpdc_item_007" type="application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
|
||||||
|
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
|
||||||
|
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
|
||||||
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
|
||||||
|
<vApp:Task endTime="2010-05-26T08:09:09.000+08:00" startTime="2010-05-26T08:08:08.000+08:00" status="success"
|
||||||
|
type="application/vnd.vmware.vcloud.task+xml" href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002">
|
||||||
|
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
|
||||||
|
<vApp:Result name="mock_vpdc_item_008" type="application/vnd.vmware.vcloud.vApp+xml"
|
||||||
|
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/vdc/2736/vmdk/1234567"/>
|
||||||
|
</vApp:Task>
|
||||||
|
</vApp:TasksList>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Vdc xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="demo6" type="application/vnd.vmware.vcloud.vdc+xml">
|
||||||
|
<vApp:Description>ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;</vApp:Description>
|
||||||
|
<vApp:OfferingTag>Deployed</vApp:OfferingTag>
|
||||||
|
<vApp:ResourceEntities>
|
||||||
|
<vApp:ResourceEntity name="Host1" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1001"/>
|
||||||
|
<vApp:ResourceEntity name="Host2" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1002"/>
|
||||||
|
<vApp:ResourceEntity name="Host3" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1003"/>
|
||||||
|
<vApp:ResourceEntity name="Host4" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/vApp/1004"/>
|
||||||
|
</vApp:ResourceEntities>
|
||||||
|
<vApp:AvailableNetworks>
|
||||||
|
<vApp:Network name="VM Tier01" type="application/vnd.vmware.vcloud.network+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1619/network/VM-Tier01"/>
|
||||||
|
</vApp:AvailableNetworks>
|
||||||
|
</vApp:Vdc>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Vdc xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="Demo7" type="application/vnd.vmware.vcloud.vdc+xml">
|
||||||
|
<vApp:Description>ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = red@chair.com;</vApp:Description>
|
||||||
|
<vApp:OfferingTag>Failed</vApp:OfferingTag>
|
||||||
|
<vApp:ResourceEntities>
|
||||||
|
<vApp:ResourceEntity name="Host1" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/vApp/1001"/>
|
||||||
|
</vApp:ResourceEntities>
|
||||||
|
<vApp:AvailableNetworks>
|
||||||
|
<vApp:Network name="VM Tier01" type="application/vnd.vmware.vcloud.network+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/1641/network/VM-Tier01"/>
|
||||||
|
</vApp:AvailableNetworks>
|
||||||
|
</vApp:Vdc>
|
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<vApp:Vdc xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="CloudBurst1" type="application/vnd.vmware.vcloud.vdc+xml">
|
||||||
|
<vApp:Description>ServiceProfileName = Essential; ServiceLocation = US_WEST; Email = me@my.com;</vApp:Description>
|
||||||
|
<vApp:OfferingTag>Saved</vApp:OfferingTag>
|
||||||
|
<vApp:ResourceEntities>
|
||||||
|
<vApp:ResourceEntity name="templateHost" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1001"/>
|
||||||
|
<vApp:ResourceEntity name="host-c501" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1037"/>
|
||||||
|
<vApp:ResourceEntity name="host-c501" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1038"/>
|
||||||
|
<vApp:ResourceEntity name="host-c601" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/vApp/1039"/>
|
||||||
|
</vApp:ResourceEntities>
|
||||||
|
<vApp:AvailableNetworks>
|
||||||
|
<vApp:Network name="VM Tier01" type="application/vnd.vmware.vcloud.network+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/2555/network/VM-Tier01"/>
|
||||||
|
</vApp:AvailableNetworks>
|
||||||
|
</vApp:Vdc>
|
@ -7,7 +7,7 @@
|
|||||||
<vApp:ResourceEntity name="DemoHost-2" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
<vApp:ResourceEntity name="DemoHost-2" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
|
||||||
<vApp:ResourceEntity name="DemoHost-3" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003"/>
|
<vApp:ResourceEntity name="DemoHost-3" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1003"/>
|
||||||
<vApp:ResourceEntity name="CustomerTemplateName" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234"/>
|
<vApp:ResourceEntity name="CustomerTemplateName" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vAppTemplate/1234"/>
|
||||||
<vApp:ResourceEntity name="firewall" type="api.sandbox.symphonyVPDC.savvis.net+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService"/>
|
<vApp:ResourceEntity name="firewall" type="api.symphonyvpdc.savvis.net+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/FirewallService"/>
|
||||||
</vApp:ResourceEntities>
|
</vApp:ResourceEntities>
|
||||||
<vApp:AvailableNetworks/>
|
<vApp:AvailableNetworks/>
|
||||||
</vApp:Vdc>
|
</vApp:Vdc>
|
Loading…
x
Reference in New Issue
Block a user