Revision fc30c430

b/logic/utils.py
25 25

  
26 26
    return int(ns)
27 27

  
28

  
29 28
def get_rsapi_state(vm):
30
    """Returns the RSAPI state for a virtual machine"""
29
    """Returns the API state for a virtual machine
30
    
31
    The API state for an instance of VirtualMachine is derived as follows:
32

  
33
    * If the deleted flag has been set, it is "DELETED".
34
    * Otherwise, it is a mapping of the last state reported by Ganeti
35
      (vm.operstate) through the RSAPI_STATE_FROM_OPER_STATE dictionary.
36
      
37
      The last state reported by Ganeti is set whenever Ganeti reports
38
      successful completion of an operation. If Ganeti says an OP_INSTANCE_STARTUP
39
      operation succeeded, vm.operstate is set to "STARTED".
40

  
41
    * To support any transitive states defined by the API (only REBOOT for the time
42
      being) this mapping is amended with information reported by Ganeti regarding
43
      any outstanding operation. If an OP_INSTANCE_STARTUP had succeeded previously
44
      and an OP_INSTANCE_REBOOT has been reported as in progress, the API state is
45
      "REBOOT".
46

  
47
    """
31 48
    try:
32 49
        r = VirtualMachine.RSAPI_STATE_FROM_OPER_STATE[vm.operstate]
33 50
    except KeyError:

Also available in: Unified diff