This commit is contained in:
Adolfo Gómez García 2019-02-24 11:48:38 +01:00
parent 6d50f99ad6
commit 6ec73b336d
5 changed files with 9 additions and 12 deletions

View File

@ -136,8 +136,7 @@ class PublicationFinishChecker(DelayedTask):
# Now we mark, if it exists, the previous usable publication as "Removable"
if State.isPreparing(prevState):
for old in servicePoolPub.deployed_service.publications.filter(state=State.USABLE):
old.state = State.REMOVABLE
old.save()
old.setstate(State.REMOVABLE)
osm = servicePoolPub.deployed_service.osmanager
# If os manager says "machine is persistent", do not tray to delete "previous version" assigned machines
@ -159,12 +158,11 @@ class PublicationFinishChecker(DelayedTask):
servicePoolPub.updateData(pi)
elif State.isErrored(state):
servicePoolPub.updateData(pi)
servicePoolPub.state = State.ERROR
servicePoolPub.setState(State.ERROR)
else:
checkLater = True # The task is running
servicePoolPub.updateData(pi)
servicePoolPub.save()
if checkLater:
PublicationFinishChecker.checkLater(servicePoolPub, pi)
except Exception:

View File

@ -64,7 +64,6 @@ class StateUpdater(object):
self.userService.setState(newState)
self.userService.updateData(self.userServiceInstance)
self.userService.save(update_fields=['data', 'state', 'state_date'])
def logIp(self):
ip = self.userServiceInstance.getIp()

View File

@ -214,8 +214,6 @@ class OSManager(Module):
counter = int(userService.getProperty('loginsCounter', '0')) + 1
userService.setProperty('loginsCounter', six.text_type(counter))
if save:
userService.save(update_fields=['in_use', 'in_use_date', 'data'])
def loggedOut(self, userService, userName=None, save=True):
"""
@ -257,9 +255,6 @@ class OSManager(Module):
log.useLog('logout', uniqueId, serviceIp, userName, knownUserIP, fullUserName, userService.friendly_name, userService.deployed_service.name)
if save:
userService.save(update_fields=['data'])
def isPersistent(self):
"""
When a publication if finished, old assigned machines will be removed if this value is True.

View File

@ -149,6 +149,7 @@ class DeployedServicePublication(UUIDModel):
:note: This method do not saves the updated record, just updates the field
"""
self.data = dsp.serialize()
self.save(update_fields=['data'])
def setState(self, state):
"""
@ -162,6 +163,7 @@ class DeployedServicePublication(UUIDModel):
"""
self.state_date = getSqlDatetime()
self.state = state
self.save(update_fields=['state_date', 'state'])
def unpublish(self):
"""

View File

@ -187,9 +187,10 @@ class UserService(UUIDModel):
Args:
dsp: :py:class:uds.core.services.UserDeployment to serialize
:note: This method do not saves the updated record, just updates the field
:note: This method SAVES the updated record, just updates the field
"""
self.data = us.serialize()
self.data.save(update_fields=['data'])
def getName(self):
"""
@ -321,6 +322,7 @@ class UserService(UUIDModel):
if state != self.state:
self.state_date = getSqlDatetime()
self.state = state
self.save(update_fields=['state', 'state_date'])
def setOsState(self, state):
"""
@ -336,7 +338,7 @@ class UserService(UUIDModel):
self.state_date = getSqlDatetime()
self.os_state = state
def assignToUser(self, user, save=False):
def assignToUser(self, user):
"""
Assigns this user deployed service to an user.
@ -361,6 +363,7 @@ class UserService(UUIDModel):
from uds.core.managers.UserServiceManager import UserServiceManager
self.in_use = state
self.in_use_date = getSqlDatetime()
self.save(update_fields=['in_use', 'in_use_date'])
# Start/stop accounting
if state is True: