You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2012/06/15 02:57:13 UTC
[2/2] git commit: CS-14986. ec2-describe-volumes supported filters.
Component: awsapi. Fix for two filters,
attachment.attach-time and create-time.
CS-14986. ec2-describe-volumes supported filters. Component: awsapi. Fix for two filters, attachment.attach-time and create-time.
Signed-off-by: Likitha Shetty <li...@citrix.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/650386c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/650386c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/650386c9
Branch: refs/heads/master
Commit: 650386c99470c7eab5fcea130348fc4c5aa4f0ee
Parents: 3a89d33
Author: Likitha Shetty <li...@citrix.com>
Authored: Wed Jun 6 11:09:49 2012 +0530
Committer: prachi <pr...@cloud.com>
Committed: Thu Jun 14 17:35:55 2012 -0700
----------------------------------------------------------------------
.../cloud/bridge/service/EC2SoapServiceImpl.java | 7 +++-
.../service/core/ec2/EC2VolumeFilterSet.java | 32 ++++++++++-----
2 files changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/650386c9/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
index a70d930..0db172c 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
@@ -1100,7 +1100,12 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface {
String devicePath = engine.cloudDeviceIdToDevicePath( vol.getHypervisor(), vol.getDeviceId());
param5.setDevice( devicePath );
param5.setStatus( toVolumeAttachmentState( vol.getInstanceId(), vol.getVMState()));
- param5.setAttachTime( cal );
+ if (vol.getAttached() == null) {
+ param5.setAttachTime( cal );
+ } else {
+ Calendar attachTime = EC2RestAuth.parseDateString(vol.getAttached());
+ param5.setAttachTime( attachTime );
+ }
param5.setDeleteOnTermination( false );
param4.addItem( param5 );
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/650386c9/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java
index 663544e..0b05204 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2VolumeFilterSet.java
@@ -21,9 +21,10 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.TimeZone;
+import java.util.Date;
import com.cloud.bridge.service.exception.EC2ServiceException;
-import com.cloud.bridge.util.DateHelper;
import com.cloud.bridge.util.EC2RestAuth;
@@ -123,8 +124,14 @@ public class EC2VolumeFilterSet {
return containsString(vol.getState(), valueSet );
else if (filterName.equalsIgnoreCase( "volume-id" ))
return containsString(vol.getId().toString(), valueSet );
- else if (filterName.equalsIgnoreCase( "attachment.attach-time" ))
- return containsTime(vol.getAttached(), valueSet );
+ else if (filterName.equalsIgnoreCase( "attachment.attach-time" )) {
+ if (vol.getAttached() != null)
+ return containsTime(vol.getAttached(), valueSet );
+ else if (vol.getInstanceId() != null)
+ return containsTime(vol.getCreated(), valueSet);
+ else
+ return false;
+ }
else if (filterName.equalsIgnoreCase( "attachment.device" ))
return containsDevice(vol.getDeviceId(), valueSet );
else if (filterName.equalsIgnoreCase( "attachment.instance-id" ))
@@ -155,14 +162,17 @@ public class EC2VolumeFilterSet {
private boolean containsTime(String lookingForDate, String[] set ) throws ParseException
{
- Calendar lookingFor = EC2RestAuth.parseDateString(lookingForDate);
- for (String s : set) {
- Calendar toMatch = Calendar.getInstance();
- toMatch.setTime( DateHelper.parseISO8601DateString( s ));
- if (0 == lookingFor.compareTo( toMatch )) return true;
- }
- return false;
- }
+ Calendar lookingFor = EC2RestAuth.parseDateString(lookingForDate);
+ lookingFor.setTimeZone(TimeZone.getTimeZone("GMT"));
+ Date lookForDate = lookingFor.getTime();
+ for (String s : set) {
+ Calendar toMatch = EC2RestAuth.parseDateString(s);
+ toMatch.setTimeZone(TimeZone.getTimeZone("GMT"));
+ Date toMatchDate = toMatch.getTime();
+ if ( 0 == lookForDate.compareTo(toMatchDate)) return true;
+ }
+ return false;
+ }
private boolean containsDevice(String deviceId, String[] set )