mirror of https://github.com/apache/cloudstack.git
CS-14985. Fix for ec2-describe-snapshots filters. Component: awsapi.
Signed-off-by: Likitha Shetty <likitha.shetty@citrix.com>
This commit is contained in:
parent
fe76cf8a60
commit
9d28ffeb02
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue