You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/12 05:45:30 UTC
[2/6] Fold dmtf into vcloud-director (its only user).
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java
new file mode 100644
index 0000000..7e7ee35
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/VirtualSystemSettingData.java
@@ -0,0 +1,720 @@
+/*
+ * 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.dmtf.cim;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS;
+import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
+
+import java.math.BigInteger;
+import java.util.Date;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlEnumValue;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.base.Function;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+
+/**
+ * VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of
+ * virtualization specific properties.
+ *
+ * VirtualSystemSettingData is also used as the top level class of virtual system configurations.
+ * Virtual system configurations model configuration information about virtual systems and their
+ * components. A virtual system configuration consists of one top-level instance of class
+ * VirtualSystemSettingData that aggregates a number of instances of class
+ * {@link ResourceAllocationSettingData}, using association {@link ConcreteComponent).
+ * <p>
+ * Virtual system configurations may for example be used to reflect configurations of:
+ * <ul>
+ * <li>virtual systems that are defined at a virtualization platform
+ * <li>virtual systems that are currently active
+ * <li>input requests to create new virtual systems
+ * <li>input requests to modify existing virtual systems
+ * <li>snapshots of virtual systems
+ * </ul>
+ *
+ * @see <a href="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd">CIM_VirtualSystemSettingData</a>
+ */
+@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = OVF_NS,
+ propOrder = {
+ "automaticRecoveryAction",
+ "automaticShutdownAction",
+ "automaticStartupAction",
+ "automaticStartupActionDelay",
+ "automaticStartupActionSequenceNumber",
+ "caption",
+ "configurationDataRoot",
+ "configurationFile",
+ "configurationID",
+ "creationTime",
+ "description",
+ "elementName",
+ "instanceID",
+ "logDataRoot",
+ "notes",
+ "recoveryFile",
+ "snapshotDataRoot",
+ "suspendDataRoot",
+ "swapFileDataRoot",
+ "virtualSystemIdentifier",
+ "virtualSystemType"
+ }
+)
+public class VirtualSystemSettingData {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromVirtualSystemSettingData(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> {
+
+ private String elementName;
+ private String instanceID;
+ private String caption;
+ private String description;
+ private AutomaticRecoveryAction automaticRecoveryAction;
+ private AutomaticShutdownAction automaticShutdownAction;
+ private AutomaticStartupAction automaticStartupAction;
+ private BigInteger automaticStartupActionDelay;
+ private Long automaticStartupActionSequenceNumber;
+ private String configurationDataRoot;
+ private String configurationFile;
+ private String configurationID;
+ private Date creationTime;
+ private String logDataRoot;
+ private String recoveryFile;
+ private String snapshotDataRoot;
+ private String suspendDataRoot;
+ private String swapFileDataRoot;
+ private String virtualSystemIdentifier;
+ private String virtualSystemType;
+ private String notes;
+
+ @SuppressWarnings("unchecked")
+ protected B self() {
+ return (B) this;
+ }
+
+ public B elementName(String elementName) {
+ this.elementName = elementName;
+ return self();
+ }
+
+ public B instanceID(String instanceID) {
+ this.instanceID = instanceID;
+ return self();
+ }
+
+ public B caption(String caption) {
+ this.caption = caption;
+ return self();
+ }
+
+ public B description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ public B automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) {
+ this.automaticRecoveryAction = automaticRecoveryAction;
+ return self();
+ }
+
+ public B automaticShutdownAction(AutomaticShutdownAction automaticShutdownAction) {
+ this.automaticShutdownAction = automaticShutdownAction;
+ return self();
+ }
+
+ public B automaticStartupAction(AutomaticStartupAction automaticStartupAction) {
+ this.automaticStartupAction = automaticStartupAction;
+ return self();
+ }
+
+ public B automaticStartupActionDelay(BigInteger automaticStartupActionDelay) {
+ this.automaticStartupActionDelay = automaticStartupActionDelay;
+ return self();
+ }
+
+ public B automaticStartupActionSequenceNumber(Long automaticStartupActionSequenceNumber) {
+ this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
+ return self();
+ }
+
+ public B configurationDataRoot(String configurationDataRoot) {
+ this.configurationDataRoot = configurationDataRoot;
+ return self();
+ }
+
+ public B configurationFile(String configurationFile) {
+ this.configurationFile = configurationFile;
+ return self();
+ }
+
+ public B configurationID(String configurationID) {
+ this.configurationID = configurationID;
+ return self();
+ }
+
+ public B creationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ return self();
+ }
+
+ public B logDataRoot(String logDataRoot) {
+ this.logDataRoot = logDataRoot;
+ return self();
+ }
+
+ public B recoveryFile(String recoveryFile) {
+ this.recoveryFile = recoveryFile;
+ return self();
+ }
+
+ public B snapshotDataRoot(String snapshotDataRoot) {
+ this.snapshotDataRoot = snapshotDataRoot;
+ return self();
+ }
+
+ public B suspendDataRoot(String suspendDataRoot) {
+ this.suspendDataRoot = suspendDataRoot;
+ return self();
+ }
+
+ public B swapFileDataRoot(String swapFileDataRoot) {
+ this.swapFileDataRoot = swapFileDataRoot;
+ return self();
+ }
+
+ public B virtualSystemIdentifier(String virtualSystemIdentifier) {
+ this.virtualSystemIdentifier = virtualSystemIdentifier;
+ return self();
+ }
+
+ public B virtualSystemType(String virtualSystemType) {
+ this.virtualSystemType = virtualSystemType;
+ return self();
+ }
+
+ public B notes(String notes) {
+ this.notes = notes;
+ return self();
+ }
+
+ public VirtualSystemSettingData build() {
+ return new VirtualSystemSettingData(this);
+ }
+
+ public B fromVirtualSystemSettingData(VirtualSystemSettingData in) {
+ return elementName(in.getElementName())
+ .instanceID(in.getInstanceID())
+ .caption(in.getCaption())
+ .description(in.getDescription())
+ .automaticRecoveryAction(in.getAutomaticRecoveryAction())
+ .automaticShutdownAction(in.getAutomaticShutdownAction())
+ .automaticStartupAction(in.getAutomaticStartupAction())
+ .automaticStartupActionDelay(in.getAutomaticStartupActionDelay())
+ .automaticStartupActionSequenceNumber(in.getAutomaticStartupActionSequenceNumber())
+ .configurationDataRoot(in.getConfigurationDataRoot())
+ .configurationFile(in.getConfigurationFile())
+ .configurationID(in.getConfigurationID())
+ .creationTime(in.getCreationTime())
+ .logDataRoot(in.getLogDataRoot())
+ .recoveryFile(in.getRecoveryFile())
+ .snapshotDataRoot(in.getSnapshotDataRoot())
+ .suspendDataRoot(in.getSuspendDataRoot())
+ .swapFileDataRoot(in.getSwapFileDataRoot())
+ .virtualSystemIdentifier(in.getVirtualSystemIdentifier())
+ .virtualSystemType(in.getVirtualSystemType())
+ .notes(in.getNotes());
+ }
+
+ }
+
+ /**
+ * Action to take for the virtual system when the software executed by the virtual system fails.
+ *
+ * Failures in this case means a failure that is detectable by the host platform, such as a
+ * non-interruptible wait state condition.
+ */
+ @XmlType
+ @XmlEnum(Integer.class)
+ public static enum AutomaticRecoveryAction {
+
+ @XmlEnumValue("2") NONE(2),
+ @XmlEnumValue("3") RESTART(3),
+ @XmlEnumValue("4") REVERT_TO_SNAPSHOT(4);
+
+ protected final int code;
+
+ AutomaticRecoveryAction(int code) {
+ this.code = code;
+ }
+
+ public String value() {
+ return Integer.toString(code);
+ }
+
+ protected static final Map<Integer, AutomaticRecoveryAction> AUTOMATIC_RECOVERY_ACTION_BY_ID = Maps.uniqueIndex(
+ ImmutableSet.copyOf(AutomaticRecoveryAction.values()), new Function<AutomaticRecoveryAction, Integer>() {
+ @Override
+ public Integer apply(AutomaticRecoveryAction input) {
+ return input.code;
+ }
+ });
+
+ public static AutomaticRecoveryAction fromValue(String automaticRecoveryAction) {
+ return AUTOMATIC_RECOVERY_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticRecoveryAction, "automaticRecoveryAction")));
+ }
+ }
+
+ /**
+ * Action to take for the virtual system when the host is shut down.
+ */
+ @XmlType
+ @XmlEnum(Integer.class)
+ public static enum AutomaticShutdownAction {
+
+ @XmlEnumValue("2") TURN_OFF(2),
+ @XmlEnumValue("3") SAVE_STATE(3),
+ @XmlEnumValue("4") SHUTDOWN(4);
+
+ protected final int code;
+
+ AutomaticShutdownAction(int code) {
+ this.code = code;
+ }
+
+ public String value() {
+ return Integer.toString(code);
+ }
+
+ protected static final Map<Integer, AutomaticShutdownAction> AUTOMATIC_SHUTDOWN_ACTION_BY_ID = Maps.uniqueIndex(
+ ImmutableSet.copyOf(AutomaticShutdownAction.values()), new Function<AutomaticShutdownAction, Integer>() {
+ @Override
+ public Integer apply(AutomaticShutdownAction input) {
+ return input.code;
+ }
+ });
+
+ public static AutomaticShutdownAction fromValue(String automaticShutdownAction) {
+ return AUTOMATIC_SHUTDOWN_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticShutdownAction, "automaticShutdownAction")));
+ }
+ }
+
+ /**
+ * Action to take for the virtual system when the host is started.
+ */
+ @XmlType
+ @XmlEnum(Integer.class)
+ public static enum AutomaticStartupAction {
+
+ @XmlEnumValue("2") NONE(2),
+ @XmlEnumValue("3") RESTART_IF_PREVIOUSLY_ACTIVE(3),
+ @XmlEnumValue("4") ALWAYS_STARTUP(4);
+
+ protected final int code;
+
+ AutomaticStartupAction(int code) {
+ this.code = code;
+ }
+
+ public String value() {
+ return Integer.toString(code);
+ }
+
+ protected static final Map<Integer, AutomaticStartupAction> AUTOMATIC_STARTUP_ACTION_BY_ID = Maps.uniqueIndex(
+ ImmutableSet.copyOf(AutomaticStartupAction.values()), new Function<AutomaticStartupAction, Integer>() {
+ @Override
+ public Integer apply(AutomaticStartupAction input) {
+ return input.code;
+ }
+ });
+
+ public static AutomaticStartupAction fromValue(String automaticStartupAction) {
+ return AUTOMATIC_STARTUP_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticStartupAction, "automaticStartupAction")));
+ }
+ }
+
+ @XmlElement(name = "ElementName", namespace = CIM_VSSD_NS)
+ private String elementName;
+ @XmlElement(name = "InstanceID", namespace = CIM_VSSD_NS)
+ private String instanceID;
+ @XmlElement(name = "Caption", namespace = CIM_VSSD_NS)
+ private String caption;
+ @XmlElement(name = "Description", namespace = CIM_VSSD_NS)
+ private String description;
+ @XmlElement(name = "VirtualSystemIdentifier", namespace = CIM_VSSD_NS)
+ private String virtualSystemIdentifier;
+ @XmlElement(name = "VirtualSystemType", namespace = CIM_VSSD_NS)
+ private String virtualSystemType;
+ @XmlElement(name = "AutomaticRecoveryAction", namespace = CIM_VSSD_NS)
+ private AutomaticRecoveryAction automaticRecoveryAction;
+ @XmlElement(name = "AutomaticShutdownAction", namespace = CIM_VSSD_NS)
+ private AutomaticShutdownAction automaticShutdownAction;
+ @XmlElement(name = "AutomaticStartupAction", namespace = CIM_VSSD_NS)
+ private AutomaticStartupAction automaticStartupAction;
+ @XmlElement(name = "AutomaticStartupActionDelay", namespace = CIM_VSSD_NS)
+ private BigInteger automaticStartupActionDelay;
+ @XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = CIM_VSSD_NS)
+ private Long automaticStartupActionSequenceNumber;
+ @XmlElement(name = "ConfigurationDataRoot", namespace = CIM_VSSD_NS)
+ private String configurationDataRoot;
+ @XmlElement(name = "ConfigurationFile", namespace = CIM_VSSD_NS)
+ private String configurationFile;
+ @XmlElement(name = "ConfigurationID", namespace = CIM_VSSD_NS)
+ private String configurationID;
+ @XmlElement(name = "CreationTime", namespace = CIM_VSSD_NS)
+ private Date creationTime;
+ @XmlElement(name = "LogDataRoot", namespace = CIM_VSSD_NS)
+ private String logDataRoot;
+ @XmlElement(name = "RecoveryFile", namespace = CIM_VSSD_NS)
+ private String recoveryFile;
+ @XmlElement(name = "SnapshotDataRoot", namespace = CIM_VSSD_NS)
+ private String snapshotDataRoot;
+ @XmlElement(name = "SuspendDataRoot", namespace = CIM_VSSD_NS)
+ private String suspendDataRoot;
+ @XmlElement(name = "SwapFileDataRoot", namespace = CIM_VSSD_NS)
+ private String swapFileDataRoot;
+ @XmlElement(name = "Notes", namespace = CIM_VSSD_NS)
+ private String notes;
+
+ private VirtualSystemSettingData(Builder<?> builder) {
+ this.elementName = builder.elementName;
+ this.instanceID = builder.instanceID;
+ this.caption = builder.caption;
+ this.description = builder.description;
+ this.automaticRecoveryAction = builder.automaticRecoveryAction;
+ this.automaticShutdownAction = builder.automaticShutdownAction;
+ this.automaticStartupAction = builder.automaticStartupAction;
+ this.automaticStartupActionDelay = builder.automaticStartupActionDelay;
+ this.automaticStartupActionSequenceNumber = builder.automaticStartupActionSequenceNumber;
+ this.configurationDataRoot = builder.configurationDataRoot;
+ this.configurationFile = builder.configurationFile;
+ this.configurationID = builder.configurationID;
+ this.creationTime = builder.creationTime;
+ this.logDataRoot = builder.logDataRoot;
+ this.recoveryFile = builder.recoveryFile;
+ this.snapshotDataRoot = builder.snapshotDataRoot;
+ this.suspendDataRoot = builder.suspendDataRoot;
+ this.swapFileDataRoot = builder.swapFileDataRoot;
+ this.virtualSystemIdentifier = builder.virtualSystemIdentifier;
+ this.virtualSystemType = builder.virtualSystemType;
+ this.notes = builder.notes;
+ }
+
+ private VirtualSystemSettingData(String elementName, String instanceID, String caption, String description,
+ AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction,
+ AutomaticStartupAction automaticStartupAction, BigInteger automaticStartupActionDelay,
+ Long automaticStartupActionSequenceNumber, String configurationDataRoot, String configurationFile,
+ String configurationID, Date creationTime, String logDataRoot, String recoveryFile, String snapshotDataRoot,
+ String suspendDataRoot, String swapFileDataRoot, String virtualSystemIdentifier,
+ String virtualSystemType, String notes) {
+ this.elementName = elementName;
+ this.instanceID = instanceID;
+ this.caption = caption;
+ this.description = description;
+ this.automaticRecoveryAction = automaticRecoveryAction;
+ this.automaticShutdownAction = automaticShutdownAction;
+ this.automaticStartupAction = automaticStartupAction;
+ this.automaticStartupActionDelay = automaticStartupActionDelay;
+ this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
+ this.configurationDataRoot = configurationDataRoot;
+ this.configurationFile = configurationFile;
+ this.configurationID = configurationID;
+ this.creationTime = creationTime;
+ this.logDataRoot = logDataRoot;
+ this.recoveryFile = recoveryFile;
+ this.snapshotDataRoot = snapshotDataRoot;
+ this.suspendDataRoot = suspendDataRoot;
+ this.swapFileDataRoot = swapFileDataRoot;
+ this.virtualSystemIdentifier = virtualSystemIdentifier;
+ this.virtualSystemType = virtualSystemType;
+ this.notes = notes;
+ }
+
+ private VirtualSystemSettingData() {
+ // for JAXB
+ }
+
+ /**
+ * The user-friendly name for this instance of SettingData. In addition, the user-friendly name
+ * can be used as an index property for a search or query. (Note: The name does not have to be
+ * unique within a namespace.)
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+ /**
+ * Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies
+ * an instance of this class.
+ */
+ public String getInstanceID() {
+ return instanceID;
+ }
+
+ /**
+ * The Caption property is a short textual description (one- line string) of the object.
+ */
+ public String getCaption() {
+ return caption;
+ }
+
+ /**
+ * The Description property provides a textual description of the object.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Action to take for the virtual system when the software executed by the virtual system fails.
+ * Failures in this case means a failure that is detectable by the host platform, such as a
+ * non-interruptible wait state condition.
+ */
+ public AutomaticRecoveryAction getAutomaticRecoveryAction() {
+ return automaticRecoveryAction;
+ }
+
+ /**
+ * Action to take for the virtual system when the host is shut down.
+ */
+ public AutomaticShutdownAction getAutomaticShutdownAction() {
+ return automaticShutdownAction;
+ }
+
+ /**
+ * Action to take for the virtual system when the host is started.
+ */
+ public AutomaticStartupAction getAutomaticStartupAction() {
+ return automaticStartupAction;
+ }
+
+ /**
+ * Delay applicable to startup action. The value shall be in the interval variant of the datetime
+ * datatype.
+ */
+ public BigInteger getAutomaticStartupActionDelay() {
+ return automaticStartupActionDelay;
+ }
+
+ /**
+ * Number indicating the relative sequence of virtual system activation when the host system is
+ * started. A lower number indicates earlier activation. If one or more configurations show the
+ * same value, the sequence is implementation dependent. A value of 0 indicates that the sequence
+ * is implementation dependent.
+ */
+ public Long getAutomaticStartupActionSequenceNumber() {
+ return automaticStartupActionSequenceNumber;
+ }
+
+ /**
+ * Filepath of a directory where information about the virtual system configuration is
+ * stored.
+ *
+ * Format shall be String based on RFC-2079.
+ */
+ public String getConfigurationDataRoot() {
+ return configurationDataRoot;
+ }
+
+ /**
+ * Filepath of a file where information about the virtual system configuration is stored.
+ *
+ * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
+ * <p>
+ * Format shall be String based on RFC-2079.
+ */
+ public String getConfigurationFile() {
+ return configurationFile;
+ }
+
+ /**
+ * Unique id of the virtual system configuration. Note that the ConfigurationID is different from
+ * the InstanceID as it is assigned by the implementation to a virtual system or a virtual system
+ * configuration. It is not a key, and the same value may occur within more than one instance.
+ */
+ public String getConfigurationID() {
+ return configurationID;
+ }
+
+ /**
+ * Time when the virtual system configuration was created.
+ */
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ /**
+ * Filepath of a directory where log information about the virtual system is stored.
+ *
+ * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
+ * <p>
+ * Format shall be String based on RFC-2079.
+ */
+ public String getLogDataRoot() {
+ return logDataRoot;
+ }
+
+ /**
+ * Filepath of a file where recovery related information of the virtual system is stored.
+ *
+ * Format shall be String based on RFC-2079.
+ */
+ public String getRecoveryFile() {
+ return recoveryFile;
+ }
+
+ /**
+ * Filepath of a directory where information about virtual system snapshots is stored.
+ *
+ * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
+ * <p>
+ * Format shall be String based on RFC-2079.
+ */
+ public String getSnapshotDataRoot() {
+ return snapshotDataRoot;
+ }
+
+ /**
+ * Filepath of a directory where suspend related information about the virtual system is stored.
+ *
+ * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
+ * <p>
+ * Format shall be String based on RFC-2079.
+ */
+ public String getSuspendDataRoot() {
+ return suspendDataRoot;
+ }
+
+ /**
+ * Filepath of a directory where swapfiles of the virtual system are stored.
+ *
+ * A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
+ * <p>
+ * Format shall be String based on RFC-2079.
+ */
+ public String getSwapFileDataRoot() {
+ return swapFileDataRoot;
+ }
+
+ /**
+ * VirtualSystemIdentifier shall reflect a unique name for the system as it is used within the
+ * virtualization platform.
+ *
+ * Note that the VirtualSystemIdentifier is not the hostname assigned to
+ * the operating system instance running within the virtual system, nor is it an IP address or
+ * MAC address assigned to any of its network ports. On create requests VirtualSystemIdentifier
+ * may contain implementation specific rules (like simple patterns or regular expression) that
+ * may be interpreted by the implementation when assigning a VirtualSystemIdentifier.
+ */
+ public String getVirtualSystemIdentifier() {
+ return virtualSystemIdentifier;
+ }
+
+ /**
+ * VirtualSystemType shall reflect a particular type of virtual system.
+ */
+ public String getVirtualSystemType() {
+ return virtualSystemType;
+ }
+
+ /**
+ * End-user supplied notes that are related to the virtual system.
+ */
+ public String getNotes() {
+ return notes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(elementName, instanceID, caption, description, virtualSystemIdentifier, virtualSystemType);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ VirtualSystemSettingData that = VirtualSystemSettingData.class.cast(obj);
+ return equal(this.elementName, that.elementName)
+ && equal(this.instanceID, that.instanceID)
+ && equal(this.caption, that.caption)
+ && equal(this.description, that.description)
+ && equal(this.automaticRecoveryAction, that.automaticRecoveryAction)
+ && equal(this.automaticShutdownAction, that.automaticShutdownAction)
+ && equal(this.automaticStartupAction, that.automaticStartupAction)
+ && equal(this.automaticStartupActionDelay, that.automaticStartupActionDelay)
+ && equal(this.automaticStartupActionSequenceNumber, that.automaticStartupActionSequenceNumber)
+ && equal(this.configurationDataRoot, that.configurationDataRoot)
+ && equal(this.configurationFile, that.configurationFile)
+ && equal(this.configurationID, that.configurationID)
+ && equal(this.creationTime, that.creationTime)
+ && equal(this.logDataRoot, that.logDataRoot)
+ && equal(this.recoveryFile, that.recoveryFile)
+ && equal(this.snapshotDataRoot, that.snapshotDataRoot)
+ && equal(this.suspendDataRoot, that.suspendDataRoot)
+ && equal(this.swapFileDataRoot, that.swapFileDataRoot)
+ && equal(this.virtualSystemIdentifier, that.virtualSystemIdentifier)
+ && equal(this.virtualSystemType, that.virtualSystemType);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper("")
+ .add("elementName", elementName)
+ .add("instanceID", instanceID)
+ .add("caption", caption)
+ .add("description", description)
+ .add("automaticRecoveryAction", automaticRecoveryAction)
+ .add("automaticShutdownAction", automaticShutdownAction)
+ .add("automaticStartupAction", automaticStartupAction)
+ .add("automaticStartupActionDelay", automaticStartupActionDelay)
+ .add("automaticStartupActionSequenceNumber", automaticStartupActionSequenceNumber)
+ .add("configurationDataRoot", configurationDataRoot)
+ .add("configurationFile", configurationFile)
+ .add("configurationID", configurationID)
+ .add("creationTime", creationTime)
+ .add("logDataRoot", logDataRoot)
+ .add("recoveryFile", recoveryFile)
+ .add("snapshotDataRoot", snapshotDataRoot)
+ .add("suspendDataRoot", suspendDataRoot)
+ .add("swapFileDataRoot", swapFileDataRoot)
+ .add("virtualSystemIdentifier", virtualSystemIdentifier)
+ .add("virtualSystemType", virtualSystemType)
+ .toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java
new file mode 100644
index 0000000..cea2526
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/functions/HardwareBuilderFromResourceAllocations.java
@@ -0,0 +1,70 @@
+/*
+ * 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.dmtf.cim.functions;
+
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.transform;
+
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.Volume;
+import org.jclouds.compute.domain.internal.VolumeImpl;
+import org.jclouds.dmtf.CIMPredicates;
+import org.jclouds.dmtf.cim.ResourceAllocationSettingData;
+import org.jclouds.dmtf.cim.ResourceAllocationSettingData.ResourceType;
+
+import com.google.common.base.Function;
+
+@Singleton
+public class HardwareBuilderFromResourceAllocations implements
+ Function<Iterable<? extends ResourceAllocationSettingData>, HardwareBuilder> {
+ @Override
+ public HardwareBuilder apply(Iterable<? extends ResourceAllocationSettingData> from) {
+ HardwareBuilder builder = new HardwareBuilder();
+ builder.volumes(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE,
+ ResourceType.BASE_PARTITIONABLE_UNIT, ResourceType.PARTITIONABLE_UNIT)),
+ new Function<ResourceAllocationSettingData, Volume>() {
+
+ @Override
+ public Volume apply(ResourceAllocationSettingData from) {
+ return HardwareBuilderFromResourceAllocations.this.apply(from);
+ }
+
+ }));
+
+ builder.ram((int) find(from, CIMPredicates.resourceTypeIn(ResourceType.MEMORY)).getVirtualQuantity().longValue());
+
+ builder.processors(transform(filter(from, CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR)),
+ new Function<ResourceAllocationSettingData, Processor>() {
+
+ @Override
+ public Processor apply(ResourceAllocationSettingData arg0) {
+ return new Processor(arg0.getVirtualQuantity().longValue(), 1);
+ }
+ }));
+ return builder;
+ }
+
+ public Volume apply(ResourceAllocationSettingData from) {
+ return new VolumeImpl(from.getAddressOnParent() + "", Volume.Type.LOCAL, from.getVirtualQuantity() == null ? null
+ : from.getVirtualQuantity().longValue() / (float) (1024 * 1024), null, "0".equals(from.getAddressOnParent())
+ || ResourceType.BASE_PARTITIONABLE_UNIT.equals(from.getResourceType()), true);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/cim/package-info.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/cim/package-info.java b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/package-info.java
new file mode 100644
index 0000000..d531ada
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/cim/package-info.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+@XmlSchema(namespace = CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED,
+ xmlns = {
+ @XmlNs(prefix = "cim", namespaceURI = CIM_NS),
+ @XmlNs(prefix = "ovf", namespaceURI = OVF_NS),
+ @XmlNs(prefix = "vssd", namespaceURI = CIM_VSSD_NS),
+ @XmlNs(prefix = "rasd", namespaceURI = CIM_RASD_NS)
+ }
+)
+@XmlAccessorType(XmlAccessType.FIELD)
+package org.jclouds.dmtf.cim;
+
+import static org.jclouds.dmtf.DMTFConstants.CIM_NS;
+import static org.jclouds.dmtf.DMTFConstants.CIM_RASD_NS;
+import static org.jclouds.dmtf.DMTFConstants.CIM_VSSD_NS;
+import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlNs;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlSchema;
+
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Configuration.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Configuration.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Configuration.java
new file mode 100644
index 0000000..0669a32
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Configuration.java
@@ -0,0 +1,147 @@
+/*
+ * 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.dmtf.ovf;
+
+import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+@XmlType(name = "Configuration", namespace = OVF_NS, propOrder = {
+ "label", "description"
+})
+public class Configuration {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String id;
+ private boolean isDefault;
+ private String label;
+ private String description;
+
+ /**
+ * @see Configuration#getId
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * @see Configuration#getLabel
+ */
+ public Builder label(String label) {
+ this.label = label;
+ return this;
+ }
+
+ /**
+ * @see Configuration#getDescription
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @see Configuration#isDefault
+ */
+ public Builder isDefault(boolean isDefault) {
+ this.isDefault = isDefault;
+ return this;
+ }
+
+ public Configuration build() {
+ return new Configuration(id, isDefault, label, description);
+ }
+
+ public Builder fromConfiguration(Configuration in) {
+ return id(in.getId()).description(in.getDescription()).label(in.getLabel());
+ }
+ }
+
+ @XmlAttribute
+ private String id;
+ @XmlAttribute(name = "default")
+ private boolean isDefault;
+ @XmlElement(name = "Label")
+ private String label;
+ @XmlElement(name = "Description")
+ private String description;
+
+ public Configuration(String id, boolean isDefault, String label, String description) {
+ this.id = id;
+ this.label = label;
+ this.description = description;
+ this.isDefault = isDefault;
+ }
+
+ public Configuration() {
+ // for JAXB
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, label, description);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Configuration other = (Configuration) obj;
+ return Objects.equal(id, other.id)
+ && Objects.equal(label, other.label)
+ && Objects.equal(description, other.description);
+ }
+
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected MoreObjects.ToStringHelper string() {
+ return MoreObjects.toStringHelper("").add("id", id).add("default", isDefault).add("label", label).add("description", description);
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public boolean isDefault() {
+ return isDefault;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java
new file mode 100644
index 0000000..253bc0b
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DeploymentOptionSection.java
@@ -0,0 +1,122 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * The DeploymentOptionSection specifies a discrete set of intended resource configurations. The
+ * author of an OVF package can include sizing metadata for different configurations. A consumer of
+ * the OVF shall select a configuration, for example, by prompting the user. The selected
+ * configuration is visible in the OVF environment, enabling guest software to adapt to the selected
+ * configuration.
+ */
+@XmlRootElement(name = "DeploymentOptionSection")
+@XmlType(name = "DeploymentOptionSection_Type")
+public class DeploymentOptionSection extends SectionType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromDeploymentOptionSection(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
+ private Set<Configuration> configurations = Sets.newLinkedHashSet();
+
+ /**
+ * @see DeploymentOptionSection#getConfigurations
+ */
+ public B configuration(Configuration configuration) {
+ this.configurations.add(checkNotNull(configuration, "configuration"));
+ return self();
+ }
+
+ /**
+ * @see DeploymentOptionSection#getConfigurations
+ */
+ public B configurations(Iterable<Configuration> configurations) {
+ this.configurations = ImmutableSet.<Configuration>copyOf(checkNotNull(configurations, "configurations"));
+ return self();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DeploymentOptionSection build() {
+ return new DeploymentOptionSection(this);
+ }
+
+ public B fromDeploymentOptionSection(DeploymentOptionSection in) {
+ return fromSectionType(in).configurations(in.getConfigurations());
+ }
+ }
+
+ @XmlElement(name = "Configuration")
+ protected Set<Configuration> configurations;
+
+ private DeploymentOptionSection(Builder<?> builder) {
+ super(builder);
+ this.configurations = ImmutableSet.copyOf(builder.configurations);
+ }
+
+ private DeploymentOptionSection() {
+ // For JAXB
+ }
+
+ public Set<Configuration> getConfigurations() {
+ return Collections.unmodifiableSet(configurations);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), configurations);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!super.equals(obj)) return false;
+ if (getClass() != obj.getClass()) return false;
+
+ DeploymentOptionSection other = (DeploymentOptionSection) obj;
+ return super.equals(other) && Objects.equal(configurations, other.configurations);
+ }
+
+ @Override
+ protected MoreObjects.ToStringHelper string() {
+ return super.string().add("configurations", configurations);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Disk.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Disk.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Disk.java
new file mode 100644
index 0000000..41f96ac
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Disk.java
@@ -0,0 +1,237 @@
+/*
+ * 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.dmtf.ovf;
+
+import java.net.URI;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "Disk")
+public class Disk implements Comparable<Disk>{
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private String id;
+ private Long capacity;
+ private String parentRef;
+ private String fileRef;
+ private URI format;
+ private Long populatedSize;
+ private String capacityAllocationUnits;
+
+ /**
+ * @see Disk#getId
+ */
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * @see Disk#getCapacity
+ */
+ public Builder capacity(Long capacity) {
+ this.capacity = capacity;
+ return this;
+ }
+
+ /**
+ * @see Disk#getParentRef
+ */
+ public Builder parentRef(String parentRef) {
+ this.parentRef = parentRef;
+ return this;
+ }
+
+ /**
+ * @see Disk#getFileRef
+ */
+ public Builder fileRef(String fileRef) {
+ this.fileRef = fileRef;
+ return this;
+ }
+
+ /**
+ * @see Disk#getFormat
+ */
+ public Builder format(URI format) {
+ this.format = format;
+ return this;
+ }
+
+ /**
+ * @see Disk#getPopulatedSize
+ */
+ public Builder populatedSize(Long populatedSize) {
+ this.populatedSize = populatedSize;
+ return this;
+ }
+
+ /**
+ * @see Disk#getCapacityAllocationUnits
+ */
+ public Builder capacityAllocationUnits(String capacityAllocationUnits) {
+ this.capacityAllocationUnits = capacityAllocationUnits;
+ return this;
+ }
+
+ public Disk build() {
+ return new Disk(id, capacity, parentRef, fileRef, format, populatedSize, capacityAllocationUnits);
+ }
+
+ public Builder fromDisk(Disk in) {
+ return id(in.getId()).capacity(in.getCapacity()).parentRef(in.getParentRef()).fileRef(in.getFileRef()).format(
+ in.getFormat()).populatedSize(in.getPopulatedSize()).capacityAllocationUnits(
+ in.getCapacityAllocationUnits());
+ }
+ }
+
+ private String id;
+ private Long capacity;
+ private String parentRef;
+ private String fileRef;
+ private URI format;
+ private Long populatedSize;
+ private String capacityAllocationUnits;
+
+ private Disk(String id, Long capacity, String parentRef, String fileRef, URI format, Long populatedSize,
+ String capacityAllocationUnits) {
+ this.id = id;
+ this.capacity = capacity;
+ this.parentRef = parentRef;
+ this.fileRef = fileRef;
+ this.format = format;
+ this.populatedSize = populatedSize;
+ this.capacityAllocationUnits = capacityAllocationUnits;
+ }
+
+ private Disk() {
+ // For Jaxb
+ }
+
+ /**
+ * Each virtual disk is represented by a Disk element that shall be given a identifier using the
+ * {@code id} attribute, the identifier shall be unique within the {@link DiskSection}.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * The capacity of a virtual disk shall be specified by the {@code capacity} attribute with an
+ * xs:long integer value. The default unit of allocation shall be bytes.
+ */
+ public Long getCapacity() {
+ return capacity;
+ }
+
+ /**
+ * OVF allows a disk image to be represented as a set of modified blocks in comparison to a
+ * parent image. The use of parent disks can often significantly reduce the size of an OVF
+ * package, if it contains multiple disks with similar content. For a Disk element, a parent disk
+ * may optionally be specified using the {@code parentRef} attribute, which shall contain a valid
+ * ovf:id reference to a different Disk element. If a disk block does not exist locally, lookup
+ * for that disk block then occurs in the parent disk. In {@link DiskSection}, parent Disk
+ * elements shall occur before child Disk elements that refer to them.
+ */
+ public String getParentRef() {
+ return parentRef;
+ }
+
+ /**
+ * The ovf:fileRef attribute denotes the virtual disk content by identifying an existing File
+ * element in the References element, the File element is identified by matching its {@code id}
+ * attribute value with the {@code fileRef} attribute value. Omitting the {@code fileRef}
+ * attribute shall indicate an empty disk. In this case, the disk shall be created and the entire
+ * disk content zeroed at installation time. The guest software will typically format empty disks
+ * in some file system format.
+ */
+ public String getFileRef() {
+ return fileRef;
+ }
+
+ /**
+ * The format URI of a non-empty virtual disk shall be specified by the {@code format} attribute.
+ */
+ public URI getFormat() {
+ return format;
+ }
+
+ /**
+ * For non-empty disks, the actual used size of the disk may optionally be specified using the
+ * {@code populatedSize} attribute. The unit of this attribute is always bytes. {@code
+ * populatedSize} is allowed to be an estimate of used disk size but shall not be larger than
+ * {@code capacity}.
+ */
+ public Long getPopulatedSize() {
+ return populatedSize;
+ }
+
+ /**
+ * The optional string attribute {@code ovf:capacityAllocationUnits} may be used to specify a
+ * particular unit of allocation. Values for {@code ovf:capacityAllocationUnits} shall match the
+ * format for programmatic units defined in DSP0004.
+ */
+ public String getCapacityAllocationUnits() {
+ return capacityAllocationUnits;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.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;
+ Disk other = (Disk) 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 String
+ .format(
+ "[id=%s, capacity=%s, capacityAllocationUnits=%s, fileRef=%s, format=%s, parentRef=%s, populatedSize=%s]",
+ id, capacity, capacityAllocationUnits, fileRef, format, parentRef, populatedSize);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int compareTo(Disk o) {
+ if (id == null)
+ return -1;
+ return (this == o) ? 0 : id.compareTo(o.id);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java
new file mode 100644
index 0000000..7c19370
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/DiskSection.java
@@ -0,0 +1,127 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * A DiskSection describes meta-information about virtual disks in the OVF package. Virtual disks
+ * and their metadata are described outside the virtual hardware to facilitate sharing between
+ * virtual machines within an OVF package.
+ */
+@XmlRootElement(name = "DiskSection")
+@XmlType(propOrder = {
+ "disks"
+})
+public class DiskSection extends SectionType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromDiskSection(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
+ private Set<Disk> disks = Sets.newLinkedHashSet();
+
+ /**
+ * @see DiskSection#getDisks
+ */
+ public B disk(Disk disk) {
+ this.disks.add(checkNotNull(disk, "disk"));
+ return self();
+ }
+
+ /**
+ * @see DiskSection#getDisks
+ */
+ public B disks(Iterable<Disk> disks) {
+ this.disks = ImmutableSet.<Disk>copyOf(checkNotNull(disks, "disks"));
+ return self();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DiskSection build() {
+ return new DiskSection(this);
+ }
+
+ public B fromDiskSection(DiskSection in) {
+ return disks(in.getDisks()).info(in.getInfo());
+ }
+ }
+
+ @XmlElement(name = "Disk")
+ private Set<Disk> disks;
+
+ protected DiskSection(Builder<?> builder) {
+ super(builder);
+ this.disks = ImmutableSet.<Disk>copyOf(checkNotNull(builder.disks, "disks"));
+ }
+
+ protected DiskSection() {
+ // for JAXB
+ }
+
+ /**
+ * All disks referred to from Connection elements in all {@link VirtualHardwareSection} elements
+ * shall be defined in the DiskSection.
+ *
+ * @return
+ */
+ public Set<Disk> getDisks() {
+ return disks;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), disks);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+
+ DiskSection other = (DiskSection) obj;
+ return super.equals(other) && Objects.equal(disks, other.disks);
+ }
+
+ @Override
+ protected MoreObjects.ToStringHelper string() {
+ return super.string().add("disks", disks);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Item.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Item.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Item.java
new file mode 100644
index 0000000..7c9e07f
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Item.java
@@ -0,0 +1,193 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Objects.equal;
+
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+
+/**
+ * Java class for anonymous complex type.
+ *
+ * <pre>
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <attribute name="id" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="order" use="required" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" />
+ * <attribute name="startDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
+ * <attribute name="waitingForGuest" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
+ * <attribute name="stopDelay" type="{http://www.w3.org/2001/XMLSchema}unsignedShort" default="0" />
+ * <attribute name="startAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOn" />
+ * <attribute name="stopAction" type="{http://www.w3.org/2001/XMLSchema}string" default="powerOff" />
+ * <anyAttribute processContents='lax'/>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ */
+@XmlType
+@XmlSeeAlso({
+ StartupSectionItem.class
+})
+public class Item {
+
+ // TODO Builder
+
+ @XmlAttribute(required = true)
+ protected String id;
+ @XmlAttribute(required = true)
+ @XmlSchemaType(name = "unsignedShort")
+ protected int order;
+ @XmlAttribute
+ @XmlSchemaType(name = "unsignedShort")
+ protected Integer startDelay;
+ @XmlAttribute
+ protected Boolean waitingForGuest;
+ @XmlAttribute
+ @XmlSchemaType(name = "unsignedShort")
+ protected Integer stopDelay;
+ @XmlAttribute
+ protected String startAction;
+ @XmlAttribute
+ protected String stopAction;
+ @XmlAnyAttribute
+ private Map<QName, String> otherAttributes = Maps.newHashMap();
+
+ /**
+ * Gets the value of the id property.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Gets the value of the order property.
+ */
+ public int getOrder() {
+ return order;
+ }
+
+ /**
+ * Gets the value of the startDelay property.
+ */
+ public int getStartDelay() {
+ if (startDelay == null) {
+ return 0;
+ } else {
+ return startDelay;
+ }
+ }
+
+ /**
+ * Gets the value of the waitingForGuest property.
+ */
+ public boolean isWaitingForGuest() {
+ if (waitingForGuest == null) {
+ return false;
+ } else {
+ return waitingForGuest;
+ }
+ }
+
+ /**
+ * Gets the value of the stopDelay property.
+ */
+ public int getStopDelay() {
+ if (stopDelay == null) {
+ return 0;
+ } else {
+ return stopDelay;
+ }
+ }
+
+ /**
+ * Gets the value of the startAction property.
+ */
+ public String getStartAction() {
+ if (startAction == null) {
+ return "powerOn";
+ } else {
+ return startAction;
+ }
+ }
+
+ /**
+ * Gets the value of the stopAction property.
+ */
+ public String getStopAction() {
+ if (stopAction == null) {
+ return "powerOff";
+ } else {
+ return stopAction;
+ }
+ }
+
+ /**
+ * Gets a map that contains attributes that aren't bound to any typed property on this class.
+ */
+ public Map<QName, String> getOtherAttributes() {
+ return otherAttributes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, order, startDelay, waitingForGuest, stopDelay, startAction, stopAction);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Item that = Item.class.cast(obj);
+ return equal(this.id, that.id) &&
+ equal(this.order, that.order) &&
+ equal(this.startDelay, that.startDelay) &&
+ equal(this.waitingForGuest, that.waitingForGuest) &&
+ equal(this.stopDelay, that.stopDelay) &&
+ equal(this.startAction, that.startAction) &&
+ equal(this.stopAction, that.stopAction);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper("")
+ .add("id", id)
+ .add("order", order)
+ .add("startDelay", startDelay)
+ .add("waitingForGuest", waitingForGuest)
+ .add("stopDelay", stopDelay)
+ .add("startAction", startAction)
+ .add("stopAction", stopAction)
+ .toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/MsgType.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/MsgType.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/MsgType.java
new file mode 100644
index 0000000..069d42a
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/MsgType.java
@@ -0,0 +1,142 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Objects.equal;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+
+/**
+ * Type for localizable string.
+ *
+ * Default string value
+ *
+ * <pre>
+ * <complexType name="Msg_Type" />
+ * </pre>
+ */
+@XmlType(name = "Msg_Type")
+public class MsgType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromMsgType(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public abstract static class Builder<B extends Builder<B>> {
+
+ protected String value;
+ protected String msgid;
+
+ @SuppressWarnings("unchecked")
+ protected B self() {
+ return (B) this;
+ }
+
+ /**
+ * @see MsgType#getValue()
+ */
+ public B value(String value) {
+ this.value = value;
+ return self();
+ }
+
+ /**
+ * @see MsgType#getMsgid()
+ */
+ public B msgid(String msgid) {
+ this.msgid = msgid;
+ return self();
+ }
+
+ public MsgType build() {
+ return new MsgType(this);
+ }
+
+ public B fromMsgType(MsgType in) {
+ return value(in.getValue()).msgid(in.getMsgid());
+ }
+ }
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute
+ protected String msgid;
+
+ private MsgType() {
+ // JAXB
+ }
+
+ private MsgType(Builder<?> builder) {
+ this.value = builder.value;
+ this.msgid = builder.msgid;
+ }
+
+ /**
+ * Gets the value of the value property.
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Gets the value of the msgid property.
+ */
+ public String getMsgid() {
+ if (msgid == null) {
+ return "";
+ } else {
+ return msgid;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(value, msgid);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MsgType that = MsgType.class.cast(obj);
+ return equal(this.value, that.value) &&
+ equal(this.msgid, that.msgid);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper("")
+ .add("value", value).add("msgid", msgid).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Network.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Network.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Network.java
new file mode 100644
index 0000000..0bf0a9d
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/Network.java
@@ -0,0 +1,111 @@
+/*
+ * 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.dmtf.ovf;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "Network")
+public class Network {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ protected String name;
+ protected String description;
+
+ /**
+ * @see Network#getName
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see Network#getDescription
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public Network build() {
+ return new Network(name, description);
+ }
+
+ public Builder fromNetwork(Network in) {
+ return name(in.getName()).description(in.getDescription());
+ }
+ }
+
+ private String name;
+ private String description;
+
+ protected Network(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ protected Network() {
+ // for JAXB
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.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;
+ Network other = (Network) obj;
+ 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;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "[name=" + name + ", description=" + description + "]";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java
new file mode 100644
index 0000000..e40f177
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/NetworkSection.java
@@ -0,0 +1,124 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * The NetworkSection element shall list all logical networks used in the OVF package.
+ */
+@XmlRootElement(name = "NetworkSection")
+@XmlType(name = "NetworkSection_Type")
+public class NetworkSection extends SectionType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromNetworkSection(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
+ protected Set<Network> networks = Sets.newLinkedHashSet();
+
+ /**
+ * @see NetworkSection#getNetworks
+ */
+ public B network(Network network) {
+ this.networks.add(checkNotNull(network, "network"));
+ return self();
+ }
+
+ /**
+ * @see NetworkSection#getNetworks
+ */
+ public B networks(Iterable<Network> networks) {
+ this.networks = ImmutableSet.<Network> copyOf(checkNotNull(networks, "networks"));
+ return self();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NetworkSection build() {
+ return new NetworkSection(this);
+ }
+
+ public B fromNetworkSection(NetworkSection in) {
+ return networks(in.getNetworks()).info(in.getInfo());
+ }
+ }
+
+ private Set<Network> networks;
+
+ private NetworkSection(Builder<?> builder) {
+ super(builder);
+ this.networks = ImmutableSet.copyOf(checkNotNull(networks, "networks"));
+ }
+
+ private NetworkSection() {
+ // for JAXB
+ }
+
+ /**
+ * All networks referred to from Connection elements in all {@link VirtualHardwareSection}
+ * elements shall be defined in the NetworkSection.
+ */
+ public Set<Network> getNetworks() {
+ return networks;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), networks);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ NetworkSection other = (NetworkSection) obj;
+ return super.equals(other)
+ && Objects.equal(networks, other.networks);
+ }
+
+ @Override
+ protected MoreObjects.ToStringHelper string() {
+ return super.string()
+ .add("networks", networks);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java
new file mode 100644
index 0000000..b01bed7
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/OperatingSystemSection.java
@@ -0,0 +1,156 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Objects.equal;
+import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+
+/**
+ * An OperatingSystemSection specifies the operating system installed on a virtual machine.
+ */
+public class OperatingSystemSection extends SectionType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromOperatingSystemSection(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
+
+ private int id;
+ private String description;
+ private String version;
+
+ /**
+ * @see OperatingSystemSection#getId()
+ */
+ public B id(int id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see OperatingSystemSection#getVersion()
+ */
+ public B version(String version) {
+ this.version = version;
+ return self();
+ }
+
+ /**
+ * @see OperatingSystemSection#getDescription
+ */
+ public B description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public OperatingSystemSection build() {
+ return new OperatingSystemSection(this);
+ }
+
+ public B fromOperatingSystemSection(OperatingSystemSection in) {
+ return fromSectionType(in)
+ .id(in.getId())
+ .version(in.getVersion())
+ .description(in.getDescription());
+ }
+ }
+
+ @XmlAttribute(namespace = OVF_NS, required = true)
+ protected int id;
+ @XmlAttribute(namespace = OVF_NS)
+ protected String version;
+ @XmlElement(name = "Description")
+ protected String description;
+
+ public OperatingSystemSection(Builder<?> builder) {
+ super(builder);
+ this.id = builder.id;
+ this.description = builder.description;
+ this.version = builder.version;
+ }
+
+ protected OperatingSystemSection() {
+ // For Builders and JAXB
+ }
+
+ /**
+ * Gets the OVF id
+ *
+ * @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode()
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * Gets the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Gets the description or null
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), id, version, description);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+
+ OperatingSystemSection that = (OperatingSystemSection) obj;
+ return super.equals(that)
+ && equal(this.id, that.id)
+ && equal(this.version, that.version)
+ && equal(this.description, that.description);
+ }
+
+ @Override
+ protected MoreObjects.ToStringHelper string() {
+ return super.string()
+ .add("id", id)
+ .add("version", version)
+ .add("description", description);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7ec7f077/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java
new file mode 100644
index 0000000..ac3bb26
--- /dev/null
+++ b/vcloud-director/src/main/java/org/jclouds/dmtf/ovf/ProductSection.java
@@ -0,0 +1,300 @@
+/*
+ * 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.dmtf.ovf;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.dmtf.DMTFConstants.CIM_NS;
+
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jclouds.dmtf.cim.CimString;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+/**
+ * The ProductSection element specifies product-information for an appliance, such as product name,
+ * version, and vendor.
+ */
+@XmlRootElement(name = "ProductSection")
+@XmlType(name = "ProductSection_Type")
+public class ProductSection extends SectionType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return builder().fromProductSection(this);
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ }
+
+ public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
+
+ private MsgType product;
+ private MsgType vendor;
+ private CimString version;
+ private CimString fullVersion;
+ private CimString productUrl;
+ private CimString vendorUrl;
+ private CimString appUrl;
+ protected Set<ProductSectionProperty> properties = Sets.newLinkedHashSet();
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected B self() {
+ return (B) this;
+ }
+
+ /**
+ * @see ProductSection#getProduct()
+ */
+ public B product(MsgType product) {
+ this.product = product;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getVendor()
+ */
+ public B vendor(MsgType vendor) {
+ this.vendor = vendor;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getVersion()
+ */
+ public B version(CimString version) {
+ this.version = version;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#geFullVersion()
+ */
+ public B fullVersion(CimString fullVersion) {
+ this.fullVersion = fullVersion;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getProductUrl()
+ */
+ public B productUrl(CimString productUrl) {
+ this.productUrl = productUrl;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getProductUrl()
+ */
+ public B productUrl(String productUrl) {
+ this.productUrl = new CimString(productUrl);
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getVendorUrl()
+ */
+ public B vendorUrl(CimString vendorUrl) {
+ this.vendorUrl = vendorUrl;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getAppUrl()
+ */
+ public B appUrl(CimString appUrl) {
+ this.appUrl = appUrl;
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getProperties()
+ */
+ public B property(ProductSectionProperty property) {
+ this.properties.add(checkNotNull(property, "property"));
+ return self();
+ }
+
+ /**
+ * @see ProductSection#getProperties
+ */
+ public B properties(Iterable<ProductSectionProperty> properties) {
+ this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties"));
+ return self();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ProductSection build() {
+ return new ProductSection(this);
+ }
+
+ public B fromProductSection(ProductSection in) {
+ return fromSectionType(in)
+ .product(in.getProduct())
+ .vendor(in.getVendor())
+ .version(in.getVersion())
+ .fullVersion(in.getFullVersion())
+ .productUrl(in.getProductUrl())
+ .vendorUrl(in.getVendorUrl())
+ .appUrl(in.getAppUrl())
+ .properties(Sets.newLinkedHashSet(in.getProperties()));
+ }
+ }
+
+ private ProductSection(Builder<?> builder) {
+ super(builder);
+ this.product = builder.product;
+ this.vendor = builder.vendor;
+ this.version = builder.version;
+ this.fullVersion = builder.fullVersion;
+ this.productUrl = builder.productUrl;
+ this.vendorUrl = builder.vendorUrl;
+ this.appUrl = builder.appUrl;
+ this.properties = builder.properties != null ? ImmutableSet.copyOf(checkNotNull(builder.properties, "properties")) : ImmutableSet.<ProductSectionProperty>of();
+ }
+
+ private ProductSection() {
+ // For JAXB
+ }
+
+ @XmlElement(name = "Product")
+ private MsgType product;
+ @XmlElement(name = "Vendor")
+ private MsgType vendor;
+ @XmlElement(name = "Version", namespace = CIM_NS)
+ private CimString version;
+ @XmlElement(name = "FullVersion", namespace = CIM_NS)
+ private CimString fullVersion;
+ @XmlElement(name = "ProductUrl", namespace = CIM_NS)
+ private CimString productUrl;
+ @XmlElement(name = "VendorUrl", namespace = CIM_NS)
+ private CimString vendorUrl;
+ @XmlElement(name = "AppUrl", namespace = CIM_NS)
+ private CimString appUrl;
+ @XmlElement(name = "Property")
+ private Set<ProductSectionProperty> properties = Sets.newLinkedHashSet();
+
+ /**
+ * Name of product.
+ */
+ public MsgType getProduct() {
+ return product;
+ }
+
+ /**
+ * Name of product vendor.
+ */
+ public MsgType getVendor() {
+ return vendor;
+ }
+
+ /**
+ * Product version, short form.
+ */
+ public CimString getVersion() {
+ return version;
+ }
+
+ /**
+ * Product version, long form.
+ */
+ public CimString getFullVersion() {
+ return fullVersion;
+ }
+
+ /**
+ * URL resolving to product description.
+ */
+ public CimString getProductUrl() {
+ return productUrl;
+ }
+
+ /**
+ * URL resolving to vendor description.
+ */
+ public CimString getVendorUrl() {
+ return vendorUrl;
+ }
+
+ /**
+ * Experimental: URL resolving to deployed product instance.
+ */
+ public CimString getAppUrl() {
+ return appUrl;
+ }
+
+ // TODO Set<Icon>
+
+ /**
+ * Properties for application-level customization.
+ */
+ public Set<ProductSectionProperty> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), product, vendor, version, fullVersion, productUrl, vendorUrl, appUrl, properties);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (!super.equals(obj)) return false;
+ if (getClass() != obj.getClass()) return false;
+
+ ProductSection that = ProductSection.class.cast(obj);
+ return super.equals(that) &&
+ equal(this.product, that.product) &&
+ equal(this.vendor, that.vendor) &&
+ equal(this.version, that.version) &&
+ equal(this.fullVersion, that.fullVersion) &&
+ equal(this.productUrl, that.productUrl) &&
+ equal(this.vendorUrl, that.vendorUrl) &&
+ equal(this.appUrl, that.appUrl) &&
+ equal(this.properties, that.properties);
+ }
+
+ @Override
+ protected MoreObjects.ToStringHelper string() {
+ return super.string()
+ .add("product", product)
+ .add("vendor", vendor)
+ .add("version", version)
+ .add("fullVersion", fullVersion)
+ .add("productUrl", productUrl)
+ .add("vendorUrl", vendorUrl)
+ .add("appUrl", appUrl)
+ .add("properties", properties);
+ }
+
+}