Issue 830: Fixes for various failing tests, updates for CIM and RASD domain objects

This commit is contained in:
Andrew Donald Kennedy 2012-03-17 15:00:02 +00:00
parent 45fd7c443e
commit 6846dad9fc
22 changed files with 1125 additions and 1084 deletions

View File

@ -36,6 +36,10 @@ public class VCloudDirectorConstants {
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

@ -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();
}
@ -110,12 +118,15 @@ 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());
}
}

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

@ -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,75 +18,124 @@
*/
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 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.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 {
@XmlType(name = "CIM_ResourceAllocationSettingData_Type", namespace = VCLOUD_CIM_RASD_NS)
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 CimString elementName;
protected CimString instanceID;
protected CimString caption;
protected CimString description;
protected CimString address;
protected CimString addressOnParent;
protected CimString allocationUnits;
protected CimBoolean automaticAllocation;
protected CimBoolean automaticDeallocation;
protected ConsumerVisibility consumerVisibility;
protected Long limit;
protected CimUnsignedLong limit;
protected MappingBehavior mappingBehavior;
protected String otherResourceType;
protected String parent;
protected String poolID;
protected Long reservation;
protected String resourceSubType;
protected CimString otherResourceType;
protected CimString parent;
protected CimString poolID;
protected CimUnsignedLong reservation;
protected CimString 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();
protected CimUnsignedLong virtualQuantity;
protected CimString virtualQuantityUnits;
protected CimUnsignedInt weight;
protected List<CimString> connections = Lists.newArrayList();
protected List<CimString> hostResources = Lists.newArrayList();
protected URI href;
protected String type;
private Set<Link> links = Sets.newLinkedHashSet();
/**
* @see ResourceAllocationSettingData#getElementName()
*/
public Builder elementName(CimString elementName) {
this.elementName = elementName;
return this;
}
/**
*@see ResourceAllocationSettingData#getInstanceId()
*/
public Builder instanceID(CimString instanceID) {
this.instanceID = instanceID;
return this;
}
/**
* @see ResourceAllocationSettingData#getCaption()
*/
public Builder caption(CimString caption) {
this.caption = caption;
return this;
}
/**
* @see ResourceAllocationSettingData#getDescription()
*/
public Builder description(CimString description) {
this.description = description;
return this;
}
/**
* @see ResourceAllocationSettingData#getAddress
*/
public Builder address(String address) {
public Builder address(CimString address) {
this.address = address;
return this;
}
@ -94,7 +143,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getAddressOnParent
*/
public Builder addressOnParent(String addressOnParent) {
public Builder addressOnParent(CimString addressOnParent) {
this.addressOnParent = addressOnParent;
return this;
}
@ -102,7 +151,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getAllocationUnits
*/
public Builder allocationUnits(String allocationUnits) {
public Builder allocationUnits(CimString allocationUnits) {
this.allocationUnits = allocationUnits;
return this;
}
@ -110,7 +159,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#isAutomaticAllocation()
*/
public Builder automaticAllocation(Boolean automaticAllocation) {
public Builder automaticAllocation(CimBoolean automaticAllocation) {
this.automaticAllocation = automaticAllocation;
return this;
}
@ -118,7 +167,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#isAutomaticDeallocation()
*/
public Builder automaticDeallocation(Boolean automaticDeallocation) {
public Builder automaticDeallocation(CimBoolean automaticDeallocation) {
this.automaticDeallocation = automaticDeallocation;
return this;
}
@ -134,7 +183,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getLimit
*/
public Builder limit(Long limit) {
public Builder limit(CimUnsignedLong limit) {
this.limit = limit;
return this;
}
@ -150,7 +199,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getOtherResourceType
*/
public Builder otherResourceType(String otherResourceType) {
public Builder otherResourceType(CimString otherResourceType) {
this.otherResourceType = otherResourceType;
return this;
}
@ -158,7 +207,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getParent
*/
public Builder parent(String parent) {
public Builder parent(CimString parent) {
this.parent = parent;
return this;
}
@ -166,7 +215,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getPoolID
*/
public Builder poolID(String poolID) {
public Builder poolID(CimString poolID) {
this.poolID = poolID;
return this;
}
@ -174,7 +223,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getReservation
*/
public Builder reservation(Long reservation) {
public Builder reservation(CimUnsignedLong reservation) {
this.reservation = reservation;
return this;
}
@ -182,7 +231,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getResourceSubType
*/
public Builder resourceSubType(String resourceSubType) {
public Builder resourceSubType(CimString resourceSubType) {
this.resourceSubType = resourceSubType;
return this;
}
@ -198,7 +247,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getVirtualQuantity
*/
public Builder virtualQuantity(Long virtualQuantity) {
public Builder virtualQuantity(CimUnsignedLong virtualQuantity) {
this.virtualQuantity = virtualQuantity;
return this;
}
@ -206,7 +255,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getVirtualQuantityUnits
*/
public Builder virtualQuantityUnits(String virtualQuantityUnits) {
public Builder virtualQuantityUnits(CimString virtualQuantityUnits) {
this.virtualQuantityUnits = virtualQuantityUnits;
return this;
}
@ -214,7 +263,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getWeight
*/
public Builder weight(Integer weight) {
public Builder weight(CimUnsignedInt weight) {
this.weight = weight;
return this;
}
@ -222,7 +271,7 @@ 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;
}
@ -230,7 +279,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getHostResources()
*/
public Builder hostResource(String hostResource) {
public Builder hostResource(CimString hostResource) {
this.hostResources.add(checkNotNull(hostResource, "hostResource"));
return this;
}
@ -238,7 +287,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @see ResourceAllocationSettingData#getConnections
*/
public Builder connections(List<String> connections) {
public Builder connections(List<CimString> connections) {
this.connections = Lists.newArrayList(checkNotNull(connections, "connections"));
return this;
}
@ -246,84 +295,123 @@ public class ResourceAllocationSettingData extends ManagedElement {
/**
* @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 +420,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 +474,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 +495,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 +513,85 @@ 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")));
}
}
protected String address;
protected String addressOnParent;
protected String allocationUnits;
protected Boolean automaticAllocation;
protected Boolean automaticDeallocation;
@XmlElement(name = "ElementName", namespace = VCLOUD_CIM_RASD_NS)
protected CimString elementName;
@XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_RASD_NS)
protected CimString instanceID;
@XmlElement(name = "Caption", namespace = VCLOUD_CIM_RASD_NS)
protected CimString caption;
@XmlElement(name = "Description", namespace = VCLOUD_CIM_RASD_NS)
protected CimString description;
@XmlElement(name = "Address", namespace = VCLOUD_CIM_RASD_NS)
protected CimString address;
@XmlElement(name = "AddressOnParent", namespace = VCLOUD_CIM_RASD_NS)
protected CimString addressOnParent;
@XmlElement(name = "AllocationUnits", namespace = VCLOUD_CIM_RASD_NS)
protected CimString allocationUnits;
@XmlElement(name = "AutomaticAllocation", namespace = VCLOUD_CIM_RASD_NS)
protected CimBoolean automaticAllocation;
@XmlElement(name = "AutomaticDeallocation", namespace = VCLOUD_CIM_RASD_NS)
protected CimBoolean automaticDeallocation;
@XmlElement(name = "ConsumerVisibility", namespace = VCLOUD_CIM_RASD_NS)
protected ConsumerVisibility consumerVisibility;
protected Long limit;
@XmlElement(name = "Limit", namespace = VCLOUD_CIM_RASD_NS)
protected CimUnsignedLong limit;
@XmlElement(name = "MappingBehavior", namespace = VCLOUD_CIM_RASD_NS)
protected MappingBehavior mappingBehavior;
protected String otherResourceType;
protected String parent;
protected String poolID;
protected Long reservation;
protected String resourceSubType;
@XmlElement(name = "OtherResourceType", namespace = VCLOUD_CIM_RASD_NS)
protected CimString otherResourceType;
@XmlElement(name = "Parent", namespace = VCLOUD_CIM_RASD_NS)
protected CimString parent;
@XmlElement(name = "PoolID", namespace = VCLOUD_CIM_RASD_NS)
protected CimString poolID;
@XmlElement(name = "Reservation", namespace = VCLOUD_CIM_RASD_NS)
protected CimUnsignedLong reservation;
@XmlElement(name = "ResourceSubType", namespace = VCLOUD_CIM_RASD_NS)
protected CimString resourceSubType;
@XmlElement(name = "ResourceType", namespace = VCLOUD_CIM_RASD_NS)
protected ResourceType resourceType;
protected Long virtualQuantity;
protected String virtualQuantityUnits;
protected Integer weight;
protected List<String> connections;
protected List<String> hostResources;
@XmlElement(name = "VirtualQuantity", namespace = VCLOUD_CIM_RASD_NS)
protected CimUnsignedLong virtualQuantity;
@XmlElement(name = "VirtualQuantityUnits", namespace = VCLOUD_CIM_RASD_NS)
protected CimString virtualQuantityUnits;
@XmlElement(name = "Weight", namespace = VCLOUD_CIM_RASD_NS)
protected CimUnsignedInt weight;
@XmlElement(name = "Connection", namespace = VCLOUD_CIM_RASD_NS)
protected List<CimString> connections;
@XmlElement(name = "HostResource", namespace = VCLOUD_CIM_RASD_NS)
protected List<CimString> hostResources;
@XmlAttribute(name = "type", namespace = VCLOUD_1_5_NS)
protected String type;
@XmlAttribute(name = "href", namespace = VCLOUD_1_5_NS)
protected 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);
private ResourceAllocationSettingData(CimString elementName, CimString instanceID, CimString caption, CimString description,
CimString address, CimString addressOnParent, CimString allocationUnits, CimBoolean automaticAllocation,
CimBoolean automaticDeallocation, ConsumerVisibility consumerVisibility, CimUnsignedLong limit,
MappingBehavior mappingBehavior, CimString otherResourceType, CimString parent, CimString poolID, CimUnsignedLong reservation,
CimString resourceSubType, ResourceType resourceType, CimUnsignedLong virtualQuantity, CimString virtualQuantityUnits,
CimUnsignedInt 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,17 +611,51 @@ 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 CimString getElementName() {
return elementName;
}
/**
* Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies
* an instance of this class.
*/
public CimString getInstanceID() {
return instanceID;
}
/**
* The Caption property is a short textual description (one- line string) of the object.
*/
public CimString getCaption() {
return caption;
}
/**
* The Description property provides a textual description of the object.
*/
public CimString getDescription() {
return description;
}
/**
* The address of the resource. For example, the MAC address of a Ethernet
* port.
*/
public String getAddress() {
public CimString getAddress() {
return address;
}
@ -500,7 +666,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* if the parent is a PCI Controller, this property would specify the PCI
* slot of this child device.
*/
public String getAddressOnParent() {
public CimString getAddressOnParent() {
return addressOnParent;
}
@ -514,7 +680,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* value of the Programmatic Units qualifier as defined in Annex C.1 of
* DSP0004 V2.5 or later.
*/
public String getAllocationUnits() {
public CimString getAllocationUnits() {
return allocationUnits;
}
@ -527,7 +693,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* on time, the media is not present. An explicit operation is required to
* allocate the resource.
*/
public Boolean isAutomaticAllocation() {
public CimBoolean isAutomaticAllocation() {
return automaticAllocation;
}
@ -538,7 +704,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* set to false, the resource will remain allocated and must be explicitly
* de-allocated.
*/
public Boolean isAutomaticDeallocation() {
public CimBoolean isAutomaticDeallocation() {
return automaticDeallocation;
}
@ -557,7 +723,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 CimUnsignedLong getLimit() {
return limit;
}
@ -574,7 +740,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* A string that describes the resource type when a well defined value is not
* available and ResourceType has the value "Other".
*/
public String getOtherResourceType() {
public CimString getOtherResourceType() {
return otherResourceType;
}
@ -582,7 +748,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* The Parent of the resource. For example, a controller for the current
* allocation
*/
public String getParent() {
public CimString getParent() {
return parent;
}
@ -591,7 +757,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* allocated from, or which ResourcePool the resource will be allocated from
* when the allocation occurs.
*/
public String getPoolID() {
public CimString getPoolID() {
return poolID;
}
@ -603,7 +769,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 CimUnsignedLong getReservation() {
return reservation;
}
@ -611,7 +777,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* A string describing an implementation specific sub-type for this resource.
* F
*/
public String getResourceSubType() {
public CimString getResourceSubType() {
return resourceSubType;
}
@ -631,7 +797,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 CimUnsignedLong getVirtualQuantity() {
return virtualQuantity;
}
@ -647,7 +813,7 @@ public class ResourceAllocationSettingData extends ManagedElement {
* this property shall be a legal value of the Programmatic Units qualifier
* as defined in Annex C.1 of DSP0004 V2.5 or later.
*/
public String getVirtualQuantityUnits() {
public CimString getVirtualQuantityUnits() {
return virtualQuantityUnits;
}
@ -657,7 +823,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 CimUnsignedInt getWeight() {
return weight;
}
@ -665,7 +831,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,30 +853,65 @@ 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
@ -721,28 +922,34 @@ public class ResourceAllocationSettingData extends ManagedElement {
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,69 +18,100 @@
*/
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 java.net.URI;
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;
/**
* VirtualSystemSettingData defines the virtual aspects of a virtual system through a set of
* virtualization specific properties.
*
* 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 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_CIM_VSSD_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 {
protected CimString elementName;
protected CimString instanceID;
private CimString caption;
private CimString description;
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 CimUnsignedLong automaticStartupActionDelay;
private CimUnsignedInt automaticStartupActionSequenceNumber;
private CimString configurationDataRoot;
private CimString configurationFile;
private CimString configurationID;
private Date creationTime;
private URI logDataRoot;
private URI recoveryFile;
private URI snapshotDataRoot;
private URI suspendDataRoot;
private URI swapFileDataRoot;
private String virtualSystemIdentifier;
private Set<String> virtualSystemTypes = Sets.newLinkedHashSet();
private String notes;
private CimString logDataRoot;
private CimString recoveryFile;
private CimString snapshotDataRoot;
private CimString suspendDataRoot;
private CimString swapFileDataRoot;
private CimString virtualSystemIdentifier;
private CimString virtualSystemType;
private CimString notes;
public Builder elementName(CimString elementName) {
this.elementName = elementName;
return this;
}
public Builder instanceID(CimString instanceID) {
this.instanceID = instanceID;
return this;
}
public Builder caption(CimString caption) {
this.caption = caption;
return this;
}
public Builder description(CimString description) {
this.description = description;
return this;
}
public Builder automaticRecoveryAction(AutomaticRecoveryAction automaticRecoveryAction) {
this.automaticRecoveryAction = automaticRecoveryAction;
@ -97,27 +128,27 @@ public class VirtualSystemSettingData extends ManagedElement {
return this;
}
public Builder automaticStartupActionDelay(Long automaticStartupActionDelay) {
public Builder automaticStartupActionDelay(CimUnsignedLong automaticStartupActionDelay) {
this.automaticStartupActionDelay = automaticStartupActionDelay;
return this;
}
public Builder automaticStartupActionSequenceNumber(Integer automaticStartupActionSequenceNumber) {
public Builder automaticStartupActionSequenceNumber(CimUnsignedInt automaticStartupActionSequenceNumber) {
this.automaticStartupActionSequenceNumber = automaticStartupActionSequenceNumber;
return this;
}
public Builder configurationDataRoot(URI configurationDataRoot) {
public Builder configurationDataRoot(CimString configurationDataRoot) {
this.configurationDataRoot = configurationDataRoot;
return this;
}
public Builder configurationFile(URI configurationFile) {
public Builder configurationFile(CimString configurationFile) {
this.configurationFile = configurationFile;
return this;
}
public Builder configurationID(String configurationID) {
public Builder configurationID(CimString configurationID) {
this.configurationID = configurationID;
return this;
}
@ -127,47 +158,42 @@ public class VirtualSystemSettingData extends ManagedElement {
return this;
}
public Builder logDataRoot(URI logDataRoot) {
public Builder logDataRoot(CimString logDataRoot) {
this.logDataRoot = logDataRoot;
return this;
}
public Builder recoveryFile(URI recoveryFile) {
public Builder recoveryFile(CimString recoveryFile) {
this.recoveryFile = recoveryFile;
return this;
}
public Builder snapshotDataRoot(URI snapshotDataRoot) {
public Builder snapshotDataRoot(CimString snapshotDataRoot) {
this.snapshotDataRoot = snapshotDataRoot;
return this;
}
public Builder suspendDataRoot(URI suspendDataRoot) {
public Builder suspendDataRoot(CimString suspendDataRoot) {
this.suspendDataRoot = suspendDataRoot;
return this;
}
public Builder swapFileDataRoot(URI swapFileDataRoot) {
public Builder swapFileDataRoot(CimString swapFileDataRoot) {
this.swapFileDataRoot = swapFileDataRoot;
return this;
}
public Builder virtualSystemIdentifier(String virtualSystemIdentifier) {
public Builder virtualSystemIdentifier(CimString virtualSystemIdentifier) {
this.virtualSystemIdentifier = virtualSystemIdentifier;
return this;
}
public Builder virtualSystemTypes(Iterable<String> virtualSystemTypes) {
this.virtualSystemTypes = ImmutableSet.copyOf(checkNotNull(virtualSystemTypes, "virtualSystemTypes"));
public Builder virtualSystemType(CimString virtualSystemType) {
this.virtualSystemType = virtualSystemType;
return this;
}
public Builder virtualSystemType(String virtualSystemType) {
this.virtualSystemTypes.add(checkNotNull(virtualSystemType, "virtualSystemType"));
return this;
}
public Builder notes(String notes) {
public Builder notes(CimString notes) {
this.notes = notes;
return this;
}
@ -177,77 +203,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 +253,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 +287,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 +321,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")));
}
}
@XmlElement(name = "ElementName", namespace = VCLOUD_CIM_VSSD_NS)
protected CimString elementName;
@XmlElement(name = "InstanceID", namespace = VCLOUD_CIM_VSSD_NS)
protected CimString instanceID;
@XmlElement(name = "Caption", namespace = VCLOUD_CIM_VSSD_NS)
protected CimString caption;
@XmlElement(name = "Description", namespace = VCLOUD_CIM_VSSD_NS)
protected CimString description;
@XmlElement(name = "VirtualSystemIdentifier", namespace = VCLOUD_CIM_VSSD_NS)
private CimString virtualSystemIdentifier;
@XmlElement(name = "VirtualSystemType", namespace = VCLOUD_CIM_VSSD_NS)
private CimString 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;
private Long automaticStartupActionDelay;
private Integer automaticStartupActionSequenceNumber;
private URI configurationDataRoot;
private URI configurationFile;
private String configurationID;
@XmlElement(name = "AutomaticStartupActionDelay", namespace = VCLOUD_CIM_VSSD_NS)
private CimUnsignedLong automaticStartupActionDelay;
@XmlElement(name = "AutomaticStartupActionSequenceNumber", namespace = VCLOUD_CIM_VSSD_NS)
private CimUnsignedInt automaticStartupActionSequenceNumber;
@XmlElement(name = "ConfigurationDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private CimString configurationDataRoot;
@XmlElement(name = "ConfigurationFile", namespace = VCLOUD_CIM_VSSD_NS)
private CimString configurationFile;
@XmlElement(name = "ConfigurationID", namespace = VCLOUD_CIM_VSSD_NS)
private CimString configurationID;
@XmlElement(name = "CreationTime", namespace = VCLOUD_CIM_VSSD_NS)
private Date creationTime;
private URI logDataRoot;
private URI recoveryFile;
private URI snapshotDataRoot;
private URI suspendDataRoot;
private URI swapFileDataRoot;
private String virtualSystemIdentifier;
private Set<String> virtualSystemTypes;
private String notes;
@XmlElement(name = "LogDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private CimString logDataRoot;
@XmlElement(name = "RecoveryFile", namespace = VCLOUD_CIM_VSSD_NS)
private CimString recoveryFile;
@XmlElement(name = "SnapshotDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private CimString snapshotDataRoot;
@XmlElement(name = "SuspendDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private CimString suspendDataRoot;
@XmlElement(name = "SwapFileDataRoot", namespace = VCLOUD_CIM_VSSD_NS)
private CimString swapFileDataRoot;
@XmlElement(name = "Notes", namespace = VCLOUD_CIM_VSSD_NS)
private CimString notes;
private VirtualSystemSettingData(String elementName, String instanceID, String caption, String description,
private VirtualSystemSettingData(CimString elementName, CimString instanceID, CimString caption, CimString 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, CimUnsignedLong automaticStartupActionDelay,
CimUnsignedInt automaticStartupActionSequenceNumber, CimString configurationDataRoot, CimString configurationFile,
CimString configurationID, Date creationTime, CimString logDataRoot, CimString recoveryFile, CimString snapshotDataRoot,
CimString suspendDataRoot, CimString swapFileDataRoot, CimString virtualSystemIdentifier,
CimString virtualSystemType, CimString notes) {
this.elementName = elementName;
this.instanceID = instanceID;
this.caption = caption;
this.description = description;
this.automaticRecoveryAction = automaticRecoveryAction;
this.automaticShutdownAction = automaticShutdownAction;
this.automaticStartupAction = automaticStartupAction;
@ -390,7 +406,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 +414,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 CimString getElementName() {
return elementName;
}
/**
* Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies
* an instance of this class.
*/
public CimString getInstanceID() {
return instanceID;
}
/**
* The Caption property is a short textual description (one- line string) of the object.
*/
public CimString getCaption() {
return caption;
}
/**
* The Description property provides a textual description of the object.
*/
public CimString 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 +472,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 CimUnsignedLong getAutomaticStartupActionDelay() {
return automaticStartupActionDelay;
}
@ -435,24 +482,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 CimUnsignedInt 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 CimString based on RFC-2079.
*/
public URI getConfigurationDataRoot() {
public CimString 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 CimString based on RFC-2079.
*/
public URI getConfigurationFile() {
public CimString getConfigurationFile() {
return configurationFile;
}
@ -461,7 +512,7 @@ public class VirtualSystemSettingData extends ManagedElement {
* the InstanceID as it is assigned by the implementation to a virtual system or a virtual system
* configuration. It is not a key, and the same value may occur within more than one instance.
*/
public String getConfigurationID() {
public CimString getConfigurationID() {
return configurationID;
}
@ -473,81 +524,89 @@ 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 CimString based on RFC-2079.
*/
public URI getLogDataRoot() {
public CimString 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 CimString based on RFC-2079.
*/
public URI getRecoveryFile() {
public CimString 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 CimString based on RFC-2079.
*/
public URI getSnapshotDataRoot() {
public CimString 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 CimString based on RFC-2079.
*/
public URI getSuspendDataRoot() {
public CimString 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 CimString based on RFC-2079.
*/
public URI getSwapFileDataRoot() {
public CimString 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
* may be interpreted by the implementation when assigning a VirtualSystemIdentifier.
*/
public String getVirtualSystemIdentifier() {
public CimString getVirtualSystemIdentifier() {
return virtualSystemIdentifier;
}
/**
* VirtualSystemType shall reflect a particular type of virtual system.
*/
public Set<String> getVirtualSystemTypes() {
return virtualSystemTypes;
public CimString getVirtualSystemType() {
return virtualSystemType;
}
/**
* End-user supplied notes that are related to the virtual system.
*/
public String getNotes() {
public CimString getNotes() {
return notes;
}
@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 +617,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,26 @@
* 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 = "vssd", namespaceURI = VCLOUD_CIM_VSSD_NS),
@XmlNs(prefix = "rasd", namespaceURI = VCLOUD_CIM_RASD_NS),
@XmlNs(prefix = "vcloud", namespaceURI = VCLOUD_1_5_NS)
}
)
// http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData
@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 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 {
@XmlAttribute(namespace = "http://schemas.dmtf.org/ovf/envelope/1", required = true)
// TODO Builder
@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

@ -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

@ -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({
@ -63,6 +73,7 @@ public abstract class SectionType {
public static abstract class Builder<B extends Builder<B>> {
private String info;
private Boolean required;
private Set<Link> links = Sets.newLinkedHashSet();
@SuppressWarnings("unchecked")
protected B self() {
@ -103,19 +114,40 @@ public abstract class SectionType {
return self();
}
/**
* @see ResourceType#getLinks()
*/
public B links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return self();
}
/**
* @see ResourceType#getLinks()
*/
public B link(Link link) {
if (links == null)
links = Sets.newLinkedHashSet();
this.links.add(checkNotNull(link, "link"));
return self();
}
public B fromSectionType(SectionType in) {
return info(in.getInfo()).required(in.isRequired());
return info(in.getInfo()).required(in.isRequired()).links(Sets.newLinkedHashSet(in.getLinks()));
}
}
@XmlElement(name = "Info")
@XmlElement(name = "Info", required = true)
private String info;
@XmlAttribute(namespace = VCLOUD_OVF_NS)
private Boolean required;
@XmlElement(name = "Link", namespace = VCLOUD_1_5_NS)
private Set<Link> links = Sets.newLinkedHashSet();
protected SectionType(Builder<?> builder) {
this.info = builder.info;
this.required = builder.required;
this.links = builder.links != null ? ImmutableSet.copyOf(builder.links) : Collections.<Link>emptySet();
}
protected SectionType() {
@ -139,9 +171,16 @@ public abstract class SectionType {
return required;
}
/**
* 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 int hashCode() {
return Objects.hashCode(info, required);
return Objects.hashCode(info, required, links);
}
@Override
@ -153,7 +192,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) && equal(this.links, other.links);
}
@Override
@ -162,7 +201,7 @@ public abstract class SectionType {
}
protected Objects.ToStringHelper string() {
return Objects.toStringHelper("").add("info", info).add("required", required);
return Objects.toStringHelper("").add("info", info).add("required", required).add("links", links);
}
}

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,21 @@
*/
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 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.XmlType;
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 +46,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,8 +64,9 @@ 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 String transport;
protected Set<ResourceAllocationSettingData> items = Sets.newLinkedHashSet();
/**
@ -69,23 +78,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 +110,10 @@ 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();
}
@ -110,20 +126,25 @@ 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());
}
}
@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();
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) : Collections.<ResourceAllocationSettingData>emptySet();
}
private VirtualHardwareSection() {
@ -131,9 +152,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,14 +164,14 @@ 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() {
@ -161,7 +184,7 @@ public class VirtualHardwareSection extends SectionType {
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(), transports, virtualSystem, items);
return Objects.hashCode(super.hashCode(), transport, virtualSystem, items);
}
@Override
@ -169,15 +192,15 @@ 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);
}
@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);
}
}

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

@ -403,7 +403,7 @@ public interface VAppAsyncClient {
*/
@PUT
@Path("/networkConnectionSection")
@Produces(NETWORK_CONFIG_SECTION)
@Produces(NETWORK_CONNECTION_SECTION)
@Consumes(TASK)
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)

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

@ -598,6 +598,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
Owner owner = vApp.getOwner();
@ -727,11 +746,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
}
}
if (hardware.getItems() != null) {
for (ResourceAllocationSettingData item : hardware.getItems()) {
checkResourceAllocationSettingData(item);

View File

@ -28,6 +28,7 @@ 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;
@ -44,8 +45,10 @@ 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.ovf.RASD;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
@ -223,12 +226,24 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
}
}
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);
}

View File

@ -44,14 +44,18 @@ 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.math.BigInteger;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
@ -67,6 +71,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;
@ -81,6 +87,9 @@ 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.VmPendingQuestion;
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.cim.ResourceAllocationSettingData.ResourceType;
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;
@ -93,6 +102,9 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
@ -349,7 +361,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
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());
@ -416,6 +428,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
GuestCustomizationSection oldSection = vAppClient.getGuestCustomizationSection(vmURI);
GuestCustomizationSection newSection = oldSection.toBuilder()
.computerName("newComputerName")
.enabled(Boolean.FALSE)
.adminPassword(null) // Not allowed
.build();
@ -431,6 +444,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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();
@ -567,15 +581,23 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
});
}
// 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
@ -588,8 +610,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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"));
@ -621,13 +643,12 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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();
assertNotNull(newSection.getId());
// The method under test
Task modifyOperatingSystemSection = vAppClient.modifyOperatingSystemSection(vmURI, newSection);
@ -640,11 +661,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
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" })
@ -689,7 +706,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
ProductSectionList newSections = oldSections.toBuilder()
.productSection(ProductSection.builder()
.info("Information about the installed software") // Default ovf:Info text
.required(true)
.required()
.product(MsgType.builder().value("jclouds").build())
.vendor(MsgType.builder().value("jclouds Inc.").build())
// NOTE other ProductSection elements not returned by vCloud
@ -706,21 +723,21 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// Check the retrieved object is well formed
checkProductSectionList(modified);
// Check the modified section fields are set correctly
// 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" })
@ -818,7 +835,24 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// Copy existing section and update fields
VirtualHardwareSection oldSection = vAppClient.getVirtualHardwareSection(vmURI);
VirtualHardwareSection newSection = oldSection.toBuilder().build();
Optional<? extends ResourceAllocationSettingData> memory = Iterables.tryFind(oldSection.getItems(),
new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData item) {
return item.getResourceType() == ResourceType.MEMORY;
}
});
if (memory.isPresent()) debug(memory);
VirtualHardwareSection newSection = oldSection.toBuilder()
.item(ResourceAllocationSettingData.builder()
.elementName(cimString("Memory"))
.instanceID(cimString(UUID.randomUUID().toString()))
.allocationUnits(cimString("byte * 2^20"))
.reservation(cimUnsignedLong(BigInteger.valueOf(0L)))
.virtualQuantity(cimUnsignedLong(BigInteger.valueOf(1024L)))
.weight(cimUnsignedInt(0L))
.build())
.build();
// The method under test
Task modifyVirtualHardwareSection = vAppClient.modifyVirtualHardwareSection(vmURI, newSection);
@ -840,7 +874,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Check the retrieved object is well formed
checkRASD(rasd);
}
@ -878,6 +915,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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
@ -928,6 +966,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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
@ -939,6 +978,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// Get URI for child VM
URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
// Method under test
RASD rasd = vAppClient.getVirtualHardwareSectionCpu(vmURI);
// Check the retrieved object is well formed
@ -973,6 +1013,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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
@ -1007,6 +1048,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
// 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

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,7 +391,7 @@ 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()
@ -411,7 +412,7 @@ 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);