diff --git a/pom.xml b/pom.xml
index 4f4725a813..7ead5a9214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,6 @@
rackspace
mezeo
nirvanix
- vcloud
twitter
rimuhosting
scriptbuilder
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java
index f50173d5ae..24f0a7a323 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudAsyncClient.java
@@ -41,16 +41,24 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.Endpoint;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.MapEntityParam;
+import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser;
+import org.jclouds.vcloud.binders.BindInstantiateVAppTemplateParamsToXmlEntity;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VDC;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
+import org.jclouds.vcloud.functions.VAppTemplateIdToUri;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.xml.CatalogHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.jclouds.vcloud.xml.TasksListHandler;
+import org.jclouds.vcloud.xml.VAppHandler;
import org.jclouds.vcloud.xml.VDCHandler;
/**
@@ -66,7 +74,6 @@ public interface VCloudAsyncClient {
@GET
@Endpoint(org.jclouds.vcloud.endpoints.Catalog.class)
@Consumes(CATALOG_XML)
- @Produces(CATALOG_XML)// required for hosting.com to operate
@XMLResponseParser(CatalogHandler.class)
Future extends Catalog> getCatalog();
@@ -162,5 +169,17 @@ public interface VCloudAsyncClient {
@Consumes(VAPP_XML)
@Endpoint(org.jclouds.vcloud.endpoints.VCloudApi.class)
@Path("/vapp/{vAppId}")
- Future getVAppString(@PathParam("vAppId") String appId);
+ @XMLResponseParser(VAppHandler.class)
+ Future extends VApp> getVApp(@PathParam("vAppId") String appId);
+
+ @POST
+ @Endpoint(org.jclouds.vcloud.endpoints.VDC.class)
+ @Path("/action/instantiateVAppTemplate")
+ @Produces("application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
+ @Consumes(VAPP_XML)
+ @XMLResponseParser(VAppHandler.class)
+ @MapBinder(BindInstantiateVAppTemplateParamsToXmlEntity.class)
+ Future extends VApp> instantiateVAppTemplate(@MapEntityParam("name") String appName,
+ @MapEntityParam("template") @ParamParser(VAppTemplateIdToUri.class) String templateId,
+ InstantiateVAppTemplateOptions... options);
}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java
index 4ae620bbbe..86004a3543 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudClient.java
@@ -30,7 +30,9 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.TasksList;
+import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VDC;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
/**
* Provides access to VCloud resources via their REST API.
@@ -41,13 +43,13 @@ import org.jclouds.vcloud.domain.VDC;
*/
@Timeout(duration = 45, timeUnit = TimeUnit.SECONDS)
public interface VCloudClient {
-
+
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
Catalog getCatalog();
-
+
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
VDC getDefaultVDC();
-
+
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
TasksList getDefaultTasksList();
@@ -86,5 +88,8 @@ public interface VCloudClient {
void cancelTask(URI task);
- String getVAppString(String appId);
+ VApp getVApp(String appId);
+
+ VApp instantiateVAppTemplate(String appName, String templateId,
+ InstantiateVAppTemplateOptions... options);
}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java
index 7190900356..aab7acdf6c 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/VCloudPropertiesBuilder.java
@@ -24,6 +24,8 @@
package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTCPUCOUNT;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTMEMORY;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_ENDPOINT;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
@@ -46,6 +48,8 @@ public class VCloudPropertiesBuilder extends HttpPropertiesBuilder {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_VCLOUD_VERSION, "0.8");
properties.setProperty(PROPERTY_VCLOUD_SESSIONINTERVAL, 9 * 60 + "");
+ properties.setProperty(PROPERTY_VCLOUD_DEFAULTCPUCOUNT, "1");
+ properties.setProperty(PROPERTY_VCLOUD_DEFAULTMEMORY, "512");
return properties;
}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java
new file mode 100644
index 0000000000..f7f21c7a8a
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlEntity.java
@@ -0,0 +1,94 @@
+package org.jclouds.vcloud.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTCPUCOUNT;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTMEMORY;
+import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULTNETWORK;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToStringEntity;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
+
+import com.google.common.collect.Maps;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+@Singleton
+public class BindInstantiateVAppTemplateParamsToXmlEntity implements MapBinder {
+
+ private final String xmlTemplate;
+ private final BindToStringEntity stringBinder;
+ protected final Map defaultParams;
+
+ @Inject
+ public BindInstantiateVAppTemplateParamsToXmlEntity(
+ @Named("InstantiateVAppTemplateParams") String xmlTemplate,
+ BindToStringEntity stringBinder,
+ @Named(PROPERTY_VCLOUD_DEFAULTNETWORK) String defaultNetwork,
+ @Named(PROPERTY_VCLOUD_DEFAULTCPUCOUNT) String defaultCpuCount,
+ @Named(PROPERTY_VCLOUD_DEFAULTMEMORY) String defaultMemory) {
+ this.xmlTemplate = xmlTemplate;
+ this.stringBinder = stringBinder;
+ this.defaultParams = Maps.newHashMap();
+ this.defaultParams.put("network", defaultNetwork);
+ this.defaultParams.put("count", defaultCpuCount);
+ this.defaultParams.put("megabytes", defaultMemory);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void bindToRequest(HttpRequest request, Map postParams) {
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+ checkState(gRequest.getArgs() != null, "args should be initialized at this point");
+ postParams = new HashMap(postParams);
+ postParams.putAll(defaultParams);
+ addOptionsToMap(postParams, gRequest);
+
+ String entity = xmlTemplate;
+ for (Entry entry : postParams.entrySet()) {
+ entity = entity.replaceAll("\\{" + entry.getKey() + "\\}", entry.getValue());
+ }
+ stringBinder.bindToRequest(request, entity);
+ }
+
+ protected void addOptionsToMap(Map postParams, GeneratedHttpRequest> gRequest) {
+ for (Object arg : gRequest.getArgs()) {
+ if (arg instanceof InstantiateVAppTemplateOptions) {
+ InstantiateVAppTemplateOptions options = (InstantiateVAppTemplateOptions) arg;
+ if (options.getCpuCount() != null) {
+ postParams.put("count", options.getCpuCount());
+ }
+ if (options.getMegabytes() != null) {
+ postParams.put("megabytes", options.getMegabytes());
+ }
+ if (options.getNetwork() != null) {
+ postParams.put("network", options.getNetwork());
+ }
+ }
+ }
+ }
+
+ public void bindToRequest(HttpRequest request, Object input) {
+ throw new IllegalStateException("InstantiateVAppTemplateParams is needs parameters");
+ }
+
+ String ifNullDefaultTo(String value, String defaultValue) {
+ return value != null ? value : checkNotNull(defaultValue, "defaultValue");
+ }
+}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java
index 2f4b275873..2fdfab3af5 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java
@@ -23,17 +23,21 @@
*/
package org.jclouds.vcloud.config;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.concurrent.internal.SyncProxy;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientFactory;
+import org.jclouds.util.Utils;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudDiscovery;
@@ -45,6 +49,7 @@ import org.jclouds.vcloud.endpoints.VCloudLogin;
import org.jclouds.vcloud.endpoints.VDC;
import org.jclouds.vcloud.endpoints.internal.CatalogItemRoot;
import org.jclouds.vcloud.endpoints.internal.VAppRoot;
+import org.jclouds.vcloud.endpoints.internal.VAppTemplateRoot;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
@@ -89,11 +94,18 @@ public class VCloudRestClientModule extends AbstractModule {
return vcloudUri.toASCIIString().replace("/login", "/vapp");
}
+ @Provides
+ @VAppTemplateRoot
+ @Singleton
+ String provideVAppTemplateRoot(@VCloudLogin URI vcloudUri) {
+ return vcloudUri.toASCIIString().replace("/login", "/vAppTemplate");
+ }
+
@Provides
@Singleton
protected Organization provideOrganization(VCloudDiscovery discovery) throws ExecutionException,
TimeoutException, InterruptedException {
- return discovery.getOrganization().get(60, TimeUnit.SECONDS);
+ return discovery.getOrganization().get(90, TimeUnit.SECONDS);
}
@Provides
@@ -110,6 +122,14 @@ public class VCloudRestClientModule extends AbstractModule {
return org.getCatalog().getLocation();
}
+ @Singleton
+ @Provides
+ @Named("InstantiateVAppTemplateParams")
+ protected String provideInstantiateVAppTemplateParams() throws IOException {
+ InputStream is = getClass().getResourceAsStream("/InstantiateVAppTemplateParams.xml");
+ return Utils.toStringAndClose(is);
+ }
+
@Provides
@Network
@Singleton
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Catalog.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Catalog.java
index 8758a953ef..e536dddcea 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Catalog.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Catalog.java
@@ -26,6 +26,7 @@ package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map;
+import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import com.google.inject.ImplementedBy;
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/NamedResource.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/NamedResource.java
deleted file mode 100644
index 0b1da8af26..0000000000
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/NamedResource.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.jclouds.vcloud.domain;
-
-import org.jclouds.rest.domain.NamedLink;
-import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * Location of a Rest resource
- *
- * @author Adrian Cole
- *
- */
-@ImplementedBy(NamedResourceImpl.class)
-public interface NamedResource extends NamedLink, Comparable {
- String getId();
-}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java
new file mode 100644
index 0000000000..29178b80fd
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceAllocation.java
@@ -0,0 +1,210 @@
+/**
+ *
+ * Copyright (C) 2009 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Adrian Cole
+ *
+ */
+public class ResourceAllocation implements Comparable {
+
+ private final int id;
+ private final String name;
+ private final String description;
+ private final ResourceType type;
+ private final String subType;
+ private final Integer address;
+ private final Integer addressOnParent;
+ private final Integer parent;
+ private final Boolean connected;
+ private final long virtualQuantity;
+ private final String virtualQuantityUnits;
+
+ public ResourceAllocation(int id, String name, String description, ResourceType type,
+ String subType, Integer address, Integer addressOnParent, Integer parent,
+ Boolean connected, long virtualQuantity, String virtualQuantityUnits) {
+ this.id = id;
+ this.name = checkNotNull(name, "name");
+ this.description = description;
+ this.type = checkNotNull(type, "type");
+ this.subType = subType;
+ this.address = address;
+ this.addressOnParent = addressOnParent;
+ this.parent = parent;
+ this.connected = connected;
+ this.virtualQuantity = virtualQuantity;
+ this.virtualQuantityUnits = virtualQuantityUnits;
+ }
+
+ public int compareTo(ResourceAllocation that) {
+ final int BEFORE = -1;
+ final int EQUAL = 0;
+ final int AFTER = 1;
+
+ if (this == that)
+ return EQUAL;
+
+ if (this.id < that.id)
+ return BEFORE;
+ if (this.id > that.id)
+ return AFTER;
+ return EQUAL;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public ResourceType getType() {
+ return type;
+ }
+
+ public String getSubType() {
+ return subType;
+ }
+
+ public Integer getAddress() {
+ return address;
+ }
+
+ public Integer getAddressOnParent() {
+ return addressOnParent;
+ }
+
+ public Integer getParent() {
+ return parent;
+ }
+
+ public Boolean getConnected() {
+ return connected;
+ }
+
+ public long getVirtualQuantity() {
+ return virtualQuantity;
+ }
+
+ public String getVirtualQuantityUnits() {
+ return virtualQuantityUnits;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
+ result = prime * result + ((connected == null) ? 0 : connected.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + id;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((parent == null) ? 0 : parent.hashCode());
+ result = prime * result + ((subType == null) ? 0 : subType.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32));
+ result = prime * result
+ + ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResourceAllocation other = (ResourceAllocation) obj;
+ if (address == null) {
+ if (other.address != null)
+ return false;
+ } else if (!address.equals(other.address))
+ return false;
+ if (addressOnParent == null) {
+ if (other.addressOnParent != null)
+ return false;
+ } else if (!addressOnParent.equals(other.addressOnParent))
+ return false;
+ if (connected == null) {
+ if (other.connected != null)
+ return false;
+ } else if (!connected.equals(other.connected))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (id != other.id)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (parent == null) {
+ if (other.parent != null)
+ return false;
+ } else if (!parent.equals(other.parent))
+ return false;
+ if (subType == null) {
+ if (other.subType != null)
+ return false;
+ } else if (!subType.equals(other.subType))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ if (virtualQuantity != other.virtualQuantity)
+ return false;
+ if (virtualQuantityUnits == null) {
+ if (other.virtualQuantityUnits != null)
+ return false;
+ } else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ResourceAllocation [address=" + address + ", addressOnParent=" + addressOnParent
+ + ", connected=" + connected + ", description=" + description + ", id=" + id
+ + ", name=" + name + ", parent=" + parent + ", subType=" + subType + ", type="
+ + type + ", virtualQuantity=" + virtualQuantity + ", virtualQuantityUnits="
+ + virtualQuantityUnits + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java
index 0e7b4960c9..300c774143 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/ResourceType.java
@@ -10,29 +10,36 @@ import org.jclouds.vcloud.VCloudAsyncClient;
*
* @author Adrian Cole
* @see VCloudAsyncClient#getVApp
- *
+ * @see
*
*/
public enum ResourceType {
-
- VIRTUAL_CPU,
-
- MEMORY,
-
- SCSI_CONTROLLER,
-
- VIRTUAL_DISK;
+ OTHER, PROCESSOR, MEMORY, IDE_CONTROLLER, SCSI_CONTROLLER, ETHERNET_ADAPTER, FLOPPY_DRIVE, CD_DRIVE, DVD_DRIVE, DISK_DRIVE, USB_CONTROLLER;
public String value() {
switch (this) {
- case VIRTUAL_CPU:
+ case OTHER:
+ return "1";
+ case PROCESSOR:
return "3";
case MEMORY:
return "4";
+ case IDE_CONTROLLER:
+ return "5";
case SCSI_CONTROLLER:
return "6";
- case VIRTUAL_DISK:
+ case ETHERNET_ADAPTER:
+ return "10";
+ case FLOPPY_DRIVE:
+ return "14";
+ case CD_DRIVE:
+ return "15";
+ case DVD_DRIVE:
+ return "16";
+ case DISK_DRIVE:
return "17";
+ case USB_CONTROLLER:
+ return "23";
default:
throw new IllegalArgumentException("invalid type:" + this);
}
@@ -44,14 +51,28 @@ public enum ResourceType {
public static ResourceType fromValue(int v) {
switch (v) {
+ case 1:
+ return OTHER;
case 3:
- return VIRTUAL_CPU;
+ return PROCESSOR;
case 4:
return MEMORY;
+ case 5:
+ return IDE_CONTROLLER;
case 6:
return SCSI_CONTROLLER;
+ case 10:
+ return ETHERNET_ADAPTER;
+ case 14:
+ return FLOPPY_DRIVE;
+ case 15:
+ return CD_DRIVE;
+ case 16:
+ return DVD_DRIVE;
case 17:
- return VIRTUAL_DISK;
+ return DISK_DRIVE;
+ case 23:
+ return USB_CONTROLLER;
default:
throw new IllegalArgumentException("invalid type:" + v);
}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkResourceAllocation.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkResourceAllocation.java
new file mode 100644
index 0000000000..084b6347ef
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkResourceAllocation.java
@@ -0,0 +1,348 @@
+/**
+ *
+ * Copyright (C) 2009 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * @author Adrian Cole
+ */
+public class TerremarkResourceAllocation implements Comparable {
+ private final Integer address;
+ private final Integer addressOnParent;
+ private final String allocationUnits;
+ private final String automaticAllocation;
+ private final String automaticDeallocation;
+ private final String caption;
+ private final String consumerVisibility;
+ private final String description;
+ private final String elementName;
+ private final String hostResource;
+ private final int instanceID;
+ private final String limit;
+ private final String mappingBehavior;
+ private final String otherResourceType;
+ private final Integer parent;
+ private final String poolID;
+ private final String reservation;
+ private final String resourceSubType;
+ private final ResourceType resourceType;
+ private final long virtualQuantity;
+ private final String virtualQuantityUnits;
+ private final String weight;
+
+ public TerremarkResourceAllocation(Integer address, Integer addressOnParent, String allocationUnits,
+ String automaticAllocation, String automaticDeallocation, String caption,
+ String consumerVisibility, String description, String elementName, String hostResource,
+ int instanceID, String limit, String mappingBehavior, String otherResourceType,
+ Integer parent, String poolID, String reservation, String resourceSubType,
+ ResourceType resourceType, long virtualQuantity, String virtualQuantityUnits,
+ String weight) {
+ this.address = address;
+ this.addressOnParent = addressOnParent;
+ this.allocationUnits = allocationUnits;
+ this.automaticAllocation = automaticAllocation;
+ this.automaticDeallocation = automaticDeallocation;
+ this.caption = caption;
+ this.consumerVisibility = consumerVisibility;
+ this.description = description;
+ this.elementName = elementName;
+ this.hostResource = hostResource;
+ this.instanceID = checkNotNull(instanceID, "instanceID");
+ this.limit = limit;
+ this.mappingBehavior = mappingBehavior;
+ this.otherResourceType = otherResourceType;
+ this.parent = parent;
+ this.poolID = poolID;
+ this.reservation = reservation;
+ this.resourceSubType = resourceSubType;
+ this.resourceType = checkNotNull(resourceType, "resourceType");
+ this.virtualQuantity = virtualQuantity;
+ this.virtualQuantityUnits = virtualQuantityUnits;
+ this.weight = weight;
+ }
+
+ public Integer getAddress() {
+ return address;
+ }
+
+ public Integer getAddressOnParent() {
+ return addressOnParent;
+ }
+
+ public String getAllocationUnits() {
+ return allocationUnits;
+ }
+
+ public String getAutomaticAllocation() {
+ return automaticAllocation;
+ }
+
+ public String getAutomaticDeallocation() {
+ return automaticDeallocation;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public String getConsumerVisibility() {
+ return consumerVisibility;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getElementName() {
+ return elementName;
+ }
+
+ public int getInstanceID() {
+ return instanceID;
+ }
+
+ public String getLimit() {
+ return limit;
+ }
+
+ public String getMappingBehavior() {
+ return mappingBehavior;
+ }
+
+ public String getOtherResourceType() {
+ return otherResourceType;
+ }
+
+ public Integer getParent() {
+ return parent;
+ }
+
+ public String getPoolID() {
+ return poolID;
+ }
+
+ public String getReservation() {
+ return reservation;
+ }
+
+ public String getResourceSubType() {
+ return resourceSubType;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public long getVirtualQuantity() {
+ return virtualQuantity;
+ }
+
+ public String getVirtualQuantityUnits() {
+ return virtualQuantityUnits;
+ }
+
+ public String getWeight() {
+ return weight;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
+ result = prime * result + ((allocationUnits == null) ? 0 : allocationUnits.hashCode());
+ result = prime * result
+ + ((automaticAllocation == null) ? 0 : automaticAllocation.hashCode());
+ result = prime * result
+ + ((automaticDeallocation == null) ? 0 : automaticDeallocation.hashCode());
+ result = prime * result + ((caption == null) ? 0 : caption.hashCode());
+ result = prime * result + ((consumerVisibility == null) ? 0 : consumerVisibility.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((elementName == null) ? 0 : elementName.hashCode());
+ result = prime * result + instanceID;
+ result = prime * result + ((limit == null) ? 0 : limit.hashCode());
+ result = prime * result + ((mappingBehavior == null) ? 0 : mappingBehavior.hashCode());
+ result = prime * result + ((otherResourceType == null) ? 0 : otherResourceType.hashCode());
+ result = prime * result + ((parent == null) ? 0 : parent.hashCode());
+ result = prime * result + ((poolID == null) ? 0 : poolID.hashCode());
+ result = prime * result + ((reservation == null) ? 0 : reservation.hashCode());
+ result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode());
+ result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
+ result = prime * result + (int) (virtualQuantity ^ (virtualQuantity >>> 32));
+ result = prime * result
+ + ((virtualQuantityUnits == null) ? 0 : virtualQuantityUnits.hashCode());
+ result = prime * result + ((weight == null) ? 0 : weight.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TerremarkResourceAllocation other = (TerremarkResourceAllocation) obj;
+ if (address == null) {
+ if (other.address != null)
+ return false;
+ } else if (!address.equals(other.address))
+ return false;
+ if (addressOnParent == null) {
+ if (other.addressOnParent != null)
+ return false;
+ } else if (!addressOnParent.equals(other.addressOnParent))
+ return false;
+ if (allocationUnits == null) {
+ if (other.allocationUnits != null)
+ return false;
+ } else if (!allocationUnits.equals(other.allocationUnits))
+ return false;
+ if (automaticAllocation == null) {
+ if (other.automaticAllocation != null)
+ return false;
+ } else if (!automaticAllocation.equals(other.automaticAllocation))
+ return false;
+ if (automaticDeallocation == null) {
+ if (other.automaticDeallocation != null)
+ return false;
+ } else if (!automaticDeallocation.equals(other.automaticDeallocation))
+ return false;
+ if (caption == null) {
+ if (other.caption != null)
+ return false;
+ } else if (!caption.equals(other.caption))
+ return false;
+ if (consumerVisibility == null) {
+ if (other.consumerVisibility != null)
+ return false;
+ } else if (!consumerVisibility.equals(other.consumerVisibility))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (elementName == null) {
+ if (other.elementName != null)
+ return false;
+ } else if (!elementName.equals(other.elementName))
+ return false;
+ if (instanceID != other.instanceID)
+ return false;
+ if (limit == null) {
+ if (other.limit != null)
+ return false;
+ } else if (!limit.equals(other.limit))
+ return false;
+ if (mappingBehavior == null) {
+ if (other.mappingBehavior != null)
+ return false;
+ } else if (!mappingBehavior.equals(other.mappingBehavior))
+ return false;
+ if (otherResourceType == null) {
+ if (other.otherResourceType != null)
+ return false;
+ } else if (!otherResourceType.equals(other.otherResourceType))
+ return false;
+ if (parent == null) {
+ if (other.parent != null)
+ return false;
+ } else if (!parent.equals(other.parent))
+ return false;
+ if (poolID == null) {
+ if (other.poolID != null)
+ return false;
+ } else if (!poolID.equals(other.poolID))
+ return false;
+ if (reservation == null) {
+ if (other.reservation != null)
+ return false;
+ } else if (!reservation.equals(other.reservation))
+ return false;
+ if (resourceSubType == null) {
+ if (other.resourceSubType != null)
+ return false;
+ } else if (!resourceSubType.equals(other.resourceSubType))
+ return false;
+ if (resourceType == null) {
+ if (other.resourceType != null)
+ return false;
+ } else if (!resourceType.equals(other.resourceType))
+ return false;
+ if (virtualQuantity != other.virtualQuantity)
+ return false;
+ if (virtualQuantityUnits == null) {
+ if (other.virtualQuantityUnits != null)
+ return false;
+ } else if (!virtualQuantityUnits.equals(other.virtualQuantityUnits))
+ return false;
+ if (weight == null) {
+ if (other.weight != null)
+ return false;
+ } else if (!weight.equals(other.weight))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "ResourceAllocation [address=" + address + ", addressOnParent=" + addressOnParent
+ + ", allocationUnits=" + allocationUnits + ", automaticAllocation="
+ + automaticAllocation + ", automaticDeallocation=" + automaticDeallocation
+ + ", caption=" + caption + ", consumerVisibility=" + consumerVisibility
+ + ", description=" + description + ", elementName=" + elementName + ", instanceID="
+ + instanceID + ", limit=" + limit + ", mappingBehavior=" + mappingBehavior
+ + ", otherResourceType=" + otherResourceType + ", parent=" + parent + ", poolID="
+ + poolID + ", reservation=" + reservation + ", resourceSubType=" + resourceSubType
+ + ", resourceType=" + resourceType + ", virtualQuantity=" + virtualQuantity
+ + ", virtualQuantityUnits=" + virtualQuantityUnits + ", weight=" + weight + "]";
+ }
+
+ public int compareTo(TerremarkResourceAllocation that) {
+ final int BEFORE = -1;
+ final int EQUAL = 0;
+ final int AFTER = 1;
+
+ if (this == that)
+ return EQUAL;
+
+ int comparison = this.resourceType.compareTo(that.resourceType);
+ if (comparison != EQUAL)
+ return comparison;
+
+ if (this.instanceID < that.instanceID)
+ return BEFORE;
+ if (this.instanceID > that.instanceID)
+ return AFTER;
+ return EQUAL;
+ }
+
+ public String getHostResource() {
+ return hostResource;
+ }
+}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java
new file mode 100644
index 0000000000..9c9ced7947
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/TerremarkVirtualSystem.java
@@ -0,0 +1,305 @@
+/**
+ *
+ * Copyright (C) 2009 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * 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.domain;
+
+import org.joda.time.DateTime;
+
+/**
+ * @author Adrian Cole
+ */
+public class TerremarkVirtualSystem extends VirtualSystem {
+
+ private final String automaticRecoveryAction;
+ private final String automaticShutdownAction;
+ private final String automaticStartupAction;
+ private final String automaticStartupActionDelay;
+ private final String automaticStartupActionSequenceNumber;
+ private final String caption;
+ private final String configurationDataRoot;
+ private final String configurationFile;
+ private final String configurationID;
+ private final DateTime creationTime;
+ private final String description;
+ private final String logDataRoot;
+ private final String recoveryFile;
+ private final String snapshotDataRoot;
+ private final String suspendDataRoot;
+ private final String swapFileDataRoot;
+
+ public TerremarkVirtualSystem(String automaticRecoveryAction, String automaticShutdownAction,
+ String automaticStartupAction, String automaticStartupActionDelay,
+ String automaticStartupActionSequenceNumber, String caption,
+ String configurationDataRoot, String configurationFile, String configurationID,
+ DateTime creationTime, String description, String elementName, int instanceID,
+ String logDataRoot, String recoveryFile, String snapshotDataRoot,
+ String suspendDataRoot, String swapFileDataRoot, String virtualSystemIdentifier,
+ String virtualSystemType) {
+ super(instanceID, elementName, virtualSystemIdentifier, virtualSystemType);
+ this.automaticRecoveryAction = automaticRecoveryAction;
+ this.automaticShutdownAction = automaticShutdownAction;
+ this.automaticStartupAction = automaticStartupAction;
+ this.automaticStartupActionDelay = automaticStartupActionDelay;
+ this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
+ this.caption = caption;
+ this.configurationDataRoot = configurationDataRoot;
+ this.configurationFile = configurationFile;
+ this.configurationID = configurationID;
+ this.creationTime = creationTime;
+ this.description = description;
+ this.logDataRoot = logDataRoot;
+ this.recoveryFile = recoveryFile;
+ this.snapshotDataRoot = snapshotDataRoot;
+ this.suspendDataRoot = suspendDataRoot;
+ this.swapFileDataRoot = swapFileDataRoot;
+ }
+
+ public String getAutomaticRecoveryAction() {
+ return automaticRecoveryAction;
+ }
+
+ public String getAutomaticShutdownAction() {
+ return automaticShutdownAction;
+ }
+
+ public String getAutomaticStartupAction() {
+ return automaticStartupAction;
+ }
+
+ public String getAutomaticStartupActionDelay() {
+ return automaticStartupActionDelay;
+ }
+
+ public String getAutomaticStartupActionSequenceNumber() {
+ return automaticStartupActionSequenceNumber;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public String getConfigurationDataRoot() {
+ return configurationDataRoot;
+ }
+
+ public String getConfigurationFile() {
+ return configurationFile;
+ }
+
+ public String getConfigurationID() {
+ return configurationID;
+ }
+
+ public DateTime getCreationTime() {
+ return creationTime;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLogDataRoot() {
+ return logDataRoot;
+ }
+
+ public String getRecoveryFile() {
+ return recoveryFile;
+ }
+
+ public String getSnapshotDataRoot() {
+ return snapshotDataRoot;
+ }
+
+ public String getSuspendDataRoot() {
+ return suspendDataRoot;
+ }
+
+ public String getSwapFileDataRoot() {
+ return swapFileDataRoot;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((automaticRecoveryAction == null) ? 0 : automaticRecoveryAction.hashCode());
+ result = prime * result
+ + ((automaticShutdownAction == null) ? 0 : automaticShutdownAction.hashCode());
+ result = prime * result
+ + ((automaticStartupAction == null) ? 0 : automaticStartupAction.hashCode());
+ result = prime
+ * result
+ + ((automaticStartupActionDelay == null) ? 0 : automaticStartupActionDelay
+ .hashCode());
+ result = prime
+ * result
+ + ((automaticStartupActionSequenceNumber == null) ? 0
+ : automaticStartupActionSequenceNumber.hashCode());
+ result = prime * result + ((caption == null) ? 0 : caption.hashCode());
+ result = prime * result
+ + ((configurationDataRoot == null) ? 0 : configurationDataRoot.hashCode());
+ result = prime * result + ((configurationFile == null) ? 0 : configurationFile.hashCode());
+ result = prime * result + ((configurationID == null) ? 0 : configurationID.hashCode());
+ result = prime * result + ((creationTime == null) ? 0 : creationTime.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + id;
+ result = prime * result + ((logDataRoot == null) ? 0 : logDataRoot.hashCode());
+ result = prime * result + ((recoveryFile == null) ? 0 : recoveryFile.hashCode());
+ result = prime * result + ((snapshotDataRoot == null) ? 0 : snapshotDataRoot.hashCode());
+ result = prime * result + ((suspendDataRoot == null) ? 0 : suspendDataRoot.hashCode());
+ result = prime * result + ((swapFileDataRoot == null) ? 0 : swapFileDataRoot.hashCode());
+ result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ TerremarkVirtualSystem other = (TerremarkVirtualSystem) obj;
+ if (automaticRecoveryAction == null) {
+ if (other.automaticRecoveryAction != null)
+ return false;
+ } else if (!automaticRecoveryAction.equals(other.automaticRecoveryAction))
+ return false;
+ if (automaticShutdownAction == null) {
+ if (other.automaticShutdownAction != null)
+ return false;
+ } else if (!automaticShutdownAction.equals(other.automaticShutdownAction))
+ return false;
+ if (automaticStartupAction == null) {
+ if (other.automaticStartupAction != null)
+ return false;
+ } else if (!automaticStartupAction.equals(other.automaticStartupAction))
+ return false;
+ if (automaticStartupActionDelay == null) {
+ if (other.automaticStartupActionDelay != null)
+ return false;
+ } else if (!automaticStartupActionDelay.equals(other.automaticStartupActionDelay))
+ return false;
+ if (automaticStartupActionSequenceNumber == null) {
+ if (other.automaticStartupActionSequenceNumber != null)
+ return false;
+ } else if (!automaticStartupActionSequenceNumber
+ .equals(other.automaticStartupActionSequenceNumber))
+ return false;
+ if (caption == null) {
+ if (other.caption != null)
+ return false;
+ } else if (!caption.equals(other.caption))
+ return false;
+ if (configurationDataRoot == null) {
+ if (other.configurationDataRoot != null)
+ return false;
+ } else if (!configurationDataRoot.equals(other.configurationDataRoot))
+ return false;
+ if (configurationFile == null) {
+ if (other.configurationFile != null)
+ return false;
+ } else if (!configurationFile.equals(other.configurationFile))
+ return false;
+ if (configurationID == null) {
+ if (other.configurationID != null)
+ return false;
+ } else if (!configurationID.equals(other.configurationID))
+ return false;
+ if (creationTime == null) {
+ if (other.creationTime != null)
+ return false;
+ } else if (!creationTime.equals(other.creationTime))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (id != other.id)
+ return false;
+ if (logDataRoot == null) {
+ if (other.logDataRoot != null)
+ return false;
+ } else if (!logDataRoot.equals(other.logDataRoot))
+ return false;
+ if (recoveryFile == null) {
+ if (other.recoveryFile != null)
+ return false;
+ } else if (!recoveryFile.equals(other.recoveryFile))
+ return false;
+ if (snapshotDataRoot == null) {
+ if (other.snapshotDataRoot != null)
+ return false;
+ } else if (!snapshotDataRoot.equals(other.snapshotDataRoot))
+ return false;
+ if (suspendDataRoot == null) {
+ if (other.suspendDataRoot != null)
+ return false;
+ } else if (!suspendDataRoot.equals(other.suspendDataRoot))
+ return false;
+ if (swapFileDataRoot == null) {
+ if (other.swapFileDataRoot != null)
+ return false;
+ } else if (!swapFileDataRoot.equals(other.swapFileDataRoot))
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "VirtualSystem [automaticRecoveryAction=" + automaticRecoveryAction
+ + ", automaticShutdownAction=" + automaticShutdownAction
+ + ", automaticStartupAction=" + automaticStartupAction
+ + ", automaticStartupActionDelay=" + automaticStartupActionDelay
+ + ", automaticStartupActionSequenceNumber=" + automaticStartupActionSequenceNumber
+ + ", caption=" + caption + ", configurationDataRoot=" + configurationDataRoot
+ + ", configurationFile=" + configurationFile + ", configurationID="
+ + configurationID + ", creationTime=" + creationTime + ", description="
+ + description + ", elementName=" + name + ", instanceID=" + id + ", logDataRoot="
+ + logDataRoot + ", recoveryFile=" + recoveryFile + ", snapshotDataRoot="
+ + snapshotDataRoot + ", suspendDataRoot=" + suspendDataRoot + ", swapFileDataRoot="
+ + swapFileDataRoot + ", virtualSystemIdentifier=" + identifier
+ + ", virtualSystemType=" + type + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VApp.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java
similarity index 71%
rename from vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VApp.java
rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java
index fc138b5bad..7e81484b98 100644
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/VApp.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VApp.java
@@ -1,6 +1,6 @@
/**
*
- * Copyright (C) 2009 Cloud Conscious, LLC.
+ * Copyright (C) 2009 Global Cloud Specialists, Inc.
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
@@ -21,36 +21,24 @@
* under the License.
* ====================================================================
*/
-package org.jclouds.vcloud.terremark.domain;
+package org.jclouds.vcloud.domain;
import java.net.InetAddress;
+import java.net.URI;
import java.util.Map;
import java.util.SortedSet;
-import org.jclouds.rest.domain.Link;
-import org.jclouds.vcloud.domain.NamedResource;
-import org.jclouds.vcloud.domain.VAppStatus;
-import org.jclouds.vcloud.terremark.domain.internal.VAppImpl;
-
import com.google.common.collect.ListMultimap;
-import com.google.inject.ImplementedBy;
-/**
- * @author Adrian Cole
- */
-@ImplementedBy(VAppImpl.class)
-public interface VApp extends NamedResource {
+public interface VApp {
+ String getId();
+
+ URI getLocation();
+
+ String getName();
VAppStatus getStatus();
- long getSize();
-
- Link getVDC();
-
- Link getComputeOptions();
-
- Link getCustomizationOptions();
-
ListMultimap getNetworkToAddresses();
String getOperatingSystemDescription();
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java
index 2565e638f3..4aa001aa82 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VAppStatus.java
@@ -29,12 +29,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author Adrian Cole
*/
public enum VAppStatus {
- CREATING, OFF, ON;
+ CREATING, TODO_I_DONT_KNOW, OFF, ON;
public String value() {
switch (this) {
case CREATING:
return "0";
+ case TODO_I_DONT_KNOW:
+ return "1";
case OFF:
return "2";
case ON:
@@ -52,6 +54,8 @@ public enum VAppStatus {
switch (v) {
case 0:
return CREATING;
+ case 1:
+ return TODO_I_DONT_KNOW;
case 2:
return OFF;
case 4:
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VDC.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VDC.java
index 0e22fe5498..bc6fb93d8b 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VDC.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VDC.java
@@ -26,7 +26,7 @@ package org.jclouds.vcloud.domain;
import java.net.URI;
import java.util.Map;
-import org.jclouds.rest.domain.NamedLink;
+import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.internal.VDCImpl;
import com.google.inject.ImplementedBy;
@@ -56,8 +56,8 @@ public interface VDC {
Quota getDeployedVmsQuota();
- Map getAvailableNetworks();
+ Map getAvailableNetworks();
- Map getResourceEntities();
+ Map getResourceEntities();
}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java
new file mode 100644
index 0000000000..06ac7d2130
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/VirtualSystem.java
@@ -0,0 +1,103 @@
+/**
+ *
+ * Copyright (C) 2009 Global Cloud Specialists, Inc.
+ *
+ * ====================================================================
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class VirtualSystem {
+ protected final int id;
+ protected final String name;
+ protected final String identifier;
+ protected final String type;
+
+ public VirtualSystem(int id, String name, String identifier, String type) {
+ this.id = id;
+ this.name = checkNotNull(name, "name");
+ this.identifier = checkNotNull(identifier, "identifier");
+ this.type = checkNotNull(type, "type");
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + id;
+ result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ VirtualSystem other = (VirtualSystem) obj;
+ if (id != other.id)
+ return false;
+ if (identifier == null) {
+ if (other.identifier != null)
+ return false;
+ } else if (!identifier.equals(other.identifier))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "VirtualSystem [id=" + id + ", identifier=" + identifier + ", name=" + name
+ + ", type=" + type + "]";
+ }
+
+}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
index 0253868b57..d3d6b184c1 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java
@@ -29,8 +29,8 @@ import java.net.URI;
import java.util.SortedMap;
import java.util.TreeMap;
+import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.Catalog;
-import org.jclouds.vcloud.domain.NamedResource;
import com.google.inject.internal.Nullable;
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/NamedResourceImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/NamedResourceImpl.java
deleted file mode 100644
index 094ea91675..0000000000
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/NamedResourceImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.jclouds.vcloud.domain.internal;
-
-import java.net.URI;
-
-import org.jclouds.rest.domain.internal.NamedLinkImpl;
-import org.jclouds.vcloud.domain.NamedResource;
-
-/**
- * Location of a Rest resource
- *
- * @author Adrian Cole
- *
- */
-public class NamedResourceImpl extends NamedLinkImpl implements NamedResource {
- private final String id;
-
- public NamedResourceImpl(String id, String name, String type, URI location) {
- super(name, type, location);
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public int compareTo(NamedResource that) {
- return (this == that) ? 0 : this.id.compareTo(that.getId());
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- NamedResourceImpl other = (NamedResourceImpl) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "NamedResourceImpl [id=" + id + ", name=" + getName() + ", location="
- + getLocation() + ", type=" + getType() + "]";
- }
-}
\ No newline at end of file
diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/internal/VAppImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
similarity index 72%
rename from vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/internal/VAppImpl.java
rename to vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
index 490b843474..a503e6a943 100644
--- a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/domain/internal/VAppImpl.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java
@@ -21,20 +21,18 @@
* under the License.
* ====================================================================
*/
-package org.jclouds.vcloud.terremark.domain.internal;
+package org.jclouds.vcloud.domain.internal;
import java.net.InetAddress;
import java.net.URI;
import java.util.Map;
import java.util.SortedSet;
-import org.jclouds.rest.domain.Link;
+import org.jclouds.vcloud.domain.ResourceAllocation;
+import org.jclouds.vcloud.domain.ResourceType;
+import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus;
-import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
-import org.jclouds.vcloud.terremark.domain.ResourceAllocation;
-import org.jclouds.vcloud.terremark.domain.ResourceType;
-import org.jclouds.vcloud.terremark.domain.VApp;
-import org.jclouds.vcloud.terremark.domain.VirtualSystem;
+import org.jclouds.vcloud.domain.VirtualSystem;
import com.google.common.base.Function;
import com.google.common.collect.ListMultimap;
@@ -46,13 +44,11 @@ import com.google.common.collect.Maps;
* @author Adrian Cole
*
*/
-public class VAppImpl extends NamedResourceImpl implements VApp {
-
+public class VAppImpl implements VApp {
+ private final String id;
+ private final String name;
+ private final URI location;
private final VAppStatus status;
- private final long size;
- private final Link vDC;
- private final Link computeOptions;
- private final Link customizationOptions;
private final ListMultimap networkToAddresses;
private final String operatingSystemDescription;
private final VirtualSystem system;
@@ -62,17 +58,14 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
- public VAppImpl(String id, String name, String type, URI location, VAppStatus status, long size,
- Link vDC, Link computeOptions, Link customizationOptions,
+ public VAppImpl(String id, String name, URI location, VAppStatus status,
ListMultimap networkToAddresses,
String operatingSystemDescription, VirtualSystem system,
SortedSet resourceAllocations) {
- super(id, name, type, location);
+ this.id = id;
+ this.name = name;
+ this.location = location;
this.status = status;
- this.size = size;
- this.vDC = vDC;
- this.computeOptions = computeOptions;
- this.customizationOptions = customizationOptions;
this.networkToAddresses = networkToAddresses;
this.operatingSystemDescription = operatingSystemDescription;
this.system = system;
@@ -81,7 +74,7 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
new Function() {
@Override
public ResourceType apply(ResourceAllocation from) {
- return from.getResourceType();
+ return from.getType();
}
});
}
@@ -90,22 +83,6 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
return status;
}
- public long getSize() {
- return size;
- }
-
- public Link getVDC() {
- return vDC;
- }
-
- public Link getComputeOptions() {
- return computeOptions;
- }
-
- public Link getCustomizationOptions() {
- return customizationOptions;
- }
-
public ListMultimap getNetworkToAddresses() {
return networkToAddresses;
}
@@ -122,13 +99,17 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
return resourceAllocations;
}
+ public Map getResourceAllocationByType() {
+ return resourceAllocationByType;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((computeOptions == null) ? 0 : computeOptions.hashCode());
- result = prime * result
- + ((customizationOptions == null) ? 0 : customizationOptions.hashCode());
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((networkToAddresses == null) ? 0 : networkToAddresses.hashCode());
result = prime * result
+ ((operatingSystemDescription == null) ? 0 : operatingSystemDescription.hashCode());
@@ -136,10 +117,8 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
+ ((resourceAllocationByType == null) ? 0 : resourceAllocationByType.hashCode());
result = prime * result
+ ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode());
- result = prime * result + (int) (size ^ (size >>> 32));
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
- result = prime * result + ((vDC == null) ? 0 : vDC.hashCode());
return result;
}
@@ -147,20 +126,25 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
public boolean equals(Object obj) {
if (this == obj)
return true;
- if (!super.equals(obj))
+ if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
VAppImpl other = (VAppImpl) obj;
- if (computeOptions == null) {
- if (other.computeOptions != null)
+ if (id == null) {
+ if (other.id != null)
return false;
- } else if (!computeOptions.equals(other.computeOptions))
+ } else if (!id.equals(other.id))
return false;
- if (customizationOptions == null) {
- if (other.customizationOptions != null)
+ if (location == null) {
+ if (other.location != null)
return false;
- } else if (!customizationOptions.equals(other.customizationOptions))
+ } else if (!location.equals(other.location))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
return false;
if (networkToAddresses == null) {
if (other.networkToAddresses != null)
@@ -182,8 +166,6 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
return false;
} else if (!resourceAllocations.equals(other.resourceAllocations))
return false;
- if (size != other.size)
- return false;
if (status == null) {
if (other.status != null)
return false;
@@ -194,16 +176,28 @@ public class VAppImpl extends NamedResourceImpl implements VApp {
return false;
} else if (!system.equals(other.system))
return false;
- if (vDC == null) {
- if (other.vDC != null)
- return false;
- } else if (!vDC.equals(other.vDC))
- return false;
return true;
}
- public Map getResourceAllocationByType() {
- return resourceAllocationByType;
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public URI getLocation() {
+ return location;
+ }
+
+ @Override
+ public String toString() {
+ return "VAppImpl [id=" + id + ", location=" + location + ", name=" + name
+ + ", networkToAddresses=" + networkToAddresses + ", operatingSystemDescription="
+ + operatingSystemDescription + ", resourceAllocationByType="
+ + resourceAllocationByType + ", resourceAllocations=" + resourceAllocations
+ + ", status=" + status + ", system=" + system + "]";
}
}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
index 7ade0eaf8b..75c15675de 100644
--- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java
@@ -28,7 +28,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Map;
-import org.jclouds.rest.domain.NamedLink;
+import org.jclouds.rest.domain.NamedResource;
import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.Quota;
import org.jclouds.vcloud.domain.VDC;
@@ -50,13 +50,14 @@ public class VDCImpl implements VDC {
private final Capacity memoryCapacity;
private final Quota instantiatedVmsQuota;
private final Quota deployedVmsQuota;
- private final Map availableNetworks;
- private final Map resourceEntities;
+ private final Map availableNetworks;
+ private final Map resourceEntities;
- public VDCImpl(String id, String name, URI location, String description, Capacity storageCapacity,
- Capacity cpuCapacity, Capacity memoryCapacity, Quota instantiatedVmsQuota,
- Quota deployedVmsQuota, Map resourceEntities,
- Map availableNetworks) {
+ public VDCImpl(String id, String name, URI location, String description,
+ Capacity storageCapacity, Capacity cpuCapacity, Capacity memoryCapacity,
+ Quota instantiatedVmsQuota, Quota deployedVmsQuota,
+ Map resourceEntities,
+ Map availableNetworks) {
this.id = id;
this.name = checkNotNull(name, "name");
this.location = checkNotNull(location, "location");
@@ -85,11 +86,11 @@ public class VDCImpl implements VDC {
return location;
}
- public Map getAvailableNetworks() {
+ public Map getAvailableNetworks() {
return availableNetworks;
}
- public Map getResourceEntities() {
+ public Map getResourceEntities() {
return resourceEntities;
}
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/internal/VAppTemplateRoot.java b/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/internal/VAppTemplateRoot.java
new file mode 100644
index 0000000000..0d52935f56
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/endpoints/internal/VAppTemplateRoot.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright (C) 2009 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * 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.endpoints.internal;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * Root path where all vApps exist.
+ *
+ * @author Adrian Cole
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
+@Qualifier
+public @interface VAppTemplateRoot {
+
+}
\ No newline at end of file
diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java
new file mode 100644
index 0000000000..262d227f86
--- /dev/null
+++ b/vcloud/core/src/main/java/org/jclouds/vcloud/functions/VAppTemplateIdToUri.java
@@ -0,0 +1,28 @@
+package org.jclouds.vcloud.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.vcloud.endpoints.internal.VAppTemplateRoot;
+
+import com.google.common.base.Function;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class VAppTemplateIdToUri implements Function