Updated Branches: refs/heads/master fe76cf8a6 -> 9d28ffeb0
CS-14985. Fix for ec2-describe-snapshots filters. Component: awsapi. Signed-off-by: Likitha Shetty <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/9d28ffeb Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/9d28ffeb Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/9d28ffeb Branch: refs/heads/master Commit: 9d28ffeb026a3cf2800f473dda5d62c24866bb72 Parents: fe76cf8 Author: Likitha Shetty <[email protected]> Authored: Fri Jun 15 18:22:48 2012 +0530 Committer: prachi <[email protected]> Committed: Tue Jun 19 12:14:07 2012 -0700 ---------------------------------------------------------------------- .../service/core/ec2/EC2SnapshotFilterSet.java | 19 +++++++++++--- 1 files changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/9d28ffeb/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java ---------------------------------------------------------------------- diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java index c69191c..9e3e4ad 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SnapshotFilterSet.java @@ -18,13 +18,16 @@ package com.cloud.bridge.service.core.ec2; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.TimeZone; import com.cloud.bridge.service.UserContext; import com.cloud.bridge.service.exception.EC2ServiceException; import com.cloud.bridge.util.DateHelper; +import com.cloud.bridge.util.EC2RestAuth; public class EC2SnapshotFilterSet { @@ -121,7 +124,12 @@ public class EC2SnapshotFilterSet { } else if (filterName.equalsIgnoreCase( "status" )) { - return containsString( "completed", valueSet ); + if ( snap.getState().equalsIgnoreCase("backedup")) + return containsString( "completed", valueSet ); + else if (snap.getState().equalsIgnoreCase("creating") || snap.getState().equalsIgnoreCase("backingup")) + return containsString( "pending", valueSet ); + else + return containsString( "error", valueSet ); } else if (filterName.equalsIgnoreCase( "volume-id" )) { @@ -160,11 +168,14 @@ public class EC2SnapshotFilterSet { private boolean containsTime( Calendar lookingFor, String[] set ) throws ParseException { + lookingFor.setTimeZone(TimeZone.getTimeZone("GMT")); + Date lookingForDate = lookingFor.getTime(); for (String s : set) { //System.out.println( "contsinsCalendar: " + lookingFor + " " + set[i] ); - Calendar toMatch = Calendar.getInstance(); - toMatch.setTime( DateHelper.parseISO8601DateString( s )); - if (0 == lookingFor.compareTo( toMatch )) return true; + Calendar toMatch = EC2RestAuth.parseDateString(s); + toMatch.setTimeZone(TimeZone.getTimeZone("GMT")); + Date toMatchDate = toMatch.getTime(); + if ( 0 == lookingForDate.compareTo(toMatchDate)) return true; } return false; }
