Sync domain objects with json responses from the documentation - part 1

This commit is contained in:
vijaykiran 2011-12-03 01:31:27 +01:00
parent 506349da67
commit 838ea11395
8 changed files with 457 additions and 195 deletions

View File

@ -18,21 +18,19 @@
*/
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat;
import com.google.common.base.Function;
import com.google.common.collect.ForwardingSet;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class Account extends ForwardingSet<User> implements Comparable<Account> {
@ -44,6 +42,7 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
public static class Builder {
private long id;
private Type type;
private String networkDomain;
private String domain;
private long domainId;
private Long IPsAvailable;
@ -80,6 +79,11 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
return this;
}
public Builder networkDomain(String networkDomain) {
this.networkDomain = networkDomain;
return this;
}
public Builder domain(String domain) {
this.domain = domain;
return this;
@ -206,7 +210,7 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
public Account build() {
return new Account(id, type, domain, domainId, IPsAvailable, IPLimit, IPs, cleanupRequired, name,
return new Account(id, type, networkDomain, domain, domainId, IPsAvailable, IPLimit, IPs, cleanupRequired, name,
receivedBytes, sentBytes, snapshotsAvailable, snapshotLimit, snapshots, state, templatesAvailable,
templateLimit, templates, VMsAvailable, VMLimit, VMsRunning, VMsStopped, VMs, volumesAvailable,
volumeLimit, volumes, users);
@ -216,6 +220,7 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
public static enum State {
ENABLED, DISABLED, LOCKED, UNRECOGNIZED;
@Override
public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
@ -278,40 +283,65 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
private long id;
@SerializedName("accounttype")
private Type type;
@SerializedName("networkdomain")
private String networkDomain;
private String domain;
@SerializedName("domainId")
private long domainId;
@SerializedName("ipsavailable")
private Long IPsAvailable;
@SerializedName("iplimit")
private Long IPLimit;
@SerializedName("iptotal")
private long IPs;
@SerializedName("iscleanuprequired")
private boolean cleanupRequired;
private String name;
@SerializedName("receivedbytes")
private long receivedBytes;
@SerializedName("sentbytes")
private long sentBytes;
@SerializedName("snapshotavailable")
private Long snapshotsAvailable;
@SerializedName("snapshotLimit")
private Long snapshotLimit;
@SerializedName("snapshottotal")
private long snapshots;
private State state;
@SerializedName("templateavailable")
private Long templatesAvailable;
@SerializedName("templatelimit")
private Long templateLimit;
@SerializedName("templatetotal")
private long templates;
@SerializedName("vmavailable")
private Long VMsAvailable;
@SerializedName("vmlimit")
private Long VMLimit;
@SerializedName("vmrunning")
private long VMsRunning;
@SerializedName("vmstopped")
private long VMsStopped;
@SerializedName("vmtotal")
private long VMs;
@SerializedName("volumeavailable")
private Long volumesAvailable;
@SerializedName("volumelimit")
private Long volumeLimit;
@SerializedName("volumetotal")
private long volumes;
private Set<User> users;
public Account(long id, Type type, String domain, long domainId, Long IPsAvailable, Long IPLimit, long iPs,
boolean cleanupRequired, String name, long receivedBytes, long sentBytes, Long snapshotsAvailable,
Long snapshotLimit, long snapshots, org.jclouds.cloudstack.domain.Account.State state,
Long templatesAvailable, Long templateLimit, long templates, Long VMsAvailable, Long VMLimit, long vMsRunning,
long vMsStopped, long vMs, Long volumesAvailable, Long volumeLimit, long volumes, Set<User> users) {
public Account(long id, Type type, String networkDomain, String domain, long domainId, Long IPsAvailable, Long IPLimit, long iPs,
boolean cleanupRequired, String name, long receivedBytes, long sentBytes, Long snapshotsAvailable,
Long snapshotLimit, long snapshots, org.jclouds.cloudstack.domain.Account.State state,
Long templatesAvailable, Long templateLimit, long templates, Long VMsAvailable, Long VMLimit, long vMsRunning,
long vMsStopped, long vMs, Long volumesAvailable, Long volumeLimit, long volumes, Set<User> users) {
this.id = id;
this.type = type;
this.networkDomain = networkDomain;
this.domain = domain;
this.domainId = domainId;
this.IPsAvailable = IPsAvailable;
@ -341,14 +371,12 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
/**
* present only for serializer
*
*/
Account() {
}
/**
*
* @return the id of the account
*/
public long getId() {
@ -356,7 +384,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the name of the account
*/
@ -365,7 +392,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return account type (admin, domain-admin, user)
*/
public Type getType() {
@ -373,7 +399,13 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the network domain
*/
public String getNetworkDomain() {
return networkDomain;
}
/**
* @return name of the Domain the account belongs to
*/
public String getDomain() {
@ -381,7 +413,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return id of the Domain the account belongs to
*/
public long getDomainId() {
@ -389,7 +420,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return true if the account requires cleanup
*/
public boolean isCleanupRequired() {
@ -397,7 +427,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the list of users associated with account
*/
public Set<User> getUsers() {
@ -405,7 +434,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of public ip addresses available for this account
* to acquire, or null if unlimited
*/
@ -415,7 +443,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of public ip addresses this account can acquire,
* or null if unlimited
*/
@ -425,7 +452,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of public ip addresses allocated for this account
*/
public long getIPs() {
@ -433,7 +459,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of network traffic bytes received
*/
public long getReceivedBytes() {
@ -441,7 +466,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of network traffic bytes sent
*/
public long getSentBytes() {
@ -449,7 +473,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of snapshots available for this account, or null
* if unlimited
*/
@ -459,7 +482,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of snapshots which can be stored by this account,
* or null if unlimited
*/
@ -469,7 +491,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of snapshots stored by this account
*/
public long getSnapshots() {
@ -477,7 +498,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the state of the account
*/
public State getState() {
@ -485,7 +505,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of templates available to be created by this
* account, or null if unlimited
*/
@ -495,7 +514,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of templates which can be created by this
* account, or null if unlimited
*/
@ -505,7 +523,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of templates which have been created by this
* account
*/
@ -514,7 +531,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of virtual machines available for this account to
* acquire, or null if unlimited
*/
@ -524,7 +540,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of virtual machines that can be deployed by this
* account, or null if unlimited
*/
@ -534,7 +549,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of virtual machines running for this account
*/
public long getVMsRunning() {
@ -542,7 +556,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of virtual machines stopped for this account
*/
public long getVMsStopped() {
@ -550,7 +563,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total number of virtual machines deployed by this account
*/
public long getVMs() {
@ -558,7 +570,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total volume available for this account, or null if unlimited
*/
@Nullable
@ -567,7 +578,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total volume which can be used by this account, or null if
* unlimited
*/
@ -577,7 +587,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
}
/**
*
* @return the total volume being used by this account
*/
public long getVolumes() {

View File

@ -18,11 +18,10 @@
*/
package org.jclouds.cloudstack.domain;
import com.google.gson.annotations.SerializedName;
import java.util.Date;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.gson.annotations.SerializedName;
/**
* @author Richard Downer
@ -344,7 +343,6 @@ public class ISO implements Comparable<ISO> {
private long hostId;
@SerializedName("hostname")
private String hostName;
@SerializedName("")
private String hypervisor;
@SerializedName("isextractable")
private boolean isExtractable;
@ -692,39 +690,39 @@ public class ISO implements Comparable<ISO> {
@Override
public String toString() {
return "[" +
"id=" + id +
", account='" + account + '\'' +
", accountId=" + accountId +
", bootable=" + bootable +
", checksum='" + checksum + '\'' +
", created=" + created +
", crossZones=" + crossZones +
", displayText='" + displayText + '\'' +
", domain='" + domain + '\'' +
", domainid=" + domainid +
", format='" + format + '\'' +
", hostId=" + hostId +
", hostName='" + hostName + '\'' +
", hypervisor='" + hypervisor + '\'' +
", isExtractable=" + isExtractable +
", isFeatured=" + isFeatured +
", isPublic=" + isPublic +
", isReady=" + isReady +
", jobId=" + jobId +
", jobStatus='" + jobStatus + '\'' +
", name='" + name + '\'' +
", osTypeId=" + osTypeId +
", osTypeName='" + osTypeName + '\'' +
", passwordEnabled=" + passwordEnabled +
", removed=" + removed +
", size=" + size +
", sourceTemplateId=" + sourceTemplateId +
", status='" + status + '\'' +
", templateTag='" + templateTag + '\'' +
", templateType='" + templateType + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
']';
"id=" + id +
", account='" + account + '\'' +
", accountId=" + accountId +
", bootable=" + bootable +
", checksum='" + checksum + '\'' +
", created=" + created +
", crossZones=" + crossZones +
", displayText='" + displayText + '\'' +
", domain='" + domain + '\'' +
", domainid=" + domainid +
", format='" + format + '\'' +
", hostId=" + hostId +
", hostName='" + hostName + '\'' +
", hypervisor='" + hypervisor + '\'' +
", isExtractable=" + isExtractable +
", isFeatured=" + isFeatured +
", isPublic=" + isPublic +
", isReady=" + isReady +
", jobId=" + jobId +
", jobStatus='" + jobStatus + '\'' +
", name='" + name + '\'' +
", osTypeId=" + osTypeId +
", osTypeName='" + osTypeName + '\'' +
", passwordEnabled=" + passwordEnabled +
", removed=" + removed +
", size=" + size +
", sourceTemplateId=" + sourceTemplateId +
", status='" + status + '\'' +
", templateTag='" + templateTag + '\'' +
", templateType='" + templateType + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
']';
}
@Override

View File

@ -39,6 +39,7 @@ public class NIC {
private boolean isDefault;
private URI isolationURI;
private String netmask;
private String macAddress;
private long networkId;
private TrafficType trafficType;
private GuestIPType guestIPType;
@ -78,6 +79,11 @@ public class NIC {
return this;
}
public Builder macAddress(String macAddress) {
this.macAddress = macAddress;
return this;
}
public Builder networkId(long networkId) {
this.networkId = networkId;
return this;
@ -94,8 +100,8 @@ public class NIC {
}
public NIC build() {
return new NIC(id, broadcastURI, gateway, IPAddress, isDefault, isolationURI, netmask, networkId, trafficType,
guestIPType);
return new NIC(id, broadcastURI, gateway, IPAddress, isDefault, isolationURI, netmask, macAddress, networkId,
trafficType, guestIPType);
}
}
@ -111,6 +117,8 @@ public class NIC {
@SerializedName("isolationuri")
private URI isolationURI;
private String netmask;
@SerializedName("macaddress")
private String macAddress;
@SerializedName("networkid")
private long networkId;
@SerializedName("traffictype")
@ -120,14 +128,13 @@ public class NIC {
/**
* present only for serializer
*
*/
NIC() {
}
public NIC(long id, URI broadcastURI, String gateway, String iPAddress, boolean isDefault, URI isolationURI,
String netmask, long networkId, TrafficType trafficType, GuestIPType guestIPType) {
String netmask, String macAddress, long networkId, TrafficType trafficType, GuestIPType guestIPType) {
this.id = id;
this.broadcastURI = broadcastURI;
this.gateway = gateway;
@ -135,6 +142,7 @@ public class NIC {
this.isDefault = isDefault;
this.isolationURI = isolationURI;
this.netmask = netmask;
this.macAddress = macAddress;
this.networkId = networkId;
this.trafficType = trafficType;
this.guestIPType = guestIPType;
@ -189,6 +197,13 @@ public class NIC {
return netmask;
}
/**
* the MAC Address of the NIC
*/
public String getMacAddress() {
return macAddress;
}
/**
* the ID of the corresponding network
*/
@ -222,6 +237,7 @@ public class NIC {
result = prime * result + (isDefault ? 1231 : 1237);
result = prime * result + ((isolationURI == null) ? 0 : isolationURI.hashCode());
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
result = prime * result + ((macAddress == null) ? 0 : macAddress.hashCode());
result = prime * result + (int) (networkId ^ (networkId >>> 32));
result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode());
return result;
@ -267,6 +283,11 @@ public class NIC {
return false;
} else if (!netmask.equals(other.netmask))
return false;
if (macAddress == null) {
if (other.macAddress != null)
return false;
} else if (!macAddress.equals(other.macAddress))
return false;
if (networkId != other.networkId)
return false;
if (trafficType != other.trafficType)
@ -277,8 +298,8 @@ public class NIC {
@Override
public String toString() {
return "[id=" + id + ", broadcastURI=" + broadcastURI + ", gateway=" + gateway + ", IPAddress=" + IPAddress
+ ", isDefault=" + isDefault + ", isolationURI=" + isolationURI + ", netmask=" + netmask + ", networkId="
+ networkId + ", trafficType=" + trafficType + ", guestIPType=" + guestIPType + "]";
+ ", isDefault=" + isDefault + ", isolationURI=" + isolationURI + ", netmask=" + netmask + ", MACAddress="
+ macAddress + ", networkId=" + networkId + ", trafficType=" + trafficType + ", guestIPType=" + guestIPType + "]";
}
}

View File

@ -18,15 +18,14 @@
*/
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.util.Date;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class PublicIPAddress implements Comparable<PublicIPAddress> {
@ -55,6 +54,8 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
private String VLANName;
private long zoneId;
private String zoneName;
private Long jobId;
private Integer jobStatus;
public Builder id(long id) {
this.id = id;
@ -151,10 +152,20 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
return this;
}
public Builder jobId(Long jobId) {
this.jobId = jobId;
return this;
}
public Builder jobStatus(int jobStatus) {
this.jobStatus = jobStatus;
return this;
}
public PublicIPAddress build() {
return new PublicIPAddress(id, account, allocated, associatedNetworkId, domain, domainId, usesVirtualNetwork,
IPAddress, isSourceNAT, isStaticNAT, networkId, state, virtualMachineDisplayName, virtualMachineId,
virtualMachineName, VLANId, VLANName, zoneId, zoneName);
virtualMachineName, VLANId, VLANName, zoneId, zoneName, jobId, jobStatus);
}
}
@ -191,9 +202,16 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
private long zoneId;
@SerializedName("zonename")
private String zoneName;
@SerializedName("jobid")
@Nullable
private Long jobId;
@SerializedName("jobstatus")
@Nullable
private Integer jobStatus;
public static enum State {
ALLOCATING, ALLOCATED, RELEASING, UNRECOGNIZED;
@Override
public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
@ -215,9 +233,10 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
public PublicIPAddress(long id, String account, Date allocated, long associatedNetworkId, String domain,
long domainId, boolean usesVirtualNetwork, String iPAddress, boolean isSourceNAT, boolean isStaticNAT,
long networkId, State state, String virtualMachineDisplayName, long virtualMachineId,
String virtualMachineName, long VLANId, String VLANName, long zoneId, String zoneName) {
long domainId, boolean usesVirtualNetwork, String iPAddress, boolean isSourceNAT, boolean isStaticNAT,
long networkId, State state, String virtualMachineDisplayName, long virtualMachineId,
String virtualMachineName, long VLANId, String VLANName, long zoneId, String zoneName, Long jobId,
Integer jobStatus) {
this.id = id;
this.account = account;
this.allocated = allocated;
@ -237,6 +256,9 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
this.VLANName = VLANName;
this.zoneId = zoneId;
this.zoneName = zoneName;
this.jobId = jobId;
this.jobStatus = jobStatus;
}
@Override
@ -245,7 +267,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return public IP address id
*/
public long getId() {
@ -253,7 +274,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the account the public IP address is associated with
*/
public String getAccount() {
@ -261,7 +281,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return date the public IP address was acquired
*/
public Date getAllocated() {
@ -269,7 +288,25 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return shows the current pending asynchronous job ID. This tag is not
* returned if no current pending jobs are acting on the virtual
* machine
*/
@Nullable
public Long getJobId() {
return jobId;
}
/**
* @return shows the current pending asynchronous job status
*/
@Nullable
public Integer getJobStatus() {
return jobStatus;
}
/**
* @return the ID of the Network associated with the IP address
*/
public long getAssociatedNetworkId() {
@ -277,7 +314,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the domain the public IP address is associated with
*/
public String getDomain() {
@ -285,7 +321,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the domain ID the public IP address is associated with
*/
public long getDomainId() {
@ -300,7 +335,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return public IP address
*/
public String getIPAddress() {
@ -308,7 +342,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return true if the IP address is a source nat address, false otherwise
*/
public boolean isSourceNAT() {
@ -316,7 +349,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return true if this ip is for static nat, false otherwise
*/
public boolean isStaticNAT() {
@ -324,7 +356,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the ID of the Network where ip belongs to
*/
public long getNetworkId() {
@ -332,7 +363,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return State of the ip address. Can be: Allocating, Allocated and
* Releasing
*/
@ -341,7 +371,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return virtual machine display name the ip address is assigned to (not
* null only for static nat Ip)
*/
@ -350,7 +379,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return virtual machine id the ip address is assigned to (not null only
* for static nat Ip)
*/
@ -359,7 +387,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return virtual machine name the ip address is assigned to (not null only
* for static nat Ip)
*/
@ -368,7 +395,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the ID of the VLAN associated with the IP address
*/
public long getVLANId() {
@ -376,7 +402,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the VLAN associated with the IP address
*/
public String getVLANName() {
@ -384,7 +409,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the ID of the zone the public IP address belongs to
*/
public long getZoneId() {
@ -392,7 +416,6 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
}
/**
*
* @return the name of the zone the public IP address belongs to
*/
public String getZoneName() {
@ -422,6 +445,7 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
result = prime * result + ((virtualMachineName == null) ? 0 : virtualMachineName.hashCode());
result = prime * result + (int) (zoneId ^ (zoneId >>> 32));
result = prime * result + ((zoneName == null) ? 0 : zoneName.hashCode());
result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode());
return result;
}
@ -499,6 +523,16 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
return false;
} else if (!zoneName.equals(other.zoneName))
return false;
if (jobId == null) {
if (other.jobId != null)
return false;
} else if (!jobId.equals(other.jobId))
return false;
if (jobStatus == null) {
if (other.jobStatus != null)
return false;
} else if (!jobStatus.equals(other.jobStatus))
return false;
return true;
}

View File

@ -18,17 +18,16 @@
*/
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.util.Set;
import java.util.SortedSet;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class SecurityGroup implements Comparable<SecurityGroup> {
@ -43,6 +42,9 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
private String description;
private String domain;
private long domainId;
private Long jobId;
private Integer jobStatus;
private Set<IngressRule> ingressRules = ImmutableSet.of();
public Builder id(long id) {
@ -75,13 +77,23 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
return this;
}
public Builder jobId(Long jobId) {
this.jobId = jobId;
return this;
}
public Builder jobStatus(int jobStatus) {
this.jobStatus = jobStatus;
return this;
}
public Builder ingressRules(Set<IngressRule> ingressRules) {
this.ingressRules = ImmutableSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
return this;
}
public SecurityGroup build() {
return new SecurityGroup(id, account, name, description, domain, domainId, ingressRules);
return new SecurityGroup(id, account, name, description, domain, domainId, jobId, jobStatus, ingressRules);
}
}
@ -92,31 +104,37 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
private String domain;
@SerializedName("domainid")
private long domainId;
@SerializedName("jobid")
@Nullable
private Long jobId;
@SerializedName("jobstatus")
@Nullable
private Integer jobStatus;
@SerializedName("ingressrule")
// so that tests and serialization come out expected
private SortedSet<IngressRule> ingressRules = ImmutableSortedSet.<IngressRule> of();
private SortedSet<IngressRule> ingressRules = ImmutableSortedSet.<IngressRule>of();
public SecurityGroup(long id, String account, String name, String description, String domain, long domainId,
Set<IngressRule> ingressRules) {
Long jobId, Integer jobStatus, Set<IngressRule> ingressRules) {
this.id = id;
this.account = account;
this.name = name;
this.description = description;
this.domain = domain;
this.domainId = domainId;
this.jobId = jobId;
this.jobStatus = jobStatus;
this.ingressRules = ImmutableSortedSet.copyOf(checkNotNull(ingressRules, "ingressRules"));
}
/**
* present only for serializer
*
*/
SecurityGroup() {
}
/**
*
* @return the id of the security group
*/
public long getId() {
@ -124,7 +142,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return the name of the security group
*/
@ -133,7 +150,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return an alternate display text of the security group.
*/
public String getDescription() {
@ -141,7 +157,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return Domain name for the security group
*/
public String getDomain() {
@ -149,7 +164,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return the domain id of the security group
*/
public long getDomainId() {
@ -157,7 +171,24 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return shows the current pending asynchronous job ID. This tag is not
* returned if no current pending jobs are acting on the virtual
* machine
*/
@Nullable
public Long getJobId() {
return jobId;
}
/**
* @return shows the current pending asynchronous job status
*/
@Nullable
public Integer getJobStatus() {
return jobStatus;
}
/**
* @return the account owning the security group
*/
public String getAccount() {
@ -165,7 +196,6 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
}
/**
*
* @return the list of ingress rules associated with the security group
*/
public Set<IngressRule> getIngressRules() {
@ -178,6 +208,7 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
int result = 1;
result = prime * result + (int) (domainId ^ (domainId >>> 32));
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + ((jobStatus == null) ? 0 : jobStatus.hashCode());
return result;
}
@ -194,6 +225,16 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
return false;
if (id != other.id)
return false;
if (jobId == null) {
if (other.jobId != null)
return false;
} else if (!jobId.equals(other.jobId))
return false;
if (jobStatus == null) {
if (other.jobStatus != null)
return false;
} else if (!jobStatus.equals(other.jobStatus))
return false;
return true;
}

View File

@ -18,18 +18,16 @@
*/
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class ServiceOffering implements Comparable<ServiceOffering> {
@ -50,6 +48,13 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
private int memory;
private boolean haSupport;
private StorageType storageType;
private boolean defaultUse;
private String hostTags;
private boolean systemOffering;
private boolean cpuUseLimited;
private long networkRate;
private boolean systemVmType;
private Set<String> tags = ImmutableSet.of();
public Builder id(long id) {
@ -112,9 +117,41 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
return this;
}
public Builder defaultUse(boolean defaultUse) {
this.defaultUse = defaultUse;
return this;
}
public Builder hostTags(String hostTags) {
this.hostTags = hostTags;
return this;
}
public Builder systemOffering(boolean systemOffering) {
this.systemOffering = systemOffering;
return this;
}
public Builder cpuUseLimited(boolean cpuUseLimited) {
this.cpuUseLimited = cpuUseLimited;
return this;
}
public Builder networkRate(long networkRate) {
this.networkRate = networkRate;
return this;
}
public Builder systemVmType(boolean systemVmType) {
this.systemVmType = systemVmType;
return this;
}
public ServiceOffering build() {
return new ServiceOffering(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory,
haSupport, storageType, tags);
haSupport, storageType, tags, defaultUse, hostTags, systemOffering, cpuUseLimited, networkRate,
systemVmType);
}
}
@ -136,9 +173,24 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
@SerializedName("storagetype")
private StorageType storageType;
private String tags;
@SerializedName("defaultuse")
private boolean defaultUse;
@SerializedName("hosttags")
private String hostTags;
@SerializedName("issystem")
private boolean systemOffering;
@SerializedName("limitcpuuse")
private boolean cpuUseLimited;
@SerializedName("networkrate")
private long networkRate;
@SerializedName("systemvmtype")
private boolean systemVmType;
public ServiceOffering(long id, String name, String displayText, Date created, String domain, long domainId,
int cpuNumber, int cpuSpeed, int memory, boolean haSupport, StorageType storageType, Set<String> tags) {
int cpuNumber, int cpuSpeed, int memory, boolean haSupport, StorageType storageType, Set<String> tags,
boolean defaultUse, String hostTags, boolean systemOffering, boolean cpuUseLimited, long networkRate,
boolean systemVmType) {
this.id = id;
this.name = name;
this.displayText = displayText;
@ -155,14 +207,12 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
/**
* present only for serializer
*
*/
ServiceOffering() {
}
/**
*
* @return the id of the service offering
*/
public long getId() {
@ -170,7 +220,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the name of the service offering
*/
@ -179,7 +228,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return an alternate display text of the service offering.
*/
public String getDisplayText() {
@ -187,7 +235,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the date this service offering was created
*/
public Date getCreated() {
@ -195,7 +242,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return Domain name for the offering
*/
public String getDomain() {
@ -203,7 +249,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the domain id of the service offering
*/
public long getDomainId() {
@ -211,7 +256,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the number of CPU
*/
public int getCpuNumber() {
@ -219,7 +263,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the clock rate CPU speed in Mhz
*/
public int getCpuSpeed() {
@ -227,7 +270,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the memory in MB
*/
public int getMemory() {
@ -235,7 +277,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the ha support in the service offering
*/
public boolean supportsHA() {
@ -243,7 +284,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return the storage type for this service offering
*/
public StorageType getStorageType() {
@ -251,11 +291,52 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
}
/**
*
* @return whether this is a default system vm offering
*/
public boolean isDefaultUse() {
return defaultUse;
}
/**
* @return the host tag for the service offering
*/
public String getHostTags() {
return hostTags;
}
/**
* @return whether this is a system vm offering
*/
public boolean isSystemOffering() {
return systemOffering;
}
/**
* @return whether restrict the CPU usage to committed service offering
*/
public boolean isCpuUseLimited() {
return cpuUseLimited;
}
/**
* @return data transfer rate in megabits per second allowed.
*/
public long getNetworkRate() {
return networkRate;
}
/**
* @return whether this is a the systemvm type for system vm offering
*/
public boolean isSystemVmType() {
return systemVmType;
}
/**
* @return the tags for the service offering
*/
public Set<String> getTags() {
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String> of();
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String>of();
}
@Override

View File

@ -18,16 +18,13 @@
*/
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.util.Date;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class Template implements Comparable<Template> {
@ -63,6 +60,11 @@ public class Template implements Comparable<Template> {
private boolean passwordEnabled;
private Long jobId;
private String jobStatus;
private String checksum;
private Long hostId;
private String hostName;
private Long sourceTemplateId;
private String templateTag;
public Builder id(long id) {
this.id = id;
@ -199,10 +201,37 @@ public class Template implements Comparable<Template> {
return this;
}
public Builder checksum(String checksum) {
this.checksum = checksum;
return this;
}
public Builder hostid(Long hostid) {
this.hostId = hostid;
return this;
}
public Builder hostName(String hostName) {
this.hostName = hostName;
return this;
}
public Builder sourceTemplateId(Long sourceTemplateId) {
this.sourceTemplateId = sourceTemplateId;
return this;
}
public Builder templateTag(String templateTag) {
this.templateTag = templateTag;
return this;
}
public Template build() {
return new Template(id, displayText, domain, domainId, account, accountId, zone, zoneId, OSType, OSTypeId,
name, type, status, format, hypervisor, size, created, removed, crossZones, bootable, extractable,
featured, isPublic, ready, passwordEnabled, jobId, jobStatus);
featured, isPublic, ready, passwordEnabled, jobId, jobStatus, checksum, hostId, hostName, sourceTemplateId,
templateTag);
}
}
@ -281,12 +310,24 @@ public class Template implements Comparable<Template> {
@SerializedName("jobstatus")
//TODO: this should be a type
private String jobStatus;
private String checksum;
@SerializedName("hostId")
private Long hostId;
@SerializedName("hostname")
private String hostName;
@SerializedName("sourcetemplateid")
@Nullable
private Long sourceTemplateId;
@SerializedName("templatetag")
private String templateTag;
public Template(long id, String displayText, String domain, long domainId, String account, long accountId,
String zone, long zoneId, String oSType, long oSTypeId, String name, Type type, String status, Format format,
String hypervisor, Long size, Date created, Date removed, boolean crossZones, boolean bootable,
boolean extractable, boolean featured, boolean ispublic, boolean ready, boolean passwordEnabled, Long jobId,
String jobStatus) {
String zone, long zoneId, String oSType, long oSTypeId, String name, Type type, String status, Format format,
String hypervisor, Long size, Date created, Date removed, boolean crossZones, boolean bootable,
boolean extractable, boolean featured, boolean ispublic, boolean ready, boolean passwordEnabled, Long jobId,
String jobStatus, String checksum, Long hostId, String hostName, Long sourceTemplateId,
String templateTag) {
this.id = id;
this.displayText = displayText;
this.domain = domain;
@ -314,18 +355,22 @@ public class Template implements Comparable<Template> {
this.passwordEnabled = passwordEnabled;
this.jobId = jobId;
this.jobStatus = jobStatus;
this.checksum = checksum;
this.hostId = hostId;
this.hostName = hostName;
this.sourceTemplateId = sourceTemplateId;
this.templateTag = templateTag;
}
/**
* present only for serializer
*
*/
Template() {
}
/**
*
* @return Template id
*/
public long getId() {
@ -333,7 +378,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the display text of the template
*/
public String getDisplayText() {
@ -341,7 +385,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the name of the domain to which the template beLongs
*/
public String getDomain() {
@ -349,7 +392,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the ID of the domain to which the template beLongs
*/
public long getDomainId() {
@ -357,7 +399,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the name of the account to which the template beLongs
*/
public String getAccount() {
@ -365,7 +406,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the ID of the account to which the template beLongs
*/
public long getAccountId() {
@ -373,7 +413,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the name of the zone to which the template beLongs
*/
public String getZone() {
@ -381,7 +420,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the ID of the zone to which the template beLongs
*/
public long getZoneId() {
@ -389,7 +427,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the name of the OS type to which the template beLongs
*/
public String getOSType() {
@ -397,7 +434,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the ID of the OS type to which the template beLongs
*/
public long getOSTypeId() {
@ -405,7 +441,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return Template name
*/
public String getName() {
@ -413,7 +448,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return
*/
public String getStatus() {
@ -421,7 +455,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the format of the template.
*/
public Format getFormat() {
@ -429,7 +462,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the hypervisor on which the template runs
*/
public String getHypervisor() {
@ -437,7 +469,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the size of the template in kilobytes
*/
public Long getSize() {
@ -445,7 +476,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the type of the template
*/
public Type getType() {
@ -453,7 +483,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the date this template was created
*/
public Date getCreated() {
@ -461,7 +490,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return the date this template was removed
*/
public Date getRemoved() {
@ -469,7 +497,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if the template is managed across all Zones, false otherwise
*/
public boolean isCrossZones() {
@ -477,7 +504,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if the ISO is bootable, false otherwise
*/
public boolean isBootable() {
@ -485,7 +511,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if the template is extractable, false otherwise
*/
public boolean isExtractable() {
@ -493,7 +518,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if this template is a featured template, false otherwise
*/
public boolean isFeatured() {
@ -501,7 +525,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if this template is a public template, false otherwise
*/
public boolean isPublic() {
@ -509,7 +532,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if the template is ready to be deployed from, false otherwise
*/
public boolean isReady() {
@ -517,7 +539,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return true if the reset password feature is enabled, false otherwise
*/
public boolean isPasswordEnabled() {
@ -525,7 +546,6 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return shows the current pending asynchronous job ID, or null if current
* pending jobs are acting on the template
*/
@ -535,13 +555,47 @@ public class Template implements Comparable<Template> {
}
/**
*
* @return shows the current pending asynchronous job status
*/
public String getJobStatus() {
return jobStatus;
}
/**
* @return checksum of the template
*/
public String getChecksum() {
return checksum;
}
/**
* @return the ID of the secondary storage host for the template
*/
public Long getHostId() {
return hostId;
}
/**
* @return the name of the secondary storage host for the template
*/
public String getHostName() {
return hostName;
}
/**
* @return the template ID of the parent template if present
*/
public Long getSourceTemplateId() {
return sourceTemplateId;
}
/**
* @return the tag of this template
*/
public String getTemplateTag() {
return templateTag;
}
@Override
public int hashCode() {
final int prime = 31;

View File

@ -19,13 +19,10 @@
package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import java.util.Map;
import org.jclouds.cloudstack.domain.VirtualMachine.State;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
@ -45,6 +42,7 @@ public class Volume implements Comparable<Volume> {
public static class Builder {
private long id;
private String account;
private Date attached;
private Date created;
private boolean destroyed;
@ -80,6 +78,11 @@ public class Volume implements Comparable<Volume> {
return this;
}
public Builder account(String account) {
this.account = account;
return this;
}
public Builder attached(Date attached) {
this.attached = attached;
return this;
@ -226,7 +229,7 @@ public class Volume implements Comparable<Volume> {
}
public Volume build() {
return new Volume(id, attached, created, destroyed, deviceId, diskOfferingDisplayText, diskOfferingId,
return new Volume(id, account, attached, created, destroyed, deviceId, diskOfferingDisplayText, diskOfferingId,
diskOfferingName, domain, domainId, hypervisor, isExtractable, jobId, jobStatus, name,
serviceOfferingDisplayText, serviceOfferingId, serviceOfferingName, size, snapshotId, state, storage,
storageType, type, virtualMachineId, vmDisplayName, vmName, vmState, zoneId, zoneName);
@ -234,6 +237,7 @@ public class Volume implements Comparable<Volume> {
}
private long id;
private String account;
private Date attached;
private Date created;
private boolean destroyed;
@ -284,7 +288,7 @@ public class Volume implements Comparable<Volume> {
@SerializedName("zonename")
private String zoneName;
public Volume(long id, Date attached, Date created, boolean destroyed, long deviceId,
public Volume(long id,String account, Date attached, Date created, boolean destroyed, long deviceId,
String diskOfferingDisplayText, long diskOfferingId, String diskOfferingName,
String domain, long domainId, String hypervisor, boolean extractable, long jobId,
String jobStatus, String name, String serviceOfferingDisplayText, long serviceOfferingId,
@ -292,6 +296,7 @@ public class Volume implements Comparable<Volume> {
String storageType, VolumeType type, long virtualMachineId, String vmDisplayName, String vmName,
VirtualMachine.State vmState, long zoneId, String zoneName) {
this.id = id;
this.account = account;
this.attached = attached;
this.created = created;
this.destroyed = destroyed;
@ -447,6 +452,10 @@ public class Volume implements Comparable<Volume> {
return zoneName;
}
public String getAccount() {
return account;
}
@Override
public int compareTo(Volume volume) {
return Long.valueOf(this.id).compareTo(volume.id);
@ -461,6 +470,7 @@ public class Volume implements Comparable<Volume> {
Volume volume = (Volume) o;
if (deviceId != volume.deviceId) return false;
if (diskOfferingId != volume.diskOfferingId) return false;
if (domainId != volume.domainId) return false;
if (id != volume.id) return false;
@ -497,7 +507,11 @@ public class Volume implements Comparable<Volume> {
if (vmName != null ? !vmName.equals(volume.vmName) : volume.vmName != null) return false;
if (vmState != volume.vmState) return false;
if (zoneName != null ? !zoneName.equals(volume.zoneName) : volume.zoneName != null) return false;
if (account == null) {
if (volume.account != null)
return false;
} else if (!account.equals(volume.account))
return false;
return true;
}
@ -537,20 +551,30 @@ public class Volume implements Comparable<Volume> {
@Override
public String toString() {
return getClass().getCanonicalName()+"["+id+"; "+name+"; "+vmState+"]";
return getClass().getCanonicalName() + "[" + id + "; " + name + "; " + vmState + "]";
}
public enum State {
/** indicates that the volume record is created in the DB, but not on the backend */
/**
* indicates that the volume record is created in the DB, but not on the backend
*/
ALLOCATED,
/** the volume is being created on the backend */
/**
* the volume is being created on the backend
*/
CREATING,
/** the volume is ready to be used */
/**
* the volume is ready to be used
*/
READY,
/** the volume is destroyed (either as a result of deleteVolume command for DataDisk or as a part of destroyVm) */
/**
* the volume is destroyed (either as a result of deleteVolume command for DataDisk or as a part of destroyVm)
*/
DESTROYED,
/** the volume has failed somehow, e.g. during creation (in cloudstack development) */
/**
* the volume has failed somehow, e.g. during creation (in cloudstack development)
*/
FAILED,
UNRECOGNIZED;