mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-18 06:03:54 +03:00
Updated actio to use match instead of ifs
This commit is contained in:
parent
e8db21b7ed
commit
5ac2e2a73d
@ -180,34 +180,42 @@ def action(request: 'ExtendedHttpRequestWithUser', service_id: str, action_strin
|
|||||||
response: typing.Any = None
|
response: typing.Any = None
|
||||||
rebuild: bool = False
|
rebuild: bool = False
|
||||||
if userservice:
|
if userservice:
|
||||||
if action_string == 'release' and userservice.service_pool.allow_users_remove:
|
match action_string:
|
||||||
rebuild = True
|
case 'release':
|
||||||
log.log(
|
if userservice.service_pool.allow_users_remove:
|
||||||
userservice.service_pool,
|
rebuild = True
|
||||||
types.log.LogLevel.INFO,
|
log.log(
|
||||||
"Removing User Service {} as requested by {} from {}".format(
|
userservice.service_pool,
|
||||||
userservice.friendly_name, request.user.pretty_name, request.ip
|
types.log.LogLevel.INFO,
|
||||||
),
|
"Removing User Service {} as requested by {} from {}".format(
|
||||||
types.log.LogSource.WEB,
|
userservice.friendly_name, request.user.pretty_name, request.ip
|
||||||
)
|
),
|
||||||
UserServiceManager.manager().request_logoff(userservice)
|
types.log.LogSource.WEB,
|
||||||
userservice.release()
|
)
|
||||||
elif (
|
UserServiceManager.manager().request_logoff(userservice)
|
||||||
action_string == 'reset'
|
userservice.release()
|
||||||
and userservice.service_pool.allow_users_reset
|
case 'reset':
|
||||||
and userservice.service_pool.service.get_type().can_reset
|
if userservice.service_pool.allow_users_reset and userservice.service_pool.service.get_type().can_reset:
|
||||||
):
|
logger.info('Resetting service')
|
||||||
rebuild = True
|
rebuild = True
|
||||||
log.log(
|
log.log(
|
||||||
userservice.service_pool,
|
userservice.service_pool,
|
||||||
types.log.LogLevel.INFO,
|
types.log.LogLevel.INFO,
|
||||||
"Reseting User Service {} as requested by {} from {}".format(
|
"Reseting User Service {} as requested by {} from {}".format(
|
||||||
userservice.friendly_name, request.user.pretty_name, request.ip
|
userservice.friendly_name, request.user.pretty_name, request.ip
|
||||||
),
|
),
|
||||||
types.log.LogSource.WEB,
|
types.log.LogSource.WEB,
|
||||||
)
|
)
|
||||||
# UserServiceManager.manager().requestLogoff(userService)
|
# UserServiceManager.manager().requestLogoff(userService)
|
||||||
UserServiceManager.manager().reset(userservice)
|
UserServiceManager.manager().reset(userservice)
|
||||||
|
# Rest, ignore
|
||||||
|
case _:
|
||||||
|
log.log(
|
||||||
|
userservice.service_pool,
|
||||||
|
types.log.LogLevel.ERROR,
|
||||||
|
"Unknown action '{}' requested by {} from {}".format(action_string, request.user.pretty_name, request.ip),
|
||||||
|
types.log.LogSource.WEB,
|
||||||
|
)
|
||||||
|
|
||||||
if rebuild:
|
if rebuild:
|
||||||
# Rebuild services data, but return only "this" service
|
# Rebuild services data, but return only "this" service
|
||||||
|
Loading…
x
Reference in New Issue
Block a user