mirror of https://github.com/apache/jclouds.git
Issue 280: added orglist command
This commit is contained in:
parent
3ae7dfb1b7
commit
b6fbc29c83
|
@ -44,7 +44,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
public interface VCloudLoginAsyncClient {
|
||||
|
||||
/**
|
||||
* This request returns a token to use in subsequent requests. After ten minutes of inactivity,
|
||||
* This request returns a token to use in subsequent requests. After 30 minutes of inactivity,
|
||||
* the token expires and you have to request a new token with this call.
|
||||
*/
|
||||
@POST
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
|
|||
import static org.jclouds.vcloud.VCloudMediaType.VM_XML;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -38,6 +39,7 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.predicates.validators.DnsNameValidator;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
|
@ -52,16 +54,19 @@ import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
|||
import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.domain.Vm;
|
||||
import org.jclouds.vcloud.domain.ovf.OvfEnvelope;
|
||||
import org.jclouds.vcloud.endpoints.OrgList;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.VAppHandler;
|
||||
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
||||
|
@ -74,11 +79,21 @@ 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)
|
||||
public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
|
||||
/**
|
||||
*
|
||||
* @see VCloudClient#listOrgs
|
||||
*/
|
||||
@GET
|
||||
@Endpoint(OrgList.class)
|
||||
@XMLResponseParser(OrgListHandler.class)
|
||||
@Consumes(VCloudMediaType.ORGLIST_XML)
|
||||
ListenableFuture<Map<String, ReferenceType>> listOrgs();
|
||||
|
||||
/**
|
||||
* @see VCloudClient#getVAppTemplate
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
package org.jclouds.vcloud;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.VApp;
|
||||
import org.jclouds.vcloud.domain.VAppTemplate;
|
||||
|
@ -38,11 +40,20 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
|||
* Provides access to VCloud resources via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
|
||||
* @see <a
|
||||
* href="http://communities.vmware.com/community/developer/forums/vcloudapi"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
|
||||
public interface VCloudClient extends CommonVCloudClient {
|
||||
/**
|
||||
* The response to a login request includes a list of the organizations to
|
||||
* which the authenticated user has access.
|
||||
*
|
||||
* @return organizations indexed by name
|
||||
*/
|
||||
Map<String, ReferenceType> listOrgs();
|
||||
|
||||
VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options);
|
||||
|
||||
|
@ -53,8 +64,9 @@ public interface VCloudClient extends CommonVCloudClient {
|
|||
OvfEnvelope getOvfEnvelopeForVAppTemplate(URI vAppTemplate);
|
||||
|
||||
/**
|
||||
* returns the vapp template corresponding to a catalog item in the catalog associated with the
|
||||
* specified name. Note that the org and catalog parameters can be null to choose default.
|
||||
* returns the vapp template corresponding to a catalog item in the catalog
|
||||
* associated with the specified name. Note that the org and catalog
|
||||
* parameters can be null to choose default.
|
||||
*
|
||||
* @param orgName
|
||||
* organization name, or null for the default
|
||||
|
@ -64,7 +76,8 @@ public interface VCloudClient extends CommonVCloudClient {
|
|||
* item you wish to lookup
|
||||
*
|
||||
* @throws NoSuchElementException
|
||||
* if you specified an org, catalog, or catalog item name that isn't present
|
||||
* if you specified an org, catalog, or catalog item name that
|
||||
* isn't present
|
||||
*/
|
||||
VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
|
||||
String itemName);
|
||||
|
@ -76,97 +89,109 @@ public interface VCloudClient extends CommonVCloudClient {
|
|||
Vm getVm(URI vm);
|
||||
|
||||
/**
|
||||
* To deploy a vApp, the client makes a request to its action/deploy URL. Deploying a vApp
|
||||
* automatically deploys all of the virtual machines it contains. To deploy a virtual machine,
|
||||
* the client makes a request to its action/deploy URL.
|
||||
* To deploy a vApp, the client makes a request to its action/deploy URL.
|
||||
* Deploying a vApp automatically deploys all of the virtual machines it
|
||||
* contains. To deploy a virtual machine, the client makes a request to its
|
||||
* action/deploy URL.
|
||||
* <p/>
|
||||
* Deploying a Vm implicitly deploys the parent vApp if that vApp is not already deployed.
|
||||
* Deploying a Vm implicitly deploys the parent vApp if that vApp is not
|
||||
* already deployed.
|
||||
*/
|
||||
Task deployVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on state
|
||||
* like {@link #deployVAppOrVm(URI)}, except deploy transistions to power on
|
||||
* state
|
||||
*
|
||||
*/
|
||||
Task deployAndPowerOnVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* Undeploying a vApp powers off or suspends any running virtual machines it contains, then frees
|
||||
* the resources reserved for the vApp and sets the vApp’s deploy attribute to a value of false
|
||||
* to indicate that it is not deployed.
|
||||
* Undeploying a vApp powers off or suspends any running virtual machines it
|
||||
* contains, then frees the resources reserved for the vApp and sets the
|
||||
* vApp’s deploy attribute to a value of false to indicate that it is not
|
||||
* deployed.
|
||||
* <p/>
|
||||
* Undeploying a virtual machine powers off or suspends the virtual machine, then frees the
|
||||
* resources reserved for it and sets the its deploy attribute to a value of false to indicate
|
||||
* that it is not deployed. This operation has no effect on the containing vApp.
|
||||
* Undeploying a virtual machine powers off or suspends the virtual machine,
|
||||
* then frees the resources reserved for it and sets the its deploy attribute
|
||||
* to a value of false to indicate that it is not deployed. This operation
|
||||
* has no effect on the containing vApp.
|
||||
* <h4>NOTE</h4>
|
||||
* Using this method will simply power off the vms. In order to save their state, use
|
||||
* {@link #undeployAndSaveStateOfVAppOrVm}
|
||||
* Using this method will simply power off the vms. In order to save their
|
||||
* state, use {@link #undeployAndSaveStateOfVAppOrVm}
|
||||
*
|
||||
*/
|
||||
Task undeployVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines are suspended and
|
||||
* their suspend state saved
|
||||
* like {@link #undeployVAppOrVm(URI)}, where the undeployed virtual machines
|
||||
* are suspended and their suspend state saved
|
||||
*
|
||||
*/
|
||||
Task undeployAndSaveStateOfVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A powerOn request to a vApp URL powers on all of the virtual machines in the vApp, as
|
||||
* specified in the vApp’s StartupSection field.
|
||||
* A powerOn request to a vApp URL powers on all of the virtual machines in
|
||||
* the vApp, as specified in the vApp’s StartupSection field.
|
||||
* <p/>
|
||||
* A powerOn request to a virtual machine URL powers on the specified virtual machine and forces
|
||||
* deployment of the parent vApp.
|
||||
* A powerOn request to a virtual machine URL powers on the specified virtual
|
||||
* machine and forces deployment of the parent vApp.
|
||||
* <p/>
|
||||
* <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
|
||||
* deployment.
|
||||
* <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is
|
||||
* undeployed forces deployment.
|
||||
*/
|
||||
Task powerOnVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A powerOff request to a vApp URL powers off all of the virtual machines in the vApp, as
|
||||
* specified in its StartupSection field.
|
||||
* A powerOff request to a vApp URL powers off all of the virtual machines in
|
||||
* the vApp, as specified in its StartupSection field.
|
||||
* <p/>
|
||||
* A powerOff request to a virtual machine URL powers off the specified virtual machine.
|
||||
* A powerOff request to a virtual machine URL powers off the specified
|
||||
* virtual machine.
|
||||
*/
|
||||
Task powerOffVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A shutdown request to a vApp URL shuts down all of the virtual machines in the vApp, as
|
||||
* specified in its StartupSection field.
|
||||
* A shutdown request to a vApp URL shuts down all of the virtual machines in
|
||||
* the vApp, as specified in its StartupSection field.
|
||||
* <p/>
|
||||
* A shutdown request to a virtual machine URL shuts down the specified virtual machine.
|
||||
* A shutdown request to a virtual machine URL shuts down the specified
|
||||
* virtual machine.
|
||||
* <p/>
|
||||
* <h4>NOTE</h4Because this request sends a signal to the guest OS, the vCloud API cannot track
|
||||
* the progress or verify the result of the requested operation. Hence, void is returned
|
||||
* <h4>NOTE</h4Because this request sends a signal to the guest OS, the
|
||||
* vCloud API cannot track the progress or verify the result of the requested
|
||||
* operation. Hence, void is returned
|
||||
*/
|
||||
void shutdownVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A reset request to a vApp URL resets all of the virtual machines in the vApp, as specified in
|
||||
* its StartupSection field.
|
||||
* A reset request to a vApp URL resets all of the virtual machines in the
|
||||
* vApp, as specified in its StartupSection field.
|
||||
* <p/>
|
||||
* A reset request to a virtual machine URL resets the specified virtual machine.
|
||||
* A reset request to a virtual machine URL resets the specified virtual
|
||||
* machine.
|
||||
*/
|
||||
Task resetVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A reboot request to a vApp URL reboots all of the virtual machines in the vApp, as specified
|
||||
* in its StartupSection field.
|
||||
* A reboot request to a vApp URL reboots all of the virtual machines in the
|
||||
* vApp, as specified in its StartupSection field.
|
||||
* <p/>
|
||||
* A reboot request to a virtual machine URL reboots the specified virtual machine.
|
||||
* A reboot request to a virtual machine URL reboots the specified virtual
|
||||
* machine.
|
||||
* <p/>
|
||||
* <h4>NOTE</h4> Because this request sends a signal to the guest OS, the vCloud API cannot track
|
||||
* the progress or verify the result of the requested operation. Hence, void is returned
|
||||
* <h4>NOTE</h4> Because this request sends a signal to the guest OS, the
|
||||
* vCloud API cannot track the progress or verify the result of the requested
|
||||
* operation. Hence, void is returned
|
||||
*/
|
||||
void rebootVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
/**
|
||||
* A suspend request to a vApp URL suspends all of the virtual machines in the vApp, as specified
|
||||
* in its StartupSection field.
|
||||
* A suspend request to a vApp URL suspends all of the virtual machines in
|
||||
* the vApp, as specified in its StartupSection field.
|
||||
* <p/>
|
||||
* A suspend request to a virtual machine URL suspends the specified virtual machine.
|
||||
* A suspend request to a virtual machine URL suspends the specified virtual
|
||||
* machine.
|
||||
*/
|
||||
Task suspendVAppOrVm(URI vAppOrVmId);
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ import org.jclouds.vcloud.domain.ReferenceType;
|
|||
import org.jclouds.vcloud.domain.VCloudSession;
|
||||
import org.jclouds.vcloud.domain.VDC;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.endpoints.OrgList;
|
||||
import org.jclouds.vcloud.endpoints.TasksList;
|
||||
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog;
|
||||
import org.jclouds.vcloud.functions.AllCatalogsInOrg;
|
||||
|
@ -94,7 +95,8 @@ import com.google.inject.name.Names;
|
|||
import domain.VCloudVersionsAsyncClient;
|
||||
|
||||
/**
|
||||
* Configures the VCloud authentication service connection, including logging and http transport.
|
||||
* Configures the VCloud authentication service connection, including logging
|
||||
* and http transport.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -191,6 +193,15 @@ public class CommonVCloudRestClientModule<S extends CommonVCloudClient, A extend
|
|||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@OrgList
|
||||
URI provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
|
||||
VCloudSession session = sessionSupplier.get();
|
||||
return URI.create(Iterables.getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*",
|
||||
"org"));
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class OrgMapSupplier implements Supplier<Map<String, ? extends Org>> {
|
||||
protected final Supplier<VCloudSession> sessionSupplier;
|
||||
|
@ -346,8 +357,7 @@ public class CommonVCloudRestClientModule<S extends CommonVCloudClient, A extend
|
|||
@Singleton
|
||||
@org.jclouds.vcloud.endpoints.VCloudLogin
|
||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
|
||||
checkState(versions.size() > 0, "No versions present");
|
||||
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
|
||||
|
@ -454,8 +464,7 @@ public class CommonVCloudRestClientModule<S extends CommonVCloudClient, A extend
|
|||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>(
|
||||
authException, seconds,
|
||||
new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
authException, seconds, new Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>>() {
|
||||
@Override
|
||||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
|
||||
return supplier.get();
|
||||
|
@ -521,8 +530,7 @@ public class CommonVCloudRestClientModule<S extends CommonVCloudClient, A extend
|
|||
new Function<org.jclouds.vcloud.domain.Catalog, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>() {
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends CatalogItem> apply(
|
||||
org.jclouds.vcloud.domain.Catalog from) {
|
||||
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
*
|
||||
* 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.domain;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.vcloud.domain.ovf.ResourceAllocation;
|
||||
import org.jclouds.vcloud.domain.ovf.System;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* The InstantiateVAppTemplateParams element forms the body of an instantiateVappTemplate request.
|
||||
*/
|
||||
public class InstantiateVAppTemplateParams {
|
||||
|
||||
protected final String info;
|
||||
protected final System virtualSystem;
|
||||
protected final Set<ResourceAllocation> resourceAllocations = Sets.newLinkedHashSet();
|
||||
|
||||
public InstantiateVAppTemplateParams(String info, System virtualSystem, Iterable<? extends ResourceAllocation> resourceAllocations) {
|
||||
this.info = info;
|
||||
this.virtualSystem = virtualSystem;
|
||||
Iterables.addAll(this.resourceAllocations, resourceAllocations);
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public System getSystem() {
|
||||
return virtualSystem;
|
||||
}
|
||||
|
||||
public Set<? extends ResourceAllocation> getResourceAllocations() {
|
||||
return resourceAllocations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((info == null) ? 0 : info.hashCode());
|
||||
result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
|
||||
result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
InstantiateVAppTemplateParams other = (InstantiateVAppTemplateParams) obj;
|
||||
if (info == null) {
|
||||
if (other.info != null)
|
||||
return false;
|
||||
} else if (!info.equals(other.info))
|
||||
return false;
|
||||
if (resourceAllocations == null) {
|
||||
if (other.resourceAllocations != null)
|
||||
return false;
|
||||
} else if (!resourceAllocations.equals(other.resourceAllocations))
|
||||
return false;
|
||||
if (virtualSystem == null) {
|
||||
if (other.virtualSystem != null)
|
||||
return false;
|
||||
} else if (!virtualSystem.equals(other.virtualSystem))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.vcloud.endpoints;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Related to a VCloud express Org List.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Qualifier
|
||||
public @interface OrgList {
|
||||
|
||||
}
|
|
@ -45,6 +45,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextFactory.ContextSpec;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
|
@ -67,6 +68,7 @@ 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.OrgListHandler;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
||||
import org.jclouds.vcloud.xml.TaskHandler;
|
||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||
|
@ -125,11 +127,11 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).addNetworkConfig(
|
||||
new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"),
|
||||
null)));
|
||||
processor
|
||||
.createRequest(method, URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "CentOS 01", processorCount(1).memory(
|
||||
512).disk(1024).addNetworkConfig(
|
||||
new NetworkConfig(null, URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null)));
|
||||
}
|
||||
|
||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
@ -157,8 +159,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server",
|
||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "new-linux-server", new CloneVAppOptions()
|
||||
.deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
|
@ -173,6 +175,21 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("listOrgs");
|
||||
HttpRequest request = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, OrgListHandler.class);
|
||||
assertExceptionParserClassEquals(method, MapHttp4xxCodesToExceptions.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudAsyncClient.class.getMethod("getOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
|
@ -790,42 +807,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
|
||||
return Suppliers
|
||||
.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of(
|
||||
"org",
|
||||
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
|
||||
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||
"vdc",
|
||||
new VDCImpl(
|
||||
"vdc",
|
||||
null,
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
|
||||
null,
|
||||
null,
|
||||
"description",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
ImmutableMap
|
||||
.<String, ReferenceType> of(
|
||||
"vapp",
|
||||
new ReferenceTypeImpl(
|
||||
"vapp",
|
||||
"application/vnd.vmware.vcloud.vApp+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")),
|
||||
"network",
|
||||
new ReferenceTypeImpl(
|
||||
"network",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))),
|
||||
null, 0, 0, 0, false))));
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new VDCImpl("vdc", null, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), null, null, "description", null,
|
||||
null, null, null, null, ImmutableMap.<String, ReferenceType> of("vapp", new ReferenceTypeImpl(
|
||||
"vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), "network",
|
||||
new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), null, 0, 0, 0,
|
||||
false))));
|
||||
|
||||
}
|
||||
|
||||
|
@ -840,17 +832,14 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
public Map<String, Org> get() {
|
||||
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", null, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap
|
||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog",
|
||||
VCloudMediaType.CATALOG_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML,
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("network", new ReferenceTypeImpl("network",
|
||||
VCloudMediaType.NETWORK_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))),
|
||||
new ReferenceTypeImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList
|
||||
.<Task> of()));
|
||||
.<String, ReferenceType> of("network", new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML,
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))), new ReferenceTypeImpl(
|
||||
"tasksList", VCloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList.<Task> of()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,12 +855,11 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
|
||||
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", "type",
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description",
|
||||
ImmutableMap.<String, ReferenceType> of("item", new ReferenceTypeImpl("item",
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description", ImmutableMap
|
||||
.<String, ReferenceType> of("item", new ReferenceTypeImpl("item",
|
||||
"application/vnd.vmware.vcloud.catalogItem+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
|
||||
"template", new ReferenceTypeImpl("template",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), "template",
|
||||
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))),
|
||||
ImmutableList.<Task> of(), true)));
|
||||
}
|
||||
|
@ -885,25 +873,13 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
|
|||
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return ImmutableMap
|
||||
.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org",
|
||||
ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog",
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||
"template",
|
||||
new CatalogItemImpl(
|
||||
"template",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"),
|
||||
"description",
|
||||
new ReferenceTypeImpl(
|
||||
"template",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
||||
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org", ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog", ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of("template",
|
||||
new CatalogItemImpl("template", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description",
|
||||
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")),
|
||||
ImmutableMap.<String, String> of()))));
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,17 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest<VCloudClien
|
|||
credential = checkNotNull(System.getProperty("vcloud.credential"), "vcloud.credential");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOrgs() throws Exception {
|
||||
for (ReferenceType response : connection.listOrgs().values()) {
|
||||
assertNotNull(response);
|
||||
assertNotNull(response.getName());
|
||||
assertNotNull(response.getHref());
|
||||
assertEquals(connection.getOrg(response.getHref()).getName(), response.getName());
|
||||
assertEquals(connection.findOrgNamed(response.getName()).getName(), response.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVAppTemplate() throws Exception {
|
||||
Org org = connection.findOrgNamed(null);
|
||||
|
|
Loading…
Reference in New Issue