mirror of https://github.com/apache/jclouds.git
Issue 830: Use XmlWrapper for collections in Vdc
This commit is contained in:
parent
25fac3b36e
commit
35391b876b
|
@ -1,139 +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;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a list of references to available networks.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>Java class for AvailableNetworks complex type.
|
||||
* <p/>
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p/>
|
||||
* <pre>
|
||||
* <complexType name="AvailableNetworks">
|
||||
* <complexContent>
|
||||
* <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
|
||||
* <sequence>
|
||||
* <element name="Network" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* <anyAttribute processContents='lax' namespace='##other'/>
|
||||
* </extension>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*/
|
||||
@XmlType(name = "AvailableNetworks", propOrder = {
|
||||
"networks"
|
||||
})
|
||||
public class AvailableNetworks {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromAvailableNetworks(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Set<Reference> networks = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see AvailableNetworks#getNetworks()
|
||||
*/
|
||||
public Builder networks(Collection<Reference> networks) {
|
||||
this.networks = Sets.newLinkedHashSet(checkNotNull(networks, "networks"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AvailableNetworks#getNetworks()
|
||||
*/
|
||||
public Builder network(Reference network) {
|
||||
networks.add(checkNotNull(network, "network"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AvailableNetworks build() {
|
||||
AvailableNetworks availableNetworks = new AvailableNetworks(networks);
|
||||
return availableNetworks;
|
||||
}
|
||||
|
||||
|
||||
public Builder fromAvailableNetworks(AvailableNetworks in) {
|
||||
return networks(in.getNetworks());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Network")
|
||||
protected Set<Reference> networks = Sets.newLinkedHashSet();
|
||||
|
||||
private AvailableNetworks(Set<Reference> networks) {
|
||||
this.networks = ImmutableSet.copyOf(networks);
|
||||
}
|
||||
|
||||
private AvailableNetworks() {
|
||||
// For JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the network property.
|
||||
*/
|
||||
public Set<Reference> getNetworks() {
|
||||
return Collections.unmodifiableSet(this.networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
AvailableNetworks that = AvailableNetworks.class.cast(o);
|
||||
return equal(networks, that.networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("network", networks).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -20,11 +20,17 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -62,13 +68,21 @@ public class Capabilities {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private SupportedHardwareVersions supportedHardwareVersions;
|
||||
private Set<String> supportedHardwareVersions = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see Capabilities#getSupportedHardwareVersions()
|
||||
*/
|
||||
public Builder supportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = supportedHardwareVersions;
|
||||
public Builder supportedHardwareVersions(Set<String> supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = Sets.newLinkedHashSet(checkNotNull(supportedHardwareVersions, "supportedHardwareVersions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Capabilities#getSupportedHardwareVersions()
|
||||
*/
|
||||
public Builder supportedHardwareVersion(String supportedHardwareVersion) {
|
||||
this.supportedHardwareVersions.add(checkNotNull(supportedHardwareVersion, "supportedHardwareVersion"));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -79,12 +93,12 @@ public class Capabilities {
|
|||
|
||||
|
||||
public Builder fromCapabilities(Capabilities in) {
|
||||
return supportedHardwareVersions(in.getSupportedHardwareVersions());
|
||||
return supportedHardwareVersions(Sets.newLinkedHashSet(in.getSupportedHardwareVersions()));
|
||||
}
|
||||
}
|
||||
|
||||
private Capabilities(SupportedHardwareVersions supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = supportedHardwareVersions;
|
||||
private Capabilities(Set<String> supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = supportedHardwareVersions == null ? Sets.<String>newLinkedHashSet() : ImmutableSet.copyOf(supportedHardwareVersions);
|
||||
}
|
||||
|
||||
private Capabilities() {
|
||||
|
@ -92,16 +106,14 @@ public class Capabilities {
|
|||
}
|
||||
|
||||
|
||||
@XmlElement(name = "SupportedHardwareVersions")
|
||||
protected SupportedHardwareVersions supportedHardwareVersions;
|
||||
@XmlElementWrapper(name = "SupportedHardwareVersions")
|
||||
@XmlElement(name = "SupportedHardwareVersion")
|
||||
protected Set<String> supportedHardwareVersions = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Gets the value of the supportedHardwareVersions property.
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link SupportedHardwareVersions }
|
||||
*/
|
||||
public SupportedHardwareVersions getSupportedHardwareVersions() {
|
||||
public Set<String> getSupportedHardwareVersions() {
|
||||
return supportedHardwareVersions;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Basic entity type in the vCloud object model.
|
||||
|
@ -104,7 +105,7 @@ public class EntityType extends ResourceType {
|
|||
|
||||
public B fromEntityType(EntityType in) {
|
||||
return fromResourceType(in)
|
||||
.description(in.getDescription()).tasks(in.getTasks())
|
||||
.description(in.getDescription()).tasks(Sets.newLinkedHashSet(in.getTasks()))
|
||||
.id(in.getId()).name(in.getName());
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +124,7 @@ public class EntityType extends ResourceType {
|
|||
super(builder);
|
||||
this.description = builder.description;
|
||||
// nullable so that jaxb wont persist empty collections
|
||||
this.tasks = builder.tasks != null && builder.tasks.size() == 0 ? null : builder.tasks;
|
||||
this.tasks = builder.tasks == null || builder.tasks.isEmpty() ? null : ImmutableSet.copyOf(builder.tasks);
|
||||
this.id = builder.id;
|
||||
this.name = builder.name;
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ public class EntityType extends ResourceType {
|
|||
* A list of queued, running, or recently completed tasks associated with this entity.
|
||||
*/
|
||||
public Set<Task> getTasks() {
|
||||
return tasks == null ? ImmutableSet.<Task>of() : Collections.unmodifiableSet(tasks);
|
||||
return tasks == null ? ImmutableSet.<Task>of() : ImmutableSet.copyOf(tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,126 +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;
|
||||
|
||||
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.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a list of references to resource entities.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="ResourceEntities" />
|
||||
* </pre>
|
||||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@XmlType(name = "ResourceEntities")
|
||||
public class ResourceEntities {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromResourceEntities(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<Reference> resourceEntities = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see ResourceEntities#getResourceEntities()
|
||||
*/
|
||||
public Builder resourceEntities(Set<Reference> resourceEntities) {
|
||||
this.resourceEntities = ImmutableSet.copyOf(checkNotNull(resourceEntities, "resourceEntities"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ResourceEntities#getResourceEntities()
|
||||
*/
|
||||
public Builder resourceEntity(Reference resourceEntity) {
|
||||
resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceEntities build() {
|
||||
return new ResourceEntities(this.resourceEntities);
|
||||
}
|
||||
|
||||
|
||||
public Builder fromResourceEntities(ResourceEntities in) {
|
||||
return resourceEntities(in.getResourceEntities());
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceEntities() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
private ResourceEntities(Set<Reference> resourceEntity) {
|
||||
this.resourceEntities = ImmutableSet.copyOf(resourceEntity);
|
||||
}
|
||||
|
||||
|
||||
@XmlElement(name = "ResourceEntity")
|
||||
private Set<Reference> resourceEntities = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Gets the value of the resourceEntity property.
|
||||
*/
|
||||
public Set<Reference> getResourceEntities() {
|
||||
return Collections.unmodifiableSet(this.resourceEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ResourceEntities that = ResourceEntities.class.cast(o);
|
||||
return equal(resourceEntities, that.resourceEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(resourceEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("resourceEntity", resourceEntities).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,140 +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;
|
||||
|
||||
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.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a list of supported VM hardware versions.
|
||||
* <p/>
|
||||
* <p/>
|
||||
* <p>Java class for SupportedHardwareVersions complex type.
|
||||
* <p/>
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
* <p/>
|
||||
* <pre>
|
||||
* <complexType name="SupportedHardwareVersions">
|
||||
* <complexContent>
|
||||
* <extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
|
||||
* <sequence>
|
||||
* <element name="SupportedHardwareVersion" type="{http://www.vmware.com/vcloud/v1.5}SupportedHardwareVersionType" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* <anyAttribute processContents='lax' namespace='##other'/>
|
||||
* </extension>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*/
|
||||
@XmlType(name = "SupportedHardwareVersions", propOrder = {
|
||||
"supportedHardwareVersions"
|
||||
})
|
||||
public class SupportedHardwareVersions {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromSupportedHardwareVersions(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private Set<String> supportedHardwareVersions = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see SupportedHardwareVersions#getSupportedHardwareVersions()
|
||||
*/
|
||||
public Builder supportedHardwareVersions(Set<String> supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = Sets.newLinkedHashSet(checkNotNull(supportedHardwareVersions, "supportedHardwareVersions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SupportedHardwareVersions#getSupportedHardwareVersions()
|
||||
*/
|
||||
public Builder supportedHardwareVersion(String supportedHardwareVersion) {
|
||||
supportedHardwareVersions.add(checkNotNull(supportedHardwareVersion, "supportedHardwareVersion"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public SupportedHardwareVersions build() {
|
||||
SupportedHardwareVersions supportedHardwareVersions = new SupportedHardwareVersions(this.supportedHardwareVersions);
|
||||
return supportedHardwareVersions;
|
||||
}
|
||||
|
||||
|
||||
public Builder fromSupportedHardwareVersions(SupportedHardwareVersions in) {
|
||||
return supportedHardwareVersions(in.getSupportedHardwareVersions());
|
||||
}
|
||||
}
|
||||
|
||||
private SupportedHardwareVersions() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
private SupportedHardwareVersions(Set<String> supportedHardwareVersions) {
|
||||
this.supportedHardwareVersions = ImmutableSet.copyOf(supportedHardwareVersions);
|
||||
}
|
||||
|
||||
|
||||
@XmlElement(name = "SupportedHardwareVersion")
|
||||
protected Set<String> supportedHardwareVersions = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Gets the value of the supportedHardwareVersion property.
|
||||
*/
|
||||
public Set<String> getSupportedHardwareVersions() {
|
||||
return Collections.unmodifiableSet(supportedHardwareVersions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
SupportedHardwareVersions that = SupportedHardwareVersions.class.cast(o);
|
||||
return equal(supportedHardwareVersions, that.supportedHardwareVersions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(supportedHardwareVersions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("supportedHardwareVersion", supportedHardwareVersions).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -19,15 +19,21 @@
|
|||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Represents a virtual data center (vDC).
|
||||
|
@ -45,6 +51,7 @@ public class Vdc extends EntityType {
|
|||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromVdc(this);
|
||||
}
|
||||
|
@ -56,8 +63,8 @@ public class Vdc extends EntityType {
|
|||
private String allocationModel;
|
||||
private CapacityWithUsage storageCapacity;
|
||||
private ComputeCapacity computeCapacity;
|
||||
private ResourceEntities resourceEntities;
|
||||
private AvailableNetworks availableNetworks;
|
||||
private Set<Reference> resourceEntities = Sets.newLinkedHashSet();
|
||||
private Set<Reference> availableNetworks = Sets.newLinkedHashSet();
|
||||
private Capabilities capabilities;
|
||||
private Integer nicQuota;
|
||||
private Integer networkQuota;
|
||||
|
@ -92,16 +99,32 @@ public class Vdc extends EntityType {
|
|||
/**
|
||||
* @see Vdc#getResourceEntities()
|
||||
*/
|
||||
public B resourceEntities(ResourceEntities resourceEntities) {
|
||||
this.resourceEntities = resourceEntities;
|
||||
public B resourceEntities(Set<Reference> resourceEntities) {
|
||||
this.resourceEntities = Sets.newLinkedHashSet(checkNotNull(resourceEntities, "resourceEntities"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Vdc#getResourceEntities()
|
||||
*/
|
||||
public B resourceEntity(Reference resourceEntity) {
|
||||
this.resourceEntities.add(checkNotNull(resourceEntity, "resourceEntity"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Vdc#getAvailableNetworks()
|
||||
*/
|
||||
public B availableNetworks(AvailableNetworks availableNetworks) {
|
||||
this.availableNetworks = availableNetworks;
|
||||
public B availableNetworks(Set<Reference> availableNetworks) {
|
||||
this.availableNetworks = Sets.newLinkedHashSet(checkNotNull(availableNetworks, "availableNetworks"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Vdc#getAvailableNetworks()
|
||||
*/
|
||||
public B network(Reference availableNetwork) {
|
||||
this.availableNetworks.add(checkNotNull(availableNetwork, "availableNetwork"));;
|
||||
return self();
|
||||
}
|
||||
|
||||
|
@ -163,8 +186,8 @@ public class Vdc extends EntityType {
|
|||
.allocationModel(in.getAllocationModel())
|
||||
.storageCapacity(in.getStorageCapacity())
|
||||
.computeCapacity(in.getComputeCapacity())
|
||||
.resourceEntities(in.getResourceEntities())
|
||||
.availableNetworks(in.getAvailableNetworks())
|
||||
.resourceEntities(Sets.newLinkedHashSet(in.getResourceEntities()))
|
||||
.availableNetworks(Sets.newLinkedHashSet(in.getAvailableNetworks()))
|
||||
.capabilities(in.getCapabilities())
|
||||
.nicQuota(in.getNicQuota())
|
||||
.networkQuota(in.getNetworkQuota())
|
||||
|
@ -183,8 +206,8 @@ public class Vdc extends EntityType {
|
|||
this.allocationModel = builder.allocationModel;
|
||||
this.storageCapacity = builder.storageCapacity;
|
||||
this.computeCapacity = builder.computeCapacity;
|
||||
this.resourceEntities = builder.resourceEntities;
|
||||
this.availableNetworks = builder.availableNetworks;
|
||||
this.resourceEntities = builder.resourceEntities == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.resourceEntities);
|
||||
this.availableNetworks = builder.availableNetworks == null ? Sets.<Reference>newLinkedHashSet() : ImmutableSet.copyOf(builder.availableNetworks);
|
||||
this.capabilities = builder.capabilities;
|
||||
this.nicQuota = builder.nicQuota;
|
||||
this.networkQuota = builder.networkQuota;
|
||||
|
@ -199,10 +222,12 @@ public class Vdc extends EntityType {
|
|||
private CapacityWithUsage storageCapacity;
|
||||
@XmlElement(name = "ComputeCapacity", required = true)
|
||||
private ComputeCapacity computeCapacity;
|
||||
@XmlElement(name = "ResourceEntities")
|
||||
private ResourceEntities resourceEntities;
|
||||
@XmlElement(name = "AvailableNetworks")
|
||||
private AvailableNetworks availableNetworks;
|
||||
@XmlElementWrapper(name = "ResourceEntities")
|
||||
@XmlElement(name = "ResourceEntity")
|
||||
private Set<Reference> resourceEntities = Sets.newLinkedHashSet();
|
||||
@XmlElementWrapper(name = "AvailableNetworks")
|
||||
@XmlElement(name = "Network")
|
||||
protected Set<Reference> availableNetworks = Sets.newLinkedHashSet();
|
||||
@XmlElement(name = "Capabilities")
|
||||
private Capabilities capabilities;
|
||||
@XmlElement(name = "NicQuota")
|
||||
|
@ -240,14 +265,14 @@ public class Vdc extends EntityType {
|
|||
/**
|
||||
* Gets the value of the resourceEntities property.
|
||||
*/
|
||||
public ResourceEntities getResourceEntities() {
|
||||
public Set<Reference> getResourceEntities() {
|
||||
return resourceEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the availableNetworks property.
|
||||
*/
|
||||
public AvailableNetworks getAvailableNetworks() {
|
||||
public Set<Reference> getAvailableNetworks() {
|
||||
return availableNetworks;
|
||||
}
|
||||
|
||||
|
|
|
@ -520,27 +520,10 @@ public class Checks {
|
|||
assertTrue(capacity.getAllocated() >= 0, "allocated must be greater than or equal to 0");
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkResourceEntities(ResourceEntities resourceEntities) {
|
||||
for (Reference resourceEntity : resourceEntities.getResourceEntities()) {
|
||||
checkReferenceType(resourceEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAvailableNetworks(AvailableNetworks availableNetworks) {
|
||||
for (Reference network : availableNetworks.getNetworks()) {
|
||||
checkReferenceType(network);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkCapabilities(Capabilities capabilities) {
|
||||
// Check optional fields
|
||||
if (capabilities.getSupportedHardwareVersions() != null) {
|
||||
checkSupportedHardwareVersions(capabilities.getSupportedHardwareVersions());
|
||||
}
|
||||
}
|
||||
public static void checkSupportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) {
|
||||
for (String supportedHardwareVersion : supportedHardwareVersions.getSupportedHardwareVersions()) {
|
||||
for (String supportedHardwareVersion : capabilities.getSupportedHardwareVersions()) {
|
||||
// NOTE supportedHardwareVersion cannot be checked?
|
||||
}
|
||||
}
|
||||
|
@ -1469,11 +1452,11 @@ public class Checks {
|
|||
|
||||
// optional
|
||||
// NOTE isEnabled cannot be checked
|
||||
if (vdc.getResourceEntities() != null) {
|
||||
checkResourceEntities(vdc.getResourceEntities());
|
||||
for (Reference resourceEntity : vdc.getResourceEntities()) {
|
||||
checkReferenceType(resourceEntity);
|
||||
}
|
||||
if (vdc.getAvailableNetworks() != null) {
|
||||
checkAvailableNetworks(vdc.getAvailableNetworks());
|
||||
for (Reference availableNetwork : vdc.getAvailableNetworks()) {
|
||||
checkReferenceType(availableNetwork);
|
||||
}
|
||||
if (vdc.getCapabilities() != null) {
|
||||
checkCapabilities(vdc.getCapabilities());
|
||||
|
|
|
@ -179,18 +179,17 @@ public abstract class AbstractVAppClientLiveTest extends BaseVCloudDirectorClien
|
|||
|
||||
@AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting created VApps")
|
||||
protected void cleanUp() {
|
||||
// Find references in the Vdc with the VApp type and named 'test-vapp' or 'new-name'
|
||||
// Find references in the Vdc with the VApp type and in the list of instantiated VApp names
|
||||
Iterable<Reference> vApps = Iterables.filter(
|
||||
vdc.getResourceEntities().getResourceEntities(),
|
||||
vdc.getResourceEntities(),
|
||||
Predicates.and(
|
||||
ReferenceTypePredicates.<Reference>typeEquals(VCloudDirectorMediaType.VAPP),
|
||||
ReferenceTypePredicates.<Reference>nameIn(vAppNames)
|
||||
)
|
||||
);
|
||||
vAppNames.clear();
|
||||
|
||||
// If we found any references, delete the VApp they point to
|
||||
if (vApps != null && !Iterables.isEmpty(vApps)) {
|
||||
if (!Iterables.isEmpty(vApps)) {
|
||||
for (Reference ref : vApps) {
|
||||
cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting
|
||||
}
|
||||
|
|
|
@ -635,7 +635,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
@Test(testName = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetNetworkConnectionSection" })
|
||||
public void testModifyNetworkConnectionSection() {
|
||||
// Look up a network in the Vdc
|
||||
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
|
||||
Set<Reference> networks = vdc.getAvailableNetworks();
|
||||
Reference network = Iterables.getLast(networks);
|
||||
|
||||
// Copy existing section and update fields
|
||||
|
|
|
@ -371,7 +371,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
@Test(testName = "PUT /vAppTemplate/{id}/networkConnectionSection")
|
||||
public void testEditNetworkConnectionSection() {
|
||||
// Look up a network in the Vdc
|
||||
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
|
||||
Set<Reference> networks = vdc.getAvailableNetworks();
|
||||
Reference network = Iterables.getLast(networks);
|
||||
|
||||
// Copy existing section and update fields
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.AvailableNetworks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Capabilities;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CapacityWithUsage;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams;
|
||||
|
@ -41,8 +41,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Media;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntities;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SupportedHardwareVersions;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
|
@ -467,47 +465,41 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
|||
.overhead(0l)
|
||||
.build())
|
||||
.build())
|
||||
.resourceEntities(ResourceEntities.builder()
|
||||
.resourceEntity(Reference.builder()
|
||||
.resourceEntity(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.vApp+xml")
|
||||
.name("vcdcap-db9")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/vApp/vapp-e2a4ab74-ea62-4afa-8bb7-0c11259044fb"))
|
||||
.build())
|
||||
.resourceEntity(Reference.builder()
|
||||
.resourceEntity(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.vAppTemplate+xml")
|
||||
.name("adriancolecap")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/vAppTemplate/vappTemplate-5571eb21-f532-4506-9737-01a4635a04cb"))
|
||||
.build())
|
||||
.resourceEntity(Reference.builder()
|
||||
.resourceEntity(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.media+xml")
|
||||
.name("DansTestMedia")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/media/794eb334-754e-4917-b5a0-5df85cbd61d1"))
|
||||
.build())
|
||||
.build())
|
||||
.availableNetworks(AvailableNetworks.builder()
|
||||
.network(Reference.builder()
|
||||
.network(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.network+xml")
|
||||
.name("orgNet-cloudsoft-Isolated")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/network/a604f3c2-0343-453e-ae1f-cddac5b7bd94"))
|
||||
.build())
|
||||
.network(Reference.builder()
|
||||
.network(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.network+xml")
|
||||
.name("orgNet-cloudsoft-External")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"))
|
||||
.build())
|
||||
.network(Reference.builder()
|
||||
.network(Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.network+xml")
|
||||
.name("orgNet-cloudsoft-Internal-Routed")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/network/6d7392e2-c816-43fb-99be-f9ebcd70abf6"))
|
||||
.build())
|
||||
.build())
|
||||
.capabilities(Capabilities.builder()
|
||||
.supportedHardwareVersions(SupportedHardwareVersions.builder()
|
||||
.supportedHardwareVersion("vmx-04")
|
||||
.supportedHardwareVersion("vmx-07")
|
||||
.supportedHardwareVersion("vmx-08")
|
||||
.build())
|
||||
.build())
|
||||
.nicQuota(0)
|
||||
.networkQuota(10)
|
||||
.vmQuota(10)
|
||||
|
|
|
@ -228,7 +228,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void testInstantiateVAppTemplate() {
|
||||
Vdc vdc = vdcClient.getVdc(vdcURI);
|
||||
|
||||
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
|
||||
Set<Reference> networks = vdc.getAvailableNetworks();
|
||||
Optional<Reference> parentNetwork = Iterables.tryFind(
|
||||
networks, new Predicate<Reference>() {
|
||||
@Override
|
||||
|
|
|
@ -97,7 +97,7 @@ import com.google.inject.Module;
|
|||
public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
protected Logger logger = Logger.CONSOLE;
|
||||
|
||||
protected static final long TASK_TIMEOUT_SECONDS = 100L;
|
||||
protected static final long LONG_TASK_TIMEOUT_SECONDS = 300L;
|
||||
|
@ -320,7 +320,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
|||
Vdc vdc = context.getApi().getVdcClient().getVdc(vdcURI);
|
||||
assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC));
|
||||
|
||||
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
|
||||
Set<Reference> networks = vdc.getAvailableNetworks();
|
||||
|
||||
// Look up the network in the Vdc with the id configured for the tests
|
||||
Optional<Reference> parentNetwork = Iterables.tryFind(networks, new Predicate<Reference>() {
|
||||
|
@ -401,6 +401,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
|||
try {
|
||||
Task task = vappClient.deleteVApp(vAppUri);
|
||||
assertTaskSucceeds(task);
|
||||
vAppNames.remove(vApp.getName());
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
vApp = vappClient.getVApp(vAppUri); // refresh
|
||||
|
|
Loading…
Reference in New Issue