1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-05 09:17:54 +03:00

Fixed a bug with creation of assigned services for services without publication

This commit is contained in:
Adolfo Gómez 2012-12-04 11:29:37 +00:00
parent baecf526a1
commit 63d0f6e470

View File

@ -177,12 +177,11 @@ class UserServiceManager(object):
@transaction.commit_on_success @transaction.commit_on_success
def __checkMaxDeployedReached(self, deployedServicePublication): def __checkMaxDeployedReached(self, deployedService):
''' '''
Checks if maxDeployed for the service has been reached, and, if so, Checks if maxDeployed for the service has been reached, and, if so,
raises an exception that no more services of this kind can be reached raises an exception that no more services of this kind can be reached
''' '''
deployedService = deployedServicePublication.deployed_service
serviceInstance = deployedService.service.getInstance() serviceInstance = deployedService.service.getInstance()
# Early return, so no database count is needed # Early return, so no database count is needed
if serviceInstance.maxDeployed == Service.UNLIMITED: if serviceInstance.maxDeployed == Service.UNLIMITED:
@ -196,25 +195,25 @@ class UserServiceManager(object):
) )
def __createCacheAtDb(self, deployedService, cacheLevel): def __createCacheAtDb(self, deployedServicePublication, cacheLevel):
''' '''
Private method to instatiate a cache element at database with default states Private method to instatiate a cache element at database with default states
''' '''
# Checks if maxDeployed has been reached and if so, raises an exception # Checks if maxDeployed has been reached and if so, raises an exception
self.__checkMaxDeployedReached(deployedService) self.__checkMaxDeployedReached(deployedServicePublication.deployed_service)
now = getSqlDatetime() now = getSqlDatetime()
return deployedService.userServices.create(cache_level = cacheLevel, state = State.PREPARING, os_state = State.PREPARING, return deployedServicePublication.userServices.create(cache_level = cacheLevel, state = State.PREPARING, os_state = State.PREPARING,
state_date=now, creation_date=now, data = '', deployed_service = deployedService.deployed_service, state_date=now, creation_date=now, data = '', deployed_service = deployedServicePublication.deployed_service,
user = None, in_use = False ) user = None, in_use = False )
def __createAssignedAtDb(self, deployedService, user): def __createAssignedAtDb(self, deployedServicePublication, user):
''' '''
Private method to instatiate an assigned element at database with default state Private method to instatiate an assigned element at database with default state
''' '''
self.__checkMaxDeployedReached(deployedService) self.__checkMaxDeployedReached(deployedServicePublication.deployed_service)
now = getSqlDatetime() now = getSqlDatetime()
return deployedService.userServices.create(cache_level=0, state=State.PREPARING, os_state=State.PREPARING, return deployedServicePublication.userServices.create(cache_level=0, state=State.PREPARING, os_state=State.PREPARING,
state_date=now, creation_date=now, data='', deployed_service=deployedService.deployed_service, user=user, in_use=False) state_date=now, creation_date=now, data='', deployed_service=deployedServicePublication.deployed_service, user=user, in_use=False)
def __createAssignedAtDbForNoPublication(self, deployedService, user): def __createAssignedAtDbForNoPublication(self, deployedService, user):
self.__checkMaxDeployedReached(deployedService) self.__checkMaxDeployedReached(deployedService)