MCPcopy Create free account
hub / github.com/apache/cloudstack / getState

Method getState

tools/marvin/marvin/lib/base.py:861–890  ·  view source on GitHub ↗

List VM and check if its state is as expected @returnValue - List[Result, Reason] 1) Result - FAIL if there is any exception in the operation or VM state does not change to expected state in given time else PASS

(self, apiclient, state, timeout=600)

Source from the content-addressed store, hash-verified

859 return self.ssh_client
860
861 def getState(self, apiclient, state, timeout=600):
862 """List VM and check if its state is as expected
863 @returnValue - List[Result, Reason]
864 1) Result - FAIL if there is any exception
865 in the operation or VM state does not change
866 to expected state in given time else PASS
867 2) Reason - Reason for failure"""
868
869 returnValue = [FAIL, Exception(f"VM state not transitioned to {state},\
870 operation timed out")]
871
872 while timeout > 0:
873 try:
874 projectid = None
875 if hasattr(self, "projectid"):
876 projectid = self.projectid
877 vms = VirtualMachine.list(apiclient, projectid=projectid,
878 id=self.id, listAll=True)
879 validationresult = validateList(vms)
880 if validationresult[0] == FAIL:
881 raise Exception("VM list validation failed: %s" % validationresult[2])
882 elif str(vms[0].state).lower() == str(state).lower():
883 returnValue = [PASS, None]
884 break
885 except Exception as e:
886 returnValue = [FAIL, e]
887 break
888 time.sleep(60)
889 timeout -= 60
890 return returnValue
891
892 def resetSshKey(self, apiclient, **kwargs):
893 """Resets SSH key"""

Callers 15

startMethod · 0.95
stopMethod · 0.95
rebootMethod · 0.95
recoverMethod · 0.95
selectMethod · 0.95
deleteBitmapMethod · 0.95
unmanageNicsMethod · 0.95
cleanupMethod · 0.95

Implementers 2

VMEntityVOengine/schema/src/main/java/org/apache
VMInstanceVOengine/schema/src/main/java/com/cloud/

Calls 3

validateListFunction · 0.90
listMethod · 0.65
sleepMethod · 0.45

Tested by

no test coverage detected