From d0e0418ede642b7558fb5257d27ea164f58fb5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Mon, 11 Jul 2016 22:16:46 +0200 Subject: [PATCH] Fixed check due 2.0 just works only with opennebula 4.x due to api changes on 5.x. 2.1 will cover both vversions --- server/src/uds/services/OpenNebula/Provider.py | 7 ++++--- server/src/uds/services/OpenNebula/on/vm.py | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/uds/services/OpenNebula/Provider.py b/server/src/uds/services/OpenNebula/Provider.py index c0fb57418..e57812d8b 100644 --- a/server/src/uds/services/OpenNebula/Provider.py +++ b/server/src/uds/services/OpenNebula/Provider.py @@ -50,7 +50,7 @@ import six # Python bindings for OpenNebula import oca -__updated__ = '2016-04-25' +__updated__ = '2016-07-11' logger = logging.getLogger(__name__) @@ -149,8 +149,9 @@ class Provider(ServiceProvider): ''' try: - if self.api.version() < '4.1': - return [False, 'OpenNebula version is not supported (required version 4.1 or newer)'] + ver = self.api.version() + if ver < '4.1' or ver >= '5': + return [False, 'OpenNebula version is not supported (required version 4.x)'] except Exception as e: return [False, '{}'.format(e)] diff --git a/server/src/uds/services/OpenNebula/on/vm.py b/server/src/uds/services/OpenNebula/on/vm.py index 57cf3bbb1..95e9b087a 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-02-09' +__updated__ = '2016-07-11' logger = logging.getLogger(__name__) @@ -161,7 +161,10 @@ def getNetInfo(api, machineId, networkId=None): break # Default, returns first MAC found (or raise an exception if there is no MAC) - return (node.getElementsByTagName('MAC')[0].childNodes[0].data, node.getElementsByTagName('IP')[0].childNodes[0].data) + try: + return (node.getElementsByTagName('MAC')[0].childNodes[0].data, node.getElementsByTagName('IP')[0].childNodes[0].data) + except Exception: + raise Exception('No network interface found on template. Please, add a network and republish.') # Sample NIC Content (there will be as much as nics) #