CS-14986. ec2-describe-volumes supported filters. Component: awsapi. Fix for two filters, attachment.attach-time and create-time.

Signed-off-by: Likitha Shetty <likitha.shetty@citrix.com>
This commit is contained in:
Likitha Shetty 2012-06-06 11:09:49 +05:30 committed by prachi
parent 3a89d33e92
commit 650386c994
2 changed files with 27 additions and 12 deletions

View File

@ -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 );
}

View File

@ -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 )