mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Fixed Opennebula & Xen connectors
This commit is contained in:
parent
d566285098
commit
bbc2cdfa30
@ -38,7 +38,7 @@ from defusedxml import minidom
|
||||
# Python bindings for OpenNebula
|
||||
from .common import sanitizeName
|
||||
|
||||
__updated__ = '2017-03-03'
|
||||
__updated__ = '2017-03-06'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -82,7 +82,10 @@ def create(api, fromTemplateId, name, toDataStore):
|
||||
imgIds = dsk.getElementsByTagName('IMAGE_ID')
|
||||
if len(imgIds) == 0:
|
||||
fromId = False
|
||||
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
|
||||
try:
|
||||
node = dsk.getElementsByTagName('IMAGE')[0].childNodes[0]
|
||||
except IndexError:
|
||||
continue # Skip this unknown node
|
||||
imgName = node.data
|
||||
# Locate
|
||||
imgId = imgs[imgName]
|
||||
|
@ -329,7 +329,7 @@ class XenLinkedDeployment(UserDeployment):
|
||||
'''
|
||||
state = self.service().getVMPowerState(self._vmid)
|
||||
|
||||
if state != XenPowerState.halted:
|
||||
if state not in(XenPowerState.halted, XenPowerState.suspended):
|
||||
self.__pushFrontOp(opStop)
|
||||
self.__executeQueue()
|
||||
else:
|
||||
|
@ -44,11 +44,12 @@ from xen_client import XenFailure, XenFault
|
||||
|
||||
from XenLinkedService import XenLinkedService
|
||||
|
||||
import six
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2016-04-25'
|
||||
__updated__ = '2017-03-06'
|
||||
|
||||
|
||||
CACHE_TIME_FOR_SERVER = 1800
|
||||
@ -156,7 +157,7 @@ class Provider(ServiceProvider):
|
||||
return (True, ts['result'])
|
||||
|
||||
# Any other state, raises an exception
|
||||
raise Exception(ts['status']) # Should be 'cancelled', 'unknown', 'failure'
|
||||
raise Exception(six.text_type(ts['result'])) # Should be error message
|
||||
|
||||
def getMachines(self, force=False):
|
||||
'''
|
||||
|
@ -50,6 +50,7 @@ class XenFailure(XenAPI.Failure, XenFault):
|
||||
exVmMissingPVDrivers = 'VM_MISSING_PV_DRIVERS'
|
||||
exHandleInvalid = 'HANDLE_INVALID'
|
||||
exHostIsSlave = 'HOST_IS_SLAVE'
|
||||
exSRError = 'SR_BACKEND_FAILURE_44'
|
||||
|
||||
def __init__(self, details=None):
|
||||
details = [] if details is None else details
|
||||
@ -73,7 +74,8 @@ class XenFailure(XenAPI.Failure, XenFault):
|
||||
XenFailure.exBadVmPowerState: 'Machine state is invalid for requested operation (needs {2} and state is {3})',
|
||||
XenFailure.exVmMissingPVDrivers: 'Machine needs Xen Server Tools to allow requested operation',
|
||||
XenFailure.exHandleInvalid: 'Invalid handler',
|
||||
XenFailure.exHostIsSlave: 'The connected host is an slave, try to connect to {1}'
|
||||
XenFailure.exHostIsSlave: 'The connected host is an slave, try to connect to {1}',
|
||||
XenFailure.exSRError: 'Error on SR: {2}',
|
||||
}
|
||||
err = errList.get(self.details[0], 'Error {0}')
|
||||
|
||||
@ -216,11 +218,11 @@ class XenServer(object):
|
||||
status = 'failure'
|
||||
except Exception as e:
|
||||
logger.exception('Unexpected exception!')
|
||||
result = unicode(e)
|
||||
result = six.text_type(e)
|
||||
status = 'failure'
|
||||
|
||||
# Removes <value></value> if present
|
||||
if result and type(result) is not XenFailure and result.startswith('<value>'):
|
||||
if result and not isinstance(result, XenFailure) and result.startswith('<value>'):
|
||||
result = result[7:-8]
|
||||
|
||||
if destroyTask:
|
||||
|
Loading…
Reference in New Issue
Block a user