Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Mike Arnold 2012-03-13 10:26:44 -05:00
commit c92a76cc8e
13 changed files with 707 additions and 141 deletions

View File

@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.Media;
@ -31,6 +32,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.GroupAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
@ -136,4 +138,10 @@ public interface VCloudDirectorAsyncClient {
*/
@Delegate
UserAsyncClient getUserClient();
/**
* @return asynchronous access to {@link AdminVdc} features
*/
@Delegate
AdminVdcAsyncClient getAdminVdcClient();
}

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.Media;
@ -34,6 +35,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Vdc;
import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogClient;
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
import org.jclouds.vcloud.director.v1_5.features.AdminVdcClient;
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
import org.jclouds.vcloud.director.v1_5.features.GroupClient;
import org.jclouds.vcloud.director.v1_5.features.MediaClient;
@ -139,4 +141,10 @@ public interface VCloudDirectorClient {
*/
@Delegate
UserClient getUserClient();
/**
* @return synchronous access to {@link AdminVdc} features
*/
@Delegate
AdminVdcClient getAdminVdcClient();
}

View File

@ -157,6 +157,8 @@ public class VCloudDirectorMediaType {
public static final String ROLE = "application/vnd.vmware.admin.role+xml";
public static final String ADMIN_VDC = "application/vnd.vmware.admin.vdc+xml";
/**
* All acceptable media types.
*
@ -177,6 +179,6 @@ public class VCloudDirectorMediaType {
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK,
ADMIN_ORG_NETWORK, USER, ROLE
ADMIN_ORG_NETWORK, USER, ROLE, ADMIN_VDC
);
}

View File

@ -0,0 +1,323 @@
/**
* 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 javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* Provides an administrative view of a vDC. Includes all members
* of the Vdc element, and adds several elements that can be
* viewed and modified only by administrators.
*
*
* <p>Java class for AdminVdc complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="AdminVdc">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VdcType">
* &lt;sequence>
* &lt;element name="ResourceGuaranteedMemory" type="{http://www.w3.org/2001/XMLSchema}double" minOccurs="0"/>
* &lt;element name="ResourceGuaranteedCpu" type="{http://www.w3.org/2001/XMLSchema}double" minOccurs="0"/>
* &lt;element name="VCpuInMhz" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
* &lt;element name="IsThinProvision" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* &lt;element name="NetworkPoolReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" minOccurs="0"/>
* &lt;element name="ProviderVdcReference" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" minOccurs="0"/>
* &lt;element name="UsesFastProvisioning" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AdminVdc", propOrder = {
"resourceGuaranteedMemory",
"resourceGuaranteedCpu",
"vCpuInMhz",
"isThinProvision",
"networkPoolReference",
"providerVdcReference",
"usesFastProvisioning"
})
public class AdminVdc extends Vdc {
public static Builder<?> builder() {
return new ConcreteBuilder();
}
public static abstract class Builder<T extends Builder<T>> extends Vdc.Builder<T> {
private Double resourceGuaranteedMemory;
private Double resourceGuaranteedCpu;
private Long vCpuInMhz;
private Boolean isThinProvision;
private Reference networkPoolReference;
private Reference providerVdcReference;
private Boolean usesFastProvisioning;
/**
* @see AdminVdc#getResourceGuaranteedMemory()
*/
public T resourceGuaranteedMemory(Double resourceGuaranteedMemory) {
this.resourceGuaranteedMemory = resourceGuaranteedMemory;
return self();
}
/**
* @see AdminVdc#getResourceGuaranteedCpu()
*/
public T resourceGuaranteedCpu(Double resourceGuaranteedCpu) {
this.resourceGuaranteedCpu = resourceGuaranteedCpu;
return self();
}
/**
* @see AdminVdc#getVCpuInMhz()
*/
public T vCpuInMhz(Long vCpuInMhz) {
this.vCpuInMhz = vCpuInMhz;
return self();
}
/**
* @see AdminVdc#getIsThinProvision()
*/
public T isThinProvision(Boolean isThinProvision) {
this.isThinProvision = isThinProvision;
return self();
}
/**
* @see AdminVdc#getNetworkPoolReference()
*/
public T networkPoolReference(Reference networkPoolReference) {
this.networkPoolReference = networkPoolReference;
return self();
}
/**
* @see AdminVdc#getProviderVdcReference()
*/
public T providerVdcReference(Reference providerVdcReference) {
this.providerVdcReference = providerVdcReference;
return self();
}
/**
* @see AdminVdc#getUsesFastProvisioning()
*/
public T usesFastProvisioning(Boolean usesFastProvisioning) {
this.usesFastProvisioning = usesFastProvisioning;
return self();
}
public AdminVdc build() {
return new AdminVdc(this);
}
public T fromAdminVdc(AdminVdc in) {
return fromVdc(in)
.resourceGuaranteedMemory(in.getResourceGuaranteedMemory())
.resourceGuaranteedCpu(in.getResourceGuaranteedCpu())
.vCpuInMhz(in.getVCpuInMhz())
.isThinProvision(in.isThinProvision())
.networkPoolReference(in.getNetworkPoolReference())
.providerVdcReference(in.getProviderVdcReference())
.usesFastProvisioning(in.usesFastProvisioning());
}
}
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override protected ConcreteBuilder self() {
return this;
}
}
@SuppressWarnings("unused")
private AdminVdc() {
// For JAXB
}
public AdminVdc(Builder<?> b) {
super(b);
resourceGuaranteedMemory = b.resourceGuaranteedMemory;
resourceGuaranteedCpu = b.resourceGuaranteedCpu;
vCpuInMhz = b.vCpuInMhz;
isThinProvision = b.isThinProvision;
networkPoolReference = b.networkPoolReference;
providerVdcReference = b.providerVdcReference;
usesFastProvisioning = b.usesFastProvisioning;
}
@XmlElement(name = "ResourceGuaranteedMemory")
protected Double resourceGuaranteedMemory;
@XmlElement(name = "ResourceGuaranteedCpu")
protected Double resourceGuaranteedCpu;
@XmlElement(name = "VCpuInMhz")
protected Long vCpuInMhz;
@XmlElement(name = "IsThinProvision")
protected Boolean isThinProvision;
@XmlElement(name = "NetworkPoolReference")
protected Reference networkPoolReference;
@XmlElement(name = "ProviderVdcReference")
protected Reference providerVdcReference;
@XmlElement(name = "UsesFastProvisioning")
protected Boolean usesFastProvisioning;
/**
* Gets the value of the resourceGuaranteedMemory property.
*
* @return
* possible object is
* {@link Double }
*
*/
public Double getResourceGuaranteedMemory() {
return resourceGuaranteedMemory;
}
/**
* Gets the value of the resourceGuaranteedCpu property.
*
* @return
* possible object is
* {@link Double }
*
*/
public Double getResourceGuaranteedCpu() {
return resourceGuaranteedCpu;
}
/**
* Gets the value of the vCpuInMhz property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getVCpuInMhz() {
return vCpuInMhz;
}
/**
* Gets the value of the isThinProvision property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isThinProvision() {
return isThinProvision;
}
/**
* Gets the value of the networkPoolReference property.
*
* @return
* possible object is
* {@link Reference }
*
*/
public Reference getNetworkPoolReference() {
return networkPoolReference;
}
/**
* Gets the value of the providerVdcReference property.
*
* @return
* possible object is
* {@link Reference }
*
*/
public Reference getProviderVdcReference() {
return providerVdcReference;
}
/**
* Gets the value of the usesFastProvisioning property.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean usesFastProvisioning() {
return usesFastProvisioning;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
AdminVdc that = AdminVdc.class.cast(o);
return super.equals(that) &&
equal(resourceGuaranteedMemory, that.resourceGuaranteedMemory) &&
equal(resourceGuaranteedCpu, that.resourceGuaranteedCpu) &&
equal(vCpuInMhz, that.vCpuInMhz) &&
equal(isThinProvision, that.isThinProvision) &&
equal(networkPoolReference, that.networkPoolReference) &&
equal(providerVdcReference, that.providerVdcReference) &&
equal(usesFastProvisioning, that.usesFastProvisioning);
}
@Override
public int hashCode() {
return Objects.hashCode(super.hashCode(),
resourceGuaranteedMemory,
resourceGuaranteedCpu,
vCpuInMhz,
isThinProvision,
networkPoolReference,
providerVdcReference,
usesFastProvisioning);
}
@Override
public ToStringHelper string() {
return super.string()
.add("resourceGuaranteedMemory", resourceGuaranteedMemory)
.add("resourceGuaranteedCpu", resourceGuaranteedCpu)
.add("vCpuInMhz", vCpuInMhz)
.add("isThinProvision", isThinProvision)
.add("networkPoolReference", networkPoolReference)
.add("providerVdcReference", providerVdcReference)
.add("usesFastProvisioning", usesFastProvisioning);
}
}

View File

@ -21,9 +21,6 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@ -31,6 +28,7 @@ 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;
/**
@ -78,23 +76,24 @@ import com.google.common.base.Objects;
"isEnabled"
})
@XmlSeeAlso({
// AdminVdc.class
AdminVdc.class
})
public class Vdc
extends EntityType<Vdc>
{
public static Builder builder() {
return new Builder();
public class Vdc extends EntityType<Vdc> {
public static Builder<?> builder() {
return new ConcreteBuilder();
}
@Override
public Builder toBuilder() {
return new Builder().fromVdc(this);
public Builder<?> toNewBuilder() {
return new ConcreteBuilder();
}
public static class Builder extends EntityType.Builder<Vdc> {
@Override
public ResourceType.Builder<Vdc> toBuilder() {
throw new UnsupportedOperationException("Use new builder");
}
public abstract static class Builder<T extends Builder<T>> extends EntityType.NewBuilder<T> {
private String allocationModel;
private CapacityWithUsage storageCapacity;
private ComputeCapacity computeCapacity;
@ -110,174 +109,96 @@ public class Vdc
/**
* @see Vdc#getAllocationModel()
*/
public Builder allocationModel(String allocationModel) {
public T allocationModel(String allocationModel) {
this.allocationModel = allocationModel;
return this;
return self();
}
/**
* @see Vdc#getStorageCapacity()
*/
public Builder storageCapacity(CapacityWithUsage storageCapacity) {
public T storageCapacity(CapacityWithUsage storageCapacity) {
this.storageCapacity = storageCapacity;
return this;
return self();
}
/**
* @see Vdc#getComputeCapacity()
*/
public Builder computeCapacity(ComputeCapacity computeCapacity) {
public T computeCapacity(ComputeCapacity computeCapacity) {
this.computeCapacity = computeCapacity;
return this;
return self();
}
/**
* @see Vdc#getResourceEntities()
*/
public Builder resourceEntities(ResourceEntities resourceEntities) {
public T resourceEntities(ResourceEntities resourceEntities) {
this.resourceEntities = resourceEntities;
return this;
return self();
}
/**
* @see Vdc#getAvailableNetworks()
*/
public Builder availableNetworks(AvailableNetworks availableNetworks) {
public T availableNetworks(AvailableNetworks availableNetworks) {
this.availableNetworks = availableNetworks;
return this;
return self();
}
/**
* @see Vdc#getCapabilities()
*/
public Builder capabilities(Capabilities capabilities) {
public T capabilities(Capabilities capabilities) {
this.capabilities = capabilities;
return this;
return self();
}
/**
* @see Vdc#getNicQuota()
*/
public Builder nicQuota(int nicQuota) {
public T nicQuota(int nicQuota) {
this.nicQuota = nicQuota;
return this;
return self();
}
/**
* @see Vdc#getNetworkQuota()
*/
public Builder networkQuota(int networkQuota) {
public T networkQuota(int networkQuota) {
this.networkQuota = networkQuota;
return this;
return self();
}
/**
* @see Vdc#getVmQuota()
*/
public Builder vmQuota(Integer vmQuota) {
public T vmQuota(Integer vmQuota) {
this.vmQuota = vmQuota;
return this;
return self();
}
/**
* @see Vdc#isEnabled()
*/
public Builder isEnabled(Boolean isEnabled) {
public T isEnabled(Boolean isEnabled) {
this.isEnabled = isEnabled;
return this;
return self();
}
/**
* @see Vdc#getStatus()
*/
public Builder status(Integer status) {
public T status(Integer status) {
this.status = status;
return this;
return self();
}
public Vdc build() {
return new Vdc(
href, type, links, description, tasks, id, name, allocationModel, storageCapacity,
computeCapacity, resourceEntities, availableNetworks, capabilities, nicQuota, networkQuota,
vmQuota, isEnabled, status);
return new Vdc(this);
}
/**
* @see EntityType#getName()
*/
public Builder name(String name) {
super.name(name);
return this;
}
/**
* @see EntityType#getDescription()
*/
public Builder description(String description) {
super.description(description);
return this;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasks()
*/
@Override
public Builder tasks(Set<Task> tasks) {
super.tasks(tasks);
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see EntityType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
super.links(links);
return this;
}
/**
* @see EntityType#getLinks()
*/
@Override
public Builder link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromEntityType(EntityType<Vdc> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromVdc(Vdc in) {
public T fromVdc(Vdc in) {
return fromEntityType(in)
.allocationModel(in.getAllocationModel())
.storageCapacity(in.getStorageCapacity())
@ -292,26 +213,31 @@ public class Vdc
.status(in.getStatus());
}
}
public Vdc(URI href, String type, Set<Link> links, String description, Set<Task> tasks, String id, String name, String allocationModel, CapacityWithUsage storageCapacity, ComputeCapacity computeCapacity, ResourceEntities resourceEntities, AvailableNetworks availableNetworks, Capabilities capabilities, int nicQuota, int networkQuota, Integer vmQuota, Boolean enabled, Integer status) {
super(href, type, links, description, tasks, id, name);
this.allocationModel = allocationModel;
this.storageCapacity = storageCapacity;
this.computeCapacity = computeCapacity;
this.resourceEntities = resourceEntities;
this.availableNetworks = availableNetworks;
this.capabilities = capabilities;
this.nicQuota = nicQuota;
this.networkQuota = networkQuota;
this.vmQuota = vmQuota;
isEnabled = enabled;
this.status = status;
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override protected ConcreteBuilder self() {
return this;
}
}
private Vdc() {
protected Vdc() {
// For JAXB
}
public Vdc(Builder<?> b) {
super(b.href, b.type, b.links, b.description, b.tasks, b.id, b.name);
this.allocationModel = b.allocationModel;
this.storageCapacity = b.storageCapacity;
this.computeCapacity = b.computeCapacity;
this.resourceEntities = b.resourceEntities;
this.availableNetworks = b.availableNetworks;
this.capabilities = b.capabilities;
this.nicQuota = b.nicQuota;
this.networkQuota = b.networkQuota;
this.vmQuota = b.vmQuota;
isEnabled = b.isEnabled;
this.status = b.status;
}
@XmlElement(name = "AllocationModel", required = true)
protected String allocationModel;
@ -447,7 +373,8 @@ public class Vdc
if (o == null || getClass() != o.getClass())
return false;
Vdc that = Vdc.class.cast(o);
return equal(allocationModel, that.allocationModel) &&
return super.equals(that) &&
equal(allocationModel, that.allocationModel) &&
equal(storageCapacity, that.storageCapacity) &&
equal(computeCapacity, that.computeCapacity) &&
equal(resourceEntities, that.resourceEntities) &&
@ -462,7 +389,8 @@ public class Vdc
@Override
public int hashCode() {
return Objects.hashCode(allocationModel,
return Objects.hashCode(super.hashCode(),
allocationModel,
storageCapacity,
computeCapacity,
resourceEntities,
@ -476,8 +404,8 @@ public class Vdc
}
@Override
public String toString() {
return Objects.toStringHelper("")
public ToStringHelper string() {
return super.string()
.add("allocationModel", allocationModel)
.add("storageCapacity", storageCapacity)
.add("computeCapacity", computeCapacity)
@ -488,7 +416,7 @@ public class Vdc
.add("networkQuota", networkQuota)
.add("vmQuota", vmQuota)
.add("isEnabled", isEnabled)
.add("status", status).toString();
.add("status", status);
}
}

View File

@ -0,0 +1,51 @@
/**
* 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.features;
import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see AdminVdcClient
* @author danikov
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface AdminVdcAsyncClient extends VdcAsyncClient {
/**
* @see AdminVdcClient#getVdc(URI)
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<AdminVdc> getVdc(@EndpointParam URI vdcRef);
}

View File

@ -0,0 +1,48 @@
/**
* 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.features;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
/**
* Provides synchronous access to Network.
* <p/>
*
* @see NetworkAsyncClient
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
* @author danikov
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface AdminVdcClient extends VdcClient {
/**
* Retrieves an admin view of virtual data center. The redwood admin can disable an
* organization vDC. This will prevent any further allocation to be used by the organization.
* Changing the state will not affect allocations already used. For example, if an organization
* vDC is disabled, an organization user cannot deploy or create a new virtual machine in the
* vDC (deploy uses memory and cpu allocations, and create uses storage allocation).
*
* @return the admin vDC or null if not found
*/
AdminVdc getVdc(URI vdcRef);
}

View File

@ -66,7 +66,7 @@ public interface VdcAsyncClient {
@Consumes
@JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Vdc> getVdc(@EndpointParam URI vdcURI);
ListenableFuture<? extends Vdc> getVdc(@EndpointParam URI vdcURI);
/**
* @see VdcClient#captureVApp(URI, CaptureVAppParams)

View File

@ -796,4 +796,64 @@ public class Checks {
public static void checkTelephone(String number) {
// TODO: regex validate telephone
}
public static void checkAdminVdc(AdminVdc vdc) {
// optional
// NOTE isThinProvision cannot be checked
// NOTE usesFastProvisioning cannot be checked
if (vdc.getResourceGuaranteedMemory() != null) {
// TODO: between 0 and 1 inc.
}
if (vdc.getResourceGuaranteedCpu() != null) {
// TODO: between 0 and 1 inc.
}
if (vdc.getVCpuInMhz() != null) {
assertTrue(vdc.getVCpuInMhz() >= 0, String.format(OBJ_FIELD_GTE_0,
"Vdc", "cCpuInMhz", vdc.getVCpuInMhz()));
}
if (vdc.getNetworkPoolReference() != null) {
checkReferenceType(vdc.getNetworkPoolReference());
}
if (vdc.getProviderVdcReference() != null) {
checkReferenceType(vdc.getProviderVdcReference());
}
// parent type
checkVdc(vdc);
}
public static void checkVdc(Vdc vdc) {
// required
assertNotNull(vdc.getAllocationModel(), String.format(OBJ_FIELD_REQ, "Vdc", "allocationModel"));
// one of: AllocationVApp, AllocationPool, ReservationPool
assertNotNull(vdc.getStorageCapacity(), String.format(OBJ_FIELD_REQ, "Vdc", "storageCapacity"));
checkCapacityWithUsage(vdc.getStorageCapacity());
assertNotNull(vdc.getComputeCapacity(), String.format(OBJ_FIELD_REQ, "Vdc", "computeCapacity"));
checkComputeCapacity(vdc.getComputeCapacity());
assertNotNull(vdc.getNicQuota(), String.format(OBJ_FIELD_REQ, "Vdc", "nicQuota"));
assertTrue(vdc.getNicQuota() >= 0, String.format(OBJ_FIELD_GTE_0,
"Vdc", "nicQuota", vdc.getNicQuota()));
assertNotNull(vdc.getNetworkQuota(), String.format(OBJ_FIELD_REQ, "Vdc", "networkQuota"));
assertTrue(vdc.getNetworkQuota() >= 0, String.format(OBJ_FIELD_GTE_0,
"Vdc", "networkQuota", vdc.getNetworkQuota()));
// optional
// NOTE isEnabled cannot be checked
if (vdc.getResourceEntities() != null) {
checkResourceEntities(vdc.getResourceEntities());
}
if (vdc.getAvailableNetworks() != null) {
checkAvailableNetworks(vdc.getAvailableNetworks());
}
if (vdc.getCapabilities() != null) {
checkCapabilities(vdc.getCapabilities());
}
if (vdc.getVmQuota() != null) {
assertTrue(vdc.getVmQuota() >= 0, String.format(OBJ_FIELD_GTE_0,
"Vdc", "vmQuota", vdc.getVmQuota()));
}
// parent type
checkEntityType(vdc);
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.features;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test;
/**
* Allows us to test a client via its side effects.
*
* @author danikov
*/
@Test(groups = { "unit", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientExpectTest")
public class AdminVdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
private Reference vdcRef = Reference.builder()
.href(URI.create(endpoint + "???"))
.build();
@Test( enabled = false )
public void testGetVdc() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("GET", "/admin/vdc/???")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/vdc/admin/vdc.xml",
VCloudDirectorMediaType.ADMIN_VDC)
.httpResponseBuilder().build());
AdminVdc expected = adminVdc();
assertEquals(client.getAdminVdcClient().getVdc(vdcRef.getHref()), expected);
}
public static final AdminVdc adminVdc() {
return AdminVdc.builder().fromVdc(VdcClientExpectTest.getVdc())
.build();
}
}

View File

@ -0,0 +1,63 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless(Link.builder().required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
import static org.testng.Assert.assertNotNull;
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
import org.jclouds.vcloud.director.v1_5.domain.Checks;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests behavior of {@link NetworkClient}
*
* @author danikov
*/
@Test(groups = { "live", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientLiveTest")
public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String VDC = "admin vdc";
/*
* Convenience reference to API client.
*/
protected AdminVdcClient vdcClient;
@Override
@BeforeClass(inheritGroups = true)
public void setupRequiredClients() {
vdcClient = context.getApi().getAdminVdcClient();
}
@Test(testName = "GET /admin/vdc/{id}", enabled = false)
public void testGetNetwork() {
// required for testing
assertNotNull(vdcURI, String.format(REF_REQ_LIVE, VDC));
AdminVdc vdc = vdcClient.getVdc(toAdminUri(vdcURI));
assertNotNull(vdc, String.format(OBJ_REQ_LIVE, VDC));
// parent type
Checks.checkAdminVdc(vdc);
}
}

View File

@ -36,6 +36,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.predicates.ReferenceTypePredicates;
@ -135,4 +136,12 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
if (context != null)
context.close();
}
public URI toAdminUri(ReferenceType<?> ref) {
return toAdminUri(ref.getHref());
}
public URI toAdminUri(URI uri) {
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
}
}