From a1f02ad0bc36aac838e0054d1c4f7a050b695a46 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 10:28:19 +0000 Subject: [PATCH 1/8] bugfix: allow inconsistent null weights from listNodes --- .../cloudloadbalancers/features/NodeClientLiveTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java index d452fc3780..cc5a643fff 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java @@ -89,7 +89,8 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { assert n.getAddress() != null : n; assert n.getPort() != -1 : n; assert n.getStatus() != null : n; - assert n.getWeight() != null : n; //FIXME may fail as can be null (json response doesn't have the attribute) + // until fixed by rackspace... listNodes gives null weight when loadbalancer algorithm isn't weighted +// assert n.getWeight() != null : n; Node getDetails = client.getNodeClient(lb.getRegion()).getNodeInLoadBalancer(n.getId(), lb.getId()); System.out.println(n.toString()); @@ -99,7 +100,8 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { assertEquals(getDetails.getAddress(), n.getAddress()); assertEquals(getDetails.getPort(), n.getPort()); assertEquals(getDetails.getStatus(), n.getStatus()); - assertEquals(getDetails.getWeight(), n.getWeight()); //FIXME disparity between list/get can lead these to mismatch + // see above; getNodes gives valid/default weight which doesn't match +// assertEquals(getDetails.getWeight(), n.getWeight()); } catch (AssertionError e) { throw new AssertionError(String.format("%s\n%s - %s", e.getMessage(),getDetails, n)); } From 76cecee53aecf05bc059c879a959a78b8b4fcbb8 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 14:58:39 +0000 Subject: [PATCH 2/8] fixed UK provider/region not working + regression tests --- .../CloudLoadBalancersUKPropertiesBuilder.java | 6 +++++- ...CloudLoadBalancersUKLoadBalancerClientLiveTest.java | 10 ++++++++++ .../CloudLoadBalancersUSPropertiesBuilder.java | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java index fc9c750a82..4371ad388e 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java @@ -32,16 +32,20 @@ import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder; +import com.google.common.base.Joiner; + /** * Builds properties used inRackspace Cloud Load Balancers Clients * * @author Dan Lo Bianco */ public class CloudLoadBalancersUKPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { + public static String[] REGIONS = {LON}; + @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_REGIONS, "UK"); + properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS)); properties.setProperty(PROPERTY_ENDPOINT, "https://lon.auth.api.rackspacecloud.com"); properties.setProperty(PROPERTY_ISO3166_CODES, "GB-SLG"); diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java index e0211bd2d6..c471a83cf6 100644 --- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java @@ -18,7 +18,10 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import static org.testng.Assert.assertEquals; + import org.jclouds.cloudloadbalancers.features.LoadBalancerClientLiveTest; +import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; /** @@ -30,4 +33,11 @@ public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancer public CloudLoadBalancersUKLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-uk"; } + + @BeforeGroups(groups = "live") + protected void setup() { + super.setup(); + assertEquals(client.getConfiguredRegions().size(), + CloudLoadBalancersUKPropertiesBuilder.REGIONS.length); + } } diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java index ad7416e3fc..5102f20273 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java @@ -41,11 +41,13 @@ import com.google.common.base.Joiner; * @author Adrian Cole */ public class CloudLoadBalancersUSPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { + public static String[] REGIONS = {ORD, DFW}; + @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com"); - properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(ORD, DFW)); + properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(REGIONS)); properties.setProperty(PROPERTY_ISO3166_CODES, "US-IL,US-TX"); properties.setProperty(PROPERTY_REGION + "." + ORD + "." + ISO3166_CODES, "US-IL"); From d8156f671749a4d5e2bec8db636efdfd5098ee16 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 13:44:23 +0000 Subject: [PATCH 3/8] Issue 695: Removed addAction method, and created Builder and added TestActions class --- .../tmrk/enterprisecloud/domain/Actions.java | 86 +++++++++++++------ .../domain/HardwareConfiguration.java | 2 +- .../domain/VirtualMachine.java | 2 +- .../enterprisecloud/domain/ActionsTest.java | 57 ++++++++++++ 4 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/ActionsTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java index 0e803c396f..29b80c90a2 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Actions.java @@ -22,7 +22,6 @@ import com.google.common.collect.Sets; import javax.xml.bind.annotation.XmlElement; import java.util.Collections; -import java.util.LinkedHashSet; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; @@ -34,37 +33,74 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class Actions { - @XmlElement(name = "Action") - private LinkedHashSet actions = Sets.newLinkedHashSet(); + @SuppressWarnings("unchecked") + public static Builder builder() { + return new Builder(); + } - void addAction(Action action) { - checkNotNull(action,"action"); - this.actions.add(action); - } + public Builder toBuilder() { + return new Builder().fromActions(this); + } - public Set getActions() { - return Collections.unmodifiableSet(actions); - } + public static class Builder { - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + private Set actions = Sets.newLinkedHashSet(); - Actions actions1 = (Actions) o; + /** + * @see Actions#getActions + */ + public Builder actions(Set actions) { + this.actions = Sets.newLinkedHashSet(checkNotNull(actions, "actions")); + return this; + } - if (!actions.equals(actions1.actions)) return false; + public Builder addAction(Action action) { + actions.add(checkNotNull(action,"action")); + return this; + } - return true; - } + public Actions build() { + return new Actions(actions); + } - @Override - public int hashCode() { - return actions.hashCode(); - } + public Builder fromActions(Actions in) { + return actions(in.getActions()); + } + } - public String toString() { - return "["+ actions.toString()+"]"; - } + public Actions() { + //For JAXB and builder use + } + private Actions(Set actions) { + this.actions = Sets.newLinkedHashSet(actions); + } + + @XmlElement(name = "Action") + private Set actions = Sets.newLinkedHashSet(); + + public Set getActions() { + return Collections.unmodifiableSet(actions); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Actions actions1 = (Actions) o; + + if (!actions.equals(actions1.actions)) return false; + + return true; + } + + @Override + public int hashCode() { + return actions.hashCode(); + } + + public String toString() { + return "["+ actions.toString()+"]"; + } } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java index cb8193383d..12f7be4ebf 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java @@ -162,7 +162,7 @@ public class HardwareConfiguration extends BaseResource { private Nics virtualNics = new Nics(); public HardwareConfiguration(Set actions, int processorCount, @Nullable Memory memory, Set virtualDisks, Set virtualNics) { - for( Action action: checkNotNull(actions, "actions")) this.actions.addAction(action); + this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build(); for( VirtualDisk disk: checkNotNull(virtualDisks, "virtualDisks")) this.virtualDisks.setVirtualDisk(disk); for( VirtualNic virtualNic: checkNotNull(virtualNics, "virtualNics")) this.virtualNics.setVirtualNic(virtualNic); diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java index 93e24ce748..9b858b114e 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java @@ -87,7 +87,7 @@ public class VirtualMachine extends BaseNamedResource { */ public Builder actions(Set actions) { checkNotNull(actions,"actions"); - for(Action action:actions) this.actions.addAction(action); + this.actions = Actions.builder().actions(actions).build(); return this; } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/ActionsTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/ActionsTest.java new file mode 100644 index 0000000000..a3812e22c4 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/domain/ActionsTest.java @@ -0,0 +1,57 @@ +/** + * 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.tmrk.enterprisecloud.domain; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +/** + * @author Jason King + */ +@Test(groups = "unit", testName = "ActionsTest") +public class ActionsTest { + + private Action action; + private Actions actions; + + @BeforeMethod() + public void setUp() throws URISyntaxException { + action = Action.builder().href(new URI("/1")).name("my action").type("test action").build(); + actions = Actions.builder().addAction(action).build(); + } + + @Test + public void testAddAction() throws URISyntaxException { + Action action2 = Action.builder().href(new URI("/2")).name("my action 2").type("test action 2").build(); + Actions twoActions = actions.toBuilder().addAction(action2).build(); + Set actionSet = twoActions.getActions(); + + assertEquals(2,actionSet.size()); + assertTrue(actionSet.contains(action)); + assertTrue(actionSet.contains(action2)); + } + +} From 8752b29b16ea0b0b83c953e8433b864c204d8a02 Mon Sep 17 00:00:00 2001 From: Jason King Date: Mon, 21 Nov 2011 13:58:41 +0000 Subject: [PATCH 4/8] Issue 695: Refactored domain package: created packages: virtualmachine,hardware,software,network --- .../domain/{ => hardware}/Disks.java | 2 +- .../{ => hardware}/HardwareConfiguration.java | 6 +++++- .../domain/{ => hardware}/Memory.java | 2 +- .../domain/{ => hardware}/VirtualDisk.java | 3 ++- .../domain/{ => network}/AssignedIpAddresses.java | 5 +++-- .../domain/{ => network}/DeviceIps.java | 2 +- .../domain/{ => network}/DeviceNetwork.java | 2 +- .../domain/{ => network}/DeviceNetworks.java | 2 +- .../domain/{ => network}/NetworkReference.java | 2 +- .../enterprisecloud/domain/{ => network}/Nics.java | 4 ++-- .../domain/{ => network}/VirtualNic.java | 2 +- .../domain/{ => software}/OperatingSystem.java | 2 +- .../domain/{ => software}/ToolsStatus.java | 2 +- .../domain/{ => vm}/VirtualMachine.java | 6 +++++- .../domain/{ => vm}/VirtualMachineIpAddresses.java | 8 ++------ .../domain/{ => vm}/VirtualMachines.java | 2 +- .../features/VirtualMachineAsyncClient.java | 6 +++--- .../features/VirtualMachineClient.java | 6 +++--- .../features/VirtualMachineClientLiveTest.java | 10 +++++----- .../xml/AssignedIpAddressesJAXBParsingTest.java | 4 ++-- .../xml/VirtualMachineJAXBParsingTest.java | 13 ++++++++++++- 21 files changed, 54 insertions(+), 37 deletions(-) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => hardware}/Disks.java (97%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => hardware}/HardwareConfiguration.java (96%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => hardware}/Memory.java (97%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => hardware}/VirtualDisk.java (96%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/AssignedIpAddresses.java (94%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/DeviceIps.java (97%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/DeviceNetwork.java (96%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/DeviceNetworks.java (96%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/NetworkReference.java (98%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/Nics.java (94%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => network}/VirtualNic.java (98%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => software}/OperatingSystem.java (98%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => software}/ToolsStatus.java (96%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => vm}/VirtualMachine.java (97%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => vm}/VirtualMachineIpAddresses.java (86%) rename sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/{ => vm}/VirtualMachines.java (97%) diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Disks.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java similarity index 97% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Disks.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java index 0e2bc2f370..3f336e6392 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Disks.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Disks.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.hardware; import com.google.common.collect.Sets; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java similarity index 96% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java index 12f7be4ebf..6378452550 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/HardwareConfiguration.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/HardwareConfiguration.java @@ -16,12 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.hardware; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.Action; +import org.jclouds.tmrk.enterprisecloud.domain.Actions; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; +import org.jclouds.tmrk.enterprisecloud.domain.network.Nics; +import org.jclouds.tmrk.enterprisecloud.domain.network.VirtualNic; import javax.xml.bind.annotation.XmlElement; import java.net.URI; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Memory.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Memory.java similarity index 97% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Memory.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Memory.java index 8aaf5c7bd1..875216acad 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Memory.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/Memory.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.hardware; import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualDisk.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/VirtualDisk.java similarity index 96% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualDisk.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/VirtualDisk.java index b61465c020..59ddbd648c 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualDisk.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/hardware/VirtualDisk.java @@ -16,9 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.hardware; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.Size; import javax.xml.bind.annotation.XmlElement; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/AssignedIpAddresses.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java similarity index 94% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/AssignedIpAddresses.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java index af211e735a..301a1b7f91 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/AssignedIpAddresses.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/AssignedIpAddresses.java @@ -16,8 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; +import org.jclouds.tmrk.enterprisecloud.domain.Actions; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; import javax.xml.bind.annotation.XmlElement; @@ -47,7 +48,7 @@ public class AssignedIpAddresses extends BaseResource { checkNotNull(networks,"networks"); } - protected AssignedIpAddresses() { + public AssignedIpAddresses() { //For JAXB } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceIps.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceIps.java similarity index 97% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceIps.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceIps.java index 5a2b5af4a4..c19118c568 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceIps.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceIps.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import com.google.common.collect.Sets; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetwork.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetwork.java similarity index 96% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetwork.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetwork.java index eb4d9e15b2..d2e18a4fd6 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetwork.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetwork.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetworks.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetworks.java similarity index 96% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetworks.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetworks.java index ebdcd10a73..260fc7df71 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/DeviceNetworks.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/DeviceNetworks.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import com.google.common.collect.Sets; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/NetworkReference.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkReference.java similarity index 98% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/NetworkReference.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkReference.java index a17d496095..57ab774346 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/NetworkReference.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/NetworkReference.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import org.jclouds.javax.annotation.Nullable; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Nics.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java similarity index 94% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Nics.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java index 3c4e984786..eb11a8f34b 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/Nics.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/Nics.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import com.google.common.collect.Sets; @@ -36,7 +36,7 @@ public class Nics { private LinkedHashSet nics = Sets.newLinkedHashSet(); @XmlElement(name = "Nic") - void setVirtualNic(VirtualNic nic) { + public void setVirtualNic(VirtualNic nic) { this.nics.add(nic); } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualNic.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/VirtualNic.java similarity index 98% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualNic.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/VirtualNic.java index 617880941f..03bb25cd1e 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualNic.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/network/VirtualNic.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.network; import org.jclouds.javax.annotation.Nullable; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/OperatingSystem.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/OperatingSystem.java similarity index 98% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/OperatingSystem.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/OperatingSystem.java index 3fb94572c5..8d559faef7 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/OperatingSystem.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/OperatingSystem.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.software; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ToolsStatus.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/ToolsStatus.java similarity index 96% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ToolsStatus.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/ToolsStatus.java index fc452876d4..b3d7d1ff55 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/ToolsStatus.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/software/ToolsStatus.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.software; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java similarity index 97% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java index 9b858b114e..29ff17e012 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachine.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachine.java @@ -16,11 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.vm; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.tmrk.enterprisecloud.domain.*; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource; import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource; +import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem; +import org.jclouds.tmrk.enterprisecloud.domain.software.ToolsStatus; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlEnum; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachineIpAddresses.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineIpAddresses.java similarity index 86% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachineIpAddresses.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineIpAddresses.java index eb736b061e..fd7f048284 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachineIpAddresses.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachineIpAddresses.java @@ -16,15 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.vm; -import com.google.common.collect.Sets; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; /** * diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachines.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java similarity index 97% rename from sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachines.java rename to sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java index 282df14474..09a12eefd3 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/VirtualMachines.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/domain/vm/VirtualMachines.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.tmrk.enterprisecloud.domain; +package org.jclouds.tmrk.enterprisecloud.domain.vm; import com.google.common.collect.Sets; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClient.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClient.java index 0cb443f947..1fdb2f38ce 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClient.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineAsyncClient.java @@ -22,9 +22,9 @@ import com.google.common.util.concurrent.ListenableFuture; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.rest.annotations.*; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import org.jclouds.tmrk.enterprisecloud.domain.AssignedIpAddresses; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachines; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines; import javax.ws.rs.Consumes; import javax.ws.rs.GET; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java index ee0b9dd720..49f743e800 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClient.java @@ -19,9 +19,9 @@ package org.jclouds.tmrk.enterprisecloud.features; import org.jclouds.concurrent.Timeout; -import org.jclouds.tmrk.enterprisecloud.domain.AssignedIpAddresses; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachines; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines; import java.net.URI; import java.util.concurrent.TimeUnit; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java index b7cdc046e9..2d56910add 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java @@ -19,10 +19,10 @@ package org.jclouds.tmrk.enterprisecloud.features; import com.google.common.collect.Iterables; -import org.jclouds.tmrk.enterprisecloud.domain.AssignedIpAddresses; -import org.jclouds.tmrk.enterprisecloud.domain.DeviceNetwork; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachines; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; +import org.jclouds.tmrk.enterprisecloud.domain.network.DeviceNetwork; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachines; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -63,7 +63,7 @@ public class VirtualMachineClientLiveTest extends BaseTerremarkEnterpriseCloudCl // TODO: don't hard-code uri VirtualMachine virtualMachine = client.getVirtualMachine(new URI("/cloudapi/ecloud/virtualMachines/5504")); assert null != virtualMachine; - assertEquals(virtualMachine.getStatus(),VirtualMachine.VirtualMachineStatus.DEPLOYED); + assertEquals(virtualMachine.getStatus(), VirtualMachine.VirtualMachineStatus.DEPLOYED); } @Test diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/AssignedIpAddressesJAXBParsingTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/AssignedIpAddressesJAXBParsingTest.java index a5e84baae0..032767002b 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/AssignedIpAddressesJAXBParsingTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/AssignedIpAddressesJAXBParsingTest.java @@ -35,8 +35,8 @@ import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.tmrk.enterprisecloud.domain.*; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine.VirtualMachineStatus; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; +import org.jclouds.tmrk.enterprisecloud.domain.network.DeviceNetwork; import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; import org.testng.Assert; import org.testng.annotations.BeforeClass; diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java index 3fbd14098c..35cc8db05b 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java @@ -36,7 +36,18 @@ import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.tmrk.enterprisecloud.domain.*; -import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine.VirtualMachineStatus; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.Memory; +import org.jclouds.tmrk.enterprisecloud.domain.hardware.VirtualDisk; +import org.jclouds.tmrk.enterprisecloud.domain.network.AssignedIpAddresses; +import org.jclouds.tmrk.enterprisecloud.domain.network.DeviceNetwork; +import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkReference; +import org.jclouds.tmrk.enterprisecloud.domain.network.VirtualNic; +import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem; +import org.jclouds.tmrk.enterprisecloud.domain.software.ToolsStatus; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine.VirtualMachineStatus; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachine; +import org.jclouds.tmrk.enterprisecloud.domain.vm.VirtualMachineIpAddresses; import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; import org.testng.Assert; import org.testng.annotations.BeforeClass; From e28773337ed97b24c340374a3175556183072dbd Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 14:58:39 +0000 Subject: [PATCH 5/8] fixed UK provider/region not working + regression tests --- ...CloudLoadBalancersUSLoadBalancerClientLiveTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java index 6610ebcb0e..d54518e51f 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java @@ -18,7 +18,10 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import static org.testng.Assert.assertEquals; + import org.jclouds.cloudloadbalancers.features.LoadBalancerClientLiveTest; +import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; /** @@ -30,4 +33,11 @@ public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancer public CloudLoadBalancersUSLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-us"; } + + @BeforeGroups(groups = "live") + protected void setup() { + super.setup(); + assertEquals(client.getConfiguredRegions().size(), + CloudLoadBalancersUSPropertiesBuilder.REGIONS.length); + } } From 2c034b6a25a72f2d8fee72ca1c20e4cff5ec8cef Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 15:08:57 +0000 Subject: [PATCH 6/8] finalising constants :D --- .../CloudLoadBalancersUKPropertiesBuilder.java | 2 +- .../CloudLoadBalancersUSPropertiesBuilder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java index 4371ad388e..785e76c4b6 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKPropertiesBuilder.java @@ -40,7 +40,7 @@ import com.google.common.base.Joiner; * @author Dan Lo Bianco */ public class CloudLoadBalancersUKPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { - public static String[] REGIONS = {LON}; + public static final String[] REGIONS = {LON}; @Override protected Properties defaultProperties() { diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java index 5102f20273..9b0c4d009d 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSPropertiesBuilder.java @@ -41,7 +41,7 @@ import com.google.common.base.Joiner; * @author Adrian Cole */ public class CloudLoadBalancersUSPropertiesBuilder extends CloudLoadBalancersPropertiesBuilder { - public static String[] REGIONS = {ORD, DFW}; + public static final String[] REGIONS = {ORD, DFW}; @Override protected Properties defaultProperties() { From 381ce837d2a697ea6b8da77ccfa124b5aa2ee85e Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 16:50:44 +0000 Subject: [PATCH 7/8] correctly test weighting dependent on loadbalancer algorithm --- .../domain/LoadBalancer.java | 56 +++++++++++++++++++ .../features/NodeClientLiveTest.java | 11 ++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java index 3b315a3936..e83d2142f5 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/LoadBalancer.java @@ -75,6 +75,11 @@ public class LoadBalancer extends BaseLoadBalancer { this.status = status; return this; } + + public Builder algorithm(Algorithm algorithm) { + algorithm(algorithm.name()); + return this; + } public Builder virtualIPs(Iterable virtualIPs) { this.virtualIPs = ImmutableSet. copyOf(checkNotNull(virtualIPs, "virtualIPs")); @@ -207,10 +212,56 @@ public class LoadBalancer extends BaseLoadBalancer { } } + + /** + All load balancers utilize an algorithm that defines how traffic should be directed between + back-end nodes. The default algorithm for newly created load balancers is RANDOM, which can + be overridden at creation time or changed after the load balancer has been initially + provisioned. The algorithm name is to be constant within a major revision of the load + balancing API, though new algorithms may be created with a unique algorithm name within + a given major revision of the service API. + */ + public static enum Algorithm { + /** + * The node with the lowest number of connections will receive requests. + */ + LEAST_CONNECTIONS, + /** + * Back-end servers are selected at random. + */ + RANDOM, + /** + * Connections are routed to each of the back-end servers in turn. + */ + ROUND_ROBIN, + /** + * Each request will be assigned to a node based on the number of concurrent connections + * to the node and its weight. + */ + WEIGHTED_LEAST_CONNECTIONS, + /** + * A round robin algorithm, but with different proportions of traffic being directed to + * the back-end nodes. Weights must be defined as part of the load balancer's node configuration. + */ + WEIGHTED_ROUND_ROBIN, + UNRECOGNIZED; + + public static Algorithm fromValue(String status) { + try { + return valueOf(checkNotNull(status, "status")); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static Algorithm[] WEIGHTED_ALGORITHMS = {Algorithm.WEIGHTED_LEAST_CONNECTIONS, + Algorithm.WEIGHTED_ROUND_ROBIN}; private final String region; private final int id; private final Status status; + private final Algorithm algorithm; private final Set virtualIPs; private final String sessionPersistenceType; private final String clusterName; @@ -226,6 +277,7 @@ public class LoadBalancer extends BaseLoadBalancer { checkArgument(id != -1, "id must be specified"); this.id = id; this.status = checkNotNull(status, "status"); + this.algorithm = Algorithm.fromValue(algorithm); this.virtualIPs = ImmutableSet.copyOf(checkNotNull(virtualIPs, "virtualIPs")); this.sessionPersistenceType = sessionPersistenceType; this.clusterName = clusterName; @@ -245,6 +297,10 @@ public class LoadBalancer extends BaseLoadBalancer { public Status getStatus() { return status; } + + public Algorithm getTypedAlgorithm() { + return algorithm; + } public Set getVirtualIPs() { return virtualIPs; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java index cc5a643fff..1ffe36590e 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java @@ -21,6 +21,7 @@ package org.jclouds.cloudloadbalancers.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -89,8 +90,8 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { assert n.getAddress() != null : n; assert n.getPort() != -1 : n; assert n.getStatus() != null : n; - // until fixed by rackspace... listNodes gives null weight when loadbalancer algorithm isn't weighted -// assert n.getWeight() != null : n; + assert !Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains( + lb.getTypedAlgorithm()) || n.getWeight() != null : n; Node getDetails = client.getNodeClient(lb.getRegion()).getNodeInLoadBalancer(n.getId(), lb.getId()); System.out.println(n.toString()); @@ -100,8 +101,10 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { assertEquals(getDetails.getAddress(), n.getAddress()); assertEquals(getDetails.getPort(), n.getPort()); assertEquals(getDetails.getStatus(), n.getStatus()); - // see above; getNodes gives valid/default weight which doesn't match -// assertEquals(getDetails.getWeight(), n.getWeight()); + if(Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains( + lb.getTypedAlgorithm())) { + assertEquals(getDetails.getWeight(), n.getWeight()); + } } catch (AssertionError e) { throw new AssertionError(String.format("%s\n%s - %s", e.getMessage(),getDetails, n)); } From 3cc79d3cdd79798de82c0b8c99579502987861ea Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 21 Nov 2011 17:34:47 +0000 Subject: [PATCH 8/8] tweaked the test to be simpler & more accurate --- .../BaseCloudLoadBalancersClientLiveTest.java | 4 ++++ .../features/LoadBalancerClientLiveTest.java | 3 ++- ...loudLoadBalancersUKLoadBalancerClientLiveTest.java | 11 +---------- ...loudLoadBalancersUSLoadBalancerClientLiveTest.java | 11 +---------- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/BaseCloudLoadBalancersClientLiveTest.java index da9ef235b8..0ef04756d5 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/BaseCloudLoadBalancersClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/BaseCloudLoadBalancersClientLiveTest.java @@ -19,7 +19,9 @@ package org.jclouds.cloudloadbalancers.features; import static com.google.common.base.Preconditions.checkNotNull; +import static org.testng.Assert.assertEquals; +import java.util.Arrays; import java.util.Properties; import java.util.concurrent.TimeUnit; @@ -36,6 +38,7 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; @@ -53,6 +56,7 @@ public class BaseCloudLoadBalancersClientLiveTest { protected CloudLoadBalancersClient client; protected RestContext context; protected String provider = "cloudloadbalancers"; + protected String[] regions = {}; protected String identity; protected String credential; protected String endpoint; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java index f3f3137bb6..34a909c72b 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java @@ -21,6 +21,7 @@ package org.jclouds.cloudloadbalancers.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import java.util.Arrays; import java.util.Set; import java.util.logging.Logger; @@ -47,7 +48,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive @BeforeGroups(groups = "live") protected void setup() { - assertTrue(client.getConfiguredRegions().size() > 0, "Need to have some regions!"); + assertEquals(client.getConfiguredRegions(), Arrays.asList(regions)); Logger.getAnonymousLogger().info("running against regions "+client.getConfiguredRegions()); } diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java index c471a83cf6..3ef8cfc4f6 100644 --- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKLoadBalancerClientLiveTest.java @@ -18,10 +18,7 @@ */ package org.jclouds.rackspace.cloudloadbalancers; -import static org.testng.Assert.assertEquals; - import org.jclouds.cloudloadbalancers.features.LoadBalancerClientLiveTest; -import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; /** @@ -32,12 +29,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUKLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest { public CloudLoadBalancersUKLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-uk"; - } - - @BeforeGroups(groups = "live") - protected void setup() { - super.setup(); - assertEquals(client.getConfiguredRegions().size(), - CloudLoadBalancersUKPropertiesBuilder.REGIONS.length); + regions = CloudLoadBalancersUKPropertiesBuilder.REGIONS; } } diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java index d54518e51f..0d471943be 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSLoadBalancerClientLiveTest.java @@ -18,10 +18,7 @@ */ package org.jclouds.rackspace.cloudloadbalancers; -import static org.testng.Assert.assertEquals; - import org.jclouds.cloudloadbalancers.features.LoadBalancerClientLiveTest; -import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; /** @@ -32,12 +29,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUSLoadBalancerClientLiveTest extends LoadBalancerClientLiveTest { public CloudLoadBalancersUSLoadBalancerClientLiveTest() { provider = "cloudloadbalancers-us"; - } - - @BeforeGroups(groups = "live") - protected void setup() { - super.setup(); - assertEquals(client.getConfiguredRegions().size(), - CloudLoadBalancersUSPropertiesBuilder.REGIONS.length); + regions = CloudLoadBalancersUSPropertiesBuilder.REGIONS; } }