Merge pull request #490 from grkvlt/vapp-vapptemplate-vm

Issue 830: vCloud 1.5 VApp updates
This commit is contained in:
Adrian Cole 2012-03-20 10:46:57 -07:00
commit 9f741d61ea
57 changed files with 2717 additions and 2951 deletions

View File

@ -35,6 +35,10 @@ public class VCloudDirectorConstants {
public static final String VCLOUD_OVF_ENV_NS = "http://schemas.dmtf.org/ovf/environment/1";
public static final String VCLOUD_CIM_NS = "http://schemas.dmtf.org/wbem/wscim/1/common";
public static final String VCLOUD_CIM_VSSD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData";
public static final String VCLOUD_CIM_RASD_NS = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
/** The property used to configure the timeout for task completion. */
public static final String PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud-director.timeout.task-complete";

View File

@ -16,23 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* Admin representation of the container for meta data (key-value pair) associated to different
* entities in the system.
* Admin representation of the container for meta data (key-value pair) associated to different
* entities in the system.
*
*
* <p>Java class for AdminCatalog complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="AdminCatalog">
* &lt;complexContent>

View File

@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
@ -30,18 +29,11 @@ import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* The AdminOrg represents an administrative view of an organization.
* It includes all members of the Org element, and adds several
* elements that can be viewed and modified only by system administrators.
*
*
* <p>Java class for AdminOrg complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* The AdminOrg represents an administrative view of an organization.
* It includes all members of the Org element, and adds several
* elements that can be viewed and modified only by system administrators.
*
* <pre>
* &lt;complexType name="AdminOrg">
* &lt;complexContent>
@ -59,10 +51,7 @@ import com.google.common.base.Objects.ToStringHelper;
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "AdminOrg")
@XmlType(propOrder = {
"settings",

View File

@ -16,31 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* Provides an administrative view of a vDC. Includes all members
* of the Vdc element, and adds several elements that can be
* viewed and modified only by administrators.
*
*
* <p>Java class for AdminVdc complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* Provides an administrative view of a vDC. Includes all members
* of the Vdc element, and adds several elements that can be
* viewed and modified only by administrators.
*
* <pre>
* &lt;complexType name="AdminVdc">
* &lt;complexContent>
@ -59,11 +50,9 @@ import com.google.common.base.Objects.ToStringHelper;
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AdminVdc", propOrder = {
@XmlRootElement(name = "AdminVdc")
@XmlType(name = "AdminVdcType", propOrder = {
"resourceGuaranteedMemory",
"resourceGuaranteedCpu",
"vCpuInMhz",

View File

@ -19,18 +19,20 @@
package org.jclouds.vcloud.director.v1_5.domain;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
/**
* Container for references to VappTemplate and Media objects.
* <p/>
* Container for references to {@link VAppTemplate} and {@link Media} objects.
*
* <pre>
* &lt;complexType name="CatalogType" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlSeeAlso({ AdminCatalog.class })
@XmlRootElement(name = "Catalog")
public class Catalog extends CatalogType {

View File

@ -161,9 +161,6 @@ public class CustomizationSection extends SectionType {
/**
* Gets the value of the href property.
*
* @return possible object is
* {@link String }
*/
public URI getHref() {
return href;
@ -171,9 +168,6 @@ public class CustomizationSection extends SectionType {
/**
* Gets the value of the type property.
*
* @return possible object is
* {@link String }
*/
public String getType() {
return type;

View File

@ -79,7 +79,15 @@ public class NetworkConnectionSection extends SectionType {
* @see NetworkConnectionSection#getNetworkConnections()
*/
public B networkConnections(Set<NetworkConnection> networkConnections) {
this.networkConnections = checkNotNull(networkConnections, "networkConnection");
this.networkConnections = checkNotNull(networkConnections, "networkConnections");
return self();
}
/**
* @see NetworkConnectionSection#getNetworkConnections()
*/
public B networkConnection(NetworkConnection networkConnection) {
this.networkConnections.add(checkNotNull(networkConnection, "networkConnection"));
return self();
}
@ -91,6 +99,14 @@ public class NetworkConnectionSection extends SectionType {
return self();
}
/**
* @see NetworkConnectionSection#getLinks()
*/
public B link(Link link) {
this.links.add(checkNotNull(link, "link"));
return self();
}
/**
* @see NetworkConnectionSection#getHref()
*/
@ -110,20 +126,23 @@ public class NetworkConnectionSection extends SectionType {
@Override
public NetworkConnectionSection build() {
return new NetworkConnectionSection(this);
}
public B fromNetworkConnectionSection(NetworkConnectionSection in) {
return fromSectionType(in).primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex()).networkConnections(in.getNetworkConnections()).links(in.getLinks()).href(in.getHref()).type(
in.getType());
return fromSectionType(in)
.primaryNetworkConnectionIndex(in.getPrimaryNetworkConnectionIndex())
.networkConnections(Sets.newLinkedHashSet(in.getNetworkConnections()))
.links(Sets.newLinkedHashSet(in.getLinks()))
.href(in.getHref())
.type(in.getType());
}
}
private NetworkConnectionSection(Builder<?> builder) {
super(builder);
this.primaryNetworkConnectionIndex = builder.primaryNetworkConnectionIndex;
this.networkConnections = ImmutableSet.copyOf(builder.networkConnections);
this.links = ImmutableSet.copyOf(builder.links);
this.networkConnections = builder.networkConnections != null ? ImmutableSet.copyOf(builder.networkConnections) : Sets.<NetworkConnection>newLinkedHashSet();
this.links = builder.links != null ? ImmutableSet.copyOf(builder.links) : Sets.<Link>newLinkedHashSet();
this.href = builder.href;
this.type = builder.type;
}
@ -155,20 +174,16 @@ public class NetworkConnectionSection extends SectionType {
/**
* Gets the value of the networkConnection property.
* <p/>
* Objects of the following type(s) are allowed in the list {@link NetworkConnection }
*/
public Set<NetworkConnection> getNetworkConnections() {
return Collections.unmodifiableSet(this.networkConnections);
return ImmutableSet.copyOf(networkConnections);
}
/**
* Gets the value of the link property.
* <p/>
* Objects of the following type(s) are allowed in the list {@link Link }
*/
public Set<Link> getLinks() {
return Collections.unmodifiableSet(this.links);
return ImmutableSet.copyOf(links);
}
/**
@ -196,8 +211,10 @@ public class NetworkConnectionSection extends SectionType {
NetworkConnectionSection that = NetworkConnectionSection.class.cast(o);
return super.equals(that) &&
equal(primaryNetworkConnectionIndex, that.primaryNetworkConnectionIndex) &&
equal(networkConnections, that.networkConnections) && equal(links, that.links) &&
equal(href, that.href) && equal(type, that.type);
equal(networkConnections, that.networkConnections) &&
equal(links, that.links) &&
equal(href, that.href) &&
equal(type, that.type);
}
@Override

View File

@ -22,6 +22,7 @@ import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
@ -40,6 +41,7 @@ import com.google.common.base.Objects.ToStringHelper;
* @author Adrian Cole
*/
@XmlRootElement(name = "Org")
@XmlSeeAlso({ AdminOrg.class })
public class Org extends EntityType {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.ORG;

View File

@ -62,6 +62,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
return new ConcreteBuilder();
}
@Override
public Builder<?> toBuilder() {
return builder().fromProductSectionList(this);
}
@ -85,7 +86,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
/**
* @see ProductSectionList#getProductSections()
*/
public B productSections(ProductSection productSection) {
public B productSection(ProductSection productSection) {
if (productSections == null)
productSections = Sets.newLinkedHashSet();
this.productSections.add(checkNotNull(productSection, "productSection"));
@ -99,7 +100,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
public B fromProductSectionList(ProductSectionList in) {
return fromResourceType(in)
.productSections(ImmutableSet.copyOf(in));
.productSections(Sets.newLinkedHashSet(in));
}
}
@ -120,7 +121,7 @@ public class ProductSectionList extends ResourceType implements Set<ProductSecti
* Gets the value of the productSection property.
*/
public Set<ProductSection> getProductSections() {
return productSections == null ? ImmutableSet.<ProductSection>of() : Collections.unmodifiableSet(productSections);
return productSections != null ? ImmutableSet.copyOf(productSections) : Collections.<ProductSection>emptySet();
}
@Override

View File

@ -27,7 +27,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
@ -59,12 +59,12 @@ public class RasdItemsList extends ResourceType {
public static abstract class Builder<B extends Builder<B>> extends ResourceType.Builder<B> {
private List<RASD> items = Lists.newArrayList();
private List<ResourceAllocationSettingData> items = Lists.newArrayList();
/**
* @see RasdItemsList#getItems()
*/
public B items(List<RASD> items) {
public B items(List<ResourceAllocationSettingData> items) {
this.items = checkNotNull(items, "items");
return self();
}
@ -72,7 +72,7 @@ public class RasdItemsList extends ResourceType {
/**
* @see RasdItemsList#getItems()
*/
public B item(RASD item) {
public B item(ResourceAllocationSettingData item) {
this.items.add(checkNotNull(item, "item"));
return self();
}
@ -98,12 +98,12 @@ public class RasdItemsList extends ResourceType {
}
@XmlElement(name = "Item")
protected List<RASD> items = Lists.newArrayList();
protected List<ResourceAllocationSettingData> items = Lists.newArrayList();
/**
* A RASD item content.
*/
public List<RASD> getItems() {
public List<ResourceAllocationSettingData> getItems() {
return items;
}

View File

@ -24,6 +24,7 @@ import java.net.URI;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
@ -44,8 +45,10 @@ import com.google.common.base.Objects.ToStringHelper;
* @author grkvlt@apache.org
*/
@XmlSeeAlso({
VAppReference.class,
CatalogReference.class
})
@XmlRootElement(name = "Reference")
@XmlType(name = "ReferenceType")
public class Reference {

View File

@ -116,7 +116,7 @@ public class ResourceType {
}
protected B fromResourceType(ResourceType in) {
return href(in.getHref()).type(in.getType()).links(in.getLinks());
return href(in.getHref()).type(in.getType()).links(Sets.newLinkedHashSet(in.getLinks()));
}
}

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
@ -37,6 +38,7 @@ import com.google.common.base.Objects.ToStringHelper;
*/
@XmlRootElement(name = "Vdc")
@XmlType(name = "VdcType")
@XmlSeeAlso({ AdminVdc.class })
public class Vdc extends EntityType {
public static Builder<?> builder() {

View File

@ -18,50 +18,79 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import static com.google.common.base.Objects.equal;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.namespace.QName;
import com.google.common.base.Objects;
/**
* Java class for cimString complex type.
*
*
* <pre>
* &lt;complexType name="cimString" /&gt;
* </pre>
*/
@XmlType(name = "cimString", namespace = "http://schemas.dmtf.org/wbem/wscim/1/common")
@XmlType(name = "cimString")
public class CimString {
@XmlValue
protected String value;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
public CimString() {
// JAXB
}
/**
* Gets the value of the value property.
*/
public String getValue() {
return value;
}
public CimString(String value) {
this.value = value;
}
/**
* Sets the value of the value property.
*/
public void setValue(String value) {
this.value = value;
}
@XmlValue
protected String value;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
/**
* Gets a map that contains attributes that aren't bound to any typed property on this class.
*/
public Map<QName, String> getOtherAttributes() {
return otherAttributes;
}
/**
* Gets the value of the value property.
*/
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
/**
* 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(value);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CimString that = CimString.class.cast(obj);
return equal(this.value, that.value);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("value", value).toString();
}
}

View File

@ -1,128 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.cim;
/**
*
* ManagedElement is an abstract class that provides a common superclass (or top of the inheritance
* tree) for the non-association classes in the CIM Schema.
*
* @author Adrian Cole
* @see <a
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
* />
*
*/
public abstract class ManagedElement extends SettingData {
public static Builder builder() {
return new Builder();
}
/**
* {@inheritDoc}
*/
@Override
public Builder toBuilder() {
return builder().fromManagedElement(this);
}
public static class Builder extends SettingData.Builder {
protected String caption;
protected String description;
/**
* @see ManagedElement#getCaption
*/
public Builder caption(String caption) {
this.caption = caption;
return this;
}
/**
* @see ManagedElement#getDescription
*/
public Builder description(String description) {
this.description = description;
return this;
}
public Builder fromManagedElement(ManagedElement in) {
return caption(in.getCaption()).description(in.getDescription()).fromSettingData(in);
}
/**
* {@inheritDoc}
*/
@Override
public Builder fromSettingData(SettingData in) {
return Builder.class.cast(super.fromSettingData(in));
}
/**
* {@inheritDoc}
*/
@Override
public Builder elementName(String elementName) {
return Builder.class.cast(super.elementName(elementName));
}
/**
* {@inheritDoc}
*/
@Override
public Builder instanceID(String instanceID) {
return Builder.class.cast(super.instanceID(instanceID));
}
}
protected String caption;
protected String description;
protected ManagedElement(String elementName, String instanceID, String caption, String description) {
super(elementName, instanceID);
this.caption = caption;
this.description = description;
}
protected ManagedElement() {
// for JAXB
}
/**
* 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;
}
@Override
public String toString() {
return String.format("[elementName=%s, instanceID=%s, caption=%s, description=%s]", elementName, instanceID,
caption, description);
}
}

View File

@ -29,179 +29,138 @@ import org.jclouds.compute.domain.OsFamily;
* />
*/
public enum OSType {
/**
* Other
*/
/** Other */
OTHER(1, "Other", OsFamily.UNRECOGNIZED, false),
/**
* MACOS
*/
/** MACOS */
MACOS(2, "MACOS", OsFamily.DARWIN, false),
/**
* Solaris
*/
/** Solaris */
SOLARIS(29, "Solaris", OsFamily.SOLARIS, false),
/**
* LINUX
*/
/** LINUX */
LINUX(36, "LINUX", OsFamily.LINUX, false),
/**
* FreeBSD
*/
/** FreeBSD */
FREEBSD(42, "FreeBSD", OsFamily.FREEBSD, false),
/**
* NetBSD
*/
/** NetBSD */
NETBSD(43, "NetBSD", OsFamily.NETBSD, false),
/**
* OpenBSD
*/
/** OpenBSD */
OPENBSD(65, "OpenBSD", OsFamily.OPENBSD, false),
/**
* Not Applicable
*/
/** Not Applicable */
NOT_APPLICABLE(66, "Not Applicable", OsFamily.UNRECOGNIZED, false),
/**
* Microsoft Windows Server 2003
*/
/** Microsoft Windows Server 2003 */
WINDOWS_SERVER_2003(69, "Microsoft Windows Server 2003", OsFamily.WINDOWS, false),
/**
* Microsoft Windows Server 2003 64-Bit
*/
/** Microsoft Windows Server 2003 64-Bit */
WINDOWS_SERVER_2003_64(70, "Microsoft Windows Server 2003 64-Bit", OsFamily.WINDOWS, true),
/**
* Microsoft Windows Server 2008
*/
/** Microsoft Windows Server 2008 */
WINDOWS_SERVER_2008(76, "Microsoft Windows Server 2008", OsFamily.WINDOWS, false),
/**
* Microsoft Windows Server 2008 64-Bit
*/
/** Microsoft Windows Server 2008 64-Bit */
WINDOWS_SERVER_2008_64(77, "Microsoft Windows Server 2008 64-Bit", OsFamily.WINDOWS, true),
/**
* FreeBSD 64-Bit
*/
/** FreeBSD 64-Bit */
FREEBSD_64(78, "FreeBSD 64-Bit", OsFamily.FREEBSD, true),
/**
* RedHat Enterprise Linux
*/
/** RedHat Enterprise Linux */
RHEL(79, "RedHat Enterprise Linux", OsFamily.RHEL, false),
/**
* RedHat Enterprise Linux 64-Bit
*/
/** RedHat Enterprise Linux 64-Bit */
RHEL_64(80, "RedHat Enterprise Linux 64-Bit", OsFamily.RHEL, true),
/**
* Solaris 64-Bit
*/
/** Solaris 64-Bit */
SOLARIS_64(81, "Solaris 64-Bit", OsFamily.SOLARIS, true),
/**
* SUSE
*/
/** SUSE */
SUSE(82, "SUSE", OsFamily.SUSE, false),
/**
* SUSE 64-Bit
*/
/** SUSE 64-Bit */
SUSE_64(83, "SUSE 64-Bit", OsFamily.SUSE, true),
/**
* SLES
*/
/** SLES */
SLES(84, "SLES", OsFamily.SUSE, false),
/**
* SLES 64-Bit
*/
/** SLES 64-Bit */
SLES_64(85, "SLES 64-Bit", OsFamily.SUSE, true),
/**
* Novell OES
*/
/** Novell OES */
NOVELL_OES(86, "Novell OES", OsFamily.SUSE, true),
/**
* Mandriva
*/
/** Mandriva */
MANDRIVA(89, "Mandriva", OsFamily.MANDRIVA, false),
/**
* Mandriva 64-Bit
*/
/** Mandriva 64-Bit */
MANDRIVA_64(90, "Mandriva 64-Bit", OsFamily.MANDRIVA, true),
/**
* TurboLinux
*/
/** TurboLinux */
TURBOLINUX(91, "TurboLinux", OsFamily.TURBOLINUX, false),
/**
* TurboLinux 64-Bit
*/
/** TurboLinux 64-Bit */
TURBOLINUX_64(92, "TurboLinux 64-Bit", OsFamily.TURBOLINUX, true),
/**
* Ubuntu
*/
/** Ubuntu */
UBUNTU(93, "Ubuntu", OsFamily.UBUNTU, false),
/**
* Ubuntu 64-Bit
*/
/** Ubuntu 64-Bit */
UBUNTU_64(94, "Ubuntu 64-Bit", OsFamily.UBUNTU, true),
/**
* Debian
*/
/** Debian */
DEBIAN(95, "Debian", OsFamily.DEBIAN, false),
/**
* Debian 64-Bit
*/
/** Debian 64-Bit */
DEBIAN_64(96, "Debian 64-Bit", OsFamily.DEBIAN, false),
/**
* Linux 2.4.x
*/
/** Linux 2.4.x */
LINUX_2_4(97, "Linux 2.4.x", OsFamily.LINUX, false),
/**
* Linux 2.4.x 64-Bi
*/
/** Linux 2.4.x 64-Bi */
LINUX_2_4_64(98, "Linux 2.4.x 64-Bit", OsFamily.LINUX, true),
/**
* Linux 2.6.x
*/
/** Linux 2.6.x */
LINUX_2_6(99, "Linux 2.6.x", OsFamily.LINUX, false),
/**
* Linux 2.6.x 64-Bit
*/
/** Linux 2.6.x 64-Bit */
LINUX_2_6_64(100, "Linux 2.6.x 64-Bit", OsFamily.LINUX, true),
/**
* Linux 64-Bit
*/
/** Linux 64-Bit */
LINUX_64(101, "Linux 64-Bit", OsFamily.LINUX, true),
/**
* Other 64-Bit
*/
/** Other 64-Bit */
OTHER_64(102, "Other 64-Bit", OsFamily.UNRECOGNIZED, true),
/**
* Microsoft Windows Server 2008 R2
*/
/** Microsoft Windows Server 2008 R2 */
WINDOWS_SERVER_2008_R2(103, "Microsoft Windows Server 2008 R2", OsFamily.WINDOWS, true),
/**
* VMware ESXi
*/
/** VMware ESXi */
ESXI(104, "VMware ESXi", OsFamily.ESX, true),
/**
* Microsoft Windows 7
*/
/** Microsoft Windows 7 */
WINDOWS_7(105, "Microsoft Windows 7", OsFamily.WINDOWS, false),
/**
* CentOS 32-bit
*/
/** CentOS 32-bit */
CENTOS(106, "CentOS 32-bit", OsFamily.CENTOS, false),
/**
* CentOS 64-bit
*/
/** CentOS 64-bit */
CENTOS_64(107, "CentOS 64-bit", OsFamily.CENTOS, true),
/**
* Oracle Enterprise Linux 32-bit
*/
/** Oracle Enterprise Linux 32-bit */
ORACLE_ENTERPRISE_LINUX(108, "Oracle Enterprise Linux 32-bit", OsFamily.OEL, false),
/**
* Oracle Enterprise Linux 64-bit
*/
/** Oracle Enterprise Linux 64-bit */
ORACLE_ENTERPRISE_LINUX_64(109, "Oracle Enterprise Linux 64-bit", OsFamily.OEL, true),
/**
* eComStation 32-bitx
*/
ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false), UNRECOGNIZED(Integer.MAX_VALUE,
"UNRECOGNIZED", null, true);
/** eComStation 32-bitx */
ECOMSTATION_32(109, "eComStation 32-bitx", OsFamily.UNRECOGNIZED, false),
UNRECOGNIZED(Integer.MAX_VALUE, "UNRECOGNIZED", null, true);
private final int code;
public int getCode() {

View File

@ -18,70 +18,150 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_RASD_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import java.math.BigInteger;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
*
* The ResourceAllocationSettingData class represents settings specifically
* related to an allocated resource that are outside the scope of the CIM class
* typically used to represent the resource itself. These settings include
* information specific to the allocation that may not be visible to the
* consumer of the resource itself. For example, a virtual processor may look
* like a 2 ghz processor to the consumer (virtual computer system), however the
* virtualization system may use time-slicing to schedule the the virtual
* processor to only allow it to use 1 ghz.
* typically used to represent the resource itself.
*
* These settings include information specific to the allocation that may not
* be visible to the consumer of the resource itself. For example, a virtual
* processor may look like a 2 GHz processor to the consumer (virtual computer
* system), however the virtualization system may use time-slicing to schedule
* the the virtual processor to only allow it to use 1 GHz.
*
* @author Adrian Cole
* @see <a href=
* "http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
* />
*
* @author grkvlt@apache.org
* @see http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd
*/
public class ResourceAllocationSettingData extends ManagedElement {
@XmlRootElement(name = "Item", namespace = VCLOUD_1_5_NS)
@XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = VCLOUD_OVF_NS,
propOrder = {
"address",
"addressOnParent",
"allocationUnits",
"automaticAllocation",
"automaticDeallocation",
"caption",
"connections",
"consumerVisibility",
"description",
"elementName",
"hostResources",
"instanceID",
"limit",
"mappingBehavior",
"otherResourceType",
"parent",
"poolID",
"reservation",
"resourceSubType",
"resourceType",
"virtualQuantity",
"virtualQuantityUnits",
"weight",
"links"
}
)
public class ResourceAllocationSettingData {
public static Builder builder() {
return new Builder();
}
/**
* {@inheritDoc}
*/
@Override
public Builder toBuilder() {
return builder().fromResourceAllocationSettingData(this);
}
public static class Builder extends ManagedElement.Builder {
public static class Builder {
protected String address;
protected String addressOnParent;
protected String allocationUnits;
protected Boolean automaticAllocation;
protected Boolean automaticDeallocation;
protected ConsumerVisibility consumerVisibility;
protected Long limit;
protected MappingBehavior mappingBehavior;
protected String otherResourceType;
protected String parent;
protected String poolID;
protected Long reservation;
protected String resourceSubType;
protected ResourceType resourceType;
protected Long virtualQuantity;
protected String virtualQuantityUnits;
protected Integer weight;
protected List<String> connections = Lists.newArrayList();
protected List<String> hostResources = Lists.newArrayList();
private String elementName;
private String instanceID;
private String caption;
private String description;
private String address;
private String addressOnParent;
private String allocationUnits;
private Boolean automaticAllocation;
private Boolean automaticDeallocation;
private ConsumerVisibility consumerVisibility;
private BigInteger limit;
private MappingBehavior mappingBehavior;
private String otherResourceType;
private String parent;
private String poolID;
private BigInteger reservation;
private String resourceSubType;
private ResourceType resourceType;
private BigInteger virtualQuantity;
private String virtualQuantityUnits;
private Long weight;
private List<CimString> connections = Lists.newArrayList();
private List<CimString> hostResources = Lists.newArrayList();
private URI href;
private String type;
private Set<Link> links = Sets.newLinkedHashSet();
/**
* @see ResourceAllocationSettingData#getElementName()
*/
public Builder elementName(String elementName) {
this.elementName = elementName;
return this;
}
/**
*@see ResourceAllocationSettingData#getInstanceId()
*/
public Builder instanceID(String instanceID) {
this.instanceID = instanceID;
return this;
}
/**
* @see ResourceAllocationSettingData#getCaption()
*/
public Builder caption(String caption) {
this.caption = caption;
return this;
}
/**
* @see ResourceAllocationSettingData#getDescription()
*/
public Builder description(String description) {
this.description = description;
return this;
}
/**
* @see ResourceAllocationSettingData#getAddress
@ -134,7 +214,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getLimit
*/
public Builder limit(Long limit) {
public Builder limit(BigInteger limit) {
this.limit = limit;
return this;
}
@ -174,7 +254,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getReservation
*/
public Builder reservation(Long reservation) {
public Builder reservation(BigInteger reservation) {
this.reservation = reservation;
return this;
}
@ -198,7 +278,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getVirtualQuantity
*/
public Builder virtualQuantity(Long virtualQuantity) {
public Builder virtualQuantity(BigInteger virtualQuantity) {
this.virtualQuantity = virtualQuantity;
return this;
}
@ -214,7 +294,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getWeight
*/
public Builder weight(Integer weight) {
public Builder weight(Long weight) {
this.weight = weight;
return this;
}
@ -222,108 +302,147 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getConnections()
*/
public Builder connection(String connection) {
public Builder connection(CimString connection) {
this.connections.add(checkNotNull(connection, "connection"));
return this;
}
/**
* @see ResourceAllocationSettingData#getHostResources()
*/
public Builder hostResource(String hostResource) {
this.hostResources.add(checkNotNull(hostResource, "hostResource"));
return this;
}
/**
* @see ResourceAllocationSettingData#getConnections
*/
public Builder connections(List<String> connections) {
public Builder connections(List<CimString> connections) {
this.connections = Lists.newArrayList(checkNotNull(connections, "connections"));
return this;
}
/**
* @see ResourceAllocationSettingData#getHostResources()
*/
public Builder hostResource(CimString hostResource) {
this.hostResources.add(checkNotNull(hostResource, "hostResource"));
return this;
}
/**
* @see ResourceAllocationSettingData#getHostResources
*/
public Builder hostResources(List<String> hostResources) {
public Builder hostResources(List<CimString> hostResources) {
this.hostResources = Lists.newArrayList(checkNotNull(hostResources, "hostResources"));
return this;
}
/**
* @see ResourceAllocationSettingData#getType()
*/
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ResourceAllocationSettingData#getHref()
*/
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ResourceAllocationSettingData#getLinks()
*/
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ResourceAllocationSettingData#getLinks()
*/
public Builder link(Link link) {
if (links == null)
links = Sets.newLinkedHashSet();
this.links.add(checkNotNull(link, "link"));
return this;
}
public ResourceAllocationSettingData build() {
return new ResourceAllocationSettingData(elementName, instanceID, caption, description, address,
addressOnParent, allocationUnits, automaticAllocation, automaticDeallocation, consumerVisibility, limit,
mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
virtualQuantity, virtualQuantityUnits, weight, connections, hostResources);
virtualQuantity, virtualQuantityUnits, weight, connections, hostResources, type, href, links);
}
public Builder fromResourceAllocationSettingData(ResourceAllocationSettingData in) {
return fromManagedElement(in).address(in.getAddress()).addressOnParent(in.getAddressOnParent())
.allocationUnits(in.getAllocationUnits()).automaticAllocation(in.isAutomaticAllocation())
.automaticDeallocation(in.isAutomaticDeallocation()).consumerVisibility(in.getConsumerVisibility())
.limit(in.getLimit()).mappingBehavior(in.getMappingBehavior())
.otherResourceType(in.getOtherResourceType()).parent(in.getParent()).poolID(in.getPoolID())
.reservation(in.getReservation()).resourceSubType(in.getResourceSubType())
.resourceType(in.getResourceType()).virtualQuantity(in.getVirtualQuantity())
.virtualQuantityUnits(in.getVirtualQuantityUnits()).weight(in.getWeight())
.connections(in.getConnections()).hostResources(in.getHostResources());
return elementName(in.getElementName())
.instanceID(in.getInstanceID())
.caption(in.getCaption())
.description(in.getDescription())
.address(in.getAddress())
.addressOnParent(in.getAddressOnParent())
.allocationUnits(in.getAllocationUnits())
.automaticAllocation(in.isAutomaticAllocation())
.automaticDeallocation(in.isAutomaticDeallocation())
.consumerVisibility(in.getConsumerVisibility())
.limit(in.getLimit())
.mappingBehavior(in.getMappingBehavior())
.otherResourceType(in.getOtherResourceType())
.parent(in.getParent())
.poolID(in.getPoolID())
.reservation(in.getReservation())
.resourceSubType(in.getResourceSubType())
.resourceType(in.getResourceType())
.virtualQuantity(in.getVirtualQuantity())
.virtualQuantityUnits(in.getVirtualQuantityUnits())
.weight(in.getWeight())
.connections(in.getConnections())
.hostResources(in.getHostResources())
.type(in.getType())
.href(in.getHref())
.links(Sets.newLinkedHashSet(in.getLinks()));
}
/**
* {@inheritDoc}
*/
@Override
public Builder fromManagedElement(ManagedElement in) {
return Builder.class.cast(super.fromManagedElement(in));
}
/**
* {@inheritDoc}
*/
@Override
public Builder caption(String caption) {
return Builder.class.cast(super.caption(caption));
}
/**
* {@inheritDoc}
*/
@Override
public Builder description(String description) {
return Builder.class.cast(super.description(description));
}
/**
* {@inheritDoc}
*/
@Override
public Builder elementName(String elementName) {
return Builder.class.cast(super.elementName(elementName));
}
/**
* {@inheritDoc}
*/
@Override
public Builder instanceID(String instanceID) {
return Builder.class.cast(super.instanceID(instanceID));
}
}
/**
* The type of resource this allocation setting represents.
*/
@XmlType
@XmlEnum(Integer.class)
public static enum ResourceType {
OTHER(1), COMPUTER_SYSTEM(2), PROCESSOR(3), MEMORY(4), IDE_CONTROLLER(5), PARALLEL_SCSI_HBA(6), FC_HBA(7), ISCSI_HBA(
8), IB_HCA(9), ETHERNET_ADAPTER(10), OTHER_NETWORK_ADAPTER(11), IO_SLOT(12), IO_DEVICE(13), FLOPPY_DRIVE(14), CD_DRIVE(
15), DVD_DRIVE(16), DISK_DRIVE(17), TAPE_DRIVE(18), STORAGE_EXTENT(19), OTHER_STORAGE_DEVICE(20), SERIAL_PORT(
21), PARALLEL_PORT(22), USB_CONTROLLER(23), GRAPHICS_CONTROLLER(24), IEEE_1394_CONTROLLER(25), PARTITIONABLE_UNIT(
26), BASE_PARTITIONABLE_UNIT(27), POWER(28), COOLING_CAPACITY(29), ETHERNET_SWITCH_PORT(30), LOGICAL_DISK(
31), STORAGE_VOLUME(32), ETHERNET_CONNECTION(33), DMTF_RESERVED(Integer.valueOf("8000", 16)), VENDOR_RESERVED(
Integer.valueOf("FFFF", 16));
@XmlEnumValue("1") OTHER(1),
@XmlEnumValue("2") COMPUTER_SYSTEM(2),
@XmlEnumValue("3") PROCESSOR(3),
@XmlEnumValue("4") MEMORY(4),
@XmlEnumValue("5") IDE_CONTROLLER(5),
@XmlEnumValue("6") PARALLEL_SCSI_HBA(6),
@XmlEnumValue("7") FC_HBA(7),
@XmlEnumValue("8") ISCSI_HBA(8),
@XmlEnumValue("9") IB_HCA(9),
@XmlEnumValue("10") ETHERNET_ADAPTER(10),
@XmlEnumValue("11") OTHER_NETWORK_ADAPTER(11),
@XmlEnumValue("12") IO_SLOT(12),
@XmlEnumValue("13") IO_DEVICE(13),
@XmlEnumValue("14") FLOPPY_DRIVE(14),
@XmlEnumValue("15") CD_DRIVE(15),
@XmlEnumValue("16") DVD_DRIVE(16),
@XmlEnumValue("17") DISK_DRIVE(17),
@XmlEnumValue("18") TAPE_DRIVE(18),
@XmlEnumValue("19") STORAGE_EXTENT(19),
@XmlEnumValue("20") OTHER_STORAGE_DEVICE(20),
@XmlEnumValue("21") SERIAL_PORT(21),
@XmlEnumValue("22") PARALLEL_PORT(22),
@XmlEnumValue("23") USB_CONTROLLER(23),
@XmlEnumValue("24") GRAPHICS_CONTROLLER(24),
@XmlEnumValue("25") IEEE_1394_CONTROLLER(25),
@XmlEnumValue("26") PARTITIONABLE_UNIT(26),
@XmlEnumValue("27") BASE_PARTITIONABLE_UNIT(27),
@XmlEnumValue("28") POWER(28),
@XmlEnumValue("29") COOLING_CAPACITY(29),
@XmlEnumValue("30") ETHERNET_SWITCH_PORT(30),
@XmlEnumValue("31") LOGICAL_DISK(31),
@XmlEnumValue("32") STORAGE_VOLUME(32),
@XmlEnumValue("33") ETHERNET_CONNECTION(33),
@XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)),
@XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16));
protected final int code;
@ -332,47 +451,52 @@ public class ResourceAllocationSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static Map<Integer, ResourceType> RESOURCE_TYPE_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(ResourceType.values()), new Function<ResourceType, Integer>() {
@Override
public Integer apply(ResourceType input) {
return input.code;
}
});
public static ResourceType fromValue(String type) {
return RESOURCE_TYPE_BY_ID.get(new Integer(checkNotNull(type, "type")));
return RESOURCE_TYPE_BY_ID.get(Integer.valueOf(checkNotNull(type, "type")));
}
}
/**
* Describes the consumers visibility to the allocated resource.
*/
@XmlType
@XmlEnum(Integer.class)
public static enum ConsumerVisibility {
UNKNOWN(0),
@XmlEnumValue("0") UNKNOWN(0),
/**
* indicates the underlying or host resource is utilized and passed
* through to the consumer, possibly using partitioning. At least one item
* shall be present in the HostResource property.
*/
PASSED_THROUGH(2),
@XmlEnumValue("2") PASSED_THROUGH(2),
/**
* indicates the resource is virtualized and may not map directly to an
* underlying/host resource. Some implementations may support specific
* assignment for virtualized resources, in which case the host
* resource(s) are exposed using the HostResource property.
*/
VIRTUALIZED(3),
@XmlEnumValue("3") VIRTUALIZED(3),
/**
* indicates a representation of the resource does not exist within the
* context of the resource consumer.
*/
NOT_REPRESENTED(4), DMTF_RESERVED(32767), VENDOR_RESERVED(65535);
@XmlEnumValue("4") NOT_REPRESENTED(4),
@XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)),
@XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16));
protected final int code;
@ -381,21 +505,19 @@ public class ResourceAllocationSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static Map<Integer, ConsumerVisibility> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(ConsumerVisibility.values()), new Function<ConsumerVisibility, Integer>() {
@Override
public Integer apply(ConsumerVisibility input) {
return input.code;
}
});
public static ConsumerVisibility fromValue(String behavior) {
return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior")));
return MAPPING_BEHAVIOR_BY_ID.get(Integer.valueOf(checkNotNull(behavior, "behavior")));
}
}
@ -404,9 +526,16 @@ public class ResourceAllocationSettingData extends ManagedElement {
* HostResource array contains any entries, this property reflects how the
* resource maps to those specific resources.
*/
@XmlType
@XmlEnum(Integer.class)
public static enum MappingBehavior {
UNKNOWN(0), NOT_SUPPORTED(2), DEDICATED(3), SOFT_AFFINITY(4), HARD_AFFINITY(5), DMTF_RESERVED(32767), VENDOR_RESERVED(
65535);
@XmlEnumValue("0") UNKNOWN(0),
@XmlEnumValue("2") NOT_SUPPORTED(2),
@XmlEnumValue("3") DEDICATED(3),
@XmlEnumValue("4") SOFT_AFFINITY(4),
@XmlEnumValue("5") HARD_AFFINITY(5),
@XmlEnumValue("32768") DMTF_RESERVED(Integer.valueOf("8000", 16)),
@XmlEnumValue("65535") VENDOR_RESERVED(Integer.valueOf("FFFF", 16));
protected final int code;
@ -415,51 +544,87 @@ public class ResourceAllocationSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static Map<Integer, MappingBehavior> MAPPING_BEHAVIOR_BY_ID = Maps.uniqueIndex(
ImmutableSet.copyOf(MappingBehavior.values()), new Function<MappingBehavior, Integer>() {
@Override
public Integer apply(MappingBehavior input) {
return input.code;
}
});
public static MappingBehavior fromValue(String behavior) {
return MAPPING_BEHAVIOR_BY_ID.get(new Integer(checkNotNull(behavior, "behavior")));
return MAPPING_BEHAVIOR_BY_ID.get(Integer.valueOf(checkNotNull(behavior, "behavior")));
}
}
// <rasd:Elementname>foo</rasd:ElementName>
protected String address;
protected String addressOnParent;
protected String allocationUnits;
protected Boolean automaticAllocation;
protected Boolean automaticDeallocation;
protected ConsumerVisibility consumerVisibility;
protected Long limit;
protected MappingBehavior mappingBehavior;
protected String otherResourceType;
protected String parent;
protected String poolID;
protected Long reservation;
protected String resourceSubType;
protected ResourceType resourceType;
protected Long virtualQuantity;
protected String virtualQuantityUnits;
protected Integer weight;
protected List<String> connections;
protected List<String> hostResources;
@XmlElement(name = "ElementName", namespace = VCLOUD_CIM_RASD_NS)
private String elementName;
@XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_RASD_NS)
private String instanceID;
@XmlElement(name = "Caption", namespace = VCLOUD_CIM_RASD_NS)
private String caption;
@XmlElement(name = "Description", namespace = VCLOUD_CIM_RASD_NS)
private String description;
@XmlElement(name = "Address", namespace = VCLOUD_CIM_RASD_NS)
private String address;
@XmlElement(name = "AddressOnParent", namespace = VCLOUD_CIM_RASD_NS)
private String addressOnParent;
@XmlElement(name = "AllocationUnits", namespace = VCLOUD_CIM_RASD_NS)
private String allocationUnits;
@XmlElement(name = "AutomaticAllocation", namespace = VCLOUD_CIM_RASD_NS)
private Boolean automaticAllocation;
@XmlElement(name = "AutomaticDeallocation", namespace = VCLOUD_CIM_RASD_NS)
private Boolean automaticDeallocation;
@XmlElement(name = "ConsumerVisibility", namespace = VCLOUD_CIM_RASD_NS)
private ConsumerVisibility consumerVisibility;
@XmlElement(name = "Limit", namespace = VCLOUD_CIM_RASD_NS)
private BigInteger limit;
@XmlElement(name = "MappingBehavior", namespace = VCLOUD_CIM_RASD_NS)
private MappingBehavior mappingBehavior;
@XmlElement(name = "OtherResourceType", namespace = VCLOUD_CIM_RASD_NS)
private String otherResourceType;
@XmlElement(name = "Parent", namespace = VCLOUD_CIM_RASD_NS)
private String parent;
@XmlElement(name = "PoolID", namespace = VCLOUD_CIM_RASD_NS)
private String poolID;
@XmlElement(name = "Reservation", namespace = VCLOUD_CIM_RASD_NS)
private BigInteger reservation;
@XmlElement(name = "ResourceSubType", namespace = VCLOUD_CIM_RASD_NS)
private String resourceSubType;
@XmlElement(name = "ResourceType", namespace = VCLOUD_CIM_RASD_NS)
private ResourceType resourceType;
@XmlElement(name = "VirtualQuantity", namespace = VCLOUD_CIM_RASD_NS)
private BigInteger virtualQuantity;
@XmlElement(name = "VirtualQuantityUnits", namespace = VCLOUD_CIM_RASD_NS)
private String virtualQuantityUnits;
@XmlElement(name = "Weight", namespace = VCLOUD_CIM_RASD_NS)
private Long weight;
@XmlElement(name = "Connection", namespace = VCLOUD_CIM_RASD_NS)
private List<CimString> connections = Lists.newArrayList();
@XmlElement(name = "HostResource", namespace = VCLOUD_CIM_RASD_NS)
private List<CimString> hostResources = Lists.newArrayList();
@XmlAttribute(name = "type", namespace = VCLOUD_1_5_NS)
private String type;
@XmlAttribute(name = "href", namespace = VCLOUD_1_5_NS)
private URI href;
@XmlElement(name = "Link", namespace = VCLOUD_1_5_NS)
private Set<Link> links = Sets.newLinkedHashSet();
private ResourceAllocationSettingData(String elementName, String instanceID, String caption, String description,
String address, String addressOnParent, String allocationUnits, Boolean automaticAllocation,
Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, Long limit,
MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, Long reservation,
String resourceSubType, ResourceType resourceType, Long virtualQuantity, String virtualQuantityUnits,
Integer weight, List<String> connections, List<String> hostResources) {
super(elementName, instanceID, caption, description);
Boolean automaticDeallocation, ConsumerVisibility consumerVisibility, BigInteger limit,
MappingBehavior mappingBehavior, String otherResourceType, String parent, String poolID, BigInteger reservation,
String resourceSubType, ResourceType resourceType, BigInteger virtualQuantity, String virtualQuantityUnits,
Long weight, List<CimString> connections, List<CimString> hostResources, String type, URI href, Set<Link> links) {
this.elementName = elementName;
this.instanceID = instanceID;
this.caption = caption;
this.description = description;
this.address = address;
this.addressOnParent = addressOnParent;
this.allocationUnits = allocationUnits;
@ -479,11 +644,45 @@ public class ResourceAllocationSettingData extends ManagedElement {
this.weight = weight;
this.connections = ImmutableList.copyOf(connections);
this.hostResources = ImmutableList.copyOf(hostResources);
this.type = type;
this.href = href;
this.links = links != null ? ImmutableSet.copyOf(links) : Collections.<Link>emptySet();
}
private ResourceAllocationSettingData() {
// 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;
}
/**
* The address of the resource. For example, the MAC address of a Ethernet
@ -557,7 +756,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* for this allocation. The value of the Limit property is expressed in the
* unit specified by the value of the AllocationUnits property.
*/
public Long getLimit() {
public BigInteger getLimit() {
return limit;
}
@ -603,7 +802,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* the Reservation property is expressed in the unit specified by the value
* of the AllocationUnits property.
*/
public Long getReservation() {
public BigInteger getReservation() {
return reservation;
}
@ -631,7 +830,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* VirtualQuantity property should be expressed in units as defined by the
* value of the VirtualQuantityUnits property.
*/
public Long getVirtualQuantity() {
public BigInteger getVirtualQuantity() {
return virtualQuantity;
}
@ -657,7 +856,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* has no unit of measure, and is only relevant when compared to other
* allocations vying for the same host resources.
*/
public Integer getWeight() {
public Long getWeight() {
return weight;
}
@ -665,7 +864,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* The thing to which this resource is connected. For example, a named
* network or switch port.
*/
public List<String> getConnections() {
public List<CimString> getConnections() {
return Collections.unmodifiableList(connections);
}
@ -687,62 +886,102 @@ public class ResourceAllocationSettingData extends ManagedElement {
* value(s) to indicate that the requested virtual resource allocation be
* based on host resources that are identified by element values.
*/
public List<String> getHostResources() {
public List<CimString> getHostResources() {
return Collections.unmodifiableList(hostResources);
}
public String getType() {
return type;
}
public URI getHref() {
return href;
}
/**
* Set of optional links to an entity or operation associated with this object.
*/
public Set<Link> getLinks() {
return links != null ? ImmutableSet.copyOf(links) : Collections.<Link>emptySet();
}
@Override
public String toString() {
return String
.format(
"[elementName=%s, instanceID=%s, caption=%s, description=%s, address=%s, addressOnParent=%s, allocationUnits=%s, automaticAllocation=%s, automaticDeallocation=%s, connections=%s, consumerVisibility=%s, hostResources=%s, limit=%s, mappingBehavior=%s, otherResourceType=%s, parent=%s, poolID=%s, reservation=%s, resourceSubType=%s, resourceType=%s, virtualQuantity=%s, virtualQuantityUnits=%s, weight=%s]",
elementName, instanceID, caption, description, address, addressOnParent, allocationUnits,
automaticAllocation, automaticDeallocation, connections, consumerVisibility, hostResources, limit,
mappingBehavior, otherResourceType, parent, poolID, reservation, resourceSubType, resourceType,
virtualQuantity, virtualQuantityUnits, weight);
return Objects.toStringHelper("")
.add("elementname", elementName)
.add("instanceId", instanceID)
.add("caption", caption)
.add("description", description)
.add("address", address)
.add("addressOnParent", addressOnParent)
.add("allocationUnits", allocationUnits)
.add("automaticAllocation", automaticAllocation)
.add("automaticDeallocation", automaticDeallocation)
.add("connections", connections)
.add("consumerVisibility", consumerVisibility)
.add("hostResources", hostResources)
.add("limit", limit)
.add("mappingBehavior", mappingBehavior)
.add("otherResourceType", otherResourceType)
.add("parent", parent)
.add("poolID", poolID)
.add("reservation", reservation)
.add("resourceSubType", resourceSubType)
.add("resourceType", resourceType)
.add("virtualQuantity", virtualQuantity)
.add("virtualQuantityUnits", virtualQuantityUnits)
.add("weight", weight)
.add("type", type)
.add("href", href)
.add("links", links)
.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + ((addressOnParent == null) ? 0 : addressOnParent.hashCode());
result = prime * result + ((resourceSubType == null) ? 0 : resourceSubType.hashCode());
result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
return result;
return Objects.hashCode(elementName, instanceID, caption, description,
address, addressOnParent, allocationUnits,
automaticAllocation, automaticDeallocation, connections,
consumerVisibility, hostResources, limit, mappingBehavior,
otherResourceType, parent, poolID, reservation, resourceSubType,
resourceType, virtualQuantity, virtualQuantityUnits, weight, type, href, links);
}
@Override
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;
ResourceAllocationSettingData other = (ResourceAllocationSettingData) 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 (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;
return true;
ResourceAllocationSettingData that = ResourceAllocationSettingData.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.address, that.address) &&
equal(this.addressOnParent, that.addressOnParent) &&
equal(this.allocationUnits, that.allocationUnits) &&
equal(this.automaticAllocation, that.automaticAllocation) &&
equal(this.automaticDeallocation, that.automaticDeallocation) &&
equal(this.connections, that.connections) &&
equal(this.consumerVisibility, that.consumerVisibility) &&
equal(this.hostResources, that.hostResources) &&
equal(this.limit, that.limit) &&
equal(this.mappingBehavior, that.mappingBehavior) &&
equal(this.otherResourceType, that.otherResourceType) &&
equal(this.parent, that.parent) &&
equal(this.poolID, that.poolID) &&
equal(this.reservation, that.reservation) &&
equal(this.resourceSubType, that.resourceSubType) &&
equal(this.resourceType, that.resourceType) &&
equal(this.virtualQuantity, that.virtualQuantity) &&
equal(this.virtualQuantityUnits, that.virtualQuantityUnits) &&
equal(this.weight, that.weight) &&
equal(this.type, that.type) &&
equal(this.href, that.href) &&
equal(this.links, that.links);
}
}

View File

@ -1,143 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.cim;
import static com.google.common.base.Preconditions.checkNotNull;
/**
*
* The type of resource this allocation setting represents.
*
* @author Adrian Cole
* @see <a
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
* />
*
*/
public abstract class SettingData implements Comparable<SettingData> {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return builder().fromSettingData(this);
}
public static class Builder {
protected String elementName;
protected String instanceID;
/**
* @see SettingData#getElementName
*/
public Builder elementName(String elementName) {
this.elementName = checkNotNull(elementName, "elementName");
return this;
}
/**
* @see SettingData#getInstanceID
*/
public Builder instanceID(String instanceID) {
this.instanceID = checkNotNull(instanceID, "instanceID");
return this;
}
public Builder fromSettingData(SettingData in) {
return elementName(in.getElementName()).instanceID(in.getInstanceID());
}
}
protected String elementName;
protected String instanceID;
public SettingData(String elementName, String instanceID) {
this.elementName = checkNotNull(elementName, "elementName");
this.instanceID = checkNotNull(instanceID, "instanceID");
}
protected SettingData() {
// 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;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((elementName == null) ? 0 : elementName.hashCode());
result = prime * result + ((instanceID == null) ? 0 : instanceID.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;
SettingData other = (SettingData) obj;
if (elementName == null) {
if (other.elementName != null)
return false;
} else if (!elementName.equals(other.elementName))
return false;
if (instanceID == null) {
if (other.instanceID != null)
return false;
} else if (!instanceID.equals(other.instanceID))
return false;
return true;
}
@Override
public String toString() {
return String.format("[elementName=%s, instanceID=%s]", elementName, instanceID);
}
/**
* {@inheritDoc}
*/
@Override
public int compareTo(SettingData o) {
if (instanceID == null)
return -1;
return (this == o) ? 0 : instanceID.compareTo(o.instanceID);
}
}

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -18,70 +18,103 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_VSSD_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import java.net.URI;
import java.math.BigInteger;
import java.util.Date;
import java.util.Map;
import java.util.Set;
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.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
*
* CIM_VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of
* virtualization specific properties. CIM_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 CIM_VirtualSystemSettingData that aggregates a number of
* instances of class CIM_ResourceAllocationSettingData, using association CIM_ConcreteComponent.
* Virtual system configurations may for example be used to reflect configurations of - virtual
* systems that are defined at a virtualization platform, - virtual systems that are currently
* active, - input requests to create new virtual systems, - input requests to modify existing
* virtual systems, or - snapshots of virtual systems.
* 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>
*
* @author Adrian Cole
* @see <a
* href="http://dmtf.org/sites/default/files/cim/cim_schema_v2280/cim_schema_2.28.0Final-Doc.zip"
* />
*
* @author grkvlt@apache.org
* @see http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd
*/
public class VirtualSystemSettingData extends ManagedElement {
@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = VCLOUD_OVF_NS)
public class VirtualSystemSettingData {
public static Builder builder() {
return new Builder();
}
/**
* {@inheritDoc}
*/
@Override
public Builder toBuilder() {
return builder().fromVirtualSystemSettingData(this);
}
public static class Builder extends ManagedElement.Builder {
public static class Builder {
private String elementName;
private String instanceID;
private String caption;
private String description;
private AutomaticRecoveryAction automaticRecoveryAction;
private AutomaticShutdownAction automaticShutdownAction;
private AutomaticStartupAction automaticStartupAction;
private Long automaticStartupActionDelay;
private Integer automaticStartupActionSequenceNumber;
private URI configurationDataRoot;
private URI configurationFile;
private BigInteger automaticStartupActionDelay;
private Long automaticStartupActionSequenceNumber;
private String configurationDataRoot;
private String configurationFile;
private String configurationID;
private Date creationTime;
private URI logDataRoot;
private URI recoveryFile;
private URI snapshotDataRoot;
private URI suspendDataRoot;
private URI swapFileDataRoot;
private String logDataRoot;
private String recoveryFile;
private String snapshotDataRoot;
private String suspendDataRoot;
private String swapFileDataRoot;
private String virtualSystemIdentifier;
private Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
private String virtualSystemType;
private String notes;
public Builder elementName(String elementName) {
this.elementName = elementName;
return this;
}
public Builder instanceID(String instanceID) {
this.instanceID = instanceID;
return this;
}
public Builder caption(String caption) {
this.caption = caption;
return this;
}
public Builder description(String description) {
this.description = description;
return this;
}
public Builder automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) {
this.automaticRecoveryAction = automaticRecoveryAction;
return this;
@ -97,22 +130,22 @@ public class VirtualSystemSettingData extends ManagedElement {
return this;
}
public Builder automaticStartupActionDelay(Long automaticStartupActionDelay) {
public Builder automaticStartupActionDelay(BigInteger automaticStartupActionDelay) {
this.automaticStartupActionDelay = automaticStartupActionDelay;
return this;
}
public Builder automaticStartupActionSequenceNumber(Integer automaticStartupActionSequenceNumber) {
public Builder automaticStartupActionSequenceNumber(Long automaticStartupActionSequenceNumber) {
this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
return this;
}
public Builder configurationDataRoot(URI configurationDataRoot) {
public Builder configurationDataRoot(String configurationDataRoot) {
this.configurationDataRoot = configurationDataRoot;
return this;
}
public Builder configurationFile(URI configurationFile) {
public Builder configurationFile(String configurationFile) {
this.configurationFile = configurationFile;
return this;
}
@ -127,27 +160,27 @@ public class VirtualSystemSettingData extends ManagedElement {
return this;
}
public Builder logDataRoot(URI logDataRoot) {
public Builder logDataRoot(String logDataRoot) {
this.logDataRoot = logDataRoot;
return this;
}
public Builder recoveryFile(URI recoveryFile) {
public Builder recoveryFile(String recoveryFile) {
this.recoveryFile = recoveryFile;
return this;
}
public Builder snapshotDataRoot(URI snapshotDataRoot) {
public Builder snapshotDataRoot(String snapshotDataRoot) {
this.snapshotDataRoot = snapshotDataRoot;
return this;
}
public Builder suspendDataRoot(URI suspendDataRoot) {
public Builder suspendDataRoot(String suspendDataRoot) {
this.suspendDataRoot = suspendDataRoot;
return this;
}
public Builder swapFileDataRoot(URI swapFileDataRoot) {
public Builder swapFileDataRoot(String swapFileDataRoot) {
this.swapFileDataRoot = swapFileDataRoot;
return this;
}
@ -157,13 +190,8 @@ public class VirtualSystemSettingData extends ManagedElement {
return this;
}
public Builder virtualSystemTypes(Iterable<String> virtualSystemTypes) {
this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
return this;
}
public Builder virtualSystemType(String virtualSystemType) {
this.virtualSystemTypes.add(checkNotNull(virtualSystemType, "virtualSystemType"));
this.virtualSystemType = virtualSystemType;
return this;
}
@ -177,77 +205,48 @@ public class VirtualSystemSettingData extends ManagedElement {
automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay,
automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile, configurationID,
creationTime, logDataRoot, recoveryFile, snapshotDataRoot, suspendDataRoot, swapFileDataRoot,
virtualSystemIdentifier, virtualSystemTypes, notes);
virtualSystemIdentifier, virtualSystemType, notes);
}
public Builder fromVirtualSystemSettingData(VirtualSystemSettingData in) {
return fromManagedElement(in).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()).virtualSystemTypes(in.getVirtualSystemTypes()).notes(
in.getNotes());
}
/**
* {@inheritDoc}
*/
@Override
public Builder fromManagedElement(ManagedElement in) {
return Builder.class.cast(super.fromManagedElement(in));
}
/**
* {@inheritDoc}
*/
@Override
public Builder caption(String caption) {
return Builder.class.cast(super.caption(caption));
}
/**
* {@inheritDoc}
*/
@Override
public Builder description(String description) {
return Builder.class.cast(super.description(description));
}
/**
* {@inheritDoc}
*/
@Override
public Builder elementName(String elementName) {
return Builder.class.cast(super.elementName(elementName));
}
/**
* {@inheritDoc}
*/
@Override
public Builder instanceID(String instanceID) {
return Builder.class.cast(super.instanceID(instanceID));
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-interuptable wait state condition.
*/
@XmlType
@XmlEnum(Integer.class)
public static enum AutomaticRecoveryAction {
NONE(2),
RESTART(3),
REVERT_TO_SNAPSHOT(4);
@XmlEnumValue("2") NONE(2),
@XmlEnumValue("3") RESTART(3),
@XmlEnumValue("4") REVERT_TO_SNAPSHOT(4);
protected final int code;
@ -256,35 +255,32 @@ public class VirtualSystemSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static 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(new Integer(checkNotNull(automaticRecoveryAction,
"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 {
TURN_OFF(2),
SAVE_STATE(3),
SHUTDOWN(4);
@XmlEnumValue("2") TURN_OFF(2),
@XmlEnumValue("3") SAVE_STATE(3),
@XmlEnumValue("4") SHUTDOWN(4);
protected final int code;
@ -293,35 +289,32 @@ public class VirtualSystemSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static 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(new Integer(checkNotNull(automaticShutdownAction,
"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 {
NONE(2),
RESTART_IF_PREVIOUSLY_ACTIVE(3),
ALWAYS_STARTUP(4);
@XmlEnumValue("2") NONE(2),
@XmlEnumValue("3") RESTART_IF_PREVIOUSLY_ACTIVE(3),
@XmlEnumValue("4") ALWAYS_STARTUP(4);
protected final int code;
@ -330,51 +323,76 @@ public class VirtualSystemSettingData extends ManagedElement {
}
public String value() {
return code + "";
return Integer.toString(code);
}
protected final static 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(new Integer(checkNotNull(automaticStartupAction,
"automaticStartupAction")));
return AUTOMATIC_STARTUP_ACTION_BY_ID.get(Integer.valueOf(checkNotNull(automaticStartupAction, "automaticStartupAction")));
}
}
private AutomaticRecoveryAction automaticRecoveryAction;
private AutomaticShutdownAction automaticShutdownAction;
private AutomaticStartupAction automaticStartupAction;
private Long automaticStartupActionDelay;
private Integer automaticStartupActionSequenceNumber;
private URI configurationDataRoot;
private URI configurationFile;
private String configurationID;
private Date creationTime;
private URI logDataRoot;
private URI recoveryFile;
private URI snapshotDataRoot;
private URI suspendDataRoot;
private URI swapFileDataRoot;
@XmlElement(name = "ElementName", namespace = VCLOUD_CIM_VSSD_NS)
private String elementName;
@XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_VSSD_NS)
private String instanceID;
@XmlElement(name = "Caption", namespace = VCLOUD_CIM_VSSD_NS)
private String caption;
@XmlElement(name = "Description", namespace = VCLOUD_CIM_VSSD_NS)
private String description;
@XmlElement(name = "VirtualSystemIdentifier", namespace = VCLOUD_CIM_VSSD_NS)
private String virtualSystemIdentifier;
private Set<String> virtualSystemTypes;
@XmlElement(name = "VirtualSystemType", namespace = VCLOUD_CIM_VSSD_NS)
private String virtualSystemType;
@XmlElement(name = "AutomaticRecoveryAction", namespace = VCLOUD_CIM_VSSD_NS)
private AutomaticRecoveryAction automaticRecoveryAction;
@XmlElement(name = "AutomaticShutdownAction", namespace = VCLOUD_CIM_VSSD_NS)
private AutomaticShutdownAction automaticShutdownAction;
@XmlElement(name = "AutomaticStartupAction", namespace = VCLOUD_CIM_VSSD_NS)
private AutomaticStartupAction automaticStartupAction;
@XmlElement(name = "AutomaticStartupActionDelay", namespace = VCLOUD_CIM_VSSD_NS)
private BigInteger automaticStartupActionDelay;
@XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = VCLOUD_CIM_VSSD_NS)
private Long automaticStartupActionSequenceNumber;
@XmlElement(name = "ConfigurationDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private String configurationDataRoot;
@XmlElement(name = "ConfigurationFile", namespace = VCLOUD_CIM_VSSD_NS)
private String configurationFile;
@XmlElement(name = "ConfigurationID", namespace = VCLOUD_CIM_VSSD_NS)
private String configurationID;
@XmlElement(name = "CreationTime", namespace = VCLOUD_CIM_VSSD_NS)
private Date creationTime;
@XmlElement(name = "LogDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private String logDataRoot;
@XmlElement(name = "RecoveryFile", namespace = VCLOUD_CIM_VSSD_NS)
private String recoveryFile;
@XmlElement(name = "SnapshotDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private String snapshotDataRoot;
@XmlElement(name = "SuspendDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private String suspendDataRoot;
@XmlElement(name = "SwapFileDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private String swapFileDataRoot;
@XmlElement(name = "Notes", namespace = VCLOUD_CIM_VSSD_NS)
private String notes;
private VirtualSystemSettingData(String elementName, String instanceID, String caption, String description,
AutomaticRecoveryAction automaticRecoveryAction, AutomaticShutdownAction automaticShutdownAction,
AutomaticStartupAction automaticStartupAction, Long automaticStartupActionDelay,
Integer automaticStartupActionSequenceNumber, URI configurationDataRoot, URI configurationFile,
String configurationID, Date creationTime, URI logDataRoot, URI recoveryFile, URI snapshotDataRoot,
URI suspendDataRoot, URI swapFileDataRoot, String virtualSystemIdentifier,
Iterable<String> virtualSystemTypes, String notes) {
super(elementName, instanceID, caption, description);
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;
@ -390,7 +408,7 @@ public class VirtualSystemSettingData extends ManagedElement {
this.suspendDataRoot = suspendDataRoot;
this.swapFileDataRoot = swapFileDataRoot;
this.virtualSystemIdentifier = virtualSystemIdentifier;
this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
this.virtualSystemType = virtualSystemType;
this.notes = notes;
}
@ -398,6 +416,37 @@ public class VirtualSystemSettingData extends ManagedElement {
// 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
@ -425,7 +474,7 @@ public class VirtualSystemSettingData extends ManagedElement {
* Delay applicable to startup action. The value shall be in the interval variant of the datetime
* datatype.
*/
public Long getAutomaticStartupActionDelay() {
public BigInteger getAutomaticStartupActionDelay() {
return automaticStartupActionDelay;
}
@ -435,24 +484,28 @@ public class VirtualSystemSettingData extends ManagedElement {
* same value, the sequence is implementation dependent. A value of 0 indicates that the sequence
* is implementation dependent.
*/
public Integer getAutomaticStartupActionSequenceNumber() {
public Long getAutomaticStartupActionSequenceNumber() {
return automaticStartupActionSequenceNumber;
}
/**
* Filepath of a directory where information about the virtual system configuration is
* stored.Format shall be URI based on RFC 2079.
* stored.
*
* Format shall be String based on RFC-2079.
*/
public URI getConfigurationDataRoot() {
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 ConfigurationDataRoot property.Format shall be URI
* based on RFC 2079.
* 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 URI getConfigurationFile() {
public String getConfigurationFile() {
return configurationFile;
}
@ -473,52 +526,63 @@ public class VirtualSystemSettingData extends ManagedElement {
}
/**
* Filepath of a directory where log information about the virtual system is stored. A relative
* path appends to the value of the ConfigurationDataRoot property.Format shall be URI based on
* RFC 2079.
* 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 URI getLogDataRoot() {
public String getLogDataRoot() {
return logDataRoot;
}
/**
* Filepath of a file where recovery relateded information of the virtual system is stored.Format
* shall be URI based on RFC 2079.
* Filepath of a file where recovery relateded information of the virtual system is stored.
*
* Format shall be String based on RFC-2079.
*/
public URI getRecoveryFile() {
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 ConfigurationDataRoot property.Format shall be URI based on
* RFC 2079.
* 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 URI getSnapshotDataRoot() {
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 ConfigurationDataRoot property.Format shall be URI
* based on RFC 2079.
*
* A relative path appends to the value of the {@link #getConfigurationDataRoot()} property.
* <p>
* Format shall be String based on RFC-2079.
*/
public URI getSuspendDataRoot() {
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 ConfigurationDataRoot property.Format shall be URI based on RFC
* 2079.
* 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 URI getSwapFileDataRoot() {
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
* 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 expresssion) that
@ -531,8 +595,8 @@ public class VirtualSystemSettingData extends ManagedElement {
/**
* VirtualSystemType shall reflect a particular type of virtual system.
*/
public Set<String> getVirtualSystemTypes() {
return virtualSystemTypes;
public String getVirtualSystemType() {
return virtualSystemType;
}
/**
@ -544,10 +608,7 @@ public class VirtualSystemSettingData extends ManagedElement {
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((virtualSystemIdentifier == null) ? 0 : virtualSystemIdentifier.hashCode());
return result;
return Objects.hashCode(elementName, instanceID, caption, description, virtualSystemIdentifier, virtualSystemType);
}
@Override
@ -558,25 +619,23 @@ public class VirtualSystemSettingData extends ManagedElement {
return false;
if (getClass() != obj.getClass())
return false;
VirtualSystemSettingData other = (VirtualSystemSettingData) obj;
if (virtualSystemIdentifier == null) {
if (other.virtualSystemIdentifier != null)
return false;
} else if (!virtualSystemIdentifier.equals(other.virtualSystemIdentifier))
return false;
return true;
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.virtualSystemIdentifier, that.virtualSystemIdentifier) &&
equal(this.virtualSystemType, that.virtualSystemType);
}
@Override
public String toString() {
return String
.format(
"[elementName=%s, instanceID=%s, caption=%s, description=%s, automaticRecoveryAction=%s, automaticShutdownAction=%s, automaticStartupAction=%s, automaticStartupActionDelay=%s, automaticStartupActionSequenceNumber=%s, configurationDataRoot=%s, configurationFile=%s, configurationID=%s, creationTime=%s, logDataRoot=%s, notes=%s, recoveryFile=%s, snapshotDataRoot=%s, suspendDataRoot=%s, swapFileDataRoot=%s, virtualSystemIdentifier=%s, virtualSystemTypes=%s]",
elementName, instanceID, caption, description, automaticRecoveryAction,
automaticShutdownAction, automaticStartupAction, automaticStartupActionDelay,
automaticStartupActionSequenceNumber, configurationDataRoot, configurationFile,
configurationID, creationTime, logDataRoot, notes, recoveryFile, snapshotDataRoot,
suspendDataRoot, swapFileDataRoot, virtualSystemIdentifier, virtualSystemTypes);
return Objects.toStringHelper("")
.add("caption", caption)
.add("description", description)
.add("virtualSystemIdentifier", virtualSystemIdentifier)
.add("virtualSystemType", virtualSystemType)
.toString();
}
}

View File

@ -16,14 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
@XmlSchema(namespace = VCLOUD_CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED)
@XmlSchema(namespace = VCLOUD_CIM_NS, elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS),
@XmlNs(prefix = "ovf", namespaceURI = VCLOUD_OVF_NS),
@XmlNs(prefix = "vssd", namespaceURI = VCLOUD_CIM_VSSD_NS),
@XmlNs(prefix = "rasd", namespaceURI = VCLOUD_CIM_RASD_NS),
@XmlNs(prefix = "vcloud", namespaceURI = VCLOUD_1_5_NS)
}
)
@XmlAccessorType(XmlAccessType.FIELD)
package org.jclouds.vcloud.director.v1_5.domain.cim;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_VSSD_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_RASD_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_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;

View File

@ -1,17 +1,28 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.08 at 02:47:44 PM GMT
//
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
@ -19,11 +30,10 @@ import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import com.google.common.base.Objects;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* Java class for anonymous complex type.
*
* <pre>
* &lt;complexType>
@ -41,82 +51,51 @@ import javax.xml.namespace.QName;
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlType(name = "")
@XmlType
@XmlSeeAlso({
StartupSectionItem.class
})
public class Item {
// TODO Builder
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true)
@XmlAttribute(required = true)
protected String id;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true)
@XmlAttribute(required = true)
@XmlSchemaType(name = "unsignedShort")
protected int order;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
@XmlAttribute
@XmlSchemaType(name = "unsignedShort")
protected Integer startDelay;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
@XmlAttribute
protected Boolean waitingForGuest;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
@XmlAttribute
@XmlSchemaType(name = "unsignedShort")
protected Integer stopDelay;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
@XmlAttribute
protected String startAction;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
@XmlAttribute
protected String stopAction;
@XmlAnyAttribute
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
/**
* Gets the value of the id property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getId() {
return id;
}
/**
* Sets the value of the id property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setId(String value) {
this.id = value;
}
/**
* Gets the value of the order property.
*
*/
public int getOrder() {
return order;
}
/**
* Sets the value of the order property.
*
*/
public void setOrder(int value) {
this.order = value;
}
/**
* Gets the value of the startDelay property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public int getStartDelay() {
if (startDelay == null) {
@ -126,25 +105,8 @@ public class Item {
}
}
/**
* Sets the value of the startDelay property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStartDelay(Integer value) {
this.startDelay = value;
}
/**
* Gets the value of the waitingForGuest property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public boolean isWaitingForGuest() {
if (waitingForGuest == null) {
@ -154,25 +116,8 @@ public class Item {
}
}
/**
* Sets the value of the waitingForGuest property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setWaitingForGuest(Boolean value) {
this.waitingForGuest = value;
}
/**
* Gets the value of the stopDelay property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public int getStopDelay() {
if (stopDelay == null) {
@ -182,25 +127,8 @@ public class Item {
}
}
/**
* Sets the value of the stopDelay property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStopDelay(Integer value) {
this.stopDelay = value;
}
/**
* Gets the value of the startAction property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStartAction() {
if (startAction == null) {
@ -210,25 +138,8 @@ public class Item {
}
}
/**
* Sets the value of the startAction property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStartAction(String value) {
this.startAction = value;
}
/**
* Gets the value of the stopAction property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getStopAction() {
if (stopAction == null) {
@ -238,34 +149,46 @@ public class Item {
}
}
/**
* Sets the value of the stopAction property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setStopAction(String value) {
this.stopAction = value;
}
/**
* Gets a map that contains attributes that aren't bound to any typed property on this class.
*
* <p>
* the map is keyed by the name of the attribute and
* the value is the string value of the attribute.
*
* the map returned by this method is live, and you can add new attribute
* by updating the map directly. Because of this design, there's no setter.
*
*
* @return
* always non-null
*/
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 Objects.toStringHelper("")
.add("id", id)
.add("order", order)
.add("startDelay", startDelay)
.add("waitingForGuest", waitingForGuest)
.add("stopDelay", stopDelay)
.add("startAction", startAction)
.add("stopAction", stopAction)
.toString();
}
}

View File

@ -0,0 +1,145 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.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.Objects;
/**
* Type for localizable string.
*
* Default string value
*
* <pre>
* &lt;complexType name="Msg_Type" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@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 static abstract 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 Objects.toStringHelper("")
.add("value", value).add("msgid", msgid).toString();
}
}

View File

@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS;
import java.net.URI;
@ -30,6 +31,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
@ -44,6 +46,7 @@ import com.google.common.collect.Sets;
* @author Adam Lowe
*/
@XmlRootElement(name = "OperatingSystemSection")
@XmlType
public class OperatingSystemSection extends SectionType {
public static Builder<?> builder() {
@ -58,7 +61,7 @@ public class OperatingSystemSection extends SectionType {
}
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
private Integer id;
private int id;
private String description;
private String version;
private String osType;
@ -69,7 +72,7 @@ public class OperatingSystemSection extends SectionType {
/**
* @see OperatingSystemSection#getId()
*/
public B id(Integer id) {
public B id(int id) {
this.id = id;
return self();
}
@ -141,16 +144,17 @@ public class OperatingSystemSection extends SectionType {
}
public B fromOperatingSystemSection(OperatingSystemSection in) {
return fromSectionType(in).id(in.getId()).version(in.getVersion()).description(in.getDescription())
return fromSectionType(in)
.id(in.getId()).version(in.getVersion()).description(in.getDescription())
.osType(in.getOsType()).href(in.getHref()).type(in.getType()).links(in.getLinks());
}
}
@XmlAttribute(required = true)
protected Integer id;
@XmlAttribute(namespace = VCLOUD_OVF_NS, required = true)
protected int id;
@XmlAttribute
protected String version;
@XmlElement
@XmlElement(name = "Description")
protected String description;
@XmlAttribute(namespace = VCLOUD_VMW_NS)
protected String osType;
@ -181,7 +185,7 @@ public class OperatingSystemSection extends SectionType {
*
* @see org.jclouds.vcloud.director.v1_5.domain.cim.OSType#getCode()
*/
public Integer getId() {
public int getId() {
return id;
}
@ -230,7 +234,7 @@ public class OperatingSystemSection extends SectionType {
* @see ResourceType#getLinks()
*/
public Set<Link> getLinks() {
return links == null ? ImmutableSet.<Link>of() : Collections.unmodifiableSet(links);
return links == null ? Sets.<Link>newLinkedHashSet() : ImmutableSet.copyOf(links);
}
@Override

View File

@ -1,4 +1,4 @@
/**
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@ -18,12 +18,18 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
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 org.jclouds.vcloud.director.v1_5.domain.cim.CimString;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
@ -32,13 +38,13 @@ import com.google.common.collect.Sets;
/**
* The ProductSection element specifies product-information for an appliance, such as product name,
* version, and vendor.
*
* TODO this should contain a multitude of other elements!
*
* @author Adrian Cole
* @author Adam Lowe
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "ProductSection", namespace = VCLOUD_OVF_NS)
@XmlRootElement(name = "ProductSection")
@XmlType(name = "ProductSection_Type")
public class ProductSection extends SectionType {
public static Builder<?> builder() {
@ -53,12 +59,84 @@ public class ProductSection extends SectionType {
}
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
protected Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties = Sets.newLinkedHashSet();
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();
/**
* @see ProductSection#getProperties
* @see ProductSection#getProduct()
*/
public B property(org.jclouds.vcloud.director.v1_5.domain.ovf.Property property) {
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();
}
@ -66,11 +144,11 @@ public class ProductSection extends SectionType {
/**
* @see ProductSection#getProperties
*/
public B properties(Iterable<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties) {
this.properties = ImmutableSet.<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> copyOf(checkNotNull(properties, "properties"));
public B properties(Iterable<ProductSectionProperty> properties) {
this.properties = ImmutableSet.copyOf(checkNotNull(properties, "properties"));
return self();
}
/**
* {@inheritDoc}
*/
@ -80,25 +158,112 @@ public class ProductSection extends SectionType {
}
public B fromProductSection(ProductSection in) {
return info(in.getInfo()).properties(in.getProperties());
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 Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> properties;
private ProductSection(Builder<?> builder) {
super(builder);
this.properties = ImmutableSet.copyOf(checkNotNull(builder.properties, "properties"));
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")) : Collections.<ProductSectionProperty>emptySet();
}
private ProductSection() {
// For JAXB
}
@XmlElement(name = "Product")
private MsgType product;
@XmlElement(name = "Vendor")
private MsgType vendor;
@XmlElement(name = "Version", namespace = VCLOUD_CIM_NS)
private CimString version;
@XmlElement(name = "FullVersion", namespace = VCLOUD_CIM_NS)
private CimString fullVersion;
@XmlElement(name = "ProductUrl", namespace = VCLOUD_CIM_NS)
private CimString productUrl;
@XmlElement(name = "VendorUrl", namespace = VCLOUD_CIM_NS)
private CimString vendorUrl;
@XmlElement(name = "AppUrl", namespace = VCLOUD_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(), properties);
return Objects.hashCode(super.hashCode(), product, vendor, version, fullVersion, productUrl, vendorUrl, appUrl, properties);
}
@Override
@ -107,17 +272,29 @@ public class ProductSection extends SectionType {
if (!super.equals(obj)) return false;
if (getClass() != obj.getClass()) return false;
ProductSection other = (ProductSection) obj;
return super.equals(other) && Objects.equal(properties, other.properties);
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 Objects.ToStringHelper string() {
return super.string().add("properties", properties);
}
public Set<org.jclouds.vcloud.director.v1_5.domain.ovf.Property> getProperties() {
return properties;
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);
}
}

View File

@ -0,0 +1,38 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.ovf;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* Property element
*
* <pre>
* &lt;element name="Property" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlType(name = "")
@XmlRootElement(name = "Property")
public class ProductSectionProperty extends Property {
// TODO hashCode, equals, toString
}

View File

@ -18,89 +18,265 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
* @author Adrian Cole
* @author Adam Lowe
* @author grkvlt@apache.org
*/
@XmlType(name = "Property", namespace = VCLOUD_OVF_NS)
@XmlType(name = "Property")
@XmlSeeAlso({ ProductSectionProperty.class })
public class Property {
public static Builder builder() {
return new Builder();
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public static class Builder {
public Builder<?> toBuilder() {
return builder().fromProperty(this);
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
}
public static abstract class Builder<B extends Builder<B>> {
protected String key;
protected String value;
protected String label;
protected String description;
protected Set<PropertyConfigurationValueType> values = Sets.newLinkedHashSet();
protected MsgType label;
protected MsgType description;
protected String type;
protected String qualifiers;
protected Boolean userConfigurable;
protected String defaultValue = "";
@SuppressWarnings("unchecked")
protected B self() {
return (B) this;
}
/**
* @see Property#getKey
* @see Property#getKey()
*/
public Builder key(String key) {
public B key(String key) {
this.key = key;
return this;
return self();
}
/**
* @see Property#getValue
* @see Property#getValues()
*/
public Builder value(String value) {
this.value = value;
return this;
public B values(Set<PropertyConfigurationValueType> values) {
this.values = checkNotNull(values, "values");
return self();
}
/**
* @see Property#getLabel
* @see Property#getValues()
*/
public Builder label(String label) {
public B value(PropertyConfigurationValueType value) {
this.values.add(checkNotNull(value, "value"));
return self();
}
/**
* @see Property#getLabel()
*/
public B label(MsgType label) {
this.label = label;
return this;
return self();
}
/**
* @see Property#getDescription
* @see Property#getDescription()
*/
public Builder description(String description) {
public B description(MsgType description) {
this.description = description;
return this;
return self();
}
/**
* @see Property#getType()
*/
public B type(String type) {
this.type = type;
return self();
}
/**
* @see Property#getQualifiers()
*/
public B qualifiers(String qualifiers) {
this.qualifiers = qualifiers;
return self();
}
/**
* @see Property#getQualifiers()
*/
public B qualifiers(Iterable<String> qualifiers) {
this.qualifiers = Joiner.on(',').join(qualifiers);
return self();
}
/**
* @see Property#getQualifiers()
*/
public B qualifiers(String...qualifiers) {
this.qualifiers = Joiner.on(',').join(qualifiers);
return self();
}
/**
* @see Property#isUserConfigurable()
*/
public B isUserConfigurable(Boolean userConfigurable) {
this.userConfigurable = userConfigurable;
return self();
}
/**
* @see Property#isUserConfigurable()
*/
public B userConfigurable() {
this.userConfigurable = Boolean.TRUE;
return self();
}
/**
* @see Property#isUserConfigurable()
*/
public B notUserConfigurable() {
this.userConfigurable = Boolean.FALSE;
return self();
}
/**
* @see Property#getDefaultValue()
*/
public B defaultValue(String defaultValue) {
this.defaultValue = defaultValue;
return self();
}
public Property build() {
return new Property(key, value, label, description);
return new Property(this);
}
public Builder fromProperty(Property in) {
return key(in.getKey()).value(in.getValue()).description(in.getDescription()).label(in.getLabel());
public B fromProperty(Property in) {
return key(in.getKey()).values(in.getValues()).description(in.getDescription()).label(in.getLabel())
.type(in.getType()).qualifiers(in.getQualifiers()).isUserConfigurable(in.isUserConfigurable()).defaultValue(in.getDefaultValue());
}
}
@XmlAttribute
private String key;
private String value;
private String label;
private String description;
@XmlElement(name = "Value")
private Set<PropertyConfigurationValueType> values;
@XmlElement(name = "Label")
private MsgType label;
@XmlElement(name = "Description")
private MsgType description;
@XmlAttribute(required = true)
private String type;
@XmlAttribute(required = true)
private String qualifiers;
@XmlAttribute
private Boolean userConfigurable;
@XmlAttribute(name = "value")
private String defaultValue;
private Property(String key, String value, String label, String description) {
this.key = key;
this.value = value;
this.label = label;
this.description = description;
protected Property(Builder<?> builder) {
this.key = builder.key;
this.values = builder.values;
this.label = builder.label;
this.description = builder.description;
this.type = builder.type;
this.qualifiers = builder.qualifiers;
this.userConfigurable = builder.userConfigurable;
this.defaultValue = builder.defaultValue;
}
private Property() {
protected Property() {
// for JAXB
}
/**
* Property identifier.
*/
public String getKey() {
return key;
}
/**
* Description of property.
*/
public MsgType getDescription() {
return description;
}
/**
* Short description of property.
*/
public MsgType getLabel() {
return label;
}
/**
* Alternative default property values for different configuration
*/
public Set<PropertyConfigurationValueType> getValues() {
return values;
}
/**
* Property type.
*/
public String getType() {
return type;
}
/**
* A comma-separated set of type qualifiers.
*/
public String getQualifiers() {
return qualifiers;
}
/**
* Determines whether the property value is configurable during installation.
*/
public Boolean isUserConfigurable() {
return userConfigurable;
}
/**
* A Default value for property.
*/
public String getDefaultValue() {
if (defaultValue == null) {
return "";
} else {
return defaultValue;
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((key == null) ? 0 : key.hashCode());
return result;
return Objects.hashCode(key, values, label, description, type, qualifiers, userConfigurable, defaultValue);
}
@Override
@ -111,33 +287,22 @@ public class Property {
return false;
if (getClass() != obj.getClass())
return false;
Property other = (Property) obj;
if (key == null) {
if (other.key != null)
return false;
} else if (!key.equals(other.key))
return false;
return true;
Property that = Property.class.cast(obj);
return equal(this.key, that.key) &&
equal(this.values, that.values) &&
equal(this.label, that.label) &&
equal(this.description, that.description) &&
equal(this.type, that.type) &&
equal(this.qualifiers, that.qualifiers) &&
equal(this.userConfigurable, that.userConfigurable) &&
equal(this.defaultValue, that.defaultValue);
}
@Override
public String toString() {
return String.format("[key=%s, value=%s, label=%s, description=%s]", key, value, label, description);
}
public String getKey() {
return key;
}
public String getDescription() {
return description;
}
public String getLabel() {
return label;
}
public String getValue() {
return value;
return Objects.toStringHelper("")
.add("key", key).add("values", values).add("label", label).add("description", description)
.add("type", type).add("qualifiers", qualifiers).add("userConfigurable", userConfigurable).add("defaultValue", defaultValue)
.toString();
}
}

View File

@ -0,0 +1,58 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.ovf;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
/**
* Type for alternative default values for properties when DeploymentOptionSection is used
*
* <pre>
* &lt;complexType name="PropertyConfigurationValue_Type">
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlType(name = "PropertyConfigurationValue_Type")
public class PropertyConfigurationValueType {
// TODO Builder
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true)
protected String value;
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1")
protected String configuration;
/**
* Gets the value of the value property.
*/
public String getValue() {
return value;
}
/**
* Gets the value of the configuration property.
*/
public String getConfiguration() {
return configuration;
}
// TODO hashCode, equals, toString
}

View File

@ -1,136 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.ovf;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.cim.CIMResourceAllocationSettingDataType;
/**
* Wrapper for CIM_ResourceAllocationSettingData_Type
*
* <pre>
* &lt;complexType name="RASD_Type" /&gt;
* </pre>
*
* @author grkvlt@apache.org
*/
@XmlType(name = "RASD_Type")
@XmlRootElement(name = "Item", namespace = VCLOUD_1_5_NS)
public class RASD extends CIMResourceAllocationSettingDataType {
// TODO Add toString, hashCode and equals
public static Builder<?> builder() {
return new ConcreteBuilder();
}
@Override
public Builder<?> toBuilder() {
return builder().fromRASD(this);
}
public static class Builder<B extends Builder<B>> extends CIMResourceAllocationSettingDataType.Builder<B> {
private Boolean required;
private String configuration;
private String bound;
public B required(Boolean val) {
this.required = val;
return self();
}
public B configuration(String val) {
this.configuration = val;
return self();
}
public B bound(String val) {
this.bound = val;
return self();
}
public B fromRASD(RASD val) {
return fromCIMResourceAllocationSettingDataType(val).required(val.isRequired()).configuration(val.getConfiguration()).bound(val.getBound());
}
@Override
public RASD build() {
return new RASD(this);
}
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
}
@XmlAttribute(namespace = VCLOUD_OVF_NS)
private Boolean required;
@XmlAttribute(namespace = VCLOUD_OVF_NS)
private String configuration;
@XmlAttribute(namespace = VCLOUD_OVF_NS)
private String bound;
protected RASD() {
// For JAXB
}
protected RASD(Builder<?> builder) {
super(builder);
this.required = builder.required;
this.configuration = builder.configuration;
this.bound = builder.bound;
}
/**
* Gets the value of the required property.
*
* @return possible object is {@link Boolean }
*/
public boolean isRequired() {
if (required == null) {
return true;
} else {
return required;
}
}
/**
* Gets the value of the configuration property.
*
* @return possible object is {@link String }
*/
public String getConfiguration() {
return configuration;
}
/**
* Gets the value of the bound property.
*
* @return possible object is {@link String }
*/
public String getBound() {
return bound;
}
}

View File

@ -18,8 +18,14 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@ -28,11 +34,14 @@ import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.RuntimeInfoSection;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* Metadata about a virtual machine or grouping of them.
@ -41,6 +50,7 @@ import com.google.common.base.Objects;
*
* @author Adrian Cole
* @author Adam Lowe
* @author grkvlt@apache.org
*/
@XmlType(name = "Section_Type")
@XmlSeeAlso({
@ -108,9 +118,9 @@ public abstract class SectionType {
}
}
@XmlElement(name = "Info")
@XmlElement(name = "Info", required = true)
private String info;
@XmlAttribute(namespace = VCLOUD_OVF_NS)
@XmlAttribute
private Boolean required;
protected SectionType(Builder<?> builder) {
@ -153,7 +163,7 @@ public abstract class SectionType {
if (getClass() != obj.getClass())
return false;
SectionType other = (SectionType) obj;
return Objects.equal(this.info, other.info) && Objects.equal(this.required, other.required);
return equal(this.info, other.info) && equal(this.required, other.required);
}
@Override

View File

@ -24,13 +24,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
/**
* Specifies the order in which entities in a VirtualSystemCollection are powered on and shut down
@ -55,8 +55,7 @@ public class StartupSection extends SectionType {
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
private List<StartupSectionItem> items = Collections.emptyList();
private List<Object> any = Collections.emptyList();
private List<StartupSectionItem> items = Lists.newArrayList();
/**
* @see StartupSection#getItem()
@ -74,28 +73,18 @@ public class StartupSection extends SectionType {
return self();
}
/**
* @see StartupSection#getAny()
*/
public B any(List<Object> any) {
this.any = any;
return self();
}
@Override
public StartupSection build() {
return new StartupSection(this);
}
public B fromStartupSection(StartupSection in) {
return fromSectionType(in).items(items).any(any);
return fromSectionType(in).items(in.getItems());
}
}
@XmlElement(name = "Item")
private List<StartupSectionItem> items;
@XmlAnyElement(lax = true)
private List<Object> any;
private List<StartupSectionItem> items = Lists.newArrayList();
protected StartupSection() {
// For JAXB
@ -104,23 +93,15 @@ public class StartupSection extends SectionType {
public StartupSection(Builder<?> builder) {
super(builder);
this.items = (items != null) ? ImmutableList.<StartupSectionItem>copyOf(builder.items) : Collections.<StartupSectionItem>emptyList();
this.any = (any != null) ? ImmutableList.<Object>copyOf(builder.any) : Collections.<Object>emptyList();
}
/**
* Gets the value of the item property.
*/
public List<StartupSectionItem> getItem() {
public List<StartupSectionItem> getItems() {
return items;
}
/**
* Gets the value of the any property.
*/
public List<Object> getAny() {
return any;
}
@Override
public boolean equals(Object o) {
if (this == o)
@ -128,17 +109,16 @@ public class StartupSection extends SectionType {
if (o == null || getClass() != o.getClass())
return false;
StartupSection that = StartupSection.class.cast(o);
return super.equals(that) &&
equal(this.items, that.items) && equal(this.any, that.any);
return super.equals(that) && equal(this.items, that.items);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), items, any);
return Objects.hashCode(super.hashCode(), items);
}
@Override
public ToStringHelper string() {
return super.string().add("items", items).add("any", any);
return super.string().add("items", items);
}
}

View File

@ -1,23 +1,28 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.08 at 02:47:44 PM GMT
//
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.domain.ovf;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for Item element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* Java class for Item element declaration.
*
* <pre>
* &lt;element name="Item">
@ -37,12 +42,23 @@ import javax.xml.bind.annotation.XmlType;
* &lt;/complexType>
* &lt;/element>
* </pre>
*
*
*/
@XmlType(name = "")
@XmlType
@XmlRootElement(name = "Item")
public class StartupSectionItem extends Item {
// TODO Builder
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StartupSectionItem that = StartupSectionItem.class.cast(obj);
return super.equals(that);
}
}

View File

@ -18,15 +18,25 @@
*/
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import java.net.URI;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.cim.VirtualSystemSettingData;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
@ -40,8 +50,10 @@ import com.google.common.collect.Sets;
*
* @author Adrian Cole
* @author Adam Lowe
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "VirtualHardwareSection")
@XmlType(name = "VirtualHardwareSection_Type")
public class VirtualHardwareSection extends SectionType {
public static Builder<?> builder() {
@ -56,9 +68,13 @@ public class VirtualHardwareSection extends SectionType {
}
public static class Builder<B extends Builder<B>> extends SectionType.Builder<B> {
protected VirtualSystemSettingData virtualSystem;
protected Set<String> transports = Sets.newLinkedHashSet();
protected Set<ResourceAllocationSettingData> items = Sets.newLinkedHashSet();
private VirtualSystemSettingData virtualSystem;
private String transport;
private Set<ResourceAllocationSettingData> items = Sets.newLinkedHashSet();
private Set<Link> links = Sets.newLinkedHashSet();
private URI href;
private String type;
/**
* @see VirtualHardwareSection#getSystem
@ -69,23 +85,31 @@ public class VirtualHardwareSection extends SectionType {
}
/**
* @see VirtualHardwareSection#getTransports
* @see VirtualHardwareSection#getTransport()
*/
public B transport(String transport) {
this.transports.add(checkNotNull(transport, "transport"));
this.transport = transport;
return self();
}
/**
* @see VirtualHardwareSection#getTransports
* @see VirtualHardwareSection#getTransport()
*/
public B transports(Iterable<String> transports) {
this.transports = ImmutableSet.<String>copyOf(checkNotNull(transports, "transports"));
public B transport(Iterable<String> transports) {
this.transport = Joiner.on(',').join(transports);
return self();
}
/**
* @see VirtualHardwareSection#getItems
* @see VirtualHardwareSection#getTransport()
*/
public B transport(String...transports) {
this.transport = Joiner.on(',').join(transports);
return self();
}
/**
* @see VirtualHardwareSection#getItems()
*/
public B item(ResourceAllocationSettingData item) {
this.items.add(checkNotNull(item, "item"));
@ -93,11 +117,42 @@ public class VirtualHardwareSection extends SectionType {
}
/**
* @see VirtualHardwareSection#getItems
* @see VirtualHardwareSection#getItems()
*/
public B items(Iterable<? extends ResourceAllocationSettingData> items) {
this.items = ImmutableSet.<ResourceAllocationSettingData>copyOf(checkNotNull(
items, "items"));
this.items = Sets.newLinkedHashSet(checkNotNull(items, "items"));
return self();
}
/**
* @see VirtualHardwareSection#getLinks()
*/
public B links(Set<Link> links) {
this.links = checkNotNull(links, "links");
return self();
}
/**
* @see VirtualHardwareSection#getLinks()
*/
public B link(Link link) {
this.links.add(checkNotNull(link, "link"));
return self();
}
/**
* @see VirtualHardwareSection#getHref()
*/
public B href(URI href) {
this.href = href;
return self();
}
/**
* @see VirtualHardwareSection#getType()
*/
public B type(String type) {
this.type = type;
return self();
}
@ -110,20 +165,38 @@ public class VirtualHardwareSection extends SectionType {
}
public B fromVirtualHardwareSection(VirtualHardwareSection in) {
return fromSectionType(in).items(in.getItems()).transports(in.getTransports()).system(
in.getSystem()).info(in.getInfo());
return fromSectionType(in)
.items(in.getItems())
.transport(in.getTransport())
.system(in.getSystem())
.links(Sets.newLinkedHashSet(in.getLinks()))
.href(in.getHref())
.type(in.getType());
}
}
@XmlElement(name = "System")
private VirtualSystemSettingData virtualSystem;
private Set<String> transports;
private Set<ResourceAllocationSettingData> items;
@XmlAttribute(name = "transport")
private String transport;
@XmlElement(name = "Item")
private Set<ResourceAllocationSettingData> items = Sets.newLinkedHashSet();
@XmlElement(name = "Link", namespace = VCLOUD_1_5_NS)
protected Set<Link> links = Sets.newLinkedHashSet();
@XmlAttribute(namespace = VCLOUD_1_5_NS)
@XmlSchemaType(name = "anyURI")
protected URI href;
@XmlAttribute(namespace = VCLOUD_1_5_NS)
protected String type;
private VirtualHardwareSection(Builder<?> builder) {
super(builder);
this.virtualSystem = builder.virtualSystem;
this.transports = ImmutableSet.<String>copyOf(checkNotNull(builder.transports, "transports"));
this.items = ImmutableSet.<ResourceAllocationSettingData>copyOf(checkNotNull(builder.items, "items"));
this.transport = builder.transport;
this.items = builder.items != null ? ImmutableSet.copyOf(builder.items) : Sets.<ResourceAllocationSettingData>newLinkedHashSet();
this.links = builder.links != null ? ImmutableSet.copyOf(builder.links) : Sets.<Link>newLinkedHashSet();
this.href = builder.href;
this.type = builder.type;
}
private VirtualHardwareSection() {
@ -131,9 +204,11 @@ public class VirtualHardwareSection extends SectionType {
}
/**
* transport types define methods by which the environment document is communicated from the
* Comma-separated list of supported transports types for the OVF descriptor.
*
* Transport types define methods by which the environment document is communicated from the
* deployment platform to the guest software.
* <p/>
* <p>
* To enable interoperability, this specification defines an "iso" transport type which all
* implementations that support CD-ROM devices are required to support. The iso transport
* communicates the environment 1346 document by making a dynamically generated ISO image
@ -141,27 +216,50 @@ public class VirtualHardwareSection extends SectionType {
* machine, an implementation shall make an ISO 9660 read-only disk image available as backing
* for a disconnected CD-ROM. If the iso transport is selected for a VirtualHardwareSection, at
* least one disconnected CD-ROM device shall be present in this section.
* <p/>
* <p>
* Support for the "iso" transport type is not a requirement for virtual hardware architectures
* or guest 1351 operating systems which do not have CD-ROM device support.
*
* @return
*/
public Set<String> getTransports() {
return transports;
public String getTransport() {
return transport;
}
public VirtualSystemSettingData getSystem() {
return virtualSystem;
}
public Set<? extends ResourceAllocationSettingData> getItems() {
return items;
public Set<ResourceAllocationSettingData> getItems() {
return ImmutableSet.copyOf(items);
}
/**
* Gets the value of the link property.
*/
public Set<Link> getLinks() {
return ImmutableSet.copyOf(links);
}
/**
* @return the value of the href property.
*/
public URI getHref() {
return href;
}
/**
* Gets the value of the type property.
*
* @return possible object is {@link String }
*/
public String getType() {
return type;
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), transports, virtualSystem, items);
return Objects.hashCode(super.hashCode(), transport, virtualSystem, items, links, href, type);
}
@Override
@ -169,15 +267,18 @@ public class VirtualHardwareSection extends SectionType {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
VirtualHardwareSection other = (VirtualHardwareSection) obj;
return super.equals(other) && Objects.equal(transports, other.transports)
&& Objects.equal(virtualSystem, other.virtualSystem)
&& Objects.equal(items, other.items);
VirtualHardwareSection that = VirtualHardwareSection.class.cast(obj);
return super.equals(that) &&
equal(this.transport, that.transport) &&
equal(this.virtualSystem, that.virtualSystem) &&
equal(this.items, that.items) &&
equal(this.links, that.links) &&
equal(this.href, that.href) &&
equal(this.type, that.type);
}
@Override
protected Objects.ToStringHelper string() {
return super.string().add("transports", transports).add("virtualSystem", virtualSystem).add("items", items);
return super.string().add("transport", transport).add("virtualSystem", virtualSystem).add("items", items).add("links", links).add("href", href).add("type", type);
}
}

View File

@ -19,14 +19,18 @@
@XmlSchema(namespace = VCLOUD_OVF_NS,
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS)
@XmlNs(prefix = "cim", namespaceURI = VCLOUD_CIM_NS),
@XmlNs(prefix = "vmv", namespaceURI = VCLOUD_VMW_NS),
@XmlNs(prefix = "vcloud", namespaceURI = VCLOUD_1_5_NS)
}
)
@XmlAccessorType(XmlAccessType.FIELD)
package org.jclouds.vcloud.director.v1_5.domain.ovf;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_CIM_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_OVF_NS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

View File

@ -43,6 +43,7 @@ public class ContainerType extends ResourceType {
return new ConcreteBuilder();
}
@Override
public Builder<?> toBuilder() {
return builder().fromContainerType(this);
}

View File

@ -45,30 +45,30 @@ import com.google.common.collect.Sets;
* @author grkvlt@apache.org
*/
@XmlRootElement(name = "QueryResultRecords")
public class QueryResultRecords<R extends QueryResultRecordType> extends ContainerType {
public class QueryResultRecords extends ContainerType {
public static final String MEDIA_TYPE = VCloudDirectorMediaType.QUERY_RESULT_RECORDS;
public static <R extends QueryResultRecordType> Builder<R, ?> builder() {
return new ConcreteBuilder<R>();
public static Builder<?> builder() {
return new ConcreteBuilder();
}
@Override
public Builder<R, ?> toBuilder() {
return QueryResultRecords.<R>builder().fromQueryResultRecords(this);
public Builder<?> toBuilder() {
return builder().fromQueryResultRecords(this);
}
private static class ConcreteBuilder<R extends QueryResultRecordType> extends Builder<R, ConcreteBuilder<R>> {
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
}
public static class Builder<R extends QueryResultRecordType, B extends Builder<R, B>> extends ContainerType.Builder<B> {
public static class Builder<B extends Builder<B>> extends ContainerType.Builder<B> {
private Set<R> records = Sets.newLinkedHashSet();
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
/**
* @see QueryResultRecords#getRecords()
*/
public B records(Set<? extends R> records) {
public B records(Set<QueryResultRecordType> records) {
this.records = Sets.newLinkedHashSet(checkNotNull(records, "records"));
return self();
}
@ -76,22 +76,22 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
/**
* @see QueryResultRecords#getRecords()
*/
public B record(R record) {
this.records.add(record);
public B record(QueryResultRecordType record) {
this.records.add(checkNotNull(record, "record"));
return self();
}
@Override
public QueryResultRecords<R> build() {
return new QueryResultRecords<R>(this);
public QueryResultRecords build() {
return new QueryResultRecords(this);
}
public B fromQueryResultRecords(QueryResultRecords<R> in) {
public B fromQueryResultRecords(QueryResultRecords in) {
return fromContainerType(in).records(in.getRecords());
}
}
protected QueryResultRecords(Builder<R,?> builder) {
protected QueryResultRecords(Builder<?> builder) {
super(builder);
this.records = ImmutableSet.copyOf(builder.records);
}
@ -101,12 +101,12 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
}
@XmlElementRef
private Set<R> records = Sets.newLinkedHashSet();
private Set<QueryResultRecordType> records = Sets.newLinkedHashSet();
/**
* Set of records representing query results.
*/
public Set<R> getRecords() {
public Set<QueryResultRecordType> getRecords() {
return Collections.unmodifiableSet(records);
}
@ -116,7 +116,7 @@ public class QueryResultRecords<R extends QueryResultRecordType> extends Contain
return true;
if (o == null || getClass() != o.getClass())
return false;
QueryResultRecords<?> that = QueryResultRecords.class.cast(o);
QueryResultRecords that = QueryResultRecords.class.cast(o);
return super.equals(that) && equal(this.records, that.records);
}

View File

@ -50,96 +50,96 @@ public interface AdminQueryAsyncClient extends QueryAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> groupsQueryAll();
ListenableFuture<QueryResultRecords> groupsQueryAll();
@GET
@Path("/admin/groups/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> groupsQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> groupsQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/orgs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> orgsQueryAll();
ListenableFuture<QueryResultRecords> orgsQueryAll();
@GET
@Path("/admin/orgs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> orgsQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> orgsQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/rights/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> rightsQueryAll();
ListenableFuture<QueryResultRecords> rightsQueryAll();
@GET
@Path("/admin/rights/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> rightsQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> rightsQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/roles/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> rolesQueryAll();
ListenableFuture<QueryResultRecords> rolesQueryAll();
@GET
@Path("/admin/roles/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> rolesQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> rolesQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/strandedUsers/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> strandedUsersQueryAll();
ListenableFuture<QueryResultRecords> strandedUsersQueryAll();
@GET
@Path("/admin/strandedUsers/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> strandedUsersQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> strandedUsersQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/users/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> usersQueryAll();
ListenableFuture<QueryResultRecords> usersQueryAll();
@GET
@Path("/admin/users/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> usersQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> usersQuery(@QueryParam("filter") String filter);
@GET
@Path("/admin/vdcs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> vdcsQueryAll();
ListenableFuture<QueryResultRecords> vdcsQueryAll();
@GET
@Path("/admin/vdcs/query")
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> vdcsQuery(@QueryParam("filter") String filter);
ListenableFuture<QueryResultRecords> vdcsQuery(@QueryParam("filter") String filter);
}

View File

@ -48,10 +48,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> groupsQueryAll();
QueryResultRecords groupsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> groupsQuery(String filter);
QueryResultRecords groupsQuery(String filter);
/**
* Retrieves a list of {@link Org}s by using REST API general QueryHandler.
@ -62,10 +62,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> orgsQueryAll();
QueryResultRecords orgsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> orgsQuery(String filter);
QueryResultRecords orgsQuery(String filter);
/**
* Retrieves a list of {@link Right}s by using REST API general QueryHandler.
@ -76,10 +76,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> rightsQueryAll();
QueryResultRecords rightsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> rightsQuery(String filter);
QueryResultRecords rightsQuery(String filter);
/**
* Retrieves a list of {@link Role}s by using REST API general QueryHandler.
@ -90,10 +90,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> rolesQueryAll();
QueryResultRecords rolesQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> rolesQuery(String filter);
QueryResultRecords rolesQuery(String filter);
/**
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
@ -104,10 +104,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> strandedUsersQueryAll();
QueryResultRecords strandedUsersQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> strandedUsersQuery(String filter);
QueryResultRecords strandedUsersQuery(String filter);
/**
* Retrieves a list of {@link User}s by using REST API general QueryHandler.
@ -118,10 +118,10 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> usersQueryAll();
QueryResultRecords usersQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> usersQuery(String filter);
QueryResultRecords usersQuery(String filter);
/**
* Retrieves a list of {@link Vdc}s by using REST API general QueryHandler.
@ -132,8 +132,8 @@ public interface AdminQueryClient extends QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> vdcsQueryAll();
QueryResultRecords vdcsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> vdcsQuery(String filter);
QueryResultRecords vdcsQuery(String filter);
}

View File

@ -67,13 +67,13 @@ public interface QueryClient {
* @see #query(String, String)
* @see #query(Integer, Integer, String, String, String)
*/
QueryResultRecords<QueryResultRecordType> queryAll(String type);
QueryResultRecords queryAll(String type);
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> query(String type, String filter);
QueryResultRecords query(String type, String filter);
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> query(Integer page, Integer pageSize, String format, String type, String filter);
QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter);
/**
* Retrieves a list of {@link Catalog}s by using REST API general QueryHandler.
@ -84,13 +84,13 @@ public interface QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> catalogsQueryAll();
QueryResultRecords catalogsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> catalogsQuery(String filter);
QueryResultRecords catalogsQuery(String filter);
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> catalogsQuery(Integer page, Integer pageSize, String filter);
QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String filter);
/**
@ -119,10 +119,10 @@ public interface QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> vAppTemplatesQueryAll();
QueryResultRecords vAppTemplatesQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> vAppTemplatesQuery(String filter);
QueryResultRecords vAppTemplatesQuery(String filter);
/**
* Retrieves a list of {@link VApp}s by using REST API general QueryHandler.
@ -133,27 +133,13 @@ public interface QueryClient {
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> vAppsQueryAll();
QueryResultRecords vAppsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> vAppsQuery(String filter);
QueryResultRecords vAppsQuery(String filter);
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> vAppsQuery(Integer page, Integer pageSize, String filter);
/**
* Retrieves a list of {@link Vm}s by using REST API general QueryHandler.
*
* <pre>
* GET /vms/query
* </pre>
*
* @see #queryAll(String)
*/
QueryResultRecords<QueryResultRecordType> vmsQueryAll();
/** @see #queryAll() */
QueryResultRecords<QueryResultRecordType> vmsQuery(String filter);
QueryResultRecords vAppsQuery(Integer page, Integer pageSize, String filter);
/**
* Retrieves a list of {@link VAppReference}s by using REST API general QueryHandler.
@ -172,5 +158,19 @@ public interface QueryClient {
/** @see #queryAll() */
VAppReferences vAppReferencesQuery(Integer page, Integer pageSize, String filter);
/**
* Retrieves a list of {@link Vm}s by using REST API general QueryHandler.
*
* <pre>
* GET /vms/query
* </pre>
*
* @see #queryAll(String)
*/
QueryResultRecords vmsQueryAll();
/** @see #queryAll() */
QueryResultRecords vmsQuery(String filter);
}

View File

@ -18,7 +18,27 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.*;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY_IMAGE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CONTROL_ACCESS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.DEPLOY_VAPP_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.MEDIA_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OPERATING_SYSTEM_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OVF_RASD_ITEM;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OVF_RASD_ITEMS_LIST;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OWNER;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RECOMPOSE_VAPP_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_VM_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.STARTUP_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.UNDEPLOY_VAPP_PARAMS;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VIRTUAL_HARDWARE_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VM_PENDING_ANSWER;
import java.net.URI;
@ -36,6 +56,7 @@ import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.binders.BindToXMLPayload;
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams;
@ -56,12 +77,13 @@ import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
@ -360,12 +382,6 @@ public interface VAppAsyncClient {
ListenableFuture<Task> insertMedia(@EndpointParam URI vmURI,
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
/**
* @return asynchronous access to {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
/**
* @see VAppClient#getNetworkConfigSection(URI)
*/
@ -403,7 +419,7 @@ public interface VAppAsyncClient {
*/
@PUT
@Path("/networkConnectionSection")
@Produces(NETWORK_CONFIG_SECTION)
@Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
@ -524,8 +540,8 @@ public interface VAppAsyncClient {
@GET
@Path("/screen")
@Consumes(ANY_IMAGE)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
@ResponseParser(ReturnPayloadBytes.class)
ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vAppURI);
/**
@ -590,10 +606,10 @@ public interface VAppAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<RASD> getVirtualHardwareSectionCpu(@EndpointParam URI vAppURI);
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionCpu(@EndpointParam URI vAppURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionCpu(URI, RASD)
* @see VAppClient#modifyVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/cpu")
@ -602,7 +618,7 @@ public interface VAppAsyncClient {
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> modifyVirtualHardwareSectionCpu(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) RASD rasd);
@BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd);
/**
* @see VAppClient#getVirtualHardwareSectionDisks(URI)
@ -644,10 +660,10 @@ public interface VAppAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<RASD> getVirtualHardwareSectionMemory(@EndpointParam URI vAppURI);
ListenableFuture<ResourceAllocationSettingData> getVirtualHardwareSectionMemory(@EndpointParam URI vAppURI);
/**
* @see VAppClient#modifyVirtualHardwareSectionMemory(URI, RASD)
* @see VAppClient#modifyVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData)
*/
@PUT
@Path("/virtualHardwareSection/memory")
@ -656,7 +672,7 @@ public interface VAppAsyncClient {
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> modifyVirtualHardwareSectionMemory(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) RASD rasd);
@BinderParam(BindToXMLPayload.class) ResourceAllocationSettingData rasd);
/**
* @see VAppClient#getVirtualHardwareSectionNetworkCards(URI)
@ -702,4 +718,10 @@ public interface VAppAsyncClient {
ListenableFuture<Task> modifyVirtualHardwareSectionSerialPorts(@EndpointParam URI vAppURI,
@BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList);
/**
* @return asynchronous access to {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
}

View File

@ -42,9 +42,9 @@ import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
@ -433,12 +433,6 @@ public interface VAppClient {
*/
Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams);
/**
* @return synchronous access to {@link Metadata} features
*/
@Delegate
MetadataClient.Writeable getMetadataClient();
/**
* Retrieves the network config section of a vApp or vApp template.
*
@ -680,7 +674,7 @@ public interface VAppClient {
*
* @since 0.9
*/
RASD getVirtualHardwareSectionCpu(URI vAppURI);
ResourceAllocationSettingData getVirtualHardwareSectionCpu(URI vAppURI);
/**
* Modifies the CPU properties in virtual hardware section of a VM.
@ -691,10 +685,10 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionCpu(URI vAppURI, RASD rasd);
Task modifyVirtualHardwareSectionCpu(URI vAppURI, ResourceAllocationSettingData rasd);
/**
* Retrieves a list of RASD items for disks from virtual hardware section of a VM.
* Retrieves a list of ResourceAllocationSettingData items for disks from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/disks
@ -716,7 +710,7 @@ public interface VAppClient {
Task modifyVirtualHardwareSectionDisks(URI vAppURI, RasdItemsList rasdItemsList);
/**
* Retrieves the list of RASD items that represents the floppies and CD/DVD drives in a VM.
* Retrieves the list of ResourceAllocationSettingData items that represents the floppies and CD/DVD drives in a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/media
@ -727,7 +721,7 @@ public interface VAppClient {
RasdItemsList getVirtualHardwareSectionMedia(URI vAppURI);
/**
* Retrieves the RASD item that contains memory information from virtual hardware section of a VM.
* Retrieves the ResourceAllocationSettingData item that contains memory information from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/memory
@ -735,7 +729,7 @@ public interface VAppClient {
*
* @since 0.9
*/
RASD getVirtualHardwareSectionMemory(URI vAppURI);
ResourceAllocationSettingData getVirtualHardwareSectionMemory(URI vAppURI);
/**
* Modifies the memory properties in virtual hardware section of a VM.
@ -746,10 +740,10 @@ public interface VAppClient {
*
* @since 0.9
*/
Task modifyVirtualHardwareSectionMemory(URI vAppURI, RASD rasd);
Task modifyVirtualHardwareSectionMemory(URI vAppURI, ResourceAllocationSettingData rasd);
/**
* Retrieves a list of RASD items for network cards from virtual hardware section of a VM.
* Retrieves a list of ResourceAllocationSettingData items for network cards from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/networkCards
@ -771,7 +765,7 @@ public interface VAppClient {
Task modifyVirtualHardwareSectionNetworkCards(URI vAppURI, RasdItemsList rasdItemsList);
/**
* Retrieves a list of RASD items for serial ports from virtual hardware section of a VM.
* Retrieves a list of ResourceAllocationSettingData items for serial ports from virtual hardware section of a VM.
*
* <pre>
* GET /vApp/{id}/virtualHardwareSection/serialPorts
@ -791,4 +785,10 @@ public interface VAppClient {
* @since 1.5
*/
Task modifyVirtualHardwareSectionSerialPorts(URI vAppURI, RasdItemsList rasdItemsList);
/**
* @return synchronous access to {@link Metadata} features
*/
@Delegate
MetadataClient.Writeable getMetadataClient();
}

View File

@ -44,6 +44,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
@ -362,5 +363,11 @@ public interface VAppTemplateAsyncClient {
ListenableFuture<Task> editProductSectionsForVAppTemplate(@EndpointParam URI templateURI,
@BinderParam(BindToXMLPayload.class) ProductSectionList sections);
// TODO shadowVms ?
// TODO shadowVms
/**
* @return asynchronous access to {@link Metadata} features
*/
@Delegate
MetadataAsyncClient.Writable getMetadataClient();
}

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
@ -155,46 +156,6 @@ public interface VAppTemplateClient {
*/
Task editVappTemplateLeaseSettingsSection(URI templateUri, LeaseSettingsSection section);
/**
* Retrieves the metadata associated with a vApp Template.
*
* @param templateUri the URI of the template
* @return the requested metadata
*/
Metadata getVAppTemplateMetadata(URI templateUri);
/**
* Merges the metadata for a vApp Template with the information provided.
*
* @param templateUri the URI of the template
* @return the task performing the action
*/
Task editVAppTemplateMetadata(URI templateUri, Metadata metadata);
/**
* Consolidates a VM
*
* @param templateUri the URI of the template
* @return the task performing the action
*/
MetadataValue getVAppTemplateMetadataValue(URI templateUri, String key);
/**
* Consolidates a VM
*
* @param templateUri the URI of the template
* @return the task performing the action
*/
Task editVAppTemplateMetadataValue(URI templateUri, String key, MetadataValue value);
/**
* Consolidates a VM
*
* @param templateUri the URI of the template
* @return the task performing the action
*/
Task deleteVAppTemplateMetadataValue(URI templateUri, String key);
/**
* Retrieves the network config section of a vApp or vApp template.
*
@ -269,5 +230,11 @@ public interface VAppTemplateClient {
*/
Task editProductSectionsForVAppTemplate(URI templateUri, ProductSectionList sections);
// TODO ShadowVms???
// TODO ShadowVms
/**
* @return synchronous access to {@link Metadata} features
*/
@Delegate
MetadataClient.Writeable getMetadataClient();
}

View File

@ -0,0 +1,45 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.director.v1_5.functions;
import java.io.IOException;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponse;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;
/**
* @author grkvlt@apache.org
*/
@Singleton
public class ReturnPayloadBytes implements Function<HttpResponse, byte[]> {
@Override
public byte[] apply(HttpResponse from) {
try {
return ByteStreams.toByteArray(from.getPayload().getInput());
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
}

View File

@ -32,7 +32,7 @@ import com.google.common.base.Predicate;
public class ReferenceTypePredicates {
/**
* Matches {@link Reference}s of the given name.
* Matches {@link Reference}s with the given name.
*
* @param T type of the reference, for example {@link Link}
* @param name value of the name attribute of the referenced object
@ -54,6 +54,30 @@ public class ReferenceTypePredicates {
};
}
/**
* Matches {@link Reference}s with names starting with the given prefix.
*
* @param T type of the reference, for example {@link Link}
* @param name prefix of the name attribute of the referenced object
* @return predicate that will match references with names starting with the given prefix
*/
public static <T extends Reference> Predicate<T> nameStartsWith(final String prefix) {
checkNotNull(prefix, "prefix must be defined");
return new Predicate<T>() {
@Override
public boolean apply(T reference) {
String name = reference.getName();
return name != null && name.startsWith(prefix);
}
@Override
public String toString() {
return "nameStartsWith(" + prefix + ")";
}
};
}
/**
* Matches {@link Reference}s of the given type.
*

View File

@ -25,7 +25,7 @@ public class VCloudDirectorLiveTestConstants {
/* regular expressions for pattern matching */
public static final String MAC_ADDRESS_PATTERN = "^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$";
public static final String MAC_ADDRESS_PATTERN = "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$";
/* Error code 200 indicates success. */

View File

@ -58,7 +58,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
@ -483,7 +482,7 @@ public class Checks {
public static void checkMacAddress(String macAddress) {
// Check the string is a valid MAC address
assertNotNull(macAddress, String.format(NOT_EMPTY_STRING_FMT, "macAddress"));
assertTrue(macAddress.toUpperCase().matches(MAC_ADDRESS_PATTERN), String.format(MATCHES_STRING_FMT, "macAddress", MAC_ADDRESS_PATTERN, macAddress));
assertTrue(macAddress.matches(MAC_ADDRESS_PATTERN), String.format(MATCHES_STRING_FMT, "macAddress", MAC_ADDRESS_PATTERN, macAddress));
}
public static void checkComputeCapacity(ComputeCapacity computeCapacity) {
@ -597,6 +596,25 @@ public class Checks {
}
return result;
}
public static void checkVmPendingQuestion(VmPendingQuestion question) {
// Check required fields
assertNotNull(question.getQuestion(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "Question"));
assertNotNull(question.getQuestionId(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "QuestionId"));
for (VmQuestionAnswerChoice choice : question.getChoices()) {
checkVmQuestionAnswerChoice(choice);
}
// Check parent type
checkResourceType(question);
}
public static void checkVmQuestionAnswerChoice(VmQuestionAnswerChoice choice) {
assertNotNull(choice, String.format(NOT_NULL_OBJ_FMT, "VmQuestionAnswerChoice"));
// NOTE the Id field cannot be checked
// NOTE the Text field cannot be checked
}
public static void checkVApp(VApp vApp) {
// Check optional fields
@ -727,11 +745,7 @@ public class Checks {
// Check optional fields
VirtualSystemSettingData virtualSystem = hardware.getSystem();
if (virtualSystem != null) checkVirtualSystemSettingData(virtualSystem);
if (hardware.getTransports() != null) {
for (String transport : hardware.getTransports()) {
// NOTE transport cannot be checked
}
}
// NOTE transport cannot be checked
if (hardware.getItems() != null) {
for (ResourceAllocationSettingData item : hardware.getItems()) {
checkResourceAllocationSettingData(item);
@ -1237,17 +1251,12 @@ public class Checks {
}
}
public static void checkRASD(RASD rasd) {
// Check fields
// TODO
}
public static void checkRasdItemsList(RasdItemsList items) {
// Check fields
// TODO
for (RASD item : items.getItems()) {
checkRASD(item);
for (ResourceAllocationSettingData item : items.getItems()) {
checkResourceAllocationSettingData(item);
}
}

View File

@ -0,0 +1,283 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().regarding copyright ownership. jclouds 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(Link.builder().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.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkGuestCustomizationSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConnectionSection;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URI;
import java.util.List;
import java.util.Random;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimBoolean;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimString;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedInt;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedLong;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
import org.jclouds.xml.internal.JAXBParser;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
/**
* Shared code to test the behaviour of {@link VAppClient} and {@link VAppTemplateClient}.
*
* @author grkvlt@apache.org
*/
public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String VAPP = "vApp";
public static final String VAPP_TEMPLATE = "vAppTemplate";
public static final String VDC = "vdc";
/*
* Convenience reference to API clients.
*/
protected CatalogClient catalogClient;
protected QueryClient queryClient;
protected VAppClient vAppClient;
protected VAppTemplateClient vAppTemplateClient;
protected VdcClient vdcClient;
protected MetadataClient.Writeable metadataClient;
/*
* Objects shared between tests.
*/
protected Vdc vdc;
protected Vm vm;
protected URI vAppURI;
protected VApp vApp;
protected VAppTemplate vAppTemplate;
protected final Random random = new Random();
/**
* Retrieves the required clients from the REST API context
*
* @see BaseVCloudDirectorClientLiveTest#setupRequiredClients()
*/
@BeforeClass(inheritGroups = true, description = "Retrieves the required clients from the REST API context")
@Override
protected void setupRequiredClients() {
assertNotNull(context.getApi());
catalogClient = context.getApi().getCatalogClient();
queryClient = context.getApi().getQueryClient();
vAppClient = context.getApi().getVAppClient();
vAppTemplateClient = context.getApi().getVAppTemplateClient();
vdcClient = context.getApi().getVdcClient();
}
/**
* Cleans up the environment.
*
* Retrieves the test {@link Vdc} and {@link VAppTemplate} from their configured {@link URI}s. Cleans up
* existing {@link VApp}s and instantiates a new test VApp.
*
* @see #cleanUp()
*/
@BeforeClass(inheritGroups = true, description = "Cleans up the environment")
protected void setupEnvironment() {
// Get the configured Vdc for the tests
vdc = vdcClient.getVdc(vdcURI);
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
// Get the configured VAppTemplate for the tests
vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
// Clean up after previous test runs
cleanUp();
// Instantiate a new VApp
VApp vAppInstantiated = instantiateVApp();
assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP));
vAppURI = vAppInstantiated.getHref();
// Wait for the task to complete
Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask"));
// Get the instantiated VApp
vApp = vAppClient.getVApp(vAppURI);
// Get the Vm
List<Vm> vms = vApp.getChildren().getVms();
vm = Iterables.getOnlyElement(vms);
assertFalse(vms.isEmpty(), "The VApp must have at least one Vm");
}
protected void getGuestCustomizationSection(Function<URI, GuestCustomizationSection> getGuestCustomizationSection) {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
try {
GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI);
// Check the retrieved object is well formed
checkGuestCustomizationSection(section);
} catch (Exception e) {
Throwables.propagate(e);
}
}
protected void getNetworkConnectionSection(Function<URI, NetworkConnectionSection> getNetworkConnectionSection) {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
try {
NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI);
// Check the retrieved object is well formed
checkNetworkConnectionSection(section);
} catch (Exception e) {
Throwables.propagate(e);
}
}
// NOTE This method is also called by the BeforeClass method setupRequiredClients
@AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps named 'test-vapp-*' or 'new-name-*'")
protected void cleanUp() {
// Find references in the Vdc with the VApp type and named 'test-vapp' or 'new-name'
Iterable<Reference> vApps = Iterables.filter(
vdc.getResourceEntities().getResourceEntities(),
Predicates.and(
ReferenceTypePredicates.<Reference>typeEquals(VCloudDirectorMediaType.VAPP),
Predicates.or(
ReferenceTypePredicates.<Reference>nameStartsWith("test-vapp-"),
ReferenceTypePredicates.<Reference>nameStartsWith("new-name-")
)
)
);
// If we found any references, delete the VApp they point to
if (vApps != null && !Iterables.isEmpty(vApps)) {
for (Reference ref : vApps) {
VApp found = vAppClient.getVApp(ref.getHref());
// debug(found);
// Shutdown and power off the VApp if necessary
if (found.getStatus().equals(Status.POWERED_ON.getValue())) {
Task shutdownTask = vAppClient.shutdown(found.getHref());
retryTaskSuccess.apply(shutdownTask);
}
// Undeploy the VApp if necessary
if (found.isDeployed()) {
UndeployVAppParams params = UndeployVAppParams.builder().build();
Task undeployTask = vAppClient.undeploy(found.getHref(), params);
retryTaskSuccess.apply(undeployTask);
}
// Delete the VApp
Task deleteTask = vAppClient.deleteVApp(found.getHref());
retryTaskSuccess.apply(deleteTask);
}
}
}
protected static CimBoolean cimBoolean(boolean val) {
CimBoolean result = new CimBoolean();
result.setValue(val);
return result;
}
protected static CimUnsignedInt cimUnsignedInt(long val) {
CimUnsignedInt result = new CimUnsignedInt();
result.setValue(val);
return result;
}
protected static CimUnsignedLong cimUnsignedLong(BigInteger val) {
CimUnsignedLong result = new CimUnsignedLong();
result.setValue(val);
return result;
}
protected static CimString cimString(String value) {
return new CimString(value);
}
protected void checkHasMatchingItem(final String context, final RasdItemsList items, final String instanceId, final String elementName) {
Optional<ResourceAllocationSettingData> found = Iterables.tryFind(items.getItems(), new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData item) {
String itemInstanceId = item.getInstanceID();
if (itemInstanceId.equals(instanceId)) {
Assert.assertEquals(item.getElementName(), elementName,
String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId + "/elementName", elementName, item.getElementName()));
return true;
}
return false;
}
});
assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId + "; only found " + items);
}
/**
* Marshals a JAXB annotated object into XML. The XML is output on {@link System#err}.
*/
protected void debug(Object object) {
JAXBParser parser = new JAXBParser();
try {
String xml = parser.toXML(object);
System.err.println(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-'));
System.err.println(xml);
System.err.println(Strings.repeat("-", 80));
} catch (IOException ioe) {
Throwables.propagate(ioe);
}
}
}

View File

@ -66,7 +66,7 @@ public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpe
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
QueryResultRecords expected = QueryResultRecords.builder()
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/groups/query?page=1&pageSize=25&format=records"))
.type("application/vnd.vmware.vcloud.query.records+xml")
.name("group")
@ -114,7 +114,7 @@ public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpe
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
QueryResultRecords expected = QueryResultRecords.builder()
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/roles/query?page=1&pageSize=25&format=records"))
.type("application/vnd.vmware.vcloud.query.records+xml")
.name("role")

View File

@ -55,7 +55,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/groups/query")
public void testQueryAllGroups() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.groupsQueryAll();
QueryResultRecords resultRecords = queryClient.groupsQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -65,7 +65,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/orgs/query")
public void testQueryAllOrgs() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.orgsQueryAll();
QueryResultRecords resultRecords = queryClient.orgsQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -75,7 +75,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/rights/query")
public void testQueryAllRights() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rightsQueryAll();
QueryResultRecords resultRecords = queryClient.rightsQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -86,7 +86,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/roles/query")
public void testQueryAllRoles() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.rolesQueryAll();
QueryResultRecords resultRecords = queryClient.rolesQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -97,7 +97,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/strandedUsers/query")
public void testQueryAllStrandedUsers() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.strandedUsersQueryAll();
QueryResultRecords resultRecords = queryClient.strandedUsersQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -108,7 +108,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/users/query")
public void testQueryAllUsers() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.usersQueryAll();
QueryResultRecords resultRecords = queryClient.usersQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);
@ -119,7 +119,7 @@ public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /admin/vdcs/query")
public void testQueryAllVdc() {
// TODO Ensure there will be at least one record, for asserting result
QueryResultRecords<QueryResultRecordType> resultRecords = queryClient.vdcsQueryAll();
QueryResultRecords resultRecords = queryClient.vdcsQueryAll();
for (QueryResultRecordType record : resultRecords.getRecords()) {
Checks.checkQueryResultRecord(record);

View File

@ -63,7 +63,7 @@ public class QueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, queryRequest, queryResponse);
QueryResultRecords<?> expected = QueryResultRecords.<QueryResultRecordType>builder()
QueryResultRecords expected = QueryResultRecords.builder()
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogs/query?page=1&pageSize=25&format=records"))
.type("application/vnd.vmware.vcloud.query.records+xml")
.name("catalog")

View File

@ -113,7 +113,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /catalogs/query")
public void testQueryAllCatalogs() {
QueryResultRecords<?> catalogRecords = queryClient.catalogsQueryAll();
QueryResultRecords catalogRecords = queryClient.catalogsQueryAll();
assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords"));
}
@ -125,7 +125,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vAppTemplates/query")
public void testQueryAllVAppTemplates() {
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQueryAll();
QueryResultRecords queryResult = queryClient.vAppTemplatesQueryAll();
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
@ -135,7 +135,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vAppTemplates/query?filter)")
public void testQueryVAppTemplatesWithFilter() {
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
QueryResultRecords<?> queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
QueryResultRecords queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
@ -146,7 +146,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void testQueryAllVApps() {
vApp = instantiateVApp();
QueryResultRecords<?> queryResult = queryClient.vAppsQueryAll();
QueryResultRecords queryResult = queryClient.vAppsQueryAll();
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
@ -155,7 +155,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" } )
public void testQueryVAppsWithFilter() {
QueryResultRecords<?> queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
QueryResultRecords queryResult = queryClient.vAppsQuery(String.format("name==%s", vApp.getName()));
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class);
@ -179,7 +179,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Set<URI> vmHrefs = toHrefs(vms);
// Method under test: do the query
QueryResultRecords<?> queryResult = queryClient.vmsQueryAll();
QueryResultRecords queryResult = queryClient.vmsQueryAll();
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
@ -191,21 +191,21 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
List<Vm> vms = vApp.getChildren().getVms();
Set<URI> vmHrefs = toHrefs(vms);
QueryResultRecords<?> queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
QueryResultRecords queryResult = queryClient.vmsQuery(String.format("containerName==%s", vApp.getName()));
Set<URI> hrefs = toHrefs(queryResult);
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class);
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs);
}
private static void assertRecordTypes(QueryResultRecords<?> queryResult, Collection<String> validTypes, Class<?> validClazz) {
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class validClazz) {
for (QueryResultRecordType record : queryResult.getRecords()) {
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes);
assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz);
}
}
private Set<URI> toHrefs(QueryResultRecords<?> queryResult) {
private Set<URI> toHrefs(QueryResultRecords queryResult) {
Set<URI> hrefs = new LinkedHashSet<URI>();
for (QueryResultRecordType record : queryResult.getRecords()) {
hrefs.add(record.getHref());

View File

@ -46,9 +46,9 @@ import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.VmQuestionAnswer;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
@ -898,7 +898,7 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.xmlFilePayload("/vApp/getVirtualHardwareSectionCpu.xml", VCloudDirectorMediaType.OVF_RASD_ITEM)
.httpResponseBuilder().build());
RASD expected = getVirtualHardwareSectionCpu();
ResourceAllocationSettingData expected = getVirtualHardwareSectionCpu();
assertEquals(client.getVAppClient().getVirtualHardwareSectionCpu(vAppURI), expected);
}
@ -915,7 +915,7 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionCpuTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RASD cpu = getVirtualHardwareSectionCpu(); // .toBuilder();
ResourceAllocationSettingData cpu = getVirtualHardwareSectionCpu(); // .toBuilder();
// .build();
Task expected = modifyVirtualHardwareSectionCpuTask();
@ -986,7 +986,7 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.xmlFilePayload("/vApp/getVirtualHardwareSectionMemory.xml", VCloudDirectorMediaType.OVF_RASD_ITEM)
.httpResponseBuilder().build());
RASD expected = getVirtualHardwareSectionMemory();
ResourceAllocationSettingData expected = getVirtualHardwareSectionMemory();
assertEquals(client.getVAppClient().getVirtualHardwareSectionMemory(vAppURI), expected);
}
@ -1003,7 +1003,7 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
.xmlFilePayload("/vApp/modifyVirtualHardwareSectionMemoryTask.xml", VCloudDirectorMediaType.TASK)
.httpResponseBuilder().build());
RASD memory = getVirtualHardwareSectionCpu(); // .toBuilder();
ResourceAllocationSettingData memory = getVirtualHardwareSectionCpu(); // .toBuilder();
// .build();
Task expected = modifyVirtualHardwareSectionMemoryTask();
@ -1414,8 +1414,8 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
return task;
}
public static RASD getVirtualHardwareSectionCpu() {
RASD cpu = RASD.builder()
public static ResourceAllocationSettingData getVirtualHardwareSectionCpu() {
ResourceAllocationSettingData cpu = ResourceAllocationSettingData.builder()
.build();
return cpu;
@ -1449,8 +1449,8 @@ public class VAppClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
return media;
}
public static RASD getVirtualHardwareSectionMemory() {
RASD memory = RASD.builder()
public static ResourceAllocationSettingData getVirtualHardwareSectionMemory() {
ResourceAllocationSettingData memory = ResourceAllocationSettingData.builder()
.build();
return memory;

View File

@ -20,7 +20,7 @@ package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_EQUAL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MATCHES_STRING_FMT;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ADMIN_USER;
@ -37,27 +37,27 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkSection
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOperatingSystemSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOwner;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkProductSectionList;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkRASD;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkRasdItemsList;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceAllocationSettingData;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkRuntimeInfoSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkScreenTicket;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkStartupSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVApp;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVirtualHardwareSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVmPendingQuestion;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URI;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AccessSetting;
import org.jclouds.vcloud.director.v1_5.domain.AccessSettings;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
@ -70,6 +70,8 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
@ -83,102 +85,48 @@ import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.VmPendingQuestion;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimString;
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedInt;
import org.jclouds.vcloud.director.v1_5.domain.cim.OSType;
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
import org.jclouds.vcloud.director.v1_5.domain.ovf.MsgType;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
import org.jclouds.xml.internal.JAXBParser;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicates;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
/**
* Tests behavior of {@code VAppClient}
*
* Tests behavior of the {@link VAppClient}.
*
* @author grkvlt@apache.org
*/
@Test(groups = { "live", "user", "vapp" }, singleThreaded = true, testName = "VAppClientLiveTest")
public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/*
* Convenience reference to API clients.
*/
protected CatalogClient catalogClient;
protected OrgClient orgClient;
protected VAppClient vAppClient;
protected VAppTemplateClient vAppTemplateClient;
protected VdcClient vdcClient;
protected MetadataClient.Writeable metadataClient;
/*
* Objects shared between tests.
*/
private Vdc vdc;
private VApp vApp;
private VAppTemplate vAppTemplate;
private final Random random = new Random();
@BeforeClass(inheritGroups = true)
@Override
public void setupRequiredClients() {
catalogClient = context.getApi().getCatalogClient();
orgClient = context.getApi().getOrgClient();
vAppClient = context.getApi().getVAppClient();
vAppTemplateClient = context.getApi().getVAppTemplateClient();
vdcClient = context.getApi().getVdcClient();
metadataClient = vAppClient.getMetadataClient();
}
@BeforeClass(inheritGroups = true)
public void setupEnvironment() throws Exception {
vdc = vdcClient.getVdc(vdcURI);
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
cleanUp();
}
public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
/**
* @see VAppClient#getVApp(URI)
*/
@Test(testName = "GET /vApp/{id}")
public void testGetVApp() {
VApp vAppInstantiated = instantiateVApp("test-vapp");
// Wait for the task to complete
Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask"));
// The method under test
vApp = vAppClient.getVApp(vAppInstantiated.getHref());
vApp = vAppClient.getVApp(vAppURI);
// Check the retrieved object is well formed
checkVApp(vApp);
// Check the required fields are set
assertEquals(vApp.isDeployed(), Boolean.FALSE, String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString()));
assertEquals(vApp.getName(), "test-vapp", String.format(OBJ_FIELD_EQ, VAPP, "name", "test-vapp", vApp.getName()));
assertTrue(vApp.getName().startsWith("test-vapp-"), String.format(MATCHES_STRING_FMT, "name", "test-vapp-*", vApp.getName()));
assertEquals(vApp.getDescription(), "Test VApp", String.format(OBJ_FIELD_EQ, VAPP, "Description", "Test VApp", vApp.getDescription()));
// TODO instantiationParams instantiationParams()
@ -194,7 +142,10 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
*/
@Test(testName = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testModifyVApp() {
VApp newVApp = VApp.builder().name("new-name").description("New Description").build();
VApp newVApp = VApp.builder()
.name("new-name-" + Integer.toString(random.nextInt(Integer.MAX_VALUE)))
.description("New Description")
.build();
// The method under test
Task modifyVApp = vAppClient.modifyVApp(vApp.getHref(), newVApp);
@ -383,7 +334,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertTrue(retryTaskSuccess.apply(discardSuspendedState), String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState"));
}
@Test(testName = "POST /vApp/{id}/action/enterMaintenanceMode", dependsOnMethods = { "testGetVApp" })
@Test(testName = "POST /vApp/{id}/action/enterMaintenanceMode", dependsOnMethods = { "testPowerOnVApp" })
public void testEnterMaintenanceMode() {
// The method under test
vAppClient.enterMaintenanceMode(vApp.getHref());
@ -401,7 +352,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertFalse(vApp.isInMaintenanceMode(), String.format(CONDITION_FMT, "InMaintenanceMode", "FALSE", vApp.isInMaintenanceMode()));
}
@Test(testName = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testGetVApp" })
@Test(testName = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testPowerOnVApp" })
public void testInstallVMwareTools() {
// The method under test
Task installVMwareTools = vAppClient.installVMwareTools(vApp.getHref());
@ -424,7 +375,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "POST /vApp/{id}/action/relocate", dependsOnMethods = { "testGetVApp" })
public void testRelocate() {
// Relocate to the last of the available datastores
QueryResultRecords<?> records = context.getApi().getQueryClient().queryAll("datastore");
QueryResultRecords records = context.getApi().getQueryClient().queryAll("datastore");
QueryResultRecordType datastore = Iterables.getLast(records.getRecords());
RelocateParams params = RelocateParams.builder().datastore(Reference.builder().href(datastore.getHref()).build()).build();
@ -451,14 +402,12 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVApp" })
public void testGetGuestCustomizationSection() {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
GuestCustomizationSection section = vAppClient.getGuestCustomizationSection(vmURI);
// Check the retrieved object is well formed
checkGuestCustomizationSection(section);
getGuestCustomizationSection(new Function<URI, GuestCustomizationSection>() {
@Override
public GuestCustomizationSection apply(URI uri) {
return vAppClient.getGuestCustomizationSection(uri);
}
});
}
@Test(testName = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" })
@ -470,6 +419,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
GuestCustomizationSection oldSection = vAppClient.getGuestCustomizationSection(vmURI);
GuestCustomizationSection newSection = oldSection.toBuilder()
.computerName("newComputerName")
.enabled(Boolean.FALSE)
.adminPassword(null) // Not allowed
.build();
@ -485,6 +435,10 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Check the modified section fields are set correctly
assertEquals(modified.getComputerName(), newSection.getComputerName());
assertFalse(modified.isEnabled());
// Reset the admin password in the retrieved GuestCustomizationSection for equality check
modified = modified.toBuilder().adminPassword(null).build();
// Check the section was modified correctly
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "GuestCustomizationSection"));
@ -610,25 +564,31 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVApp" })
public void testGetNetworkConnectionSection() {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
NetworkConnectionSection section = vAppClient.getNetworkConnectionSection(vmURI);
// Check the retrieved object is well formed
checkNetworkConnectionSection(section);
getNetworkConnectionSection(new Function<URI, NetworkConnectionSection>() {
@Override
public NetworkConnectionSection apply(URI uri) {
return vAppClient.getNetworkConnectionSection(uri);
}
});
}
// FIXME "Task error: Unable to perform this action. Contact your cloud administrator."
@Test(testName = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetNetworkConnectionSection" })
public void testModifyNetworkConnectionSection() {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Look up a network in the Vdc
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
Reference network = Iterables.getLast(networks);
// Copy existing section and update fields
NetworkConnectionSection oldSection = vAppClient.getNetworkConnectionSection(vmURI);
NetworkConnectionSection newSection = oldSection.toBuilder()
.info("Changed NetworkConnectionSection Info")
.networkConnection(NetworkConnection.builder()
.ipAddressAllocationMode(IpAddressAllocationMode.DHCP.toString())
.network(network.getName())
.build())
.build();
// The method under test
@ -641,8 +601,8 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Check the retrieved object is well formed
checkNetworkConnectionSection(modified);
// Check the modified section fields are set correctly
assertEquals(modified.getInfo(), newSection.getInfo());
// Check the modified section has an extra network connection
assertEquals(modified.getNetworkConnections().size(), newSection.getNetworkConnections().size() + 1);
// Check the section was modified correctly
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "NetworkConnectionSection"));
@ -674,14 +634,12 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Copy existing section and update fields
OperatingSystemSection oldSection = vAppClient.getOperatingSystemSection(vmURI);
OperatingSystemSection newSection = oldSection.toBuilder()
.info("Changed OperatingSystemSection Description")
.description("Changed OperatingSystemSection Description")
// Create new OperatingSystemSection
OperatingSystemSection newSection = OperatingSystemSection.builder()
.info("") // NOTE Required OVF field, ignored
.id(OSType.RHEL_64.getCode())
.osType("rhel5_64Guest")
.build();
debug(newSection);
assertNotNull(newSection.getId());
// The method under test
Task modifyOperatingSystemSection = vAppClient.modifyOperatingSystemSection(vmURI, newSection);
@ -694,11 +652,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
checkOperatingSystemSection(modified);
// Check the modified section fields are set correctly
assertEquals(modified.getInfo(), newSection.getInfo());
assertEquals(modified.getDescription(), newSection.getDescription());
// Check the section was modified correctly
assertEquals(modified, newSection, String.format(ENTITY_EQUAL, "OperatingSystemSection"));
assertEquals(modified.getId(), newSection.getId());
}
@Test(testName = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" })
@ -738,27 +692,43 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" })
public void testModifyProductSections() {
ProductSectionList origSections = vAppClient.getProductSections(vApp.getHref());
ProductSectionList newSections = origSections.toBuilder().build();
// Copy existing section and update fields
ProductSectionList oldSections = vAppClient.getProductSections(vApp.getHref());
ProductSectionList newSections = oldSections.toBuilder()
.productSection(ProductSection.builder()
.info("Information about the installed software") // Default ovf:Info text
.required()
.product(MsgType.builder().value("jclouds").build())
.vendor(MsgType.builder().value("jclouds Inc.").build())
// NOTE other ProductSection elements not returned by vCloud
.build())
.build();
// The method under test
Task modifyProductSections = vAppClient.modifyProductSections(vApp.getHref(), newSections);
assertTrue(retryTaskSuccess.apply(modifyProductSections), String.format(TASK_COMPLETE_TIMELY, "modifyProductSections"));
ProductSectionList modifiedList = vAppClient.getProductSections(vApp.getHref());
Checks.checkProductSectionList(modifiedList);
// TODO What to modify, to confirm that changes took effect?
// Retrieve the modified section
ProductSectionList modified = vAppClient.getProductSections(vApp.getHref());
// Check the retrieved object is well formed
checkProductSectionList(modified);
// Check the modified object has an extra ProductSection
assertEquals(modified.getProductSections().size(), oldSections.getProductSections().size() + 1);
// Check the section was modified correctly
assertEquals(modified, newSections, String.format(ENTITY_EQUAL, "ProductSectionList"));
}
@Test(testName = "GET /vApp/{id}/question", dependsOnMethods = { "testGetVApp" })
@Test(testName = "GET /vApp/{id}/question", dependsOnMethods = { "testPowerOnVApp" })
public void testGetPendingQuestion() {
// TODO how to test?
// The method under test
VmPendingQuestion question = vAppClient.getPendingQuestion(vApp.getHref());
// Check the retrieved object is well formed
// checkQuestion(question);
checkVmPendingQuestion(question);
}
@Test(testName = "PUT /vApp/{id}/question/action/answer", dependsOnMethods = { "testGetPendingQuestion" })
@ -784,10 +754,13 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
checkRuntimeInfoSection(section);
}
@Test(testName = "GET /vApp/{id}/screen", dependsOnMethods = { "testGetVApp" })
@Test(testName = "GET /vApp/{id}/screen", dependsOnMethods = { "testPowerOnVApp" })
public void testGetScreenImage() {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
byte[] image = vAppClient.getScreenImage(vApp.getHref());
byte[] image = vAppClient.getScreenImage(vmURI);
// Check returned bytes against PNG header magic number
byte[] pngHeaderBytes = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
@ -800,8 +773,11 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testGetVApp" })
public void testGetScreenTicket() {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// The method under test
ScreenTicket ticket = vAppClient.getScreenTicket(vApp.getHref());
ScreenTicket ticket = vAppClient.getScreenTicket(vmURI);
// Check the retrieved object is well formed
checkScreenTicket(ticket);
@ -856,21 +832,45 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Copy existing section and update fields
VirtualHardwareSection oldSection = vAppClient.getVirtualHardwareSection(vmURI);
VirtualHardwareSection newSection = oldSection.toBuilder().build();
Set<ResourceAllocationSettingData> oldItems = oldSection.getItems();
ResourceAllocationSettingData oldMemory = Iterables.find(oldItems, new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData rasd) {
return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
}
});
ResourceAllocationSettingData newMemory = oldMemory.toBuilder()
.elementName("1024 MB of memory")
.virtualQuantity(BigInteger.valueOf(1024L))
.build();
Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems);
newItems.remove(oldMemory);
newItems.add(newMemory);
VirtualHardwareSection newSection = oldSection.toBuilder()
.items(newItems)
.build();
// The method under test
Task modifyVirtualHardwareSection = vAppClient.modifyVirtualHardwareSection(vmURI, newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSection), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSection"));
// Retrieve the modified section
VirtualHardwareSection modified = vAppClient.getVirtualHardwareSection(vmURI);
VirtualHardwareSection modifiedSection = vAppClient.getVirtualHardwareSection(vmURI);
// Check the retrieved object is well formed
checkVirtualHardwareSection(modified);
checkVirtualHardwareSection(modifiedSection);
// Check the modified section fields are set correctly
// assertEquals(modified.getX(), "");
assertEquals(modified, newSection);
Set<ResourceAllocationSettingData> modifiedItems = modifiedSection.getItems();
ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedItems, new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData rasd) {
return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
}
});
assertEquals(modifiedMemory.getVirtualQuantity(), BigInteger.valueOf(1024L));
assertEquals(modifiedMemory, newMemory);
assertEquals(modifiedSection, newSection);
}
@Test(testName = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" })
@ -878,8 +878,11 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
checkRASD(rasd);
// Method under test
ResourceAllocationSettingData rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Check the retrieved object is well formed
checkResourceAllocationSettingData(rasd);
}
@Test(testName = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" })
@ -887,24 +890,26 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
RASD origSection = vAppClient.getVirtualHardwareSectionCpu(vmURI);
RASD newSection = origSection.toBuilder().build();
// Copy existing section and update fields
ResourceAllocationSettingData oldItem = vAppClient.getVirtualHardwareSectionCpu(vmURI);
ResourceAllocationSettingData newItem = oldItem.toBuilder()
.build();
// Method under test
Task modifyVirtualHardwareSectionCpu = vAppClient.modifyVirtualHardwareSectionCpu(vmURI, newSection);
Task modifyVirtualHardwareSectionCpu = vAppClient.modifyVirtualHardwareSectionCpu(vmURI, newItem);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionCpu), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionCpu"));
// Retrieve the modified section
RASD modified = vAppClient.getVirtualHardwareSectionCpu(vmURI);
ResourceAllocationSettingData modified = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Check the retrieved object
checkRASD(modified);
checkResourceAllocationSettingData(modified);
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "weight", but it continued to have the value zero when looked up post-modify.
//
// long weight = random.nextInt(Integer.MAX_VALUE);
// RASD newSection = origSection.toBuilder()
// ResourceAllocationSettingData newSection = origSection.toBuilder()
// .weight(newCimUnsignedInt(weight))
// .build();
// ...
@ -916,6 +921,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionDisks(vmURI);
// Check the retrieved object is well formed
@ -944,8 +950,8 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "elementName" of one of the items, but it continued to have the old value when looked up post-modify.
//
// List<RASD> newItems = new ArrayList<RASD>(oldSection.getItems());
// RASD item0 = newItems.get(0);
// List<ResourceAllocationSettingData> newItems = new ArrayList<ResourceAllocationSettingData>(oldSection.getItems());
// ResourceAllocationSettingData item0 = newItems.get(0);
// String item0InstanceId = item0.getInstanceID().getValue();
// String item0ElementName = item0.getElementName().getValue()+"-"+random.nextInt(Integer.MAX_VALUE);
// newItems.set(0, item0.toBuilder().elementName(newCimString(item0ElementName)).build());
@ -954,7 +960,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// .build();
// ...
// long weight = random.nextInt(Integer.MAX_VALUE);
// RASD newSection = origSection.toBuilder()
// ResourceAllocationSettingData newSection = origSection.toBuilder()
// .weight(newCimUnsignedInt(weight))
// .build();
// ...
@ -966,6 +972,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionMedia(vmURI);
// Check the retrieved object is well formed
@ -977,10 +984,11 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Method under test
ResourceAllocationSettingData rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Check the retrieved object is well formed
checkRASD(rasd);
checkResourceAllocationSettingData(rasd);
}
@Test(testName = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" })
@ -988,18 +996,18 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
RASD origSection = vAppClient.getVirtualHardwareSectionMemory(vmURI);
RASD newSection = origSection.toBuilder().build();
ResourceAllocationSettingData origSection = vAppClient.getVirtualHardwareSectionMemory(vmURI);
ResourceAllocationSettingData newSection = origSection.toBuilder().build();
// Method under test
Task modifyVirtualHardwareSectionMemory = vAppClient.modifyVirtualHardwareSectionMemory(vmURI, newSection);
assertTrue(retryTaskSuccess.apply(modifyVirtualHardwareSectionMemory), String.format(TASK_COMPLETE_TIMELY, "modifyVirtualHardwareSectionMemory"));
// Retrieve the modified section
RASD modified = vAppClient.getVirtualHardwareSectionMemory(vmURI);
ResourceAllocationSettingData modified = vAppClient.getVirtualHardwareSectionMemory(vmURI);
// Check the retrieved object
checkRASD(modified);
checkResourceAllocationSettingData(modified);
// TODO What is modifiable? What can we change, so we can assert the change took effect?
// I tried changing "weight", but it continued to have the value zero when looked up post-modify.
@ -1011,6 +1019,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionNetworkCards(vmURI);
// Check the retrieved object is well formed
@ -1045,6 +1054,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RasdItemsList rasdItems = vAppClient.getVirtualHardwareSectionSerialPorts(vmURI);
// Check the retrieved object is well formed
@ -1076,7 +1086,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vApp/{id}/metadata", dependsOnMethods = { "testGetVApp" })
public void testGetMetadata() {
Metadata metadata = metadataClient.getMetadata(vApp.getHref());
Metadata metadata = vAppClient.getMetadataClient().getMetadata(vApp.getHref());
// Check the retrieved object is well formed
checkMetadataFor(VAPP, metadata);
@ -1085,13 +1095,13 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "PUT & GET /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testSetAndGetMetadataValue() {
// Store a value
String key = Integer.toString(random.nextInt());
String value = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
MetadataValue metadataValue = MetadataValue.builder().value(value).build();
metadataClient.setMetadata(vApp.getHref(), key, metadataValue);
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
// Retrieve the value, and assert it was set correctly
MetadataValue newMetadataValue = metadataClient.getMetadataValue(vApp.getHref(), key);
MetadataValue newMetadataValue = vAppClient.getMetadataClient().getMetadataValue(vApp.getHref(), key);
// Check the retrieved object is well formed
checkMetadataValueFor(VAPP, newMetadataValue, value);
@ -1100,16 +1110,16 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetAndGetMetadataValue" })
public void testDeleteMetadataEntry() {
// Store a value, to be deleted
String key = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
metadataClient.setMetadata(vApp.getHref(), key, metadataValue);
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
// Delete the entry
Task task = metadataClient.deleteMetadataEntry(vApp.getHref(), key);
Task task = vAppClient.getMetadataClient().deleteMetadataEntry(vApp.getHref(), key);
retryTaskSuccess.apply(task);
// Confirm the entry has been deleted
Metadata newMetadata = metadataClient.getMetadata(vApp.getHref());
Metadata newMetadata = vAppClient.getMetadataClient().getMetadata(vApp.getHref());
// Check the retrieved object is well formed
checkMetadataKeyAbsentFor(VAPP, newMetadata, key);
@ -1117,20 +1127,20 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testMergeMetadata() {
Metadata oldMetadata = metadataClient.getMetadata(vApp.getHref());
Metadata oldMetadata = vAppClient.getMetadataClient().getMetadata(vApp.getHref());
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be deleted
String key = Integer.toString(random.nextInt());
String value = Integer.toString(random.nextInt());
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
Metadata addedMetadata = Metadata.builder()
.entry(MetadataEntry.builder().key(key).value(value).build())
.build();
Task task = metadataClient.mergeMetadata(vApp.getHref(), addedMetadata);
Task task = vAppClient.getMetadataClient().mergeMetadata(vApp.getHref(), addedMetadata);
retryTaskSuccess.apply(task);
// Confirm the entry contains everything that was there, and everything that was being added
Metadata newMetadata = metadataClient.getMetadata(vApp.getHref());
Metadata newMetadata = vAppClient.getMetadataClient().getMetadata(vApp.getHref());
Map<String, String> expectedMetadataMap = ImmutableMap.<String, String>builder()
.putAll(oldMetadataMap)
.put(key, value)
@ -1143,86 +1153,27 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/**
* @see VAppClient#deleteVApp(URI)
*/
@Test(testName = "DELETE /vApp/{id}", dependsOnMethods = { "testPowerOffVApp" })
@Test(testName = "DELETE /vApp/{id}")
public void testDeleteVApp() {
// Create a temporary VApp to delete
VApp temp = instantiateVApp();
DeployVAppParams params = DeployVAppParams.builder()
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
.notForceCustomization()
.notPowerOn()
.build();
Task deployVApp = vAppClient.deploy(temp.getHref(), params);
assertTrue(retryTaskSuccessLong.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp"));
// The method under test
Task deleteVApp = vAppClient.deleteVApp(vApp.getHref());
Task deleteVApp = vAppClient.deleteVApp(temp.getHref());
assertTrue(retryTaskSuccess.apply(deleteVApp), String.format(TASK_COMPLETE_TIMELY, "deleteVApp"));
try {
vApp = vAppClient.getVApp(vApp.getHref());
vAppClient.getVApp(temp.getHref());
fail("The VApp should have been deleted");
} catch (VCloudDirectorException vcde) {
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The error code should have been 'Forbidden' (403)");
vApp = null;
}
}
// NOTE This method is also called by the BeforeClass method setupRequiredClients
@AfterClass(alwaysRun = true, description = "Clean up the environment by deleting created VApps named 'test-vapp' or 'new-name'")
public void cleanUp() throws Exception {
// Find references in the Vdc with the VApp type and named 'test-vapp' or 'new-name'
Iterable<Reference> vApps = Iterables.filter(
vdc.getResourceEntities().getResourceEntities(),
Predicates.and(
ReferenceTypePredicates.<Reference> typeEquals(VCloudDirectorMediaType.VAPP),
Predicates.or(
ReferenceTypePredicates.<Reference> nameEquals("test-vapp"),
ReferenceTypePredicates.<Reference> nameEquals("new-name")
)
)
);
// If we found any references, delete the VApp they point to
if (vApps != null && !Iterables.isEmpty(vApps)) {
for (Reference each : vApps) {
cleanUpVApp(each.getHref());
}
}
}
/**
* Marshals a JAXB annotated object into XML. The XML is output on {@link System#err}.
*/
private void debug(Object object) {
JAXBParser parser = new JAXBParser();
try {
String xml = parser.toXML(object);
System.err.println(Strings.repeat("-", 80));
System.err.println(xml);
System.err.println(Strings.repeat("-", 80));
} catch (IOException ioe) {
Throwables.propagate(ioe);
}
}
@SuppressWarnings("unused")
private CimUnsignedInt newCimUnsignedInt(long val) {
CimUnsignedInt result = new CimUnsignedInt();
result.setValue(val);
return result;
}
@SuppressWarnings("unused")
private CimString newCimString(String val) {
CimString result = new CimString();
result.setValue(val);
return result;
}
@SuppressWarnings("unused")
private void checkHasMatchingItem(String context, RasdItemsList items, String instanceId, String elementName) {
boolean found = false;
for (RASD item : items.getItems()) {
String itemInstanceId = item.getInstanceID().getValue();
if (itemInstanceId.equals(instanceId)) {
assertEquals(item.getElementName().getValue(), elementName,
String.format(OBJ_FIELD_EQ, VAPP, context+"/"+instanceId+"/elementName", elementName, ""+item.getElementName().getValue()));
found = true;
break;
}
}
assertTrue(found, "no "+context+" item found with id "+instanceId+"; only found "+items);
}
}

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ERROR;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION;
@ -390,18 +391,18 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(METADATA).httpRequestBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/metadata.xml", METADATA).httpResponseBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
).getVAppTemplateClient();
assertNotNull(client);
Metadata metadata = client.getVAppTemplateMetadata(uri);
Metadata metadata = client.getMetadataClient().getMetadata(uri);
assertEquals(metadata, exampleMetadata());
Task task = client.editVAppTemplateMetadata(uri, exampleMetadata());
Task task = client.getMetadataClient().mergeMetadata(uri, exampleMetadata());
assertNotNull(task);
}
@ -411,10 +412,10 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
URI uri = URI.create(endpoint + templateId);
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(METADATA).httpRequestBuilder().build(),
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.getVAppTemplateMetadata(uri);
client.getMetadataClient().getMetadata(uri);
}
@Test(expectedExceptions = VCloudDirectorException.class)
@ -426,7 +427,7 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateMetadata(uri, exampleMetadata());
client.getMetadataClient().mergeMetadata(uri, exampleMetadata());
}
public void testVappTemplateMetadataValue() {
@ -443,14 +444,14 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
).getVAppTemplateClient();
assertNotNull(client);
MetadataValue metadata = client.getVAppTemplateMetadataValue(uri, "12345");
MetadataValue metadata = client.getMetadataClient().getMetadataValue(uri, "12345");
assertEquals(metadata, exampleMetadataValue());
Task task = client.editVAppTemplateMetadataValue(uri, "12345", exampleMetadataValue());
Task task = client.getMetadataClient().setMetadata(uri, "12345", exampleMetadataValue());
assertNotNull(task);
task = client.deleteVAppTemplateMetadataValue(uri, "12345");
task = client.getMetadataClient().deleteMetadataEntry(uri, "12345");
assertNotNull(task);
}
@ -463,7 +464,7 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata/12345").acceptMedia(METADATA_ENTRY).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.getVAppTemplateMetadataValue(uri, "12345");
client.getMetadataClient().getMetadataValue(uri, "12345");
}
@Test(expectedExceptions = VCloudDirectorException.class)
@ -475,7 +476,7 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata/12345").xmlFilePayload("/vapptemplate/metadataValue.xml", METADATA_ENTRY).acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
client.editVAppTemplateMetadataValue(uri, "12345", exampleMetadataValue());
client.getMetadataClient().setMetadata(uri, "12345", exampleMetadataValue());
}
@Test(expectedExceptions = VCloudDirectorException.class)
@ -487,7 +488,7 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId + "/metadata/12345").acceptMedia(TASK).httpRequestBuilder().build(),
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateClient();
client.deleteVAppTemplateMetadataValue(uri, "12345");
client.getMetadataClient().deleteMetadataEntry(uri, "12345");
}
public void testNetworkConfigSection() throws ParseException {

View File

@ -18,17 +18,30 @@
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCustomizationSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkGuestCustomizationSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkLeaseSettingsSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataFor;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataKeyAbsentFor;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConfigSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConnectionSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOvfEnvelope;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOvfNetworkSection;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOwner;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkProductSectionList;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkVAppTemplate;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.metadataToMap;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
import java.util.List;
import java.net.URI;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
@ -43,52 +56,25 @@ import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.UndeployVAppParams;
import org.jclouds.vcloud.director.v1_5.domain.VApp;
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
import org.jclouds.vcloud.director.v1_5.domain.Vm;
import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
/**
* Tests the request/response behavior of {@link org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient}
* Tests the request/response behavior of {@link VAppTemplateClient}
*
* NOTE The environment MUST have at least one template configured
*
* @author Aled Sage
*/
@Test(groups = {"live", "unit", "user"}, testName = "VAppTemplateClientLiveTest")
public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private VAppTemplateClient vappTemplateClient;
private VdcClient vdcClient;
private VAppClient vappClient;
private VApp vApp;
private Vm vm;
@BeforeClass(inheritGroups = true)
@Override
public void setupRequiredClients() throws Exception {
vappTemplateClient = context.getApi().getVAppTemplateClient();
vdcClient = context.getApi().getVdcClient();
vappClient = context.getApi().getVAppClient();
}
// TODO remove duplication from other tests
@AfterClass(groups = { "live" })
public void cleanUp() throws Exception {
if (vApp != null) cleanUpVApp(vApp);
}
@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest")
public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
// FIXME cloneVAppTemplate is giving back 500 error
private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception {
@ -106,114 +92,108 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
return clonedVappTemplate;
}
@Test
public void testInstantiateAndStartVApp() throws Exception {
vApp = instantiateVApp();
Task instantiateTask = Iterables.getFirst(vApp.getTasks(), null);
if (instantiateTask != null) {
assertTaskSucceedsLong(instantiateTask);
}
// Start the vApp so that it has VMs
Task task = vappClient.powerOn(vApp.getHref());
assertTaskSucceedsLong(task);
// Get a VM
vApp = vappClient.getVApp(vApp.getHref()); // refresh
List<Vm> vms = vApp.getChildren().getVms();
vm = Iterables.getFirst(vms, null);
assertNotNull(vm, "started vApp "+vApp+" must have at least one VM");
}
@Test
public void testGetVAppTemplate() {
VAppTemplate template = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
Checks.checkVAppTemplate(template);
assertEquals(template.getHref(), vAppTemplateURI);
checkVAppTemplate(vAppTemplate);
assertEquals(vAppTemplate.getHref(), vAppTemplateURI);
}
@Test
public void testGetOwner() {
Owner owner = vappTemplateClient.getOwnerOfVAppTemplate(vAppTemplateURI);
public void testGetVAppTemplateOwner() {
Owner owner = vAppTemplateClient.getOwnerOfVAppTemplate(vAppTemplateURI);
Checks.checkOwner(owner);
assertEquals(owner.getUser(), vappTemplateClient.getVAppTemplate(vAppTemplateURI).getOwner().getUser());
checkOwner(owner);
assertEquals(owner.getUser(), vAppTemplateClient.getVAppTemplate(vAppTemplateURI).getOwner().getUser());
}
@Test
public void testGetCustomizationSection() {
CustomizationSection customizationSection = vappTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI);
CustomizationSection customizationSection = vAppTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI);
Checks.checkCustomizationSection(customizationSection);
checkCustomizationSection(customizationSection);
}
@Test
public void testGetProductSections() {
ProductSectionList productSectionList = vappTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI);
ProductSectionList productSectionList = vAppTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI);
Checks.checkProductSectionList(productSectionList);
checkProductSectionList(productSectionList);
}
@Test( dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test(testName = "GET /vAppTemplate/{id}/guestCustomizationSection")
public void testGetGuestCustomizationSection() {
GuestCustomizationSection guestCustomizationSection = vappTemplateClient.getVAppTemplateGuestCustomizationSection(vm.getHref());
getGuestCustomizationSection(new Function<URI, GuestCustomizationSection>() {
@Override
public GuestCustomizationSection apply(URI uri) {
return vAppTemplateClient.getVAppTemplateGuestCustomizationSection(uri);
}
});
}
@Test
public void testGetProductSectionsForVAppTemplate() {
ProductSectionList productSectionList = vAppTemplateClient.getProductSectionsForVAppTemplate(vAppTemplateURI);
Checks.checkGuestCustomizationSection(guestCustomizationSection);
checkProductSectionList(productSectionList);
}
@Test
public void testGetLeaseSettingsSection() {
// FIXME Wrong case for Vapp
LeaseSettingsSection leaseSettingsSection = vappTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI);
LeaseSettingsSection leaseSettingsSection = vAppTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI);
Checks.checkLeaseSettingsSection(leaseSettingsSection);
checkLeaseSettingsSection(leaseSettingsSection);
}
@Test
public void testGetMetadata() {
Metadata metadata = vappTemplateClient.getVAppTemplateMetadata(vAppTemplateURI);
public void testGetVAppTemplateMetadata() {
Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
Checks.checkMetadata(metadata);
checkMetadata(metadata);
}
@Test // implicitly tested by testEditVAppTemplateMetadataValue, which first creates the metadata entry; otherwise no entry may exist
public void testGetMetadataValue() {
Metadata metadata = vappTemplateClient.getVAppTemplateMetadata(vAppTemplateURI);
Metadata metadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0);
MetadataValue val = vappTemplateClient.getVAppTemplateMetadataValue(vAppTemplateURI, entry.getKey());
MetadataValue val = vAppTemplateClient.getMetadataClient().getMetadataValue(vAppTemplateURI, entry.getKey());
Checks.checkMetadataValue(val);
checkMetadataValue(val);
assertEquals(val.getValue(), entry.getValue());
}
@Test
public void testGetNetworkConfigSection() {
NetworkConfigSection networkConfigSection = vappTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI);
public void testGetVAppTemplateNetworkConfigSection() {
NetworkConfigSection networkConfigSection = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI);
Checks.checkNetworkConfigSection(networkConfigSection);
checkNetworkConfigSection(networkConfigSection);
}
@Test( dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test(testName = "GET /vAppTemplate/{id}/networkConnectionSection")
public void testGetNetworkConnectionSection() {
NetworkConnectionSection networkConnectionSection = vappTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
Checks.checkNetworkConnectionSection(networkConnectionSection);
getNetworkConnectionSection(new Function<URI, NetworkConnectionSection>() {
@Override
public NetworkConnectionSection apply(URI uri) {
return vAppTemplateClient.getVAppTemplateNetworkConnectionSection(uri);
}
});
}
@Test
public void testGetNetworkSection() {
NetworkSection networkSection = vappTemplateClient.getVAppTemplateNetworkSection(vAppTemplateURI);
public void testGetVAppTemplateNetworkSection() {
NetworkSection networkSection = vAppTemplateClient.getVAppTemplateNetworkSection(vAppTemplateURI);
Checks.checkOvfNetworkSection(networkSection);
checkOvfNetworkSection(networkSection);
}
@Test
public void testGetOvf() {
Envelope envelope = vappTemplateClient.getVAppTemplateOvf(vAppTemplateURI);
public void testGetVAppTemplateOvf() {
Envelope envelope = vAppTemplateClient.getVAppTemplateOvf(vAppTemplateURI);
Checks.checkOvfEnvelope(envelope);
checkOvfEnvelope(envelope);
}
@Test
@ -226,10 +206,10 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
.description(description)
.build();
final Task task = vappTemplateClient.editVAppTemplate(vAppTemplateURI, template);
final Task task = vAppTemplateClient.editVAppTemplate(vAppTemplateURI, template);
retryTaskSuccess.apply(task);
VAppTemplate newTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
VAppTemplate newTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
assertEquals(newTemplate.getName(), name);
assertEquals(newTemplate.getDescription(), description);
}
@ -238,8 +218,8 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
public void testEditMetadata() {
// TODO Cleanup after ourselves..
Metadata oldMetadata = vappTemplateClient.getVAppTemplateMetadata(vAppTemplateURI);
Map<String,String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
Metadata oldMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
Map<String,String> oldMetadataMap = metadataToMap(oldMetadata);
String uid = ""+random.nextInt();
String key = "mykey-"+uid;
@ -247,15 +227,15 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build();
Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build();
final Task task = vappTemplateClient.editVAppTemplateMetadata(vAppTemplateURI, metadata);
final Task task = vAppTemplateClient.getMetadataClient().mergeMetadata(vAppTemplateURI, metadata);
retryTaskSuccess.apply(task);
Metadata newMetadata = vappTemplateClient.getVAppTemplateMetadata(vAppTemplateURI);
Metadata newMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
Map<String,String> expectedMetadataMap = ImmutableMap.<String,String>builder()
.putAll(oldMetadataMap)
.put(key, val)
.build();
Checks.checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap);
checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap);
}
@Test
@ -267,10 +247,10 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
String val = "myval-"+uid;
MetadataValue metadataValue = MetadataValue.builder().value(val).build();
final Task task = vappTemplateClient.editVAppTemplateMetadataValue(vAppTemplateURI, key, metadataValue);
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
retryTaskSuccess.apply(task);
MetadataValue newMetadataValue = vappTemplateClient.getVAppTemplateMetadataValue(vAppTemplateURI, key);
MetadataValue newMetadataValue = vAppTemplateClient.getMetadataClient().getMetadataValue(vAppTemplateURI, key);
assertEquals(newMetadataValue.getValue(), metadataValue.getValue());
}
@ -279,19 +259,19 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
// First store a value
String key = "mykey-"+random.nextInt();
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
final Task task = vappTemplateClient.editVAppTemplateMetadataValue(vAppTemplateURI, key, metadataValue);
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
retryTaskSuccess.apply(task);
// Then delete the entry
final Task deletionTask = vappTemplateClient.deleteVAppTemplateMetadataValue(vAppTemplateURI, key);
final Task deletionTask = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key);
retryTaskSuccess.apply(deletionTask);
// Then confirm the entry is not there
Metadata newMetadata = vappTemplateClient.getVAppTemplateMetadata(vAppTemplateURI);
Checks.checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
Metadata newMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
}
@Test( dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test
public void testEditGuestCustomizationSection() {
String computerName = "a"+random.nextInt(Integer.MAX_VALUE);
GuestCustomizationSection newSection = GuestCustomizationSection.builder()
@ -299,32 +279,15 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
.computerName(computerName)
.build();
final Task task = vappTemplateClient.editVAppTemplateGuestCustomizationSection(vm.getHref(), newSection);
final Task task = vAppTemplateClient.editVAppTemplateGuestCustomizationSection(vm.getHref(), newSection);
assertTaskSucceeds(task);
GuestCustomizationSection modified = vappTemplateClient.getVAppTemplateGuestCustomizationSection(vm.getHref());
GuestCustomizationSection modified = vAppTemplateClient.getVAppTemplateGuestCustomizationSection(vm.getHref());
Checks.checkGuestCustomizationSection(modified);
checkGuestCustomizationSection(modified);
assertEquals(modified.getComputerName(), computerName);
}
@Test
public void testEditCustomizationSection() {
boolean oldVal = vappTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI).isCustomizeOnInstantiate();
boolean newVal = !oldVal;
CustomizationSection customizationSection = CustomizationSection.builder()
.info("my info")
.customizeOnInstantiate(newVal)
.build();
final Task task = vappTemplateClient.editVAppTemplateCustomizationSection(vAppTemplateURI, customizationSection);
retryTaskSuccess.apply(task);
CustomizationSection newCustomizationSection = vappTemplateClient.getVAppTemplateCustomizationSection(vAppTemplateURI);
assertEquals(newCustomizationSection.isCustomizeOnInstantiate(), newVal);
}
@Test // FIXME deploymentLeaseInSeconds returned is null
public void testEditLeaseSettingsSection() throws Exception {
// Note: use smallish number for storageLeaseInSeconds; it seems to be capped at 5184000?
@ -336,19 +299,19 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
.deploymentLeaseInSeconds(deploymentLeaseInSeconds)
.build();
final Task task = vappTemplateClient.editVappTemplateLeaseSettingsSection(vAppTemplateURI, leaseSettingSection);
final Task task = vAppTemplateClient.editVappTemplateLeaseSettingsSection(vAppTemplateURI, leaseSettingSection);
retryTaskSuccess.apply(task);
LeaseSettingsSection newLeaseSettingsSection = vappTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI);
LeaseSettingsSection newLeaseSettingsSection = vAppTemplateClient.getVappTemplateLeaseSettingsSection(vAppTemplateURI);
assertEquals(newLeaseSettingsSection.getStorageLeaseInSeconds(), (Integer)storageLeaseInSeconds);
assertEquals(newLeaseSettingsSection.getDeploymentLeaseInSeconds(), (Integer)deploymentLeaseInSeconds);
}
@Test( dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test
public void testEditNetworkConfigSection() {
// TODO What to modify?
NetworkConfigSection oldSection = vappTemplateClient.getVAppTemplateNetworkConfigSection(vApp.getHref());
NetworkConfigSection oldSection = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vApp.getHref());
NetworkConfigSection newSection = oldSection.toBuilder().build();
// String networkName = ""+random.nextInt();
@ -365,31 +328,31 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
// .networkConfigs(vappNetworkConfigurations)
// .build();
final Task task = vappTemplateClient.editVAppTemplateNetworkConfigSection(vApp.getHref(), newSection);
final Task task = vAppTemplateClient.editVAppTemplateNetworkConfigSection(vApp.getHref(), newSection);
assertTaskSucceeds(task);
NetworkConfigSection modified = vappTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI);
Checks.checkNetworkConfigSection(modified);
NetworkConfigSection modified = vAppTemplateClient.getVAppTemplateNetworkConfigSection(vAppTemplateURI);
checkNetworkConfigSection(modified);
// assertEquals(modified§.getNetworkConfigs().size(), 1);
//
// VAppNetworkConfiguration newVAppNetworkConfig = Iterables.get(modified§.getNetworkConfigs(), 0);
// assertEquals(newVAppNetworkConfig.getNetworkName(), networkName);
}
@Test( dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test
public void testEditNetworkConnectionSection() {
// TODO Modify a field so can assert that the change really took effect
NetworkConnectionSection oldSection = vappTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
NetworkConnectionSection oldSection = vAppTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
NetworkConnectionSection newSection = oldSection.toBuilder()
.build();
final Task task = vappTemplateClient.editVAppTemplateNetworkConnectionSection(vm.getHref(), newSection);
final Task task = vAppTemplateClient.editVAppTemplateNetworkConnectionSection(vm.getHref(), newSection);
assertTaskSucceeds(task);
NetworkConnectionSection modified = vappTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
Checks.checkNetworkConnectionSection(modified);
NetworkConnectionSection modified = vAppTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
checkNetworkConnectionSection(modified);
}
@Test // FIXME cloneVAppTemplate is giving back 500 error
@ -397,16 +360,16 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
VAppTemplate clonedVappTemplate = cloneVAppTemplate(true);
// Confirm that "get" works pre-delete
VAppTemplate vAppTemplatePreDelete = vappTemplateClient.getVAppTemplate(clonedVappTemplate.getHref());
Checks.checkVAppTemplate(vAppTemplatePreDelete);
VAppTemplate vAppTemplatePreDelete = vAppTemplateClient.getVAppTemplate(clonedVappTemplate.getHref());
checkVAppTemplate(vAppTemplatePreDelete);
// Delete the template
final Task task = vappTemplateClient.deleteVappTemplate(clonedVappTemplate.getHref());
final Task task = vAppTemplateClient.deleteVappTemplate(clonedVappTemplate.getHref());
retryTaskSuccess.apply(task);
// Confirm that can't access post-delete, i.e. template has been deleted
try {
vappTemplateClient.getVAppTemplate(clonedVappTemplate.getHref());
vAppTemplateClient.getVAppTemplate(clonedVappTemplate.getHref());
} catch (VCloudDirectorException e) {
// success; should get a 403 because vAppTemplate no longer exists
}
@ -414,14 +377,14 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test
public void testDisableVAppTemplateDownload() throws Exception {
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
// TODO Check that it really is disabled. The only thing I can see for determining this
// is the undocumented "download" link in the VAppTemplate. But that is brittle and we
// don't know what timing guarantees there are for adding/removing the link.
//
// For example:
// VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
// VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
// Set<Link> links = vAppTemplate.getLinks();
// assertFalse(hasLinkMatchingRel(links, "download.*"), "Should not offer download link after disabling download: "+vAppTemplate);
}
@ -429,8 +392,8 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test
public void testEnableVAppTemplateDownload() throws Exception {
// First disable so that enable really has some work to do...
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
final Task task = vappTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
final Task task = vAppTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
retryTaskSuccess.apply(task);
// TODO Check that it really is enabled. The only thing I can see for determining this
@ -438,7 +401,7 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
// don't know what timing guarantees there are for adding/removing the link.
//
// For example:
// VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
// VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
// Set<Link> links = vAppTemplate.getLinks();
// assertTrue(hasLinkMatchingRel(links, "download.*"), "Should offer download link after enabling download: "+vAppTemplate);
}
@ -453,12 +416,12 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
return false;
}
@Test(dependsOnMethods = { "testInstantiateAndStartVApp" } )
@Test
public void testConsolidateVAppTemplate() throws Exception {
// TODO Need assertion that command had effect
System.out.println("About to try to consolidate "+vm);
final Task task = vappTemplateClient.consolidateVappTemplate(vm.getHref());
final Task task = vAppTemplateClient.consolidateVappTemplate(vm.getHref());
assertTaskSucceedsLong(task);
}
@ -470,7 +433,7 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
.datastore(dataStore)
.build();
final Task task = vappTemplateClient.relocateVappTemplate(vAppTemplateURI, relocateParams);
final Task task = vAppTemplateClient.relocateVappTemplate(vAppTemplateURI, relocateParams);
assertTaskSucceedsLong(task);
}
@ -479,12 +442,12 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test
public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception {
// Kick off a task, and wait for it to complete
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
final Task task = vappTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
final Task task = vAppTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
retryTaskSuccess.apply(task);
// Ask the VAppTemplate for its tasks, and the status of the matching task if it exists
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
Set<Task> tasks = vAppTemplate.getTasks();
if (tasks != null) {
for (Task contender : tasks) {

View File

@ -251,7 +251,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
* @return the VApp that is being instantiated
*/
protected VApp instantiateVApp() {
return instantiateVApp("test-vapp-"+random.nextInt(Integer.MAX_VALUE));
return instantiateVApp("test-vapp-" + random.nextInt(Integer.MAX_VALUE));
}
protected VApp instantiateVApp(String name) {