Skip to content
GitLab
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
6afc9c11
Commit
6afc9c11
authored
Sep 14, 2017
by
Daniele Venzano
Browse files
Guest users have a quota of 1 execution running maximum
parent
f6b39c60
Changes
1
Hide whitespace changes
Inline
Side-by-side
zoe_api/api_endpoint.py
View file @
6afc9c11
...
...
@@ -29,6 +29,8 @@ from zoe_lib.config import get_conf
log
=
logging
.
getLogger
(
__name__
)
GUEST_QUOTA_MAX_EXECUTIONS
=
1
class
APIEndpoint
:
"""
...
...
@@ -71,10 +73,14 @@ class APIEndpoint:
except
zoe_lib
.
exceptions
.
InvalidApplicationDescription
as
e
:
raise
zoe_api
.
exceptions
.
ZoeException
(
'Invalid application description: '
+
e
.
message
)
if
3
>
len
(
exec_name
)
>
128
:
raise
zoe_api
.
exceptions
.
ZoeException
(
"Execution name must be between 4 and 128 characters long"
)
if
not
re
.
match
(
r
'^[a-zA-Z0-9\-]+$'
,
exec_name
):
raise
zoe_api
.
exceptions
.
ZoeException
(
"Execution name can contain only letters, numbers and dashes. '{}' is not valid."
.
format
(
exec_name
))
# quota check
if
role
==
"guest"
:
running_execs
=
self
.
execution_list
(
uid
,
role
,
**
{
'status'
:
'running'
})
running_execs
+=
self
.
execution_list
(
uid
,
role
,
**
{
'status'
:
'starting'
})
running_execs
+=
self
.
execution_list
(
uid
,
role
,
**
{
'status'
:
'scheduled'
})
running_execs
+=
self
.
execution_list
(
uid
,
role
,
**
{
'status'
:
'submitted'
})
if
len
(
running_execs
)
>
GUEST_QUOTA_MAX_EXECUTIONS
:
raise
zoe_api
.
exceptions
.
ZoeException
(
'Guest users cannot run more than one execution at a time, quota exceeded.'
)
new_id
=
self
.
sql
.
execution_new
(
exec_name
,
uid
,
application_description
)
success
,
message
=
self
.
master
.
execution_start
(
new_id
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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