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
f8cfca08
Commit
f8cfca08
authored
Aug 30, 2018
by
Daniele Venzano
Browse files
Fix status page for non-admin users
parent
87aa4ae9
Changes
3
Hide whitespace changes
Inline
Side-by-side
zoe_api/api_endpoint.py
View file @
f8cfca08
...
...
@@ -18,7 +18,7 @@
from
datetime
import
timedelta
,
datetime
import
logging
import
os
from
typing
import
List
from
typing
import
List
,
Union
import
zoe_api.exceptions
import
zoe_api.master_api
...
...
@@ -41,13 +41,13 @@ class APIEndpoint:
self
.
master
=
master_api
self
.
sql
=
sql_manager
def
execution_by_id
(
self
,
user
:
zoe_lib
.
state
.
User
,
execution_id
:
int
)
->
zoe_lib
.
state
.
Execution
:
def
execution_by_id
(
self
,
user
:
Union
[
None
,
zoe_lib
.
state
.
User
]
,
execution_id
:
int
)
->
zoe_lib
.
state
.
Execution
:
"""Lookup an execution by its ID."""
e
=
self
.
sql
.
executions
.
select
(
id
=
execution_id
,
only_one
=
True
)
if
e
is
None
:
raise
zoe_api
.
exceptions
.
ZoeNotFoundException
(
'No such execution'
)
assert
isinstance
(
e
,
zoe_lib
.
state
.
Execution
)
if
e
.
user_id
!=
user
.
id
and
not
user
.
role
.
can_operate_others
:
if
user
is
not
None
and
e
.
user_id
!=
user
.
id
and
not
user
.
role
.
can_operate_others
:
raise
zoe_api
.
exceptions
.
ZoeAuthException
()
return
e
...
...
zoe_api/web/status.py
View file @
f8cfca08
...
...
@@ -16,7 +16,7 @@
"""Main points of entry for the Zoe web interface."""
from
zoe_api.web.request_handler
import
ZoeWebRequestHandler
from
zoe_api.exceptions
import
ZoeException
from
zoe_api.exceptions
import
ZoeException
,
ZoeAuthException
class
StatusEndpointWeb
(
ZoeWebRequestHandler
):
...
...
@@ -33,9 +33,9 @@ class StatusEndpointWeb(ZoeWebRequestHandler):
executions_in_queue
=
{}
for
exec_id
in
stats
[
'queue'
]:
executions_in_queue
[
exec_id
]
=
self
.
api_endpoint
.
execution_by_id
(
self
.
current_user
,
exec_id
)
executions_in_queue
[
exec_id
]
=
self
.
api_endpoint
.
execution_by_id
(
None
,
exec_id
)
for
exec_id
in
stats
[
'running_queue'
]:
executions_in_queue
[
exec_id
]
=
self
.
api_endpoint
.
execution_by_id
(
self
.
current_user
,
exec_id
)
executions_in_queue
[
exec_id
]
=
self
.
api_endpoint
.
execution_by_id
(
None
,
exec_id
)
services_per_node
=
{}
for
node
in
stats
[
'platform_stats'
][
'nodes'
]:
...
...
zoe_api/web/templates/status.jinja2
View file @
f8cfca08
...
...
@@ -41,7 +41,11 @@
<div class="scheduler_queue">
{% for id in stats['queue'] %}
<div class="queue_item" id="{{ id }}">
<a href="{{ reverse_url('execution_inspect', id) }}">{{ id }}</a> ({{ executions_in_queue[id].user_id }})
{% if user.role.can_operate_others %}
<a href="{{ reverse_url('execution_inspect', id) }}">{{ id }}</a> ({{ executions_in_queue[id].owner.username }})
{% else %}
{{ id }} ({{ executions_in_queue[id].owner.username }})
{% endif %}
{% for service in executions_in_queue[id].services %}
{% if service.essential %}
<div class="service essential {{ 'running' if not service.is_dead() }}">
...
...
@@ -71,8 +75,12 @@
<p>This queue is unsorted, all services here should be green.</p>
<div class="scheduler_queue">
{% for id in stats['running_queue'] %}
<div class="queue_item" id="{{ id }}">
<a href="{{ reverse_url('execution_inspect', id) }}">{{ id }}</a> ({{ executions_in_queue[id].user_id }})
<div class="queue_item" id="{{ id }}">
{% if user.role.can_operate_others %}
<a href="{{ reverse_url('execution_inspect', id) }}">{{ id }}</a> ({{ executions_in_queue[id].owner.username }})
{% else %}
{{ id }} ({{ executions_in_queue[id].owner.username }})
{% endif %}
{% for service in executions_in_queue[id].services %}
{% if service.essential %}
<div class="service essential {{ 'running' if service.status == service.ACTIVE_STATUS }}">
...
...
@@ -230,7 +238,14 @@
<td class="cell-host">{{ node.name }}</td>
{% for service in services_per_node[node.name] %}
{% if service.backend_status == "started" %}
<td class="{{ 'running' if service.essential }}"><a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a> (M: <script>format_bytes({{ node.service_stats[service['id']]['mem_limit'] }});</script> C: {{ '%0.2f'|format(node.service_stats[service['id']]['core_limit']|float) }})</td>
<td class="{{ 'running' if service.essential }}">
{% if user.role.can_operate_others %}
<a href="{{ reverse_url('execution_inspect', service['execution_id']) }}">{{ service['name'] }}</a>
{% else %}
{{ service['name'] }}
{% endif %}
(M: <script>format_bytes({{ node.service_stats[service['id']]['mem_limit'] }});</script> C: {{ '%0.2f'|format(node.service_stats[service['id']]['core_limit']|float) }})
</td>
{% endif %}
{% endfor %}
</tr>
...
...
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