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; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;
import java.util.Set; 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.CaseFormat;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ForwardingSet; import com.google.common.collect.ForwardingSet;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class Account extends ForwardingSet<User> implements Comparable<Account> { 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 { public static class Builder {
private long id; private long id;
private Type type; private Type type;
private String networkDomain;
private String domain; private String domain;
private long domainId; private long domainId;
private Long IPsAvailable; private Long IPsAvailable;
@ -80,6 +79,11 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
return this; return this;
} }
public Builder networkDomain(String networkDomain) {
this.networkDomain = networkDomain;
return this;
}
public Builder domain(String domain) { public Builder domain(String domain) {
this.domain = domain; this.domain = domain;
return this; return this;
@ -206,7 +210,7 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
public Account build() { 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, receivedBytes, sentBytes, snapshotsAvailable, snapshotLimit, snapshots, state, templatesAvailable,
templateLimit, templates, VMsAvailable, VMLimit, VMsRunning, VMsStopped, VMs, volumesAvailable, templateLimit, templates, VMsAvailable, VMLimit, VMsRunning, VMsStopped, VMs, volumesAvailable,
volumeLimit, volumes, users); volumeLimit, volumes, users);
@ -216,6 +220,7 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
public static enum State { public static enum State {
ENABLED, DISABLED, LOCKED, UNRECOGNIZED; ENABLED, DISABLED, LOCKED, UNRECOGNIZED;
@Override @Override
public String toString() { public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); 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; private long id;
@SerializedName("accounttype")
private Type type; private Type type;
@SerializedName("networkdomain")
private String networkDomain;
private String domain; private String domain;
@SerializedName("domainId")
private long domainId; private long domainId;
@SerializedName("ipsavailable")
private Long IPsAvailable; private Long IPsAvailable;
@SerializedName("iplimit")
private Long IPLimit; private Long IPLimit;
@SerializedName("iptotal")
private long IPs; private long IPs;
@SerializedName("iscleanuprequired")
private boolean cleanupRequired; private boolean cleanupRequired;
private String name; private String name;
@SerializedName("receivedbytes")
private long receivedBytes; private long receivedBytes;
@SerializedName("sentbytes")
private long sentBytes; private long sentBytes;
@SerializedName("snapshotavailable")
private Long snapshotsAvailable; private Long snapshotsAvailable;
@SerializedName("snapshotLimit")
private Long snapshotLimit; private Long snapshotLimit;
@SerializedName("snapshottotal")
private long snapshots; private long snapshots;
private State state; private State state;
@SerializedName("templateavailable")
private Long templatesAvailable; private Long templatesAvailable;
@SerializedName("templatelimit")
private Long templateLimit; private Long templateLimit;
@SerializedName("templatetotal")
private long templates; private long templates;
@SerializedName("vmavailable")
private Long VMsAvailable; private Long VMsAvailable;
@SerializedName("vmlimit")
private Long VMLimit; private Long VMLimit;
@SerializedName("vmrunning")
private long VMsRunning; private long VMsRunning;
@SerializedName("vmstopped")
private long VMsStopped; private long VMsStopped;
@SerializedName("vmtotal")
private long VMs; private long VMs;
@SerializedName("volumeavailable")
private Long volumesAvailable; private Long volumesAvailable;
@SerializedName("volumelimit")
private Long volumeLimit; private Long volumeLimit;
@SerializedName("volumetotal")
private long volumes; private long volumes;
private Set<User> users; private Set<User> users;
public Account(long id, Type type, String domain, long domainId, Long IPsAvailable, Long IPLimit, long iPs, 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, boolean cleanupRequired, String name, long receivedBytes, long sentBytes, Long snapshotsAvailable,
Long snapshotLimit, long snapshots, org.jclouds.cloudstack.domain.Account.State state, Long snapshotLimit, long snapshots, org.jclouds.cloudstack.domain.Account.State state,
Long templatesAvailable, Long templateLimit, long templates, Long VMsAvailable, Long VMLimit, long vMsRunning, 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) { long vMsStopped, long vMs, Long volumesAvailable, Long volumeLimit, long volumes, Set<User> users) {
this.id = id; this.id = id;
this.type = type; this.type = type;
this.networkDomain = networkDomain;
this.domain = domain; this.domain = domain;
this.domainId = domainId; this.domainId = domainId;
this.IPsAvailable = IPsAvailable; this.IPsAvailable = IPsAvailable;
@ -341,14 +371,12 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
/** /**
* present only for serializer * present only for serializer
*
*/ */
Account() { Account() {
} }
/** /**
*
* @return the id of the account * @return the id of the account
*/ */
public long getId() { public long getId() {
@ -356,7 +384,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
/** /**
*
* @return the name of the 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) * @return account type (admin, domain-admin, user)
*/ */
public Type getType() { 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 * @return name of the Domain the account belongs to
*/ */
public String getDomain() { 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 * @return id of the Domain the account belongs to
*/ */
public long getDomainId() { public long getDomainId() {
@ -389,7 +420,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
/** /**
*
* @return true if the account requires cleanup * @return true if the account requires cleanup
*/ */
public boolean isCleanupRequired() { public boolean isCleanupRequired() {
@ -397,7 +427,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
/** /**
*
* @return the list of users associated with account * @return the list of users associated with account
*/ */
public Set<User> getUsers() { 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 * @return the total number of public ip addresses available for this account
* to acquire, or null if unlimited * 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, * @return the total number of public ip addresses this account can acquire,
* or null if unlimited * 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 * @return the total number of public ip addresses allocated for this account
*/ */
public long getIPs() { 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 * @return the total number of network traffic bytes received
*/ */
public long getReceivedBytes() { 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 * @return the total number of network traffic bytes sent
*/ */
public long getSentBytes() { 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 * @return the total number of snapshots available for this account, or null
* if unlimited * 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, * @return the total number of snapshots which can be stored by this account,
* or null if unlimited * 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 * @return the total number of snapshots stored by this account
*/ */
public long getSnapshots() { public long getSnapshots() {
@ -477,7 +498,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
/** /**
*
* @return the state of the account * @return the state of the account
*/ */
public State getState() { 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 * @return the total number of templates available to be created by this
* account, or null if unlimited * 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 * @return the total number of templates which can be created by this
* account, or null if unlimited * 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 * @return the total number of templates which have been created by this
* account * 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 * @return the total number of virtual machines available for this account to
* acquire, or null if unlimited * 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 * @return the total number of virtual machines that can be deployed by this
* account, or null if unlimited * 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 * @return the total number of virtual machines running for this account
*/ */
public long getVMsRunning() { 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 * @return the total number of virtual machines stopped for this account
*/ */
public long getVMsStopped() { 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 * @return the total number of virtual machines deployed by this account
*/ */
public long getVMs() { 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 * @return the total volume available for this account, or null if unlimited
*/ */
@Nullable @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 * @return the total volume which can be used by this account, or null if
* unlimited * unlimited
*/ */
@ -577,7 +587,6 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
} }
/** /**
*
* @return the total volume being used by this account * @return the total volume being used by this account
*/ */
public long getVolumes() { public long getVolumes() {

View File

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

View File

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

View File

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

View File

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

View File

@ -18,18 +18,16 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class ServiceOffering implements Comparable<ServiceOffering> { public class ServiceOffering implements Comparable<ServiceOffering> {
@ -50,6 +48,13 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
private int memory; private int memory;
private boolean haSupport; private boolean haSupport;
private StorageType storageType; 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(); private Set<String> tags = ImmutableSet.of();
public Builder id(long id) { public Builder id(long id) {
@ -112,9 +117,41 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
return this; 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() { public ServiceOffering build() {
return new ServiceOffering(id, name, displayText, created, domain, domainId, cpuNumber, cpuSpeed, memory, 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") @SerializedName("storagetype")
private StorageType storageType; private StorageType storageType;
private String tags; 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, 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.id = id;
this.name = name; this.name = name;
this.displayText = displayText; this.displayText = displayText;
@ -155,14 +207,12 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
/** /**
* present only for serializer * present only for serializer
*
*/ */
ServiceOffering() { ServiceOffering() {
} }
/** /**
*
* @return the id of the service offering * @return the id of the service offering
*/ */
public long getId() { public long getId() {
@ -170,7 +220,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the name of the service offering * @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. * @return an alternate display text of the service offering.
*/ */
public String getDisplayText() { public String getDisplayText() {
@ -187,7 +235,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the date this service offering was created * @return the date this service offering was created
*/ */
public Date getCreated() { public Date getCreated() {
@ -195,7 +242,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return Domain name for the offering * @return Domain name for the offering
*/ */
public String getDomain() { public String getDomain() {
@ -203,7 +249,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the domain id of the service offering * @return the domain id of the service offering
*/ */
public long getDomainId() { public long getDomainId() {
@ -211,7 +256,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the number of CPU * @return the number of CPU
*/ */
public int getCpuNumber() { public int getCpuNumber() {
@ -219,7 +263,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the clock rate CPU speed in Mhz * @return the clock rate CPU speed in Mhz
*/ */
public int getCpuSpeed() { public int getCpuSpeed() {
@ -227,7 +270,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the memory in MB * @return the memory in MB
*/ */
public int getMemory() { public int getMemory() {
@ -235,7 +277,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the ha support in the service offering * @return the ha support in the service offering
*/ */
public boolean supportsHA() { public boolean supportsHA() {
@ -243,7 +284,6 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
} }
/** /**
*
* @return the storage type for this service offering * @return the storage type for this service offering
*/ */
public StorageType getStorageType() { 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 * @return the tags for the service offering
*/ */
public Set<String> getTags() { 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 @Override

View File

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

View File

@ -19,13 +19,10 @@
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date; import java.util.Date;
import java.util.Map; 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.CaseFormat;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -45,6 +42,7 @@ public class Volume implements Comparable<Volume> {
public static class Builder { public static class Builder {
private long id; private long id;
private String account;
private Date attached; private Date attached;
private Date created; private Date created;
private boolean destroyed; private boolean destroyed;
@ -80,6 +78,11 @@ public class Volume implements Comparable<Volume> {
return this; return this;
} }
public Builder account(String account) {
this.account = account;
return this;
}
public Builder attached(Date attached) { public Builder attached(Date attached) {
this.attached = attached; this.attached = attached;
return this; return this;
@ -226,7 +229,7 @@ public class Volume implements Comparable<Volume> {
} }
public Volume build() { 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, diskOfferingName, domain, domainId, hypervisor, isExtractable, jobId, jobStatus, name,
serviceOfferingDisplayText, serviceOfferingId, serviceOfferingName, size, snapshotId, state, storage, serviceOfferingDisplayText, serviceOfferingId, serviceOfferingName, size, snapshotId, state, storage,
storageType, type, virtualMachineId, vmDisplayName, vmName, vmState, zoneId, zoneName); storageType, type, virtualMachineId, vmDisplayName, vmName, vmState, zoneId, zoneName);
@ -234,6 +237,7 @@ public class Volume implements Comparable<Volume> {
} }
private long id; private long id;
private String account;
private Date attached; private Date attached;
private Date created; private Date created;
private boolean destroyed; private boolean destroyed;
@ -284,7 +288,7 @@ public class Volume implements Comparable<Volume> {
@SerializedName("zonename") @SerializedName("zonename")
private String 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 diskOfferingDisplayText, long diskOfferingId, String diskOfferingName,
String domain, long domainId, String hypervisor, boolean extractable, long jobId, String domain, long domainId, String hypervisor, boolean extractable, long jobId,
String jobStatus, String name, String serviceOfferingDisplayText, long serviceOfferingId, 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, String storageType, VolumeType type, long virtualMachineId, String vmDisplayName, String vmName,
VirtualMachine.State vmState, long zoneId, String zoneName) { VirtualMachine.State vmState, long zoneId, String zoneName) {
this.id = id; this.id = id;
this.account = account;
this.attached = attached; this.attached = attached;
this.created = created; this.created = created;
this.destroyed = destroyed; this.destroyed = destroyed;
@ -447,6 +452,10 @@ public class Volume implements Comparable<Volume> {
return zoneName; return zoneName;
} }
public String getAccount() {
return account;
}
@Override @Override
public int compareTo(Volume volume) { public int compareTo(Volume volume) {
return Long.valueOf(this.id).compareTo(volume.id); return Long.valueOf(this.id).compareTo(volume.id);
@ -461,6 +470,7 @@ public class Volume implements Comparable<Volume> {
Volume volume = (Volume) o; Volume volume = (Volume) o;
if (deviceId != volume.deviceId) return false; if (deviceId != volume.deviceId) return false;
if (diskOfferingId != volume.diskOfferingId) return false; if (diskOfferingId != volume.diskOfferingId) return false;
if (domainId != volume.domainId) return false; if (domainId != volume.domainId) return false;
if (id != volume.id) 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 (vmName != null ? !vmName.equals(volume.vmName) : volume.vmName != null) return false;
if (vmState != volume.vmState) return false; if (vmState != volume.vmState) return false;
if (zoneName != null ? !zoneName.equals(volume.zoneName) : volume.zoneName != null) 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; return true;
} }
@ -537,20 +551,30 @@ public class Volume implements Comparable<Volume> {
@Override @Override
public String toString() { public String toString() {
return getClass().getCanonicalName()+"["+id+"; "+name+"; "+vmState+"]"; return getClass().getCanonicalName() + "[" + id + "; " + name + "; " + vmState + "]";
} }
public enum State { 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, ALLOCATED,
/** the volume is being created on the backend */ /**
* the volume is being created on the backend
*/
CREATING, CREATING,
/** the volume is ready to be used */ /**
* the volume is ready to be used
*/
READY, 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, 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, FAILED,
UNRECOGNIZED; UNRECOGNIZED;