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

This commit is contained in:
vijaykiran 2011-12-07 13:17:35 +01:00
parent 4b56039f3c
commit 2566c04c19
6 changed files with 378 additions and 97 deletions

View File

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

View File

@ -18,10 +18,13 @@
*/
package org.jclouds.cloudstack.domain;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class IPForwardingRule implements Comparable<IPForwardingRule> {
@ -40,6 +43,10 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
private String virtualMachineDisplayName;
public long virtualMachineId;
private String virtualMachineName;
private Set<String> CIDRs = ImmutableSet.of();
private int privateEndPort;
private int publicEndPort;
public int publicPort;
public Builder id(long id) {
this.id = id;
@ -91,9 +98,29 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
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() {
return new IPForwardingRule(id, IPAddress, IPAddressId, startPort, protocol, endPort, state,
virtualMachineDisplayName, virtualMachineId, virtualMachineName);
virtualMachineDisplayName, virtualMachineId, virtualMachineName, publicEndPort, publicPort, CIDRs, privateEndPort);
}
}
@ -114,6 +141,14 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
public long virtualMachineId;
@SerializedName("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
IPForwardingRule() {
@ -121,7 +156,8 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
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.IPAddress = iPAddress;
this.IPAddressId = iPAddressId;
@ -132,6 +168,11 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
this.virtualMachineDisplayName = virtualMachineDisplayName;
this.virtualMachineId = virtualMachineId;
this.virtualMachineName = virtualMachineName;
this.CIDRs = new HashSet<String>(CIDRs);
this.privateEndPort = privateEndPort;
this.publicEndPort = publicEndPort;
this.publicPort = publicPort;
}
@Override
@ -140,7 +181,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the ID of the ip forwarding rule
*/
public long getId() {
@ -148,7 +188,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the public ip address for the ip forwarding rule
*/
public String getIPAddress() {
@ -156,7 +195,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the public ip address id for the ip forwarding rule
*/
public long getIPAddressId() {
@ -164,7 +202,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the private port for the ip forwarding rule
*/
public int getStartPort() {
@ -172,7 +209,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the protocol of the ip forwarding rule
*/
public String getProtocol() {
@ -180,7 +216,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the public port for the ip forwarding rule
*/
public int getEndPort() {
@ -188,7 +223,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the state of the rule
*/
public String getState() {
@ -196,7 +230,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the VM display name for the ip forwarding rule
*/
public String getVirtualMachineDisplayName() {
@ -204,7 +237,6 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the VM ID for the ip forwarding rule
*/
public long getVirtualMachineId() {
@ -212,13 +244,40 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
/**
*
* @return the VM name for the ip forwarding rule
*/
public String getVirtualMachineName() {
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 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
public int hashCode() {
final int prime = 31;
@ -229,6 +288,9 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
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 + ((virtualMachineDisplayName == null) ? 0 : virtualMachineDisplayName.hashCode());
result = prime * result + (int) (virtualMachineId ^ (virtualMachineId >>> 32));
@ -254,6 +316,12 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
return false;
if (endPort != other.endPort)
return false;
if (publicPort != other.publicPort)
return false;
if (publicEndPort != other.publicEndPort)
return false;
if (privateEndPort != other.privateEndPort)
return false;
if (id != other.id)
return false;
if (protocol == null) {

View File

@ -20,16 +20,20 @@ package org.jclouds.cloudstack.domain;
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.collect.ImmutableSet;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
public static enum State {
ADD, ACTIVE, UNRECOGNIZED;
@Override
public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
@ -47,6 +51,7 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
public static enum Algorithm {
SOURCE, ROUNDROBIN, LEASTCONN, UNRECOGNIZED;
@Override
public String toString() {
return name().toLowerCase();
@ -79,6 +84,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
private long publicIPId;
private int publicPort;
private State state;
private Set<String> CIDRs = ImmutableSet.of();
private long zoneId;
public Builder id(long id) {
this.id = id;
@ -140,9 +147,19 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
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() {
return new LoadBalancerRule(id, account, algorithm, description, domain, domainId, name, privatePort,
publicIP, publicIPId, publicPort, state);
publicIP, publicIPId, publicPort, state, zoneId, CIDRs);
}
}
@ -163,6 +180,10 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
@SerializedName("publicport")
private int publicPort;
private State state;
@SerializedName("cidrlist")
private Set<String> CIDRs;
@SerializedName("zoneId")
private long zoneId;
// for deserializer
LoadBalancerRule() {
@ -170,7 +191,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
}
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.account = account;
this.algorithm = algorithm;
@ -269,11 +291,26 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
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
public int compareTo(LoadBalancerRule arg0) {
return new Long(id).compareTo(arg0.getId());
}
@Override
public int hashCode() {
final int prime = 31;
@ -289,6 +326,7 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
result = prime * result + ((publicIP == null) ? 0 : publicIP.hashCode());
result = prime * result + (int) (publicIPId ^ (publicIPId >>> 32));
result = prime * result + publicPort;
result = prime * result + (int) (zoneId ^ (zoneId >>> 32));
result = prime * result + ((state == null) ? 0 : state.hashCode());
return result;
}
@ -324,6 +362,8 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
return false;
if (domainId != other.domainId)
return false;
if (zoneId != other.zoneId)
return false;
if (id != other.id)
return false;
if (name == null) {
@ -353,7 +393,7 @@ public class LoadBalancerRule implements Comparable<LoadBalancerRule> {
@Override
public String toString() {
return "[account=" + account + ", algorithm=" + algorithm + ", description=" + description + ", domain=" + domain
+ ", domainId=" + domainId + ", id=" + id + ", name=" + name + ", privatePort=" + privatePort
+ ", domainId=" + domainId + ", zoneId=" + zoneId + ", id=" + id + ", name=" + name + ", privatePort=" + privatePort
+ ", publicIP=" + publicIP + ", publicIPId=" + publicIPId + ", publicPort=" + publicPort + ", state="
+ state + "]";
}

View File

@ -18,10 +18,7 @@
*/
package org.jclouds.cloudstack.domain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gson.annotations.SerializedName;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;
import java.net.URI;
@ -29,7 +26,12 @@ import java.util.List;
import java.util.Set;
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
@ -66,12 +68,27 @@ public class Network implements Comparable<Network> {
private TrafficType trafficType;
private long zoneId;
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) {
this.id = id;
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) {
this.broadcastDomainType = broadcastDomainType;
return this;
@ -197,15 +214,26 @@ public class Network implements Comparable<Network> {
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() {
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,
networkOfferingDisplayText, networkOfferingId, networkOfferingName, related, startIP, name, state,
guestIPType, VLAN, trafficType, zoneId, services);
guestIPType, VLAN, trafficType, zoneId, services, tags, securityGroupEnabled, account);
}
}
private long id;
private String account;
@SerializedName("broadcastdomaintype")
private String broadcastDomainType;
@SerializedName("broadcasturi")
@ -216,8 +244,9 @@ public class Network implements Comparable<Network> {
private String DNS1;
@SerializedName("dns2")
private String DNS2;
@SerializedName("networkdomain")
private String domain;
@SerializedName("domainid")
private long domainId;
@SerializedName("endip")
private String endIP;
private String gateway;
@ -253,6 +282,9 @@ public class Network implements Comparable<Network> {
@SerializedName("zoneid")
private long zoneId;
@SerializedName("service")
private String tags;
@SerializedName("securitygroupenabled")
private boolean securityGroupEnabled;
// so tests and serialization comes out expected
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,
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,
String networkOfferingDisplayText, long networkOfferingId, String networkOfferingName, long related,
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.broadcastDomainType = broadcastDomainType;
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.DNS2 = DNS.size() > 1 ? DNS.get(1) : null;
this.domain = domain;
this.domainId = domainId;
this.endIP = endIP;
this.gateway = gateway;
this.isDefault = isDefault;
@ -296,6 +330,9 @@ public class Network implements Comparable<Network> {
this.trafficType = trafficType;
this.zoneId = zoneId;
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() {
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
*/
@ -485,6 +536,20 @@ public class Network implements Comparable<Network> {
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
public int hashCode() {
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 + ((trafficType == null) ? 0 : trafficType.hashCode());
result = prime * result + (int) (zoneId ^ (zoneId >>> 32));
result = prime * result + ((tags == null) ? 0 : tags.hashCode());
result = prime * result + (int) (domainId ^ (domainId >>> 32));
return result;
}
@ -636,6 +703,13 @@ public class Network implements Comparable<Network> {
return false;
if (zoneId != other.zoneId)
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;
}
@ -645,11 +719,11 @@ public class Network implements Comparable<Network> {
+ guestIPType + ", trafficType=" + trafficType + ", DNS=" + getDNS() + ", VLAN=" + VLAN
+ ", startIP=" + startIP + ", endIP=" + endIP + ", netmask=" + netmask + ", gateway=" + gateway
+ ", broadcastDomainType=" + broadcastDomainType + ", broadcastURI=" + broadcastURI + ", services="
+ services + ", domain=" + domain + ", isDefault=" + isDefault + ", isShared="
+ services + ", domain=" + domain + ", domainId=" + domainId + ", isDefault=" + isDefault + ", isShared="
+ isShared + ", isSystem=" + isSystem + ", related=" + related + ", zoneId=" + zoneId + ", domain="
+ networkDomain + ", networkOfferingAvailability=" + networkOfferingAvailability
+ ", networkOfferingDisplayText=" + networkOfferingDisplayText + ", networkOfferingId=" + networkOfferingId
+ ", networkOfferingName=" + networkOfferingName + "]";
+ ", networkOfferingName=" + networkOfferingName + ", tags=" + getTags() + "]";
}
@Override

View File

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

View File

@ -20,15 +20,13 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import javax.annotation.Nullable;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.gson.annotations.SerializedName;
/**
*
* @author Adrian Cole
*/
public class Zone implements Comparable<Zone> {
@ -47,9 +45,11 @@ public class Zone implements Comparable<Zone> {
private List<String> internalDNS = ImmutableList.of();
private String name;
private NetworkType networkType;
private String status;
private String VLAN;
private boolean securityGroupsEnabled;
private String allocationState;
private String dhcpProvider;
private String zoneToken;
public Builder id(long id) {
this.id = id;
@ -101,11 +101,6 @@ public class Zone implements Comparable<Zone> {
return this;
}
public Builder status(String status) {
this.status = status;
return this;
}
public Builder VLAN(String VLAN) {
this.VLAN = VLAN;
return this;
@ -116,9 +111,25 @@ public class Zone implements Comparable<Zone> {
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() {
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;
@SerializedName("networktype")
private NetworkType networkType;
private String status;
@SerializedName("vlan")
private String VLAN;
@SerializedName("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
*
*/
Zone() {
}
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 vLAN, boolean securityGroupsEnabled) {
String guestCIDRAddress, List<String> internalDNS, String name, NetworkType networkType,
String vLAN, boolean securityGroupsEnabled, String allocationState, String dhcpProvider, String zoneToken) {
this.id = id;
this.description = description;
this.displayText = displayText;
@ -172,13 +188,14 @@ public class Zone implements Comparable<Zone> {
this.internalDNS2 = internalDNS.size() > 1 ? internalDNS.get(1) : null;
this.name = name;
this.networkType = networkType;
this.status = status;
this.VLAN = vLAN;
this.securityGroupsEnabled = securityGroupsEnabled;
this.allocationState = allocationState;
this.dhcpProvider = dhcpProvider;
this.zoneToken = zoneToken;
}
/**
*
* @return Zone id
*/
public long getId() {
@ -186,7 +203,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return Zone description
*/
public String getDescription() {
@ -194,7 +210,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return the display text of the zone
*/
public String getDisplayText() {
@ -202,7 +217,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return the external DNS for the Zone
*/
public List<String> getDNS() {
@ -215,7 +229,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return Domain name for the Vms in the zone
*/
public String getDomain() {
@ -223,7 +236,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return the ID of the containing domain, null for public zones
*/
@Nullable
@ -232,7 +244,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return the guest CIDR address for the Zone
*/
public String getGuestCIDRAddress() {
@ -240,7 +251,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return the internal DNS for the Zone
*/
public List<String> getInternalDNS() {
@ -253,7 +263,6 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return Zone name
*/
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
*/
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
*/
public String getVLAN() {
@ -285,13 +284,33 @@ public class Zone implements Comparable<Zone> {
}
/**
*
* @return true if this zone has security groups enabled
*/
public boolean isSecurityGroupsEnabled() {
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
public int hashCode() {
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 + ((internalDNS2 == null) ? 0 : internalDNS2.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 + (securityGroupsEnabled ? 1231 : 1237);
return result;
@ -342,6 +362,11 @@ public class Zone implements Comparable<Zone> {
return false;
} else if (!description.equals(other.description))
return false;
if (allocationState == null) {
if (other.allocationState != null)
return false;
} else if (!allocationState.equals(other.allocationState))
return false;
if (displayText == null) {
if (other.displayText != null)
return false;
@ -388,7 +413,7 @@ public class Zone implements Comparable<Zone> {
@Override
public String toString() {
return "[id=" + id + ", status=" + status + ", name=" + name + ", description=" + description + ", displayText="
return "[id=" + id + ", allocationState=" + allocationState + ", name=" + name + ", description=" + description + ", displayText="
+ displayText + ", domain=" + domain + ", domainId=" + domainId + ", networkType=" + networkType
+ ", guestCIDRAddress=" + guestCIDRAddress + ", VLAN=" + VLAN + ", DNS=" + getDNS()
+ ", securityGroupsEnabled=" + isSecurityGroupsEnabled() + ", internalDNS=" + getInternalDNS() + "]";