mirror of https://github.com/apache/jclouds.git
Issue 306: revised vdc, instantiate, and clone to accept org/vdc name parameters
This commit is contained in:
parent
1ec0c40c95
commit
d8a8c38e4f
|
@ -64,6 +64,7 @@ import org.jclouds.vcloud.domain.VAppTemplate;
|
|||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.VAppIdToUri;
|
||||
import org.jclouds.vcloud.functions.VAppTemplateIdToUri;
|
||||
|
@ -197,6 +198,17 @@ public interface VCloudAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#getVDCInOrg(String, String)
|
||||
*/
|
||||
@GET
|
||||
@XMLResponseParser(VDCHandler.class)
|
||||
@Consumes(VDC_XML)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends VDC> getVDCInOrg(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#getVDC(URI)
|
||||
*/
|
||||
|
@ -333,9 +345,26 @@ public interface VCloudAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends VApp> getVApp(@PathParam("vAppId") String appId);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#instantiateVAppTemplate
|
||||
*/
|
||||
@POST
|
||||
@Path("/action/instantiateVAppTemplate")
|
||||
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
||||
@Consumes(VAPP_XML)
|
||||
@XMLResponseParser(VAppHandler.class)
|
||||
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||
ListenableFuture<? extends VApp> instantiateVAppTemplateInOrg(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName,
|
||||
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
|
||||
@MapPayloadParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#instantiateVAppTemplateInVDC
|
||||
*/
|
||||
@Deprecated
|
||||
@POST
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/vdc/{vDCId}/action/instantiateVAppTemplate")
|
||||
|
@ -349,9 +378,26 @@ public interface VCloudAsyncClient {
|
|||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#cloneVAppInVDC
|
||||
* @see VCloudClient#cloneVApp
|
||||
*/
|
||||
@POST
|
||||
@Path("/action/cloneVApp")
|
||||
@Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
|
||||
@Consumes(TASK_XML)
|
||||
@XMLResponseParser(TaskHandler.class)
|
||||
@MapBinder(BindCloneVAppParamsToXmlPayload.class)
|
||||
ListenableFuture<? extends Task> cloneVAppInOrg(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName,
|
||||
@MapPayloadParam("vApp") @ParamParser(VAppIdToUri.class) String vAppIdToClone,
|
||||
@MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
|
||||
CloneVAppOptions... options);
|
||||
|
||||
/**
|
||||
* - * @see VCloudClient#cloneVAppInVDC
|
||||
*/
|
||||
@Deprecated
|
||||
@POST
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/vdc/{vDCId}/action/cloneVApp")
|
||||
@Produces("application/vnd.vmware.vcloud.cloneVAppParams+xml")
|
||||
|
@ -362,4 +408,5 @@ public interface VCloudAsyncClient {
|
|||
@MapPayloadParam("vApp") @ParamParser(VAppIdToUri.class) String vAppIdToClone,
|
||||
@MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
|
||||
CloneVAppOptions... options);
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -56,8 +57,8 @@ public interface VCloudClient {
|
|||
Organization getOrganization(String orgId);
|
||||
|
||||
/**
|
||||
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and task lists within
|
||||
* the organization.
|
||||
* This call returns a list of all vCloud Data Centers (vdcs), catalogs, and
|
||||
* task lists within the organization.
|
||||
*
|
||||
* @param name
|
||||
* organization name, or null for the default
|
||||
|
@ -80,6 +81,8 @@ public interface VCloudClient {
|
|||
@Deprecated
|
||||
VDC getVDC(String vDCId);
|
||||
|
||||
VDC getVDCInOrg(String orgName, String vdcName);
|
||||
|
||||
VDC getVDC(URI vdc);
|
||||
|
||||
VDC getDefaultVDC();
|
||||
|
@ -95,12 +98,14 @@ public interface VCloudClient {
|
|||
Task undeployVApp(String vAppId);
|
||||
|
||||
/**
|
||||
* This call powers on the vApp, as specified in the vApp's ovf:Startup element.
|
||||
* This call powers on the vApp, as specified in the vApp's ovf:Startup
|
||||
* element.
|
||||
*/
|
||||
Task powerOnVApp(String vAppId);
|
||||
|
||||
/**
|
||||
* This call powers off the vApp, as specified in the vApp's ovf:Startup element.
|
||||
* This call powers off the vApp, as specified in the vApp's ovf:Startup
|
||||
* element.
|
||||
*/
|
||||
Task powerOffVApp(String vAppId);
|
||||
|
||||
|
@ -125,8 +130,16 @@ public interface VCloudClient {
|
|||
|
||||
VApp getVApp(String appId);
|
||||
|
||||
@Deprecated
|
||||
VApp instantiateVAppTemplateInVDC(String vDCId, String appName, String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
VApp instantiateVAppTemplateInOrg(String org, String vdc, String appName, String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
@Deprecated
|
||||
Task cloneVAppInVDC(String vDCId, String vAppIdToClone, String newName, CloneVAppOptions... options);
|
||||
|
||||
Task cloneVAppInOrg(String org, String vdc, String vAppIdToClone, String newName, CloneVAppOptions... options);
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -65,13 +66,13 @@ public class BaseVCloudComputeClient implements VCloudComputeClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> start(String vDCId, String name, String templateId,
|
||||
public Map<String, String> start(@Nullable String orgName, @Nullable String vDCName, String name, String templateId,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||
checkNotNull(options, "options");
|
||||
logger
|
||||
.debug(">> instantiating vApp vDC(%s) name(%s) template(%s) options(%s) ", vDCId, name, templateId, options);
|
||||
logger.debug(">> instantiating vApp org(%s) vDC(%s) name(%s) template(%s) options(%s) ", orgName, vDCName, name,
|
||||
templateId, options);
|
||||
|
||||
VApp vAppResponse = client.instantiateVAppTemplateInVDC(vDCId, name, templateId, options);
|
||||
VApp vAppResponse = client.instantiateVAppTemplateInOrg(orgName, vDCName, name, templateId, options);
|
||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
||||
|
||||
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.vcloud.compute;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
@ -32,15 +34,19 @@ import com.google.inject.ImplementedBy;
|
|||
@ImplementedBy(BaseVCloudComputeClient.class)
|
||||
public interface VCloudComputeClient {
|
||||
/**
|
||||
* Runs through all commands necessary to startup a vApp, opening at least one ip address to the
|
||||
* public network. These are the steps:
|
||||
* Runs through all commands necessary to startup a vApp, opening at least
|
||||
* one ip address to the public network. These are the steps:
|
||||
* <p/>
|
||||
* instantiate -> deploy -> powerOn
|
||||
* <p/>
|
||||
* This command blocks until the vApp is in state {@code VAppStatus#ON}
|
||||
*
|
||||
* @param vDCId
|
||||
* id of the virtual datacenter {@code VCloudClient#getDefaultVDC}
|
||||
* @param orgName
|
||||
* name of the organization
|
||||
*
|
||||
* @param vDCName
|
||||
* name of the virtual datacenter {@code
|
||||
* VCloudClient#getDefaultVDC}
|
||||
* @param name
|
||||
* name of the vApp
|
||||
* @param templateId
|
||||
|
@ -55,12 +61,12 @@ public interface VCloudComputeClient {
|
|||
* opens the following ports on the public ip address
|
||||
* @return map contains at least the following properties
|
||||
* <ol>
|
||||
* <li>id - vApp id</li> <li>username - console login user</li> <li>password - console
|
||||
* login password</li>
|
||||
* <li>id - vApp id</li> <li>username - console login user</li> <li>
|
||||
* password - console login password</li>
|
||||
* </ol>
|
||||
*/
|
||||
Map<String, String> start(String vDCId, String name, String templateId,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen);
|
||||
Map<String, String> start(@Nullable String orgName, @Nullable String vDCName, String name, String templateId,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen);
|
||||
|
||||
/**
|
||||
* returns a set of addresses that are only visible to the private network.
|
||||
|
@ -73,7 +79,8 @@ public interface VCloudComputeClient {
|
|||
Set<String> getPublicAddresses(String vAppId);
|
||||
|
||||
/**
|
||||
* reboots the vApp, blocking until the following state transition is complete:
|
||||
* reboots the vApp, blocking until the following state transition is
|
||||
* complete:
|
||||
* <p/>
|
||||
* current -> {@code VAppStatus#OFF} -> {@code VAppStatus#ON}
|
||||
*
|
||||
|
@ -83,8 +90,8 @@ public interface VCloudComputeClient {
|
|||
void reboot(String vAppId);
|
||||
|
||||
/**
|
||||
* Destroys dependent resources, powers off and deletes the vApp, blocking until the following
|
||||
* state transition is complete:
|
||||
* Destroys dependent resources, powers off and deletes the vApp, blocking
|
||||
* until the following state transition is complete:
|
||||
* <p/>
|
||||
* current -> {@code VAppStatus#OFF} -> deleted
|
||||
*
|
||||
|
|
|
@ -69,8 +69,8 @@ import com.google.inject.TypeLiteral;
|
|||
import com.google.inject.util.Providers;
|
||||
|
||||
/**
|
||||
* Configures the {@link VCloudComputeServiceContext}; requires {@link BaseVCloudComputeClient}
|
||||
* bound.
|
||||
* Configures the {@link VCloudComputeServiceContext}; requires
|
||||
* {@link BaseVCloudComputeClient} bound.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -80,8 +80,8 @@ public class VCloudComputeServiceContextModule extends AbstractModule {
|
|||
@Provides
|
||||
Map<VAppStatus, NodeState> provideVAppStatusToNodeState() {
|
||||
return ImmutableMap.<VAppStatus, NodeState> builder().put(VAppStatus.OFF, NodeState.SUSPENDED).put(VAppStatus.ON,
|
||||
NodeState.RUNNING).put(VAppStatus.RESOLVED, NodeState.PENDING).put(VAppStatus.SUSPENDED,
|
||||
NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED, NodeState.PENDING).build();
|
||||
NodeState.RUNNING).put(VAppStatus.RESOLVED, NodeState.PENDING).put(VAppStatus.SUSPENDED,
|
||||
NodeState.SUSPENDED).put(VAppStatus.UNRESOLVED, NodeState.PENDING).build();
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -151,7 +151,7 @@ public class VCloudComputeServiceContextModule extends AbstractModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
Location getVDC(VCloudClient client, Set<? extends Location> locations) {
|
||||
final String vdc = client.getDefaultVDC().getId();
|
||||
final String vdc = client.getDefaultVDC().getName();
|
||||
return Iterables.find(locations, new Predicate<Location>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.compute.config.providers;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -27,9 +28,9 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.domain.internal.LocationImpl;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient.VCloudSession;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -39,16 +40,17 @@ import com.google.common.collect.Sets;
|
|||
*/
|
||||
@Singleton
|
||||
public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Location>> {
|
||||
private final Supplier<VCloudSession> cache;
|
||||
private final VCloudClient client;
|
||||
private final String providerName;
|
||||
private final Supplier<Map<String, NamedResource>> orgNameToResource;
|
||||
private final Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCResource;
|
||||
|
||||
@Inject
|
||||
OrgAndVDCToLocationProvider(@org.jclouds.rest.annotations.Provider String providerName,
|
||||
Supplier<VCloudSession> cache, VCloudClient client) {
|
||||
@Org Supplier<Map<String, NamedResource>> orgNameToResource,
|
||||
@VDC Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCResource) {
|
||||
this.providerName = providerName;
|
||||
this.cache = cache;
|
||||
this.client = client;
|
||||
this.orgNameToResource = orgNameToResource;
|
||||
this.orgNameToVDCResource = orgNameToVDCResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,11 +58,11 @@ public class OrgAndVDCToLocationProvider implements Provider<Set<? extends Locat
|
|||
Location provider = new LocationImpl(LocationScope.PROVIDER, providerName, providerName, null);
|
||||
Set<Location> locations = Sets.newLinkedHashSet();
|
||||
|
||||
for (NamedResource org : cache.get().getOrgs().values()) {
|
||||
for (NamedResource org : orgNameToResource.get().values()) {
|
||||
Location orgL = new LocationImpl(LocationScope.REGION, org.getName(), org.getLocation().toASCIIString(),
|
||||
provider);
|
||||
for (NamedResource vdc : client.getOrganizationNamed(org.getName()).getVDCs().values()) {
|
||||
locations.add(new LocationImpl(LocationScope.ZONE, vdc.getId(), vdc.getName(), orgL));
|
||||
for (NamedResource vdc : orgNameToVDCResource.get().get(org.getName()).values()) {
|
||||
locations.add(new LocationImpl(LocationScope.ZONE, vdc.getName(), vdc.getLocation().toASCIIString(), orgL));
|
||||
}
|
||||
}
|
||||
return locations;
|
||||
|
|
|
@ -57,14 +57,14 @@ public class FindLocationForResource {
|
|||
public Location apply(NamedResource resource) {
|
||||
for (Location input : locations.get()) {
|
||||
do {
|
||||
if (input.getId().equals(resource.getName()))
|
||||
return input;
|
||||
else if (input.getId().equals(resource.getId()))
|
||||
// The "name" isn't always present, ex inside a vApp we have a rel
|
||||
// link that only includes href and type.
|
||||
if (input.getDescription().equals(resource.getLocation().toASCIIString()))
|
||||
return input;
|
||||
input = input.getParent();
|
||||
} while (input.getParent() != null);
|
||||
}
|
||||
throw new NoSuchElementException(String.format("resource: %s not found in locations: %s", resource, locations
|
||||
.get()));
|
||||
.get()));
|
||||
}
|
||||
}
|
|
@ -49,8 +49,7 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
|||
protected final Map<VAppStatus, NodeState> vAppStatusToNodeState;
|
||||
|
||||
@Inject
|
||||
protected VCloudAddNodeWithTagStrategy(VCloudClient client,
|
||||
VCloudComputeClient computeClient,
|
||||
protected VCloudAddNodeWithTagStrategy(VCloudClient client, VCloudComputeClient computeClient,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
this.client = client;
|
||||
this.computeClient = computeClient;
|
||||
|
@ -59,29 +58,23 @@ public class VCloudAddNodeWithTagStrategy implements AddNodeWithTagStrategy {
|
|||
|
||||
@Override
|
||||
public NodeMetadata execute(String tag, String name, Template template) {
|
||||
InstantiateVAppTemplateOptions options = processorCount(
|
||||
Double.valueOf(template.getSize().getCores()).intValue()).memory(
|
||||
template.getSize().getRam()).disk(
|
||||
template.getSize().getDisk() * 1024 * 1024l);
|
||||
InstantiateVAppTemplateOptions options = processorCount(Double.valueOf(template.getSize().getCores()).intValue())
|
||||
.memory(template.getSize().getRam()).disk(template.getSize().getDisk() * 1024 * 1024l);
|
||||
if (!template.getOptions().shouldBlockUntilRunning())
|
||||
options.blockOnDeploy(false);
|
||||
Map<String, String> metaMap = computeClient.start(template.getLocation()
|
||||
.getId(), name, template.getImage().getProviderId(), options,
|
||||
template.getOptions().getInboundPorts());
|
||||
Map<String, String> metaMap = computeClient.start(template.getLocation().getParent().getId(), template
|
||||
.getLocation().getId(), name, template.getImage().getProviderId(), options, template.getOptions()
|
||||
.getInboundPorts());
|
||||
VApp vApp = client.getVApp(metaMap.get("id"));
|
||||
return newCreateNodeResponse(tag, template, metaMap, vApp);
|
||||
}
|
||||
|
||||
protected NodeMetadata newCreateNodeResponse(String tag, Template template,
|
||||
Map<String, String> metaMap, VApp vApp) {
|
||||
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(),
|
||||
template.getLocation(), vApp.getLocation(), ImmutableMap
|
||||
.<String, String> of(), tag, template.getImage(),
|
||||
vAppStatusToNodeState.get(vApp.getStatus()), computeClient
|
||||
.getPublicAddresses(vApp.getId()), computeClient
|
||||
.getPrivateAddresses(vApp.getId()), ImmutableMap
|
||||
.<String, String> of(), new Credentials(metaMap
|
||||
.get("username"), metaMap.get("password")));
|
||||
protected NodeMetadata newCreateNodeResponse(String tag, Template template, Map<String, String> metaMap, VApp vApp) {
|
||||
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vApp.getId(), template.getLocation(), vApp
|
||||
.getLocation(), ImmutableMap.<String, String> of(), tag, template.getImage(), vAppStatusToNodeState
|
||||
.get(vApp.getStatus()), computeClient.getPublicAddresses(vApp.getId()), computeClient
|
||||
.getPrivateAddresses(vApp.getId()), ImmutableMap.<String, String> of(), new Credentials(metaMap
|
||||
.get("username"), metaMap.get("password")));
|
||||
}
|
||||
|
||||
}
|
|
@ -34,7 +34,8 @@ import com.google.inject.ImplementedBy;
|
|||
public interface NamedResource extends Comparable<NamedResource> {
|
||||
|
||||
/**
|
||||
* name is not a safe means to identify a resource. Please use name.
|
||||
* name is not a safe means to identify a resource. Please use name or
|
||||
* location
|
||||
*/
|
||||
@Deprecated
|
||||
String getId();
|
||||
|
|
|
@ -106,7 +106,6 @@ public class NamedResourceImpl implements NamedResource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NamedResourceImpl [id=" + id + ", name=" + name + ", type=" + type + ", location="
|
||||
+ location + "]";
|
||||
return "[id=" + id + ", name=" + name + ", type=" + type + ", location=" + location + "]";
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class OrganizationImpl implements Organization {
|
|||
private final Map<String, NamedResource> tasksLists;
|
||||
|
||||
public OrganizationImpl(String id, String name, URI location, Map<String, NamedResource> catalogs,
|
||||
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
|
||||
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.location = location;
|
||||
|
@ -143,4 +143,8 @@ public class OrganizationImpl implements Organization {
|
|||
return (this == o) ? 0 : getId().compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", name=" + name + ", type=" + getType() + ", location=" + location + "]";
|
||||
}
|
||||
}
|
|
@ -51,8 +51,7 @@ public class AllCatalogsInOrganization implements Function<Organization, Iterabl
|
|||
private final ExecutorService executor;
|
||||
|
||||
@Inject
|
||||
AllCatalogsInOrganization(VCloudAsyncClient aclient,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
AllCatalogsInOrganization(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.aclient = aclient;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
@ -68,8 +67,7 @@ public class AllCatalogsInOrganization implements Function<Organization, Iterabl
|
|||
return (Future<Catalog>) aclient.getCatalog(from.getId());
|
||||
}
|
||||
|
||||
}, executor, null, logger, "catalogs in " + from.getId());
|
||||
}, executor, null, logger, "catalogs in " + from.getName());
|
||||
return catalogItems;
|
||||
}
|
||||
|
||||
}
|
|
@ -57,17 +57,17 @@ public class AllVDCsInOrganization implements Function<Organization, Iterable<?
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends VDC> apply(Organization from) {
|
||||
public Iterable<? extends VDC> apply(final Organization org) {
|
||||
|
||||
Iterable<VDC> catalogItems = transformParallel(from.getVDCs().values(),
|
||||
new Function<NamedResource, Future<VDC>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<VDC> apply(NamedResource from) {
|
||||
return (Future<VDC>) aclient.getVDC(from.getId());
|
||||
}
|
||||
Iterable<VDC> catalogItems = transformParallel(org.getVDCs().values(),
|
||||
new Function<NamedResource, Future<VDC>>() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Future<VDC> apply(NamedResource from) {
|
||||
return (Future<VDC>) aclient.getVDCInOrg(org.getName(), from.getName());
|
||||
}
|
||||
|
||||
}, executor, null, logger, "vdcs in " + from.getId());
|
||||
}, executor, null, logger, "vdcs in " + org.getName());
|
||||
return catalogItems;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.vcloud.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.vcloud.domain.NamedResource;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.endpoints.VDC;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class OrgNameAndVDCNameToEndpoint implements Function<Object, URI> {
|
||||
private final Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCEndpoint;
|
||||
private final String defaultOrg;
|
||||
private final URI defaultUri;
|
||||
|
||||
@Inject
|
||||
public OrgNameAndVDCNameToEndpoint(@VDC Supplier<Map<String, Map<String, NamedResource>>> orgNameToVDCEndpoint,
|
||||
@Org String defaultOrg, @VDC URI defaultUri) {
|
||||
this.orgNameToVDCEndpoint = orgNameToVDCEndpoint;
|
||||
this.defaultOrg = defaultOrg;
|
||||
this.defaultUri = defaultUri;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public URI apply(Object from) {
|
||||
Iterable<Object> orgVdc = (Iterable<Object>) checkNotNull(from, "args");
|
||||
Object org = Iterables.get(orgVdc, 0);
|
||||
Object vdc = Iterables.get(orgVdc, 1);
|
||||
if (org == null && vdc == null)
|
||||
return defaultUri;
|
||||
else if (org == null)
|
||||
org = defaultOrg;
|
||||
|
||||
try {
|
||||
Map<String, NamedResource> vdcs = checkNotNull(orgNameToVDCEndpoint.get().get(org));
|
||||
|
||||
return vdc == null ? Iterables.getLast(vdcs.values()).getLocation() : vdcs.get(vdc).getLocation();
|
||||
} catch (NullPointerException e) {
|
||||
throw new NoSuchElementException(org + "/" + vdc + " not found in " + orgNameToVDCEndpoint.get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -29,9 +29,12 @@ import java.lang.reflect.Array;
|
|||
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;
|
||||
|
@ -80,7 +83,6 @@ import com.google.inject.TypeLiteral;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "vcloud.VCloudAsyncClientTest")
|
||||
public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
||||
|
||||
public void testInstantiateVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", String.class, String.class,
|
||||
String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
|
@ -171,6 +173,89 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
.withDescription("The description of the new vApp"));
|
||||
}
|
||||
|
||||
public void testInstantiateVAppTemplateInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInOrg", String.class, String.class,
|
||||
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "my-vapp", 3 + "");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/newvapp-hosting.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testInstantiateVAppTemplateInOrgOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInOrg", String.class, String.class,
|
||||
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "my-vapp", 3 + "", processorCount(1).memory(
|
||||
512).disk(1024).fenceMode("allowInOut").inNetwork(
|
||||
URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/newvapp-hostingcpumemdisk.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
|
||||
false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VAppHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInOrg", String.class, String.class,
|
||||
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
processor.createRequest(method, "org", "vdc", "CentOS 01", 3 + "", processorCount(1).memory(512).disk(1024)
|
||||
.inNetwork(URI.create("https://vcloud.safesecureweb.com/network/1990")));
|
||||
}
|
||||
|
||||
public void testCloneVAppInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInOrg", String.class, String.class, String.class,
|
||||
String.class, Array.newInstance(CloneVAppOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "4181", "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testCloneVAppInOrgOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("cloneVAppInOrg", String.class, String.class, String.class,
|
||||
String.class, Array.newInstance(CloneVAppOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "201", "new-linux-server",
|
||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDefaultOrganization() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getDefaultOrganization");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
@ -306,6 +391,63 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetVDCByOrgAndName() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NoSuchElementException.class)
|
||||
public void testGetVDCByOrgAndNameBadVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||
processor.createRequest(method, "org", "vdc1");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NoSuchElementException.class)
|
||||
public void testGetVDCByOrgAndNameBadOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||
processor.createRequest(method, "org1", "vdc");
|
||||
}
|
||||
|
||||
public void testGetVDCByOrgAndNameNullOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "vdc");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetVDCByOrgAndNameNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDCInOrg", String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, null);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VDCHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testGetVDCString() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", String.class);
|
||||
HttpRequest request = processor.createRequest(method, "1");
|
||||
|
@ -323,7 +465,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
public void testGetVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
@ -569,12 +712,23 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(OrgNameToVDCSupplier.class).to(TestOrgNameToVDCSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideOrg(@Org Iterable<NamedResource> orgs) {
|
||||
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/org");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideOrgName(@Org Iterable<NamedResource> orgs) {
|
||||
return "org";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideCatalog(Organization org, @Named(PROPERTY_IDENTITY) String user) {
|
||||
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog");
|
||||
|
@ -626,6 +780,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestOrgNameToVDCSupplier extends OrgNameToVDCSupplier {
|
||||
@Inject
|
||||
protected TestOrgNameToVDCSupplier() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, NamedResource>> get() {
|
||||
return ImmutableMap.<String, Map<String, NamedResource>> of("org", ImmutableMap.<String, NamedResource> of(
|
||||
"vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,31 +80,27 @@ public class VCloudComputeClientLiveTest {
|
|||
protected Predicate<String> addressTester;
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
||||
IOException {
|
||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
OsFamily toTest = OsFamily.CENTOS;
|
||||
|
||||
String serverName = getCompatibleServerName(toTest);
|
||||
int processorCount = 1;
|
||||
int memory = 512;
|
||||
|
||||
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024)
|
||||
.productProperties(ImmutableMap.of("foo", "bar"));
|
||||
InstantiateVAppTemplateOptions options = processorCount(1).memory(512).disk(10 * 1025 * 1024).productProperties(
|
||||
ImmutableMap.of("foo", "bar"));
|
||||
|
||||
id = computeClient.start(client.getDefaultVDC().getId(), serverName, templateId, options)
|
||||
.get("id");
|
||||
id = computeClient.start(null, null, serverName, templateId, options).get("id");
|
||||
Expectation expectation = expectationMap.get(toTest);
|
||||
|
||||
VApp vApp = client.getVApp(id);
|
||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory,
|
||||
expectation.hardDisk);
|
||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory, expectation.hardDisk);
|
||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||
}
|
||||
|
||||
private String getCompatibleServerName(OsFamily toTest) {
|
||||
String serverName = CaseFormat.UPPER_UNDERSCORE
|
||||
.to(CaseFormat.LOWER_HYPHEN, toTest.toString()).substring(0,
|
||||
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
|
||||
String serverName = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, toTest.toString()).substring(0,
|
||||
toTest.toString().length() <= 15 ? toTest.toString().length() : 14);
|
||||
return serverName;
|
||||
}
|
||||
|
||||
|
@ -114,23 +110,18 @@ public class VCloudComputeClientLiveTest {
|
|||
assert !addressTester.apply(publicAddress);
|
||||
}
|
||||
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs,
|
||||
int processorCount, int memory, long hardDisk) {
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
|
||||
int memory, long hardDisk) {
|
||||
// assertEquals(vApp.getName(), serverName);
|
||||
// assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||
assertEquals(
|
||||
Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), processorCount);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
||||
memory);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||
.getVirtualQuantity(), hardDisk);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), processorCount);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.MEMORY))
|
||||
.getVirtualQuantity(), memory);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||
.getVirtualQuantity(), hardDisk);
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
|
@ -143,20 +134,19 @@ public class VCloudComputeClientLiveTest {
|
|||
public void setupClient() {
|
||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
||||
String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"),
|
||||
"jclouds.test.endpoint");
|
||||
String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), "jclouds.test.endpoint");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("vcloud.endpoint", endpoint);
|
||||
Injector injector = new RestContextFactory().createContextBuilder("vcloud", identity, credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), props).buildInjector();
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), props).buildInjector();
|
||||
|
||||
computeClient = injector.getInstance(VCloudComputeClient.class);
|
||||
client = injector.getInstance(VCloudClient.class);
|
||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() {
|
||||
}));
|
||||
expectationMap = ImmutableMap.<OsFamily, Expectation> builder().put(OsFamily.CENTOS,
|
||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
|
||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).build();
|
||||
provider = "vcloudtest";
|
||||
templateId = "3";
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.vcloud.hostingdotcom;
|
|||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
|
@ -29,6 +30,7 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.MapPayloadParam;
|
||||
|
@ -40,6 +42,7 @@ import org.jclouds.vcloud.VCloudAsyncClient;
|
|||
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.domain.Catalog;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.VAppTemplateIdToUri;
|
||||
import org.jclouds.vcloud.hostingdotcom.domain.HostingDotComVApp;
|
||||
import org.jclouds.vcloud.hostingdotcom.xml.HostingDotComVAppHandler;
|
||||
|
@ -52,7 +55,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(SetVCloudTokenCookie.class)
|
||||
|
@ -76,6 +80,22 @@ public interface HostingDotComVCloudAsyncClient extends VCloudAsyncClient {
|
|||
@Override
|
||||
ListenableFuture<? extends HostingDotComVApp> getVApp(@PathParam("vAppId") String appId);
|
||||
|
||||
@POST
|
||||
@Path("/action/instantiateVAppTemplate")
|
||||
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
||||
@Consumes(VAPP_XML)
|
||||
// required for hosting.com to operate
|
||||
@XMLResponseParser(HostingDotComVAppHandler.class)
|
||||
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||
@Override
|
||||
ListenableFuture<? extends HostingDotComVApp> instantiateVAppTemplateInOrg(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName,
|
||||
@MapPayloadParam("name") String appName,
|
||||
@MapPayloadParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
@Deprecated
|
||||
@POST
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/vdc/{vDCId}/action/instantiateVAppTemplate")
|
||||
|
@ -85,8 +105,9 @@ public interface HostingDotComVCloudAsyncClient extends VCloudAsyncClient {
|
|||
@XMLResponseParser(HostingDotComVAppHandler.class)
|
||||
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||
@Override
|
||||
ListenableFuture<? extends HostingDotComVApp> instantiateVAppTemplateInVDC(
|
||||
@PathParam("vDCId") String vDCId, @MapPayloadParam("name") String appName,
|
||||
@MapPayloadParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
ListenableFuture<? extends HostingDotComVApp> instantiateVAppTemplateInVDC(@PathParam("vDCId") String vDCId,
|
||||
@MapPayloadParam("name") String appName,
|
||||
@MapPayloadParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -37,8 +38,13 @@ public interface HostingDotComVCloudClient extends VCloudClient {
|
|||
|
||||
@Override
|
||||
@Timeout(duration = 600, timeUnit = TimeUnit.SECONDS)
|
||||
HostingDotComVApp instantiateVAppTemplateInVDC(String vDCId, String appName, String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
HostingDotComVApp instantiateVAppTemplateInOrg(String org, String vDC, String appName, String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
@Override
|
||||
@Timeout(duration = 600, timeUnit = TimeUnit.SECONDS)
|
||||
HostingDotComVApp instantiateVAppTemplateInVDC(String vDC, String appName, String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
@Override
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.vcloud.terremark;
|
|||
|
||||
import static org.jclouds.vcloud.VCloudMediaType.CATALOG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.ORG_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
||||
import static org.jclouds.vcloud.VCloudMediaType.VDC_XML;
|
||||
import static org.jclouds.vcloud.terremark.TerremarkVCloudMediaType.CATALOGITEMCUSTOMIZATIONPARAMETERS_XML;
|
||||
|
@ -65,6 +64,7 @@ import org.jclouds.vcloud.domain.VApp;
|
|||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Org;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.VAppId;
|
||||
import org.jclouds.vcloud.functions.VAppTemplateIdToUri;
|
||||
|
@ -93,7 +93,6 @@ import org.jclouds.vcloud.terremark.xml.PublicIpAddressesHandler;
|
|||
import org.jclouds.vcloud.terremark.xml.TerremarkOrgHandler;
|
||||
import org.jclouds.vcloud.terremark.xml.TerremarkVDCHandler;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -164,8 +163,27 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
|||
ListenableFuture<? extends VDC> getVDC(@PathParam("vDCId") String vDCId);
|
||||
|
||||
/**
|
||||
* @see TerremarkVCloudExpressClient#instantiateVAppTemplateInVDC
|
||||
* @see VCloudClient#instantiateVAppTemplate
|
||||
*/
|
||||
@Override
|
||||
@POST
|
||||
@Path("/action/instantiateVAppTemplate")
|
||||
@Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
|
||||
@Consumes(VAPP_XML)
|
||||
@XMLResponseParser(VAppHandler.class)
|
||||
@MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class)
|
||||
ListenableFuture<? extends VApp> instantiateVAppTemplateInOrg(
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String orgName,
|
||||
@Nullable @EndpointParam(parser = OrgNameAndVDCNameToEndpoint.class) String vdcName,
|
||||
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
|
||||
@MapPayloadParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
|
||||
InstantiateVAppTemplateOptions... options);
|
||||
|
||||
/**
|
||||
* @see VCloudClient#instantiateVAppTemplateInVDC
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
@POST
|
||||
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
|
||||
@Path("/vdc/{vDCId}/action/instantiateVAppTemplate")
|
||||
|
@ -369,5 +387,5 @@ public interface TerremarkVCloudAsyncClient extends VCloudAsyncClient {
|
|||
@Consumes(CATALOGITEMCUSTOMIZATIONPARAMETERS_XML)
|
||||
ListenableFuture<? extends CustomizationParameters> getCustomizationOptionsOfCatalogItem(
|
||||
@PathParam("catalogItemId") String catalogItemId);
|
||||
|
||||
|
||||
}
|
|
@ -64,9 +64,9 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
|
||||
@Inject
|
||||
protected TerremarkVCloudComputeClient(TerremarkVCloudExpressClient client,
|
||||
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
|
||||
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<String> successTester,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
PopulateDefaultLoginCredentialsForImageStrategy credentialsProvider,
|
||||
@Named("PASSWORD") Provider<String> passwordGenerator, Predicate<String> successTester,
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState) {
|
||||
super(client, successTester, vAppStatusToNodeState);
|
||||
this.client = client;
|
||||
this.credentialsProvider = credentialsProvider;
|
||||
|
@ -83,21 +83,20 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> start(String vDCId, String name, String templateId,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||
public Map<String, String> start(String org, String vDC, String name, String templateId,
|
||||
InstantiateVAppTemplateOptions options, int... portsToOpen) {
|
||||
if (options.getDiskSizeKilobytes() != null) {
|
||||
logger.warn("trmk does not support resizing the primary disk; unsetting disk size");
|
||||
}
|
||||
// we only get IP addresses after "deploy"
|
||||
if (portsToOpen.length > 0 && !options.shouldBlockOnDeploy())
|
||||
throw new IllegalArgumentException(
|
||||
"We cannot open ports on terremark unless we can deploy the vapp");
|
||||
throw new IllegalArgumentException("We cannot open ports on terremark unless we can deploy the vapp");
|
||||
String password = null;
|
||||
if (client.getVAppTemplate(templateId).getDescription().indexOf("Windows") != -1) {
|
||||
password = passwordGenerator.get();
|
||||
options.getProperties().put("password", password);
|
||||
}
|
||||
Map<String, String> response = super.start(vDCId, name, templateId, options, portsToOpen);
|
||||
Map<String, String> response = super.start(org, vDC, name, templateId, options, portsToOpen);
|
||||
if (password != null) {
|
||||
response = new LinkedHashMap<String, String>(response);
|
||||
response.put("password", password);
|
||||
|
@ -115,39 +114,36 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
InternetService is = null;
|
||||
Protocol protocol;
|
||||
switch (port) {
|
||||
case 22:
|
||||
protocol = Protocol.TCP;
|
||||
break;
|
||||
case 80:
|
||||
case 8080:
|
||||
protocol = Protocol.HTTP;
|
||||
break;
|
||||
case 443:
|
||||
protocol = Protocol.HTTPS;
|
||||
break;
|
||||
default:
|
||||
protocol = Protocol.HTTP;
|
||||
break;
|
||||
case 22:
|
||||
protocol = Protocol.TCP;
|
||||
break;
|
||||
case 80:
|
||||
case 8080:
|
||||
protocol = Protocol.HTTP;
|
||||
break;
|
||||
case 443:
|
||||
protocol = Protocol.HTTPS;
|
||||
break;
|
||||
default:
|
||||
protocol = Protocol.HTTP;
|
||||
break;
|
||||
}
|
||||
if (ip == null) {
|
||||
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getId(),
|
||||
protocol, port);
|
||||
is = client.addInternetServiceToVDC(vApp.getVDC().getId(), vApp.getName() + "-" + port,
|
||||
protocol, port, withDescription(String.format(
|
||||
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||
.getName())));
|
||||
logger.debug(">> creating InternetService in vDC %s:%s:%d", vApp.getVDC().getId(), protocol, port);
|
||||
is = client.addInternetServiceToVDC(vApp.getVDC().getId(), vApp.getName() + "-" + port, protocol, port,
|
||||
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||
.getName())));
|
||||
ip = is.getPublicIpAddress();
|
||||
} else {
|
||||
logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
|
||||
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port,
|
||||
protocol, port, withDescription(String.format(
|
||||
"port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||
.getName())));
|
||||
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port,
|
||||
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getId(), vApp
|
||||
.getName())));
|
||||
}
|
||||
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getId(), is
|
||||
.getPublicIpAddress().getAddress(), is.getProtocol(), is.getPort());
|
||||
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is
|
||||
.getPort(), privateAddress, port);
|
||||
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getId(), is.getPublicIpAddress().getAddress(), is
|
||||
.getProtocol(), is.getPort());
|
||||
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
|
||||
privateAddress, port);
|
||||
Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
|
||||
logger.debug("<< added Node(%s)", node.getId());
|
||||
}
|
||||
|
@ -156,20 +152,18 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
|
||||
private Set<PublicIpAddress> deleteInternetServicesAndNodesAssociatedWithVApp(VApp vApp) {
|
||||
Set<PublicIpAddress> ipAddresses = Sets.newHashSet();
|
||||
SERVICE: for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC()
|
||||
.getId())) {
|
||||
SERVICE: for (InternetService service : client.getAllInternetServicesInVDC(vApp.getVDC().getId())) {
|
||||
for (Node node : client.getNodes(service.getId())) {
|
||||
if (vApp.getNetworkToAddresses().containsValue(node.getIpAddress())) {
|
||||
ipAddresses.add(service.getPublicIpAddress());
|
||||
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getId(), service
|
||||
.getPublicIpAddress().getAddress(), service.getPort(), node.getIpAddress(),
|
||||
node.getPort());
|
||||
logger.debug(">> deleting Node(%s) %s:%d -> %s:%d", node.getId(), service.getPublicIpAddress()
|
||||
.getAddress(), service.getPort(), node.getIpAddress(), node.getPort());
|
||||
client.deleteNode(node.getId());
|
||||
logger.debug("<< deleted Node(%s)", node.getId());
|
||||
Set<Node> nodes = client.getNodes(service.getId());
|
||||
if (nodes.size() == 0) {
|
||||
logger.debug(">> deleting InternetService(%s) %s:%d", service.getId(), service
|
||||
.getPublicIpAddress().getAddress(), service.getPort());
|
||||
logger.debug(">> deleting InternetService(%s) %s:%d", service.getId(), service.getPublicIpAddress()
|
||||
.getAddress(), service.getPort());
|
||||
client.deleteInternetService(service.getId());
|
||||
logger.debug("<< deleted InternetService(%s)", service.getId());
|
||||
continue SERVICE;
|
||||
|
@ -182,11 +176,9 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
|
||||
private void deletePublicIpAddressesWithNoServicesAttached(Set<PublicIpAddress> ipAddresses) {
|
||||
IPADDRESS: for (PublicIpAddress address : ipAddresses) {
|
||||
Set<InternetService> services = client
|
||||
.getInternetServicesOnPublicIp(address.getId());
|
||||
Set<InternetService> services = client.getInternetServicesOnPublicIp(address.getId());
|
||||
if (services.size() == 0) {
|
||||
logger.debug(">> deleting PublicIpAddress(%s) %s", address.getId(), address
|
||||
.getAddress());
|
||||
logger.debug(">> deleting PublicIpAddress(%s) %s", address.getId(), address.getAddress());
|
||||
client.deletePublicIp(address.getId());
|
||||
logger.debug("<< deleted PublicIpAddress(%s)", address.getId());
|
||||
continue IPADDRESS;
|
||||
|
@ -195,9 +187,10 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
}
|
||||
|
||||
/**
|
||||
* deletes the internet service and nodes associated with the vapp. Deletes the IP address, if
|
||||
* there are no others using it. Finally, it powers off and deletes the vapp. Note that we do not
|
||||
* call undeploy, as terremark does not support the command.
|
||||
* deletes the internet service and nodes associated with the vapp. Deletes
|
||||
* the IP address, if there are no others using it. Finally, it powers off
|
||||
* and deletes the vapp. Note that we do not call undeploy, as terremark does
|
||||
* not support the command.
|
||||
*/
|
||||
@Override
|
||||
public void stop(String id) {
|
||||
|
@ -234,8 +227,7 @@ public class TerremarkVCloudComputeClient extends BaseVCloudComputeClient {
|
|||
|
||||
@Override
|
||||
public boolean apply(Task input) {
|
||||
return input.getStatus() == TaskStatus.QUEUED
|
||||
|| input.getStatus() == TaskStatus.RUNNING;
|
||||
return input.getStatus() == TaskStatus.QUEUED || input.getStatus() == TaskStatus.RUNNING;
|
||||
}
|
||||
|
||||
}));
|
||||
|
|
|
@ -114,8 +114,9 @@ public class TerremarkVCloudComputeServiceContextModule extends VCloudComputeSer
|
|||
@Override
|
||||
public NodeMetadata execute(String tag, String name, Template template) {
|
||||
TerremarkInstantiateVAppTemplateOptions options = getOptions.apply(template);
|
||||
Map<String, String> metaMap = computeClient.start(template.getLocation().getId(), name, template.getImage()
|
||||
.getProviderId(), options, template.getOptions().getInboundPorts());
|
||||
Map<String, String> metaMap = computeClient.start(template.getLocation().getParent().getId(), template
|
||||
.getLocation().getId(), name, template.getImage().getProviderId(), options, template.getOptions()
|
||||
.getInboundPorts());
|
||||
return getNode.execute(metaMap.get("id"));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,14 +31,12 @@ import org.jclouds.vcloud.terremark.domain.TerremarkOrganization;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class TerremarkOrganizationImpl extends OrganizationImpl implements
|
||||
TerremarkOrganization {
|
||||
public class TerremarkOrganizationImpl extends OrganizationImpl implements TerremarkOrganization {
|
||||
|
||||
private final NamedResource keysList;
|
||||
|
||||
public TerremarkOrganizationImpl(String id, String name, URI location,
|
||||
Map<String, NamedResource> catalogs, Map<String, NamedResource> vdcs,
|
||||
Map<String, NamedResource> tasksLists, NamedResource keysList) {
|
||||
public TerremarkOrganizationImpl(String id, String name, URI location, Map<String, NamedResource> catalogs,
|
||||
Map<String, NamedResource> vdcs, Map<String, NamedResource> tasksLists, NamedResource keysList) {
|
||||
super(id, name, location, catalogs, vdcs, tasksLists);
|
||||
this.keysList = keysList;
|
||||
}
|
||||
|
|
|
@ -102,16 +102,14 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
|
||||
@Test
|
||||
public void testGetAllInternetServices() throws Exception {
|
||||
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.getDefaultVDC()
|
||||
.getId())) {
|
||||
for (InternetService service : tmClient.getAllInternetServicesInVDC(tmClient.getDefaultVDC().getId())) {
|
||||
assertNotNull(tmClient.getNodes(service.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
|
||||
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.getDefaultVDC()
|
||||
.getId())) {
|
||||
for (PublicIpAddress ip : tmClient.getPublicIpsAssociatedWithVDC(tmClient.getDefaultVDC().getId())) {
|
||||
assertNotNull(tmClient.getInternetServicesOnPublicIp(ip.getId()));
|
||||
assertNotNull(tmClient.getPublicIp(ip.getId()));
|
||||
}
|
||||
|
@ -139,8 +137,8 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException {
|
||||
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
||||
IOException {
|
||||
prepare();
|
||||
StringBuffer name = new StringBuffer();
|
||||
for (int i = 0; i < 15; i++)
|
||||
|
@ -153,8 +151,8 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
// String catalogOs = "CentOS 5.3 (32-bit)";
|
||||
// String expectedOs = "Red Hat Enterprise Linux 5 (32-bit)";
|
||||
|
||||
// lookup the id of the datacenter you are deploying into
|
||||
String vDCId = tmClient.getDefaultVDC().getId();
|
||||
// lookup the name of the datacenter you are deploying into
|
||||
String vdc = tmClient.getDefaultVDC().getName();
|
||||
|
||||
// lookup the id of the item in the catalog you wish to deploy by name
|
||||
Catalog catalog = tmClient.getDefaultCatalog();
|
||||
|
@ -164,8 +162,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
|
||||
// if this template supports setting the root password, let's add it to
|
||||
// our options
|
||||
CustomizationParameters customizationOptions = tmClient
|
||||
.getCustomizationOptionsOfCatalogItem(itemId);
|
||||
CustomizationParameters customizationOptions = tmClient.getCustomizationOptionsOfCatalogItem(itemId);
|
||||
if (customizationOptions.canCustomizePassword())
|
||||
instantiateOptions.withPassword("robotsarefun");
|
||||
|
||||
|
@ -174,8 +171,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
String vAppTemplateId = tmClient.getCatalogItem(itemId).getEntity().getId();
|
||||
|
||||
// instantiate, noting vApp returned has minimal details
|
||||
vApp = tmClient.instantiateVAppTemplateInVDC(vDCId, serverName, vAppTemplateId,
|
||||
instantiateOptions);
|
||||
vApp = tmClient.instantiateVAppTemplateInOrg(null, vdc, serverName, vAppTemplateId, instantiateOptions);
|
||||
|
||||
assertEquals(vApp.getStatus(), VAppStatus.RESOLVED);
|
||||
|
||||
|
@ -225,10 +221,8 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
abstract TerremarkInstantiateVAppTemplateOptions createInstantiateOptions();
|
||||
|
||||
@Test
|
||||
public void testAddInternetService() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException {
|
||||
is = tmClient.addInternetServiceToVDC(tmClient.getDefaultVDC().getId(), "SSH", Protocol.TCP,
|
||||
22);
|
||||
public void testAddInternetService() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
is = tmClient.addInternetServiceToVDC(tmClient.getDefaultVDC().getId(), "SSH", Protocol.TCP, 22);
|
||||
publicIp = is.getPublicIpAddress().getAddress();
|
||||
}
|
||||
|
||||
|
@ -238,7 +232,7 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
||||
|
||||
// lookup the id of the datacenter you are deploying into
|
||||
String vDCId = tmClient.getDefaultVDC().getId();
|
||||
String vdc = tmClient.getDefaultVDC().getName();
|
||||
|
||||
String vAppIdToClone = vApp.getId();
|
||||
|
||||
|
@ -247,11 +241,10 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
name.append("b");
|
||||
String newName = name.toString();
|
||||
|
||||
CloneVAppOptions options = deploy().powerOn()
|
||||
.withDescription("The description of " + newName);
|
||||
CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName);
|
||||
|
||||
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
|
||||
Task task = tmClient.cloneVAppInVDC(vDCId, vAppIdToClone, newName, options);
|
||||
Task task = tmClient.cloneVAppInOrg(null, vdc, vAppIdToClone, newName, options);
|
||||
|
||||
// wait for the task to complete
|
||||
assert successTester.apply(task.getId());
|
||||
|
@ -271,10 +264,9 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
||||
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException,
|
||||
IOException {
|
||||
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()),
|
||||
vApp.getName() + "-SSH", 22);
|
||||
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
node = tmClient.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
|
||||
+ "-SSH", 22);
|
||||
loopAndCheckPass();
|
||||
}
|
||||
|
||||
|
@ -294,16 +286,13 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||
public void testConfigureNode() throws InterruptedException, ExecutionException,
|
||||
TimeoutException, IOException {
|
||||
node = tmClient.configureNode(node.getId(), new NodeConfiguration()
|
||||
.changeDescriptionTo("holy cow"));
|
||||
public void testConfigureNode() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
node = tmClient.configureNode(node.getId(), new NodeConfiguration().changeDescriptionTo("holy cow"));
|
||||
assertEquals(node.getDescription(), "holy cow");
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException,
|
||||
IOException {
|
||||
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
|
||||
try {// per docs, this is not supported
|
||||
tmClient.undeployVApp(vApp.getId());
|
||||
|
@ -336,25 +325,21 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
|
||||
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException,
|
||||
IOException {
|
||||
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
|
||||
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536)
|
||||
.changeProcessorCountTo(1).addDisk(25 * 1048576).addDisk(25 * 1048576));
|
||||
Task task = tmClient.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
|
||||
.addDisk(25 * 1048576).addDisk(25 * 1048576));
|
||||
|
||||
assert successTester.apply(task.getId());
|
||||
|
||||
vApp = tmClient.getVApp(vApp.getId());
|
||||
assertEquals(vApp.getName(), "eduardo");
|
||||
assertEquals(
|
||||
Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
||||
1536);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.MEMORY))
|
||||
.getVirtualQuantity(), 1536);
|
||||
assertEquals(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE).size(), 3);
|
||||
|
||||
assert successTester.apply(tmClient.powerOnVApp(vApp.getId()).getId());
|
||||
|
@ -365,11 +350,10 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
|
||||
// extract the disks on the vApp sorted by addressOnParent
|
||||
List<ResourceAllocation> disks = Lists.newArrayList(vApp.getResourceAllocationByType().get(
|
||||
ResourceType.DISK_DRIVE));
|
||||
ResourceType.DISK_DRIVE));
|
||||
|
||||
// delete the second disk
|
||||
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1)
|
||||
.getAddressOnParent()));
|
||||
task = tmClient.configureVApp(vApp, deleteDiskWithAddressOnParent(disks.get(1).getAddressOnParent()));
|
||||
|
||||
assert successTester.apply(task.getId());
|
||||
|
||||
|
@ -377,33 +361,26 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
loopAndCheckPass();
|
||||
}
|
||||
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs,
|
||||
int processorCount, long memory, long hardDisk) {
|
||||
private void verifyConfigurationOfVApp(VApp vApp, String serverName, String expectedOs, int processorCount,
|
||||
long memory, long hardDisk) {
|
||||
assertEquals(vApp.getName(), serverName);
|
||||
assertEquals(vApp.getOperatingSystemDescription(), expectedOs);
|
||||
assertEquals(
|
||||
Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), processorCount);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity(),
|
||||
memory);
|
||||
assertEquals(Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||
.getVirtualQuantity(), hardDisk);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR))
|
||||
.getVirtualQuantity(), processorCount);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.SCSI_CONTROLLER))
|
||||
.getVirtualQuantity(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.MEMORY))
|
||||
.getVirtualQuantity(), memory);
|
||||
assertEquals(Iterables.getOnlyElement(vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||
.getVirtualQuantity(), hardDisk);
|
||||
assertEquals(vApp.getSize().longValue(), Iterables.getOnlyElement(
|
||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE))
|
||||
.getVirtualQuantity());
|
||||
vApp.getResourceAllocationByType().get(ResourceType.DISK_DRIVE)).getVirtualQuantity());
|
||||
}
|
||||
|
||||
private void doCheckPass(String address) throws IOException {
|
||||
IPSocket socket = new IPSocket(address, 22);
|
||||
|
||||
System.out.printf("%d: %s awaiting ssh service to start%n", System.currentTimeMillis(),
|
||||
socket);
|
||||
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);
|
||||
|
||||
|
@ -450,35 +427,26 @@ public abstract class TerremarkClientLiveTest extends VCloudClientLiveTest {
|
|||
@BeforeGroups(groups = { "live" })
|
||||
@Override
|
||||
public void setupClient() {
|
||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"),
|
||||
"jclouds.test.identity");
|
||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"),
|
||||
"jclouds.test.credential");
|
||||
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
|
||||
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
|
||||
|
||||
String endpoint = System.getProperty("jclouds.test.endpoint");
|
||||
Properties props = new Properties();
|
||||
if (endpoint != null && !"".equals(endpoint))
|
||||
props.setProperty("terremark.endpoint", endpoint);
|
||||
Injector injector = new RestContextFactory()
|
||||
.createContextBuilder(
|
||||
provider,
|
||||
identity,
|
||||
credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule(),
|
||||
new JschSshClientModule()), props).buildInjector();
|
||||
Injector injector = new RestContextFactory().createContextBuilder(provider, identity, credential,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new JschSshClientModule()), props).buildInjector();
|
||||
|
||||
connection = tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||
|
||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 130,
|
||||
10, TimeUnit.SECONDS);// make
|
||||
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 130, 10, TimeUnit.SECONDS);// make
|
||||
// it
|
||||
// longer
|
||||
// then
|
||||
// default internet
|
||||
// service timeout
|
||||
successTester = new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), 650,
|
||||
10, TimeUnit.SECONDS);
|
||||
successTester = new RetryablePredicate<String>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
|
@ -144,11 +144,13 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
}
|
||||
|
||||
public void testInstantiateVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", String.class,
|
||||
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "1", "name", 3 + "");
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInOrg", String.class,
|
||||
String.class, String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0)
|
||||
.getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "name", 3 + "");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test.xml")),
|
||||
|
@ -162,13 +164,15 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
}
|
||||
|
||||
public void testInstantiateVAppTemplateOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", String.class,
|
||||
String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "1", "name", 3 + "",
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInOrg", String.class,
|
||||
String.class, String.class, String.class, Array.newInstance(InstantiateVAppTemplateOptions.class, 0)
|
||||
.getClass());
|
||||
HttpRequest request = processor.createRequest(method, "org", "vdc", "name", 3 + "",
|
||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inRow("row").inGroup("group")
|
||||
.withPassword("password").inNetwork(URI.create("http://network")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Utils.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")),
|
||||
|
@ -443,7 +447,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
public void testListKeyPairsInOrgNull() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", String.class);
|
||||
HttpRequest request = processor.createRequest(method,(String) null);
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1/keysList HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n");
|
||||
|
@ -567,6 +571,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
protected void configure() {
|
||||
super.configure();
|
||||
bind(OrgNameToKeysListSupplier.class).to(TestOrgNameToKeysListSupplier.class);
|
||||
bind(OrgNameToVDCSupplier.class).to(TestOrgNameToVDCSupplier.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -640,6 +645,21 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class TestOrgNameToVDCSupplier extends OrgNameToVDCSupplier {
|
||||
@Inject
|
||||
protected TestOrgNameToVDCSupplier() {
|
||||
super(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<String, NamedResource>> get() {
|
||||
return ImmutableMap.<String, Map<String, NamedResource>> of("org", ImmutableMap.<String, NamedResource> of(
|
||||
"vdc", new NamedResourceImpl("1", "vdc", VCloudMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideDefaultTasksList(Organization org) {
|
||||
return URI.create("https://taskslist");
|
||||
|
|
|
@ -51,8 +51,7 @@ public class TerremarkVCloudComputeClientTest {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testStartWindows() throws IOException {
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/terremark/windows_description.txt");
|
||||
InputStream is = getClass().getResourceAsStream("/terremark/windows_description.txt");
|
||||
String description = new String(ByteStreams.toByteArray(is));
|
||||
VAppTemplate template = createMock(VAppTemplate.class);
|
||||
expect(template.getDescription()).andReturn(description).atLeastOnce();
|
||||
|
@ -61,9 +60,8 @@ public class TerremarkVCloudComputeClientTest {
|
|||
VApp vApp = createMock(VApp.class);
|
||||
|
||||
expect(
|
||||
client.instantiateVAppTemplateInVDC("vDCId", "name", "templateId",
|
||||
new TerremarkInstantiateVAppTemplateOptions()
|
||||
.productProperty("password", "password"))).andReturn(
|
||||
client.instantiateVAppTemplateInOrg("org", "vDC", "name", "templateId",
|
||||
new TerremarkInstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(
|
||||
vApp);
|
||||
Task task = createMock(Task.class);
|
||||
|
||||
|
@ -78,10 +76,8 @@ public class TerremarkVCloudComputeClientTest {
|
|||
Predicate<VApp> notFoundTester = createMock(Predicate.class);
|
||||
Map<VAppStatus, NodeState> vAppStatusToNodeState = createMock(Map.class);
|
||||
|
||||
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(
|
||||
client,
|
||||
new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(),
|
||||
new Provider<String>() {
|
||||
TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
|
||||
new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(), new Provider<String>() {
|
||||
|
||||
@Override
|
||||
public String get() {
|
||||
|
@ -98,8 +94,8 @@ public class TerremarkVCloudComputeClientTest {
|
|||
replay(notFoundTester);
|
||||
replay(vAppStatusToNodeState);
|
||||
|
||||
Map<String, String> response = computeClient.start("vDCId", "name",
|
||||
"templateId", new TerremarkInstantiateVAppTemplateOptions());
|
||||
Map<String, String> response = computeClient.start("org", "vDC", "name", "templateId",
|
||||
new TerremarkInstantiateVAppTemplateOptions());
|
||||
|
||||
assertEquals(response.get("id"), "1");
|
||||
assertEquals(response.get("username"), "Administrator");
|
||||
|
|
Loading…
Reference in New Issue