Fixed trying to remove VM when LCM_STATE was "boot" or prior for

OpenNebula
This commit is contained in:
Adolfo Gómez García 2018-08-20 13:38:54 +02:00
parent eb3188c6c1
commit c2a95711da
4 changed files with 16 additions and 9 deletions

View File

@ -39,7 +39,7 @@ from . import on
import pickle
import logging
__updated__ = '2018-03-16'
__updated__ = '2018-08-20'
logger = logging.getLogger(__name__)
@ -356,6 +356,13 @@ class LiveDeployment(UserDeployment):
if state == on.VmState.UNKNOWN:
raise Exception('Machine not found')
if state == on.VmState.ACTIVE:
subState = self.service().getMachineSubstate(self._vmid)
if subState < 3: # Less than running
logger.info('Must wait before remove: {}'.format(subState))
self.__pushFrontOp(opRetry)
return
self.service().removeMachine(self._vmid)
def __startMachine(self):

View File

@ -40,7 +40,7 @@ from uds.core.ui import gui
import logging
__updated__ = '2018-03-16'
__updated__ = '2018-08-20'
logger = logging.getLogger(__name__)
@ -214,12 +214,12 @@ class LiveService(Service):
'''
return self.parent().getMachineState(machineId)
def getMachineSubState(self, machineId):
def getMachineSubstate(self, machineId):
'''
On OpenNebula, the machine can be "active" but not "running".
Any active machine will have a LCM_STATE, that is what we get here
'''
return self.parent().getMachineSubState(machineId)
return self.parent().getMachineSubstate(machineId)
def startMachine(self, machineId):
'''

View File

@ -49,7 +49,7 @@ import six
# Python bindings for OpenNebula
# import oca
__updated__ = '2018-03-16'
__updated__ = '2018-08-20'
logger = logging.getLogger(__name__)
@ -187,7 +187,7 @@ class Provider(ServiceProvider):
'''
return on.vm.getMachineState(self.api, machineId)
def getMachineSubState(self, machineId):
def getMachineSubstate(self, machineId):
'''
Returns the LCM_STATE of a machine (must be ready)
'''

View File

@ -39,7 +39,7 @@ from defusedxml import minidom
# Python bindings for OpenNebula
from .common import VmState
__updated__ = '2018-03-16'
__updated__ = '2018-08-20'
logger = logging.getLogger(__name__)
@ -71,7 +71,7 @@ def getMachineSubstate(api, machineId):
Returns the lcm_state
'''
try:
return api.getVMSubState(machineId)
return api.getVMSubstate(machineId)
except Exception as e:
logger.error('Error obtaining machine state for {} on OpenNebula: {}'.format(machineId, e))
@ -156,7 +156,7 @@ def removeMachine(api, machineId):
api.deleteVM(machineId)
except Exception as e:
logger.exception('Error removing machine {} on OpenNebula: {}'.format(machineId, e))
raise 'Error removing machine {} on OpenNebula: {}'.format(machineId, e)
raise Exception('Error removing machine {} on OpenNebula: {}'.format(machineId, e))
def enumerateMachines(api):