From ac259a68373252b7094073b695d2377b013cfef8 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Mon, 6 Feb 2012 12:45:33 +0000 Subject: [PATCH 1/8] Clean up OrgClientExpectTest formatting --- .../director/v1_5/features/OrgClientExpectTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index f9ebe85644..c8c407e86e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -45,7 +45,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", URI.create("http://localhost/api/org/")), - getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML)); + getStandardPayloadResponse("/org/orglist.xml", VCloudDirectorMediaType.ORGLIST_XML+";version=1.5")); OrgList expected = OrgList.builder() .org(Reference.builder() @@ -64,7 +64,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", orgRef), - getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML)); + getStandardPayloadResponse("/org/org.xml", VCloudDirectorMediaType.ORG_XML+";version=1.5")); Org expected = Org .builder() @@ -125,7 +125,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metaRef), - getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML)); + getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATA_XML+";version=1.5")); Metadata expected = Metadata.builder() .type("application/vnd.vmware.vcloud.metadata+xml") @@ -146,7 +146,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metadataRef), - getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML)); + getStandardPayloadResponse("/org/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML+";version=1.5")); MetadataEntry expected = MetadataEntry.builder() .build(); From 517dfef56f11aae9cae64475b859084f7daca909 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 17:21:49 +0000 Subject: [PATCH 2/8] add exemplar xml --- .../src/test/resources/network/network.xml | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 labs/vcloud-director/src/test/resources/network/network.xml diff --git a/labs/vcloud-director/src/test/resources/network/network.xml b/labs/vcloud-director/src/test/resources/network/network.xml new file mode 100644 index 0000000000..b3a53f615a --- /dev/null +++ b/labs/vcloud-director/src/test/resources/network/network.xml @@ -0,0 +1,25 @@ + + + + + + + + true + 173.240.107.49 + 255.255.255.240 + 173.240.111.52 + 173.240.111.53 + + + 173.240.107.50 + 173.240.107.62 + + + + bridged + false + + + + From 6b2a2a845b39f1de34fa73f802f6607800c4112b Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 17:22:04 +0000 Subject: [PATCH 3/8] add expect test --- .../features/NetworkClientExpectTest.java | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java new file mode 100644 index 0000000000..4eb787aeff --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -0,0 +1,134 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless(Link.builder().required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; +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.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.domain.VAppNetwork; +import org.jclouds.vcloud.director.v1_5.domain.Org; +import org.jclouds.vcloud.director.v1_5.domain.OrgList; +import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; +import org.testng.annotations.Test; + +/** + * Allows us to test a client via its side effects. + * + * @author danikov + */ +@Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest") +public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { + + /* + GET /network/{id} + GET /network/{id}/metadata + GET /network/{id}/metadata/{key} + */ + + @Test + public void testWhenResponseIs2xxLoginReturnsValidNetwork() { + URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", orgRef), + getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML)); + + OrgNetwork expected = OrgNetwork + .builder() + .name("internet01-Jclouds") + .id("urn:vcloud:network:55a677cf-ab3f-48ae-b880-fab90421980c") + .type(VCloudDirectorMediaType.ORG_NETWORK_XML) + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) + .link(Link.builder() + .rel("up") + .type("application/vnd.vmware.vcloud.org+xml") + .name("Cluster01-JClouds") + .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) + .build()) + .link(Link.builder() + .rel("down") + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadat")) + .build()) + .description("") + .configuration(NetworkConfiguration.builder() + .IpScope(IpScope.builder() + .isInherited(true) + .gateway("") + .netmask("") + .dns1("") + .dns2("") + .ipRange("", "") + .build()) + .fenceMode("bridged") + .retainNetInfoAcrossDeployments(false) + .syslogServerSettings(null) + .build()) + .allowedExternalIpAddresses(null) + .build(); + + assertEquals(client.getNetworkClient().getNetwork(networkRef), expected); + } + + @Test + public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { + URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); + URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", metaRef), + getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATA_XML)); + + Metadata expected = Metadata.builder() + .type("application/vnd.vmware.vcloud.metadata+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata")) + .link(Link.builder() + .rel("up") + .type("????????") + .href(URI.create("??????")) + .build()) + .build(); + + assertEquals(client.getOrgClient().getMetadata(orgRef), expected); + } + + @Test(enabled=false) // No metadata in exemplar xml... + public void testWhenResponseIs2xxLoginReturnsValidMetadata() { + URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata/KEY"); + + VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, + getStandardRequest("GET", metadataRef), + getStandardPayloadResponse("/network/metadata.xml", VCloudDirectorMediaType.METADATAENTRY_XML)); + + MetadataEntry expected = MetadataEntry.builder() + .build(); + + assertEquals(client.getOrgClient().getMetadataEntry(metadataRef), expected); + } +} From 24bd9f72e320229e1862198a0c92c2bd70d2e9b0 Mon Sep 17 00:00:00 2001 From: danikov Date: Tue, 7 Feb 2012 17:22:18 +0000 Subject: [PATCH 4/8] add domain classes and media type --- .../v1_5/VCloudDirectorMediaType.java | 2 + .../vcloud/director/v1_5/domain/IpScope.java | 5 + .../v1_5/domain/NetworkConfiguration.java | 5 + .../director/v1_5/domain/OrgNetwork.java | 174 ++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java index 078e95672c..d50ec22299 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorMediaType.java @@ -42,4 +42,6 @@ public interface VCloudDirectorMediaType { public final static String ORG_XML = "application/vnd.vmware.vcloud.org+xml"; + public static final String ORG_NETWORK_XML = "application/vnd.vmware.vcloud.orgNetwork+xml"; + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java new file mode 100644 index 0000000000..fe795cf14c --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java @@ -0,0 +1,5 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +public class IpScope { + +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java new file mode 100644 index 0000000000..7df61c2d21 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java @@ -0,0 +1,5 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +public class NetworkConfiguration{ + +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java new file mode 100644 index 0000000000..d1630c40ea --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java @@ -0,0 +1,174 @@ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; + +import org.jclouds.vcloud.director.v1_5.domain.Org.Builder; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +public class OrgNetwork extends EntityType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromOrgNetwork(this); + } + + public static class Builder extends EntityType.Builder { + + private boolean allowedExternalIpAddresses; + + /** + * @see Network#getAllowedExternalIpAddresses() + */ + public Builder allowedExternalIpAddresses(boolean ExternalIpAddresses) { + this.allowedExternalIpAddresses = allowedExternalIpAddresses; + return this; + } + + @Override + public OrgNetwork build() { + Org org = new OrgNetwork(href, name); + org.setNetworkPool(network); + org.setDescription(description); + org.setId(id); + org.setType(type); + org.setLinks(links); + org.setTasksInProgress(tasksInProgress); + return org; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasksInProgress() + */ + @Override + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromOrgNetwork(OrgNetwork in) { + return fromEntityType(in).fullName(in.getFullName()); + } + } + + private OrgNetwork() { + // For JAXB and builder use + } + + private OrgNetwork(URI href, String name, String fullName) { + super(href, name); + this.fullName = fullName; + } + + @XmlElement(namespace = NS, name = "FullName") + private String fullName; + + /** + * + * @return fullName of the org + */ + public String getFullName() { + return fullName; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + Org that = Org.class.cast(o); + return super.equals(that) && equal(fullName, that.fullName); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(fullName); + } + + @Override + public ToStringHelper string() { + return super.string().add("fullName", fullName); + } + +} From e5eea32e697cea3162dca7f0e0569c74622969bd Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 9 Feb 2012 02:10:06 +0000 Subject: [PATCH 5/8] finish network test --- .../features/NetworkClientExpectTest.java | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index 4eb787aeff..a5c3732c7c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -24,16 +24,16 @@ 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.NetworkConfiguration; +import org.jclouds.vcloud.director.v1_5.domain.IpAddresses; +import org.jclouds.vcloud.director.v1_5.domain.IpRange; +import org.jclouds.vcloud.director.v1_5.domain.IpRanges; import org.jclouds.vcloud.director.v1_5.domain.IpScope; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; -import org.jclouds.vcloud.director.v1_5.domain.VAppNetwork; -import org.jclouds.vcloud.director.v1_5.domain.Org; -import org.jclouds.vcloud.director.v1_5.domain.OrgList; -import org.jclouds.vcloud.director.v1_5.domain.Reference; +import org.jclouds.vcloud.director.v1_5.domain.SyslogServerSettings; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.testng.annotations.Test; @@ -45,18 +45,12 @@ import org.testng.annotations.Test; @Test(groups = "unit", singleThreaded = true, testName = "NetworkClientExpectTest") public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { - /* - GET /network/{id} - GET /network/{id}/metadata - GET /network/{id}/metadata/{key} - */ - @Test public void testWhenResponseIs2xxLoginReturnsValidNetwork() { - URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); + URI networkRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, - getStandardRequest("GET", orgRef), + getStandardRequest("GET", networkRef), getStandardPayloadResponse("/network/network.xml", VCloudDirectorMediaType.ORG_NETWORK_XML)); OrgNetwork expected = OrgNetwork @@ -68,37 +62,41 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT .link(Link.builder() .rel("up") .type("application/vnd.vmware.vcloud.org+xml") - .name("Cluster01-JClouds") .href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")) .build()) .link(Link.builder() .rel("down") .type("application/vnd.vmware.vcloud.metadata+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadat")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")) .build()) .description("") .configuration(NetworkConfiguration.builder() - .IpScope(IpScope.builder() + .ipScope(IpScope.builder() .isInherited(true) - .gateway("") - .netmask("") - .dns1("") - .dns2("") - .ipRange("", "") + .gateway("173.240.107.49") + .netmask("255.255.255.240") + .dns1("173.240.111.52") + .dns2("173.240.111.53") + .ipRanges(IpRanges.builder() + .ipRange(IpRange.builder() + .startAddress("173.240.107.50") + .endAddress("173.240.107.62") + .build()) + .build()) .build()) .fenceMode("bridged") .retainNetInfoAcrossDeployments(false) - .syslogServerSettings(null) + .syslogServerSettings(SyslogServerSettings.builder().build()) .build()) - .allowedExternalIpAddresses(null) + .allowedExternalIpAddresses(IpAddresses.builder().build()) .build(); assertEquals(client.getNetworkClient().getNetwork(networkRef), expected); } @Test - public void testWhenResponseIs2xxLoginReturnsValidMetadataList() { - URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY"); + public void testWhenResponseIs2xxLoginReturnsValidMetadata() { + URI orgRef = URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c"); URI metaRef = URI.create(orgRef.toASCIIString()+"/metadata/"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, @@ -107,11 +105,11 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT Metadata expected = Metadata.builder() .type("application/vnd.vmware.vcloud.metadata+xml") - .href(URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata")) + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata")) .link(Link.builder() .rel("up") - .type("????????") - .href(URI.create("??????")) + .type("application/vnd.vmware.vcloud.network+xml") + .href(URI.create("https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c")) .build()) .build(); @@ -119,8 +117,9 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT } @Test(enabled=false) // No metadata in exemplar xml... - public void testWhenResponseIs2xxLoginReturnsValidMetadata() { - URI metadataRef = URI.create("https://vcloudbeta.bluelock.com/api/network/NETWORK_KEY/metadata/KEY"); + public void testWhenResponseIs2xxLoginReturnsValidMetadataEntry() { + URI metadataRef = URI.create( + "https://vcloudbeta.bluelock.com/api/network/55a677cf-ab3f-48ae-b880-fab90421980c/metadata/KEY"); VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, getStandardRequest("GET", metadataRef), From 60e39a4a999ec175bd611af6f9c9f53febb59811 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 9 Feb 2012 02:10:57 +0000 Subject: [PATCH 6/8] network domain objects --- .../director/v1_5/domain/IpAddresses.java | 112 +++++++ .../vcloud/director/v1_5/domain/IpRange.java | 125 ++++++++ .../vcloud/director/v1_5/domain/IpRanges.java | 112 +++++++ .../vcloud/director/v1_5/domain/IpScope.java | 289 ++++++++++++++++++ .../v1_5/domain/NetworkConfiguration.java | 265 ++++++++++++++++ .../director/v1_5/domain/NetworkFeatures.java | 119 ++++++++ .../director/v1_5/domain/NetworkService.java | 105 +++++++ .../director/v1_5/domain/OrgNetwork.java | 248 +++++++++++++++ .../director/v1_5/domain/RouterInfo.java | 104 +++++++ .../v1_5/domain/SyslogServerSettings.java | 133 ++++++++ .../vcloud/director/v1_5/domain/IpScope.java | 5 - .../v1_5/domain/NetworkConfiguration.java | 5 - .../director/v1_5/domain/OrgNetwork.java | 174 ----------- 13 files changed, 1612 insertions(+), 184 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java delete mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java delete mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java delete mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java new file mode 100644 index 0000000000..c7dfa043a0 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpAddresses.java @@ -0,0 +1,112 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * A list of IpAddresses. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "IpAddresses") +public class IpAddresses { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromIpAddresses(this); + } + + public static class Builder { + private Set ipAddresses = Sets.newLinkedHashSet(); + + /** + * @see IpAddresses#getIpAddresses() + */ + public Builder ipAddresses(Set ipAddresses) { + this.ipAddresses = Sets.newLinkedHashSet(checkNotNull(ipAddresses, "ipAddresses")); + return this; + } + + /** + * @see IpAddresses#getIpAddresses() + */ + public Builder ipAddress(String ipAddress) { + ipAddresses.add(checkNotNull(ipAddress, "ipAddress")); + return this; + } + + public IpAddresses build() { + return new IpAddresses(ipAddresses); + } + + public Builder fromIpAddresses(IpAddresses in) { + return ipAddresses(in.getIpAddresses()); + } + } + + private IpAddresses() { + // For JAXB and builder use + } + + private IpAddresses(Set orgs) { + this.ipAddresses = ImmutableSet.copyOf(orgs); + } + + @XmlElement(namespace = NS, name = "IpAddress") + private Set ipAddresses = Sets.newLinkedHashSet(); + + public Set getIpAddresses() { + return ImmutableSet.copyOf(ipAddresses); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + IpAddresses that = IpAddresses.class.cast(o); + return equal(ipAddresses, that.ipAddresses); + } + + @Override + public int hashCode() { + return Objects.hashCode(ipAddresses); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("ipAddresses", ipAddresses).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java new file mode 100644 index 0000000000..efffaee687 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRange.java @@ -0,0 +1,125 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents a range of IP addresses, start and end inclusive. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "IpRange") +public class IpRange { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromIpRange(this); + } + + public static class Builder { + + private String startAddress; + private String endAddress; + + /** + * @see IpRange#getStartAddress() + */ + public Builder startAddress(String startAddress) { + this.startAddress = startAddress; + return this; + } + + /** + * @see IpRange#getEndAddress() + */ + public Builder endAddress(String endAddress) { + this.endAddress = endAddress; + return this; + } + + public IpRange build() { + return new IpRange(startAddress, endAddress); + } + + public Builder fromIpRange(IpRange in) { + return startAddress(in.getStartAddress()).endAddress(in.getEndAddress()); + } + } + + private IpRange() { + // For JAXB and builder use + } + + private IpRange(String startAddress, String endAddress) { + this.startAddress = startAddress; + this.endAddress = endAddress; + } + + + @XmlElement(namespace = NS, name = "StartAddress") + private String startAddress; + @XmlElement(namespace = NS, name = "EndAddress") + private String endAddress; + + /** + * @return Start address of the IP range. + */ + public String getStartAddress() { + return startAddress; + } + + /** + * @return End address of the IP range. + */ + public String getEndAddress() { + return endAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + IpRange that = IpRange.class.cast(o); + return equal(startAddress, that.startAddress) && equal(endAddress, that.endAddress); + } + + @Override + public int hashCode() { + return Objects.hashCode(startAddress, endAddress); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("startAddress", startAddress) + .add("endAddress", endAddress).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java new file mode 100644 index 0000000000..da637355ac --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpRanges.java @@ -0,0 +1,112 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * A list of IpAddresses. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "IpRanges") +public class IpRanges { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromIpRanges(this); + } + + public static class Builder { + private Set ipRanges = Sets.newLinkedHashSet(); + + /** + * @see IpRanges#getIpRanges() + */ + public Builder ipRanges(Set ipRanges) { + this.ipRanges = Sets.newLinkedHashSet(checkNotNull(ipRanges, "ipRanges")); + return this; + } + + /** + * @see IpRanges#getIpRanges() + */ + public Builder ipRange(IpRange ipRange) { + ipRanges.add(checkNotNull(ipRange, "ipRange")); + return this; + } + + public IpRanges build() { + return new IpRanges(ipRanges); + } + + public Builder fromIpRanges(IpRanges in) { + return ipRanges(in.getIpRanges()); + } + } + + private IpRanges() { + // For JAXB and builder use + } + + private IpRanges(Set ipRanges) { + this.ipRanges = ImmutableSet.copyOf(ipRanges); + } + + @XmlElement(namespace = NS, name = "IpRange") + private Set ipRanges = Sets.newLinkedHashSet(); + + public Set getIpRanges() { + return ImmutableSet.copyOf(ipRanges); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + IpRanges that = IpRanges.class.cast(o); + return equal(ipRanges, that.ipRanges); + } + + @Override + public int hashCode() { + return Objects.hashCode(ipRanges); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("ipRanges", ipRanges).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java new file mode 100644 index 0000000000..763082741b --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java @@ -0,0 +1,289 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Specify network settings like gateway, network mask, DNS servers, IP ranges, etc. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "IpScope") +@XmlAccessorType(XmlAccessType.FIELD) +public class IpScope { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromIpScope(this); + } + + public static class Builder { + + private boolean isInherited; + private String gateway; + private String netmask; + private String dns1; + private String dns2; + private String dnsSuffix; + private IpRanges ipRanges; + private IpAddresses allocatedIpAddresses; + + /** + * @see IpScope#isInherited() + */ + public Builder isInherited(boolean isInherited) { + this.isInherited = isInherited; + return this; + } + + /** + * @see IpScope#getGateway() + */ + public Builder gateway(String gateway) { + this.gateway = gateway; + return this; + } + + /** + * @see IpScope#getNetmask() + */ + public Builder netmask(String netmask) { + this.netmask = netmask; + return this; + } + + /** + * @see IpScope#getDns1() + */ + public Builder dns1(String dns1) { + this.dns1 = dns1; + return this; + } + + /** + * @see IpScope#getDns2() + */ + public Builder dns2(String dns2) { + this.dns2 = dns2; + return this; + } + + /** + * @see IpScope#getDnsSuffix() + */ + public Builder dnsSuffix(String dnsSuffix) { + this.dnsSuffix = dnsSuffix; + return this; + } + + /** + * @see IpScope#getIpRanges() + */ + public Builder ipRanges(IpRanges ipRanges) { + this.ipRanges = ipRanges; + return this; + } + + /** + * @see IpScope#getAllocatedIpAddresses() + */ + public Builder allocatedIpAddresses(IpAddresses allocatedIpAddresses) { + this.allocatedIpAddresses = allocatedIpAddresses; + return this; + } + + public IpScope build() { + IpScope ipScope = new IpScope(isInherited); + ipScope.setGateway(gateway); + ipScope.setNetmask(netmask); + ipScope.setDns1(dns1); + ipScope.setDns2(dns2); + ipScope.setDnsSuffix(dnsSuffix); + ipScope.setIpRanges(ipRanges); + ipScope.setAllocatedIpAddresses(allocatedIpAddresses); + return ipScope; + } + + public Builder fromIpScope(IpScope in) { + return isInherited(in.isInherited()).gateway(in.getGateway()) + .netmask(in.getNetmask()) + .dns1(in.getDns1()) + .dns2(in.getDns2()) + .dnsSuffix(in.getDnsSuffix()) + .ipRanges(in.getIpRanges()) + .allocatedIpAddresses(in.getAllocatedIpAddresses()); + } + } + + private IpScope() { + // For JAXB and builder use + } + + private IpScope(boolean isInherited) { + this.isInherited = isInherited; + } + + @XmlElement(namespace = NS, name = "IsInherited") + private boolean isInherited; + @XmlElement(namespace = NS, name = "Gateway") + private String gateway; + @XmlElement(namespace = NS, name = "Netmask") + private String netmask; + @XmlElement(namespace = NS, name = "Dns1") + private String dns1; + @XmlElement(namespace = NS, name = "Dns2") + private String dns2; + @XmlElement(namespace = NS, name = "DnsSuffix") + private String dnsSuffix; + @XmlElement(namespace = NS, name = "IpRanges") + private IpRanges ipRanges; + @XmlElement(namespace = NS, name = "AllocatedIpAddresses") + private IpAddresses allocatedIpAddresses; + + /** + * @return True if the IP scope is inherit from parent network. + */ + public boolean isInherited() { + return isInherited; + } + + /** + * @return Gateway of the network.. + */ + public String getGateway() { + return gateway; + } + + public void setGateway(String gateway) { + this.gateway = gateway; + } + + /** + * @return Network mask. + */ + public String getNetmask() { + return netmask; + } + + public void setNetmask(String netmask) { + this.netmask = netmask; + } + + /** + * @return Primary DNS server. + */ + public String getDns1() { + return dns1; + } + + public void setDns1(String dns1) { + this.dns1 = dns1; + } + + /** + * @return Secondary DNS server. + */ + public String getDns2() { + return dns2; + } + + public void setDns2(String dns2) { + this.dns2 = dns2; + } + + /** + * @return DNS suffix. + */ + public String getDnsSuffix() { + return dnsSuffix; + } + + public void setDnsSuffix(String dnsSuffix) { + this.dnsSuffix = dnsSuffix; + } + + /** + * @return IP ranges used for static pool allocation in the network. + */ + public IpRanges getIpRanges() { + return ipRanges; + } + + public void setIpRanges(IpRanges ipRanges) { + this.ipRanges = ipRanges; + } + + /** + * @return Read-only list of allocated IP addresses in the network. + */ + public IpAddresses getAllocatedIpAddresses() { + return allocatedIpAddresses; + } + + public void setAllocatedIpAddresses(IpAddresses allocatedIpAddresses) { + this.allocatedIpAddresses = allocatedIpAddresses; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + IpScope that = IpScope.class.cast(o); + return equal(isInherited, that.isInherited) && equal(gateway, that.gateway) && + equal(netmask, that.netmask) && + equal(dns1, that.dns1) && + equal(dns2, that.dns2) && + equal(dnsSuffix, that.dnsSuffix) && + equal(ipRanges, that.ipRanges) && + equal(allocatedIpAddresses, that.allocatedIpAddresses); + } + + @Override + public int hashCode() { + return Objects.hashCode(isInherited, gateway, netmask, dns1, dns2, dnsSuffix, + ipRanges, allocatedIpAddresses); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("isInherited", isInherited) + .add("gateway", gateway) + .add("netmask", netmask) + .add("dns1", dns1) + .add("dns2", dns2) + .add("dnsSuffix", dnsSuffix) + .add("ipRanges", ipRanges) + .add("allocatedIpAddresses", allocatedIpAddresses).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java new file mode 100644 index 0000000000..694c1fd815 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java @@ -0,0 +1,265 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Returns a network configuration + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "NetworkConfiguration") +@XmlAccessorType(XmlAccessType.FIELD) +public class NetworkConfiguration{ + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromConfiguration(this); + } + + public static class Builder { + private IpScope ipScope; + private ReferenceType parentNetwork; + private String fenceMode; + private boolean retainNetInfoAcrossDeployments; + private NetworkFeatures features; + private SyslogServerSettings syslogServerSettings; + private RouterInfo routerInfo; + + /** + * @see NetworkConfiguration#getIpScope() + */ + public Builder ipScope(IpScope ipScope) { + this.ipScope = ipScope; + return this; + } + + /** + * @see NetworkConfiguration#getParentNetwork() + */ + public Builder parentNetwork(ReferenceType parentNetwork) { + this.parentNetwork = parentNetwork; + return this; + } + + /** + * @see NetworkConfiguration#getFenceMode() + */ + public Builder fenceMode(String fenceMode) { + this.fenceMode = fenceMode; + return this; + } + + /** + * @see NetworkConfiguration#getRetainNetInfoAcrossDeployments() + */ + public Builder retainNetInfoAcrossDeployments(boolean retainNetInfoAcrossDeployments) { + this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments; + return this; + } + + /** + * @see NetworkConfiguration#getNetworkFeatures() + */ + public Builder features(NetworkFeatures features) { + this.features = features; + return this; + } + + /** + * @see NetworkConfiguration#getSyslogServerSettings() + */ + public Builder syslogServerSettings(SyslogServerSettings syslogServerSettings) { + this.syslogServerSettings = syslogServerSettings; + return this; + } + + /** + * @see NetworkConfiguration#getRouterInfo() + */ + public Builder routerInfo(RouterInfo routerInfo) { + this.routerInfo = routerInfo; + return this; + } + + public NetworkConfiguration build() { + NetworkConfiguration networkConfiguration = new NetworkConfiguration(fenceMode); + networkConfiguration.setIpScope(ipScope); + networkConfiguration.setParentNetwork(parentNetwork); + networkConfiguration.setRetainNetInfoAcrossDeployments(retainNetInfoAcrossDeployments); + networkConfiguration.setNetworkFeatures(features); + networkConfiguration.setSyslogServerSettings(syslogServerSettings); + networkConfiguration.setRouterInfo(routerInfo); + return networkConfiguration; + } + + public Builder fromConfiguration(NetworkConfiguration in) { + return ipScope(in.getIpScope()).parentNetwork(in.getParentNetwork()).fenceMode(in.getFenceMode()) + .retainNetInfoAcrossDeployments(in.getRetainNetInfoAcrossDeployments()) + .features(in.getNetworkFeatures()) + .syslogServerSettings(in.getSyslogServerSettings()) + .routerInfo(in.getRouterInfo()); + } + } + + private NetworkConfiguration() { + // For JAXB and builder use + } + + private NetworkConfiguration(String fenceMode) { + this.fenceMode = fenceMode; + } + + @XmlElement(namespace = NS, name = "IpScope") + private IpScope ipScope; + @XmlElement(namespace = NS, name = "ParentNetwork") + private ReferenceType parentNetwork; + @XmlElement(namespace = NS, name = "FenceMode") + private String fenceMode; + @XmlElement(namespace = NS, name = "RetainNetInfoAcrossDeployments") + private boolean retainNetInfoAcrossDeployments = false; + @XmlElement(namespace = NS, name = "Features") + private NetworkFeatures features; + @XmlElement(namespace = NS, name = "SyslogServerSettings") + private SyslogServerSettings syslogServerSettings; + @XmlElement(namespace = NS, name = "RouterInfo") + private RouterInfo routerInfo; + + /** + * @return IP level configuration items such as gateway, dns, subnet, + * IP address pool to be used for allocation. Note that the pool of IP addresses + * needs to fall within the subnet/mask of the IpScope. + */ + public IpScope getIpScope() { + return ipScope; + } + + public void setIpScope(IpScope ipScope) { + this.ipScope = ipScope; + } + + /** + * @return reference to parent network. + */ + public ReferenceType getParentNetwork() { + return parentNetwork; + } + + public void setParentNetwork(ReferenceType parentNetwork) { + this.parentNetwork = parentNetwork; + } + + /** + * @return Isolation type of the network. If ParentNetwork is specified, this property + * controls connectivity to the parent. One of: bridged (connected directly to the ParentNetwork), + * isolated (not connected to any other network), natRouted (connected to the ParentNetwork via a + * NAT service) + */ + public String getFenceMode() { + return fenceMode; + } + + /** + * @return whether the network resources such as IP/MAC of router will be retained + * across deployments. Default is false. + */ + public boolean getRetainNetInfoAcrossDeployments() { + return retainNetInfoAcrossDeployments; + } + + public void setRetainNetInfoAcrossDeployments(boolean retainNetInfoAcrossDeployments) { + this.retainNetInfoAcrossDeployments = retainNetInfoAcrossDeployments; + } + + /** + * @return Network features like DHCP, firewall and NAT rules. + */ + public NetworkFeatures getNetworkFeatures() { + return features; + } + + public void setNetworkFeatures(NetworkFeatures features) { + this.features = features; + } + + /** + * @return Syslog server settings for the network. + */ + public SyslogServerSettings getSyslogServerSettings() { + return syslogServerSettings; + } + + public void setSyslogServerSettings(SyslogServerSettings syslogServerSettings) { + this.syslogServerSettings = syslogServerSettings; + } + + /** + * @return router information + */ + public RouterInfo getRouterInfo() { + return routerInfo; + } + + public void setRouterInfo(RouterInfo routerInfo) { + this.routerInfo = routerInfo; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkConfiguration that = NetworkConfiguration.class.cast(o); + return equal(ipScope, that.ipScope) && equal(parentNetwork, that.parentNetwork) && + equal(fenceMode, that.fenceMode) && + equal(retainNetInfoAcrossDeployments, that.retainNetInfoAcrossDeployments) && + equal(features, that.features) && + equal(syslogServerSettings, that.syslogServerSettings) && + equal(routerInfo, that.routerInfo); + } + + @Override + public int hashCode() { + return Objects.hashCode(ipScope, parentNetwork, fenceMode, retainNetInfoAcrossDeployments, + features, syslogServerSettings, routerInfo); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("ipScope", ipScope).add("parentNetwork", parentNetwork) + .add("fenceMode", fenceMode) + .add("retainNetInfoAcrossDeployments", retainNetInfoAcrossDeployments) + .add("features", features) + .add("syslogServerSettings", syslogServerSettings) + .add("routerInfo", routerInfo).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java new file mode 100644 index 0000000000..b8a6d47897 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkFeatures.java @@ -0,0 +1,119 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + +/** + * Represents features of a network. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "Features") +public class NetworkFeatures { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkFeatures(this); + } + + public static class Builder { + + private Set services = Sets.newLinkedHashSet(); + + /** + * @see NetworkFeatures#getNetworkServices() + */ + public Builder services(Set services) { + this.services = Sets.newLinkedHashSet(checkNotNull(services, "services")); + return this; + } + + /** + * @see NetworkFeatures#getNetworkServices() + */ + public Builder service(NetworkService service) { + services.add(checkNotNull(service, "service")); + return this; + } + + public NetworkFeatures build() { + NetworkFeatures networkFeatures = new NetworkFeatures(); + networkFeatures.setNetworkServices(services); + return networkFeatures; + } + + public Builder fromNetworkFeatures(NetworkFeatures in) { + return services(in.getNetworkServices()); + } + } + + private NetworkFeatures() { + // For JAXB and builder use + } + + @XmlElement(namespace = NS, name = "NetworkService") + private Set services = Sets.newLinkedHashSet(); + + /** + * @return a Network service. May be any of DhcpService, NatService, IpsecVpnService, + * DhcpService, or StaticRoutingService. + */ + public Set getNetworkServices() { + return ImmutableSet.copyOf(services); + } + + public void setNetworkServices(Set services) { + this.services = Sets.newLinkedHashSet(checkNotNull(services, "services")); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkFeatures that = NetworkFeatures.class.cast(o); + return equal(services, that.services); + } + + @Override + public int hashCode() { + return Objects.hashCode(services); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("services", services).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java new file mode 100644 index 0000000000..6fcbff73ac --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/NetworkService.java @@ -0,0 +1,105 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Represents a network service + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "NetworkService") +public class NetworkService { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromNetworkService(this); + } + + public static class Builder { + + private boolean isEnabled; + + /** + * @see NetworkService#isEnabled() + */ + public Builder enabled(boolean isEnabled) { + this.isEnabled = isEnabled; + return this; + } + + public NetworkService build() { + NetworkService networkService = new NetworkService(); + networkService.setEnabled(isEnabled); + return networkService; + } + + public Builder fromNetworkService(NetworkService in) { + return enabled(in.isEnabled()); + } + } + + private NetworkService() { + // For JAXB and builder use + } + + @XmlElement(namespace = NS, name = "IsEnabled") + private boolean isEnabled; + + /** + * @return Enable or disable the service using this flag + */ + public boolean isEnabled() { + return isEnabled; + } + + public void setEnabled(boolean isEnabled) { + this.isEnabled = isEnabled; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + NetworkService that = NetworkService.class.cast(o); + return equal(isEnabled, that.isEnabled); + } + + @Override + public int hashCode() { + return Objects.hashCode(isEnabled); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("isEnabled", isEnabled).toString(); + } +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java new file mode 100644 index 0000000000..9133bf4f03 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java @@ -0,0 +1,248 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless(Link.builder().required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import java.net.URI; +import java.util.Set; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import org.jclouds.ovf.Network; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.Sets; + +@XmlRootElement(namespace = NS, name = "OrgNetwork") +public class OrgNetwork extends EntityType { + + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return new Builder().fromOrgNetwork(this); + } + + public static class Builder extends EntityType.Builder { + + private NetworkConfiguration networkConfiguration; + private ReferenceType networkPool; + private IpAddresses allowedExternalIpAddresses; + + /** + * @see Network#getConfiguration() + */ + public Builder configuration(NetworkConfiguration networkConfiguration) { + this.networkConfiguration = networkConfiguration; + return this; + } + + /** + * @see Network#getNetworkPool() + */ + public Builder networkPool(ReferenceType networkPool) { + this.networkPool = networkPool; + return this; + } + + /** + * @see Network#getAllowedExternalIpAddresses() + */ + public Builder allowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) { + this.allowedExternalIpAddresses = allowedExternalIpAddresses; + return this; + } + + @Override + public OrgNetwork build() { + OrgNetwork network = new OrgNetwork(href, name); + network.setConfiguration(networkConfiguration); + network.setNetworkPool(networkPool); + network.setAllowedExternalIpAddresses(allowedExternalIpAddresses); + network.setDescription(description); + network.setId(id); + network.setType(type); + network.setLinks(links); + network.setTasksInProgress(tasksInProgress); + return network; + } + + /** + * @see EntityType#getName() + */ + @Override + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see EntityType#getDescription() + */ + @Override + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see EntityType#getId() + */ + @Override + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see EntityType#getTasksInProgress() + */ + @Override + public Builder tasksInProgress(TasksInProgress tasksInProgress) { + this.tasksInProgress = tasksInProgress; + return this; + } + + /** + * @see ReferenceType#getHref() + */ + @Override + public Builder href(URI href) { + this.href = href; + return this; + } + + /** + * @see ReferenceType#getType() + */ + @Override + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder links(Set links) { + this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); + return this; + } + + /** + * @see ReferenceType#getLinks() + */ + @Override + public Builder link(Link link) { + this.links.add(checkNotNull(link, "link")); + return this; + } + + @Override + public Builder fromEntityType(EntityType in) { + return Builder.class.cast(super.fromEntityType(in)); + } + + public Builder fromOrgNetwork(OrgNetwork in) { + return fromEntityType(in).configuration(in.getConfiguration()) + .networkPool(in.getNetworkPool()) + .allowedExternalIpAddresses(in.getAllowedExternalIpAddresses()); + } + } + + private OrgNetwork() { + // For JAXB and builder use + } + + private OrgNetwork(URI href, String name) { + super(href, name); + } + + @XmlElement(namespace = NS, name = "Configuration") + private NetworkConfiguration networkConfiguration; + @XmlElement(namespace = NS, name = "NetworkPool") + private ReferenceType networkPool; + @XmlElement(namespace = NS, name = "AllowedExternalIpAddresses") + private IpAddresses allowedExternalIpAddresses; + + /** + * @return optional configuration + */ + public NetworkConfiguration getConfiguration() { + return networkConfiguration; + } + + public void setConfiguration(NetworkConfiguration networkConfiguration) { + this.networkConfiguration = networkConfiguration; + } + + /** + * @return optional network pool + */ + public ReferenceType getNetworkPool() { + return networkPool; + } + + public void setNetworkPool(ReferenceType networkPool) { + this.networkPool = networkPool; + } + + /** + * @return optional network pool + */ + public IpAddresses getAllowedExternalIpAddresses() { + return allowedExternalIpAddresses; + } + + public void setAllowedExternalIpAddresses(IpAddresses allowedExternalIpAddresses) { + this.allowedExternalIpAddresses = allowedExternalIpAddresses; + } + + @Override + public boolean equals(Object o) { + if (!super.equals(o)) + return false; + OrgNetwork that = OrgNetwork.class.cast(o); + return super.equals(that) && equal(networkConfiguration, that.networkConfiguration) && + equal(networkPool, that.networkPool) && + equal(allowedExternalIpAddresses, that.allowedExternalIpAddresses); + } + + @Override + public int hashCode() { + return super.hashCode() + Objects.hashCode(networkConfiguration, + networkPool, allowedExternalIpAddresses); + } + + @Override + public ToStringHelper string() { + return super.string().add("configuration", networkConfiguration).add("networkPool", networkPool) + .add("allowedExternalIpAddresses", allowedExternalIpAddresses); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java new file mode 100644 index 0000000000..99151515a8 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/RouterInfo.java @@ -0,0 +1,104 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Specifies router information. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "RouterInfo") +public class RouterInfo { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromRouterInfo(this); + } + + public static class Builder { + + private String externalIp; + + /** + * @see RouterInfo#getExternalIp() + */ + public Builder externalIp(String externalIp) { + this.externalIp = externalIp; + return this; + } + + public RouterInfo build() { + return new RouterInfo(externalIp); + } + + public Builder fromRouterInfo(RouterInfo in) { + return externalIp(in.getExternalIp()); + } + } + + private RouterInfo() { + // For JAXB and builder use + } + + private RouterInfo(String externalIp) { + this.externalIp = externalIp; + } + + + @XmlElement(namespace = NS, name = "ExternalIp") + private String externalIp; + + /** + * @return the external IP of the router. Applicable for NAT Routed / Fenced networks only. + */ + public String getExternalIp() { + return externalIp; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RouterInfo that = RouterInfo.class.cast(o); + return equal(externalIp, that.externalIp); + } + + @Override + public int hashCode() { + return Objects.hashCode(externalIp, externalIp); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("externalIp", externalIp).toString(); + } + +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java new file mode 100644 index 0000000000..5217ad1252 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/domain/SyslogServerSettings.java @@ -0,0 +1,133 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + *(Link.builder().regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless(Link.builder().required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.domain; + +import static com.google.common.base.Objects.equal; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.google.common.base.Objects; + +/** + * Syslog server settings. If logging is configured for firewall rules, the logs + * will be directed to these syslog servers. + * + * @author danikov + */ +@XmlRootElement(namespace = NS, name = "SyslogServerSettings") +@XmlAccessorType(XmlAccessType.FIELD) +public class SyslogServerSettings { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSyslogServerSettings(this); + } + + public static class Builder { + + private String syslogServerIp1; + private String syslogServerIp2; + + /** + * @see SyslogServerSettings#getSyslogServerIp1() + */ + public Builder syslogServerIp1(String syslogServerIp1) { + this.syslogServerIp1 = syslogServerIp1; + return this; + } + + /** + * @see SyslogServerSettings#getSyslogServerIp2() + */ + public Builder syslogServerIp2(String syslogServerIp2) { + this.syslogServerIp2 = syslogServerIp2; + return this; + } + + public SyslogServerSettings build() { + SyslogServerSettings syslogServerSettings = new SyslogServerSettings(); + syslogServerSettings.syslogServerIp1 = syslogServerIp1; + syslogServerSettings.syslogServerIp2 = syslogServerIp2; + return syslogServerSettings; + } + + public Builder fromSyslogServerSettings(SyslogServerSettings in) { + return syslogServerIp1(in.getSyslogServerIp1()).syslogServerIp2(in.getSyslogServerIp2()); + } + } + + private SyslogServerSettings() { + // For JAXB and builder use + } + + @XmlElement(namespace = NS, name = "SyslogServerIp1") + private String syslogServerIp1; + @XmlElement(namespace = NS, name = "SyslogServerIp2") + private String syslogServerIp2; + + /** + * @return Primary syslog server. + */ + public String getSyslogServerIp1() { + return syslogServerIp1; + } + + public void setSyslogServerIp1(String syslogServerIp1) { + this.syslogServerIp1 = syslogServerIp1; + } + + /** + * @return Secondary syslog server. + */ + public String getSyslogServerIp2() { + return syslogServerIp2; + } + + public void setSyslogServerIp2(String syslogServerIp2) { + this.syslogServerIp2 = syslogServerIp2; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + SyslogServerSettings that = SyslogServerSettings.class.cast(o); + return equal(syslogServerIp1, that.syslogServerIp1) && equal(syslogServerIp2, that.syslogServerIp1); + } + + @Override + public int hashCode() { + return Objects.hashCode(syslogServerIp1, syslogServerIp2); + } + + @Override + public String toString() { + return Objects.toStringHelper("").add("syslogServerIp1", syslogServerIp1) + .add("syslogServerIp1", syslogServerIp2).toString(); + } +} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java deleted file mode 100644 index fe795cf14c..0000000000 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/IpScope.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.jclouds.vcloud.director.v1_5.domain; - -public class IpScope { - -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java deleted file mode 100644 index 7df61c2d21..0000000000 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/NetworkConfiguration.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.jclouds.vcloud.director.v1_5.domain; - -public class NetworkConfiguration{ - -} diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java deleted file mode 100644 index d1630c40ea..0000000000 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/domain/OrgNetwork.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.jclouds.vcloud.director.v1_5.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NS; - -import java.net.URI; -import java.util.Set; - -import javax.xml.bind.annotation.XmlElement; - -import org.jclouds.vcloud.director.v1_5.domain.Org.Builder; - -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.collect.Sets; - -public class OrgNetwork extends EntityType { - - @SuppressWarnings("unchecked") - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return new Builder().fromOrgNetwork(this); - } - - public static class Builder extends EntityType.Builder { - - private boolean allowedExternalIpAddresses; - - /** - * @see Network#getAllowedExternalIpAddresses() - */ - public Builder allowedExternalIpAddresses(boolean ExternalIpAddresses) { - this.allowedExternalIpAddresses = allowedExternalIpAddresses; - return this; - } - - @Override - public OrgNetwork build() { - Org org = new OrgNetwork(href, name); - org.setNetworkPool(network); - org.setDescription(description); - org.setId(id); - org.setType(type); - org.setLinks(links); - org.setTasksInProgress(tasksInProgress); - return org; - } - - /** - * @see EntityType#getName() - */ - @Override - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see EntityType#getDescription() - */ - @Override - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * @see EntityType#getId() - */ - @Override - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see EntityType#getTasksInProgress() - */ - @Override - public Builder tasksInProgress(TasksInProgress tasksInProgress) { - this.tasksInProgress = tasksInProgress; - return this; - } - - /** - * @see ReferenceType#getHref() - */ - @Override - public Builder href(URI href) { - this.href = href; - return this; - } - - /** - * @see ReferenceType#getType() - */ - @Override - public Builder type(String type) { - this.type = type; - return this; - } - - /** - * @see ReferenceType#getLinks() - */ - @Override - public Builder links(Set links) { - this.links = Sets.newLinkedHashSet(checkNotNull(links, "links")); - return this; - } - - /** - * @see ReferenceType#getLinks() - */ - @Override - public Builder link(Link link) { - this.links.add(checkNotNull(link, "link")); - return this; - } - - @Override - public Builder fromEntityType(EntityType in) { - return Builder.class.cast(super.fromEntityType(in)); - } - - public Builder fromOrgNetwork(OrgNetwork in) { - return fromEntityType(in).fullName(in.getFullName()); - } - } - - private OrgNetwork() { - // For JAXB and builder use - } - - private OrgNetwork(URI href, String name, String fullName) { - super(href, name); - this.fullName = fullName; - } - - @XmlElement(namespace = NS, name = "FullName") - private String fullName; - - /** - * - * @return fullName of the org - */ - public String getFullName() { - return fullName; - } - - @Override - public boolean equals(Object o) { - if (!super.equals(o)) - return false; - Org that = Org.class.cast(o); - return super.equals(that) && equal(fullName, that.fullName); - } - - @Override - public int hashCode() { - return super.hashCode() + Objects.hashCode(fullName); - } - - @Override - public ToStringHelper string() { - return super.string().add("fullName", fullName); - } - -} From f2732fc49e240ae2914a7dfebfa9c95cb95617d2 Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 9 Feb 2012 02:11:37 +0000 Subject: [PATCH 7/8] network client + wiring --- .../v1_5/VCloudDirectorAsyncClient.java | 9 ++- .../director/v1_5/VCloudDirectorClient.java | 7 ++ .../VCloudDirectorRestClientModule.java | 3 + .../v1_5/features/NetworkAsyncClient.java | 74 +++++++++++++++++++ .../director/v1_5/features/NetworkClient.java | 61 +++++++++++++++ 5 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index ba7af5a7c9..11d9fa44e7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import com.google.inject.Provides; @@ -41,8 +42,14 @@ public interface VCloudDirectorAsyncClient { Session getCurrentSession(); /** - * @return synchronous access to Org features + * @return asynchronous access to Org features */ @Delegate OrgAsyncClient getOrgClient(); + + /** + * @return asynchronous access to Network features + */ + @Delegate + NetworkAsyncClient getNetworkClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 8be15b1602..ac5d56f44c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Session; +import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import com.google.inject.Provides; @@ -48,4 +49,10 @@ public interface VCloudDirectorClient { */ @Delegate OrgClient getOrgClient(); + + /** + * @return synchronous access to Network features + */ + @Delegate + NetworkClient getNetworkClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 73ad9722fe..41a31f0e34 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -42,6 +42,8 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.annotations.Login; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; +import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.functions.LoginUserInOrgWithPassword; @@ -72,6 +74,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// .put(OrgClient.class, OrgAsyncClient.class) + .put(NetworkClient.class, NetworkAsyncClient.class) .build(); public VCloudDirectorRestClientModule() { diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java new file mode 100644 index 0000000000..aea399dbb4 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java @@ -0,0 +1,74 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; +import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + + * @see NetworkClient + * @author danikov + */ +@RequestFilters(AddVCloudAuthorizationToRequest.class) +public interface NetworkAsyncClient { + + /** + * @see NeworkClient#getNetwork() + */ + @GET + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetwork(@EndpointParam URI uri); + + /** + * @see NeworkClient#getMetadata() + */ + @GET + @Path("/metadata/") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getMetadata(@EndpointParam URI orgRef); + + /** + * @see NeworkClient#getMetadataEntry() + */ + @GET + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getMetadataEntry(@EndpointParam URI metaDataRef); +} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java new file mode 100644 index 0000000000..c10ddd07b1 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.features; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; +import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; + +/** + * Provides synchronous access to Network. + *

+ * + * @see NetworkAsyncClient + * @see + * @author danikov + */ +@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) +public interface NetworkClient { + + /** + * Retrieves a network. + * + * @return the network or null if not found + */ + OrgNetwork getNetwork(URI networkRef); + + /** + * Retrieves an list of the network's metadata + * + * @return a list of metadata + */ + Metadata getMetadata(URI networkRef); + + /** + * Retrieves a metadata entry + * + * @return the metadata entry, or null if not found + */ + MetadataEntry getMetadataEntry(URI metaDataRef); + +} From 3656c61da0c528eb6ce1fc66af5ec35224f46fae Mon Sep 17 00:00:00 2001 From: danikov Date: Thu, 9 Feb 2012 02:18:19 +0000 Subject: [PATCH 8/8] metadata exemplar xml --- labs/vcloud-director/src/test/resources/network/metadata.xml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 labs/vcloud-director/src/test/resources/network/metadata.xml diff --git a/labs/vcloud-director/src/test/resources/network/metadata.xml b/labs/vcloud-director/src/test/resources/network/metadata.xml new file mode 100644 index 0000000000..035f8ef25d --- /dev/null +++ b/labs/vcloud-director/src/test/resources/network/metadata.xml @@ -0,0 +1,4 @@ + + + +