mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-13 08:58:35 +03:00
Small fix for metapools in case it's 100%
This commit is contained in:
parent
fcf6e31486
commit
c5171c014b
2
actor
2
actor
@ -1 +1 @@
|
||||
Subproject commit 0489009e08acfd59ec9936ab33457cb32151e11f
|
||||
Subproject commit 46088958fb5e883bda4c516244e755e02f83b862
|
@ -611,8 +611,10 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
def checkUuid(self, userService: UserService) -> bool:
|
||||
return comms.checkUuid(userService)
|
||||
|
||||
def requestScreenshot(self, userService: UserService) -> bytes:
|
||||
return comms.requestScreenshot(userService)
|
||||
def requestScreenshot(self, userService: UserService) -> None:
|
||||
# Screenshot will request an screenshot to the actor
|
||||
# And the actor will return back, via REST actor API, the screenshot
|
||||
comms.requestScreenshot(userService)
|
||||
|
||||
def sendScript(self, userService: UserService, script: str, forUser: bool = False) -> None:
|
||||
comms.sendScript(userService, script, forUser)
|
||||
@ -919,7 +921,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
if meta.policy == types.pools.LoadBalancingPolicy.PRIORITY:
|
||||
sortPools = [(p.priority, p.pool) for p in poolMembers]
|
||||
elif meta.policy == types.pools.LoadBalancingPolicy.GREATER_PERCENT_FREE:
|
||||
sortPools = [(p.pool.usage()[0], p.pool) for p in poolMembers]
|
||||
sortPools = [(p.pool.usage().percent, p.pool) for p in poolMembers]
|
||||
else:
|
||||
sortPools = [
|
||||
(
|
||||
@ -940,7 +942,7 @@ class UserServiceManager(metaclass=singleton.Singleton):
|
||||
for p in sortedPools:
|
||||
if not p[1].isUsable():
|
||||
continue
|
||||
if p[1].usage() == 100:
|
||||
if p[1].usage().percent == 100:
|
||||
poolsFull.append(p[1])
|
||||
else:
|
||||
pools.append(p[1])
|
||||
|
@ -163,31 +163,37 @@ def checkUuid(userService: 'UserService') -> bool:
|
||||
return True # Actor does not supports checking
|
||||
|
||||
|
||||
def requestScreenshot(userService: 'UserService') -> bytes:
|
||||
def requestScreenshot(userService: 'UserService') -> None:
|
||||
"""
|
||||
Returns an screenshot in PNG format (bytes) or empty png if not supported
|
||||
Requests an screenshot to an actor on an user service
|
||||
|
||||
This method is used to request an screenshot to an actor on an user service.
|
||||
|
||||
Args:
|
||||
userService: User service to request screenshot from
|
||||
|
||||
Notes:
|
||||
The screenshot is not returned directly, but will be returned on a actor REST API call to "screenshot" method.
|
||||
"""
|
||||
emptyPng = (
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='
|
||||
)
|
||||
try:
|
||||
png = _requestActor(
|
||||
userService, 'screenshot', minVersion='3.0.0'
|
||||
# Data = {} forces an empty POST
|
||||
_requestActor(
|
||||
userService, 'screenshot', data={}, minVersion='4.0.0'
|
||||
) # First valid version with screenshot is 3.0
|
||||
except exceptions.actor.NoActorComms:
|
||||
png = None
|
||||
|
||||
return base64.b64decode(png or emptyPng)
|
||||
pass # No actor comms, nothing to do
|
||||
|
||||
|
||||
def sendScript(userService: 'UserService', script: str, forUser: bool = False) -> None:
|
||||
"""
|
||||
If allowed, send script to user service
|
||||
If allowed, sends script to user service
|
||||
Note tha the script is a python script, so it can be executed directly by the actor
|
||||
"""
|
||||
try:
|
||||
data: collections.abc.MutableMapping[str, typing.Any] = {'script': script}
|
||||
if forUser:
|
||||
data['user'] = forUser
|
||||
# Data = {} forces an empty POST
|
||||
_requestActor(userService, 'script', data=data)
|
||||
except exceptions.actor.NoActorComms:
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user