add batch info in the backend and frontend
This commit is contained in:
parent
f346901fc6
commit
b1aaa558bc
|
@ -880,6 +880,17 @@ def list_job(user,beans,form):
|
|||
}
|
||||
return json.dumps(result)
|
||||
|
||||
@app.route("/batch/job/info/", methods=['POST'])
|
||||
@login_required
|
||||
def info_job(user,beans,form):
|
||||
global G_jobmgr
|
||||
jobid = form.get("jobid","")
|
||||
[success, data] = G_jobmgr.get_job(user, jobid)
|
||||
if success:
|
||||
return json.dumps({'success':'true', 'data':data})
|
||||
else:
|
||||
return json.dumps({'success':'false', 'message': data})
|
||||
|
||||
@app.route("/batch/job/stop/", methods=['POST'])
|
||||
@login_required
|
||||
def stop_job(user,beans,form):
|
||||
|
@ -905,12 +916,6 @@ def get_output(user,beans,form):
|
|||
}
|
||||
return json.dumps(result)
|
||||
|
||||
|
||||
@app.route("/batch/job/info/", methods=['POST'])
|
||||
@login_required
|
||||
def info_job(user,beans,form):
|
||||
pass
|
||||
|
||||
@app.route("/batch/task/info/", methods=['POST'])
|
||||
@login_required
|
||||
def info_task(user,beans,form):
|
||||
|
|
|
@ -353,9 +353,17 @@ class JobMgr():
|
|||
# user: username
|
||||
# jobid: the id of job
|
||||
# get the information of a job, including the status, json description and other information
|
||||
# call get_task to get the task information
|
||||
def get_job(self, user, job_id):
|
||||
pass
|
||||
job = Batchjob.query.get(job_id)
|
||||
if job is None:
|
||||
return [False, "Jobid(%s) does not exist."%job_id]
|
||||
if job.username != user:
|
||||
return [False, "Wrong User!"]
|
||||
jobdata = json.loads(str(job))
|
||||
tasks = job.tasks.all()
|
||||
tasksdata = [json.loads(str(t)) for t in tasks]
|
||||
jobdata['tasks'] = tasksdata
|
||||
return [True, jobdata]
|
||||
|
||||
# check if a job exists
|
||||
def is_job_exist(self, job_id):
|
||||
|
@ -408,6 +416,8 @@ class JobMgr():
|
|||
taskdb.status = status
|
||||
if status == 'failed':
|
||||
taskdb.failed_reason = reason
|
||||
if status == 'failed' or status == 'stopped' or status == 'finished':
|
||||
taskdb.end_time = datetime.now()
|
||||
if billing > 0:
|
||||
taskdb.running_time = running_time
|
||||
taskdb.billing = billing
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
{% extends 'base_AdminLTE.html' %}
|
||||
|
||||
{% block title %}Docklet | Batch Job Info{% endblock %}
|
||||
|
||||
{% block panel_title %}Info for {{ jobinfo['job_id'] }}{% endblock %}
|
||||
|
||||
{% block css_src %}
|
||||
<link href="//cdn.bootcss.com/datatables/1.10.11/css/dataTables.bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//cdn.bootcss.com/datatables/1.10.11/css/jquery.dataTables_themeroller.css" rel="stylesheet">
|
||||
<link href="/static/dist/css/modalconfig.css" rel="stylesheet">
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block panel_list %}
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a href="/dashboard/"><i class="fa fa-dashboard"></i>Home</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='/batch_jobs/'>Batch Job</a>
|
||||
</li>
|
||||
<li class='active'>
|
||||
<strong>Info</strong>
|
||||
</li>
|
||||
</ol>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-info">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Overview</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Job ID</th>
|
||||
<th>Name</th>
|
||||
<th>Priority</th>
|
||||
<th>Status</th>
|
||||
<th>Create Time</th>
|
||||
<th>End Time</th>
|
||||
<th>Billing</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ jobinfo['job_id'] }}</td>
|
||||
<td>{{ jobinfo['job_name'] }}</td>
|
||||
<td>{{ jobinfo['priority'] }}</td>
|
||||
<td>{{ jobinfo['status'] }}</td>
|
||||
<td>{{ jobinfo['create_time'] }}</td>
|
||||
<td>{{ jobinfo['end_time'] }}</td>
|
||||
<td>{{ jobinfo['billing'] }} <img src='/static/img/bean.png' /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-info">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Tasks Overview</h3>
|
||||
|
||||
<div class="box-tools pull-right">
|
||||
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body table-responsive">
|
||||
<table width="100%" cellspacing="0" style="margin: 0 auto;" id="table-tasks" class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Task Index</th>
|
||||
<th>Status</th>
|
||||
<th>Failed Reason(if fails)</th>
|
||||
<th>Tried Times</th>
|
||||
<th>Start Time</th>
|
||||
<th>End Time</th>
|
||||
<th>Total Running Time</th>
|
||||
<th>Billing</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for task in jobinfo['tasks'] %}
|
||||
<tr>
|
||||
<td>{{ task['idx'] }}</td>
|
||||
<td>{{ task['status'] }}</td>
|
||||
<td>{{ task['failed_reason'] }}</td>
|
||||
<td>{{ task['tried_times'] }}</td>
|
||||
<td>{{ task['start_time'] }}</td>
|
||||
<td>{{ task['end_time'] }}</td>
|
||||
<td>{{ task['running_time'] }} s</td>
|
||||
<td>{{ task['billing'] }} <img src='/static/img/bean.png' /></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script_src %}
|
||||
<script src="//cdn.bootcss.com/datatables/1.10.11/js/jquery.dataTables.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/datatables/1.10.11/js/dataTables.bootstrap.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#table-tasks").DataTable({"scrollX":true,"order":[[ 0, "asc" ]]});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
{% block panel_title %}Batch Job{% endblock %}
|
||||
|
||||
{% block css_src %}
|
||||
<link href="//cdn.bootcss.com/datatables/1.10.11/css/dataTables.bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//cdn.bootcss.com/datatables/1.10.11/css/jquery.dataTables_themeroller.css" rel="stylesheet">
|
||||
<link href="/static/dist/css/modalconfig.css" rel="stylesheet">
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block panel_list %}
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
|
@ -85,6 +92,7 @@
|
|||
<th>End Time</th>
|
||||
<th>billing</th>
|
||||
<th>Stdout and Stderr</th>
|
||||
<th>Detailed Info</th>
|
||||
</tr>
|
||||
<thead>
|
||||
<tbody>
|
||||
|
@ -100,12 +108,13 @@
|
|||
{% if job_info['status'] == 'done' or job_info['status'] == 'failed' or job_info['status'] == 'stopping' or job_info['status'] == 'stopped'%}
|
||||
<td><button type="button" class="btn btn-xs btn-default"> Stop </button></td>
|
||||
{% else %}
|
||||
<td><a href="/batch_job/{{master.split("@")[0]}}/stop/{{ job_info['job_id'] }}/"><button type="button" class="btn btn-xs btn-danger"> Stop </button></a></td>
|
||||
<td><a href="/batch_job/{{master.split("@")[0]}}/stop/{{ job_info['job_id'] }}/"><button type="button" class="btn btn-xs btn-danger"> Stop </button></a></td>
|
||||
{% endif %}
|
||||
<td>{{ job_info['create_time'] }}</td>
|
||||
<td>{{ job_info['end_time'] }}</td>
|
||||
<td>{{ job_info['billing'] }} <img src='/static/img/bean.png' /></td>
|
||||
<td><a role="button" class="btn btn-info btn-xs" id='{{ master }}_{{ job_info['job_id'] }}_output' data-toggle="modal" data-target='#OutputModal_{{ master.split('@')[1] }}_{{ job_info['job_id'] }}'>Get Output</a></td>
|
||||
<td><a href="/batch_job/{{master.split("@")[0]}}/info/{{ job_info['job_id'] }}/"><button type="button" class="btn btn-xs btn-info"> Info </button></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -152,10 +152,12 @@ def stop_batch_job(masterip,jobid):
|
|||
stopBatchJobView.jobid = jobid
|
||||
return stopBatchJobView().as_view()
|
||||
|
||||
@app.route("/batch_job/state/", methods=['GET'])
|
||||
@app.route("/batch_job/<masterip>/info/<jobid>/", methods=['GET'])
|
||||
@login_required
|
||||
def state_batch_job():
|
||||
return stateBatchJobView().as_view()
|
||||
def info_batch_job(masterip,jobid):
|
||||
infoBatchJobView.masterip = masterip
|
||||
infoBatchJobView.jobid = jobid
|
||||
return infoBatchJobView().as_view()
|
||||
|
||||
@app.route("/batch_job/output/<masterip>/<jobid>/<taskid>/<vnodeid>/<issue>/", methods=['GET'])
|
||||
@login_required
|
||||
|
|
|
@ -35,15 +35,25 @@ class createBatchJobView(normalView):
|
|||
return self.render(self.template_path, masterips=masterips, images=images)
|
||||
|
||||
|
||||
class stateBatchJobView(normalView):
|
||||
template_path = "batch/batch_state.html"
|
||||
class infoBatchJobView(normalView):
|
||||
template_path = "batch/batch_info.html"
|
||||
error_path = "error.html"
|
||||
masterip = ""
|
||||
jobid = ""
|
||||
|
||||
@classmethod
|
||||
def get(self):
|
||||
if True:
|
||||
return self.render(self.template_path)
|
||||
data = {
|
||||
'jobid':self.jobid
|
||||
}
|
||||
result = dockletRequest.post("/batch/job/info/",data,self.masterip)
|
||||
data = result.get("data")
|
||||
logger.info(str(data))
|
||||
#logger.debug("job_list: %s" % job_list)
|
||||
if result.get('success',"") == "true":
|
||||
return self.render(self.template_path, masterip=self.masterip, jobinfo=data)
|
||||
else:
|
||||
return self.error()
|
||||
return self.render(self.error_path, message = result.get('message'))
|
||||
|
||||
class addBatchJobView(normalView):
|
||||
template_path = "batch/batch_list.html"
|
||||
|
|
Loading…
Reference in New Issue