Merge pull request #223 from vijaykiran/sync-domain-objects

Sync domain objects with json responses from the documentation - part 2
This commit is contained in:
Adrian Cole 2011-12-07 09:22:19 -08:00
commit 615de6d2a1
39 changed files with 895 additions and 271 deletions

View File

@ -18,11 +18,12 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
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;
@ -598,15 +599,39 @@ public class Account extends ForwardingSet<User> implements Comparable<Account>
return new Long(id).compareTo(arg0.getId()); return new Long(id).compareTo(arg0.getId());
} }
@Override @Override
public String toString() { public String toString() {
return String return "Account{" +
.format( "id=" + id +
"[id=%s, name=%s, type=%s, state=%s, domain=%s, domainId=%s, cleanupRequired=%s, sentBytes=%s, receivedBytes=%s, IPs=%s, IPsAvailable=%s, IPLimit=%s, VMs=%s, VMsAvailable=%s, VMsRunning=%s, VMsStopped=%s, VMLimit=%s, snapshots=%s, snapshotLimit=%s, snapshotsAvailable=%s, templateLimit=%s, templates=%s, templatesAvailable=%s, volumes=%s, volumeLimit=%s, volumesAvailable=%s, users=%s]", ", type=" + type +
id, name, type, state, domain, domainId, cleanupRequired, sentBytes, receivedBytes, IPs, ", networkDomain='" + networkDomain + '\'' +
IPsAvailable, IPLimit, VMs, VMsAvailable, VMsRunning, VMsStopped, VMLimit, snapshots, snapshotLimit, ", domain='" + domain + '\'' +
snapshotsAvailable, templateLimit, templates, templatesAvailable, volumes, volumeLimit, ", domainId=" + domainId +
volumesAvailable, users); ", IPsAvailable=" + IPsAvailable +
", IPLimit=" + IPLimit +
", IPs=" + IPs +
", cleanupRequired=" + cleanupRequired +
", name='" + name + '\'' +
", receivedBytes=" + receivedBytes +
", sentBytes=" + sentBytes +
", snapshotsAvailable=" + snapshotsAvailable +
", snapshotLimit=" + snapshotLimit +
", snapshots=" + snapshots +
", state=" + state +
", templatesAvailable=" + templatesAvailable +
", templateLimit=" + templateLimit +
", templates=" + templates +
", VMsAvailable=" + VMsAvailable +
", VMLimit=" + VMLimit +
", VMsRunning=" + VMsRunning +
", VMsStopped=" + VMsStopped +
", VMs=" + VMs +
", volumesAvailable=" + volumesAvailable +
", volumeLimit=" + volumeLimit +
", volumes=" + volumes +
", users=" + users +
'}';
} }
@Override @Override

View File

@ -118,14 +118,15 @@ public class Alert implements Comparable<Alert> {
return result; return result;
} }
@Override @Override
public String toString() { public String toString() {
return "Alert{" + return "Alert{" +
"id=" + id + "id=" + id +
", description='" + description + '\'' + ", description='" + description + '\'' +
", sent=" + sent + ", sent=" + sent +
", type='" + type + '\'' + ", type='" + type + '\'' +
'}'; '}';
} }
@Override @Override

View File

@ -85,7 +85,10 @@ public class AsyncCreateResponse {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", jobId=" + jobId + "]"; return "AsyncCreateResponse{" +
"id=" + id +
", jobId=" + jobId +
'}';
} }
} }

View File

@ -422,10 +422,21 @@ public class AsyncJob<T> {
@Override @Override
public String toString() { public String toString() {
return "[accountId=" + accountId + ", cmd=" + cmd + ", created=" + created + ", id=" + id + ", instanceId=" return "AsyncJob{" +
+ instanceId + ", instanceType=" + instanceType + ", error=" + error + ", progress=" + progress "accountId=" + accountId +
+ ", result=" + result + ", resultCode=" + resultCode + ", resultType=" + resultType + ", status=" + status ", cmd='" + cmd + '\'' +
+ ", userId=" + userId + "]"; ", created=" + created +
", id=" + id +
", instanceId=" + instanceId +
", instanceType='" + instanceType + '\'' +
", progress=" + progress +
", result=" + result +
", resultCode=" + resultCode +
", resultType='" + resultType + '\'' +
", status=" + status +
", userId=" + userId +
", error=" + error +
'}';
} }
} }

View File

@ -120,7 +120,10 @@ public class AsyncJobError {
@Override @Override
public String toString() { public String toString() {
return "[errorCode=" + errorCode + ", errorText=" + errorText + "]"; return "AsyncJobError{" +
"errorCode=" + errorCode +
", errorText='" + errorText + '\'' +
'}';
} }
} }

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudstack.domain;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class Capabilities { public class Capabilities {
@ -33,6 +32,8 @@ public class Capabilities {
private String cloudStackVersion; private String cloudStackVersion;
private boolean securityGroupsEnabled; private boolean securityGroupsEnabled;
private boolean canShareTemplates; private boolean canShareTemplates;
private boolean firewallRuleUiEnabled;
private boolean supportELB;
public Builder cloudStackVersion(String cloudStackVersion) { public Builder cloudStackVersion(String cloudStackVersion) {
this.cloudStackVersion = cloudStackVersion; this.cloudStackVersion = cloudStackVersion;
@ -49,8 +50,18 @@ public class Capabilities {
return this; return this;
} }
public Builder firewallRuleUiEnabled(boolean firewallRuleUiEnabled) {
this.firewallRuleUiEnabled = firewallRuleUiEnabled;
return this;
}
public Builder supportELB(boolean supportELB) {
this.supportELB = supportELB;
return this;
}
public Capabilities build() { public Capabilities build() {
return new Capabilities(cloudStackVersion, securityGroupsEnabled, canShareTemplates); return new Capabilities(cloudStackVersion, securityGroupsEnabled, canShareTemplates, firewallRuleUiEnabled, supportELB);
} }
} }
@ -60,24 +71,27 @@ public class Capabilities {
private boolean securityGroupsEnabled; private boolean securityGroupsEnabled;
@SerializedName("userpublictemplateenabled") @SerializedName("userpublictemplateenabled")
private boolean canShareTemplates; private boolean canShareTemplates;
private boolean firewallRuleUiEnabled;
private boolean supportELB;
/** /**
* present only for serializer * present only for serializer
*
*/ */
Capabilities() { Capabilities() {
} }
public Capabilities(String cloudStackVersion, boolean securityGroupsEnabled, boolean canShareTemplates) { public Capabilities(String cloudStackVersion, boolean securityGroupsEnabled, boolean canShareTemplates,
boolean firewallRuleUiEnabled, boolean supportELB) {
this.cloudStackVersion = cloudStackVersion; this.cloudStackVersion = cloudStackVersion;
this.securityGroupsEnabled = securityGroupsEnabled; this.securityGroupsEnabled = securityGroupsEnabled;
this.canShareTemplates = canShareTemplates; this.canShareTemplates = canShareTemplates;
this.firewallRuleUiEnabled = firewallRuleUiEnabled;
this.supportELB = supportELB;
} }
/** /**
*
* @return version of the cloud stack * @return version of the cloud stack
*/ */
public String getCloudStackVersion() { public String getCloudStackVersion() {
@ -85,7 +99,6 @@ public class Capabilities {
} }
/** /**
*
* @return true if security groups support is enabled, false otherwise * @return true if security groups support is enabled, false otherwise
*/ */
public boolean isSecurityGroupsEnabled() { public boolean isSecurityGroupsEnabled() {
@ -93,7 +106,6 @@ public class Capabilities {
} }
/** /**
*
* @return true if user and domain admins can set templates to be shared, * @return true if user and domain admins can set templates to be shared,
* false otherwise * false otherwise
*/ */
@ -101,6 +113,20 @@ public class Capabilities {
return canShareTemplates; return canShareTemplates;
} }
/**
* @return true if the firewall rule UI is enabled
*/
public boolean isFirewallRuleUiEnabled() {
return firewallRuleUiEnabled;
}
/**
* @return true if region supports elastic load balancer on basic zones
*/
public boolean isSupportELB() {
return supportELB;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -108,6 +134,8 @@ public class Capabilities {
result = prime * result + (canShareTemplates ? 1231 : 1237); result = prime * result + (canShareTemplates ? 1231 : 1237);
result = prime * result + ((cloudStackVersion == null) ? 0 : cloudStackVersion.hashCode()); result = prime * result + ((cloudStackVersion == null) ? 0 : cloudStackVersion.hashCode());
result = prime * result + (securityGroupsEnabled ? 1231 : 1237); result = prime * result + (securityGroupsEnabled ? 1231 : 1237);
result = prime * result + (firewallRuleUiEnabled ? 1231 : 1237);
result = prime * result + (supportELB ? 1231 : 1237);
return result; return result;
} }
@ -129,12 +157,21 @@ public class Capabilities {
return false; return false;
if (securityGroupsEnabled != other.securityGroupsEnabled) if (securityGroupsEnabled != other.securityGroupsEnabled)
return false; return false;
if (firewallRuleUiEnabled != other.firewallRuleUiEnabled)
return false;
if (supportELB != other.supportELB)
return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[cloudStackVersion=" + cloudStackVersion + ", canShareTemplates=" + canShareTemplates return "Capabilities{" +
+ ", securityGroupsEnabled=" + securityGroupsEnabled + "]"; "cloudStackVersion='" + cloudStackVersion + '\'' +
", securityGroupsEnabled=" + securityGroupsEnabled +
", canShareTemplates=" + canShareTemplates +
", firewallRuleUiEnabled=" + firewallRuleUiEnabled +
", supportELB=" + supportELB +
'}';
} }
} }

View File

@ -234,16 +234,16 @@ public class Capacity implements Comparable<Capacity> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "Capacity{" +
"podId=" + podId + "capacityTotal=" + capacityTotal +
", podName='" + podName + '\'' + ", capacityUsed=" + capacityUsed +
", zoneId=" + zoneId + ", percentUsed=" + percentUsed +
", zoneName='" + zoneName + '\'' + ", podId=" + podId +
", type=" + type + ", podName='" + podName + '\'' +
", capacityUsed=" + capacityUsed + ", type=" + type +
", capacityTotal=" + capacityTotal + ", zoneId=" + zoneId +
", percentUsed=" + percentUsed + ", zoneName='" + zoneName + '\'' +
']'; '}';
} }
@Override @Override

View File

@ -270,9 +270,17 @@ public class DiskOffering implements Comparable<DiskOffering> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created + ", diskSize=" return "DiskOffering{" +
+ diskSize + ", iscustomized=" + customized + ", domain=" + domain + ", domainId=" + domainId + ", tags=" "id=" + id +
+ getTags() + "]"; ", name='" + name + '\'' +
", displayText='" + displayText + '\'' +
", created=" + created +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", diskSize=" + diskSize +
", customized=" + customized +
", tags='" + tags + '\'' +
'}';
} }
@Override @Override

View File

@ -265,9 +265,19 @@ public class Event implements Comparable<Event> {
@Override @Override
public String toString() { public String toString() {
return String.format("[id=%d, account=%s, description=%s, created=%s, domain=%s, domainId=%d, level=%s, " + return "Event{" +
"parentId=%s, state=%s, type=%s, username=%s]", "id=" + id +
id, account, description, created, domain, domainId, level, parentId, state, type, username); ", account='" + account + '\'' +
", description='" + description + '\'' +
", created=" + created +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", level='" + level + '\'' +
", parentId='" + parentId + '\'' +
", state='" + state + '\'' +
", type='" + type + '\'' +
", username='" + username + '\'' +
'}';
} }

View File

@ -18,10 +18,14 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import java.util.Collections;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class IPForwardingRule implements Comparable<IPForwardingRule> { public class IPForwardingRule implements Comparable<IPForwardingRule> {
@ -40,6 +44,10 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
private String virtualMachineDisplayName; private String virtualMachineDisplayName;
public long virtualMachineId; public long virtualMachineId;
private String virtualMachineName; private String virtualMachineName;
private Set<String> CIDRs = ImmutableSet.of();
private int privateEndPort;
private int publicEndPort;
public int publicPort;
public Builder id(long id) { public Builder id(long id) {
this.id = id; this.id = id;
@ -91,9 +99,29 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
return this; return this;
} }
public Builder publicPort(int publicPort) {
this.publicPort = publicPort;
return this;
}
public Builder CIDRs(Set<String> CIDRs) {
this.CIDRs = CIDRs;
return this;
}
public Builder privateEndPort(int privateEndPort) {
this.privateEndPort = privateEndPort;
return this;
}
public Builder publicEndPort(int publicEndPort) {
this.publicEndPort = publicEndPort;
return this;
}
public IPForwardingRule build() { public IPForwardingRule build() {
return new IPForwardingRule(id, IPAddress, IPAddressId, startPort, protocol, endPort, state, return new IPForwardingRule(id, IPAddress, IPAddressId, startPort, protocol, endPort, state,
virtualMachineDisplayName, virtualMachineId, virtualMachineName); virtualMachineDisplayName, virtualMachineId, virtualMachineName, publicEndPort, publicPort, CIDRs, privateEndPort);
} }
} }
@ -114,6 +142,14 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
public long virtualMachineId; public long virtualMachineId;
@SerializedName("virtualmachinename") @SerializedName("virtualmachinename")
private String virtualMachineName; private String virtualMachineName;
@SerializedName("publicport")
public int publicPort;
@SerializedName("cidrlist")
private Set<String> CIDRs;
@SerializedName("privateendport")
private int privateEndPort;
@SerializedName("publicendport")
private int publicEndPort;
// for deserializer // for deserializer
IPForwardingRule() { IPForwardingRule() {
@ -121,7 +157,8 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
public IPForwardingRule(long id, String iPAddress, long iPAddressId, int startPort, String protocol, int endPort, public IPForwardingRule(long id, String iPAddress, long iPAddressId, int startPort, String protocol, int endPort,
String state, String virtualMachineDisplayName, long virtualMachineId, String virtualMachineName) { String state, String virtualMachineDisplayName, long virtualMachineId, String virtualMachineName,
int publicEndPort, int publicPort, Set<String> CIDRs, int privateEndPort) {
this.id = id; this.id = id;
this.IPAddress = iPAddress; this.IPAddress = iPAddress;
this.IPAddressId = iPAddressId; this.IPAddressId = iPAddressId;
@ -132,6 +169,11 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
this.virtualMachineDisplayName = virtualMachineDisplayName; this.virtualMachineDisplayName = virtualMachineDisplayName;
this.virtualMachineId = virtualMachineId; this.virtualMachineId = virtualMachineId;
this.virtualMachineName = virtualMachineName; this.virtualMachineName = virtualMachineName;
this.CIDRs = Sets.newHashSet(CIDRs);
this.privateEndPort = privateEndPort;
this.publicEndPort = publicEndPort;
this.publicPort = publicPort;
} }
@Override @Override
@ -140,7 +182,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the ID of the ip forwarding rule * @return the ID of the ip forwarding rule
*/ */
public long getId() { public long getId() {
@ -148,7 +189,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the public ip address for the ip forwarding rule * @return the public ip address for the ip forwarding rule
*/ */
public String getIPAddress() { public String getIPAddress() {
@ -156,7 +196,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the public ip address id for the ip forwarding rule * @return the public ip address id for the ip forwarding rule
*/ */
public long getIPAddressId() { public long getIPAddressId() {
@ -164,7 +203,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the private port for the ip forwarding rule * @return the private port for the ip forwarding rule
*/ */
public int getStartPort() { public int getStartPort() {
@ -172,7 +210,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the protocol of the ip forwarding rule * @return the protocol of the ip forwarding rule
*/ */
public String getProtocol() { public String getProtocol() {
@ -180,7 +217,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the public port for the ip forwarding rule * @return the public port for the ip forwarding rule
*/ */
public int getEndPort() { public int getEndPort() {
@ -188,7 +224,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the state of the rule * @return the state of the rule
*/ */
public String getState() { public String getState() {
@ -196,7 +231,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the VM display name for the ip forwarding rule * @return the VM display name for the ip forwarding rule
*/ */
public String getVirtualMachineDisplayName() { public String getVirtualMachineDisplayName() {
@ -204,7 +238,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the VM ID for the ip forwarding rule * @return the VM ID for the ip forwarding rule
*/ */
public long getVirtualMachineId() { public long getVirtualMachineId() {
@ -212,13 +245,40 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
} }
/** /**
*
* @return the VM name for the ip forwarding rule * @return the VM name for the ip forwarding rule
*/ */
public String getVirtualMachineName() { public String getVirtualMachineName() {
return virtualMachineName; return virtualMachineName;
} }
/**
* @return the starting port of port forwarding rule's public port range
*/
public int getPublicPort() {
return publicPort;
}
/**
* @return the cidr list to forward traffic from
*/
public Set<String> getCIDRs() {
return Collections.unmodifiableSet(CIDRs);
}
/**
* @return the ending port of port forwarding rule's private port range
*/
public int getPrivateEndPort() {
return privateEndPort;
}
/**
* @return the ending port of port forwarding rule's private port range
*/
public int getPublicEndPort() {
return publicEndPort;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -229,6 +289,9 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
result = prime * result + (int) (id ^ (id >>> 32)); result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
result = prime * result + startPort; result = prime * result + startPort;
result = prime * result + publicEndPort;
result = prime * result + privateEndPort;
result = prime * result + publicPort;
result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode());
result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode());
result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32));
@ -254,6 +317,12 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
return false; return false;
if (endPort != other.endPort) if (endPort != other.endPort)
return false; return false;
if (publicPort != other.publicPort)
return false;
if (publicEndPort != other.publicEndPort)
return false;
if (privateEndPort != other.privateEndPort)
return false;
if (id != other.id) if (id != other.id)
return false; return false;
if (protocol == null) { if (protocol == null) {

View File

@ -689,7 +689,7 @@ public class ISO implements Comparable<ISO> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "ISO{" +
"id=" + id + "id=" + id +
", account='" + account + '\'' + ", account='" + account + '\'' +
", accountId=" + accountId + ", accountId=" + accountId +
@ -722,7 +722,7 @@ public class ISO implements Comparable<ISO> {
", templateType='" + templateType + '\'' + ", templateType='" + templateType + '\'' +
", zoneId=" + zoneId + ", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' + ", zoneName='" + zoneName + '\'' +
']'; '}';
} }
@Override @Override

View File

@ -313,21 +313,21 @@ public class ISOExtraction implements Comparable<ISOExtraction> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "ISOExtraction{" +
"id=" + id + "id=" + id +
", accountId=" + accountId + ", accountId=" + accountId +
", created=" + created + ", created=" + created +
", extractId=" + extractId + ", extractId=" + extractId +
", extractMode=" + extractMode + ", extractMode=" + extractMode +
", name='" + name + '\'' + ", name='" + name + '\'' +
", state='" + state + '\'' + ", state='" + state + '\'' +
", status='" + status + '\'' + ", status='" + status + '\'' +
", storageType='" + storageType + '\'' + ", storageType='" + storageType + '\'' +
", uploadPercentage=" + uploadPercentage + ", uploadPercentage=" + uploadPercentage +
", url='" + url + '\'' + ", url='" + url + '\'' +
", zoneId=" + zoneId + ", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' + ", zoneName='" + zoneName + '\'' +
']'; '}';
} }
@Override @Override

View File

@ -137,12 +137,12 @@ public class ISOPermissions implements Comparable<ISOPermissions> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "ISOPermissions{" +
"id=" + id + "id=" + id +
", account='" + account + '\'' + ", account='" + account + '\'' +
", domainId=" + domainId + ", domainId=" + domainId +
", isPublic=" + isPublic + ", isPublic=" + isPublic +
']'; '}';
} }
@Override @Override

View File

@ -256,9 +256,17 @@ public class IngressRule implements Comparable<IngressRule> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", securityGroupName=" + securityGroupName + ", account=" + account + ", startPort=" return "IngressRule{" +
+ startPort + ", endPort=" + endPort + ", protocol=" + protocol + ", CIDR=" + CIDR + ", ICMPCode=" "account='" + account + '\'' +
+ ICMPCode + ", ICMPType=" + ICMPType + "]"; ", CIDR='" + CIDR + '\'' +
", endPort=" + endPort +
", ICMPCode=" + ICMPCode +
", ICMPType=" + ICMPType +
", protocol='" + protocol + '\'' +
", id=" + id +
", securityGroupName='" + securityGroupName + '\'' +
", startPort=" + startPort +
'}';
} }
@Override @Override

View File

@ -57,10 +57,10 @@ public class JobResult implements Comparable<JobResult> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "JobResult{" +
"success=" + success + "success=" + success +
", displayText=" + (displayText != null ? '\'' + displayText + '\'' : "null") + ", displayText='" + displayText + '\'' +
']'; '}';
} }
@Override @Override

View File

@ -20,16 +20,21 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class LoadBalancerRule implements Comparable<LoadBalancerRule> { public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
public static enum State { public static enum State {
ADD, ACTIVE, UNRECOGNIZED; ADD, ACTIVE, 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());
@ -47,6 +52,7 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
public static enum Algorithm { public static enum Algorithm {
SOURCE, ROUNDROBIN, LEASTCONN, UNRECOGNIZED; SOURCE, ROUNDROBIN, LEASTCONN, UNRECOGNIZED;
@Override @Override
public String toString() { public String toString() {
return name().toLowerCase(); return name().toLowerCase();
@ -79,6 +85,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
private long publicIPId; private long publicIPId;
private int publicPort; private int publicPort;
private State state; private State state;
private Set<String> CIDRs = ImmutableSet.of();
private long zoneId;
public Builder id(long id) { public Builder id(long id) {
this.id = id; this.id = id;
@ -140,9 +148,19 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
return this; return this;
} }
public Builder CIDRs(Set<String> CIDRs) {
this.CIDRs = CIDRs;
return this;
}
public Builder zoneId(long zoneId) {
this.zoneId = zoneId;
return this;
}
public LoadBalancerRule build() { public LoadBalancerRule build() {
return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort, return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort,
publicIP, publicIPId, publicPort, state); publicIP, publicIPId, publicPort, state, zoneId, CIDRs);
} }
} }
@ -163,6 +181,10 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
@SerializedName("publicport") @SerializedName("publicport")
private int publicPort; private int publicPort;
private State state; private State state;
@SerializedName("cidrlist")
private Set<String> CIDRs;
@SerializedName("zoneId")
private long zoneId;
// for deserializer // for deserializer
LoadBalancerRule() { LoadBalancerRule() {
@ -170,7 +192,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
} }
public LoadBalancerRule(long id, String account, Algorithm algorithm, String description, String domain, public LoadBalancerRule(long id, String account, Algorithm algorithm, String description, String domain,
long domainId, String name, int privatePort, String publicIP, long publicIPId, int publicPort, State state) { long domainId, String name, int privatePort, String publicIP, long publicIPId, int publicPort, State state,
long zoneId, Set<String> CIDRs) {
this.id = id; this.id = id;
this.account = account; this.account = account;
this.algorithm = algorithm; this.algorithm = algorithm;
@ -183,6 +206,9 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
this.publicIPId = publicIPId; this.publicIPId = publicIPId;
this.publicPort = publicPort; this.publicPort = publicPort;
this.state = state; this.state = state;
this.zoneId = zoneId;
this.CIDRs = Sets.newHashSet(CIDRs);
} }
/** /**
@ -269,11 +295,26 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
return state; return state;
} }
/**
* @return the cidr list to forward traffic from
*/
public Set<String> getCIDRs() {
return Collections.unmodifiableSet(CIDRs);
}
/**
* @return the id of the zone the rule belongs to
*/
public long getZoneId() {
return zoneId;
}
@Override @Override
public int compareTo(LoadBalancerRule arg0) { public int compareTo(LoadBalancerRule arg0) {
return new Long(id).compareTo(arg0.getId()); return new Long(id).compareTo(arg0.getId());
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -289,6 +330,7 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode()); result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode());
result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32)); result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32));
result = prime * result + publicPort; result = prime * result + publicPort;
result = prime * result + (int) (zoneId ^ (zoneId >>> 32));
result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode());
return result; return result;
} }
@ -324,6 +366,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
return false; return false;
if (domainId != other.domainId) if (domainId != other.domainId)
return false; return false;
if (zoneId != other.zoneId)
return false;
if (id != other.id) if (id != other.id)
return false; return false;
if (name == null) { if (name == null) {
@ -352,10 +396,22 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
@Override @Override
public String toString() { public String toString() {
return "[account=" + account + ", algorithm=" + algorithm + ", description=" + description + ", domain=" + domain return "LoadBalancerRule{" +
+ ", domainId=" + domainId + ", id=" + id + ", name=" + name + ", privatePort=" + privatePort "id=" + id +
+ ", publicIP=" + publicIP + ", publicIPId=" + publicIPId + ", publicPort=" + publicPort + ", state=" ", account='" + account + '\'' +
+ state + "]"; ", algorithm=" + algorithm +
", description='" + description + '\'' +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", name='" + name + '\'' +
", privatePort=" + privatePort +
", publicIP='" + publicIP + '\'' +
", publicIPId=" + publicIPId +
", publicPort=" + publicPort +
", state=" + state +
", CIDRs=" + CIDRs +
", zoneId=" + zoneId +
'}';
} }
} }

View File

@ -297,9 +297,19 @@ public class NIC {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", broadcastURI=" + broadcastURI + ", gateway=" + gateway + ", IPAddress=" + IPAddress return "NIC{" +
+ ", isDefault=" + isDefault + ", isolationURI=" + isolationURI + ", netmask=" + netmask + ", MACAddress=" "id=" + id +
+ macAddress + ", networkId=" + networkId + ", trafficType=" + trafficType + ", guestIPType=" + guestIPType + "]"; ", broadcastURI=" + broadcastURI +
", gateway='" + gateway + '\'' +
", IPAddress='" + IPAddress + '\'' +
", isDefault=" + isDefault +
", isolationURI=" + isolationURI +
", netmask='" + netmask + '\'' +
", macAddress='" + macAddress + '\'' +
", networkId=" + networkId +
", trafficType=" + trafficType +
", guestIPType=" + guestIPType +
'}';
} }
} }

View File

@ -18,10 +18,7 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import com.google.common.collect.ImmutableList; 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;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.net.URI; import java.net.URI;
@ -29,7 +26,12 @@ import java.util.List;
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.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gson.annotations.SerializedName;
/** /**
* @author Adrian Cole * @author Adrian Cole
@ -66,12 +68,27 @@ public class Network implements Comparable<Network> {
private TrafficType trafficType; private TrafficType trafficType;
private long zoneId; private long zoneId;
private Set<? extends NetworkService> services = ImmutableSet.<NetworkService>of(); private Set<? extends NetworkService> services = ImmutableSet.<NetworkService>of();
private String account;
private long domainId;
private boolean securityGroupEnabled;
private Set<String> tags = ImmutableSet.of();
public Builder id(long id) { public Builder id(long id) {
this.id = id; this.id = id;
return this; return this;
} }
public Builder account(String account) {
this.account = account;
return this;
}
public Builder domainId(long domainId) {
this.domainId = domainId;
return this;
}
public Builder broadcastDomainType(String broadcastDomainType) { public Builder broadcastDomainType(String broadcastDomainType) {
this.broadcastDomainType = broadcastDomainType; this.broadcastDomainType = broadcastDomainType;
return this; return this;
@ -197,15 +214,26 @@ public class Network implements Comparable<Network> {
return this; return this;
} }
public Builder tags(Set<String> tags) {
this.tags = ImmutableSet.copyOf(checkNotNull(tags, "tags"));
return this;
}
public Builder securityGroupEnabled(boolean securityGroupEnabled) {
this.securityGroupEnabled = securityGroupEnabled;
return this;
}
public Network build() { public Network build() {
return new Network(id, broadcastDomainType, broadcastURI, displayText, DNS, domain, endIP, return new Network(id, broadcastDomainType, broadcastURI, displayText, DNS, domain, domainId, endIP,
gateway, isDefault, isShared, isSystem, netmask, networkDomain, networkOfferingAvailability, gateway, isDefault, isShared, isSystem, netmask, networkDomain, networkOfferingAvailability,
networkOfferingDisplayText, networkOfferingId, networkOfferingName, related, startIP, name, state, networkOfferingDisplayText, networkOfferingId, networkOfferingName, related, startIP, name, state,
guestIPType, VLAN, trafficType, zoneId, services); guestIPType, VLAN, trafficType, zoneId, services, tags, securityGroupEnabled, account);
} }
} }
private long id; private long id;
private String account;
@SerializedName("broadcastdomaintype") @SerializedName("broadcastdomaintype")
private String broadcastDomainType; private String broadcastDomainType;
@SerializedName("broadcasturi") @SerializedName("broadcasturi")
@ -216,8 +244,9 @@ public class Network implements Comparable<Network> {
private String DNS1; private String DNS1;
@SerializedName("dns2") @SerializedName("dns2")
private String DNS2; private String DNS2;
@SerializedName("networkdomain")
private String domain; private String domain;
@SerializedName("domainid")
private long domainId;
@SerializedName("endip") @SerializedName("endip")
private String endIP; private String endIP;
private String gateway; private String gateway;
@ -252,8 +281,11 @@ public class Network implements Comparable<Network> {
private TrafficType trafficType; private TrafficType trafficType;
@SerializedName("zoneid") @SerializedName("zoneid")
private long zoneId; private long zoneId;
@SerializedName("service") private String tags;
@SerializedName("securitygroupenabled")
private boolean securityGroupEnabled;
// so tests and serialization comes out expected // so tests and serialization comes out expected
@SerializedName("service")
private SortedSet<? extends NetworkService> services = ImmutableSortedSet.<NetworkService>of(); private SortedSet<? extends NetworkService> services = ImmutableSortedSet.<NetworkService>of();
/** /**
@ -264,11 +296,12 @@ public class Network implements Comparable<Network> {
} }
public Network(long id, String broadcastDomainType, URI broadcastURI, String displayText, public Network(long id, String broadcastDomainType, URI broadcastURI, String displayText,
List<String> DNS, String domain, String endIP, String gateway, boolean isDefault, List<String> DNS, String domain, long domainId, String endIP, String gateway, boolean isDefault,
boolean isShared, boolean isSystem, String netmask, String networkDomain, String networkOfferingAvailability, boolean isShared, boolean isSystem, String netmask, String networkDomain, String networkOfferingAvailability,
String networkOfferingDisplayText, long networkOfferingId, String networkOfferingName, long related, String networkOfferingDisplayText, long networkOfferingId, String networkOfferingName, long related,
String startIP, String name, String state, GuestIPType type, String vLAN, TrafficType trafficType, String startIP, String name, String state, GuestIPType type, String vLAN, TrafficType trafficType,
long zoneId, Set<? extends NetworkService> services) { long zoneId, Set<? extends NetworkService> services, Set<String> tags, boolean securityGroupEnabled,
String account) {
this.id = id; this.id = id;
this.broadcastDomainType = broadcastDomainType; this.broadcastDomainType = broadcastDomainType;
this.broadcastURI = broadcastURI; this.broadcastURI = broadcastURI;
@ -276,6 +309,7 @@ public class Network implements Comparable<Network> {
this.DNS1 = checkNotNull(DNS, "DNS").size() > 0 ? DNS.get(0) : null; this.DNS1 = checkNotNull(DNS, "DNS").size() > 0 ? DNS.get(0) : null;
this.DNS2 = DNS.size() > 1 ? DNS.get(1) : null; this.DNS2 = DNS.size() > 1 ? DNS.get(1) : null;
this.domain = domain; this.domain = domain;
this.domainId = domainId;
this.endIP = endIP; this.endIP = endIP;
this.gateway = gateway; this.gateway = gateway;
this.isDefault = isDefault; this.isDefault = isDefault;
@ -296,6 +330,9 @@ public class Network implements Comparable<Network> {
this.trafficType = trafficType; this.trafficType = trafficType;
this.zoneId = zoneId; this.zoneId = zoneId;
this.services = ImmutableSortedSet.copyOf(checkNotNull(services, "services")); this.services = ImmutableSortedSet.copyOf(checkNotNull(services, "services"));
this.tags = tags.size() == 0 ? null : Joiner.on(',').join(tags);
this.securityGroupEnabled = securityGroupEnabled;
this.account = account;
} }
/** /**
@ -339,12 +376,26 @@ public class Network implements Comparable<Network> {
} }
/** /**
* @return Domain name for the Vms in the zone * @return Domain name for the Network
*/ */
public String getDomain() { public String getDomain() {
return domain; return domain;
} }
/**
* @return the domain id of the Network
*/
public long getDomainId() {
return domainId;
}
/**
* @return the account associated with the network
*/
public String getAccount() {
return account;
}
/** /**
* @return the end ip of the network * @return the end ip of the network
*/ */
@ -485,6 +536,20 @@ public class Network implements Comparable<Network> {
return services; return services;
} }
/**
* @return true if security group is enabled, false otherwise
*/
public boolean isSecurityGroupEnabled() {
return securityGroupEnabled;
}
/**
* @return the tags for the Network
*/
public Set<String> getTags() {
return tags != null ? ImmutableSet.copyOf(Splitter.on(',').split(tags)) : ImmutableSet.<String>of();
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -516,6 +581,8 @@ public class Network implements Comparable<Network> {
result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode());
result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode()); result = prime * result + ((trafficType == null) ? 0 : trafficType.hashCode());
result = prime * result + (int) (zoneId ^ (zoneId >>> 32)); result = prime * result + (int) (zoneId ^ (zoneId >>> 32));
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
result = prime * result + (int) (domainId ^ (domainId >>> 32));
return result; return result;
} }
@ -636,20 +703,51 @@ public class Network implements Comparable<Network> {
return false; return false;
if (zoneId != other.zoneId) if (zoneId != other.zoneId)
return false; return false;
if (tags == null) {
if (other.tags != null)
return false;
} else if (!tags.equals(other.tags))
return false;
if (domainId != other.domainId)
return false;
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", state=" + state + ", name=" + name + ", displayText=" + displayText + ", guestIPType=" return "Network{" +
+ guestIPType + ", trafficType=" + trafficType + ", DNS=" + getDNS() + ", VLAN=" + VLAN "id=" + id +
+ ", startIP=" + startIP + ", endIP=" + endIP + ", netmask=" + netmask + ", gateway=" + gateway ", account='" + account + '\'' +
+ ", broadcastDomainType=" + broadcastDomainType + ", broadcastURI=" + broadcastURI + ", services=" ", broadcastDomainType='" + broadcastDomainType + '\'' +
+ services + ", domain=" + domain + ", isDefault=" + isDefault + ", isShared=" ", broadcastURI=" + broadcastURI +
+ isShared + ", isSystem=" + isSystem + ", related=" + related + ", zoneId=" + zoneId + ", domain=" ", displayText='" + displayText + '\'' +
+ networkDomain + ", networkOfferingAvailability=" + networkOfferingAvailability ", DNS1='" + DNS1 + '\'' +
+ ", networkOfferingDisplayText=" + networkOfferingDisplayText + ", networkOfferingId=" + networkOfferingId ", DNS2='" + DNS2 + '\'' +
+ ", networkOfferingName=" + networkOfferingName + "]"; ", domain='" + domain + '\'' +
", domainId=" + domainId +
", endIP='" + endIP + '\'' +
", gateway='" + gateway + '\'' +
", isDefault=" + isDefault +
", isShared=" + isShared +
", isSystem=" + isSystem +
", netmask='" + netmask + '\'' +
", networkDomain='" + networkDomain + '\'' +
", networkOfferingAvailability='" + networkOfferingAvailability + '\'' +
", networkOfferingDisplayText='" + networkOfferingDisplayText + '\'' +
", networkOfferingId=" + networkOfferingId +
", networkOfferingName='" + networkOfferingName + '\'' +
", related=" + related +
", startIP='" + startIP + '\'' +
", name='" + name + '\'' +
", state='" + state + '\'' +
", guestIPType=" + guestIPType +
", VLAN='" + VLAN + '\'' +
", trafficType=" + trafficType +
", zoneId=" + zoneId +
", tags='" + tags + '\'' +
", securityGroupEnabled=" + securityGroupEnabled +
", services=" + services +
'}';
} }
@Override @Override

View File

@ -334,9 +334,20 @@ public class NetworkOffering implements Comparable<NetworkOffering> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created return "NetworkOffering{" +
+ ", maxConnections=" + maxConnections + ", trafficType=" + trafficType + ", isDefault=" + isDefault "id=" + id +
+ ", availability=" + availability + ", supportsVLAN=" + supportsVLAN + ", tags=" + getTags() + "]"; ", name='" + name + '\'' +
", displayText='" + displayText + '\'' +
", created=" + created +
", availability=" + availability +
", maxConnections=" + maxConnections +
", isDefault=" + isDefault +
", supportsVLAN=" + supportsVLAN +
", trafficType=" + trafficType +
", guestIPType=" + guestIPType +
", networkRate=" + networkRate +
", tags='" + tags + '\'' +
'}';
} }
@Override @Override

View File

@ -160,7 +160,10 @@ public class NetworkService implements Comparable<NetworkService> {
@Override @Override
public String toString() { public String toString() {
return "[name=" + name + ", capabilities=" + capabilities + "]"; return "NetworkService{" +
"name='" + name + '\'' +
", capabilities=" + capabilities +
'}';
} }
@Override @Override

View File

@ -125,7 +125,11 @@ public class OSType implements Comparable<OSType> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", OSCategoryId=" + OSCategoryId + ", description=" + description + "]"; return "OSType{" +
"id=" + id +
", OSCategoryId=" + OSCategoryId +
", description='" + description + '\'' +
'}';
} }
@Override @Override

View File

@ -18,10 +18,14 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
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 PortForwardingRule implements Comparable<PortForwardingRule> { public class PortForwardingRule implements Comparable<PortForwardingRule> {
@ -40,6 +44,9 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
private String virtualMachineDisplayName; private String virtualMachineDisplayName;
public long virtualMachineId; public long virtualMachineId;
private String virtualMachineName; private String virtualMachineName;
private Set<String> CIDRs = ImmutableSet.of();
private int privateEndPort;
private int publicEndPort;
public Builder id(long id) { public Builder id(long id) {
this.id = id; this.id = id;
@ -91,9 +98,24 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
return this; return this;
} }
public Builder CIDRs(Set<String> CIDRs) {
this.CIDRs = CIDRs;
return this;
}
public Builder privateEndPort(int privateEndPort) {
this.privateEndPort = privateEndPort;
return this;
}
public Builder publicEndPort(int publicEndPort) {
this.publicEndPort = publicEndPort;
return this;
}
public PortForwardingRule build() { public PortForwardingRule build() {
return new PortForwardingRule(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state, return new PortForwardingRule(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state,
virtualMachineDisplayName, virtualMachineId, virtualMachineName); virtualMachineDisplayName, virtualMachineId, virtualMachineName, CIDRs, privateEndPort, publicEndPort);
} }
} }
@ -106,7 +128,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
private int privatePort; private int privatePort;
private String protocol; private String protocol;
@SerializedName("publicport") @SerializedName("publicport")
public String publicPort; public int publicPort;
private String state; private String state;
@SerializedName("virtualmachinedisplayname") @SerializedName("virtualmachinedisplayname")
private String virtualMachineDisplayName; private String virtualMachineDisplayName;
@ -114,6 +136,13 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
public long virtualMachineId; public long virtualMachineId;
@SerializedName("virtualmachinename") @SerializedName("virtualmachinename")
private String virtualMachineName; private String virtualMachineName;
@SerializedName("cidrlist")
private Set<String> CIDRs;
@SerializedName("privateendport")
private int privateEndPort;
@SerializedName("publicendport")
private int publicEndPort;
// for deserializer // for deserializer
PortForwardingRule() { PortForwardingRule() {
@ -121,18 +150,21 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, String protocol, public PortForwardingRule(long id, String iPAddress, long iPAddressId, int privatePort, String protocol,
int publicPort, String state, String virtualMachineDisplayName, long virtualMachineId, int publicPort, String state, String virtualMachineDisplayName, long virtualMachineId,
String virtualMachineName) { String virtualMachineName, Set<String> CIDRs, int privateEndPort, int publicEndPort) {
this.id = id; this.id = id;
this.IPAddress = iPAddress; this.IPAddress = iPAddress;
this.IPAddressId = iPAddressId; this.IPAddressId = iPAddressId;
this.privatePort = privatePort; this.privatePort = privatePort;
this.protocol = protocol; this.protocol = protocol;
this.publicPort = publicPort + ""; this.publicPort = publicPort;
this.state = state; this.state = state;
this.virtualMachineDisplayName = virtualMachineDisplayName; this.virtualMachineDisplayName = virtualMachineDisplayName;
this.virtualMachineId = virtualMachineId; this.virtualMachineId = virtualMachineId;
this.virtualMachineName = virtualMachineName; this.virtualMachineName = virtualMachineName;
this.CIDRs = new HashSet<String>(CIDRs);
this.privateEndPort = privateEndPort;
this.publicEndPort = publicEndPort;
} }
@Override @Override
@ -141,7 +173,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the ID of the port forwarding rule * @return the ID of the port forwarding rule
*/ */
public long getId() { public long getId() {
@ -149,7 +180,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the public ip address for the port forwarding rule * @return the public ip address for the port forwarding rule
*/ */
public String getIPAddress() { public String getIPAddress() {
@ -157,7 +187,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the public ip address id for the port forwarding rule * @return the public ip address id for the port forwarding rule
*/ */
public long getIPAddressId() { public long getIPAddressId() {
@ -165,7 +194,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the private port for the port forwarding rule * @return the private port for the port forwarding rule
*/ */
public int getPrivatePort() { public int getPrivatePort() {
@ -173,7 +201,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the protocol of the port forwarding rule * @return the protocol of the port forwarding rule
*/ */
public String getProtocol() { public String getProtocol() {
@ -181,15 +208,13 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the public port for the port forwarding rule * @return the public port for the port forwarding rule
*/ */
public int getPublicPort() { public int getPublicPort() {
return Integer.parseInt(publicPort); return publicPort;
} }
/** /**
*
* @return the state of the rule * @return the state of the rule
*/ */
public String getState() { public String getState() {
@ -197,7 +222,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the VM display name for the port forwarding rule * @return the VM display name for the port forwarding rule
*/ */
public String getVirtualMachineDisplayName() { public String getVirtualMachineDisplayName() {
@ -205,7 +229,6 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the VM ID for the port forwarding rule * @return the VM ID for the port forwarding rule
*/ */
public long getVirtualMachineId() { public long getVirtualMachineId() {
@ -213,13 +236,33 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
} }
/** /**
*
* @return the VM name for the port forwarding rule * @return the VM name for the port forwarding rule
*/ */
public String getVirtualMachineName() { public String getVirtualMachineName() {
return virtualMachineName; return virtualMachineName;
} }
/**
* @return the cidr list to forward traffic from
*/
public Set<String> getCIDRs() {
return Collections.unmodifiableSet(CIDRs);
}
/**
* @return the starting port of port forwarding rule's private port range
*/
public int getPrivateEndPort() {
return privateEndPort;
}
/**
* @return the starting port of port forwarding rule's public port range
*/
public int getPublicEndPort() {
return publicEndPort;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -229,7 +272,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
result = prime * result + (int) (id ^ (id >>> 32)); result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + privatePort; result = prime * result + privatePort;
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
result = prime * result + ((publicPort == null) ? 0 : publicPort.hashCode()); result = prime * result + publicPort;
result = prime * result + ((state == null) ? 0 : state.hashCode()); result = prime * result + ((state == null) ? 0 : state.hashCode());
result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode()); result = prime * result + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode());
result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32)); result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32));
@ -262,10 +305,7 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
return false; return false;
} else if (!protocol.equals(other.protocol)) } else if (!protocol.equals(other.protocol))
return false; return false;
if (publicPort == null) { if (privatePort != other.privatePort)
if (other.publicPort != null)
return false;
} else if (!publicPort.equals(other.publicPort))
return false; return false;
if (state == null) { if (state == null) {
if (other.state != null) if (other.state != null)
@ -289,10 +329,21 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
@Override @Override
public String toString() { public String toString() {
return "[IPAddress=" + IPAddress + ", IPAddressId=" + IPAddressId + ", id=" + id + ", privatePort=" + privatePort return "PortForwardingRule{" +
+ ", protocol=" + protocol + ", publicPort=" + publicPort + ", state=" + state "id=" + id +
+ ", virtualMachineDisplayName=" + virtualMachineDisplayName + ", virtualMachineId=" + virtualMachineId ", IPAddress='" + IPAddress + '\'' +
+ ", virtualMachineName=" + virtualMachineName + "]"; ", IPAddressId=" + IPAddressId +
", privatePort=" + privatePort +
", protocol='" + protocol + '\'' +
", publicPort=" + publicPort +
", state='" + state + '\'' +
", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' +
", virtualMachineId=" + virtualMachineId +
", virtualMachineName='" + virtualMachineName + '\'' +
", CIDRs=" + CIDRs +
", privateEndPort=" + privateEndPort +
", publicEndPort=" + publicEndPort +
'}';
} }
} }

View File

@ -18,10 +18,11 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable; 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;
@ -538,12 +539,29 @@ public class PublicIPAddress implements Comparable<PublicIPAddress> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", IPAddress=" + IPAddress + ", VLANId=" + VLANId + ", VLANName=" + VLANName + ", account=" return "PublicIPAddress{" +
+ account + ", allocated=" + allocated + ", associatedNetworkId=" + associatedNetworkId + ", domain=" "id=" + id +
+ domain + ", domainId=" + domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", isSourceNAT=" ", account='" + account + '\'' +
+ isSourceNAT + ", isStaticNAT=" + isStaticNAT + ", networkId=" + networkId + ", state=" + state ", allocated=" + allocated +
+ ", virtualMachineDisplayName=" + virtualMachineDisplayName + ", virtualMachineId=" + virtualMachineId ", associatedNetworkId=" + associatedNetworkId +
+ ", virtualMachineName=" + virtualMachineName + ", zoneId=" + zoneId + ", zoneName=" + zoneName + "]"; ", domain='" + domain + '\'' +
", domainId=" + domainId +
", usesVirtualNetwork=" + usesVirtualNetwork +
", IPAddress='" + IPAddress + '\'' +
", isSourceNAT=" + isSourceNAT +
", isStaticNAT=" + isStaticNAT +
", networkId=" + networkId +
", state=" + state +
", virtualMachineDisplayName='" + virtualMachineDisplayName + '\'' +
", virtualMachineId=" + virtualMachineId +
", virtualMachineName='" + virtualMachineName + '\'' +
", VLANId=" + VLANId +
", VLANName='" + VLANName + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
", jobId=" + jobId +
", jobStatus=" + jobStatus +
'}';
} }
} }

View File

@ -148,8 +148,13 @@ public class ResourceLimit implements Comparable<ResourceLimit> {
@Override @Override
public String toString() { public String toString() {
return String.format("[account=%s, domain=%s, domainId=%d, max=%d, resourceType=%s]", return "ResourceLimit{" +
account, domain, domainId, max, resourceType); "account='" + account + '\'' +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", max=" + max +
", resourceType=" + resourceType +
'}';
} }
/** /**

View File

@ -240,8 +240,17 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", account=" + account + ", name=" + name + ", description=" + description + ", domain=" return "SecurityGroup{" +
+ domain + ", domainId=" + domainId + ", ingressRules=" + ingressRules + "]"; "id=" + id +
", account='" + account + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", jobId=" + jobId +
", jobStatus=" + jobStatus +
", ingressRules=" + ingressRules +
'}';
} }
@Override @Override

View File

@ -411,10 +411,26 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", created=" + created + ", cpuNumber=" return "ServiceOffering{" +
+ cpuNumber + ", cpuSpeed=" + cpuSpeed + ", memory=" + memory + ", storageType=" + storageType "id=" + id +
+ ", haSupport=" + haSupport + ", domain=" + domain + ", domainId=" + domainId + ", tags=" + getTags() ", name='" + name + '\'' +
+ "]"; ", displayText='" + displayText + '\'' +
", created=" + created +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", cpuNumber=" + cpuNumber +
", cpuSpeed=" + cpuSpeed +
", memory=" + memory +
", haSupport=" + haSupport +
", storageType=" + storageType +
", tags='" + tags + '\'' +
", defaultUse=" + defaultUse +
", hostTags='" + hostTags + '\'' +
", systemOffering=" + systemOffering +
", cpuUseLimited=" + cpuUseLimited +
", networkRate=" + networkRate +
", systemVmType=" + systemVmType +
'}';
} }
@Override @Override

View File

@ -406,7 +406,7 @@ public class Snapshot implements Comparable<Snapshot> {
@Override @Override
public String toString() { public String toString() {
return "Snapshot[" + return "Snapshot{" +
"id=" + id + "id=" + id +
", account='" + account + '\'' + ", account='" + account + '\'' +
", created=" + created + ", created=" + created +
@ -420,8 +420,8 @@ public class Snapshot implements Comparable<Snapshot> {
", state=" + state + ", state=" + state +
", volumeId=" + volumeId + ", volumeId=" + volumeId +
", volumeName='" + volumeName + '\'' + ", volumeName='" + volumeName + '\'' +
", volumeType='" + volumeType + '\'' + ", volumeType=" + volumeType +
']'; '}';
} }
@Override @Override

View File

@ -188,14 +188,14 @@ public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "SnapshotPolicy{" +
"id=" + id + "id=" + id +
", interval=" + interval + ", interval=" + interval +
", numberToRetain=" + numberToRetain + ", numberToRetain=" + numberToRetain +
", schedule='" + schedule + '\'' + ", schedule='" + schedule + '\'' +
", timezone='" + timezone + '\'' + ", timezone='" + timezone + '\'' +
", volumeId=" + volumeId + ", volumeId=" + volumeId +
']'; '}';
} }
@Override @Override

View File

@ -41,4 +41,12 @@ public class SnapshotPolicySchedule {
public String getTime() { public String getTime() {
return time; return time;
} }
@Override
public String toString() {
return "SnapshotPolicySchedule{" +
"interval=" + interval +
", time='" + time + '\'' +
'}';
}
} }

View File

@ -125,7 +125,11 @@ public class SshKeyPair implements Comparable<SshKeyPair> {
@Override @Override
public String toString() { public String toString() {
return "[fingerprint=" + fingerprint + ", name=" + name + "]"; return "SshKeyPair{" +
"fingerprint='" + fingerprint + '\'' +
", name='" + name + '\'' +
", privateKey='" + privateKey + '\'' +
'}';
} }
@Override @Override

View File

@ -737,13 +737,40 @@ public class Template implements Comparable<Template> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", name=" + name + ", displayText=" + displayText + ", format=" + format + ", type=" + type return "Template{" +
+ ", hypervisor=" + hypervisor + ", size=" + size + ", status=" + status + ", created=" + created "id=" + id +
+ ", removed=" + removed + ", OSType=" + OSType + ", OSTypeId=" + OSTypeId + ", account=" + account ", displayText='" + displayText + '\'' +
+ ", accountId=" + accountId + ", domain=" + domain + ", domainId=" + domainId + ", zone=" + zone ", domain='" + domain + '\'' +
+ ", zoneId=" + zoneId + ", ready=" + ready + ", bootable=" + bootable + ", crossZones=" + crossZones ", domainId=" + domainId +
+ ", extractable=" + extractable + ", featured=" + featured + ", ispublic=" + ispublic ", account='" + account + '\'' +
+ ", passwordEnabled=" + passwordEnabled + ", jobId=" + jobId + ", jobStatus=" + jobStatus + "]"; ", accountId=" + accountId +
", zone='" + zone + '\'' +
", zoneId=" + zoneId +
", OSType='" + OSType + '\'' +
", OSTypeId=" + OSTypeId +
", name='" + name + '\'' +
", type=" + type +
", status='" + status + '\'' +
", format=" + format +
", hypervisor='" + hypervisor + '\'' +
", size=" + size +
", created=" + created +
", removed=" + removed +
", crossZones=" + crossZones +
", bootable=" + bootable +
", extractable=" + extractable +
", featured=" + featured +
", ispublic=" + ispublic +
", ready=" + ready +
", passwordEnabled=" + passwordEnabled +
", jobId=" + jobId +
", jobStatus='" + jobStatus + '\'' +
", checksum='" + checksum + '\'' +
", hostId=" + hostId +
", hostName='" + hostName + '\'' +
", sourceTemplateId=" + sourceTemplateId +
", templateTag='" + templateTag + '\'' +
'}';
} }
@Override @Override

View File

@ -332,11 +332,21 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", accountId=" + accountId + ", created=" + created return "TemplateExtraction{" +
+ ", extractId=" + extractId + ", extractMode=" + extractMode "id=" + id +
+ ", name=" + name + ", state=" + state + ", status=" + status ", accountId=" + accountId +
+ ", storageType=" + storageType + ", uploadPercentage=" + uploadPercentage ", created=" + created +
+ ", url=" + url + ", zoneId=" + zoneId + ", zoneName=" + zoneName; ", extractId=" + extractId +
", extractMode=" + extractMode +
", name='" + name + '\'' +
", state='" + state + '\'' +
", status='" + status + '\'' +
", storageType='" + storageType + '\'' +
", uploadPercentage=" + uploadPercentage +
", url='" + url + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
'}';
} }
@Override @Override

View File

@ -220,9 +220,17 @@ public class TemplateMetadata {
return Objects.hashCode(name, displayText, osTypeId, snapshotId, volumeId, passwordEnabled, virtualMachineId); return Objects.hashCode(name, displayText, osTypeId, snapshotId, volumeId, passwordEnabled, virtualMachineId);
} }
@Override @Override
public String toString() { public String toString() {
return "[" + "name='" + name + '\'' + ", osTypeId=" + osTypeId + ", displayText='" + displayText + '\'' + ']'; return "TemplateMetadata{" +
} "name='" + name + '\'' +
", osTypeId=" + osTypeId +
", displayText='" + displayText + '\'' +
", snapshotId=" + snapshotId +
", volumeId=" + volumeId +
", virtualMachineId=" + virtualMachineId +
", passwordEnabled=" + passwordEnabled +
'}';
}
} }

View File

@ -143,12 +143,12 @@ public class TemplatePermission implements Comparable<TemplatePermission> {
@Override @Override
public String toString() { public String toString() {
return "[" + return "TemplatePermission{" +
"id=" + id + "id=" + id +
", account='" + account + '\'' + ", account='" + account + '\'' +
", domainId=" + domainId + ", domainId=" + domainId +
", isPublic=" + isPublic + ", isPublic=" + isPublic +
']'; '}';
} }
@Override @Override

View File

@ -326,11 +326,22 @@ public class User implements Comparable<User> {
@Override @Override
public String toString() { public String toString() {
return String return "User{" +
.format( "id=" + id +
"[id=%s, name=%s, state=%s, created=%s, account=%s, accountType=%s, domain=%s, domainId=%s, email=%s, firstName=%s, lastName=%s, apiKey=%s, secretKey=%s, timeZone=%s]", ", name='" + name + '\'' +
id, name, state, created, account, accountType, domain, domainId, email, firstName, lastName, apiKey, ", firstName='" + firstName + '\'' +
secretKey, timeZone); ", lastName='" + lastName + '\'' +
", email='" + email + '\'' +
", created=" + created +
", state='" + state + '\'' +
", account='" + account + '\'' +
", accountType=" + accountType +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", timeZone='" + timeZone + '\'' +
", apiKey='" + apiKey + '\'' +
", secretKey='" + secretKey + '\'' +
'}';
} }
} }

View File

@ -18,10 +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 com.google.gson.annotations.SerializedName;
/** /**
* @author Richard Downer * @author Richard Downer
*/ */
@ -170,13 +170,14 @@ public class VMGroup implements Comparable<VMGroup> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + return "VMGroup{" +
", account='" + account + '\'' + "id=" + id +
", created=" + created + ", account='" + account + '\'' +
", domain='" + domain + '\'' + ", created=" + created +
", domainId=" + domainId + ", domain='" + domain + '\'' +
", name='" + name + '\'' + ", domainId=" + domainId +
'}'; ", name='" + name + '\'' +
'}';
} }
@Override @Override

View File

@ -958,23 +958,49 @@ public class VirtualMachine implements Comparable<VirtualMachine> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id return "VirtualMachine{" +
// + ", account=" + account + ", cpuCount=" + cpuCount + ", cpuSpeed=" + cpuSpeed + ", cpuUsed=" + cpuUsed "id=" + id +
+ ", displayName=" + displayName + ", created=" + created ", account='" + account + '\'' +
// + ", domain=" + domain + ", domainId=" ", cpuCount=" + cpuCount +
// + domainId + ", usesVirtualNetwork=" + usesVirtualNetwork + ", group=" + group + ", groupId=" + groupId ", cpuSpeed=" + cpuSpeed +
// + ", guestOSId=" + guestOSId + ", HAEnabled=" + HAEnabled + ", hostId=" + hostId + ", hostname=" + hostname ", cpuUsed='" + cpuUsed + '\'' +
+ ", IPAddress=" + IPAddress ", displayName='" + displayName + '\'' +
// + ", ISODisplayText=" + ISODisplayText + ", ISOId=" + ISOId + ", ISOName=" ", created=" + created +
// + ISOName + ", jobId=" + jobId + ", jobStatus=" + jobStatus + ", memory=" + memory + ", name=" + name ", domain='" + domain + '\'' +
// + ", networkKbsRead=" + networkKbsRead + ", networkKbsWrite=" + networkKbsWrite + ", password=" + password ", domainId=" + domainId +
// + ", passwordEnabled=" + passwordEnabled + ", rootDeviceId=" + rootDeviceId + ", rootDeviceType=" ", usesVirtualNetwork=" + usesVirtualNetwork +
// + rootDeviceType + ", serviceOfferingId=" + serviceOfferingId + ", serviceOfferingName=" + serviceOfferingName ", group='" + group + '\'' +
+ ", state=" + state ", groupId=" + groupId +
// + ", templateDisplayText=" + templateDisplayText ", guestOSId=" + guestOSId +
// + ", templateId=" + templateId + ", templateName=" + templateName + ", zoneId=" + zoneId + ", zoneName=" ", HAEnabled=" + HAEnabled +
// + zoneName + ", nics=" + nics + ", hypervisor=" + hypervisor + ", securityGroups=" + securityGroups ", hostId=" + hostId +
+ "]"; ", hostname='" + hostname + '\'' +
", IPAddress='" + IPAddress + '\'' +
", ISODisplayText='" + ISODisplayText + '\'' +
", ISOId=" + ISOId +
", ISOName='" + ISOName + '\'' +
", jobId=" + jobId +
", jobStatus=" + jobStatus +
", memory=" + memory +
", name='" + name + '\'' +
", networkKbsRead=" + networkKbsRead +
", networkKbsWrite=" + networkKbsWrite +
", password='" + password + '\'' +
", passwordEnabled=" + passwordEnabled +
", rootDeviceId=" + rootDeviceId +
", rootDeviceType='" + rootDeviceType + '\'' +
", serviceOfferingId=" + serviceOfferingId +
", serviceOfferingName='" + serviceOfferingName + '\'' +
", state=" + state +
", templateDisplayText='" + templateDisplayText + '\'' +
", templateId=" + templateId +
", templateName='" + templateName + '\'' +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
", nics=" + nics +
", hypervisor='" + hypervisor + '\'' +
", securityGroups=" + securityGroups +
'}';
} }
@Override @Override

View File

@ -19,10 +19,11 @@
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 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;
@ -551,7 +552,39 @@ public class Volume implements Comparable<Volume> {
@Override @Override
public String toString() { public String toString() {
return getClass().getCanonicalName() + "[" + id + "; " + name + "; " + vmState + "]"; return "Volume{" +
"id=" + id +
", account='" + account + '\'' +
", attached=" + attached +
", created=" + created +
", destroyed=" + destroyed +
", deviceId=" + deviceId +
", diskOfferingDisplayText='" + diskOfferingDisplayText + '\'' +
", diskOfferingId=" + diskOfferingId +
", diskOfferingName='" + diskOfferingName + '\'' +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", hypervisor='" + hypervisor + '\'' +
", isExtractable=" + isExtractable +
", jobId=" + jobId +
", jobStatus='" + jobStatus + '\'' +
", name='" + name + '\'' +
", serviceOfferingDisplayText='" + serviceOfferingDisplayText + '\'' +
", serviceOfferingId=" + serviceOfferingId +
", serviceOfferingName='" + serviceOfferingName + '\'' +
", size=" + size +
", snapshotId=" + snapshotId +
", state=" + state +
", storage='" + storage + '\'' +
", storageType='" + storageType + '\'' +
", type=" + type +
", virtualMachineId=" + virtualMachineId +
", vmDisplayName='" + vmDisplayName + '\'' +
", vmName='" + vmName + '\'' +
", vmState=" + vmState +
", zoneId=" + zoneId +
", zoneName='" + zoneName + '\'' +
'}';
} }
public enum State { public enum State {

View File

@ -20,15 +20,13 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**
*
* @author Adrian Cole * @author Adrian Cole
*/ */
public class Zone implements Comparable<Zone> { public class Zone implements Comparable<Zone> {
@ -47,9 +45,11 @@ public class Zone implements Comparable<Zone> {
private List<String> internalDNS = ImmutableList.of(); private List<String> internalDNS = ImmutableList.of();
private String name; private String name;
private NetworkType networkType; private NetworkType networkType;
private String status;
private String VLAN; private String VLAN;
private boolean securityGroupsEnabled; private boolean securityGroupsEnabled;
private String allocationState;
private String dhcpProvider;
private String zoneToken;
public Builder id(long id) { public Builder id(long id) {
this.id = id; this.id = id;
@ -101,11 +101,6 @@ public class Zone implements Comparable<Zone> {
return this; return this;
} }
public Builder status(String status) {
this.status = status;
return this;
}
public Builder VLAN(String VLAN) { public Builder VLAN(String VLAN) {
this.VLAN = VLAN; this.VLAN = VLAN;
return this; return this;
@ -116,9 +111,25 @@ public class Zone implements Comparable<Zone> {
return this; return this;
} }
public Builder allocationState(String allocationState) {
this.allocationState = allocationState;
return this;
}
public Builder dhcpProvider(String dhcpProvider) {
this.dhcpProvider = dhcpProvider;
return this;
}
public Builder zoneToken(String zoneToken) {
this.zoneToken = zoneToken;
return this;
}
public Zone build() { public Zone build() {
return new Zone(id, description, displayText, DNS, domain, domainId, guestCIDRAddress, internalDNS, name, return new Zone(id, description, displayText, DNS, domain, domainId, guestCIDRAddress, internalDNS, name,
networkType, status, VLAN, securityGroupsEnabled); networkType, VLAN, securityGroupsEnabled, allocationState, dhcpProvider, zoneToken);
} }
} }
@ -143,23 +154,28 @@ public class Zone implements Comparable<Zone> {
private String name; private String name;
@SerializedName("networktype") @SerializedName("networktype")
private NetworkType networkType; private NetworkType networkType;
private String status;
@SerializedName("vlan") @SerializedName("vlan")
private String VLAN; private String VLAN;
@SerializedName("securitygroupsenabled") @SerializedName("securitygroupsenabled")
private boolean securityGroupsEnabled; private boolean securityGroupsEnabled;
@SerializedName("allocationstate")
//TODO Change to enum?
private String allocationState;
@SerializedName("dhcpprovider")
private String dhcpProvider;
@SerializedName("zonetoken")
private String zoneToken;
/** /**
* present only for serializer * present only for serializer
*
*/ */
Zone() { Zone() {
} }
public Zone(long id, String description, String displayText, List<String> DNS, String domain, long domainId, public Zone(long id, String description, String displayText, List<String> DNS, String domain, long domainId,
String guestCIDRAddress, List<String> internalDNS, String name, NetworkType networkType, String status, String guestCIDRAddress, List<String> internalDNS, String name, NetworkType networkType,
String vLAN, boolean securityGroupsEnabled) { String vLAN, boolean securityGroupsEnabled, String allocationState, String dhcpProvider, String zoneToken) {
this.id = id; this.id = id;
this.description = description; this.description = description;
this.displayText = displayText; this.displayText = displayText;
@ -172,13 +188,14 @@ public class Zone implements Comparable<Zone> {
this.internalDNS2 = internalDNS.size() > 1 ? internalDNS.get(1) : null; this.internalDNS2 = internalDNS.size() > 1 ? internalDNS.get(1) : null;
this.name = name; this.name = name;
this.networkType = networkType; this.networkType = networkType;
this.status = status;
this.VLAN = vLAN; this.VLAN = vLAN;
this.securityGroupsEnabled = securityGroupsEnabled; this.securityGroupsEnabled = securityGroupsEnabled;
this.allocationState = allocationState;
this.dhcpProvider = dhcpProvider;
this.zoneToken = zoneToken;
} }
/** /**
*
* @return Zone id * @return Zone id
*/ */
public long getId() { public long getId() {
@ -186,7 +203,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return Zone description * @return Zone description
*/ */
public String getDescription() { public String getDescription() {
@ -194,7 +210,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the display text of the zone * @return the display text of the zone
*/ */
public String getDisplayText() { public String getDisplayText() {
@ -202,7 +217,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the external DNS for the Zone * @return the external DNS for the Zone
*/ */
public List<String> getDNS() { public List<String> getDNS() {
@ -215,7 +229,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return Domain name for the Vms in the zone * @return Domain name for the Vms in the zone
*/ */
public String getDomain() { public String getDomain() {
@ -223,7 +236,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the ID of the containing domain, null for public zones * @return the ID of the containing domain, null for public zones
*/ */
@Nullable @Nullable
@ -232,7 +244,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the guest CIDR address for the Zone * @return the guest CIDR address for the Zone
*/ */
public String getGuestCIDRAddress() { public String getGuestCIDRAddress() {
@ -240,7 +251,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the internal DNS for the Zone * @return the internal DNS for the Zone
*/ */
public List<String> getInternalDNS() { public List<String> getInternalDNS() {
@ -253,7 +263,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return Zone name * @return Zone name
*/ */
public String getName() { public String getName() {
@ -261,7 +270,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return the network type of the zone; can be Basic or Advanced * @return the network type of the zone; can be Basic or Advanced
*/ */
public NetworkType getNetworkType() { public NetworkType getNetworkType() {
@ -269,15 +277,6 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return
*/
public String getStatus() {
return status;
}
/**
*
* @return the vlan range of the zone * @return the vlan range of the zone
*/ */
public String getVLAN() { public String getVLAN() {
@ -285,13 +284,33 @@ public class Zone implements Comparable<Zone> {
} }
/** /**
*
* @return true if this zone has security groups enabled * @return true if this zone has security groups enabled
*/ */
public boolean isSecurityGroupsEnabled() { public boolean isSecurityGroupsEnabled() {
return securityGroupsEnabled; return securityGroupsEnabled;
} }
/**
* @return the allocation state of the cluster
*/
public String getAllocationState() {
return allocationState;
}
/**
* @return the dhcp Provider for the Zone
*/
public String getDhcpProvider() {
return dhcpProvider;
}
/**
* @return Zone Token
*/
public String getZoneToken() {
return zoneToken;
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
@ -308,6 +327,7 @@ public class Zone implements Comparable<Zone> {
result = prime * result + ((internalDNS1 == null) ? 0 : internalDNS1.hashCode()); result = prime * result + ((internalDNS1 == null) ? 0 : internalDNS1.hashCode());
result = prime * result + ((internalDNS2 == null) ? 0 : internalDNS2.hashCode()); result = prime * result + ((internalDNS2 == null) ? 0 : internalDNS2.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((allocationState == null) ? 0 : allocationState.hashCode());
result = prime * result + ((networkType == null) ? 0 : networkType.hashCode()); result = prime * result + ((networkType == null) ? 0 : networkType.hashCode());
result = prime * result + (securityGroupsEnabled ? 1231 : 1237); result = prime * result + (securityGroupsEnabled ? 1231 : 1237);
return result; return result;
@ -342,6 +362,11 @@ public class Zone implements Comparable<Zone> {
return false; return false;
} else if (!description.equals(other.description)) } else if (!description.equals(other.description))
return false; return false;
if (allocationState == null) {
if (other.allocationState != null)
return false;
} else if (!allocationState.equals(other.allocationState))
return false;
if (displayText == null) { if (displayText == null) {
if (other.displayText != null) if (other.displayText != null)
return false; return false;
@ -388,10 +413,25 @@ public class Zone implements Comparable<Zone> {
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + ", status=" + status + ", name=" + name + ", description=" + description + ", displayText=" return "Zone{" +
+ displayText + ", domain=" + domain + ", domainId=" + domainId + ", networkType=" + networkType "id=" + id +
+ ", guestCIDRAddress=" + guestCIDRAddress + ", VLAN=" + VLAN + ", DNS=" + getDNS() ", description='" + description + '\'' +
+ ", securityGroupsEnabled=" + isSecurityGroupsEnabled() + ", internalDNS=" + getInternalDNS() + "]"; ", displayText='" + displayText + '\'' +
", DNS1='" + DNS1 + '\'' +
", DNS2='" + DNS2 + '\'' +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", guestCIDRAddress='" + guestCIDRAddress + '\'' +
", internalDNS1='" + internalDNS1 + '\'' +
", internalDNS2='" + internalDNS2 + '\'' +
", name='" + name + '\'' +
", networkType=" + networkType +
", VLAN='" + VLAN + '\'' +
", securityGroupsEnabled=" + securityGroupsEnabled +
", allocationState='" + allocationState + '\'' +
", dhcpProvider='" + dhcpProvider + '\'' +
", zoneToken='" + zoneToken + '\'' +
'}';
} }
@Override @Override