diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToNICs.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToNICs.java index 983a9a5261..3c2cce8087 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToNICs.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToNICs.java @@ -23,29 +23,43 @@ import java.util.Map; import javax.inject.Singleton; +import com.google.inject.Inject; import org.jclouds.elasticstack.domain.Model; import org.jclouds.elasticstack.domain.NIC; import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; +import org.jclouds.rest.annotations.ApiVersion; /** - * * @author Adrian Cole */ @Singleton public class MapToNICs implements Function, List> { + private String apiVersion; + + @Inject + public MapToNICs(@ApiVersion String apiVersion) { + this.apiVersion = apiVersion; + } + @Override public List apply(Map from) { ImmutableList.Builder nics = ImmutableList.builder(); - NIC: for (int id : new int[] { 0, 1 }) { + NIC: + for (int id : new int[]{0, 1}) { String key = String.format("nic:%d", id); if (!from.containsKey(key + ":model")) break NIC; NIC.Builder nicBuilder = new NIC.Builder(); - nicBuilder.dhcp(from.get(key + ":dhcp")); + + if (apiVersion.equals("2.0")) { + nicBuilder.dhcp(from.get(key + ":dhcp:ip")); + } else { + nicBuilder.dhcp(from.get(key + ":dhcp")); + } nicBuilder.model(Model.fromValue(from.get(key + ":model"))); nicBuilder.vlan(from.get(key + ":vlan")); nicBuilder.mac(from.get(key + ":mac")); diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToServerInfo.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToServerInfo.java index 6c3b9a4679..3188fc4e99 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToServerInfo.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToServerInfo.java @@ -36,20 +36,22 @@ import org.jclouds.elasticstack.domain.VNC; import com.google.common.base.Function; import com.google.common.base.Splitter; import com.google.common.collect.Maps; +import org.jclouds.rest.annotations.ApiVersion; /** - * * @author Adrian Cole */ @Singleton public class MapToServerInfo implements Function, ServerInfo> { + private String apiVersion; private final Function, Map> mapToDevices; private final Function, ServerMetrics> mapToMetrics; private final Function, List> mapToNICs; @Inject public MapToServerInfo(Function, Map> mapToDevices, - Function, ServerMetrics> mapToMetrics, Function, List> mapToNICs) { + Function, ServerMetrics> mapToMetrics, Function, List> mapToNICs) { + this.apiVersion = apiVersion; this.mapToDevices = mapToDevices; this.mapToMetrics = mapToMetrics; this.mapToNICs = mapToNICs; @@ -66,19 +68,28 @@ public class MapToServerInfo implements Function, ServerInfo builder.tags(Splitter.on(' ').split(from.get("tags"))); if (from.containsKey("status")) builder.status(ServerStatus.fromValue(from.get("status"))); - if (from.containsKey("smp") && !"auto".equals(from.get("smp"))) - builder.smp(new Integer(from.get("smp"))); + + + if (from.containsKey("smp:cores")) { + builder.smp(new Integer(from.get("smp:cores"))); + } else if (from.containsKey("smp") && !"auto".equals(from.get("smp"))) { + builder.smp(new Integer(from.get("smp"))); + } + builder.cpu(Integer.parseInt(from.get("cpu"))); builder.mem(Integer.parseInt(from.get("mem"))); builder.user(from.get("user")); if (from.containsKey("started")) builder.started(new Date(new Long(from.get("started")))); builder.uuid(from.get("server")); - builder.vnc(new VNC(from.get("vnc:ip"), from.get("vnc:password"), from.containsKey("vnc:tls") - && Boolean.valueOf(from.get("vnc:tls")))); if (from.containsKey("boot")) builder.bootDeviceIds(Splitter.on(' ').split(from.get("boot"))); + + builder.vnc(new VNC(from.get("vnc:ip") == null ? "auto" : from.get("vnc:ip"), from.get("vnc:password"), from.containsKey("vnc:tls") + && Boolean.valueOf(from.get("vnc:tls")))); + + Map metadata = Maps.newLinkedHashMap(); for (Entry entry : from.entrySet()) { if (entry.getKey().startsWith("user:")) diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ServerToMap.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ServerToMap.java index 6261e6d313..8ad17a3b4c 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ServerToMap.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/ServerToMap.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; import java.util.Map.Entry; +import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.elasticstack.domain.Device; @@ -32,13 +33,22 @@ import org.jclouds.elasticstack.domain.Server; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; +import org.jclouds.rest.annotations.ApiVersion; /** - * * @author Adrian Cole */ @Singleton public class ServerToMap implements Function> { + + @ApiVersion + private final String apiVersion; + + @Inject + public ServerToMap(@ApiVersion String apiVersion) { + this.apiVersion = apiVersion; + } + @Override public Map apply(Server from) { checkNotNull(from, "server"); @@ -68,7 +78,14 @@ public class ServerToMap implements Function> { builder.put("nic:" + nicId + ":mac", nic.getMac()); nicId++; } - builder.put("vnc:ip", from.getVnc().getIp() == null ? "auto" : from.getVnc().getIp()); + + String vncIp = from.getVnc().getIp(); + if (apiVersion.equals("2.0")) { + builder.put("vnc", "auto"); + } else { + builder.put("vnc:ip", vncIp == null ? "auto" : vncIp); + } + if (from.getVnc().getPassword() != null) builder.put("vnc:password", from.getVnc().getPassword()); if (from.getVnc().isTls()) diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java index 582cbdbdbe..16a760eaf2 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/binders/BindServerToPlainTextStringTest.java @@ -18,30 +18,26 @@ */ package org.jclouds.elasticstack.binders; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; -import java.util.Map; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.elasticstack.domain.IDEDevice; -import org.jclouds.elasticstack.domain.Model; -import org.jclouds.elasticstack.domain.NIC; -import org.jclouds.elasticstack.domain.Server; -import org.jclouds.elasticstack.domain.VNC; -import org.jclouds.elasticstack.functions.ServerToMap; -import org.jclouds.http.HttpRequest; -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Guice; +import com.google.inject.Injector; import com.google.inject.TypeLiteral; +import org.jclouds.elasticstack.domain.*; +import org.jclouds.elasticstack.functions.ServerToMap; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.util.Strings2; +import org.testng.annotations.Test; + +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.net.URI; +import java.util.Map; + +import static org.testng.Assert.assertEquals; /** * @@ -69,19 +65,20 @@ public class BindServerToPlainTextStringTest { .nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000). build())).vnc(new VNC(null, "XXXXXXXX", false)).build(); - private static final BindServerToPlainTextString FN = Guice.createInjector(new AbstractModule() { + private Injector i = Guice.createInjector(new AbstractModule() { @Override protected void configure() { + bindConstant().annotatedWith(ApiVersion.class).to("1.0"); bind(new TypeLiteral>>() { }).to(ServerToMap.class); } - }).getInstance(BindServerToPlainTextString.class); + }); public void testSimple() throws IOException { HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create")); - FN.bindToRequest(request, SERVER); + i.getInstance(BindServerToPlainTextString.class).bindToRequest(request, SERVER); assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN); assertEquals(request.getPayload().getRawContent(), CREATED_SERVER); } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java index d2eab467ca..2716fbd015 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/KeyValuesDelimitedByBlankLinesToServerInfoTest.java @@ -30,6 +30,7 @@ import org.jclouds.elasticstack.domain.ServerMetrics; import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payloads; +import org.jclouds.rest.annotations.ApiVersion; import org.testng.annotations.Test; import com.google.common.base.Function; @@ -48,6 +49,7 @@ public class KeyValuesDelimitedByBlankLinesToServerInfoTest { @Override protected void configure() { + bindConstant().annotatedWith(ApiVersion.class).to("1.0"); bind(new TypeLiteral, List>>() { }).to(MapToNICs.class); bind(new TypeLiteral, Map>>() { diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java index adf4ee7e0a..877c52ee5f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest.java @@ -31,6 +31,7 @@ import org.jclouds.elasticstack.domain.ServerMetrics; import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payloads; +import org.jclouds.rest.annotations.ApiVersion; import org.testng.annotations.Test; import com.google.common.base.Function; @@ -51,6 +52,7 @@ public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest { @Override protected void configure() { + bindConstant().annotatedWith(ApiVersion.class).to("1.0"); bind(new TypeLiteral, List>>() { }).to(MapToNICs.class); bind(new TypeLiteral, Map>>() { diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToServerInfoTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToServerInfoTest.java index e0a29b9598..9c4aa0d76a 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToServerInfoTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/MapToServerInfoTest.java @@ -42,7 +42,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; /** - * + * * @author Adrian Cole */ @Test(groups = { "unit" }) @@ -102,7 +102,7 @@ public class MapToServerInfoTest { .build()).build(); private static final MapToServerInfo MAP_TO_DRIVE = new MapToServerInfo(new MapToDevices(new DeviceToId()), - new MapToServerMetrics(new MapToDriveMetrics()), new MapToNICs()); + new MapToServerMetrics(new MapToDriveMetrics()), new MapToNICs("1.0")); public void testEmptyMapReturnsNull() { assertEquals(MAP_TO_DRIVE.apply(ImmutableMap. of()), null); @@ -158,4 +158,14 @@ public class MapToServerInfoTest { assertEquals(MAP_TO_DRIVE.apply(input), NEW); } + + + public void testNew2() throws IOException { + + Map input = new ListOfKeyValuesDelimitedByBlankLinesToListOfMaps().apply( + Strings2.toStringAndClose(MapToServerInfoTest.class.getResourceAsStream("/new_server2.txt"))).get(0); + + assertEquals(MAP_TO_DRIVE.apply(input), NEW); + + } } \ No newline at end of file diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ServerToMapTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ServerToMapTest.java index 92459f5d8f..940ea4e62f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ServerToMapTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/functions/ServerToMapTest.java @@ -31,15 +31,16 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; /** - * + * * @author Adrian Cole */ @Test(groups = { "unit" }) public class ServerToMapTest { - private static final ServerToMap SERVER_TO_MAP = new ServerToMap(); + private static final ServerToMap SERVER_TO_MAP = new ServerToMap("1.0"); + private static final ServerToMap SERVER_TO_MAP_V2 = new ServerToMap("2.0"); - public void testBasics() { + public void testBasics() { assertEquals( SERVER_TO_MAP.apply(new Server.Builder() .name("TestServer") @@ -62,4 +63,27 @@ public class ServerToMapTest { "vnc:password", "XXXXXXXX")).build()); } + public void testBasicsV2() { + assertEquals( + SERVER_TO_MAP_V2.apply(new Server.Builder() + .name("TestServer") + .cpu(2000) + .mem(1024) + .devices( + ImmutableMap.of("ide:0:0", + new IDEDevice.Builder(0, 0).uuid("08c92dd5-70a0-4f51-83d2-835919d254df").build())) + .bootDeviceIds(ImmutableSet.of("ide:0:0")).nics(ImmutableSet.of(new NIC.Builder().model(Model.E1000). + + build())).vnc(new VNC(null, "XXXXXXXX", false)).build()), + ImmutableMap + .builder() + .putAll(ImmutableMap.of("name", "TestServer", "cpu", "2000", "smp", "auto", "mem", "1024")) + .putAll( + ImmutableMap.of("persistent", "false", "boot", "ide:0:0", "ide:0:0", + "08c92dd5-70a0-4f51-83d2-835919d254df")) + .putAll( + ImmutableMap.of("ide:0:0:media", "disk", "nic:0:model", "e1000", "vnc", "auto", + "vnc:password", "XXXXXXXX")).build()); + } + } \ No newline at end of file diff --git a/apis/elasticstack/src/test/resources/new_server2.txt b/apis/elasticstack/src/test/resources/new_server2.txt new file mode 100644 index 0000000000..5f2aabdd87 --- /dev/null +++ b/apis/elasticstack/src/test/resources/new_server2.txt @@ -0,0 +1,25 @@ +ide:0:0:write:requests 0 +boot ide:0:0 +vnc:password XXXXXXXX +ide:0:0 403c9a86-0aab-4e47-aa95-e9768021c4c1 +ide:0:0:read:requests 0 +ide:0:0:read:bytes 0 +vnc auto +vnc:ip 83.222.249.221 +tx:packets 0 +tx 0 +rx 0 +smp 1 +mem 512 +nic:0:model e1000 +status active +started 1292695612 +rx:packets 0 +user 2f6244eb-50bc-4403-847e-f03cc3706a1f +ide:0:0:media disk +name adriancole.test +persistent true +nic:0:block tcp/43594 tcp/5902 udp/5060 tcp/5900 tcp/5901 tcp/21 tcp/22 tcp/23 tcp/25 tcp/110 tcp/143 tcp/43595 +server bd98615a-6f74-4d63-ad1e-b13338b9356a +ide:0:0:write:bytes 0 +cpu 1000 \ No newline at end of file diff --git a/apis/elasticstack/src/test/resources/server2.txt b/apis/elasticstack/src/test/resources/server2.txt new file mode 100644 index 0000000000..b3e91784f8 --- /dev/null +++ b/apis/elasticstack/src/test/resources/server2.txt @@ -0,0 +1,41 @@ +ide:0:0:write:requests 3698 +boot ide:0:0 +vnc:password HfHzVmLT +ide:0:0 4af85ed3-0caa-4736-8a26-a33d7de0a122 +ide:0:0:read:requests 11154 +ide:0:0:read:bytes 45686784 +vnc:ip 46.20.114.124 +tx:packets 31 +tx 2550 +rx 455530 +smp 1 +mem 1024 +nic:0:model e1000 +status active +started 1291493868 +rx:packets 7583 +user 2f6244eb-50bc-4403-847e-f03cc3706a1f +name jo +persistent true +nic:0:block tcp/43594 tcp/5902 udp/5060 tcp/5900 tcp/5901 tcp/21 tcp/22 tcp/23 tcp/25 tcp/110 tcp/143 tcp/43595 +server f8bee9cd-8e4b-4a05-8593-1314e3bfe49b +nic:0:dhcp auto +nic:0:dhcp:ip 46.20.114.124 +ide:0:0:write:bytes 15147008 +cpu 2000 + +status stopped +name Demo +mem 1024 +boot ide:0:0 +vnc:password HWbjvrg2 +persistent true +server 0f962616-2071-4173-be79-7dd084271edf +smp auto +nic:0:dhcp auto +user 2f6244eb-50bc-4403-847e-f03cc3706a1f +nic:0:model e1000 +vnc:ip auto +ide:0:0 853bb98a-4fff-4c2f-a265-97c363f19ea5 +cpu 2000 +ide:0:0:media cdrom diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java index 9b9309e3fe..2bb4317db6 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonPropertiesBuilder.java @@ -37,7 +37,7 @@ public class ElasticHostsBlueSquareLondonPropertiesBuilder extends ElasticStackP Properties properties = super.defaultProperties(); properties.setProperty(PROPERTY_ISO3166_CODES, "GB-LND"); properties.setProperty(PROPERTY_ENDPOINT, "https://api.lon-b.elastichosts.com"); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); + properties.setProperty(PROPERTY_API_VERSION, "2.0"); return properties; } diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java index b1e022b6a2..c301977b7a 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerAsyncClient.java @@ -29,7 +29,7 @@ import org.jclouds.softlayer.features.VirtualGuestAsyncClient; *

* * @see SoftLayerClient - * @see + * @see * @author Adrian Cole */ public interface SoftLayerAsyncClient { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java index adc64ec552..1656ff1c8e 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerClient.java @@ -32,7 +32,7 @@ import org.jclouds.softlayer.features.VirtualGuestClient; *

* * @see SoftLayerAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 60, timeUnit = TimeUnit.SECONDS) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java index fe105fc989..be58688ac3 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/Datacenter.java @@ -21,7 +21,7 @@ package org.jclouds.softlayer.domain; /** * * @author Adrian Cole - * @see */ public class Datacenter implements Comparable { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java index cb9ce12223..c8c43ab0cc 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductPackage.java @@ -18,19 +18,19 @@ */ package org.jclouds.softlayer.domain; -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import java.util.Set; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; +import static com.google.common.base.Preconditions.checkNotNull; /** * The SoftLayer_Product_Package data type contains information about packages * from which orders can be generated. Packages contain general information * regarding what is in them, where they are currently sold, availability, and * pricing. - * + * * @author Adrian Cole * @see { private String name; private String description; private Set items = Sets.newLinkedHashSet(); + private Set datacenters = Sets.newLinkedHashSet(); public Builder id(long id) { this.id = id; @@ -65,23 +66,26 @@ public class ProductPackage implements Comparable { return this; } - public Builder productItem(ProductItem items) { - this.items.add(checkNotNull(items, "items")); - return this; - } - public Builder items(Iterable items) { this.items = ImmutableSet. copyOf(checkNotNull(items, "items")); return this; } + public Builder datacenters(Iterable datacenters) { + this.datacenters = ImmutableSet. copyOf(checkNotNull(datacenters, "datacenters")); + return this; + } + public ProductPackage build() { - return new ProductPackage(id, name, description, items); + return new ProductPackage(id, name, description, items, datacenters); } public static Builder fromProductPackage(ProductPackage in) { - return ProductPackage.builder().id(in.getId()).name(in.getName()).description(in.getDescription()) - .items(in.getItems()); + return ProductPackage.builder().id(in.getId()) + .name(in.getName()) + .description(in.getDescription()) + .items(in.getItems()) + .datacenters(in.getDatacenters()); } } @@ -89,17 +93,19 @@ public class ProductPackage implements Comparable { private String name; private String description; private Set items = Sets.newLinkedHashSet(); + private Set locations = Sets.newLinkedHashSet(); // for deserializer ProductPackage() { } - public ProductPackage(long id, String name, String description, Iterable items) { + public ProductPackage(long id, String name, String description, Iterable items, Iterable datacenters) { this.id = id; this.name = name; this.description = description; this.items = ImmutableSet. copyOf(checkNotNull(items, "items")); + this.locations = ImmutableSet. copyOf(checkNotNull(datacenters, "datacenters")); } @Override @@ -133,7 +139,7 @@ public class ProductPackage implements Comparable { } /** - * + * * @return A collection of valid items available for purchase in this * package. */ @@ -141,6 +147,14 @@ public class ProductPackage implements Comparable { return items; } + /** + * + * @return A collection of valid locations for this package. + */ + public Set getDatacenters() { + return locations; + } + public Builder toBuilder() { return Builder.fromProductPackage(this); } @@ -169,6 +183,6 @@ public class ProductPackage implements Comparable { @Override public String toString() { - return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + "]"; + return "ProductPackage [id=" + id + ", name=" + name + ", description=" + description + ", items=" + items + ", datacenters=" + locations + "]"; } } diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java index 8c080da7be..7823d95f0a 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java @@ -34,7 +34,7 @@ import com.google.gson.annotations.SerializedName; * * @author Adrian Cole * @see */ public class VirtualGuest implements Comparable { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java index 5abb61e874..37efa6a48f 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterAsyncClient.java @@ -41,7 +41,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* * @see DatacenterClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java index b8ca23ac25..bd71990a7b 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/DatacenterClient.java @@ -29,10 +29,10 @@ import org.jclouds.softlayer.domain.Datacenter; *

* * @see DatacenterAsyncClient - * @see + * @see * @author Adrian Cole */ -@Timeout(duration = 4, timeUnit = TimeUnit.SECONDS) +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface DatacenterClient { /** diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java index e7805cda98..f060993a5c 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageAsyncClient.java @@ -18,12 +18,7 @@ */ package org.jclouds.softlayer.features; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - +import com.google.common.util.concurrent.ListenableFuture; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.QueryParams; @@ -31,20 +26,24 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.softlayer.domain.ProductPackage; -import com.google.common.util.concurrent.ListenableFuture; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; /** * Provides asynchronous access to ProductPackage via their REST API. *

- * + * * @see ProductPackageClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) @Path("/v{jclouds.api-version}") public interface ProductPackageAsyncClient { - public static String PRODUCT_MASK = "items"; + public static String PRODUCT_MASK = "items;locations"; /** * @see ProductPackageClient#getProductPackage diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java index dbc6af02a3..09339ba18b 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/ProductPackageClient.java @@ -28,7 +28,7 @@ import org.jclouds.softlayer.domain.ProductPackage; *

* * @see ProductPackageAsyncClient - * @see + * @see * @author Adrian Cole */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java index c7d7ded984..78f327b97b 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestAsyncClient.java @@ -42,7 +42,7 @@ import com.google.common.util.concurrent.ListenableFuture; *

* * @see VirtualGuestClient - * @see + * @see * @author Adrian Cole */ @RequestFilters(BasicAuthentication.class) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java index 8d969355c6..08d0ec2fbf 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestClient.java @@ -29,10 +29,10 @@ import org.jclouds.softlayer.domain.VirtualGuest; *

* * @see VirtualGuestAsyncClient - * @see + * @see * @author Adrian Cole */ -@Timeout(duration = 4, timeUnit = TimeUnit.SECONDS) +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface VirtualGuestClient { /** diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java index 90dd1fa6a7..faae225fba 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java @@ -43,7 +43,7 @@ public class ProductPackageAsyncClientTest extends BaseSoftLayerAsyncClientTest< assertRequestLineEquals( httpRequest, - "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items HTTP/1.1"); + "GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/1234.json?objectMask=items%3Blocations HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertPayloadEquals(httpRequest, null, null, false); diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java index 353d479b13..32ded9be2c 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.softlayer.features; import static org.testng.Assert.assertTrue; +import org.jclouds.softlayer.domain.Datacenter; import org.jclouds.softlayer.domain.ProductItem; import org.jclouds.softlayer.domain.ProductItemPrice; import org.jclouds.softlayer.domain.ProductPackage; @@ -57,6 +58,11 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest { // assertEquals(item.getId(), newDetails.getId()); checkProductItem(item); } + + assertTrue(response.getDatacenters().size() > 0); + for (Datacenter datacenter : response.getDatacenters()) { + checkDatacenter(datacenter); + } } } @@ -81,4 +87,10 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest { assert price.getRecurringFee() != null || price.getHourlyRecurringFee() != null : price; } + private void checkDatacenter(Datacenter datacenter) { + assert datacenter.getId() > 0 : datacenter; + assert datacenter.getName() != null : datacenter; + assert datacenter.getLongName() != null : datacenter; + } + }