Revision dfd19c2d logic/utils.py
b/logic/utils.py | ||
---|---|---|
30 | 30 |
def get_rsapi_state(vm): |
31 | 31 |
"""Returns the RSAPI state for a virtual machine""" |
32 | 32 |
try: |
33 |
r = VirtualMachine.RSAPI_STATE_FROM_OPER_STATE[vm._operstate]
|
|
33 |
r = VirtualMachine.RSAPI_STATE_FROM_OPER_STATE[vm.operstate] |
|
34 | 34 |
except KeyError: |
35 | 35 |
return "UNKNOWN" |
36 | 36 |
# A machine is in REBOOT if an OP_INSTANCE_REBOOT request is in progress |
37 |
if r == 'ACTIVE' and vm._backendopcode == 'OP_INSTANCE_REBOOT' and \
|
|
37 |
if r == 'ACTIVE' and vm.backendopcode == 'OP_INSTANCE_REBOOT' and \ |
|
38 | 38 |
vm._backendjobstatus in ('queued', 'waiting', 'running'): |
39 | 39 |
return "REBOOT" |
40 | 40 |
return r |
41 | 41 |
|
42 |
def update_state(self, new_operstate): |
|
43 |
"""Wrapper around updates of the _operstate field |
|
44 |
|
|
45 |
Currently calls the charge() method when necessary. |
|
46 |
|
|
47 |
""" |
|
42 |
def update_state(vm, new_operstate): |
|
43 |
"""Wrapper around updates of the VirtualMachine.operstate field""" |
|
48 | 44 |
|
49 | 45 |
# Call charge() unconditionally before any change of |
50 | 46 |
# internal state. |
51 |
credits.charge(self) |
|
52 |
self._operstate = new_operstate |
|
47 |
credits.charge(vm) |
|
48 |
vm.operstate = new_operstate |
Also available in: Unified diff