cleaned up org and vdc for savvis

This commit is contained in:
Adrian Cole 2011-03-04 18:23:16 -05:00
parent 16304e5301
commit 87f6bdcce8
14 changed files with 926 additions and 86 deletions

View File

@ -117,43 +117,43 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
public void endElement(String uri, String name, String qName) {
taskHandler.endElement(uri, name, qName);
if (qName.equals("Task")) {
if (qName.endsWith("Task")) {
this.tasks.add(taskHandler.getResult());
} else if (qName.equals("Description")) {
} else if (qName.endsWith("Description")) {
description = currentOrNull();
} else if (qName.equals("AllocationModel")) {
} else if (qName.endsWith("AllocationModel")) {
allocationModel = AllocationModel.fromValue(currentOrNull());
} else if (qName.equals("Units")) {
} else if (qName.endsWith("Units")) {
units = currentOrNull();
} else if (qName.equals("Allocated")) {
} else if (qName.endsWith("Allocated")) {
allocated = Integer.parseInt(currentOrNull());
} else if (qName.equals("Used")) {
} else if (qName.endsWith("Used")) {
used = Integer.parseInt(currentOrNull());
} else if (qName.equals("Limit")) {
} else if (qName.endsWith("Limit")) {
limit = Integer.parseInt(currentOrNull());
} else if (qName.equals("Overhead")) {
} else if (qName.endsWith("Overhead")) {
overhead = Integer.parseInt(currentOrNull());
} else if (qName.equals("StorageCapacity")) {
} else if (qName.endsWith("StorageCapacity")) {
storageCapacity = new Capacity(units, allocated, limit, used, overhead);
resetCapacity();
} else if (qName.equals("Cpu")) {
} else if (qName.endsWith("Cpu")) {
cpuCapacity = new Capacity(units, allocated, limit, used, overhead);
resetCapacity();
} else if (qName.equals("Memory")) {
} else if (qName.endsWith("Memory")) {
memoryCapacity = new Capacity(units, allocated, limit, used, overhead);
resetCapacity();
} else if (qName.equals("DeployedVmsQuota")) {
} else if (qName.endsWith("DeployedVmsQuota")) {
vmQuota = (int) limit;
// vcloud express doesn't have the zero is unlimited rule
if (vmQuota == -1)
vmQuota = 0;
} else if (qName.equals("VmQuota")) {
} else if (qName.endsWith("VmQuota")) {
vmQuota = Integer.parseInt(currentOrNull());
} else if (qName.equals("NicQuota")) {
} else if (qName.endsWith("NicQuota")) {
nicQuota = Integer.parseInt(currentOrNull());
} else if (qName.equals("NetworkQuota")) {
} else if (qName.endsWith("NetworkQuota")) {
networkQuota = Integer.parseInt(currentOrNull());
} else if (qName.equals("IsEnabled")) {
} else if (qName.endsWith("IsEnabled")) {
isEnabled = Boolean.parseBoolean(currentOrNull());
}
currentText = new StringBuilder();

View File

@ -23,26 +23,53 @@ 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.VDC;
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.VDCHandler;
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;
@ -59,86 +86,278 @@ public interface SymphonyVPDCAsyncClient extends VCloudExpressAsyncClient {
/**
* {@inheritDoc}
*/
// savvis doesn't work with accept header
@Override
@GET
// no accept header
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Override
ListenableFuture<? extends Org> findOrgNamed(
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
@Nullable @EndpointParam(parser = OrgNameToEndpoint.class) String orgName);
/**
* {@inheritDoc}
*/
// savvis doesn't work with accept header
@Override
@GET
// no accept header
@XMLResponseParser(OrgHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Override
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgId);
/**
* @see CommonVCloudClient#getVDC(URI)
*/
@GET
@XMLResponseParser(VDCHandler.class)
// no accept header
@XMLResponseParser(SymphonyVPDCVDCHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> getVDC(@EndpointParam URI vdc);
@Override
ListenableFuture<? extends SymphonyVPDCVDC> getVDC(@EndpointParam URI vdc);
/**
* @see CommonVCloudClient#findVDCInOrgNamed(String, String)
*/
@GET
@XMLResponseParser(VDCHandler.class)
// no accept header
@XMLResponseParser(SymphonyVPDCVDCHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends VDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
/**
* @see CommonVCloudClient#findNetworkInOrgVDCNamed
*//*
@GET
@XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends OrgNetwork> findNetworkInOrgVDCNamed(
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String catalogName,
@EndpointParam(parser = OrgNameVDCNameResourceEntityNameToEndpoint.class) String networkName);
@Override
ListenableFuture<? extends SymphonyVPDCVDC> findVDCInOrgNamed(
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
*//**
* @see CommonVCloudClient#getNetwork
*//*
@GET
@XMLResponseParser(TerremarkOrgNetworkFromTerremarkVCloudExpressNetworkHandler.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<? extends OrgNetwork> getNetwork(@EndpointParam URI network);*/
/**
* @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);
@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);
}

View File

@ -19,9 +19,11 @@
package org.jclouds.savvis.vpdc;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.savvis.vpdc.domain.SymphonyVPDCVDC;
import org.jclouds.vcloud.VCloudExpressClient;
/**
@ -33,5 +35,9 @@ import org.jclouds.vcloud.VCloudExpressClient;
*/
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
public interface SymphonyVPDCClient extends VCloudExpressClient {
@Override
SymphonyVPDCVDC findVDCInOrgNamed(String orgName, String vdcName);
@Override
SymphonyVPDCVDC getVDC(URI vdc);
}

View File

@ -0,0 +1,34 @@
/**
*
* 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 org.jclouds.savvis.vpdc.domain.internal.SymphonyVPDCVDCImpl;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VDC;
import com.google.inject.ImplementedBy;
/**
* @author Adrian Cole
*/
@ImplementedBy(SymphonyVPDCVDCImpl.class)
public interface SymphonyVPDCVDC extends VDC {
String getOfferingTag();
}

View File

@ -0,0 +1,75 @@
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 + "]";
}
}

View File

@ -0,0 +1,58 @@
/**
*
* 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);
}
}

View File

@ -50,9 +50,9 @@ 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.VCloudExpressAsyncClient;
import org.jclouds.vcloud.VCloudExpressLoginAsyncClient;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
@ -77,7 +77,6 @@ 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.jclouds.vcloud.xml.VDCHandler;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
@ -104,7 +103,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hosting.xml")).replace(
@ -136,7 +135,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request,
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/newvapp-hostingcpumemdisk.xml"))
.replace("vcloud.safesecureweb.com/api", "api.sandbox.symphonyVPDC.savvis.net/rest/api"),
@ -176,7 +175,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream("/express/cloneVApp-default.xml")).replace(
@ -200,7 +199,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
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);
@ -250,7 +249,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -266,7 +265,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalog/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -300,7 +299,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -317,7 +316,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/catalogItem/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -334,7 +333,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -351,7 +350,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vAppTemplate/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -370,7 +369,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
@ -397,7 +396,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
@ -412,7 +411,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
@ -428,7 +427,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, VDCHandler.class);
assertSaxResponseParserClassEquals(method, SymphonyVPDCVDCHandler.class);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
@ -441,7 +440,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"GET https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/tasksList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -452,12 +451,12 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
}
public void testFindTasksListInOrgNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = VCloudExpressAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class);
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, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -474,7 +473,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/deploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -507,7 +506,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/action/undeploy HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -541,7 +540,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -558,7 +557,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -575,7 +574,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -592,7 +591,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
assertRequestLineEquals(request,
"POST https://api.sandbox.symphonyVPDC.savvis.net/rest/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -625,7 +624,7 @@ public class SymphonyVPDCAsyncClientTest extends RestClientTest<SymphonyVPDCAsyn
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, "Accept: application/vnd.vmware.vcloud.task+xml\n");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);

View File

@ -19,14 +19,48 @@
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.compute.ComputeServiceContextFactory;
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 {
@ -46,9 +80,247 @@ public class SymphonyVPDCClientLiveTest extends VCloudExpressClientLiveTest {
restProperties.setProperty("savvis-symphony-vpdc.propertiesbuilder",
SymphonyVPDCPropertiesBuilder.class.getName());
context = new ComputeServiceContextFactory(restProperties).createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
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());
}
connection = context.getApi();
}
}

View File

@ -32,7 +32,7 @@ import org.testng.annotations.Test;
*
* @author Kedar Dave
*/
@Test(groups = "live", enabled = true, sequential = true)
@Test(groups = "live", enabled = false, sequential = true)
public class SymphonyVPDCComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public SymphonyVPDCComputeServiceLiveTest() {
provider = "savvis-symphony-vpdc";

View File

@ -28,7 +28,7 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
@Test(groups = "live")
@Test(groups = "live", enabled = false)
public class SymphonyVPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
public SymphonyVPDCTemplateBuilderLiveTest() {

View File

@ -0,0 +1,66 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.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.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
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 com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Tests behavior of {@code OrgHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit")
public class OrgHandlerTest {
public void testSavvis() {
InputStream is = getClass().getResourceAsStream("/savvis/org.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(
result,
new OrgImpl("100000.0", null, null, "100000.0", "SAVVISStation Integration Testing", ImmutableMap
.<String, ReferenceType> of(), ImmutableMap.<String, ReferenceType> of(
"demo_vpdcname",
new ReferenceTypeImpl("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"))),
ImmutableMap.<String, ReferenceType> of(), null, ImmutableSet.<Task> of()));
}
}

View File

@ -0,0 +1,93 @@
/**
*
* 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());
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vApp:Org 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="100000.0">
<vApp:Link name="demo_vpdcname" type="application/vnd.vmware.vcloud.vdc+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736" rel="down"/>
<vApp:Description>SAVVISStation Integration Testing</vApp:Description>
</vApp:Org>

View File

@ -0,0 +1,13 @@
<?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="demo_vpdcname" type="application/vnd.vmware.vcloud.vdc+xml">
<vApp:Description>ServiceProfileName = Balanced; ServiceLocation = North America; Email = jim@company.com;</vApp:Description>
<vApp:OfferingTag>Deployed</vApp:OfferingTag>
<vApp:ResourceEntities>
<vApp:ResourceEntity name="DemoHost-1" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.sandbox.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1001"/>
<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="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:ResourceEntities>
<vApp:AvailableNetworks/>
</vApp:Vdc>