mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-23 17:34:17 +03:00
Merge remote-tracking branch 'origin/v2.1'
This commit is contained in:
commit
5037fd2bd4
@ -39,7 +39,7 @@ from . import on
|
||||
import pickle
|
||||
import logging
|
||||
|
||||
__updated__ = '2017-02-28'
|
||||
__updated__ = '2017-03-27'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -229,7 +229,7 @@ class LiveDeployment(UserDeployment):
|
||||
|
||||
ret = State.RUNNING
|
||||
|
||||
if type(chkState) is list:
|
||||
if isinstance(chkState, (list, tuple)):
|
||||
if state in chkState:
|
||||
ret = State.FINISHED
|
||||
else:
|
||||
|
@ -34,11 +34,13 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from uds.core.services import Publication
|
||||
from uds.core.util.State import State
|
||||
from datetime import datetime
|
||||
|
||||
import six
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
__updated__ = '2016-07-22'
|
||||
__updated__ = '2017-03-27'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -93,7 +95,7 @@ class LivePublication(Publication):
|
||||
self._templateId = self.service().makeTemplate(self._name)
|
||||
except Exception as e:
|
||||
self._state = 'error'
|
||||
self._reason = str(e)
|
||||
self._reason = six.text_type(e)
|
||||
return State.ERROR
|
||||
|
||||
return State.RUNNING
|
||||
@ -103,9 +105,13 @@ class LivePublication(Publication):
|
||||
Checks state of publication creation
|
||||
'''
|
||||
if self._state == 'running':
|
||||
if self.service().checkTemplatePublished(self._templateId) is False:
|
||||
return
|
||||
self._state = 'ok'
|
||||
try:
|
||||
if self.service().checkTemplatePublished(self._templateId) is False:
|
||||
return
|
||||
self._state = 'ok'
|
||||
except Exception as e:
|
||||
self._state = 'error'
|
||||
self._reason = six.text_type(e)
|
||||
|
||||
if self._state == 'error':
|
||||
return State.ERROR
|
||||
|
@ -43,7 +43,7 @@ import six
|
||||
import six
|
||||
from uds.core.util import xml2dict
|
||||
|
||||
__updated__ = '2016-11-10'
|
||||
__updated__ = '2017-03-27'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -300,6 +300,14 @@ class OpenNebulaClient(object):
|
||||
result = self.connection.one.vm.info(self.sessionString, int(vmId))
|
||||
return int(checkResult(result)['VM']['STATE'])
|
||||
|
||||
@ensureConnected
|
||||
def getVMLCMState(self, vmId):
|
||||
'''
|
||||
Returns the VM State
|
||||
'''
|
||||
result = self.connection.one.vm.info(self.sessionString, int(vmId))
|
||||
return int(checkResult(result)['VM']['LCM_STATE'])
|
||||
|
||||
@ensureConnected
|
||||
def VMAction(self, vmId, action):
|
||||
result = self.connection.one.vm.action(self.sessionString, action, int(vmId))
|
||||
|
@ -38,7 +38,7 @@ from defusedxml import minidom
|
||||
# Python bindings for OpenNebula
|
||||
from .common import sanitizeName
|
||||
|
||||
__updated__ = '2017-03-07'
|
||||
__updated__ = '2017-03-27'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -203,8 +203,11 @@ def checkPublished(api, templateId):
|
||||
|
||||
logger.debug('Found {} for checking'.format(imgId))
|
||||
|
||||
if api.imageInfo(imgId)[0]['IMAGE']['STATE'] == '4':
|
||||
state = api.imageInfo(imgId)[0]['IMAGE']['STATE']
|
||||
if state in ('0', '4'):
|
||||
return False
|
||||
elif state != '1': # If error is not READY
|
||||
raise Exception('Error publishing. Image is in an invalid state. (Check it and delete it if not needed anymore)')
|
||||
except Exception:
|
||||
logger.exception('Exception checking published')
|
||||
raise
|
||||
|
Loading…
Reference in New Issue
Block a user