forked from shaba/openuds
* REST fix to delete incompleted created service
* oVirtLinkedServiced added check to memory value (fix)
This commit is contained in:
parent
cf5e25796d
commit
89f887c68c
@ -91,11 +91,19 @@ class Services(DetailHandler):
|
||||
logger.exception('getItems')
|
||||
self.invalidItemException()
|
||||
|
||||
def deleteIncompleteService(self, service):
|
||||
if service is not None:
|
||||
try:
|
||||
service.delete()
|
||||
except:
|
||||
pass
|
||||
|
||||
def saveItem(self, parent, item):
|
||||
# Extract item db fields
|
||||
# We need this fields for all
|
||||
logger.debug('Saving service {0} / {1}'.format(parent, item))
|
||||
fields = self.readFieldsFromParams(['name', 'comments', 'data_type'])
|
||||
service = None
|
||||
try:
|
||||
if item is None: # Create new
|
||||
service = parent.services.create(**fields)
|
||||
@ -110,10 +118,12 @@ class Services(DetailHandler):
|
||||
except IntegrityError: # Duplicate key probably
|
||||
raise RequestError(_('Element already exists (duplicate key error)'))
|
||||
except coreService.ValidationException as e:
|
||||
self.deleteIncompleteService(service)
|
||||
raise RequestError(_('Input error: {0}'.format(unicode(e))))
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
self.deleteIncompleteService(service)
|
||||
logger.exception('Saving Service')
|
||||
raise RequestError('incorrect invocation to PUT')
|
||||
raise RequestError('incorrect invocation to PUT: {0}'.format(e))
|
||||
|
||||
return self.getItems(parent, service.id)
|
||||
|
||||
|
@ -148,7 +148,7 @@ class OVirtLinkedService(Service):
|
||||
raise Service.ValidationException(_('The length of basename plus length must not be greater than 15'))
|
||||
if self.baseName.value.isdigit():
|
||||
raise Service.ValidationException(_('The machine name can\'t be only numbers'))
|
||||
if int(self.memory.value) < 256:
|
||||
if int(self.memory.value) < 256 or int(self.memoryGuaranteed.value) < 256:
|
||||
raise Service.ValidationException(_('The minimum allowed memory is 256 Mb'))
|
||||
if int(self.memoryGuaranteed.value) > int(self.memory.value):
|
||||
self.memoryGuaranteed.value = self.memory.value
|
||||
|
Loading…
Reference in New Issue
Block a user