From ca64722a0f6df193795ab5e43fdd916abf9388cd Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 16 Jun 2010 12:26:35 -0400 Subject: [PATCH] Issue 27: adjusted for incorrect 0.0.0.0 ips and inconsistent timestamp formats in eucalyptus --- .../aws/ec2/xml/BaseReservationHandler.java | 13 ++++++- .../DescribeInstancesResponseHandlerTest.java | 6 +-- .../resources/ec2/describe_instances_euc.xml | 39 +++++++++++++++++++ 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 aws/core/src/test/resources/ec2/describe_instances_euc.xml diff --git a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java index bd87a928be..d84bbea7c4 100644 --- a/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java +++ b/aws/core/src/main/java/org/jclouds/aws/ec2/xml/BaseReservationHandler.java @@ -132,6 +132,9 @@ public abstract class BaseReservationHandler extends HandlerWithResult { amiLaunchIndex = currentOrNull(); } else if (qName.equals("dnsName")) { dnsName = currentOrNull(); + // Eucalyptus + if ("0.0.0.0".equals(dnsName)) + dnsName = null; } else if (qName.equals("imageId")) { imageId = currentOrNull(); } else if (qName.equals("instanceId")) { @@ -147,7 +150,12 @@ public abstract class BaseReservationHandler extends HandlerWithResult { } else if (qName.equals("keyName")) { keyName = currentOrNull(); } else if (qName.equals("launchTime")) { - launchTime = dateService.iso8601DateParse(currentOrNull()); + try { + launchTime = dateService.iso8601DateParse(currentOrNull()); + } catch (RuntimeException e) { + // Eucalyptus + launchTime = dateService.iso8601SecondsDateParse(currentOrNull()); + } } else if (qName.equals("enabled")) { monitoring = Boolean.parseBoolean(currentOrNull()); } else if (qName.equals("availabilityZone")) { @@ -156,6 +164,9 @@ public abstract class BaseReservationHandler extends HandlerWithResult { platform = currentOrNull(); } else if (qName.equals("privateDnsName")) { privateDnsName = currentOrNull(); + // Eucalyptus + if ("0.0.0.0".equals(privateDnsName)) + privateDnsName = null; } else if (qName.equals("privateIpAddress")) { privateIpAddress = currentOrNull(); } else if (qName.equals("ramdiskId")) { diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java index 0be3545f6e..ceb3fb38ab 100644 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/ec2/xml/DescribeInstancesResponseHandlerTest.java @@ -133,9 +133,9 @@ public class DescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest { contents.add(new Reservation(defaultRegion, ImmutableSet.of("default"), ImmutableSet.of(new RunningInstance(defaultRegion, ImmutableSet .of("jclouds#euc"), "1", null, "emi-9ACB1363", "i-3FFA0762", - InstanceState.SHUTTING_DOWN, InstanceType.M1_LARGE, - "10.7.0.179", "eki-6CBD12F2", "jclouds#euc-17", dateService - .iso8601DateParse("2010-06-16T03:06:19.771Z"), false, + InstanceState.SHUTTING_DOWN, InstanceType.M1_LARGE, null, + "eki-6CBD12F2", "jclouds#euc-17", dateService + .iso8601DateParse("2010-06-16T03:06:19.000Z"), false, "open", null, null, "10.7.0.179", ImmutableSet. of(), "eri-A97113E4", null, null, null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap diff --git a/aws/core/src/test/resources/ec2/describe_instances_euc.xml b/aws/core/src/test/resources/ec2/describe_instances_euc.xml new file mode 100644 index 0000000000..7ee16645a2 --- /dev/null +++ b/aws/core/src/test/resources/ec2/describe_instances_euc.xml @@ -0,0 +1,39 @@ + + e323d0bd-48a2-401b-aeee-1cbf653bc6db + + + r-4D2A08AD + jclouds + + + jclouds#euc + + + + + i-3FFA0762 + emi-9ACB1363 + + 32 + shutting-down + + 10.7.0.179 + 0.0.0.0 + jclouds#euc-17 + 1 + + m1.large + 2010-06-16T03:06:19Z + + open + + eki-6CBD12F2 + eri-A97113E4 + + false + + + + + + \ No newline at end of file