Commit 72e255a6 authored by Oleg Borisenko's avatar Oleg Borisenko
Browse files

queue and logs tab

parent 495988a1
......@@ -5,6 +5,7 @@ def includeme(config):
config.add_route('targets', '/targets')
config.add_route('tapes', '/tapes')
config.add_route('files', '/files')
config.add_route('queue_and_log', '/queue_and_log')
config.add_route('library_scan', '/library_scan')
config.add_route('add_backup_target', '/add_backup_target')
......
......@@ -35,6 +35,7 @@
кассет</a>
<a href="/files" class="navbar-menu-link" id="files">Обзор файлов</a>
<!--<a href="/labnums" class="navbar-menu-link" id="labnums">Обзор лаб.номеров</a>-->
<a href="/queue_and_log" class="navbar-menu-link" id="queue_and_log">Очереди и лог</a>
</nav>
</div>
</div>
......
{% extends "base.jinja2" %}
{% block content %}
<p>Формируется очередей: {{ new_len }}</p>
<p>Очередей в процессе бэкапа: {{ in_progress_len }}</p>
<p>Файлов в текущей очереди бэкапа: {{ in_progress_remaining_files }}</p>
<p>Завершенных очередей бэкапа: {{ finished_len }}</p>
{# нужно вставить кнопку для очистки стертых файлов#}
{# нужно вставить отфильтрованный лог и поменять уровни логирования#}
{% endblock %}
\ No newline at end of file
......@@ -313,3 +313,45 @@ def add_to_restore_queue(request):
_query=(('result', e.detail),
('color', 'red')))
return HTTPFound(location=next_url)
@view_config(route_name="queue_and_log", renderer='tapebackup:templates/queue_and_log.jinja2')
def queue_and_log(request):
try:
backup_queues = request.dbsession.query(models.Batch).all()
new = []
in_progress = []
paused = [] # need this state for clearer model state and debug
finished = [] # need to be very careful here: shouldn't be able to start one if there is any in less state
cancelled = []
finalized = []
for i in backup_queues:
if i.status == models.BatchStatus.new:
new.append(i)
if i.status == models.BatchStatus.in_progress:
in_progress.append(i)
if i.status == models.BatchStatus.paused:
paused.append(i)
if i.status == models.BatchStatus.finished:
finished.append(i)
if i.status == models.BatchStatus.cancelled:
cancelled.append(i)
if i.status == models.BatchStatus.finalized:
finalized.append(i)
in_progress_remaining_files = 0
for i in in_progress:
in_progress_remaining_files += len(i.files_to_backup)
return {"new_len": len(new),
"in_progress_len": len(in_progress),
"paused_len": len(paused),
"finished_len": len(finished),
"cancelled_len": len(cancelled),
"finalized_len": len(finalized),
"in_progress_remaining_files": in_progress_remaining_files
}
except HTTPException as e:
next_url = request.route_url('files',
_query=(('result', e.detail),
('color', 'red')))
return HTTPFound(location=next_url)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment