You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by me...@apache.org on 2014/03/05 06:57:12 UTC
[11/18] Forking jclouds's vcloud API
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
new file mode 100755
index 0000000..bd11f25
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java
@@ -0,0 +1,180 @@
+/*
+ * 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.TASK_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VAPPTEMPLATE_XML;
+import static org.jclouds.vcloud.VCloudMediaType.VAPP_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.ovf.xml.EnvelopeHandler;
+import org.jclouds.predicates.validators.DnsNameValidator;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.ParamValidators;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.PayloadParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindCaptureVAppParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindCloneVAppTemplateParamsToXmlPayload;
+import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlPayload;
+import org.jclouds.vcloud.binders.OrgNameCatalogNameVAppTemplateNameToEndpoint;
+import org.jclouds.vcloud.domain.Task;
+import org.jclouds.vcloud.domain.VApp;
+import org.jclouds.vcloud.domain.VAppTemplate;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.options.CaptureVAppOptions;
+import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+import org.jclouds.vcloud.xml.TaskHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
+import org.jclouds.vcloud.xml.VAppTemplateHandler;
+
+
+/**
+ * Provides access to VApp Template functionality in vCloud
+ * <p/>
+ *
+ * @see <a href="http://communities.vmware.com/community/developer/forums/vcloudapi" />
+ * @author Adrian Cole
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VAppTemplateApi {
+ /**
+ * 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
+ * @param catalogName
+ * catalog name, or null for the default
+ * @param itemName
+ * item you wish to lookup
+ *
+ * @throws NoSuchElementException
+ * if you specified an org, catalog, or catalog item name that isn't present
+ */
+ @GET
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameCatalogNameVAppTemplateNameToEndpoint.class)
+ VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("catalogName") String catalogName,
+ @PayloadParam("itemName") String itemName);
+
+ /**
+ */
+ @POST
+ @Path("/action/instantiateVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
+ @Consumes(VAPP_XML)
+ @XMLResponseParser(VAppHandler.class)
+ @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
+ VApp createVAppInVDCByInstantiatingTemplate(
+ @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @EndpointParam URI vdc,
+ @PayloadParam("template") URI template, InstantiateVAppTemplateOptions... options);
+
+ @POST
+ @Path("/action/cloneVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
+ Task copyVAppTemplateToVDCAndName(@PayloadParam("Source") URI sourceVAppTemplate,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppTemplateOptions... options);
+
+ @POST
+ @Path("/action/cloneVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml")
+ @Consumes(TASK_XML)
+ @XMLResponseParser(TaskHandler.class)
+ @PayloadParams(keys = "IsSourceDelete", values = "true")
+ @MapBinder(BindCloneVAppTemplateParamsToXmlPayload.class)
+ Task moveVAppTemplateToVDCAndRename(@PayloadParam("Source") URI toClone,
+ @EndpointParam URI vdc, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String newName,
+ CloneVAppTemplateOptions... options);
+
+ /**
+ * The captureVApp request creates a vApp template from an instantiated vApp. <h4>Note</h4>
+ * Before it can be captured, a vApp must be undeployed
+ *
+ * @param targetVdcHref
+ * @param sourceVAppHref
+ * @param newTemplateName
+ * @param options
+ * @return template in progress
+ */
+ @POST
+ @Path("/action/captureVApp")
+ @Produces("application/vnd.vmware.vcloud.captureVAppParams+xml")
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @MapBinder(BindCaptureVAppParamsToXmlPayload.class)
+ VAppTemplate captureVAppAsTemplateInVDC(@PayloadParam("vApp") URI toCapture,
+ @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName,
+ @EndpointParam URI vdc, CaptureVAppOptions... options);
+
+ @GET
+ @Consumes(VAPPTEMPLATE_XML)
+ @XMLResponseParser(VAppTemplateHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VAppTemplate getVAppTemplate(@EndpointParam URI vAppTemplate);
+
+ @GET
+ @Consumes(MediaType.TEXT_XML)
+ @Path("/ovf")
+ @XMLResponseParser(EnvelopeHandler.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Envelope getOvfEnvelopeForVAppTemplate(@EndpointParam URI href);
+
+ /**
+ * delete a vAppTemplate, vApp, or media image. You cannot delete an object if it is in use. Any
+ * object that is being copied or moved is in use. Other criteria that determine whether an
+ * object is in use depend on the object type.
+ * <ul>
+ * <li>A vApptemplate is in use if it is being instantiated. After instantiation is complete, the
+ * template is no longer in use.</li>
+ * <li>A vApp is in use if it is deployed.</li>
+ * <li>A media image is in use if it is inserted in a Vm.</li>
+ * </ul>
+ *
+ * @param id
+ * href of the vApp
+ * @return task of the operation in progress
+ */
+ @DELETE
+ @Consumes(TASK_XML)
+ @Fallback(Fallbacks.VoidOnNotFoundOr404.class)
+ @XMLResponseParser(TaskHandler.class)
+ Task deleteVAppTemplate(@EndpointParam URI href);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
new file mode 100755
index 0000000..ebb8b6a
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java
@@ -0,0 +1,73 @@
+/*
+ * 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.VDC_XML;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.rest.annotations.EndpointParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.OrgNameAndVDCNameToEndpoint;
+import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest;
+import org.jclouds.vcloud.xml.VDCHandler;
+
+
+/**
+ * Provides access to VDC functionality in vCloud
+ * <p/>
+ *
+ * @author Adrian Cole
+ */
+@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
+public interface VDCApi {
+ @GET
+ @XMLResponseParser(VDCHandler.class)
+ @Consumes(VDC_XML)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ VDC getVDC(@EndpointParam 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
+ */
+ @GET
+ @XMLResponseParser(VDCHandler.class)
+ @Consumes(VDC_XML)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(OrgNameAndVDCNameToEndpoint.class)
+ VDC findVDCInOrgNamed(@Nullable @PayloadParam("orgName") String orgName,
+ @Nullable @PayloadParam("vdcName") String vdcName);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
new file mode 100755
index 0000000..2026ea4
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java
@@ -0,0 +1,295 @@
+/*
+ * 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;
+
+
+/**
+ * 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-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
new file mode 100755
index 0000000..6b06ea5
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.filters;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.core.HttpHeaders;
+
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.vcloud.VCloudToken;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMultimap;
+
+/**
+ * Adds the VCloud Token to the request as a cookie
+ *
+ * @author Adrian Cole
+ *
+ */
+@Singleton
+public class AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilter {
+ private Supplier<String> vcloudTokenProvider;
+
+ @Inject
+ public AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier<String> authTokenProvider) {
+ this.vcloudTokenProvider = authTokenProvider;
+ }
+
+ @Override
+ public HttpRequest filter(HttpRequest request) throws HttpException {
+ String token = vcloudTokenProvider.get();
+ return request
+ .toBuilder()
+ .replaceHeaders(
+ ImmutableMultimap.of("x-vcloud-authorization", token, HttpHeaders.COOKIE, "vcloud-token="
+ + token)).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java
new file mode 100755
index 0000000..f5d6a71
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.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.functions;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.ReferenceType;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class CatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ CatalogItemsInCatalog(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<CatalogItem> apply(Catalog from) {
+ return transform(filter(from.values(), new Predicate<ReferenceType>() {
+ public boolean apply(ReferenceType input) {
+ return input.getType().equals(VCloudMediaType.CATALOGITEM_XML);
+ }
+ }), new Function<ReferenceType, CatalogItem>() {
+ public CatalogItem apply(ReferenceType from) {
+ return aclient.getCatalogApi().getCatalogItem(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
new file mode 100755
index 0000000..31f5383
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java
@@ -0,0 +1,57 @@
+/*
+ * 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.functions;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.Catalog;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class CatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
+
+ private final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
+
+ private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
+
+ @Inject
+ CatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
+ Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
+ this.allCatalogsInOrg = allCatalogsInOrg;
+ this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;
+ }
+
+ @Override
+ public Iterable<CatalogItem> apply(Org from) {
+ return Iterables.concat(Iterables.transform(allCatalogsInOrg.apply(from),
+ new Function<Catalog, Iterable<? extends CatalogItem>>() {
+ @Override
+ public Iterable<? extends CatalogItem> apply(Catalog from) {
+ return allCatalogItemsInCatalog.apply(from);
+ }
+
+ }));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
new file mode 100755
index 0000000..11be749
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java
@@ -0,0 +1,56 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+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;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class CatalogsInOrg implements Function<Org, Iterable<Catalog>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ CatalogsInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<Catalog> apply(final Org org) {
+ return transform(org.getCatalogs().values(), new Function<ReferenceType, Catalog>() {
+ public Catalog apply(ReferenceType from) {
+ return aclient.getCatalogApi().getCatalog(from.getHref());
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
new file mode 100755
index 0000000..eeecb8d
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java
@@ -0,0 +1,47 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.collect.Iterables.get;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Network;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class DefaultNetworkNameInTemplate implements Function<VAppTemplate, String> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Override
+ public String apply(VAppTemplate vAppTemplate) {
+ checkArgument(vAppTemplate != null, "vAppTemplate was null!");
+ Set<Network> networks = vAppTemplate.getNetworkSection().getNetworks();
+ checkArgument(networks.size() > 0, "no networks found in vAppTemplate %s", vAppTemplate);
+ if (networks.size() > 1)
+ logger.warn("multiple networks found for %s, choosing first from: %s", vAppTemplate.getName(), networks);
+ return get(networks, 0).getName();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
new file mode 100755
index 0000000..261498c
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java
@@ -0,0 +1,57 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+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;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class NetworksInOrg implements Function<Org, Iterable<OrgNetwork>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ NetworksInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<OrgNetwork> apply(final Org org) {
+ return transform(org.getNetworks().values(), new Function<ReferenceType, OrgNetwork>() {
+ public OrgNetwork apply(ReferenceType from) {
+ return aclient.getNetworkApi().getNetwork(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
new file mode 100755
index 0000000..507d307
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java
@@ -0,0 +1,57 @@
+/*
+ * 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.functions;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.Org;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class OrgNameToEndpoint implements Function<Object, URI> {
+ private final Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier;
+ private final Supplier<ReferenceType> defaultOrg;
+
+ @Inject
+ public OrgNameToEndpoint(@Org Supplier<Map<String, ReferenceType>> orgNameToEndpointSupplier,
+ @Org Supplier<ReferenceType> defaultOrg) {
+ this.orgNameToEndpointSupplier = orgNameToEndpointSupplier;
+ this.defaultOrg = defaultOrg;
+ }
+
+ public URI apply(Object from) {
+ try {
+ Map<String, ReferenceType> orgNameToEndpoint = orgNameToEndpointSupplier.get();
+ return from == null ? defaultOrg.get().getHref() : orgNameToEndpoint.get(from).getHref();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException("org " + from + " not found in " + orgNameToEndpointSupplier.get().keySet());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
new file mode 100755
index 0000000..bf9fa13
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java
@@ -0,0 +1,62 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.TasksList;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class OrgNameToTasksListEndpoint implements Function<Object, URI> {
+ private final Supplier<Map<String, Org>> orgMap;
+ private final Supplier<ReferenceType> defaultTasksList;
+
+ @Inject
+ public OrgNameToTasksListEndpoint(Supplier<Map<String, Org>> orgMap,
+ @TasksList Supplier<ReferenceType> defaultTasksList) {
+ this.orgMap = orgMap;
+ this.defaultTasksList = defaultTasksList;
+ }
+
+ public URI apply(Object from) {
+ Object org = from;
+ if (org == null)
+ return defaultTasksList.get().getHref();
+ try {
+ return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
+ } catch (NullPointerException e) {
+ throw new NoSuchElementException(org + " not found in " + orgMap.get());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
new file mode 100755
index 0000000..26a1450
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java
@@ -0,0 +1,73 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.logging.Logger;
+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;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class OrgsForLocations implements Function<Iterable<Location>, Iterable<Org>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ OrgsForLocations(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ /**
+ * Zones are assignable, but we want regions. so we look for zones, whose
+ * parent is region. then, we use a set to extract the unique set.
+ */
+ @Override
+ public Iterable<Org> apply(Iterable<Location> from) {
+ FluentIterable<URI> uris = FluentIterable.from(from).filter(new Predicate<Location>() {
+ public boolean apply(Location input) {
+ return input.getScope() == LocationScope.ZONE;
+ }
+ }).transform(new Function<Location, URI>() {
+ public URI apply(Location from) {
+ return URI.create(from.getParent().getId());
+ }
+ });
+ return transform(uris, new Function<URI, Org>() {
+ public Org apply(URI from) {
+ return aclient.getOrgApi().getOrg(from);
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
new file mode 100755
index 0000000..7749269
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java
@@ -0,0 +1,56 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+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;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class OrgsForNames implements Function<Iterable<String>, Iterable<Org>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ OrgsForNames(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<Org> apply(Iterable<String> from) {
+ return Iterables.filter(transform(from, new Function<String, Org>() {
+ public Org apply(String from) {
+ return aclient.getOrgApi().findOrgNamed(from);
+ }
+ }), Predicates.notNull());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
new file mode 100755
index 0000000..41c96c2
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java
@@ -0,0 +1,105 @@
+/*
+ * 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.functions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.http.HttpUtils.releasePayload;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+import javax.ws.rs.core.HttpHeaders;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.http.functions.ParseSax;
+import org.jclouds.http.functions.ParseSax.Factory;
+import org.jclouds.vcloud.VCloudToken;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.domain.VCloudSession;
+import org.jclouds.vcloud.endpoints.Org;
+import org.jclouds.vcloud.xml.OrgListHandler;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+
+/**
+ * This parses {@link VCloudSession} from HTTP headers.
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class ParseLoginResponseFromHeaders implements Function<HttpResponse, VCloudSession> {
+ static final Pattern pattern = Pattern.compile("(vcloud-token)=?([^;]+)(;.*)?");
+
+ private final ParseSax.Factory factory;
+ private final Provider<OrgListHandler> orgHandlerProvider;
+
+ @Inject
+ private ParseLoginResponseFromHeaders(Factory factory, Provider<OrgListHandler> orgHandlerProvider) {
+ this.factory = factory;
+ this.orgHandlerProvider = orgHandlerProvider;
+ }
+
+ /**
+ * parses the http response headers to create a new {@link VCloudSession} object.
+ */
+ public VCloudSession apply(HttpResponse from) {
+ try {
+ final String token = parseTokenFromHeaders(from);
+ final Map<String, ReferenceType> org = factory.create(orgHandlerProvider.get()).parse(
+ checkNotNull(from.getPayload().getInput(), "no payload in http response to login request %s", from));
+
+ return new VCloudSession() {
+ @VCloudToken
+ public String getVCloudToken() {
+ return token;
+ }
+
+ @Org
+ public Map<String, ReferenceType> getOrgs() {
+ return org;
+ }
+ };
+ } finally {
+ releasePayload(from);
+ }
+ }
+
+ public String parseTokenFromHeaders(HttpResponse from) {
+ String cookieHeader = from.getFirstHeaderOrNull("x-vcloud-authorization");
+ if (cookieHeader != null) {
+ Matcher matcher = pattern.matcher(cookieHeader);
+ return matcher.find() ? matcher.group(2) : cookieHeader;
+ } else {
+ try {
+ cookieHeader = Iterables.find(from.getHeaders().get(HttpHeaders.SET_COOKIE), Predicates.contains(pattern));
+ Matcher matcher = pattern.matcher(cookieHeader);
+ matcher.find();
+ return matcher.group(2);
+ } catch (NoSuchElementException e) {
+ throw new HttpResponseException(String.format("Header %s or %s must be present", "x-vcloud-authorization",
+ HttpHeaders.SET_COOKIE), null, from);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
new file mode 100755
index 0000000..1a0327a
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java
@@ -0,0 +1,66 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.filter;
+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.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.VCloudMediaType;
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class VAppTemplatesForCatalogItems implements Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ private Logger logger = Logger.NULL;
+ private final VCloudApi aclient;
+
+ @Inject
+ VAppTemplatesForCatalogItems(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<VAppTemplate> apply(Iterable<CatalogItem> from) {
+ return filter(transform(filter(from, new Predicate<CatalogItem>() {
+ public boolean apply(CatalogItem input) {
+ return input.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML);
+ }
+ }), new Function<CatalogItem, VAppTemplate>() {
+ public VAppTemplate apply(CatalogItem from) {
+ return aclient.getVAppTemplateApi().getVAppTemplate(from.getEntity().getHref());
+ }
+ }), Predicates.notNull());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
new file mode 100755
index 0000000..e7507d4
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java
@@ -0,0 +1,65 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.filter;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.domain.CatalogItem;
+import org.jclouds.vcloud.domain.Org;
+import org.jclouds.vcloud.domain.Status;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>> {
+
+ private final Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg;
+ private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
+
+ @Inject
+ VAppTemplatesInOrg(Function<Org, Iterable<CatalogItem>> allCatalogItemsInOrg,
+ Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems) {
+ this.allCatalogItemsInOrg = allCatalogItemsInOrg;
+ this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
+ }
+
+ @Override
+ public Iterable<VAppTemplate> apply(Org from) {
+ Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
+ Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
+ return filter(vAppTemplates, and(notNull(), new Predicate<VAppTemplate>() {
+ @Override
+ public boolean apply(VAppTemplate input) {
+ if (input == null)
+ return false;
+ return ImmutableSet.of(Status.RESOLVED, Status.OFF).contains(input.getStatus());
+ }
+ }));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
new file mode 100755
index 0000000..741c184
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java
@@ -0,0 +1,57 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+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;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class VDCsInOrg implements Function<Org, Iterable<VDC>> {
+ @Resource
+ public Logger logger = Logger.NULL;
+
+ private final VCloudApi aclient;
+
+ @Inject
+ VDCsInOrg(VCloudApi aclient) {
+ this.aclient = aclient;
+ }
+
+ @Override
+ public Iterable<VDC> apply(final Org org) {
+ return transform(org.getVDCs().values(), new Function<ReferenceType, VDC>() {
+ public VDC apply(ReferenceType from) {
+ return aclient.getVDCApi().getVDC(from.getHref());
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
new file mode 100755
index 0000000..c5777a9
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java
@@ -0,0 +1,121 @@
+/*
+ * 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.handlers;
+
+import static org.jclouds.http.HttpUtils.releasePayload;
+
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.logging.Logger;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.util.Strings2;
+import org.jclouds.vcloud.VCloudResponseException;
+import org.jclouds.vcloud.domain.VCloudError;
+import org.jclouds.vcloud.domain.VCloudError.MinorCode;
+import org.jclouds.vcloud.util.VCloudUtils;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ *
+ * @author Adrian Cole
+ *
+ */
+@Singleton
+public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler {
+ @Resource
+ protected Logger logger = Logger.NULL;
+ public static final Pattern RESOURCE_PATTERN = Pattern.compile(".*/v[^/]+/([^/]+)/([0-9]+)");
+ private final VCloudUtils utils;
+
+ @Inject
+ public ParseVCloudErrorFromHttpResponse(VCloudUtils utils) {
+ this.utils = utils;
+ }
+
+ public void handleError(HttpCommand command, HttpResponse response) {
+ HttpRequest request = command.getCurrentRequest();
+ Exception exception = new HttpResponseException(command, response);
+ try {
+ VCloudError error = null;
+ String message = null;
+ if (response.getPayload() != null) {
+ try {
+ error = utils.parseErrorFromContent(request, response);
+ if (error != null) {
+ message = error.getMessage();
+ exception = new VCloudResponseException(command, response, error);
+ } else {
+ message = Strings2.toString(response.getPayload());
+ exception = message != null ? new HttpResponseException(command, response, message) : exception;
+ }
+ } catch (IOException e) {
+ } finally {
+ response.getPayload().release();
+ }
+ }
+ message = message != null ? message : String.format("%s -> %s", request.getRequestLine(), response
+ .getStatusLine());
+
+ switch (response.getStatusCode()) {
+ case 400:
+ if (error != null
+ && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.BUSY_ENTITY)
+ || (error.getMessage() != null && error.getMessage().indexOf("is not running") != -1)))
+ exception = new IllegalStateException(message, exception);
+ else
+ exception = new IllegalArgumentException(message, exception);
+ break;
+ case 401:
+ case 403:
+ if (error != null
+ && ((error.getMinorErrorCode() != null && error.getMinorErrorCode() == MinorCode.ACCESS_TO_RESOURCE_IS_FORBIDDEN)
+ || (error.getMessage() != null && error.getMessage().indexOf("No access to entity") != -1)))
+ exception = new ResourceNotFoundException(message, exception);
+ else
+ exception = new AuthorizationException(exception.getMessage(), exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ String path = command.getCurrentRequest().getEndpoint().getPath();
+ Matcher matcher = RESOURCE_PATTERN.matcher(path);
+ if (matcher.find()) {
+ message = String.format("%s %s not found", matcher.group(1), matcher.group(2));
+ } else {
+ message = path;
+ }
+ exception = new ResourceNotFoundException(message);
+ }
+ break;
+ }
+ } finally {
+ releasePayload(response);
+ command.setException(exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
new file mode 100755
index 0000000..a333874
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java
@@ -0,0 +1,58 @@
+/*
+ * 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.http.filters;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Supplier;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.jclouds.domain.Credentials;
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequest.Builder;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.location.Provider;
+import org.jclouds.rest.annotations.ApiVersion;
+
+@Singleton
+public class VCloudBasicAuthentication implements HttpRequestFilter
+{
+ private final Supplier<Credentials> creds;
+ private final String apiVersion;
+
+ @Inject
+ public VCloudBasicAuthentication(@Provider Supplier<Credentials> creds, @ApiVersion String apiVersion)
+ {
+ this.creds = ((Supplier)Preconditions.checkNotNull(creds, "creds"));
+ this.apiVersion = apiVersion;
+ }
+
+ public HttpRequest filter(HttpRequest request) throws HttpException
+ {
+ Credentials currentCreds = (Credentials)Preconditions.checkNotNull(this.creds.get(), "credential supplier returned null");
+ String acceptType = request.getFirstHeaderOrNull("Accept") == null ? "application/*+xml" : request.getFirstHeaderOrNull("Accept");
+
+ String version = ";version=" + this.apiVersion;
+ String acceptHeader = acceptType + version;
+
+ request = ((HttpRequest.Builder)request.toBuilder().replaceHeader("Accept", new String[] { acceptHeader })).build();
+
+ return ((HttpRequest.Builder)request.toBuilder().replaceHeader("Authorization", new String[] { BasicAuthentication.basic(currentCreds.identity, currentCreds.credential) })).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
new file mode 100755
index 0000000..3769fda
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java
@@ -0,0 +1,35 @@
+/*
+ * 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.http.filters;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+
+@Singleton
+public class VCloudSupportedVersions implements HttpRequestFilter
+{
+ @SuppressWarnings("rawtypes")
+public HttpRequest filter(HttpRequest request)
+ throws HttpException
+ {
+ return ((HttpRequest.Builder)request.toBuilder().replaceHeader("Accept", new String[] { "*/*" })).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java
new file mode 100755
index 0000000..acf77c5
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/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-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
new file mode 100755
index 0000000..f004f97
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java
@@ -0,0 +1,47 @@
+/*
+ * 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.loaders;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.ovf.Envelope;
+import org.jclouds.vcloud.VCloudApi;
+
+import com.google.common.cache.CacheLoader;
+
+@Singleton
+public class OVFLoader extends CacheLoader<URI, Envelope> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final VCloudApi client;
+
+ @Inject
+ OVFLoader(VCloudApi client) {
+ this.client = client;
+ }
+
+ @Override
+ public Envelope load(URI template) {
+ return client.getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(template);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
new file mode 100755
index 0000000..ee707db
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java
@@ -0,0 +1,47 @@
+/*
+ * 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.loaders;
+
+import java.net.URI;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.vcloud.VCloudApi;
+import org.jclouds.vcloud.domain.VAppTemplate;
+
+import com.google.common.cache.CacheLoader;
+
+@Singleton
+public class VAppTemplateLoader extends CacheLoader<URI, VAppTemplate> {
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ private final VCloudApi client;
+
+ @Inject
+ VAppTemplateLoader(VCloudApi client) {
+ this.client = client;
+ }
+
+ @Override
+ public VAppTemplate load(URI template) {
+ return client.getVAppTemplateApi().getVAppTemplate(template);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4cbbd29e/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
new file mode 100755
index 0000000..38fb340
--- /dev/null
+++ b/dependencies/jclouds/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java
@@ -0,0 +1,74 @@
+/*
+ * 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.location;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.find;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.vcloud.domain.ReferenceType;
+import org.jclouds.vcloud.endpoints.VDC;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
+@Singleton
+public class DefaultVDC implements ImplicitLocationSupplier {
+ private final Supplier<Set<? extends Location>> locationsSupplier;
+ private final IsDefaultVDC isDefaultVDC;
+
+ @Inject
+ DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
+ this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
+ this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
+ }
+
+ @Override
+ public Location get() {
+ return find(locationsSupplier.get(), isDefaultVDC);
+ }
+
+
+ @Singleton
+ public static class IsDefaultVDC implements Predicate<Location> {
+ private final Supplier<ReferenceType> defaultVDCSupplier;
+
+ @Inject
+ IsDefaultVDC(@VDC Supplier<ReferenceType> defaultVDCSupplier) {
+ this.defaultVDCSupplier = checkNotNull(defaultVDCSupplier, "defaultVDCSupplier");
+ }
+
+ @Override
+ public boolean apply(Location input) {
+ ReferenceType defaultVDC = defaultVDCSupplier.get();
+ return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
+ }
+
+ @Override
+ public String toString() {
+ return "isDefaultVDC()";
+ }
+ }
+}