From: Likitha Shetty <likitha.she...@citrix.com>
Signed-off-by: Likitha Shetty <likitha.she...@citrix.com> --- .../cloud/bridge/service/EC2SoapServiceImpl.java | 7 ++++- .../service/core/ec2/EC2VolumeFilterSet.java | 32 +++++++++++++------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index de3dcd4..222ef49 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -1130,7 +1130,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 ); } 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 ) -- 1.7.5.4