mirror of https://github.com/apache/jclouds.git
workaround eucalyptus problem
This commit is contained in:
parent
754a511ec2
commit
b1da61fa03
|
@ -33,8 +33,7 @@ import com.google.common.collect.Maps;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class DescribeRegionsResponseHandler extends
|
public class DescribeRegionsResponseHandler extends ParseSax.HandlerWithResult<Map<String, URI>> {
|
||||||
ParseSax.HandlerWithResult<Map<String, URI>> {
|
|
||||||
private StringBuilder currentText = new StringBuilder();
|
private StringBuilder currentText = new StringBuilder();
|
||||||
|
|
||||||
private Map<String, URI> regionEndpoints = Maps.newHashMap();
|
private Map<String, URI> regionEndpoints = Maps.newHashMap();
|
||||||
|
@ -52,11 +51,11 @@ public class DescribeRegionsResponseHandler extends
|
||||||
String pending = currentText.toString().trim();
|
String pending = currentText.toString().trim();
|
||||||
if (pending.indexOf("Walrus") == -1)
|
if (pending.indexOf("Walrus") == -1)
|
||||||
region = pending;
|
region = pending;
|
||||||
} else if (qName.equals("regionEndpoint")) {
|
// Eucalyptus uses regionUrl
|
||||||
|
} else if (qName.equals("regionEndpoint") || qName.equals("regionUrl")) {
|
||||||
String pending = currentText.toString().trim();
|
String pending = currentText.toString().trim();
|
||||||
if (pending.indexOf("Walrus") == -1)
|
if (pending.indexOf("Walrus") == -1)
|
||||||
regionEndpoint = URI.create(pending.startsWith("http") ? pending
|
regionEndpoint = URI.create(pending.startsWith("http") ? pending : String.format("https://%s", pending));
|
||||||
: String.format("https://%s", pending));
|
|
||||||
} else if (qName.equals("item") && region != null) {
|
} else if (qName.equals("item") && region != null) {
|
||||||
regionEndpoints.put(region, regionEndpoint);
|
regionEndpoints.put(region, regionEndpoint);
|
||||||
this.region = null;
|
this.region = null;
|
||||||
|
|
|
@ -66,16 +66,16 @@ public class DescribeAvailabilityZonesResponseHandlerTest extends BaseHandlerTes
|
||||||
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
Set<AvailabilityZoneInfo> expected = ImmutableSet.<AvailabilityZoneInfo> of(
|
||||||
|
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet.<String> of()),
|
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1A, "available", Region.US_EAST_1, ImmutableSet.<String> of()),
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet
|
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1B, "available", Region.US_EAST_1, ImmutableSet
|
||||||
.<String> of()),
|
.<String> of()),
|
||||||
|
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1, ImmutableSet
|
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1C, "available", Region.US_EAST_1, ImmutableSet
|
||||||
.<String> of("our service is awesome")),
|
.<String> of("our service is awesome")),
|
||||||
|
|
||||||
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1, ImmutableSet
|
new AvailabilityZoneInfo(AvailabilityZone.US_EAST_1D, "downlikeaclown", Region.US_EAST_1, ImmutableSet
|
||||||
.<String> of()));
|
.<String> of()));
|
||||||
Set<AvailabilityZoneInfo> result = factory.create(
|
Set<AvailabilityZoneInfo> result = factory.create(
|
||||||
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
injector.getInstance(DescribeAvailabilityZonesResponseHandler.class)).parse(is);
|
||||||
|
|
||||||
assertEquals(result, expected);
|
assertEquals(result, expected);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,21 @@ public class DescribeRegionsResponseHandlerTest extends BaseHandlerTest {
|
||||||
|
|
||||||
assertEquals(result, expected);
|
assertEquals(result, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEuc2() {
|
||||||
|
|
||||||
|
InputStream is = Utils
|
||||||
|
.toInputStream("<?xml version=\"1.0\" ?><DescribeRegionsResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-11-30/\"><requestId>1LAQRTCLTLPS6CEIC627</requestId><regionInfo><item><regionUrl>http://10.255.255.1:8773/services/Cloud</regionUrl><regionName>nova</regionName></item></regionInfo></DescribeRegionsResponse>");
|
||||||
|
|
||||||
|
Map<String, URI> expected = ImmutableMap.<String, URI> of("nova",
|
||||||
|
URI.create("http://10.255.255.1:8773/services/Cloud"));
|
||||||
|
|
||||||
|
Map<String, URI> result = factory.create(
|
||||||
|
injector.getInstance(DescribeRegionsResponseHandler.class)).parse(
|
||||||
|
is);
|
||||||
|
|
||||||
|
assertEquals(result, expected);
|
||||||
|
}
|
||||||
|
|
||||||
public void testUnsupportedAdditionalRegionDoesntBreak() {
|
public void testUnsupportedAdditionalRegionDoesntBreak() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue