Merge pull request #366 from FirmlyReality/batch
Change http url to https url & Add csrf token
This commit is contained in:
commit
9c4d096f75
|
@ -803,6 +803,8 @@ def add_job(user,beans,form):
|
||||||
'message': 'add batch job success'
|
'message': 'add batch job success'
|
||||||
}
|
}
|
||||||
for key in job_data:
|
for key in job_data:
|
||||||
|
if key == 'csrf_token':
|
||||||
|
continue
|
||||||
key_arr = key.split('_')
|
key_arr = key.split('_')
|
||||||
value = job_data[key]
|
value = job_data[key]
|
||||||
if key_arr[0] == 'srcAddr' and value == '':
|
if key_arr[0] == 'srcAddr' and value == '':
|
||||||
|
|
|
@ -22,7 +22,10 @@ class BatchJob(object):
|
||||||
def top_sort(self):
|
def top_sort(self):
|
||||||
logger.debug('top sorting')
|
logger.debug('top sorting')
|
||||||
tasks = self.raw_job_info["tasks"]
|
tasks = self.raw_job_info["tasks"]
|
||||||
|
logger.debug('top sorting test')
|
||||||
dependency_graph = {}
|
dependency_graph = {}
|
||||||
|
logger.debug('top sorting test2')
|
||||||
|
logger.info(tasks)
|
||||||
for task_idx in tasks:
|
for task_idx in tasks:
|
||||||
dependency_graph[task_idx] = set()
|
dependency_graph[task_idx] = set()
|
||||||
task_info = tasks[task_idx]
|
task_info = tasks[task_idx]
|
||||||
|
@ -33,6 +36,7 @@ class BatchJob(object):
|
||||||
if not t in tasks:
|
if not t in tasks:
|
||||||
raise ValueError('task %s is not defined in the dependency of task %s' % (t, task_idx))
|
raise ValueError('task %s is not defined in the dependency of task %s' % (t, task_idx))
|
||||||
dependency_graph[task_idx].add(t)
|
dependency_graph[task_idx].add(t)
|
||||||
|
logger.debug('top sorting end')
|
||||||
while len(dependency_graph) > 0:
|
while len(dependency_graph) > 0:
|
||||||
s = set()
|
s = set()
|
||||||
flag = False
|
flag = False
|
||||||
|
@ -54,6 +58,7 @@ class BatchJob(object):
|
||||||
'task_idx': s,
|
'task_idx': s,
|
||||||
'status': 'pending'
|
'status': 'pending'
|
||||||
})
|
})
|
||||||
|
logger.debug('top sorting return')
|
||||||
|
|
||||||
# get a task and pass it to taskmgr
|
# get a task and pass it to taskmgr
|
||||||
def get_task(self):
|
def get_task(self):
|
||||||
|
@ -89,11 +94,15 @@ class JobMgr(threading.Thread):
|
||||||
# user submit a new job, add this job to queue and database
|
# user submit a new job, add this job to queue and database
|
||||||
def add_job(self, user, job_info):
|
def add_job(self, user, job_info):
|
||||||
try:
|
try:
|
||||||
|
logger.info(self.job_queue)
|
||||||
job = BatchJob(user, job_info)
|
job = BatchJob(user, job_info)
|
||||||
|
logger.info("test2")
|
||||||
job.job_id = self.gen_jobid()
|
job.job_id = self.gen_jobid()
|
||||||
|
logger.info("test3")
|
||||||
self.job_queue.append(job.job_id)
|
self.job_queue.append(job.job_id)
|
||||||
self.job_map[job.job_id] = job
|
self.job_map[job.job_id] = job
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
|
logger.error(err)
|
||||||
return [False, err.args[0]]
|
return [False, err.args[0]]
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return [False, err.args[0]]
|
return [False, err.args[0]]
|
||||||
|
@ -104,6 +113,7 @@ class JobMgr(threading.Thread):
|
||||||
# list a user's all job
|
# list a user's all job
|
||||||
def list_jobs(self,user):
|
def list_jobs(self,user):
|
||||||
res = []
|
res = []
|
||||||
|
logger.info(self.job_queue)
|
||||||
for job_id in self.job_queue:
|
for job_id in self.job_queue:
|
||||||
job = self.job_map[job_id]
|
job = self.job_map[job_id]
|
||||||
logger.debug('job_id: %s, user: %s' % (job_id, job.user))
|
logger.debug('job_id: %s, user: %s' % (job_id, job.user))
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<form id="form" class="form-horizontal" action="/batch_job/{{masterips[0].split("@")[0]}}/add/" method="POST">
|
<form id="form" class="form-horizontal" action="/batch_job/{{masterips[0].split("@")[0]}}/add/" method="POST">
|
||||||
|
|
||||||
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||||
<div class="form-group"><label class="col-sm-2 control-label">Job Name</label>
|
<div class="form-group"><label class="col-sm-2 control-label">Job Name</label>
|
||||||
<div class="col-sm-10"><input type="text" class="form-control" name="jobName" id="job_name"></div>
|
<div class="col-sm-10"><input type="text" class="form-control" name="jobName" id="job_name"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -79,21 +80,19 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block script_src %}
|
{% block script_src %}
|
||||||
<!-- Custom and plugin javascript -->
|
|
||||||
<script src="/static/js/inspinia.js"></script>
|
|
||||||
|
|
||||||
<script src="http://cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
|
<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
|
||||||
|
|
||||||
<!-- Steps -->
|
<!-- Steps -->
|
||||||
<script src="http://cdn.bootcss.com/jquery-steps/1.1.0/jquery.steps.min.js"></script>
|
<script src="//cdn.bootcss.com/jquery-steps/1.1.0/jquery.steps.min.js"></script>
|
||||||
|
|
||||||
<!-- Jquery Validate -->
|
<!-- Jquery Validate -->
|
||||||
<script src="http://cdn.bootcss.com/jquery-validate/1.15.0/jquery.validate.min.js"></script>
|
<script src="//cdn.bootcss.com/jquery-validate/1.15.0/jquery.validate.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script src="http://cdn.bootcss.com/datatables/1.10.11/js/jquery.dataTables.js"></script>
|
<script src="//cdn.bootcss.com/datatables/1.10.11/js/jquery.dataTables.min.js"></script>
|
||||||
<script src="http://cdn.bootcss.com/datatables/1.10.11/js/dataTables.bootstrap.js"></script>
|
<script src="//cdn.bootcss.com/datatables/1.10.11/js/dataTables.bootstrap.min.js"></script>
|
||||||
<script src="http://cdn.bootcss.com/datatables-tabletools/2.1.5/js/TableTools.min.js"></script>
|
<script src="//cdn.bootcss.com/datatables-tabletools/2.1.5/js/TableTools.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
function updateOutput()
|
function updateOutput()
|
||||||
{
|
{
|
||||||
var host = window.location.host;
|
var host = window.location.host;
|
||||||
url = "http://" + host + "/batch/job/output/" + "{{ masterip }}" + "/" + "{{ jobid }}" + "/" + "{{ taskid }}" + "/" + "{{ instid }}" + "/" + "{{ issue }}" + "/";
|
url = "//" + host + "/batch/job/output/" + "{{ masterip }}" + "/" + "{{ jobid }}" + "/" + "{{ taskid }}" + "/" + "{{ instid }}" + "/" + "{{ issue }}" + "/";
|
||||||
$.post(url,{},function(data){
|
$.post(url,{},function(data){
|
||||||
$("#output").html(data.data);
|
$("#output").html(data.data);
|
||||||
},"json");
|
},"json");
|
||||||
|
|
Loading…
Reference in New Issue