1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Removed non used deployed service method "assignTouser"

This commit is contained in:
Adolfo Gómez García 2019-02-24 10:51:12 +01:00
parent f5abeb0a94
commit 7910327a8a
10 changed files with 9 additions and 140 deletions

View File

@ -1,40 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project> <?eclipse-pydev version="1.0"?><pydev_project>
<<<<<<< HEAD <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">uds 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.7</pydev_property>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>src/manage.py</value>
<key>DJANGO_SETTINGS_MODULE</key>
<value>server.settings</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/uds/src</path>
</pydev_pathproperty>
=======
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">uds 2.2</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>src/manage.py</value>
<key>DJANGO_SETTINGS_MODULE</key>
<value>server.settings</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/uds/src</path>
</pydev_pathproperty>
>>>>>>> origin/v2.2
</pydev_project> </pydev_project>

View File

@ -58,11 +58,7 @@ import json
import logging import logging
import random import random
<<<<<<< HEAD
__updated__ = '2019-02-11'
=======
__updated__ = '2019-02-22' __updated__ = '2019-02-22'
>>>>>>> origin/v2.2
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
traceLogger = logging.getLogger('traceLog') traceLogger = logging.getLogger('traceLog')
@ -302,17 +298,12 @@ class UserServiceManager(object):
cache = None cache = None
if cache: if cache:
cache.assignToUser(user) cache.assignToUser(user, save=True)
cache.save() # Store assigned ASAP, we do not know how long assignToUser method of instance will take
# Out of atomic transaction # Out of atomic transaction
if cache is not None: if cache is not None:
logger.debug('Found a cached-ready service from {0} for user {1}, item {2}'.format(ds, user, cache)) logger.debug('Found a cached-ready service from {0} for user {1}, item {2}'.format(ds, user, cache))
events.addEvent(ds, events.ET_CACHE_HIT, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.USABLE).count()) events.addEvent(ds, events.ET_CACHE_HIT, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.USABLE).count())
ci = cache.getInstance() # User Deployment instance
ci.assignToUser(user)
cache.updateData(ci)
cache.save()
return cache return cache
# Cache missed # Cache missed
@ -325,8 +316,7 @@ class UserServiceManager(object):
if ds.cachedUserServices().select_for_update().filter(user=None, uuid=cache.uuid).update(user=user, cache_level=0) != 1: if ds.cachedUserServices().select_for_update().filter(user=None, uuid=cache.uuid).update(user=user, cache_level=0) != 1:
cache = None cache = None
else: else:
cache.assignToUser(user) cache.assignToUser(user, save=True)
cache.save()
else: else:
cache = None cache = None
@ -334,10 +324,6 @@ class UserServiceManager(object):
if cache is not None: if cache is not None:
logger.debug('Found a cached-preparing service from {0} for user {1}, item {2}'.format(ds, user, cache)) logger.debug('Found a cached-preparing service from {0} for user {1}, item {2}'.format(ds, user, cache))
events.addEvent(ds, events.ET_CACHE_MISS, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING).count()) events.addEvent(ds, events.ET_CACHE_MISS, fld1=ds.cachedUserServices().filter(cache_level=services.UserDeployment.L1_CACHE, state=State.PREPARING).count())
ci = cache.getInstance() # User Deployment instance
ci.assignToUser(user)
cache.updateData(ci)
cache.save()
return cache return cache
# Can't assign directly from L2 cache... so we check if we can create e new service in the limits requested # Can't assign directly from L2 cache... so we check if we can create e new service in the limits requested

View File

@ -449,25 +449,6 @@ class UserDeployment(Environmentable, Serializable):
""" """
pass pass
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This is not a task method right now, simply a notification. This means
that L1 cache items must be directly usable (except for the readyness part)
by users in a single step operation.
Note that there will be an setReady call before letting the user consume
this user deployment, so this is more informational (so, if you keep at
what cache level is this instance, you can update it) than anything else.
This is not a task method. All level 1 cache items can be dircetly
assigned to an user with no more work needed, but, if something is needed,
here you can do whatever you need.
user is a Database user object.
"""
pass
def moveToCache(self, newLevel): def moveToCache(self, newLevel):
""" """
This method is invoked whenever the core needs to move from the current This method is invoked whenever the core needs to move from the current

View File

@ -116,7 +116,7 @@ class UserService(UUIDModel):
""" """
return "{}\\{}".format(self.deployed_service.name, self.friendly_name) return "{}\\{}".format(self.deployed_service.name, self.friendly_name)
def getEnvironment(self) -> Environment: def getEnvironment(self):
""" """
Returns an environment valid for the record this object represents. Returns an environment valid for the record this object represents.
@ -138,7 +138,7 @@ class UserService(UUIDModel):
} }
) )
def getInstance(self) -> UserDeployment: def getInstance(self):
""" """
Instantiates the object this record contains. In this case, the instantiated object needs also Instantiates the object this record contains. In this case, the instantiated object needs also
the os manager and the publication, so we also instantiate those here. the os manager and the publication, so we also instantiate those here.
@ -336,7 +336,7 @@ class UserService(UUIDModel):
self.state_date = getSqlDatetime() self.state_date = getSqlDatetime()
self.os_state = state self.os_state = state
def assignToUser(self, user): def assignToUser(self, user, save=False):
""" """
Assigns this user deployed service to an user. Assigns this user deployed service to an user.
@ -346,6 +346,8 @@ class UserService(UUIDModel):
self.cache_level = 0 self.cache_level = 0
self.state_date = getSqlDatetime() self.state_date = getSqlDatetime()
self.user = user self.user = user
if save:
self.save(update_fields=['cache_level', 'state_date', 'user'])
def setInUse(self, state): def setInUse(self, state):
""" """

View File

@ -523,14 +523,6 @@ class OVirtLinkedDeployment(UserDeployment):
self.__debug('finish') self.__debug('finish')
pass pass
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This gives the User Deployment an oportunity to do whatever actions
are required so the service puts at a correct state for using by a service.
"""
pass
def moveToCache(self, newLevel): def moveToCache(self, newLevel):
""" """
Moves machines between cache levels Moves machines between cache levels

View File

@ -459,14 +459,6 @@ class LiveDeployment(UserDeployment):
self.__debug('finish') self.__debug('finish')
pass pass
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This gives the User Deployment an oportunity to do whatever actions
are required so the service puts at a correct state for using by a service.
"""
pass
def moveToCache(self, newLevel): def moveToCache(self, newLevel):
""" """
Moves machines between cache levels Moves machines between cache levels

View File

@ -463,14 +463,6 @@ class LiveDeployment(UserDeployment):
self.__debug('finish') self.__debug('finish')
pass pass
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This gives the User Deployment an oportunity to do whatever actions
are required so the service puts at a correct state for using by a service.
"""
pass
def moveToCache(self, newLevel): def moveToCache(self, newLevel):
""" """
Moves machines between cache levels Moves machines between cache levels

View File

@ -289,20 +289,6 @@ class SampleUserDeploymentOne(UserDeployment):
# Note that this is not really needed, is just a sample of storage use # Note that this is not really needed, is just a sample of storage use
self.storage.remove('count') self.storage.remove('count')
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This gives the User Deployment an oportunity to do whatever actions
are required so the service puts at a correct state for using by a service.
In our sample, the service is always ready, so this does nothing.
This is not a task method. All level 1 cache items can be diretly
assigned to an user with no more work needed, but, if something is needed,
here you can do whatever you need
"""
pass
def userLoggedIn(self, user): def userLoggedIn(self, user):
""" """
This method must be available so os managers can invoke it whenever This method must be available so os managers can invoke it whenever

View File

@ -379,25 +379,6 @@ class SampleUserDeploymentTwo(UserDeployment):
# We set count to 0, not needed but for sample purposes # We set count to 0, not needed but for sample purposes
self._count = 0 self._count = 0
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This is not a task method right now, simply a notification. This means
that L1 cache items must be directly usable (except for the readyness part)
by users in a single step operation.
Note that there will be an setReady call before letting the user consume
this user deployment, so this is more informational (so, if you keep at
what cache level is this instance, you can update it) than anything else.
This is not a task method. All level 1 cache items can be dircetly
assigned to an user with no more work needed, but, if something is needed,
here you can do whatever you need.
user is a Database user object.
"""
logger.debug('Assigned to user {0}'.format(user))
def userLoggedIn(self, user): def userLoggedIn(self, user):
""" """
This method must be available so os managers can invoke it whenever This method must be available so os managers can invoke it whenever

View File

@ -515,14 +515,6 @@ class XenLinkedDeployment(UserDeployment):
self.__debug('finish') self.__debug('finish')
pass pass
def assignToUser(self, user):
"""
This method is invoked whenever a cache item gets assigned to an user.
This gives the User Deployment an oportunity to do whatever actions
are required so the service puts at a correct state for using by a service.
"""
pass
def moveToCache(self, newLevel): def moveToCache(self, newLevel):
""" """
Moves machines between cache levels Moves machines between cache levels