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
019f1b29
Commit
019f1b29
authored
May 18, 2016
by
Daniele Venzano
Browse files
Create start execution pages and add back links
parent
53712709
Changes
10
Hide whitespace changes
Inline
Side-by-side
zoe_web/web/__init__.py
View file @
019f1b29
...
...
@@ -18,7 +18,6 @@ from flask import Blueprint
web_bp
=
Blueprint
(
'web'
,
__name__
,
template_folder
=
'templates'
,
static_folder
=
'static'
)
import
zoe_web.web.start
import
zoe_web.web.status
import
zoe_web.web.executions
from
zoe_lib.version
import
ZOE_API_VERSION
,
ZOE_VERSION
...
...
zoe_web/web/executions.py
View file @
019f1b29
...
...
@@ -13,34 +13,60 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
json
import
re
from
flask
import
render_template
,
request
,
redirect
,
url_for
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
import
zoe_lib.exceptions
import
zoe_lib.applications
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>'
)
def
execution_start
(
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
)
if
application
is
None
:
return
abort
(
404
)
def
error_page
(
error_message
,
status
):
return
render_template
(
'error.html'
,
error
=
error_message
),
status
template_vars
=
{
"user_id"
:
user
.
id
,
"email"
:
user
.
email
,
'app'
:
application
}
return
render_template
(
'execution_new.html'
,
**
template_vars
)
@
web_bp
.
route
(
'/executions/new'
)
def
execution_define
():
auth
=
request
.
authorization
if
not
auth
:
return
missing_auth
()
return
render_template
(
'execution_new.html'
)
@
web_bp
.
route
(
'/executions/start'
,
methods
=
[
'POST'
])
def
execution_start
():
auth
=
request
.
authorization
if
not
auth
:
return
missing_auth
()
guest_identifier
=
auth
.
username
guest_password
=
auth
.
password
app_descr_json
=
request
.
files
[
'file'
].
read
()
app_descr
=
json
.
loads
(
app_descr_json
.
decode
(
'utf-8'
))
try
:
zoe_lib
.
applications
.
app_validate
(
app_descr
)
except
zoe_lib
.
exceptions
.
InvalidApplicationDescription
as
e
:
return
error_page
(
e
.
message
,
400
)
exec_name
=
request
.
form
[
'exec_name'
]
if
3
>
len
(
exec_name
)
>
128
:
return
error_page
(
"Execution name must be between 4 and 128 characters long"
,
400
)
if
not
re
.
match
(
r
'^[a-zA-Z0-9\-]+$'
,
exec_name
):
return
error_page
(
"Execution name can contain only letters, numbers and dashes. '{}' is not valid."
.
format
(
exec_name
))
exec_api
=
ZoeExecutionsAPI
(
get_conf
().
master_url
,
guest_identifier
,
guest_password
)
new_id
=
exec_api
.
execution_start
(
exec_name
,
app_descr
)
return
redirect
(
url_for
(
'web.execution_inspect'
,
execution_id
=
new_id
))
@
web_bp
.
route
(
'/executions/restart/<int:execution_id>'
)
...
...
zoe_web/web/status.py
deleted
100644 → 0
View file @
53712709
# Copyright (c) 2015, Daniele Venzano
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
zoe_lib.users
as
us
from
flask
import
render_template
,
redirect
,
url_for
,
session
from
zoe_web.web
import
web_bp
@
web_bp
.
route
(
'/status/platform'
)
def
status_platform
():
user
=
us
.
user_get
(
session
[
'user_id'
])
if
user
is
None
:
return
redirect
(
url_for
(
'web.index'
))
platform_stats
=
di
.
platform_stats
()
template_vars
=
{
"user_id"
:
user
.
id
,
"platform"
:
platform_stats
}
return
render_template
(
'platform_stats.html'
,
**
template_vars
)
zoe_web/web/templates/_formhelpers.html
deleted
100644 → 0
View file @
53712709
{% macro render_field(field) %}
<dt>
{{ field.label }}
<dd>
{{ field(**kwargs)|safe }}
{% if field.errors %}
<ul
class=
errors
>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
</dd>
{% endmacro %}
\ No newline at end of file
zoe_web/web/templates/base_user.html
View file @
019f1b29
{% extends "base.html" %}
{% block footer %}
<p>
Back to the
<a
href=
"{{ url_for(
'
web.home
') }}"
>
user home pag
e
</a></p>
<p><a
href=
"{{ url_for(
"
web.home
_user
")
}}"
>
Hom
e
</a></p>
{{ super() }}
{% endblock %}
zoe_web/web/templates/error.html
0 → 100644
View file @
019f1b29
{% extends "base.html" %}
{% block title %}Error{% endblock %}
{% block content %}
<h1
style=
"color: red"
>
Error!
</h1>
<p>
{{ error }}
</p>
{% endblock %}
zoe_web/web/templates/execution_inspect.html
View file @
019f1b29
{% extends "base.html" %}
{% extends "base
_user
.html" %}
{% block title %}Inspect execution {{ e['name'] }}{% endblock %}
{% block content %}
<h2>
Detailed information for execution {{ e['name'] }}
</h2>
...
...
@@ -24,6 +24,9 @@
{% endif %}
<div
id=
"container_list"
>
{% if services|length > 0 %}
<p>
Services:
</p>
{% endif %}
<ul>
{% for s in services %}
<li
class=
"container_name"
id=
"{{ s['id'] }}"
>
{{ s['name'] }}
</li>
...
...
zoe_web/web/templates/execution_new.html
View file @
019f1b29
{% extends "base.html" %}
{% block title %}
{{ app.description.name }} startup
{% endblock %}
{% extends "base
_user
.html" %}
{% block title %}
New execution definition
{% endblock %}
{% block content %}
<h1>
New {{ app.description.name }} execution
</h1>
<h1>
New execution
</h1>
<form
method=
"post"
action=
"{{ url_for('web.execution_start') }}"
enctype=
"multipart/form-data"
>
<label>
Execution name:
<input
type=
"text"
name=
"exec_name"
></label><br>
<label>
Application description:
<input
type=
"file"
name=
"file"
></label><br>
<input
type=
"submit"
value=
"Start!"
>
</form>
<p
id=
"starting"
>
Starting execution...
</p>
<p
id=
"scheduled"
style=
"display: none"
>
Your execution request has been schduled and will be served as soon as possible.
You can monitor application status from the
<a
href=
"{{ url_for("
web.home
")
}}"
>
home page
</a>
.
</p>
<p
id=
"schedule_error"
style=
"display: none"
>
Your execution request has been denied. The system is not currently able to satisfy the
application resource requirements.
</p>
<p
id=
"communication_error"
style=
"display: none"
>
Error: there is a communication problem with the Zoe web server. Is the network
still available?.
</p>
<script
type=
"application/javascript"
>
function
completeHandler
(
e
)
{
if
(
e
.
status
==
"
ok
"
)
{
$
(
"
#starting
"
).
hide
();
$
(
"
#scheduled
"
).
show
();
}
else
{
$
(
"
#starting
"
).
hide
();
$
(
"
#schedule_error
"
).
show
();
}
return
false
;
}
function
errorHandler
()
{
$
(
"
#starting
"
).
hide
();
$
(
"
#communication_error
"
).
show
();
}
function
start
()
{
$
.
getJSON
(
"
{{ url_for(
"
api
.
execution_start
"
, app_id=app.id) }}
"
)
.
done
(
completeHandler
)
.
error
(
errorHandler
);
}
start
();
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
zoe_web/web/templates/home_user.html
View file @
019f1b29
...
...
@@ -4,6 +4,7 @@
<div
id=
"my_executions"
>
<h3>
Executions
</h3>
<p><a
href=
"{{ url_for('web.execution_define') }}"
>
New execution
</a></p>
<table
id=
"exec_list"
class=
"app_list sortable"
>
<thead>
<tr>
...
...
zoe_web/web/templates/platform_stats.html
deleted
100644 → 0
View file @
53712709
{% extends "base_user.html" %}
{% block title %}Status{% endblock %}
{% block content %}
<h2>
System status overview
</h2>
<h3>
Scheduler stats
</h3>
<ul>
<li>
Running applications: {{ platform['scheduler']['count_running'] }}
</li>
<li>
Waiting applications: {{ platform['scheduler']['count_waiting'] }}
</li>
</ul>
<h3>
Swarm staus
</h3>
<ul>
<li>
Running containers: {{ platform.swarm.container_count }}
</li>
<li>
Images: {{ platform.swarm.image_count }}
</li>
<li>
Total memory: {{ platform.swarm.memory_total|filesizeformat }}
</li>
<li>
Number of cores: {{ platform.swarm.cores_total }}
</li>
<li>
Swarm placement strategy: {{ platform.swarm.placement_strategy }}
</li>
</ul>
<h3>
Node status:
</h3>
{% for node in platform.swarm.nodes %}
<h4>
{{ node.name }}
</h4>
<ul>
<li>
Running containers: {{ node.container_count }}
</li>
<li>
Cores: {{ node.cores_total }}
</li>
<li>
Cores reserved: {{ node.cores_reserved }}
</li>
<li>
Memory: {{ node.memory_total }}
</li>
<li>
Memory reserved: {{ node.memory_reserved }}
</li>
<li>
Labels: {{ node.labels }}
</li>
</ul>
{% endfor %}
{% endblock %}
\ No newline at end of file
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