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
zoe
main
Commits
2a383f4c
Commit
2a383f4c
authored
May 13, 2016
by
Daniele Venzano
Browse files
Create the execution inspect page
parent
03e41c4b
Changes
4
Hide whitespace changes
Inline
Side-by-side
zoe_web/web/__init__.py
View file @
2a383f4c
...
...
@@ -19,7 +19,7 @@ web_bp = Blueprint('web', __name__, template_folder='templates', static_folder='
import
zoe_web.web.start
import
zoe_web.web.status
import
zoe_web.web.
applica
tions
import
zoe_web.web.
execu
tions
from
zoe_lib.version
import
ZOE_API_VERSION
,
ZOE_VERSION
...
...
zoe_web/web/
applica
tions.py
→
zoe_web/web/
execu
tions.py
View file @
2a383f4c
...
...
@@ -13,30 +13,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
zoe_lib.applications
as
ap
import
zoe_lib.executions
as
ex
import
zoe_lib.users
as
us
from
flask
import
render_template
,
url_for
,
redirect
,
session
,
abort
from
zoe_web.web
import
web_bp
@
web_bp
.
route
(
'/apps/new'
)
def
application_new
():
user
=
us
.
user_get
(
session
[
'user_id'
])
if
user
is
None
:
return
redirect
(
url_for
(
'web.index'
))
template_vars
=
{
"user_id"
:
user
.
id
,
"email"
:
user
.
email
,
}
return
render_template
(
'application_new.html'
,
**
template_vars
)
from
flask
import
render_template
,
request
from
zoe_lib.services
import
ZoeServiceAPI
from
zoe_lib.executions
import
ZoeExecutionsAPI
from
zoe_lib.query
import
ZoeQueryAPI
from
zoe_lib.users
import
ZoeUserAPI
from
zoe_lib.exceptions
import
ZoeAPIException
@
web_bp
.
route
(
'/app/modify/<app_id>'
)
def
application_modify
(
app_id
):
return
redirect
(
url_for
(
'web.index'
))
from
zoe_web.config
import
get_conf
from
zoe_web.web
import
web_bp
from
zoe_web.web.auth
import
missing_auth
@
web_bp
.
route
(
'/executions/start/<app_id>'
)
...
...
@@ -71,31 +58,29 @@ def execution_terminate(exec_id):
return
render_template
(
'execution_terminate.html'
,
**
template_vars
)
@
web_bp
.
route
(
'/apps/delete/<app_id>'
)
def
application_delete
(
app_id
):
user
=
us
.
user_get
(
session
[
'user_id'
])
if
user
is
None
:
return
redirect
(
url_for
(
'web.index'
))
application
=
ap
.
application_get
(
app_id
)
@
web_bp
.
route
(
'/executions/inspect/<int:execution_id>'
)
def
execution_inspect
(
execution_id
):
auth
=
request
.
authorization
if
not
auth
:
return
missing_auth
()
template_vars
=
{
"user_id"
:
user
.
id
,
"email"
:
user
.
email
,
'app'
:
application
}
return
render_template
(
'application_delete.html'
,
**
template_vars
)
guest_identifier
=
auth
.
username
guest_password
=
auth
.
password
exec_api
=
ZoeExecutionsAPI
(
get_conf
().
master_url
,
guest_identifier
,
guest_password
)
cont_api
=
ZoeServiceAPI
(
get_conf
().
master_url
,
guest_identifier
,
guest_password
)
@
web_bp
.
route
(
'/executions/inspect/<execution_id>'
)
def
execution_inspect
(
execution_id
):
user
=
us
.
user_get
(
session
[
'user_id'
])
if
user
is
None
:
return
redirect
(
url_for
(
'web.index'
))
execution
=
ex
.
execution_get
(
execution_id
)
e
=
exec_api
.
execution_get
(
execution_id
)
services
=
[]
for
sid
in
e
[
'services'
]:
services
.
append
(
cont_api
.
get
(
sid
))
for
s
in
services
:
s
[
'ip'
]
=
list
(
s
[
'ip_address'
].
values
())[
0
]
template_vars
=
{
"user_id"
:
user
.
id
,
"email"
:
user
.
email
,
'execution'
:
execution
"e"
:
e
,
"services"
:
services
}
return
render_template
(
'execution_inspect.html'
,
**
template_vars
)
zoe_web/web/templates/execution_inspect.html
View file @
2a383f4c
{% extends "base
_user
.html" %}
{% block title %}Inspect execution {{ e
xecution.
name }}{% endblock %}
{% extends "base.html" %}
{% block title %}Inspect execution {{ e
['
name
']
}}{% endblock %}
{% block content %}
<h2>
Detailed information for execution {{ execution.name }}
</h2>
{% if execution.containers|count == 0 %}
<p>
This application execution has no running containers
</p>
{% else %}
<div
id=
"contents"
>
<div
id=
"container_list"
>
<h2>
Detailed information for execution {{ e['name'] }}
</h2>
<div
id=
"contents"
>
<ul>
<li>
Application name: {{ e['application']['name'] }}
</li>
<li>
Owner: {{ e['owner'] }}
</li>
<li>
Status: {{ e['status'] }}
</li>
<li>
Time submitted:
<script>
format_timestamp
(
"
{{ e['time_scheduled'] }}
"
)
</script></li>
{% if e['time_started'] == None %}
<li>
Not yet
</li>
{% else %}
<li>
Time started:
<script>
format_timestamp
(
"
{{ e['time_started'] }}
"
)
</script></li>
{% endif %}
{% if e['time_finished'] == None %}
<li>
Not yet
</li>
{% else %}
<li>
Time finished:
<script>
format_timestamp
(
"
{{ e['time_finished'] }}
"
)
</script></li>
{% endif %}
</ul>
{% if e['status'] == 'error' %}
<p>
Error message:
<code>
{{ e['error'] }}
</code></p>
{% endif %}
<div
id=
"container_list"
>
<ul>
{% for s in services %}
<li
class=
"container_name"
id=
"{{ s['id'] }}"
>
{{ s['name'] }}
</li>
<ul>
{% for
c
in
execution.containers
%}
<li
class=
"container_name"
id=
"{{ c.id }}"
><span
onclick=
"get_container({{ c.id }})"
class=
"fakelink"
>
{{ c.description.
name }}
</
span
></li>
{% for
p
in
s['ports']
%}
<li
><a
href=
"{{ p['protocol'] }}://{{ s['ip'] }}:{{ p['port_number'] }}{{ p['path'] }}"
>
{{ p['
name
']
}}
</
a
></li>
{% endfor %}
</ul>
</div>
<div
id=
"stats"
>
<ul>
<li>
Memory used
<span
id=
"ram_used"
>
0
</span>
of
<span
id=
"ram_total"
>
0
</span></li>
<li>
Network:
<span
id=
"net_rx"
>
0
</span>
rx,
<span
id=
"net_tx"
>
0
</span>
tx
</li>
<li>
Disk I/O:
<span
id=
"io_bytes_read"
>
0
</span>
read,
<span
id=
"io_bytes_write"
>
0
</span>
written
</li>
</ul>
</div>
<div
id=
"log_area"
>
<textarea
id=
"log"
disabled
></textarea>
</div>
</div>
<script
type=
"application/javascript"
>
function
humanFileSize
(
bytes
)
{
var
si
=
true
;
var
thresh
=
si
?
1000
:
1024
;
if
(
Math
.
abs
(
bytes
)
<
thresh
)
{
return
bytes
+
'
B
'
;
}
var
units
=
si
?
[
'
kB
'
,
'
MB
'
,
'
GB
'
,
'
TB
'
,
'
PB
'
,
'
EB
'
,
'
ZB
'
,
'
YB
'
]
:
[
'
KiB
'
,
'
MiB
'
,
'
GiB
'
,
'
TiB
'
,
'
PiB
'
,
'
EiB
'
,
'
ZiB
'
,
'
YiB
'
];
var
u
=
-
1
;
do
{
bytes
/=
thresh
;
++
u
;
}
while
(
Math
.
abs
(
bytes
)
>=
thresh
&&
u
<
units
.
length
-
1
);
return
bytes
.
toFixed
(
1
)
+
'
'
+
units
[
u
];
}
function
get_log
(
container_id
)
{
$
.
getJSON
(
'
/api/executions/logs/container/
'
+
container_id
)
.
done
(
function
(
data
)
{
$
(
"
#log
"
).
val
(
data
.
log
);
}).
error
(
function
(
data
)
{
$
(
"
#log
"
).
val
(
"
error fetching log
"
);
});
}
function
get_stats
(
container_id
)
{
$
.
getJSON
(
'
/api/executions/stats/container/
'
+
container_id
)
.
done
(
function
(
data
)
{
$
(
"
#ram_used
"
).
text
(
humanFileSize
(
data
.
memory_used
));
$
(
"
#ram_total
"
).
text
(
humanFileSize
(
data
.
memory_total
));
$
(
"
#net_rx
"
).
text
(
humanFileSize
(
data
.
net_bytes_rx
));
$
(
"
#net_tx
"
).
text
(
humanFileSize
(
data
.
net_bytes_tx
));
$
(
"
#io_bytes_read
"
).
text
(
humanFileSize
(
data
.
io_bytes_read
));
$
(
"
#io_bytes_write
"
).
text
(
humanFileSize
(
data
.
io_bytes_write
));
}).
error
(
function
(
data
)
{
$
(
"
#ram_used
"
).
text
(
"
N/A
"
);
$
(
"
#ram_total
"
).
text
(
"
N/A
"
);
$
(
"
#net_rx
"
).
text
(
"
N/A
"
);
$
(
"
#net_tx
"
).
text
(
"
N/A
"
);
});
}
function
get_container
(
container_id
)
{
get_log
(
container_id
);
get_stats
(
container_id
);
}
get_log
({{
(
execution
.
containers
|
first
).
id
}});
get_stats
({{
(
execution
.
containers
|
first
).
id
}});
</script>
{% endif %}
{% endfor %}
</ul>
</div>
{% endblock %}
\ No newline at end of file
</div>
{% endblock %}
zoe_web/web/templates/home_user.html
View file @
2a383f4c
...
...
@@ -21,7 +21,7 @@
<tbody>
{% for e in executions %}
<tr
class=
"{{ loop.cycle('odd', 'even') }}"
>
<td>
{{ e['name'] }}
</td>
<td>
<a
href=
"/executions/inspect/{{ e['id'] }}"
>
{{ e['name'] }}
</
a></
td>
<td>
{{ e['application']['name'] }}
</td>
{% if is_admin %}
<td>
{{ e['owner'] }}
</td>
...
...
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