|
18 | 18 | import java.text.ParseException; |
19 | 19 | import java.util.ArrayList; |
20 | 20 | import java.util.Calendar; |
| 21 | +import java.util.Date; |
21 | 22 | import java.util.HashMap; |
22 | 23 | import java.util.List; |
23 | 24 | import java.util.Map; |
| 25 | +import java.util.TimeZone; |
24 | 26 |
|
25 | 27 | import com.cloud.bridge.service.UserContext; |
26 | 28 | import com.cloud.bridge.service.exception.EC2ServiceException; |
27 | 29 | import com.cloud.bridge.util.DateHelper; |
| 30 | +import com.cloud.bridge.util.EC2RestAuth; |
28 | 31 |
|
29 | 32 | public class EC2SnapshotFilterSet { |
30 | 33 |
|
@@ -121,7 +124,12 @@ else if (filterName.equalsIgnoreCase( "start-time" )) |
121 | 124 | } |
122 | 125 | else if (filterName.equalsIgnoreCase( "status" )) |
123 | 126 | { |
124 | | - return containsString( "completed", valueSet ); |
| 127 | + if ( snap.getState().equalsIgnoreCase("backedup")) |
| 128 | + return containsString( "completed", valueSet ); |
| 129 | + else if (snap.getState().equalsIgnoreCase("creating") || snap.getState().equalsIgnoreCase("backingup")) |
| 130 | + return containsString( "pending", valueSet ); |
| 131 | + else |
| 132 | + return containsString( "error", valueSet ); |
125 | 133 | } |
126 | 134 | else if (filterName.equalsIgnoreCase( "volume-id" )) |
127 | 135 | { |
@@ -160,11 +168,14 @@ private boolean containsLong( long lookingFor, String[] set ) |
160 | 168 |
|
161 | 169 | private boolean containsTime( Calendar lookingFor, String[] set ) throws ParseException |
162 | 170 | { |
| 171 | + lookingFor.setTimeZone(TimeZone.getTimeZone("GMT")); |
| 172 | + Date lookingForDate = lookingFor.getTime(); |
163 | 173 | for (String s : set) { |
164 | 174 | //System.out.println( "contsinsCalendar: " + lookingFor + " " + set[i] ); |
165 | | - Calendar toMatch = Calendar.getInstance(); |
166 | | - toMatch.setTime( DateHelper.parseISO8601DateString( s )); |
167 | | - if (0 == lookingFor.compareTo( toMatch )) return true; |
| 175 | + Calendar toMatch = EC2RestAuth.parseDateString(s); |
| 176 | + toMatch.setTimeZone(TimeZone.getTimeZone("GMT")); |
| 177 | + Date toMatchDate = toMatch.getTime(); |
| 178 | + if ( 0 == lookingForDate.compareTo(toMatchDate)) return true; |
168 | 179 | } |
169 | 180 | return false; |
170 | 181 | } |
|
0 commit comments