From 7a0c8aa977ae45c8a4f9c3ab87b7ea00ab60d6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Fri, 22 Jul 2016 17:40:03 +0200 Subject: [PATCH] More Fixes for OpenNebula 4.x (for new API implementation) --- server/src/uds/services/OpenNebula/on/__init__.py | 5 ++--- server/src/uds/services/OpenNebula/on/template.py | 4 +++- server/src/uds/services/OpenNebula/on/vm.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/uds/services/OpenNebula/on/__init__.py b/server/src/uds/services/OpenNebula/on/__init__.py index a8b9c2a4..ef01ffa9 100644 --- a/server/src/uds/services/OpenNebula/on/__init__.py +++ b/server/src/uds/services/OpenNebula/on/__init__.py @@ -279,12 +279,11 @@ class OpenNebulaClient(object): Deletes an vm ''' if self.version[0] == '4': - result = self.VMAction(vmId, 'delete') + return self.VMAction(vmId, 'delete') else: # Version 5 - result = self.VMAction(vmId, 'terminate-hard') + return self.VMAction(vmId, 'terminate-hard') - return checkResult(result, parseResult=False) @ensureConnected def getVMState(self, vmId): diff --git a/server/src/uds/services/OpenNebula/on/template.py b/server/src/uds/services/OpenNebula/on/template.py index 9015ecbe..d01a9b94 100644 --- a/server/src/uds/services/OpenNebula/on/template.py +++ b/server/src/uds/services/OpenNebula/on/template.py @@ -190,8 +190,10 @@ def checkPublished(api, templateId): logger.debug('Found {} for checking'.format(imgId)) - if api.getImageInfo(imgId)[0]['IMAGE']['STATE'] == '4': + if api.imageInfo(imgId)[0]['IMAGE']['STATE'] == '4': return False except Exception: logger.exception('Exception checking published') raise + + return True diff --git a/server/src/uds/services/OpenNebula/on/vm.py b/server/src/uds/services/OpenNebula/on/vm.py index e612fd5b..1202c816 100644 --- a/server/src/uds/services/OpenNebula/on/vm.py +++ b/server/src/uds/services/OpenNebula/on/vm.py @@ -39,7 +39,7 @@ from defusedxml import minidom # Python bindings for OpenNebula from .common import VmState -__updated__ = '2016-07-11' +__updated__ = '2016-07-22' logger = logging.getLogger(__name__) @@ -126,7 +126,7 @@ def removeMachine(api, machineId): # vm.delete() api.deleteVM(machineId) except Exception as e: - logger.error('Error obtaining machine state for {} on opennebula: {}'.format(machineId, e)) + logger.error('Error removing machine {} on opennebula: {}'.format(machineId, e)) def enumerateMachines(api):