diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java index 2157cf76ac..591574e9d7 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadata.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.nova.v1_1.compute.functions; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.transform; @@ -51,9 +50,11 @@ import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone; import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndId; +import org.jclouds.util.InetAddresses2; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.net.InetAddresses; @@ -103,14 +104,20 @@ public class ServerInZoneToNodeMetadata implements Function isPrivateAddress = new Predicate
() { + public boolean apply(Address in) { + return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr()); + } + }; + public static final Predicate isInet4Address = new Predicate() { @Override public boolean apply(String input) { diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Address.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Address.java index 3053ccf162..7faa0b49e7 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Address.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Address.java @@ -30,42 +30,7 @@ import com.google.common.base.Objects; * @author AdrianCole */ public class Address { - - /** - * Relations associated with resources. - */ - public static enum Type { - /** - * internet routable address - */ - INTERNET, - /** - * publically routable address - */ - PUBLIC, - /** - * address that is not publicly routable. - */ - PRIVATE, - /** - * the value returned by the OpenStack service was not recognized. - */ - UNRECOGNIZED; - - public String value() { - return name().toLowerCase(); - } - - public static Type fromValue(String v) { - try { - return valueOf(v.toUpperCase()); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - } - + public static Builder builder() { return new Builder(); } diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java index 985066392c..576d2a33ad 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.nova.v1_1.domain; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.Collection; import java.util.Date; import java.util.Map; import java.util.Set; @@ -29,20 +28,14 @@ import org.jclouds.compute.domain.NodeState; import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.domain.Link; import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.nova.v1_1.domain.Address.Type; import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; -import org.jclouds.util.InetAddresses2; import org.jclouds.util.Multimaps2; -import com.google.common.base.Predicate; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Predicates; import com.google.common.base.Strings; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Iterables; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; @@ -122,7 +115,7 @@ public class Server extends Resource { private Resource flavor; private Map metadata = Maps.newHashMap(); // TODO: get gson multimap ad - private Multimap addresses = LinkedHashMultimap.create(); + private Multimap addresses = LinkedHashMultimap.create(); private String adminPass; private String keyName; @@ -233,59 +226,11 @@ public class Server extends Resource { /** * @see Server#getAddresses() */ - public Builder addresses(Multimap addresses) { + public Builder addresses(Multimap addresses) { this.addresses = ImmutableMultimap.copyOf(checkNotNull(addresses, "addresses")); return this; } - - /** - * @see Server#getPrivateAddresses() - */ - public Builder privateAddresses(Address... privateAddresses) { - return privateAddresses(ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"))); - } - - /** - * @see Server#getPrivateAddresses() - */ - public Builder privateAddresses(Set
privateAddresses) { - this.addresses.replaceValues(Address.Type.PRIVATE, ImmutableSet.copyOf(checkNotNull(privateAddresses, - "privateAddresses"))); - return this; - } - /** - * @see Server#getInternetAddresses() - */ - public Builder internetAddresses(Address... internetAddresses) { - return internetAddresses(ImmutableSet.copyOf(checkNotNull(internetAddresses, "internetAddresses"))); - } - - /** - * @see Server#getInternetAddresses() - */ - public Builder internetAddresses(Set
internetAddresses) { - this.addresses.replaceValues(Address.Type.INTERNET, ImmutableSet.copyOf(checkNotNull(internetAddresses, - "internetAddresses"))); - return this; - } - - /** - * @see Server#getPublicAddresses() - */ - public Builder publicAddresses(Address... publicAddresses) { - return publicAddresses(ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"))); - } - - /** - * @see Server#getPublicAddresses() - */ - public Builder publicAddresses(Set
publicAddresses) { - this.addresses.replaceValues(Address.Type.PUBLIC, ImmutableSet.copyOf(checkNotNull(publicAddresses, - "publicAddresses"))); - return this; - } - /** * @see Server#getAdminPass() */ @@ -376,13 +321,13 @@ public class Server extends Resource { @SerializedName("config_drive") protected final String configDrive; // TODO: get gson multimap adapter! - protected final Map> addresses; + protected final Map> addresses; protected final Map metadata; protected Server(String id, String name, Set links, @Nullable String uuid, String tenantId, String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4, @Nullable String accessIPv6, Status status, @Nullable String configDrive, Resource image, Resource flavor, - String adminPass, @Nullable String keyName, Multimap addresses, + String adminPass, @Nullable String keyName, Multimap addresses, Map metadata) { super(id, name, links); this.uuid = uuid; // TODO: see what version this came up in @@ -470,75 +415,11 @@ public class Server extends Resource { return ImmutableMap.copyOf(Maps.filterValues(this.metadata, Predicates.notNull())); } - /** - * @return the private ip addresses assigned to the server - */ - public Set
getPrivateAddresses() { - Collection
privateAddresses = getAddresses().get(Address.Type.PRIVATE); - if (privateAddresses == null) { - return ImmutableSet.
of(); - } else { - return ImmutableSet.copyOf(privateAddresses); - } - } - - /** - * @return the internet ip addresses assigned to the server - * @since essex - */ - public Set
getInternetAddresses() { - Collection
internetAddrs = getAddresses().get(Address.Type.INTERNET); - if (internetAddrs == null) { - return ImmutableSet.
of(); - } else { - return ImmutableSet.copyOf(internetAddrs); - } - } - - /** - * @return the public ip addresses assigned to the server - */ - public Set
getPublicAddresses() { - Collection
publicAddrs = getAddresses().get(Address.Type.PUBLIC); - if (publicAddrs == null) { - return ImmutableSet.
of(); - } else { - return ImmutableSet.copyOf(publicAddrs); - } - } - /** * @return the ip addresses assigned to the server */ - public Multimap getAddresses() { - - Set
privateAddresses = addresses.get(Address.Type.PRIVATE); - - if (privateAddresses != null && privateAddresses.size() > 1) { - return hackNeededForFloatingIpsFixedInEssex(privateAddresses); - } else { - return Multimaps2.fromOldSchool(addresses); - } - - } - - private Multimap hackNeededForFloatingIpsFixedInEssex(Set
privateAddresses) { - Set
publicAddresses = addresses.get(Address.Type.PUBLIC); - ImmutableSetMultimap.Builder returnMapBuilder = new ImmutableSetMultimap.Builder(); - if (publicAddresses != null) { - returnMapBuilder.putAll(Address.Type.PUBLIC, publicAddresses); - } - returnMapBuilder.putAll(Address.Type.PRIVATE, Iterables.filter(privateAddresses, IsPrivateAddress.INSTANCE)); - returnMapBuilder.putAll(Address.Type.PUBLIC, Iterables.filter(privateAddresses, Predicates - .not(IsPrivateAddress.INSTANCE))); - return returnMapBuilder.build(); - } - - private static enum IsPrivateAddress implements Predicate
{ - INSTANCE; - public boolean apply(Address in) { - return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr()); - } + public Multimap getAddresses() { + return Multimaps2.fromOldSchool(addresses); } /** diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java index 1db260412f..b3262d325b 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClientLiveTest.java @@ -181,7 +181,7 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest { try { Server server = client.getServer(serverId); boolean ipInServerAddresses = false; - Multimap addresses = server.getAddresses(); + Multimap addresses = server.getAddresses(); for (Address address : addresses.values()) { if (address.getAddr().equals(floatingIP)) { ipInServerAddresses = true; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java index f7e3681aad..9105e3a6ed 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java @@ -18,22 +18,17 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import java.io.InputStream; import java.net.URI; import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.rest.config.CredentialStoreModule; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.io.InputSupplier; import com.google.inject.Module; /** @@ -91,12 +86,4 @@ public abstract class BaseNovaComputeServiceContextExpectTest extends BaseNov return new NovaApiMetadata(); } - // isolate tests from eachother, as default credentialStore is static - protected Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( - new ConcurrentHashMap>())); - - @Override - protected Module createModule() { - return credentialStoreModule; - } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java new file mode 100644 index 0000000000..a4e7f51e51 --- /dev/null +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java @@ -0,0 +1,164 @@ +/** + * 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.openstack.nova.v1_1.parse; + +import java.net.URI; +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseSetParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.domain.Link.Relation; +import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.openstack.nova.v1_1.domain.Address; +import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ParseServerDetailsEssexTest") +public class ParseServerDetailsEssexTest extends BaseSetParserTest { + + @Override + public String resource() { + return "/server_list_details_essex.json"; + } + + @Override + @SelectJson("servers") + @Consumes(MediaType.APPLICATION_JSON) + public Set expected() { + return ImmutableSet.of( + Server.builder() + .addresses(ImmutableMultimap.builder() + .putAll("Net TenantA Front-Middle", Address.createV4("172.16.11.5")) + .putAll("Public network", Address.createV4("172.16.1.13"), Address.createV4("10.193.112.119")).build()) + .links( + Link.create( + Relation.SELF, + URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207")), + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207"))) + .image( + Resource.builder() + .id("416af940-2d3c-4a7c-977c-a9030685ad5e") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build()) + .flavor( + Resource.builder() + .id("1") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build()) + .id("0c80b392-db30-4736-ae02-4480090f1207") + .userId("df13814f6c354d00a8acf66502836323") + .status(Server.Status.ACTIVE) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:21:33Z")) + .hostId("03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408") + .name("VM proxy") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:21:23Z")) + .tenantId("8d10e6646d5d4585937395b04839a353").build(), + Server.builder() + .addresses(ImmutableMultimap.builder() + .putAll("Net TenantA Front-Middle", Address.createV4("172.16.11.4")) + .putAll("Net TenantA Middle-Back", Address.createV4("172.16.12.5")).build()) + .links( + Link.create( + Relation.SELF, + URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236")), + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236"))) + .image( + Resource.builder() + .id("416af940-2d3c-4a7c-977c-a9030685ad5e") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build()) + .flavor( + Resource.builder() + .id("1") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build()) + .id("b332b5cd-535e-4677-b68e-fc8badc13236") + .userId("df13814f6c354d00a8acf66502836323") + .status(Server.Status.ACTIVE) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:18:58Z")) + .hostId("e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc") + .name("VM blog") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:18:48Z")) + .tenantId("8d10e6646d5d4585937395b04839a353").build(), + Server.builder() + .addresses(ImmutableMultimap.builder() + .putAll("Net TenantA Middle-Back", Address.createV4("172.16.12.4")).build()) + .links( + Link.create( + Relation.SELF, + URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21")), + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21"))) + .image( + Resource.builder() + .id("416af940-2d3c-4a7c-977c-a9030685ad5e") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build()) + .flavor( + Resource.builder() + .id("1") + .links( + Link.create( + Relation.BOOKMARK, + URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build()) + .id("f9d43436-4572-4c9b-9b74-5fa6890a2f21") + .userId("df13814f6c354d00a8acf66502836323") + .status(Server.Status.ACTIVE) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:15:09Z")) + .hostId("03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408") + .name("VM MySQL") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:14:56Z")) + .tenantId("8d10e6646d5d4585937395b04839a353").build()); + } + + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } +} diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java index f249f3bdb1..7e54bd06c8 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java @@ -37,6 +37,7 @@ import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; import com.google.inject.Guice; import com.google.inject.Injector; @@ -96,9 +97,11 @@ public class ParseServerTest extends BaseItemParserTest { .metadata( new ImmutableMap.Builder().put("Server Label", "Web Head 1") .put("Image Version", "2.1").build()) - .publicAddresses(Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"), + .addresses(ImmutableMultimap.builder() + .putAll("public", Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"), Address.createV4("67.23.10.131"), Address.createV6("::babe:4317:0A83")) - .privateAddresses(Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16")).build(); + .putAll("private", Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16")) + .build()).build(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java index b5272f2cbc..15a0dae5bc 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java @@ -36,6 +36,7 @@ import org.jclouds.openstack.nova.v1_1.domain.Server.Status; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableMultimap; import com.google.inject.Guice; import com.google.inject.Injector; @@ -90,7 +91,7 @@ public class ParseServerWithInternetAddressesTest extends BaseItemParserTest { +public class PublicIpsInPrivateAddressBlockExpectTest extends BaseItemParserTest { @Override public String resource() { @@ -86,8 +87,8 @@ public class PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100"))) .build()) .metadata(ImmutableMap.of("Name", "hpcloud-computes")) - .privateAddresses(Address.createV4("10.6.39.189")) - .publicAddresses(Address.createV4("15.185.181.94")) + .addresses(ImmutableMultimap.builder() + .putAll("private", Address.createV4("10.6.39.189"), Address.createV4("15.185.181.94")).build()) .links( Link.create(Relation.SELF, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662")), Link.create(Relation.BOOKMARK, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662"))).build(); diff --git a/apis/openstack-nova/src/test/resources/server_list_details_essex.json b/apis/openstack-nova/src/test/resources/server_list_details_essex.json new file mode 100644 index 0000000000..9ca9445f18 --- /dev/null +++ b/apis/openstack-nova/src/test/resources/server_list_details_essex.json @@ -0,0 +1,152 @@ +{ + "servers": [{ + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Front-Middle": [{ + "version": 4, + "addr": "172.16.11.5" + }], + "Public network": [{ + "version": 4, + "addr": "172.16.1.13" + }, { + "version": 4, + "addr": "10.193.112.119" + }] + }, + "links": [{ + "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", + "rel": "self" + }, { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", + "rel": "bookmark" + }], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + }] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + }] + }, + "id": "0c80b392-db30-4736-ae02-4480090f1207", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:21:33Z", + "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", + "key_name": "", + "name": "VM proxy", + "created": "2012-04-12T11:21:23Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + }, { + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Front-Middle": [{ + "version": 4, + "addr": "172.16.11.4" + }], + "Net TenantA Middle-Back": [{ + "version": 4, + "addr": "172.16.12.5" + }] + }, + "links": [{ + "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", + "rel": "self" + }, { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", + "rel": "bookmark" + }], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + }] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + }] + }, + "id": "b332b5cd-535e-4677-b68e-fc8badc13236", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:18:58Z", + "hostId": "e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc", + "key_name": "", + "name": "VM blog", + "created": "2012-04-12T11:18:48Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + }, { + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Middle-Back": [{ + "version": 4, + "addr": "172.16.12.4" + }] + }, + "links": [{ + "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "rel": "self" + }, { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "rel": "bookmark" + }], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + }] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [{ + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + }] + }, + "id": "f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:15:09Z", + "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", + "key_name": "", + "name": "VM MySQL", + "created": "2012-04-12T11:14:56Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + }] +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java index 88e6758087..8e77a564be 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java @@ -22,11 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; @@ -57,11 +59,13 @@ import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.internal.BaseHttpCommandExecutorService; import org.jclouds.http.internal.HttpWire; +import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.RestApiMetadata; +import org.jclouds.rest.config.CredentialStoreModule; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import org.w3c.dom.Node; @@ -74,6 +78,7 @@ import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.io.InputSupplier; import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.inject.AbstractModule; @@ -540,11 +545,13 @@ public abstract class BaseRestClientExpectTest { this.api = RestApiMetadata.class.cast(builder.getApiMetadata()).getApi(); + // isolate tests from eachother, as default credentialStore is static return builder.credentials(identity, credential).modules( - ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)).overrides(setupProperties()) + ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), new CredentialStoreModule(new CopyInputStreamInputSupplierMap( + new ConcurrentHashMap>())), module)).overrides(setupProperties()) .buildInjector(); } - + /** * override this to supply context-specific parameters during tests. */