Check if snapshot is in required state returnValue: List[Result, Reason] @Result: PASS if snapshot is in required state, else FAIL @Reason: Reason for failure in case Result is FAIL
(self, apiclient, snapshotstate, timeout=600)
| 1456 | |
| 1457 | |
| 1458 | def validateState(self, apiclient, snapshotstate, timeout=600): |
| 1459 | """Check if snapshot is in required state |
| 1460 | returnValue: List[Result, Reason] |
| 1461 | @Result: PASS if snapshot is in required state, |
| 1462 | else FAIL |
| 1463 | @Reason: Reason for failure in case Result is FAIL |
| 1464 | """ |
| 1465 | isSnapshotInRequiredState = False |
| 1466 | try: |
| 1467 | while timeout >= 0: |
| 1468 | snapshots = Snapshot.list(apiclient, id=self.id) |
| 1469 | assert validateList(snapshots)[0] == PASS, "snapshots list\ |
| 1470 | validation failed" |
| 1471 | if str(snapshots[0].state).lower() == snapshotstate: |
| 1472 | isSnapshotInRequiredState = True |
| 1473 | break |
| 1474 | timeout -= 60 |
| 1475 | time.sleep(60) |
| 1476 | # end while |
| 1477 | if isSnapshotInRequiredState: |
| 1478 | return [PASS, None] |
| 1479 | else: |
| 1480 | raise Exception("Snapshot not in required state") |
| 1481 | except Exception as e: |
| 1482 | return [FAIL, e] |
| 1483 | |
| 1484 | |
| 1485 | class Template: |