You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by li...@citrix.com on 2012/06/15 14:56:10 UTC
[PATCH] CS-14985. Fix for ec2-describe-snapshots filters. Component: awsapi.
From: Likitha Shetty <li...@citrix.com>
Signed-off-by: Likitha Shetty <li...@citrix.com>
---
.../service/core/ec2/EC2SnapshotFilterSet.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
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;
}
--
1.7.5.4
RE: [PATCH] CS-14985. Fix for ec2-describe-snapshots filters.
Component: awsapi.
Posted by Prachi Damle <Pr...@citrix.com>.
Likitha,
Changes for this patch look fine. I will apply this patch.
Thanks,
Prachi
-----Original Message-----
From: likitha.shetty@citrix.com [mailto:likitha.shetty@citrix.com]
Sent: Friday, June 15, 2012 5:56 AM
To: cloudstack-dev@incubator.apache.org
Cc: Likitha Shetty
Subject: [PATCH] CS-14985. Fix for ec2-describe-snapshots filters. Component: awsapi.
From: Likitha Shetty <li...@citrix.com>
Signed-off-by: Likitha Shetty <li...@citrix.com>
---
.../service/core/ec2/EC2SnapshotFilterSet.java | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
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;
}
--
1.7.5.4