mirror of https://github.com/apache/jclouds.git
adminNetwork getNetwork w/tests
This commit is contained in:
parent
1c53a0402f
commit
5fdc6dd522
|
@ -193,6 +193,8 @@ public class VCloudDirectorMediaType {
|
|||
|
||||
public static final String TEXT_XML = "text/xml";
|
||||
|
||||
public static final String NETWORK_POOL = "application/vnd.vmware.admin.networkPool+xml";
|
||||
|
||||
/**
|
||||
* All acceptable media types.
|
||||
*/
|
||||
|
@ -216,8 +218,7 @@ public class VCloudDirectorMediaType {
|
|||
ADMIN_ORG_NETWORK, USER, ROLE, DEPLOY_VAPP_PARAMS, RECOMPOSE_VAPP_PARAMS,
|
||||
RELOCATE_VM_PARAMS, UNDEPLOY_VAPP_PARAMS, ADMIN_VDC, MEDIA_PARAMS,
|
||||
RUNTIME_INFO_SECTION, SCREEN_TICKET, VAPP_NETWORK,
|
||||
|
||||
TEXT_XML
|
||||
TEXT_XML, ADMIN_VDC, NETWORK_POOL
|
||||
);
|
||||
|
||||
// NOTE These lists must be updated whenever a new media type constant is added.
|
||||
|
|
|
@ -44,6 +44,8 @@ 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.AdminCatalogAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminNetworkAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminNetworkClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
|
||||
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* 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 javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Admin representation of external network.
|
||||
*
|
||||
*
|
||||
* <p>Java class for ExternalNetwork complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="ExternalNetwork">
|
||||
* <complexContent>
|
||||
* <extension base="{http://www.vmware.com/vcloud/v1.5}NetworkType">
|
||||
* <sequence>
|
||||
* <element name="ProviderInfo" type="{http://www.w3.org/2001/XMLSchema}string"/>
|
||||
* </sequence>
|
||||
* <anyAttribute processContents='lax' namespace='##other'/>
|
||||
* </extension>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "ExternalNetwork")
|
||||
@XmlType(propOrder = {
|
||||
"providerInfo"
|
||||
})
|
||||
public class ExternalNetwork extends Network {
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toNewBuilder() {
|
||||
return new ConcreteBuilder().fromExternalNetwork(this);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public EntityType.Builder<Network> toBuilder() {
|
||||
throw new UnsupportedOperationException("Use toNewBuilder() instead");
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Network.Builder<T> {
|
||||
private String providerInfo;
|
||||
|
||||
/**
|
||||
* @see ExternalNetwork#getProviderInfo()
|
||||
*/
|
||||
public T providerInfo(String providerInfo) {
|
||||
this.providerInfo = providerInfo;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ExternalNetwork build() {
|
||||
return new ExternalNetwork(this);
|
||||
}
|
||||
|
||||
public T fromExternalNetwork(ExternalNetwork in) {
|
||||
return fromNetworkType(in)
|
||||
.providerInfo(in.getProviderInfo());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private ExternalNetwork() {
|
||||
// For JAXB
|
||||
}
|
||||
|
||||
private ExternalNetwork(Builder<?> b) {
|
||||
super(b);
|
||||
providerInfo = b.providerInfo;
|
||||
}
|
||||
|
||||
@XmlElement(name = "ProviderInfo", required = true)
|
||||
protected String providerInfo;
|
||||
|
||||
/**
|
||||
* Gets the value of the providerInfo property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getProviderInfo() {
|
||||
return providerInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
ExternalNetwork that = ExternalNetwork.class.cast(o);
|
||||
return super.equals(that) && equal(providerInfo, that.providerInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), providerInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string()
|
||||
.add("providerInfo", providerInfo);
|
||||
}
|
||||
|
||||
}
|
|
@ -100,6 +100,7 @@ public class Link extends Reference {
|
|||
public static final String UPGRADE = "upgrade";
|
||||
public static final String UPLOAD_ALTERNATE = "upload:alternate";
|
||||
public static final String UPLOAD_DEFAULT = "upload:default";
|
||||
public static final String REPAIR = "repair";
|
||||
|
||||
/**
|
||||
* All acceptable {@link Link#getRel()} values.
|
||||
|
@ -117,7 +118,8 @@ public class Link extends Reference {
|
|||
REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET,
|
||||
SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER,
|
||||
TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP,
|
||||
UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT
|
||||
UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT,
|
||||
UPLOAD_DEFAULT, REPAIR
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,55 +21,43 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
|||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
@XmlRootElement(name = "NetworkType")
|
||||
public class NetworkType extends EntityType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromNetworkType(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends EntityType.Builder<B> {
|
||||
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
@XmlSeeAlso( {OrgNetwork.class, ExternalNetwork.class} )
|
||||
public abstract class Network extends EntityType {
|
||||
public abstract static class Builder<T extends Builder<T>> extends EntityType.Builder<T> {
|
||||
protected NetworkConfiguration networkConfiguration;
|
||||
|
||||
/**
|
||||
* @see NetworkType#getConfiguration()
|
||||
* @see Network#getConfiguration()
|
||||
*/
|
||||
public B configuration(NetworkConfiguration networkConfiguration) {
|
||||
public T configuration(NetworkConfiguration networkConfiguration) {
|
||||
this.networkConfiguration = networkConfiguration;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkType build() {
|
||||
return new NetworkType(this);
|
||||
}
|
||||
|
||||
public B fromNetworkType(NetworkType in) {
|
||||
public T fromNetworkType(Network in) {
|
||||
return fromEntityType(in).configuration(in.getConfiguration());
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkType(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.networkConfiguration = builder.networkConfiguration;
|
||||
|
||||
public Network(Builder<?> b) {
|
||||
super(b);
|
||||
networkConfiguration = b.networkConfiguration;
|
||||
}
|
||||
|
||||
protected NetworkType() {
|
||||
protected Network() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Network> T toSubType(Network clazz) {
|
||||
assert clazz instanceof Network;
|
||||
return (T)clazz;
|
||||
}
|
||||
|
||||
@XmlElement(name = "Configuration")
|
||||
private NetworkConfiguration networkConfiguration;
|
||||
|
@ -85,18 +73,17 @@ public class NetworkType extends EntityType {
|
|||
public boolean equals(Object o) {
|
||||
if (!super.equals(o))
|
||||
return false;
|
||||
NetworkType that = NetworkType.class.cast(o);
|
||||
Network that = Network.class.cast(o);
|
||||
return super.equals(that) && equal(networkConfiguration, that.networkConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), networkConfiguration);
|
||||
return super.hashCode() + Objects.hashCode(networkConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("configuration", networkConfiguration);
|
||||
}
|
||||
|
||||
}
|
|
@ -27,28 +27,24 @@ import com.google.common.base.Objects;
|
|||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
@XmlRootElement(name = "OrgNetwork")
|
||||
public class OrgNetwork extends NetworkType {
|
||||
|
||||
public class OrgNetwork extends Network {
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromOrgNetwork(this);
|
||||
return new ConcreteBuilder().fromOrgNetwork(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static abstract class Builder<B extends Builder<B>> extends NetworkType.Builder<B> {
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> extends Network.Builder<T> {
|
||||
private Reference networkPool;
|
||||
private IpAddresses allowedExternalIpAddresses;
|
||||
|
||||
/**
|
||||
* @see OrgNetwork#getNetworkPool()
|
||||
*/
|
||||
public B networkPool(Reference networkPool) {
|
||||
public T networkPool(Reference networkPool) {
|
||||
this.networkPool = networkPool;
|
||||
return self();
|
||||
}
|
||||
|
@ -56,7 +52,7 @@ public class OrgNetwork extends NetworkType {
|
|||
/**
|
||||
* @see OrgNetwork#getAllowedExternalIpAddresses()
|
||||
*/
|
||||
public B allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
|
||||
public T allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
|
||||
this.allowedExternalIpAddresses = allowedExternalIpAddresses;
|
||||
return self();
|
||||
}
|
||||
|
@ -65,22 +61,29 @@ public class OrgNetwork extends NetworkType {
|
|||
public OrgNetwork build() {
|
||||
return new OrgNetwork(this);
|
||||
}
|
||||
|
||||
public B fromOrgNetwork(OrgNetwork in) {
|
||||
return fromNetworkType(in).configuration(in.getConfiguration())
|
||||
|
||||
public T fromOrgNetwork(OrgNetwork in) {
|
||||
return fromEntityType(in).configuration(in.getConfiguration())
|
||||
.networkPool(in.getNetworkPool())
|
||||
.allowedExternalIpAddresses(in.getAllowedExternalIpAddresses());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected OrgNetwork() {
|
||||
// For JAXB
|
||||
}
|
||||
|
||||
protected OrgNetwork(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.networkPool = builder.networkPool;
|
||||
this.allowedExternalIpAddresses = builder.allowedExternalIpAddresses;
|
||||
private OrgNetwork(Builder<?> b) {
|
||||
super(b);
|
||||
networkPool = b.networkPool;
|
||||
allowedExternalIpAddresses = b.allowedExternalIpAddresses;
|
||||
}
|
||||
|
||||
@XmlElement(name = "NetworkPool")
|
||||
|
@ -107,18 +110,22 @@ public class OrgNetwork extends NetworkType {
|
|||
if (!super.equals(o))
|
||||
return false;
|
||||
OrgNetwork that = OrgNetwork.class.cast(o);
|
||||
return super.equals(that) && equal(networkPool, that.networkPool) &&
|
||||
return super.equals(that) &&
|
||||
equal(networkPool, that.networkPool) &&
|
||||
equal(allowedExternalIpAddresses, that.allowedExternalIpAddresses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), networkPool, allowedExternalIpAddresses);
|
||||
return Objects.hashCode(super.hashCode(),
|
||||
networkPool,
|
||||
allowedExternalIpAddresses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("networkPool", networkPool)
|
||||
return super.string()
|
||||
.add("networkPool", networkPool)
|
||||
.add("allowedExternalIpAddresses", allowedExternalIpAddresses);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,4 +232,4 @@ public class Reference {
|
|||
.href(URI.create(getHref().toASCIIString().replace(endpoint, endpoint+"/admin")))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class ResourceType {
|
|||
@XmlAttribute
|
||||
private String type;
|
||||
@XmlElement(name = "Link")
|
||||
private Set<Link> links;
|
||||
private Set<Link> links = Sets.newLinkedHashSet();
|
||||
|
||||
protected ResourceType(Builder<?> builder) {
|
||||
this.href = builder.href;
|
||||
|
@ -136,7 +136,7 @@ public class ResourceType {
|
|||
public ResourceType(URI href, String type, @Nullable Set<Link> links) {
|
||||
this.href = href;
|
||||
this.type = type;
|
||||
// nullable so that jaxb wont persist empty collections
|
||||
// nullable so that jaxb wont persist empty collections?
|
||||
this.links = links != null && links.isEmpty() ? null : links;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
|
||||
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.vcloud.director.v1_5.domain.ExternalNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @see AdminNetworkClient
|
||||
|
@ -28,7 +40,15 @@ import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
|||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
public interface AdminNetworkAsyncClient extends NetworkAsyncClient {
|
||||
|
||||
// GET /admin/network/{id}
|
||||
/**
|
||||
* @see NetworkClient#getNetwork(URI)
|
||||
*/
|
||||
@GET
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
@Override
|
||||
ListenableFuture<ExternalNetwork> getNetwork(@EndpointParam URI networkRef);
|
||||
|
||||
// PUT /admin/network/{id}
|
||||
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
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.Network;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to admin {@link Network} objects.
|
||||
|
@ -31,7 +33,20 @@ import org.jclouds.concurrent.Timeout;
|
|||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
public interface AdminNetworkClient extends NetworkClient {
|
||||
|
||||
// GET /admin/network/{id}
|
||||
/**
|
||||
* Gets admin representation of network. This operation could return admin
|
||||
* representation of organization network or external network. vApp networks
|
||||
* do not have admin representation.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/network/{id}
|
||||
* </pre>
|
||||
*
|
||||
* @param catalogUri the reference for the catalog
|
||||
* @return a catalog
|
||||
*/
|
||||
@Override
|
||||
Network getNetwork(URI networkRef);
|
||||
|
||||
// PUT /admin/network/{id}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jclouds.rest.annotations.ExceptionParser;
|
|||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public interface NetworkAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam URI networkUri);
|
||||
ListenableFuture<? extends Network> getNetwork(@EndpointParam URI networkUri);
|
||||
|
||||
/**
|
||||
* @return asynchronous access to {@link Metadata.Readable} features
|
||||
|
|
|
@ -24,7 +24,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.Metadata;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Network.
|
||||
|
@ -42,7 +42,7 @@ public interface NetworkClient {
|
|||
*
|
||||
* @return the network or null if not found
|
||||
*/
|
||||
OrgNetwork getNetwork(URI networkUri);
|
||||
Network getNetwork(URI networkUri);
|
||||
|
||||
/**
|
||||
* @return synchronous access to {@link Metadata.Readable} features
|
||||
|
|
|
@ -360,7 +360,7 @@ public class Checks {
|
|||
"The Image type of a Media must be one of the allowed list");
|
||||
}
|
||||
|
||||
public static void checkNetworkType(NetworkType network) {
|
||||
public static void checkNetworkType(Network network) {
|
||||
// Check optional fields
|
||||
NetworkConfiguration config = network.getConfiguration();
|
||||
if (config != null) {
|
||||
|
@ -1365,6 +1365,29 @@ public class Checks {
|
|||
private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) {
|
||||
// TODO Could do more assertions...
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ResouorceAllocatoinSettingData"));
|
||||
|
||||
public static void checkOrgNetwork(OrgNetwork network) {
|
||||
// optional
|
||||
ReferenceType<?> networkPoolRef = network.getNetworkPool();
|
||||
if (networkPoolRef != null) {
|
||||
Checks.checkReferenceType(networkPoolRef);
|
||||
}
|
||||
IpAddresses allowedExternalIpAddresses = network.getAllowedExternalIpAddresses();
|
||||
if (allowedExternalIpAddresses != null) {
|
||||
Checks.checkIpAddresses(allowedExternalIpAddresses);
|
||||
}
|
||||
|
||||
// parent type
|
||||
checkNetworkType(network);
|
||||
}
|
||||
|
||||
public static void checkExternalNetwork(ExternalNetwork network) {
|
||||
// required
|
||||
assertNotNull(network.getProviderInfo(), String.format(OBJ_FIELD_REQ,
|
||||
"ExternalNetwork", "providerInfo"));
|
||||
|
||||
// parent type
|
||||
checkNetworkType(network);
|
||||
}
|
||||
|
||||
public static void checkAdminVdc(AdminVdc vdc) {
|
||||
|
|
|
@ -18,20 +18,86 @@
|
|||
*/
|
||||
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.Link;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Test the {@link GroupClient} by observing its side effects.
|
||||
*
|
||||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "unit", "user", "adminNetwork"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
|
||||
@Test(groups = { "unit", "admin", "adminNetwork"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
|
||||
public class AdminNetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||
|
||||
// GET /admin/network/{id}
|
||||
Reference networkRef = Reference.builder()
|
||||
.href(URI.create(endpoint+"/admin/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"))
|
||||
.build();
|
||||
|
||||
@Test
|
||||
public void testGetNetworkWithOrgNetwork() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/network/b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/admin/orgNetwork.xml", VCloudDirectorMediaType.ORG_NETWORK)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
OrgNetwork expected = orgNetwork();
|
||||
|
||||
assertEquals(client.getAdminNetworkClient().getNetwork(networkRef.getHref()), expected);
|
||||
}
|
||||
|
||||
// PUT /admin/network/{id}
|
||||
|
||||
// POST /admin/network/{id}/action/reset
|
||||
|
||||
public final OrgNetwork orgNetwork() {
|
||||
return NetworkClientExpectTest.orgNetwork().toNewBuilder()
|
||||
.href(toAdminUri(NetworkClientExpectTest.orgNetwork().getHref()))
|
||||
.links(ImmutableSet.of(
|
||||
Link.builder()
|
||||
.rel("alternate")
|
||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
||||
.build(),
|
||||
Link.builder()
|
||||
.rel("edit")
|
||||
.type("application/vnd.vmware.admin.orgNetwork+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
||||
.build(),
|
||||
Link.builder()
|
||||
.rel("up")
|
||||
.type("application/vnd.vmware.admin.organization+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||
.build(),
|
||||
Link.builder()
|
||||
.rel("repair")
|
||||
.type("application/vnd.vmware.admin.orgNetwork+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/action/reset"))
|
||||
.build(),
|
||||
Link.builder()
|
||||
.rel("down")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/metadata"))
|
||||
.build()))
|
||||
.networkPool(Reference.builder()
|
||||
.type("application/vnd.vmware.admin.networkPool+xml")
|
||||
.name("vcdni01")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/extension/networkPool/e86bfdb5-b3e0-4ece-9125-e764ac64c95c"))
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,36 +18,62 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ExternalNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests live behavior of {@link AdminCatalogClient}.
|
||||
* Tests live behavior of {@link AdminNetworkClient}.
|
||||
*
|
||||
* @author danikov
|
||||
*/
|
||||
@Test(groups = { "live", "admin", "group" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
||||
@Test(groups = { "live", "admin", "network" }, singleThreaded = true, testName = "AdminNetworkLiveTest")
|
||||
public class AdminNetworkLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||
|
||||
public static final String GROUP = "admin group";
|
||||
public static final String NETWORK = "AdminNetwork";
|
||||
|
||||
/*
|
||||
* Convenience references to API clients.
|
||||
*/
|
||||
|
||||
private AdminNetworkClient networkClient;
|
||||
|
||||
/*
|
||||
* Shared state between dependant tests.
|
||||
*/
|
||||
|
||||
Reference networkRef;
|
||||
Network network;
|
||||
|
||||
@BeforeClass(inheritGroups = true)
|
||||
public void setupRequiredClients() {
|
||||
protected void setupRequiredClients() {
|
||||
networkClient = context.getApi().getAdminNetworkClient();
|
||||
networkRef = Reference.builder().href(networkURI).build().toAdminReference(endpoint);
|
||||
}
|
||||
|
||||
// GET /admin/network/{id}
|
||||
@Test(testName = "GET /admin/network/{id}")
|
||||
public void testGetNetwork() {
|
||||
assertNotNull(networkRef, String.format(REF_REQ_LIVE, NETWORK));
|
||||
network = networkClient.getNetwork(networkRef.getHref());
|
||||
|
||||
if(network instanceof ExternalNetwork) {
|
||||
Checks.checkExternalNetwork(Network.<ExternalNetwork>toSubType(network));
|
||||
} else if (network instanceof OrgNetwork) {
|
||||
Checks.checkOrgNetwork(Network.<OrgNetwork>toSubType(network));
|
||||
} else {
|
||||
fail(String.format(REQUIRED_VALUE_OBJECT_FMT, ".class", NETWORK,
|
||||
network.getClass(),"ExternalNetwork,. OrgNetwork"));
|
||||
}
|
||||
}
|
||||
|
||||
// PUT /admin/network/{id}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.net.URI;
|
|||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.DhcpService;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.IpAddresses;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.IpRange;
|
||||
|
@ -34,7 +35,10 @@ 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.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkFeatures;
|
||||
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;
|
||||
|
@ -51,30 +55,40 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||
|
||||
@Test
|
||||
public void testWhenResponseIs2xxLoginReturnsValidNetwork() {
|
||||
URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c");
|
||||
public void testGetNetwork() {
|
||||
URI networkUri = URI.create(endpoint + "/network/f3ba8256-6f48-4512-aad6-600e85b4dc38");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c"),
|
||||
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK));
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/f3ba8256-6f48-4512-aad6-600e85b4dc38")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
OrgNetwork expected = orgNetwork();
|
||||
assertEquals(client.getNetworkClient().getNetwork(networkUri), expected);
|
||||
assertEquals(Network.<OrgNetwork>toSubType(client.getNetworkClient().getNetwork(networkUri)), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWhenResponseIs400ForInvalidNetworkId() {
|
||||
public void testGetNetworkWithInvalidId() {
|
||||
URI networkUri = URI.create(endpoint + "/network/NOTAUUID");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/network/NOTAUUID"),
|
||||
getStandardPayloadResponse(400, "/network/error400.xml", VCloudDirectorMediaType.ERROR));
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/NOTAUUID")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/error400.xml", VCloudDirectorMediaType.ERROR)
|
||||
.httpResponseBuilder().statusCode(400).build());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.network.")
|
||||
.majorErrorCode(400)
|
||||
.minorErrorCode("BAD_REQUEST")
|
||||
.build();
|
||||
.message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.network.")
|
||||
.majorErrorCode(400)
|
||||
.minorErrorCode("BAD_REQUEST")
|
||||
.build();
|
||||
|
||||
try {
|
||||
client.getNetworkClient().getNetwork(networkUri);
|
||||
|
@ -87,18 +101,23 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWhenResponseIs403ForCatalogIdUsedAsNetworkId() {
|
||||
public void testGetNetworkWithCatalogId() {
|
||||
URI networkUri = URI.create(endpoint + "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"),
|
||||
getStandardPayloadResponse(403, "/network/error403-catalog.xml", VCloudDirectorMediaType.ERROR));
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/error403-catalog.xml", VCloudDirectorMediaType.ERROR)
|
||||
.httpResponseBuilder().statusCode(403).build());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("This operation is denied.")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
.message("This operation is denied.")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
|
||||
try {
|
||||
client.getNetworkClient().getNetwork(networkUri);
|
||||
|
@ -111,18 +130,23 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWhenResponseIs403ForFakeNetworkId() {
|
||||
public void testGetNetworkWithFakeId() {
|
||||
URI networkUri = URI.create(endpoint + "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"),
|
||||
getStandardPayloadResponse(403, "/network/error403-fake.xml", VCloudDirectorMediaType.ERROR));
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/error403-fake.xml", VCloudDirectorMediaType.ERROR)
|
||||
.httpResponseBuilder().statusCode(403).build());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("This operation is denied.")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
.message("This operation is denied.")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
|
||||
try {
|
||||
client.getNetworkClient().getNetwork(networkUri);
|
||||
|
@ -135,83 +159,105 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() {
|
||||
public void testGetMetadata() {
|
||||
URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/metadata.xml", VCloudDirectorMediaType.METADATA)
|
||||
.httpResponseBuilder().build());
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/metadata.xml", VCloudDirectorMediaType.METADATA)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
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())
|
||||
.entries(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
||||
.build();
|
||||
.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())
|
||||
.entries(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
||||
.build();
|
||||
|
||||
assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkUri), expected);
|
||||
}
|
||||
|
||||
@Test(enabled=false) // No metadata in exemplar xml...
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
||||
@Test
|
||||
public void testGetMetadataValue() {
|
||||
URI networkUri = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY"),
|
||||
getStandardPayloadResponse("/network/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/network/metadataValue.xml", VCloudDirectorMediaType.METADATA_ENTRY)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
MetadataEntry expected = MetadataEntry.builder()
|
||||
.entry("key", "value")
|
||||
.build();
|
||||
MetadataValue expected = MetadataValue.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/key"))
|
||||
.link(Link.builder()
|
||||
.rel("up")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"))
|
||||
.build())
|
||||
.value("value")
|
||||
.build();
|
||||
|
||||
assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkUri, "KEY"), expected);
|
||||
}
|
||||
|
||||
|
||||
public static OrgNetwork orgNetwork() {
|
||||
return OrgNetwork.builder()
|
||||
.name("internet01-Jclouds")
|
||||
.id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c")
|
||||
.type(VCloudDirectorMediaType.ORG_NETWORK)
|
||||
.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"))
|
||||
.name("ilsolation01-Jclouds")
|
||||
.id("urn:vcloud:network:f3ba8256-6f48-4512-aad6-600e85b4dc38")
|
||||
.type("application/vnd.vmware.vcloud.orgNetwork+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
|
||||
.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/f3ba8256-6f48-4512-aad6-600e85b4dc38/metadata"))
|
||||
.build())
|
||||
.description("")
|
||||
.configuration(NetworkConfiguration.builder()
|
||||
.ipScope(IpScope.builder()
|
||||
.isInherited(false)
|
||||
.gateway("192.168.1.1")
|
||||
.netmask("255.255.255.0")
|
||||
.dns1("173.240.111.52")
|
||||
.dns2("173.240.111.53")
|
||||
.ipRanges(IpRanges.builder()
|
||||
.ipRange(IpRange.builder()
|
||||
.startAddress("192.168.1.100")
|
||||
.endAddress("192.168.1.199")
|
||||
.build())
|
||||
.build())
|
||||
.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())
|
||||
.fenceMode("isolated")
|
||||
.retainNetInfoAcrossDeployments(false)
|
||||
.features(NetworkFeatures.builder()
|
||||
.service(DhcpService.builder()
|
||||
.enabled(false)
|
||||
.defaultLeaseTime(3600)
|
||||
.maxLeaseTime(7200)
|
||||
.ipRange(IpRange.builder()
|
||||
.startAddress("192.168.1.2")
|
||||
.endAddress("192.168.1.99")
|
||||
.build())
|
||||
.build())
|
||||
.fenceMode("bridged")
|
||||
.retainNetInfoAcrossDeployments(false)
|
||||
.syslogServerSettings(SyslogServerSettings.builder().build())
|
||||
.build())
|
||||
.allowedExternalIpAddresses(IpAddresses.builder().build())
|
||||
.build();
|
||||
.syslogServerSettings(SyslogServerSettings.builder().build())
|
||||
.build())
|
||||
.allowedExternalIpAddresses(IpAddresses.builder().build())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
|
|||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
@ -30,10 +31,10 @@ import static org.testng.Assert.assertNotNull;
|
|||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.IpAddresses;
|
||||
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.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||
|
@ -62,29 +63,20 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void setupRequiredClients() {
|
||||
networkClient = context.getApi().getNetworkClient();
|
||||
}
|
||||
|
||||
|
||||
@Test(testName = "GET /network/{id}")
|
||||
public void testGetNetwork() {
|
||||
// required for testing
|
||||
assertNotNull(networkURI, String.format(REF_REQ_LIVE, NETWORK));
|
||||
|
||||
OrgNetwork network = networkClient.getNetwork(networkURI);
|
||||
Network abstractNetwork = networkClient.getNetwork(networkURI);
|
||||
assertTrue(abstractNetwork instanceof OrgNetwork, String.format(REQUIRED_VALUE_OBJECT_FMT,
|
||||
".class", NETWORK, abstractNetwork.getClass(),"OrgNetwork"));
|
||||
OrgNetwork network = Network.toSubType(abstractNetwork);
|
||||
assertNotNull(network, String.format(OBJ_REQ_LIVE, NETWORK));
|
||||
assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing");
|
||||
|
||||
// parent type
|
||||
Checks.checkNetworkType(network);
|
||||
|
||||
// optional
|
||||
Reference networkPoolRef = network.getNetworkPool();
|
||||
if (networkPoolRef != null) {
|
||||
Checks.checkReferenceType(networkPoolRef);
|
||||
}
|
||||
|
||||
IpAddresses allowedExternalIpAddresses = network.getAllowedExternalIpAddresses();
|
||||
if (allowedExternalIpAddresses != null) {
|
||||
Checks.checkIpAddresses(allowedExternalIpAddresses);
|
||||
}
|
||||
Checks.checkOrgNetwork(network);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /network/{id}/metadata")
|
||||
|
|
|
@ -85,7 +85,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
|||
}
|
||||
|
||||
// NOTE Implement as required to populate xxxClient fields, or NOP
|
||||
public abstract void setupRequiredClients() throws Exception;
|
||||
protected abstract void setupRequiredClients() throws Exception;
|
||||
|
||||
public Predicate<Task> retryTaskSuccess;
|
||||
public Predicate<Task> retryTaskSuccessLong;
|
||||
|
@ -104,7 +104,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
|||
protected Session session;
|
||||
|
||||
@BeforeClass(groups = { "live" })
|
||||
public void setupContext() throws Exception {
|
||||
protected void setupContext() throws Exception {
|
||||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.jclouds.http.HttpResponse;
|
|||
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
@ -241,4 +243,12 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
|||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
public URI toAdminUri(ReferenceType<?> ref) {
|
||||
return toAdminUri(ref.getHref());
|
||||
}
|
||||
|
||||
public URI toAdminUri(URI uri) {
|
||||
return Reference.builder().href(uri).build().toAdminReference(endpoint).getHref();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1.5" name="ilsolation01-Jclouds" id="urn:vcloud:network:f3ba8256-6f48-4512-aad6-600e85b4dc38" type="application/vnd.vmware.vcloud.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38" 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="alternate" type="application/vnd.vmware.vcloud.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"/>
|
||||
<Link rel="edit" type="application/vnd.vmware.admin.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"/>
|
||||
<Link rel="up" type="application/vnd.vmware.admin.organization+xml" href="https://vcloudbeta.bluelock.com/api/admin/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||
<Link rel="repair" type="application/vnd.vmware.admin.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/action/reset"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/admin/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/metadata"/>
|
||||
<Description/>
|
||||
<Configuration>
|
||||
<IpScope>
|
||||
<IsInherited>false</IsInherited>
|
||||
<Gateway>192.168.1.1</Gateway>
|
||||
<Netmask>255.255.255.0</Netmask>
|
||||
<Dns1>173.240.111.52</Dns1>
|
||||
<Dns2>173.240.111.53</Dns2>
|
||||
<IpRanges>
|
||||
<IpRange>
|
||||
<StartAddress>192.168.1.100</StartAddress>
|
||||
<EndAddress>192.168.1.199</EndAddress>
|
||||
</IpRange>
|
||||
</IpRanges>
|
||||
</IpScope>
|
||||
<FenceMode>isolated</FenceMode>
|
||||
<RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
|
||||
<Features>
|
||||
<DhcpService>
|
||||
<IsEnabled>false</IsEnabled>
|
||||
<DefaultLeaseTime>3600</DefaultLeaseTime>
|
||||
<MaxLeaseTime>7200</MaxLeaseTime>
|
||||
<IpRange>
|
||||
<StartAddress>192.168.1.2</StartAddress>
|
||||
<EndAddress>192.168.1.99</EndAddress>
|
||||
</IpRange>
|
||||
</DhcpService>
|
||||
</Features>
|
||||
<SyslogServerSettings/>
|
||||
</Configuration>
|
||||
<NetworkPool type="application/vnd.vmware.admin.networkPool+xml" name="vcdni01" href="https://vcloudbeta.bluelock.com/api/admin/extension/networkPool/e86bfdb5-b3e0-4ece-9125-e764ac64c95c"/>
|
||||
<AllowedExternalIpAddresses/>
|
||||
</OrgNetwork>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MetadataValue xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/key" 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.metadata+xml" href="https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata"/>
|
||||
<Value>value</Value>
|
||||
</MetadataValue>
|
|
@ -1,25 +1,36 @@
|
|||
<?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">
|
||||
<OrgNetwork xmlns="http://www.vmware.com/vcloud/v1.5" name="ilsolation01-Jclouds" id="urn:vcloud:network:f3ba8256-6f48-4512-aad6-600e85b4dc38" type="application/vnd.vmware.vcloud.orgNetwork+xml" href="https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38" 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"/>
|
||||
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/metadata"/>
|
||||
<Description/>
|
||||
<Configuration>
|
||||
<IpScope>
|
||||
<IsInherited>true</IsInherited>
|
||||
<Gateway>173.240.107.49</Gateway>
|
||||
<Netmask>255.255.255.240</Netmask>
|
||||
<IsInherited>false</IsInherited>
|
||||
<Gateway>192.168.1.1</Gateway>
|
||||
<Netmask>255.255.255.0</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>
|
||||
<StartAddress>192.168.1.100</StartAddress>
|
||||
<EndAddress>192.168.1.199</EndAddress>
|
||||
</IpRange>
|
||||
</IpRanges>
|
||||
</IpScope>
|
||||
<FenceMode>bridged</FenceMode>
|
||||
<FenceMode>isolated</FenceMode>
|
||||
<RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
|
||||
<Features>
|
||||
<DhcpService>
|
||||
<IsEnabled>false</IsEnabled>
|
||||
<DefaultLeaseTime>3600</DefaultLeaseTime>
|
||||
<MaxLeaseTime>7200</MaxLeaseTime>
|
||||
<IpRange>
|
||||
<StartAddress>192.168.1.2</StartAddress>
|
||||
<EndAddress>192.168.1.99</EndAddress>
|
||||
</IpRange>
|
||||
</DhcpService>
|
||||
</Features>
|
||||
<SyslogServerSettings/>
|
||||
</Configuration>
|
||||
<AllowedExternalIpAddresses/>
|
||||
</OrgNetwork>
|
||||
</OrgNetwork>
|
Loading…
Reference in New Issue