List Host and check if its resource state is as expected @returnValue - List[Result, Reason] 1) Result - FAIL if there is any exception in the operation or Host state does not change to expected state in given time else PAS
(cls, apiclient, hostid, state, resourcestate, timeout=600)
| 3465 | |
| 3466 | @classmethod |
| 3467 | def getState(cls, apiclient, hostid, state, resourcestate, timeout=600): |
| 3468 | """List Host and check if its resource state is as expected |
| 3469 | @returnValue - List[Result, Reason] |
| 3470 | 1) Result - FAIL if there is any exception |
| 3471 | in the operation or Host state does not change |
| 3472 | to expected state in given time else PASS |
| 3473 | 2) Reason - Reason for failure""" |
| 3474 | |
| 3475 | returnValue = [FAIL, "VM state not trasited to %s,\ |
| 3476 | operation timed out" % state] |
| 3477 | |
| 3478 | while timeout > 0: |
| 3479 | try: |
| 3480 | hosts = Host.list(apiclient, |
| 3481 | id=hostid, listall=True) |
| 3482 | validationresult = validateList(hosts) |
| 3483 | if validationresult[0] == FAIL: |
| 3484 | raise Exception("Host list validation failed: %s" % validationresult[2]) |
| 3485 | elif str(hosts[0].state).lower() == str(state).lower() and str( |
| 3486 | hosts[0].resourcestate).lower() == str(resourcestate).lower(): |
| 3487 | returnValue = [PASS, None] |
| 3488 | break |
| 3489 | except Exception as e: |
| 3490 | returnValue = [FAIL, e] |
| 3491 | break |
| 3492 | time.sleep(60) |
| 3493 | timeout -= 60 |
| 3494 | return returnValue |
| 3495 | |
| 3496 | |
| 3497 | class StoragePool: |
nothing calls this directly
no test coverage detected