From 050c2d64113ad70cb3b1fb9513f30661644d4edc Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 11 Mar 2016 13:28:54 +0100 Subject: [PATCH] Update VM status in OpenNebula --- IM/connectors/OpenNebula.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/IM/connectors/OpenNebula.py b/IM/connectors/OpenNebula.py index 4cee92776..d8a76bcc8 100644 --- a/IM/connectors/OpenNebula.py +++ b/IM/connectors/OpenNebula.py @@ -233,23 +233,29 @@ def updateVMInfo(self, vm, auth_data): vm.info.systems[0].setValue('instance_name', res_vm.NAME) # update the state of the VM - if res_vm.STATE == 3: - if res_vm.LCM_STATE == 3: - res_state = VirtualMachine.RUNNING + if res_vm.STATE < 3 : + res_state = VirtualMachine.PENDING + elif res_vm.STATE == 3: + if res_vm.LCM_STATE < 3: + res_state = VirtualMachine.PENDING elif res_vm.LCM_STATE == 5 or res_vm.LCM_STATE == 6: res_state = VirtualMachine.STOPPED + elif res_vm.LCM_STATE == 14: + res_state = VirtualMachine.FAILED + elif res_vm.LCM_STATE == 16: + res_state = VirtualMachine.UNKNOWN + elif res_vm.LCM_STATE == 12 or res_vm.LCM_STATE == 13 or res_vm.LCM_STATE == 18: + res_state = VirtualMachine.OFF else: - res_state = VirtualMachine.PENDING - elif res_vm.STATE < 3 : - res_state = VirtualMachine.PENDING - elif res_vm.LCM_STATE == 15: - res_state = VirtualMachine.UNKNOWN - elif res_vm.STATE == 7: - res_state = VirtualMachine.FAILED + res_state = VirtualMachine.RUNNING elif res_vm.STATE == 4 or res_vm.STATE == 5: res_state = VirtualMachine.STOPPED - else: + elif res_vm.STATE == 7: + res_state = VirtualMachine.FAILED + elif res_vm.STATE == 6 or res_vm.STATE == 8 or res_vm.STATE == 9: res_state = VirtualMachine.OFF + else: + res_state = VirtualMachine.UNKNOWN vm.state = res_state # Update network data