You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/29 20:31:54 UTC
[12/14] JCLOUDS-166,
JCLOUDS-167 - Removing async from vcloud and Terremark APIs/providers
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java
deleted file mode 100644
index 5fb4fe1..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VDCClient.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.features;
-
-import java.net.URI;
-import org.jclouds.vcloud.domain.VDC;
-
-/**
- * Provides access to VDC functionality in vCloud
- * <p/>
- *
- * @author Adrian Cole
- */
-public interface VDCClient {
- VDC getVDC(URI vdc);
-
- /**
- * returns the VDC in the organization associated with the specified name. Note that both
- * parameters can be null to choose default.
- *
- * @param orgName
- * organization name, or null for the default
- * @param vdcName
- * catalog name, or null for the default
- * @throws NoSuchElementException
- * if you specified an org or vdc name that isn't present
- */
- VDC findVDCInOrgNamed(String orgName, String vdcName);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java
new file mode 100644
index 0000000..dce9075
--- /dev/null
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmApi.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
+import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML;
+import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML;
+import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
+import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VM_XML;
+
+import java.io.InputStream;
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindCPUCountToXmlPayload;
+import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload;
+import org.jclouds.vcloud.binders.BindMemoryToXmlPayload;
+import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload;
+import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
+import org.jclouds.vcloud.domain.GuestCustomizationSection;
+import org.jclouds.vcloud.domain.NetworkConnectionSection;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.Vm;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VmHandler;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides access to VM functionality in vCloud
+ * <p/>
+ *
+ * @author Adrian Cole
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VmApi {
+
+ @GET
+ @Consumes(VM_XML)
+ @XMLResponseParser(VmHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Vm getVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deployVm(@EndpointParam URI href);
+
+ /**
+ * like {@link #deploy(URI)}, except deploy transitions to power on state
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(DEPLOYVAPPPARAMS_XML)
+ @Path("/action/deploy")
+ @MapBinder(BindDeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "powerOn", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task deployAndPowerOnVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ * <h4>NOTE</h4>
+ * Using this method will simply power off the vms. In order to save their state, use
+ * {@link #undeployAndSaveStateOf}
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployVm(@EndpointParam URI href);
+
+ /**
+ * like {@link #undeploy(URI)}, where the undeployed virtual machines are suspended and their
+ * suspend state saved
+ *
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Produces(UNDEPLOYVAPPPARAMS_XML)
+ @Path("/action/undeploy")
+ @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
+ @PayloadParams(keys = "saveState", values = "true")
+ @XMLResponseParser(TaskHandler.class)
+ Task undeployAndSaveStateOfVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ * <p/>
+ * <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
+ * deployment.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOn")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOnVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/powerOff")
+ @XMLResponseParser(TaskHandler.class)
+ Task powerOffVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ * <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
+ */
+ @POST
+ @Path("/power/action/shutdown")
+ void shutdownVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/reset")
+ @XMLResponseParser(TaskHandler.class)
+ Task resetVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ * <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
+ */
+ @POST
+ @Path("/power/action/reboot")
+ void rebootVm(@EndpointParam URI href);
+
+ /**
+ * 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.
+ */
+ @POST
+ @Consumes(TASK_XML)
+ @Path("/power/action/suspend")
+ @XMLResponseParser(TaskHandler.class)
+ Task suspendVm(@EndpointParam URI href);
+
+ /**
+ * Get a Screen Thumbnail for a Virtual Machine
+ *
+ * @param href
+ * to snapshot
+ */
+ @GET
+ @Path("/screen")
+ @Consumes("image/png")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ InputStream getScreenThumbnailForVm(@EndpointParam URI vm);
+
+ /**
+ * Modify the Guest Customization Section of a Virtual Machine
+ *
+ * @param href
+ * uri to modify
+ * @param updated
+ * guestCustomizationSection
+ * @return task in progress
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(GUESTCUSTOMIZATIONSECTION_XML)
+ @Path("/guestCustomizationSection")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateGuestCustomizationOfVm(
+ @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
+ @EndpointParam URI href);
+
+ /**
+ * Modify the Network Connection Section of a Virtual Machine
+ *
+ * @param href
+ * uri to modify
+ * @param updated
+ * networkConnectionSection
+ * @return task in progress
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(NETWORKCONNECTIONSECTION_XML)
+ @Path("/networkConnectionSection")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateNetworkConnectionOfVm(
+ @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
+ @EndpointParam URI href);
+
+ /**
+ * update the cpuCount of an existing VM
+ *
+ * @param href
+ * to update
+ * @param cpuCount
+ * count to change the primary cpu to
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(RASDITEM_XML)
+ @Path("/virtualHardwareSection/cpu")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
+ @EndpointParam URI href);
+
+ /**
+ * update the memoryInMB of an existing VM
+ *
+ * @param href
+ * to update
+ * @param memoryInMB
+ * memory in MB to assign to the VM
+ */
+ @PUT
+ @Consumes(TASK_XML)
+ @Produces(RASDITEM_XML)
+ @Path("/virtualHardwareSection/memory")
+ @XMLResponseParser(TaskHandler.class)
+ Task updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
+ @EndpointParam URI href);
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java
deleted file mode 100644
index 6b945f9..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmAsyncClient.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.features;
-
-import static org.jclouds.vcloud.VCloudMediaType.DEPLOYVAPPPARAMS_XML;
-import static org.jclouds.vcloud.VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML;
-import static org.jclouds.vcloud.VCloudMediaType.NETWORKCONNECTIONSECTION_XML;
-import static org.jclouds.vcloud.VCloudMediaType.RASDITEM_XML;
-import static org.jclouds.vcloud.VCloudMediaType.TASK_XML;
-import static org.jclouds.vcloud.VCloudMediaType.UNDEPLOYVAPPPARAMS_XML;
-import static org.jclouds.vcloud.VCloudMediaType.VM_XML;
-
-import java.io.InputStream;
-import java.net.URI;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.EndpointParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.PayloadParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.XMLResponseParser;
-import org.jclouds.vcloud.binders.BindCPUCountToXmlPayload;
-import org.jclouds.vcloud.binders.BindDeployVAppParamsToXmlPayload;
-import org.jclouds.vcloud.binders.BindGuestCustomizationSectionToXmlPayload;
-import org.jclouds.vcloud.binders.BindMemoryToXmlPayload;
-import org.jclouds.vcloud.binders.BindNetworkConnectionSectionToXmlPayload;
-import org.jclouds.vcloud.binders.BindUndeployVAppParamsToXmlPayload;
-import org.jclouds.vcloud.domain.GuestCustomizationSection;
-import org.jclouds.vcloud.domain.NetworkConnectionSection;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.Vm;
-import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
-import org.jclouds.vcloud.xml.TaskHandler;
-import org.jclouds.vcloud.xml.VmHandler;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides access to Vm functionality in vCloud
- * <p/>
- *
- * @author Adrian Cole
- */
-@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
-public interface VmAsyncClient {
-
- /**
- * @see VmClient#getVm
- */
- @GET
- @Consumes(VM_XML)
- @XMLResponseParser(VmHandler.class)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Vm> getVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#deployVm
- */
- @POST
- @Consumes(TASK_XML)
- @Produces(DEPLOYVAPPPARAMS_XML)
- @Path("/action/deploy")
- @MapBinder(BindDeployVAppParamsToXmlPayload.class)
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> deployVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#deployAndPowerOnVm
- */
- @POST
- @Consumes(TASK_XML)
- @Produces(DEPLOYVAPPPARAMS_XML)
- @Path("/action/deploy")
- @MapBinder(BindDeployVAppParamsToXmlPayload.class)
- @PayloadParams(keys = "powerOn", values = "true")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> deployAndPowerOnVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#undeployVm
- */
- @POST
- @Consumes(TASK_XML)
- @Produces(UNDEPLOYVAPPPARAMS_XML)
- @Path("/action/undeploy")
- @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> undeployVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#undeployAndSaveStateOfVm
- */
- @POST
- @Consumes(TASK_XML)
- @Produces(UNDEPLOYVAPPPARAMS_XML)
- @Path("/action/undeploy")
- @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
- @PayloadParams(keys = "saveState", values = "true")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> undeployAndSaveStateOfVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#powerOnVm
- */
- @POST
- @Consumes(TASK_XML)
- @Path("/power/action/powerOn")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> powerOnVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#powerOffVm
- */
- @POST
- @Consumes(TASK_XML)
- @Path("/power/action/powerOff")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> powerOffVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#shutdownVm
- */
- @POST
- @Path("/power/action/shutdown")
- ListenableFuture<Void> shutdownVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#resetVm
- */
- @POST
- @Consumes(TASK_XML)
- @Path("/power/action/reset")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> resetVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#rebootVm
- */
- @POST
- @Path("/power/action/reboot")
- ListenableFuture<Void> rebootVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#suspendVm
- */
- @POST
- @Consumes(TASK_XML)
- @Path("/power/action/suspend")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> suspendVm(@EndpointParam URI href);
-
- /**
- * @see VmClient#updateCPUCountOfVm
- */
- @PUT
- @Consumes(TASK_XML)
- @Produces(RASDITEM_XML)
- @Path("/virtualHardwareSection/cpu")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> updateCPUCountOfVm(@BinderParam(BindCPUCountToXmlPayload.class) int cpuCount,
- @EndpointParam URI href);
-
- /**
- * @see VmClient#updateMemoryMBOfVm
- */
- @PUT
- @Consumes(TASK_XML)
- @Produces(RASDITEM_XML)
- @Path("/virtualHardwareSection/memory")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> updateMemoryMBOfVm(@BinderParam(BindMemoryToXmlPayload.class) int memoryInMB,
- @EndpointParam URI href);
-
- /**
- * @see VmClient#updateGuestCustomizationOfVm
- */
- @PUT
- @Consumes(TASK_XML)
- @Produces(GUESTCUSTOMIZATIONSECTION_XML)
- @Path("/guestCustomizationSection")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> updateGuestCustomizationOfVm(
- @BinderParam(BindGuestCustomizationSectionToXmlPayload.class) GuestCustomizationSection guestCustomizationSection,
- @EndpointParam URI href);
-
- /**
- * @see VmClient#updateNetworkConnectionOfVm
- */
- @PUT
- @Consumes(TASK_XML)
- @Produces(NETWORKCONNECTIONSECTION_XML)
- @Path("/networkConnectionSection")
- @XMLResponseParser(TaskHandler.class)
- ListenableFuture<Task> updateNetworkConnectionOfVm(
- @BinderParam(BindNetworkConnectionSectionToXmlPayload.class) NetworkConnectionSection networkConnectionSection,
- @EndpointParam URI href);
-
- /**
- *
- * @see VmClient#getScreenThumbnailForVm
- */
- @GET
- @Path("/screen")
- @Consumes("image/png")
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<InputStream> getScreenThumbnailForVm(@EndpointParam URI vm);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java
deleted file mode 100644
index 9e77a19..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/features/VmClient.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.features;
-
-import java.io.InputStream;
-import java.net.URI;
-import org.jclouds.vcloud.domain.GuestCustomizationSection;
-import org.jclouds.vcloud.domain.NetworkConnectionSection;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.Vm;
-
-/**
- * Provides access to VM functionality in vCloud
- * <p/>
- *
- * @author Adrian Cole
- */
-public interface VmClient {
-
- Vm getVm(URI vApp);
-
- /**
- * 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.
- */
- Task deployVm(URI href);
-
- /**
- * like {@link #deploy(URI)}, except deploy transitions to power on state
- *
- */
- Task deployAndPowerOnVm(URI href);
-
- /**
- * 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.
- * <h4>NOTE</h4>
- * Using this method will simply power off the vms. In order to save their state, use
- * {@link #undeployAndSaveStateOf}
- *
- */
- Task undeployVm(URI href);
-
- /**
- * like {@link #undeploy(URI)}, where the undeployed virtual machines are suspended and their
- * suspend state saved
- *
- */
- Task undeployAndSaveStateOfVm(URI href);
-
- /**
- * 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.
- * <p/>
- * <h4>NOTE</h4> A powerOn request to a vApp or virtual machine that is undeployed forces
- * deployment.
- */
- Task powerOnVm(URI href);
-
- /**
- * 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.
- */
- Task powerOffVm(URI href);
-
- /**
- * 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.
- * <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
- */
- void shutdownVm(URI href);
-
- /**
- * 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.
- */
- Task resetVm(URI href);
-
- /**
- * 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.
- * <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
- */
- void rebootVm(URI href);
-
- /**
- * 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.
- */
- Task suspendVm(URI href);
-
- /**
- * Get a Screen Thumbnail for a Virtual Machine
- *
- * @param href
- * to snapshot
- */
- InputStream getScreenThumbnailForVm(URI href);
-
- /**
- * Modify the Guest Customization Section of a Virtual Machine
- *
- * @param href
- * uri to modify
- * @param updated
- * guestCustomizationSection
- * @return task in progress
- */
- Task updateGuestCustomizationOfVm(GuestCustomizationSection guestCustomizationSection, URI href);
-
- /**
- * Modify the Network Connection Section of a Virtual Machine
- *
- * @param href
- * uri to modify
- * @param updated
- * networkConnectionSection
- * @return task in progress
- */
- Task updateNetworkConnectionOfVm(NetworkConnectionSection guestCustomizationSection, URI href);
-
- /**
- * update the cpuCount of an existing VM
- *
- * @param href
- * to update
- * @param cpuCount
- * count to change the primary cpu to
- */
- Task updateCPUCountOfVm(int cpuCount, URI href);
-
- /**
- * update the memoryInMB of an existing VM
- *
- * @param href
- * to update
- * @param memoryInMB
- * memory in MB to assign to the VM
- */
- Task updateMemoryMBOfVm(int memoryInMB, URI href);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
index 5aa7dd5..746dce1 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
@@ -17,16 +17,14 @@
package org.jclouds.vcloud.functions;
import static com.google.common.collect.Iterables.filter;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
@@ -34,8 +32,6 @@ import org.jclouds.vcloud.domain.ReferenceType;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -45,26 +41,24 @@ public class CatalogItemsInCatalog implements Function<Catalog, Iterable<Catalog
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- CatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ CatalogItemsInCatalog(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<CatalogItem> apply(Catalog from) {
- return transformParallel(filter(from.values(), new Predicate<ReferenceType>() {
+ return transform(filter(from.values(), new Predicate<ReferenceType>() {
public boolean apply(ReferenceType input) {
return input.getType().equals(VCloudMediaType.CATALOGITEM_XML);
}
- }), new Function<ReferenceType, ListenableFuture<? extends CatalogItem>>() {
- public ListenableFuture<CatalogItem> apply(ReferenceType from) {
+ }), new Function<ReferenceType, CatalogItem>() {
+ public CatalogItem apply(ReferenceType from) {
return aclient.getCatalogClient().getCatalogItem(from.getHref());
}
- }, userExecutor, null, logger, "catalogItems in " + from.getHref());
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
index 174f817..92f91a9 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
@@ -16,23 +16,19 @@
*/
package org.jclouds.vcloud.functions;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -42,21 +38,19 @@ public class CatalogsInOrg implements Function<Org, Iterable<Catalog>> {
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- CatalogsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ CatalogsInOrg(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<Catalog> apply(final Org org) {
- return transformParallel(org.getCatalogs().values(), new Function<ReferenceType, ListenableFuture<? extends Catalog>>() {
- public ListenableFuture<Catalog> apply(ReferenceType from) {
+ return transform(org.getCatalogs().values(), new Function<ReferenceType, Catalog>() {
+ public Catalog apply(ReferenceType from) {
return aclient.getCatalogClient().getCatalog(from.getHref());
}
- }, userExecutor, null, logger, "catalogs in " + org.getName());
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
index 4b6f8dd..1160494 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
@@ -16,23 +16,19 @@
*/
package org.jclouds.vcloud.functions;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.network.OrgNetwork;
import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -42,22 +38,20 @@ public class NetworksInOrg implements Function<Org, Iterable<OrgNetwork>> {
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- NetworksInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ NetworksInOrg(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<OrgNetwork> apply(final Org org) {
- return transformParallel(org.getNetworks().values(), new Function<ReferenceType, ListenableFuture<? extends OrgNetwork>>() {
- public ListenableFuture<? extends OrgNetwork> apply(ReferenceType from) {
+ return transform(org.getNetworks().values(), new Function<ReferenceType, OrgNetwork>() {
+ public OrgNetwork apply(ReferenceType from) {
return aclient.getNetworkClient().getNetwork(from.getHref());
}
- }, userExecutor, null, logger, "OrgNetworks in org " + org.getName());
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
index 0180a78..138a8d2 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
@@ -16,27 +16,23 @@
*/
package org.jclouds.vcloud.functions;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import java.net.URI;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Org;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -45,13 +41,11 @@ import com.google.common.util.concurrent.ListeningExecutorService;
public class OrgsForLocations implements Function<Iterable<Location>, Iterable<Org>> {
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- OrgsForLocations(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ OrgsForLocations(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
/**
@@ -69,11 +63,11 @@ public class OrgsForLocations implements Function<Iterable<Location>, Iterable<O
return URI.create(from.getParent().getId());
}
});
- return transformParallel(uris, new Function<URI, ListenableFuture<? extends Org>>() {
- public ListenableFuture<Org> apply(URI from) {
+ return transform(uris, new Function<URI, Org>() {
+ public Org apply(URI from) {
return aclient.getOrgClient().getOrg(from);
}
- }, userExecutor, null, logger, "organizations for uris");
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
index 9301761..c4e4f8e 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
@@ -16,23 +16,19 @@
*/
package org.jclouds.vcloud.functions;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Org;
import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -41,22 +37,20 @@ import com.google.common.util.concurrent.ListeningExecutorService;
public class OrgsForNames implements Function<Iterable<String>, Iterable<Org>> {
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- OrgsForNames(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ OrgsForNames(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<Org> apply(Iterable<String> from) {
- return Iterables.filter(transformParallel(from, new Function<String, ListenableFuture<? extends Org>>() {
- public ListenableFuture<Org> apply(String from) {
+ return Iterables.filter(transform(from, new Function<String, Org>() {
+ public Org apply(String from) {
return aclient.getOrgClient().findOrgNamed(from);
}
- }, userExecutor, null, logger, "organizations for names"), Predicates.notNull());
+ }), Predicates.notNull());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
index 63fe698..ea23416 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
@@ -17,8 +17,7 @@
package org.jclouds.vcloud.functions;
import static com.google.common.collect.Iterables.filter;
-import static org.jclouds.Constants.PROPERTY_USER_THREADS;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
@@ -27,7 +26,7 @@ import javax.inject.Singleton;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.VAppTemplate;
@@ -35,8 +34,6 @@ import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -46,27 +43,24 @@ public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogIt
@Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
private Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
-
+ private final VCloudApi aclient;
@Inject
- VAppTemplatesForCatalogItems(VCloudAsyncClient aclient, @Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ VAppTemplatesForCatalogItems(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<VAppTemplate> apply(Iterable<CatalogItem> from) {
- return filter(transformParallel(filter(from, new Predicate<CatalogItem>() {
+ return filter(transform(filter(from, new Predicate<CatalogItem>() {
public boolean apply(CatalogItem input) {
return input.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML);
}
- }), new Function<CatalogItem, ListenableFuture<? extends VAppTemplate>>() {
- public ListenableFuture<VAppTemplate> apply(CatalogItem from) {
+ }), new Function<CatalogItem, VAppTemplate>() {
+ public VAppTemplate apply(CatalogItem from) {
return aclient.getVAppTemplateClient().getVAppTemplate(from.getEntity().getHref());
}
- }, userExecutor, null, logger, "vappTemplates in"), Predicates.notNull());
+ }), Predicates.notNull());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
index 2053edc..7f52102 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
@@ -16,23 +16,19 @@
*/
package org.jclouds.vcloud.functions;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
+import static com.google.common.collect.Iterables.transform;
import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Singleton;
-import org.jclouds.Constants;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudAsyncClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.VDC;
import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
/**
* @author Adrian Cole
@@ -42,22 +38,20 @@ public class VDCsInOrg implements Function<Org, Iterable<VDC>> {
@Resource
public Logger logger = Logger.NULL;
- private final VCloudAsyncClient aclient;
- private final ListeningExecutorService userExecutor;
+ private final VCloudApi aclient;
@Inject
- VDCsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
+ VDCsInOrg(VCloudApi aclient) {
this.aclient = aclient;
- this.userExecutor = userExecutor;
}
@Override
public Iterable<VDC> apply(final Org org) {
- return transformParallel(org.getVDCs().values(), new Function<ReferenceType, ListenableFuture<? extends VDC>>() {
- public ListenableFuture<? extends VDC> apply(ReferenceType from) {
+ return transform(org.getVDCs().values(), new Function<ReferenceType, VDC>() {
+ public VDC apply(ReferenceType from) {
return aclient.getVDCClient().getVDC(from.getHref());
}
- }, userExecutor, null, logger, "vdcs in org " + org.getName());
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
new file mode 100644
index 0000000..acf77c5
--- /dev/null
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.internal;
+
+import java.io.Closeable;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
+
+@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class)
+@RequestFilters(BasicAuthentication.class)
+public interface VCloudLoginApi extends Closeable {
+
+ /**
+ * This request returns a token to use in subsequent requests. After 30 minutes of inactivity,
+ * the token expires and you have to request a new token with this call.
+ */
+ @POST
+ @ResponseParser(ParseLoginResponseFromHeaders.class)
+ @Consumes(VCloudMediaType.ORGLIST_XML)
+ VCloudSession login();
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClient.java
deleted file mode 100644
index 2cd6631..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClient.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.internal;
-
-import java.io.Closeable;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Endpoint;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.vcloud.VCloudMediaType;
-import org.jclouds.vcloud.domain.VCloudSession;
-import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Establishes a context with a VCloud endpoint.
- * <p/>
- *
- * @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
- * @author Adrian Cole
- */
-@Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class)
-@RequestFilters(BasicAuthentication.class)
-public interface VCloudLoginAsyncClient extends Closeable {
-
- /**
- * This request returns a token to use in subsequent requests. After 30 minutes of inactivity,
- * the token expires and you have to request a new token with this call.
- */
- @POST
- @ResponseParser(ParseLoginResponseFromHeaders.class)
- @Consumes(VCloudMediaType.ORGLIST_XML)
- ListenableFuture<VCloudSession> login();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginClient.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginClient.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginClient.java
deleted file mode 100644
index 20a3a34..0000000
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/internal/VCloudLoginClient.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.internal;
-
-import java.io.Closeable;
-
-import org.jclouds.vcloud.domain.VCloudSession;
-
-public interface VCloudLoginClient extends Closeable {
-
- VCloudSession login();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
index df8c93a..70962bc 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
@@ -24,7 +24,7 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.ovf.Envelope;
-import org.jclouds.vcloud.VCloudClient;
+import org.jclouds.vcloud.VCloudApi;
import com.google.common.cache.CacheLoader;
@@ -33,10 +33,10 @@ public class OVFLoader extends CacheLoader<URI, Envelope> {
@Resource
protected Logger logger = Logger.NULL;
- private final VCloudClient client;
+ private final VCloudApi client;
@Inject
- OVFLoader(VCloudClient client) {
+ OVFLoader(VCloudApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
index a13c60c..f3f80b3 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
@@ -23,7 +23,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.VCloudClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.VAppTemplate;
import com.google.common.cache.CacheLoader;
@@ -33,10 +33,10 @@ public class VAppTemplateLoader extends CacheLoader<URI, VAppTemplate> {
@Resource
protected Logger logger = Logger.NULL;
- private final VCloudClient client;
+ private final VCloudApi client;
@Inject
- VAppTemplateLoader(VCloudClient client) {
+ VAppTemplateLoader(VCloudApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
index 30a334a..578b673 100644
--- a/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
+++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java
@@ -23,7 +23,7 @@ import javax.inject.Singleton;
import org.jclouds.logging.Logger;
import org.jclouds.vcloud.TaskInErrorStateException;
-import org.jclouds.vcloud.VCloudClient;
+import org.jclouds.vcloud.VCloudApi;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TaskStatus;
@@ -39,13 +39,13 @@ import com.google.inject.Inject;
@Singleton
public class TaskSuccess implements Predicate<URI> {
- private final VCloudClient client;
+ private final VCloudApi client;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public TaskSuccess(VCloudClient client) {
+ public TaskSuccess(VCloudApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
new file mode 100644
index 0000000..fab8690
--- /dev/null
+++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.utils.TestUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code VCloudApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "VCloudApiTest")
+public class VCloudApiTest extends BaseVCloudApiTest<VCloudApi> {
+
+ private VCloudApi syncClient;
+
+ public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
+ assert syncClient.getVAppClient() != null;
+ assert syncClient.getCatalogClient() != null;
+ assert syncClient.getVmClient() != null;
+ assert syncClient.getVAppTemplateClient() != null;
+ assert syncClient.getTaskClient() != null;
+ assert syncClient.getVDCClient() != null;
+ assert syncClient.getNetworkClient() != null;
+ assert syncClient.getOrgClient() != null;
+ }
+
+ @BeforeClass
+ @Override
+ protected void setupFactory() throws IOException {
+ super.setupFactory();
+ syncClient = injector.getInstance(VCloudApi.class);
+ }
+
+ @DataProvider
+ public Object[][] ignoreOnWindows() {
+ return (TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
+ : TestUtils.SINGLE_NO_ARG_INVOCATION);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java
deleted file mode 100644
index 485bd57..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudAsyncClientTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
-import org.jclouds.vcloud.utils.TestUtils;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code VCloudAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "VCloudAsyncClientTest")
-public class VCloudAsyncClientTest extends BaseVCloudAsyncClientTest<VCloudAsyncClient> {
-
- private VCloudAsyncClient asyncClient;
- private VCloudClient syncClient;
-
- public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert syncClient.getVAppClient() != null;
- assert syncClient.getCatalogClient() != null;
- assert syncClient.getVmClient() != null;
- assert syncClient.getVAppTemplateClient() != null;
- assert syncClient.getTaskClient() != null;
- assert syncClient.getVDCClient() != null;
- assert syncClient.getNetworkClient() != null;
- assert syncClient.getOrgClient() != null;
- }
-
- public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert asyncClient.getVAppClient() != null;
- assert asyncClient.getCatalogClient() != null;
- assert asyncClient.getVmClient() != null;
- assert asyncClient.getVAppTemplateClient() != null;
- assert asyncClient.getTaskClient() != null;
- assert asyncClient.getVDCClient() != null;
- assert asyncClient.getNetworkClient() != null;
- assert asyncClient.getOrgClient() != null;
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- asyncClient = injector.getInstance(VCloudAsyncClient.class);
- syncClient = injector.getInstance(VCloudClient.class);
- }
-
- @DataProvider
- public Object[][] ignoreOnWindows() {
- return (TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
- : TestUtils.SINGLE_NO_ARG_INVOCATION);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
index 66314fa..2aad4fd 100644
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
+++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java
@@ -16,7 +16,7 @@
*/
package org.jclouds.vcloud;
-import org.jclouds.vcloud.internal.BaseVCloudClientLiveTest;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
import org.testng.annotations.Test;
/**
@@ -25,14 +25,13 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true)
-public class VCloudSessionRefreshLiveTest extends BaseVCloudClientLiveTest {
+public class VCloudSessionRefreshLiveTest extends BaseVCloudApiLiveTest {
private static final int timeOut = 40;
@Test
public void testSessionRefresh() throws Exception {
- VCloudClient connection = VCloudClient.class.cast(client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN)
- .getApi());
+ VCloudApi connection = view.unwrapApi(VCloudApi.class);
connection.getOrgClient().findOrgNamed(null);
Thread.sleep(timeOut * 1000);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
new file mode 100644
index 0000000..3df78b6
--- /dev/null
+++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud;
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.providers.AnonymousProviderMetadata;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.xml.SupportedVersionsHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+
+/**
+ * Tests behavior of {@code VCloudVersionsApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "VCloudVersionsApiTest")
+public class VCloudVersionsApiTest extends BaseAsyncClientTest<VCloudVersionsApi> {
+
+ public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(VCloudVersionsApi.class, "getSupportedVersions");
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
+
+ assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, SupportedVersionsHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 0);
+ }
+
+ @Override
+ protected ProviderMetadata createProviderMetadata() {
+ return AnonymousProviderMetadata.forApiOnEndpoint(VCloudVersionsApi.class,
+ "http://localhost:8080");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java
deleted file mode 100644
index fdcf810..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud;
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.providers.AnonymousProviderMetadata;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.vcloud.xml.SupportedVersionsHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-
-/**
- * Tests behavior of {@code VCloudVersionsAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "VCloudVersionsAsyncClientTest")
-public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest<VCloudVersionsAsyncClient> {
-
- public void testVersions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VCloudVersionsAsyncClient.class, "getSupportedVersions");
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, SupportedVersionsHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 0);
- }
-
- @Override
- protected ProviderMetadata createProviderMetadata() {
- return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class,
- VCloudVersionsAsyncClient.class, "http://localhost:8080");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
new file mode 100644
index 0000000..972366e
--- /dev/null
+++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.rest.annotations.ApiVersion;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Key;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CatalogApiLiveTest")
+public class CatalogApiLiveTest extends BaseVCloudApiLiveTest {
+ @Test
+ public void testGetCatalog() throws Exception {
+ Org org = getVCloudApi().getOrgClient().findOrgNamed(null);
+ for (ReferenceType catalog : org.getCatalogs().values()) {
+ assertEquals(catalog.getType(), VCloudMediaType.CATALOG_XML);
+ assertNotNull(getVCloudApi().getCatalogClient().getCatalog(catalog.getHref()));
+ }
+ }
+
+ @Test
+ public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception {
+ // when we are in vCloud 1.0.0 public catalogs don't work, so our default
+ // catalog is private
+ if (!view.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5"))
+ assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a61ad06c/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
new file mode 100644
index 0000000..cf63390
--- /dev/null
+++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.vcloud.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.net.URI;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.internal.BaseVCloudApiTest;
+import org.jclouds.vcloud.options.CatalogItemOptions;
+import org.jclouds.vcloud.xml.CatalogHandler;
+import org.jclouds.vcloud.xml.CatalogItemHandler;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code CatalogApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "CatalogApiTest")
+public class CatalogApiTest extends BaseVCloudApiTest<CatalogApi> {
+
+ public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "getCatalog", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testCatalogInOrg() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "findCatalogInOrgNamed", String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "getCatalogItem", URI.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2")));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "findCatalogItemInOrgCatalogNamed", String.class,
+ String.class, String.class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "item"));
+
+ assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(request);
+ }
+
+ public void testAddVAppTemplateOrMediaImageToCatalogAndNameItem() throws SecurityException, NoSuchMethodException,
+ IOException {
+ Invokable<?, ?> method = method(CatalogApi.class, "addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class,
+ URI.class, String.class, CatalogItemOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI.create("http://fooentity"), URI
+ .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder
+ .description("mydescription")));
+
+ assertRequestLineEquals(request,
+ "POST https://vcenterprise.bluelock.com/api/v1.0/catalog/1/catalogItems HTTP/1.1");
+ assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
+ assertPayloadEquals(
+ request,
+ "<CatalogItem xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"myname\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd\"><Description>mydescription</Description><Entity href=\"http://fooentity\"/></CatalogItem>",
+ "application/vnd.vmware.vcloud.catalogItem+xml", false);
+
+ assertResponseParserClassEquals(method, request, ParseSax.class);
+ assertSaxResponseParserClassEquals(method, CatalogItemHandler.class);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+}