Merge pull request #360 from danikov/vcloud-director-network

Issue 830: vCloud Network
This commit is contained in:
Adrian Cole 2012-02-08 21:44:05 -08:00
commit 5509b03afe
20 changed files with 1933 additions and 5 deletions

View File

@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
import com.google.inject.Provides;
@ -41,8 +42,14 @@ public interface VCloudDirectorAsyncClient {
Session getCurrentSession();
/**
* @return synchronous access to Org features
* @return asynchronous access to Org features
*/
@Delegate
OrgAsyncClient getOrgClient();
/**
* @return asynchronous access to Network features
*/
@Delegate
NetworkAsyncClient getNetworkClient();
}

View File

@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import com.google.inject.Provides;
@ -48,4 +49,10 @@ public interface VCloudDirectorClient {
*/
@Delegate
OrgClient getOrgClient();
/**
* @return synchronous access to Network features
*/
@Delegate
NetworkClient getNetworkClient();
}

View File

@ -42,4 +42,6 @@ public interface VCloudDirectorMediaType {
public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml";
public static final String ORG_NETWORK_XML = "application/vnd.vmware.vcloud.orgNetwork+xml";
}

View File

@ -42,6 +42,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.annotations.Login;
import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.NetworkClient;
import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.OrgClient;
import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword;
@ -72,6 +74,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(OrgClient.class, OrgAsyncClient.class)
.put(NetworkClient.class, NetworkAsyncClient.class)
.build();
public VCloudDirectorRestClientModule() {

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

@ -0,0 +1,74 @@
/**
* 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.features;
import java.net.URI;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @see NetworkClient
* @author danikov
*/
@RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface NetworkAsyncClient {
/**
* @see NeworkClient#getNetwork()
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam URI uri);
/**
* @see NeworkClient#getMetadata()
*/
@GET
@Path("/metadata/")
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam URI orgRef);
/**
* @see NeworkClient#getMetadataEntry()
*/
@GET
@Consumes
@JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam URI metaDataRef);
}

View File

@ -0,0 +1,61 @@
/**
* 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.features;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
/**
* Provides synchronous access to Network.
* <p/>
*
* @see NetworkAsyncClient
* @see <a href= "http://support.theenterprisecloud.com/kb/default.asp?id=984&Lang=1&SID=" />
* @author danikov
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface NetworkClient {
/**
* Retrieves a network.
*
* @return the network or null if not found
*/
OrgNetwork getNetwork(URI networkRef);
/**
* Retrieves an list of the network's metadata
*
* @return a list of metadata
*/
Metadata getMetadata(URI networkRef);
/**
* Retrieves a metadata entry
*
* @return the metadata entry, or null if not found
*/
MetadataEntry getMetadataEntry(URI metaDataRef);
}

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.features;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import org.jclouds.vcloud.director.v1_5.domain.IpAddresses;
import org.jclouds.vcloud.director.v1_5.domain.IpRange;
import org.jclouds.vcloud.director.v1_5.domain.IpRanges;
import org.jclouds.vcloud.director.v1_5.domain.IpScope;
import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test;
/**
* Allows us to test a client via its side effects.
*
* @author danikov
*/
@Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest")
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test
public void testWhenResponseIs2xxLoginReturnsValidNetwork() {
URI networkRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", networkRef),
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML));
OrgNetwork expected = OrgNetwork
.builder()
.name("internet01-Jclouds")
.id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c")
.type(VCloudDirectorMediaType.ORG_NETWORK_XML)
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.org+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
.build())
.link(Link.builder()
.rel("down")
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"))
.build())
.description("")
.configuration(NetworkConfiguration.builder()
.ipScope(IpScope.builder()
.isInherited(true)
.gateway("173.240.107.49")
.netmask("255.255.255.240")
.dns1("173.240.111.52")
.dns2("173.240.111.53")
.ipRanges(IpRanges.builder()
.ipRange(IpRange.builder()
.startAddress("173.240.107.50")
.endAddress("173.240.107.62")
.build())
.build())
.build())
.fenceMode("bridged")
.retainNetInfoAcrossDeployments(false)
.syslogServerSettings(SyslogServerSettings.builder().build())
.build())
.allowedExternalIpAddresses(IpAddresses.builder().build())
.build();
assertEquals(client.getNetworkClient().getNetwork(networkRef), expected);
}
@Test
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metaRef),
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"))
.link(Link.builder()
.rel("up")
.type("application/vnd.vmware.vcloud.network+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"))
.build())
.build();
assertEquals(client.getOrgClient().getMetadata(orgRef), expected);
}
@Test(enabled=false) // No metadata in exemplar xml...
public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() {
URI metadataRef = URI.create(
"https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metadataRef),
getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
MetadataEntry expected = MetadataEntry.builder()
.build();
assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected);
}
}

View File

@ -45,7 +45,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", URI.create("http://localhost/api/org/")),
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML));
getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML+";version=1.5"));
OrgList expected = OrgList.builder()
.org(Reference.builder()
@ -64,7 +64,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", orgRef),
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML));
getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML+";version=1.5"));
Org expected = Org
.builder()
@ -125,7 +125,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metaRef),
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML));
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML+";version=1.5"));
Metadata expected = Metadata.builder()
.type("application/vnd.vmware.vcloud.metadata+xml")
@ -146,7 +146,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", metadataRef),
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML));
getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML+";version=1.5"));
MetadataEntry expected = MetadataEntry.builder()
.build();

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Metadata xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.network+xml" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"/>
</Metadata>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1.5" name="internet01-Jclouds" id="urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c" type="application/vnd.vmware.vcloud.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"/>
<Description/>
<Configuration>
<IpScope>
<IsInherited>true</IsInherited>
<Gateway>173.240.107.49</Gateway>
<Netmask>255.255.255.240</Netmask>
<Dns1>173.240.111.52</Dns1>
<Dns2>173.240.111.53</Dns2>
<IpRanges>
<IpRange>
<StartAddress>173.240.107.50</StartAddress>
<EndAddress>173.240.107.62</EndAddress>
</IpRange>
</IpRanges>
</IpScope>
<FenceMode>bridged</FenceMode>
<RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
<SyslogServerSettings/>
</Configuration>
<AllowedExternalIpAddresses/>
</OrgNetwork>