adminNetwork getNetwork w/tests

This commit is contained in:
danikov 2012-03-14 16:52:11 +00:00
parent 1c53a0402f
commit 5fdc6dd522
22 changed files with 595 additions and 193 deletions

View File

@ -193,6 +193,8 @@ public class VCloudDirectorMediaType {
public static final String TEXT_XML = "text/xml"; public static final String TEXT_XML = "text/xml";
public static final String NETWORK_POOL = "application/vnd.vmware.admin.networkPool+xml";
/** /**
* All acceptable media types. * All acceptable media types.
*/ */
@ -216,8 +218,7 @@ public class VCloudDirectorMediaType {
ADMIN_ORG_NETWORK, USER, ROLE, DEPLOY_VAPP_PARAMS, RECOMPOSE_VAPP_PARAMS, ADMIN_ORG_NETWORK, USER, ROLE, DEPLOY_VAPP_PARAMS, RECOMPOSE_VAPP_PARAMS,
RELOCATE_VM_PARAMS, UNDEPLOY_VAPP_PARAMS, ADMIN_VDC, MEDIA_PARAMS, RELOCATE_VM_PARAMS, UNDEPLOY_VAPP_PARAMS, ADMIN_VDC, MEDIA_PARAMS,
RUNTIME_INFO_SECTION, SCREEN_TICKET, VAPP_NETWORK, RUNTIME_INFO_SECTION, SCREEN_TICKET, VAPP_NETWORK,
TEXT_XML, ADMIN_VDC, NETWORK_POOL
TEXT_XML
); );
// NOTE These lists must be updated whenever a new media type constant is added. // NOTE These lists must be updated whenever a new media type constant is added.

View File

@ -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.domain.SessionWithToken;
import org.jclouds.vcloud.director.v1_5.features.AdminCatalogAsyncClient; 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.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.AdminOrgAsyncClient;
import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient; import org.jclouds.vcloud.director.v1_5.features.AdminOrgClient;
import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient; import org.jclouds.vcloud.director.v1_5.features.AdminVdcAsyncClient;

View File

@ -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>
* &lt;complexType name="ExternalNetwork">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}NetworkType">
* &lt;sequence>
* &lt;element name="ProviderInfo" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/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);
}
}

View File

@ -100,6 +100,7 @@ public class Link extends Reference {
public static final String UPGRADE = "upgrade"; public static final String UPGRADE = "upgrade";
public static final String UPLOAD_ALTERNATE = "upload:alternate"; public static final String UPLOAD_ALTERNATE = "upload:alternate";
public static final String UPLOAD_DEFAULT = "upload:default"; public static final String UPLOAD_DEFAULT = "upload:default";
public static final String REPAIR = "repair";
/** /**
* All acceptable {@link Link#getRel()} values. * All acceptable {@link Link#getRel()} values.
@ -117,7 +118,8 @@ public class Link extends Reference {
REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET, REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET,
SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER, SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER,
TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP, 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
); );
} }

View File

@ -21,56 +21,44 @@ package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlElement; 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;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
@XmlRootElement(name = "NetworkType") @XmlSeeAlso( {OrgNetwork.class, ExternalNetwork.class} )
public class NetworkType extends EntityType { public abstract class Network extends EntityType {
public abstract static class Builder<T extends Builder<T>> extends EntityType.Builder<T> {
public static Builder<?> builder() { protected NetworkConfiguration networkConfiguration;
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;
/** /**
* @see NetworkType#getConfiguration() * @see Network#getConfiguration()
*/ */
public B configuration(NetworkConfiguration networkConfiguration) { public T configuration(NetworkConfiguration networkConfiguration) {
this.networkConfiguration = networkConfiguration; this.networkConfiguration = networkConfiguration;
return self(); return self();
} }
@Override public T fromNetworkType(Network in) {
public NetworkType build() {
return new NetworkType(this);
}
public B fromNetworkType(NetworkType in) {
return fromEntityType(in).configuration(in.getConfiguration()); return fromEntityType(in).configuration(in.getConfiguration());
} }
} }
public NetworkType(Builder<?> builder) { public Network(Builder<?> b) {
super(builder); super(b);
this.networkConfiguration = builder.networkConfiguration; networkConfiguration = b.networkConfiguration;
} }
protected NetworkType() { protected Network() {
// for JAXB // for JAXB
} }
@SuppressWarnings("unchecked")
public static <T extends Network> T toSubType(Network clazz) {
assert clazz instanceof Network;
return (T)clazz;
}
@XmlElement(name = "Configuration") @XmlElement(name = "Configuration")
private NetworkConfiguration networkConfiguration; private NetworkConfiguration networkConfiguration;
@ -85,18 +73,17 @@ public class NetworkType extends EntityType {
public boolean equals(Object o) { public boolean equals(Object o) {
if (!super.equals(o)) if (!super.equals(o))
return false; return false;
NetworkType that = NetworkType.class.cast(o); Network that = Network.class.cast(o);
return super.equals(that) && equal(networkConfiguration, that.networkConfiguration); return super.equals(that) && equal(networkConfiguration, that.networkConfiguration);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), networkConfiguration); return super.hashCode() + Objects.hashCode(networkConfiguration);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string().add("configuration", networkConfiguration); return super.string().add("configuration", networkConfiguration);
} }
} }

View File

@ -27,28 +27,24 @@ import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
@XmlRootElement(name = "OrgNetwork") @XmlRootElement(name = "OrgNetwork")
public class OrgNetwork extends NetworkType { public class OrgNetwork extends Network {
public static Builder<?> builder() { public static Builder<?> builder() {
return new ConcreteBuilder(); return new ConcreteBuilder();
} }
@Override
public Builder<?> toBuilder() { public Builder<?> toBuilder() {
return builder().fromOrgNetwork(this); return new ConcreteBuilder().fromOrgNetwork(this);
} }
private static class ConcreteBuilder extends Builder<ConcreteBuilder> { public static abstract class Builder<T extends Builder<T>> extends Network.Builder<T> {
}
public static abstract class Builder<B extends Builder<B>> extends NetworkType.Builder<B> {
private Reference networkPool; private Reference networkPool;
private IpAddresses allowedExternalIpAddresses; private IpAddresses allowedExternalIpAddresses;
/** /**
* @see OrgNetwork#getNetworkPool() * @see OrgNetwork#getNetworkPool()
*/ */
public B networkPool(Reference networkPool) { public T networkPool(Reference networkPool) {
this.networkPool = networkPool; this.networkPool = networkPool;
return self(); return self();
} }
@ -56,7 +52,7 @@ public class OrgNetwork extends NetworkType {
/** /**
* @see OrgNetwork#getAllowedExternalIpAddresses() * @see OrgNetwork#getAllowedExternalIpAddresses()
*/ */
public B allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) { public T allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) {
this.allowedExternalIpAddresses = allowedExternalIpAddresses; this.allowedExternalIpAddresses = allowedExternalIpAddresses;
return self(); return self();
} }
@ -66,21 +62,28 @@ public class OrgNetwork extends NetworkType {
return new OrgNetwork(this); return new OrgNetwork(this);
} }
public B fromOrgNetwork(OrgNetwork in) { public T fromOrgNetwork(OrgNetwork in) {
return fromNetworkType(in).configuration(in.getConfiguration()) return fromEntityType(in).configuration(in.getConfiguration())
.networkPool(in.getNetworkPool()) .networkPool(in.getNetworkPool())
.allowedExternalIpAddresses(in.getAllowedExternalIpAddresses()); .allowedExternalIpAddresses(in.getAllowedExternalIpAddresses());
} }
} }
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
@Override
protected ConcreteBuilder self() {
return this;
}
}
protected OrgNetwork() { protected OrgNetwork() {
// For JAXB // For JAXB
} }
protected OrgNetwork(Builder<?> builder) { private OrgNetwork(Builder<?> b) {
super(builder); super(b);
this.networkPool = builder.networkPool; networkPool = b.networkPool;
this.allowedExternalIpAddresses = builder.allowedExternalIpAddresses; allowedExternalIpAddresses = b.allowedExternalIpAddresses;
} }
@XmlElement(name = "NetworkPool") @XmlElement(name = "NetworkPool")
@ -107,18 +110,22 @@ public class OrgNetwork extends NetworkType {
if (!super.equals(o)) if (!super.equals(o))
return false; return false;
OrgNetwork that = OrgNetwork.class.cast(o); 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); equal(allowedExternalIpAddresses, that.allowedExternalIpAddresses);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(super.hashCode(), networkPool, allowedExternalIpAddresses); return Objects.hashCode(super.hashCode(),
networkPool,
allowedExternalIpAddresses);
} }
@Override @Override
public ToStringHelper string() { public ToStringHelper string() {
return super.string().add("networkPool", networkPool) return super.string()
.add("networkPool", networkPool)
.add("allowedExternalIpAddresses", allowedExternalIpAddresses); .add("allowedExternalIpAddresses", allowedExternalIpAddresses);
} }
} }

View File

@ -125,7 +125,7 @@ public class ResourceType {
@XmlAttribute @XmlAttribute
private String type; private String type;
@XmlElement(name = "Link") @XmlElement(name = "Link")
private Set<Link> links; private Set<Link> links = Sets.newLinkedHashSet();
protected ResourceType(Builder<?> builder) { protected ResourceType(Builder<?> builder) {
this.href = builder.href; this.href = builder.href;
@ -136,7 +136,7 @@ public class ResourceType {
public ResourceType(URI href, String type, @Nullable Set<Link> links) { public ResourceType(URI href, String type, @Nullable Set<Link> links) {
this.href = href; this.href = href;
this.type = type; 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; this.links = links != null && links.isEmpty() ? null : links;
} }

View File

@ -18,8 +18,20 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; 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.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.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @see AdminNetworkClient * @see AdminNetworkClient
@ -28,7 +40,15 @@ import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
@RequestFilters(AddVCloudAuthorizationToRequest.class) @RequestFilters(AddVCloudAuthorizationToRequest.class)
public interface AdminNetworkAsyncClient extends NetworkAsyncClient { 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} // PUT /admin/network/{id}

View File

@ -18,9 +18,11 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.director.v1_5.domain.Network;
/** /**
* Provides synchronous access to admin {@link Network} objects. * Provides synchronous access to admin {@link Network} objects.
@ -31,7 +33,20 @@ import org.jclouds.concurrent.Timeout;
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface AdminNetworkClient extends NetworkClient { 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} // PUT /admin/network/{id}

View File

@ -29,7 +29,7 @@ import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; 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.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
@ -50,7 +50,7 @@ public interface NetworkAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<OrgNetwork> getNetwork(@EndpointParam URI networkUri); ListenableFuture<? extends Network> getNetwork(@EndpointParam URI networkUri);
/** /**
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features

View File

@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; 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. * Provides synchronous access to Network.
@ -42,7 +42,7 @@ public interface NetworkClient {
* *
* @return the network or null if not found * @return the network or null if not found
*/ */
OrgNetwork getNetwork(URI networkUri); Network getNetwork(URI networkUri);
/** /**
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features

View File

@ -360,7 +360,7 @@ public class Checks {
"The Image type of a Media must be one of the allowed list"); "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 // Check optional fields
NetworkConfiguration config = network.getConfiguration(); NetworkConfiguration config = network.getConfiguration();
if (config != null) { if (config != null) {
@ -1365,6 +1365,29 @@ public class Checks {
private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) { private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) {
// TODO Could do more assertions... // TODO Could do more assertions...
assertNotNull(val, String.format(NOT_NULL_OBJ_FMT, "ResouorceAllocatoinSettingData")); 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) { public static void checkAdminVdc(AdminVdc vdc) {

View File

@ -18,20 +18,86 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; 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.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/** /**
* Test the {@link GroupClient} by observing its side effects. * Test the {@link GroupClient} by observing its side effects.
* *
* @author danikov * @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 { 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} // PUT /admin/network/{id}
// POST /admin/network/{id}/action/reset // 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();
}
} }

View File

@ -18,36 +18,62 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; 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.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests live behavior of {@link AdminCatalogClient}. * Tests live behavior of {@link AdminNetworkClient}.
* *
* @author danikov * @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 class AdminNetworkLiveTest extends BaseVCloudDirectorClientLiveTest {
public static final String GROUP = "admin group"; public static final String NETWORK = "AdminNetwork";
/* /*
* Convenience references to API clients. * Convenience references to API clients.
*/ */
private AdminNetworkClient networkClient; private AdminNetworkClient networkClient;
/* /*
* Shared state between dependant tests. * Shared state between dependant tests.
*/ */
Reference networkRef;
Network network;
@BeforeClass(inheritGroups = true) @BeforeClass(inheritGroups = true)
public void setupRequiredClients() { protected void setupRequiredClients() {
networkClient = context.getApi().getAdminNetworkClient(); 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} // PUT /admin/network/{id}

View File

@ -26,6 +26,7 @@ import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.Error;
import org.jclouds.vcloud.director.v1_5.domain.IpAddresses; 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.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.Link;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; 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.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.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.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings; import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
@ -51,24 +55,34 @@ import com.google.common.collect.ImmutableSet;
public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test @Test
public void testWhenResponseIs2xxLoginReturnsValidNetwork() { public void testGetNetwork() {
URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c"); URI networkUri = URI.create(endpoint + "/network/f3ba8256-6f48-4512-aad6-600e85b4dc38");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK)); .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(); OrgNetwork expected = orgNetwork();
assertEquals(client.getNetworkClient().getNetwork(networkUri), expected); assertEquals(Network.<OrgNetwork>toSubType(client.getNetworkClient().getNetwork(networkUri)), expected);
} }
@Test @Test
public void testWhenResponseIs400ForInvalidNetworkId() { public void testGetNetworkWithInvalidId() {
URI networkUri = URI.create(endpoint + "/network/NOTAUUID"); URI networkUri = URI.create(endpoint + "/network/NOTAUUID");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/NOTAUUID"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse(400, "/network/error400.xml", VCloudDirectorMediaType.ERROR)); .apiCommand("GET", "/network/NOTAUUID")
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.xmlFilePayload("/network/error400.xml", VCloudDirectorMediaType.ERROR)
.httpResponseBuilder().statusCode(400).build());
Error expected = Error.builder() Error expected = Error.builder()
.message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.network.") .message("validation error : EntityRef has incorrect type, expected type is com.vmware.vcloud.entity.network.")
@ -87,12 +101,17 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
} }
@Test @Test
public void testWhenResponseIs403ForCatalogIdUsedAsNetworkId() { public void testGetNetworkWithCatalogId() {
URI networkUri = URI.create(endpoint + "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"); URI networkUri = URI.create(endpoint + "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/9e08c2f6-077a-42ce-bece-d5332e2ebb5c"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse(403, "/network/error403-catalog.xml", VCloudDirectorMediaType.ERROR)); .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() Error expected = Error.builder()
.message("This operation is denied.") .message("This operation is denied.")
@ -111,12 +130,17 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
} }
@Test @Test
public void testWhenResponseIs403ForFakeNetworkId() { public void testGetNetworkWithFakeId() {
URI networkUri = URI.create(endpoint + "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); URI networkUri = URI.create(endpoint + "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse(403, "/network/error403-fake.xml", VCloudDirectorMediaType.ERROR)); .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() Error expected = Error.builder()
.message("This operation is denied.") .message("This operation is denied.")
@ -135,7 +159,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
} }
@Test @Test
public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { public void testGetMetadata() {
URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c"); URI networkUri = URI.create(endpoint + "/network/55a677cf-ab3f-48ae-b880-fab90421980c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
@ -161,16 +185,27 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkUri), expected); assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkUri), expected);
} }
@Test(enabled=false) // No metadata in exemplar xml... @Test
public void testWhenResponseIs2xxLoginReturnsValidMetadata() { public void testGetMetadataValue() {
URI networkUri = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"); URI networkUri = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c");
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
getStandardRequest("GET", "/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY"), new VcloudHttpRequestPrimer()
getStandardPayloadResponse("/network/metadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY)); .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() MetadataValue expected = MetadataValue.builder()
.entry("key", "value") .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(); .build();
assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkUri, "KEY"), expected); assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkUri, "KEY"), expected);
@ -178,10 +213,10 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
public static OrgNetwork orgNetwork() { public static OrgNetwork orgNetwork() {
return OrgNetwork.builder() return OrgNetwork.builder()
.name("internet01-Jclouds") .name("ilsolation01-Jclouds")
.id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c") .id("urn:vcloud:network:f3ba8256-6f48-4512-aad6-600e85b4dc38")
.type(VCloudDirectorMediaType.ORG_NETWORK) .type("application/vnd.vmware.vcloud.orgNetwork+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) .href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38"))
.link(Link.builder() .link(Link.builder()
.rel("up") .rel("up")
.type("application/vnd.vmware.vcloud.org+xml") .type("application/vnd.vmware.vcloud.org+xml")
@ -190,25 +225,36 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT
.link(Link.builder() .link(Link.builder()
.rel("down") .rel("down")
.type("application/vnd.vmware.vcloud.metadata+xml") .type("application/vnd.vmware.vcloud.metadata+xml")
.href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")) .href(URI.create("https://vcloudbeta.bluelock.com/api/network/f3ba8256-6f48-4512-aad6-600e85b4dc38/metadata"))
.build()) .build())
.description("") .description("")
.configuration(NetworkConfiguration.builder() .configuration(NetworkConfiguration.builder()
.ipScope(IpScope.builder() .ipScope(IpScope.builder()
.isInherited(true) .isInherited(false)
.gateway("173.240.107.49") .gateway("192.168.1.1")
.netmask("255.255.255.240") .netmask("255.255.255.0")
.dns1("173.240.111.52") .dns1("173.240.111.52")
.dns2("173.240.111.53") .dns2("173.240.111.53")
.ipRanges(IpRanges.builder() .ipRanges(IpRanges.builder()
.ipRange(IpRange.builder() .ipRange(IpRange.builder()
.startAddress("173.240.107.50") .startAddress("192.168.1.100")
.endAddress("173.240.107.62") .endAddress("192.168.1.199")
.build()) .build())
.build()) .build())
.build()) .build())
.fenceMode("bridged") .fenceMode("isolated")
.retainNetInfoAcrossDeployments(false) .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())
.build())
.syslogServerSettings(SyslogServerSettings.builder().build()) .syslogServerSettings(SyslogServerSettings.builder().build())
.build()) .build())
.allowedExternalIpAddresses(IpAddresses.builder().build()) .allowedExternalIpAddresses(IpAddresses.builder().build())

View File

@ -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_FIELD_REQ_LIVE;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_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.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.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
@ -30,10 +31,10 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.jclouds.vcloud.director.v1_5.domain.Checks; 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.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; 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.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.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
@ -68,23 +69,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// required for testing // required for testing
assertNotNull(networkURI, String.format(REF_REQ_LIVE, NETWORK)); 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)); assertNotNull(network, String.format(OBJ_REQ_LIVE, NETWORK));
assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing"); assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing");
// parent type Checks.checkOrgNetwork(network);
Checks.checkNetworkType(network);
// optional
Reference networkPoolRef = network.getNetworkPool();
if (networkPoolRef != null) {
Checks.checkReferenceType(networkPoolRef);
}
IpAddresses allowedExternalIpAddresses = network.getAllowedExternalIpAddresses();
if (allowedExternalIpAddresses != null) {
Checks.checkIpAddresses(allowedExternalIpAddresses);
}
} }
@Test(testName = "GET /network/{id}/metadata") @Test(testName = "GET /network/{id}/metadata")

View File

@ -85,7 +85,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
} }
// NOTE Implement as required to populate xxxClient fields, or NOP // 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> retryTaskSuccess;
public Predicate<Task> retryTaskSuccessLong; public Predicate<Task> retryTaskSuccessLong;
@ -104,7 +104,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
protected Session session; protected Session session;
@BeforeClass(groups = { "live" }) @BeforeClass(groups = { "live" })
public void setupContext() throws Exception { protected void setupContext() throws Exception {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();

View File

@ -31,6 +31,8 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.rest.BaseRestClientExpectTest; import org.jclouds.rest.BaseRestClientExpectTest;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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 org.testng.annotations.BeforeGroups;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
@ -241,4 +243,12 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
return builder; 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();
}
} }

View File

@ -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>

View File

@ -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>

View File

@ -1,24 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?> <?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="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/> <Description/>
<Configuration> <Configuration>
<IpScope> <IpScope>
<IsInherited>true</IsInherited> <IsInherited>false</IsInherited>
<Gateway>173.240.107.49</Gateway> <Gateway>192.168.1.1</Gateway>
<Netmask>255.255.255.240</Netmask> <Netmask>255.255.255.0</Netmask>
<Dns1>173.240.111.52</Dns1> <Dns1>173.240.111.52</Dns1>
<Dns2>173.240.111.53</Dns2> <Dns2>173.240.111.53</Dns2>
<IpRanges> <IpRanges>
<IpRange> <IpRange>
<StartAddress>173.240.107.50</StartAddress> <StartAddress>192.168.1.100</StartAddress>
<EndAddress>173.240.107.62</EndAddress> <EndAddress>192.168.1.199</EndAddress>
</IpRange> </IpRange>
</IpRanges> </IpRanges>
</IpScope> </IpScope>
<FenceMode>bridged</FenceMode> <FenceMode>isolated</FenceMode>
<RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments> <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/> <SyslogServerSettings/>
</Configuration> </Configuration>
<AllowedExternalIpAddresses/> <AllowedExternalIpAddresses/>