Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simone Rossi
main
Commits
13ec2f68
Commit
13ec2f68
authored
Oct 23, 2017
by
Daniele Venzano
Browse files
Create a new admin command to terminate all executions of a user
parent
eb074ab1
Changes
1
Hide whitespace changes
Inline
Side-by-side
zoe_cmd/entrypoint_admin.py
View file @
13ec2f68
...
...
@@ -135,6 +135,20 @@ def exec_rm_cmd(auth, args):
exec_api
.
delete
(
args
.
id
)
def
exec_kill_user_cmd
(
auth
,
args
):
"""Terminates all executions for the given user."""
exec_api
=
ZoeExecutionsAPI
(
auth
[
'url'
],
auth
[
'user'
],
auth
[
'pass'
])
filters
=
{
'status'
:
'running'
,
'user_id'
:
args
.
user_id
}
data
=
exec_api
.
list
(
**
filters
)
print
(
'Terminating {} executions belonging to user {}'
.
format
(
len
(
data
),
args
.
user_id
))
for
execution
in
data
:
exec_api
.
terminate
(
execution
)
print
(
'Execution {} terminated'
.
format
(
execution
))
ENV_HELP_TEXT
=
'''To authenticate with Zoe you need to define three environment variables:
ZOE_URL: point to the URL of the Zoe Scheduler (ex.: http://localhost:5000/
ZOE_USER: the username used for authentication
...
...
@@ -184,6 +198,10 @@ def process_arguments() -> Tuple[ArgumentParser, Namespace]:
argparser_execution_rm
.
add_argument
(
'id'
,
type
=
int
,
help
=
"Execution id"
)
argparser_execution_rm
.
set_defaults
(
func
=
exec_rm_cmd
)
argparser_execution_kill_user
=
subparser
.
add_parser
(
'user-terminate'
,
help
=
"Terminate all executions of a user"
)
argparser_execution_kill_user
.
add_argument
(
'user_id'
,
help
=
"User name"
)
argparser_execution_kill_user
.
set_defaults
(
func
=
exec_kill_user_cmd
)
return
parser
,
parser
.
parse_args
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment