network domain objects

This commit is contained in:
danikov 2012-02-09 02:10:57 +00:00
parent e5eea32e69
commit 60e39a4a99
13 changed files with 1612 additions and 184 deletions

View File

@ -0,0 +1,112 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* A list of IpAddresses.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "IpAddresses")
public class IpAddresses {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromIpAddresses(this);
}
public static class Builder {
private Set<String> ipAddresses = Sets.newLinkedHashSet();
/**
* @see IpAddresses#getIpAddresses()
*/
public Builder ipAddresses(Set<String> ipAddresses) {
this.ipAddresses = Sets.newLinkedHashSet(checkNotNull(ipAddresses, "ipAddresses"));
return this;
}
/**
* @see IpAddresses#getIpAddresses()
*/
public Builder ipAddress(String ipAddress) {
ipAddresses.add(checkNotNull(ipAddress, "ipAddress"));
return this;
}
public IpAddresses build() {
return new IpAddresses(ipAddresses);
}
public Builder fromIpAddresses(IpAddresses in) {
return ipAddresses(in.getIpAddresses());
}
}
private IpAddresses() {
// For JAXB and builder use
}
private IpAddresses(Set<String> orgs) {
this.ipAddresses = ImmutableSet.copyOf(orgs);
}
@XmlElement(namespace = NS, name = "IpAddress")
private Set<String> ipAddresses = Sets.newLinkedHashSet();
public Set<String> getIpAddresses() {
return ImmutableSet.copyOf(ipAddresses);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
IpAddresses that = IpAddresses.class.cast(o);
return equal(ipAddresses, that.ipAddresses);
}
@Override
public int hashCode() {
return Objects.hashCode(ipAddresses);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("ipAddresses", ipAddresses).toString();
}
}

View File

@ -0,0 +1,125 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Represents a range of IP addresses, start and end inclusive.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "IpRange")
public class IpRange {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromIpRange(this);
}
public static class Builder {
private String startAddress;
private String endAddress;
/**
* @see IpRange#getStartAddress()
*/
public Builder startAddress(String startAddress) {
this.startAddress = startAddress;
return this;
}
/**
* @see IpRange#getEndAddress()
*/
public Builder endAddress(String endAddress) {
this.endAddress = endAddress;
return this;
}
public IpRange build() {
return new IpRange(startAddress, endAddress);
}
public Builder fromIpRange(IpRange in) {
return startAddress(in.getStartAddress()).endAddress(in.getEndAddress());
}
}
private IpRange() {
// For JAXB and builder use
}
private IpRange(String startAddress, String endAddress) {
this.startAddress = startAddress;
this.endAddress = endAddress;
}
@XmlElement(namespace = NS, name = "StartAddress")
private String startAddress;
@XmlElement(namespace = NS, name = "EndAddress")
private String endAddress;
/**
* @return Start address of the IP range.
*/
public String getStartAddress() {
return startAddress;
}
/**
* @return End address of the IP range.
*/
public String getEndAddress() {
return endAddress;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
IpRange that = IpRange.class.cast(o);
return equal(startAddress, that.startAddress) && equal(endAddress, that.endAddress);
}
@Override
public int hashCode() {
return Objects.hashCode(startAddress, endAddress);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("startAddress", startAddress)
.add("endAddress", endAddress).toString();
}
}

View File

@ -0,0 +1,112 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* A list of IpAddresses.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "IpRanges")
public class IpRanges {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromIpRanges(this);
}
public static class Builder {
private Set<IpRange> ipRanges = Sets.newLinkedHashSet();
/**
* @see IpRanges#getIpRanges()
*/
public Builder ipRanges(Set<IpRange> ipRanges) {
this.ipRanges = Sets.newLinkedHashSet(checkNotNull(ipRanges, "ipRanges"));
return this;
}
/**
* @see IpRanges#getIpRanges()
*/
public Builder ipRange(IpRange ipRange) {
ipRanges.add(checkNotNull(ipRange, "ipRange"));
return this;
}
public IpRanges build() {
return new IpRanges(ipRanges);
}
public Builder fromIpRanges(IpRanges in) {
return ipRanges(in.getIpRanges());
}
}
private IpRanges() {
// For JAXB and builder use
}
private IpRanges(Set<IpRange> ipRanges) {
this.ipRanges = ImmutableSet.copyOf(ipRanges);
}
@XmlElement(namespace = NS, name = "IpRange")
private Set<IpRange> ipRanges = Sets.newLinkedHashSet();
public Set<IpRange> getIpRanges() {
return ImmutableSet.copyOf(ipRanges);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
IpRanges that = IpRanges.class.cast(o);
return equal(ipRanges, that.ipRanges);
}
@Override
public int hashCode() {
return Objects.hashCode(ipRanges);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("ipRanges", ipRanges).toString();
}
}

View File

@ -0,0 +1,289 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Specify network settings like gateway, network mask, DNS servers, IP ranges, etc.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "IpScope")
@XmlAccessorType(XmlAccessType.FIELD)
public class IpScope {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromIpScope(this);
}
public static class Builder {
private boolean isInherited;
private String gateway;
private String netmask;
private String dns1;
private String dns2;
private String dnsSuffix;
private IpRanges ipRanges;
private IpAddresses allocatedIpAddresses;
/**
* @see IpScope#isInherited()
*/
public Builder isInherited(boolean isInherited) {
this.isInherited = isInherited;
return this;
}
/**
* @see IpScope#getGateway()
*/
public Builder gateway(String gateway) {
this.gateway = gateway;
return this;
}
/**
* @see IpScope#getNetmask()
*/
public Builder netmask(String netmask) {
this.netmask = netmask;
return this;
}
/**
* @see IpScope#getDns1()
*/
public Builder dns1(String dns1) {
this.dns1 = dns1;
return this;
}
/**
* @see IpScope#getDns2()
*/
public Builder dns2(String dns2) {
this.dns2 = dns2;
return this;
}
/**
* @see IpScope#getDnsSuffix()
*/
public Builder dnsSuffix(String dnsSuffix) {
this.dnsSuffix = dnsSuffix;
return this;
}
/**
* @see IpScope#getIpRanges()
*/
public Builder ipRanges(IpRanges ipRanges) {
this.ipRanges = ipRanges;
return this;
}
/**
* @see IpScope#getAllocatedIpAddresses()
*/
public Builder allocatedIpAddresses(IpAddresses allocatedIpAddresses) {
this.allocatedIpAddresses = allocatedIpAddresses;
return this;
}
public IpScope build() {
IpScope ipScope = new IpScope(isInherited);
ipScope.setGateway(gateway);
ipScope.setNetmask(netmask);
ipScope.setDns1(dns1);
ipScope.setDns2(dns2);
ipScope.setDnsSuffix(dnsSuffix);
ipScope.setIpRanges(ipRanges);
ipScope.setAllocatedIpAddresses(allocatedIpAddresses);
return ipScope;
}
public Builder fromIpScope(IpScope in) {
return isInherited(in.isInherited()).gateway(in.getGateway())
.netmask(in.getNetmask())
.dns1(in.getDns1())
.dns2(in.getDns2())
.dnsSuffix(in.getDnsSuffix())
.ipRanges(in.getIpRanges())
.allocatedIpAddresses(in.getAllocatedIpAddresses());
}
}
private IpScope() {
// For JAXB and builder use
}
private IpScope(boolean isInherited) {
this.isInherited = isInherited;
}
@XmlElement(namespace = NS, name = "IsInherited")
private boolean isInherited;
@XmlElement(namespace = NS, name = "Gateway")
private String gateway;
@XmlElement(namespace = NS, name = "Netmask")
private String netmask;
@XmlElement(namespace = NS, name = "Dns1")
private String dns1;
@XmlElement(namespace = NS, name = "Dns2")
private String dns2;
@XmlElement(namespace = NS, name = "DnsSuffix")
private String dnsSuffix;
@XmlElement(namespace = NS, name = "IpRanges")
private IpRanges ipRanges;
@XmlElement(namespace = NS, name = "AllocatedIpAddresses")
private IpAddresses allocatedIpAddresses;
/**
* @return True if the IP scope is inherit from parent network.
*/
public boolean isInherited() {
return isInherited;
}
/**
* @return Gateway of the network..
*/
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
/**
* @return Network mask.
*/
public String getNetmask() {
return netmask;
}
public void setNetmask(String netmask) {
this.netmask = netmask;
}
/**
* @return Primary DNS server.
*/
public String getDns1() {
return dns1;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
/**
* @return Secondary DNS server.
*/
public String getDns2() {
return dns2;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
/**
* @return DNS suffix.
*/
public String getDnsSuffix() {
return dnsSuffix;
}
public void setDnsSuffix(String dnsSuffix) {
this.dnsSuffix = dnsSuffix;
}
/**
* @return IP ranges used for static pool allocation in the network.
*/
public IpRanges getIpRanges() {
return ipRanges;
}
public void setIpRanges(IpRanges ipRanges) {
this.ipRanges = ipRanges;
}
/**
* @return Read-only list of allocated IP addresses in the network.
*/
public IpAddresses getAllocatedIpAddresses() {
return allocatedIpAddresses;
}
public void setAllocatedIpAddresses(IpAddresses allocatedIpAddresses) {
this.allocatedIpAddresses = allocatedIpAddresses;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
IpScope that = IpScope.class.cast(o);
return equal(isInherited, that.isInherited) && equal(gateway, that.gateway) &&
equal(netmask, that.netmask) &&
equal(dns1, that.dns1) &&
equal(dns2, that.dns2) &&
equal(dnsSuffix, that.dnsSuffix) &&
equal(ipRanges, that.ipRanges) &&
equal(allocatedIpAddresses, that.allocatedIpAddresses);
}
@Override
public int hashCode() {
return Objects.hashCode(isInherited, gateway, netmask, dns1, dns2, dnsSuffix,
ipRanges, allocatedIpAddresses);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("isInherited", isInherited)
.add("gateway", gateway)
.add("netmask", netmask)
.add("dns1", dns1)
.add("dns2", dns2)
.add("dnsSuffix", dnsSuffix)
.add("ipRanges", ipRanges)
.add("allocatedIpAddresses", allocatedIpAddresses).toString();
}
}

View File

@ -0,0 +1,265 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Returns a network configuration
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "NetworkConfiguration")
@XmlAccessorType(XmlAccessType.FIELD)
public class NetworkConfiguration{
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromConfiguration(this);
}
public static class Builder {
private IpScope ipScope;
private ReferenceType<?> parentNetwork;
private String fenceMode;
private boolean retainNetInfoAcrossDeployments;
private NetworkFeatures features;
private SyslogServerSettings syslogServerSettings;
private RouterInfo routerInfo;
/**
* @see NetworkConfiguration#getIpScope()
*/
public Builder ipScope(IpScope ipScope) {
this.ipScope = ipScope;
return this;
}
/**
* @see NetworkConfiguration#getParentNetwork()
*/
public Builder parentNetwork(ReferenceType<?> parentNetwork) {
this.parentNetwork = parentNetwork;
return this;
}
/**
* @see NetworkConfiguration#getFenceMode()
*/
public Builder fenceMode(String fenceMode) {
this.fenceMode = fenceMode;
return this;
}
/**
* @see NetworkConfiguration#getRetainNetInfoAcrossDeployments()
*/
public Builder retainNetInfoAcrossDeployments(boolean retainNetInfoAcrossDeployments) {
this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments;
return this;
}
/**
* @see NetworkConfiguration#getNetworkFeatures()
*/
public Builder features(NetworkFeatures features) {
this.features = features;
return this;
}
/**
* @see NetworkConfiguration#getSyslogServerSettings()
*/
public Builder syslogServerSettings(SyslogServerSettings syslogServerSettings) {
this.syslogServerSettings = syslogServerSettings;
return this;
}
/**
* @see NetworkConfiguration#getRouterInfo()
*/
public Builder routerInfo(RouterInfo routerInfo) {
this.routerInfo = routerInfo;
return this;
}
public NetworkConfiguration build() {
NetworkConfiguration networkConfiguration = new NetworkConfiguration(fenceMode);
networkConfiguration.setIpScope(ipScope);
networkConfiguration.setParentNetwork(parentNetwork);
networkConfiguration.setRetainNetInfoAcrossDeployments(retainNetInfoAcrossDeployments);
networkConfiguration.setNetworkFeatures(features);
networkConfiguration.setSyslogServerSettings(syslogServerSettings);
networkConfiguration.setRouterInfo(routerInfo);
return networkConfiguration;
}
public Builder fromConfiguration(NetworkConfiguration in) {
return ipScope(in.getIpScope()).parentNetwork(in.getParentNetwork()).fenceMode(in.getFenceMode())
.retainNetInfoAcrossDeployments(in.getRetainNetInfoAcrossDeployments())
.features(in.getNetworkFeatures())
.syslogServerSettings(in.getSyslogServerSettings())
.routerInfo(in.getRouterInfo());
}
}
private NetworkConfiguration() {
// For JAXB and builder use
}
private NetworkConfiguration(String fenceMode) {
this.fenceMode = fenceMode;
}
@XmlElement(namespace = NS, name = "IpScope")
private IpScope ipScope;
@XmlElement(namespace = NS, name = "ParentNetwork")
private ReferenceType<?> parentNetwork;
@XmlElement(namespace = NS, name = "FenceMode")
private String fenceMode;
@XmlElement(namespace = NS, name = "RetainNetInfoAcrossDeployments")
private boolean retainNetInfoAcrossDeployments = false;
@XmlElement(namespace = NS, name = "Features")
private NetworkFeatures features;
@XmlElement(namespace = NS, name = "SyslogServerSettings")
private SyslogServerSettings syslogServerSettings;
@XmlElement(namespace = NS, name = "RouterInfo")
private RouterInfo routerInfo;
/**
* @return IP level configuration items such as gateway, dns, subnet,
* IP address pool to be used for allocation. Note that the pool of IP addresses
* needs to fall within the subnet/mask of the IpScope.
*/
public IpScope getIpScope() {
return ipScope;
}
public void setIpScope(IpScope ipScope) {
this.ipScope = ipScope;
}
/**
* @return reference to parent network.
*/
public ReferenceType<?> getParentNetwork() {
return parentNetwork;
}
public void setParentNetwork(ReferenceType<?> parentNetwork) {
this.parentNetwork = parentNetwork;
}
/**
* @return Isolation type of the network. If ParentNetwork is specified, this property
* controls connectivity to the parent. One of: bridged (connected directly to the ParentNetwork),
* isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a
* NAT service)
*/
public String getFenceMode() {
return fenceMode;
}
/**
* @return whether the network resources such as IP/MAC of router will be retained
* across deployments. Default is false.
*/
public boolean getRetainNetInfoAcrossDeployments() {
return retainNetInfoAcrossDeployments;
}
public void setRetainNetInfoAcrossDeployments(boolean retainNetInfoAcrossDeployments) {
this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments;
}
/**
* @return Network features like DHCP, firewall and NAT rules.
*/
public NetworkFeatures getNetworkFeatures() {
return features;
}
public void setNetworkFeatures(NetworkFeatures features) {
this.features = features;
}
/**
* @return Syslog server settings for the network.
*/
public SyslogServerSettings getSyslogServerSettings() {
return syslogServerSettings;
}
public void setSyslogServerSettings(SyslogServerSettings syslogServerSettings) {
this.syslogServerSettings = syslogServerSettings;
}
/**
* @return router information
*/
public RouterInfo getRouterInfo() {
return routerInfo;
}
public void setRouterInfo(RouterInfo routerInfo) {
this.routerInfo = routerInfo;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
NetworkConfiguration that = NetworkConfiguration.class.cast(o);
return equal(ipScope, that.ipScope) && equal(parentNetwork, that.parentNetwork) &&
equal(fenceMode, that.fenceMode) &&
equal(retainNetInfoAcrossDeployments, that.retainNetInfoAcrossDeployments) &&
equal(features, that.features) &&
equal(syslogServerSettings, that.syslogServerSettings) &&
equal(routerInfo, that.routerInfo);
}
@Override
public int hashCode() {
return Objects.hashCode(ipScope, parentNetwork, fenceMode, retainNetInfoAcrossDeployments,
features, syslogServerSettings, routerInfo);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("ipScope", ipScope).add("parentNetwork", parentNetwork)
.add("fenceMode", fenceMode)
.add("retainNetInfoAcrossDeployments", retainNetInfoAcrossDeployments)
.add("features", features)
.add("syslogServerSettings", syslogServerSettings)
.add("routerInfo", routerInfo).toString();
}
}

View File

@ -0,0 +1,119 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
/**
* Represents features of a network.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "Features")
public class NetworkFeatures {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromNetworkFeatures(this);
}
public static class Builder {
private Set<NetworkService> services = Sets.newLinkedHashSet();
/**
* @see NetworkFeatures#getNetworkServices()
*/
public Builder services(Set<NetworkService> services) {
this.services = Sets.newLinkedHashSet(checkNotNull(services, "services"));
return this;
}
/**
* @see NetworkFeatures#getNetworkServices()
*/
public Builder service(NetworkService service) {
services.add(checkNotNull(service, "service"));
return this;
}
public NetworkFeatures build() {
NetworkFeatures networkFeatures = new NetworkFeatures();
networkFeatures.setNetworkServices(services);
return networkFeatures;
}
public Builder fromNetworkFeatures(NetworkFeatures in) {
return services(in.getNetworkServices());
}
}
private NetworkFeatures() {
// For JAXB and builder use
}
@XmlElement(namespace = NS, name = "NetworkService")
private Set<NetworkService> services = Sets.newLinkedHashSet();
/**
* @return a Network service. May be any of DhcpService, NatService, IpsecVpnService,
* DhcpService, or StaticRoutingService.
*/
public Set<NetworkService> getNetworkServices() {
return ImmutableSet.copyOf(services);
}
public void setNetworkServices(Set<NetworkService> services) {
this.services = Sets.newLinkedHashSet(checkNotNull(services, "services"));
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
NetworkFeatures that = NetworkFeatures.class.cast(o);
return equal(services, that.services);
}
@Override
public int hashCode() {
return Objects.hashCode(services);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("services", services).toString();
}
}

View File

@ -0,0 +1,105 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Represents a network service
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "NetworkService")
public class NetworkService {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromNetworkService(this);
}
public static class Builder {
private boolean isEnabled;
/**
* @see NetworkService#isEnabled()
*/
public Builder enabled(boolean isEnabled) {
this.isEnabled = isEnabled;
return this;
}
public NetworkService build() {
NetworkService networkService = new NetworkService();
networkService.setEnabled(isEnabled);
return networkService;
}
public Builder fromNetworkService(NetworkService in) {
return enabled(in.isEnabled());
}
}
private NetworkService() {
// For JAXB and builder use
}
@XmlElement(namespace = NS, name = "IsEnabled")
private boolean isEnabled;
/**
* @return Enable or disable the service using this flag
*/
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
NetworkService that = NetworkService.class.cast(o);
return equal(isEnabled, that.isEnabled);
}
@Override
public int hashCode() {
return Objects.hashCode(isEnabled);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("isEnabled", isEnabled).toString();
}
}

View File

@ -0,0 +1,248 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless(Link.builder().required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.ovf.Network;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
@XmlRootElement(namespace = NS, name = "OrgNetwork")
public class OrgNetwork extends EntityType<OrgNetwork> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
@Override
public Builder toBuilder() {
return new Builder().fromOrgNetwork(this);
}
public static class Builder extends EntityType.Builder<OrgNetwork> {
private NetworkConfiguration networkConfiguration;
private ReferenceType<?> networkPool;
private IpAddresses allowedExternalIpAddresses;
/**
* @see Network#getConfiguration()
*/
public Builder configuration(NetworkConfiguration networkConfiguration) {
this.networkConfiguration = networkConfiguration;
return this;
}
/**
* @see Network#getNetworkPool()
*/
public Builder networkPool(ReferenceType<?> networkPool) {
this.networkPool = networkPool;
return this;
}
/**
* @see Network#getAllowedExternalIpAddresses()
*/
public Builder allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
return this;
}
@Override
public OrgNetwork build() {
OrgNetwork network = new OrgNetwork(href, name);
network.setConfiguration(networkConfiguration);
network.setNetworkPool(networkPool);
network.setAllowedExternalIpAddresses(allowedExternalIpAddresses);
network.setDescription(description);
network.setId(id);
network.setType(type);
network.setLinks(links);
network.setTasksInProgress(tasksInProgress);
return network;
}
/**
* @see EntityType#getName()
*/
@Override
public Builder name(String name) {
this.name = name;
return this;
}
/**
* @see EntityType#getDescription()
*/
@Override
public Builder description(String description) {
this.description = description;
return this;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
@Override
public Builder fromEntityType(EntityType<OrgNetwork> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromOrgNetwork(OrgNetwork in) {
return fromEntityType(in).configuration(in.getConfiguration())
.networkPool(in.getNetworkPool())
.allowedExternalIpAddresses(in.getAllowedExternalIpAddresses());
}
}
private OrgNetwork() {
// For JAXB and builder use
}
private OrgNetwork(URI href, String name) {
super(href, name);
}
@XmlElement(namespace = NS, name = "Configuration")
private NetworkConfiguration networkConfiguration;
@XmlElement(namespace = NS, name = "NetworkPool")
private ReferenceType<?> networkPool;
@XmlElement(namespace = NS, name = "AllowedExternalIpAddresses")
private IpAddresses allowedExternalIpAddresses;
/**
* @return optional configuration
*/
public NetworkConfiguration getConfiguration() {
return networkConfiguration;
}
public void setConfiguration(NetworkConfiguration networkConfiguration) {
this.networkConfiguration = networkConfiguration;
}
/**
* @return optional network pool
*/
public ReferenceType<?> getNetworkPool() {
return networkPool;
}
public void setNetworkPool(ReferenceType<?> networkPool) {
this.networkPool = networkPool;
}
/**
* @return optional network pool
*/
public IpAddresses getAllowedExternalIpAddresses() {
return allowedExternalIpAddresses;
}
public void setAllowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
}
@Override
public boolean equals(Object o) {
if (!super.equals(o))
return false;
OrgNetwork that = OrgNetwork.class.cast(o);
return super.equals(that) && equal(networkConfiguration, that.networkConfiguration) &&
equal(networkPool, that.networkPool) &&
equal(allowedExternalIpAddresses, that.allowedExternalIpAddresses);
}
@Override
public int hashCode() {
return super.hashCode() + Objects.hashCode(networkConfiguration,
networkPool, allowedExternalIpAddresses);
}
@Override
public ToStringHelper string() {
return super.string().add("configuration", networkConfiguration).add("networkPool", networkPool)
.add("allowedExternalIpAddresses", allowedExternalIpAddresses);
}
}

View File

@ -0,0 +1,104 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Specifies router information.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "RouterInfo")
public class RouterInfo {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromRouterInfo(this);
}
public static class Builder {
private String externalIp;
/**
* @see RouterInfo#getExternalIp()
*/
public Builder externalIp(String externalIp) {
this.externalIp = externalIp;
return this;
}
public RouterInfo build() {
return new RouterInfo(externalIp);
}
public Builder fromRouterInfo(RouterInfo in) {
return externalIp(in.getExternalIp());
}
}
private RouterInfo() {
// For JAXB and builder use
}
private RouterInfo(String externalIp) {
this.externalIp = externalIp;
}
@XmlElement(namespace = NS, name = "ExternalIp")
private String externalIp;
/**
* @return the external IP of the router. Applicable for NAT Routed / Fenced networks only.
*/
public String getExternalIp() {
return externalIp;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
RouterInfo that = RouterInfo.class.cast(o);
return equal(externalIp, that.externalIp);
}
@Override
public int hashCode() {
return Objects.hashCode(externalIp, externalIp);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("externalIp", externalIp).toString();
}
}

View File

@ -0,0 +1,133 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
*(Link.builder().regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless(Link.builder().required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Objects;
/**
* Syslog server settings. If logging is configured for firewall rules, the logs
* will be directed to these syslog servers.
*
* @author danikov
*/
@XmlRootElement(namespace = NS, name = "SyslogServerSettings")
@XmlAccessorType(XmlAccessType.FIELD)
public class SyslogServerSettings {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromSyslogServerSettings(this);
}
public static class Builder {
private String syslogServerIp1;
private String syslogServerIp2;
/**
* @see SyslogServerSettings#getSyslogServerIp1()
*/
public Builder syslogServerIp1(String syslogServerIp1) {
this.syslogServerIp1 = syslogServerIp1;
return this;
}
/**
* @see SyslogServerSettings#getSyslogServerIp2()
*/
public Builder syslogServerIp2(String syslogServerIp2) {
this.syslogServerIp2 = syslogServerIp2;
return this;
}
public SyslogServerSettings build() {
SyslogServerSettings syslogServerSettings = new SyslogServerSettings();
syslogServerSettings.syslogServerIp1 = syslogServerIp1;
syslogServerSettings.syslogServerIp2 = syslogServerIp2;
return syslogServerSettings;
}
public Builder fromSyslogServerSettings(SyslogServerSettings in) {
return syslogServerIp1(in.getSyslogServerIp1()).syslogServerIp2(in.getSyslogServerIp2());
}
}
private SyslogServerSettings() {
// For JAXB and builder use
}
@XmlElement(namespace = NS, name = "SyslogServerIp1")
private String syslogServerIp1;
@XmlElement(namespace = NS, name = "SyslogServerIp2")
private String syslogServerIp2;
/**
* @return Primary syslog server.
*/
public String getSyslogServerIp1() {
return syslogServerIp1;
}
public void setSyslogServerIp1(String syslogServerIp1) {
this.syslogServerIp1 = syslogServerIp1;
}
/**
* @return Secondary syslog server.
*/
public String getSyslogServerIp2() {
return syslogServerIp2;
}
public void setSyslogServerIp2(String syslogServerIp2) {
this.syslogServerIp2 = syslogServerIp2;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
SyslogServerSettings that = SyslogServerSettings.class.cast(o);
return equal(syslogServerIp1, that.syslogServerIp1) && equal(syslogServerIp2, that.syslogServerIp1);
}
@Override
public int hashCode() {
return Objects.hashCode(syslogServerIp1, syslogServerIp2);
}
@Override
public String toString() {
return Objects.toStringHelper("").add("syslogServerIp1", syslogServerIp1)
.add("syslogServerIp1", syslogServerIp2).toString();
}
}

View File

@ -1,5 +0,0 @@
package org.jclouds.vcloud.director.v1_5.domain;
public class IpScope {
}

View File

@ -1,5 +0,0 @@
package org.jclouds.vcloud.director.v1_5.domain;
public class NetworkConfiguration{
}

View File

@ -1,174 +0,0 @@
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import org.jclouds.vcloud.director.v1_5.domain.Org.Builder;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
public class OrgNetwork extends EntityType<OrgNetwork> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
@Override
public Builder toBuilder() {
return new Builder().fromOrgNetwork(this);
}
public static class Builder extends EntityType.Builder<OrgNetwork> {
private boolean allowedExternalIpAddresses;
/**
* @see Network#getAllowedExternalIpAddresses()
*/
public Builder allowedExternalIpAddresses(boolean ExternalIpAddresses) {
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
return this;
}
@Override
public OrgNetwork build() {
Org org = new OrgNetwork(href, name);
org.setNetworkPool(network);
org.setDescription(description);
org.setId(id);
org.setType(type);
org.setLinks(links);
org.setTasksInProgress(tasksInProgress);
return org;
}
/**
* @see EntityType#getName()
*/
@Override
public Builder name(String name) {
this.name = name;
return this;
}
/**
* @see EntityType#getDescription()
*/
@Override
public Builder description(String description) {
this.description = description;
return this;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
@Override
public Builder fromEntityType(EntityType<OrgNetwork> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromOrgNetwork(OrgNetwork in) {
return fromEntityType(in).fullName(in.getFullName());
}
}
private OrgNetwork() {
// For JAXB and builder use
}
private OrgNetwork(URI href, String name, String fullName) {
super(href, name);
this.fullName = fullName;
}
@XmlElement(namespace = NS, name = "FullName")
private String fullName;
/**
*
* @return fullName of the org
*/
public String getFullName() {
return fullName;
}
@Override
public boolean equals(Object o) {
if (!super.equals(o))
return false;
Org that = Org.class.cast(o);
return super.equals(that) && equal(fullName, that.fullName);
}
@Override
public int hashCode() {
return super.hashCode() + Objects.hashCode(fullName);
}
@Override
public ToStringHelper string() {
return super.string().add("fullName", fullName);
}
}