Skip to content

Commit

Permalink
Find a bug & try to fix it
Browse files Browse the repository at this point in the history
Signed-off-by: Y.Jace Liu <[email protected]>
  • Loading branch information
yjlcoder committed Nov 15, 2017
1 parent c1819ec commit 092ea28
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions alto/unicorn/entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,28 @@ def on_get(self, req, res):
result[task.task_id] = task_dict
res.body = json.dumps(result)


class SchedulingResultLookupEntry(object):
def on_get(self, req, res, task_id):
res.status = falcon.HTTP_200
try:
task = TaskDataProvider().get_task_obj(int(task_id))
scheduling_result = task.scheduling_result
jobs = task.jobs
task_dict = dict()
for job in jobs:
flows = job.flows
job_dict = dict()
for flow in flows:
job_dict[flow.flow_id] = flow.to_dict()
job_dict[flow.flow_id]["avail-bw"] = scheduling_result[flow.flow_id]
task_dict[job.job_id] = job_dict
res.body = json.dumps(task_dict)
except KeyError:
res.body = json.dumps({"error": "orchestrator doesn't have such task id"})
return
scheduling_result = task.scheduling_result
jobs = task.jobs
task_dict = dict()
for job in jobs:
flows = job.flows
job_dict = dict()
for flow in flows:
if flow.flow_id not in scheduling_result.keys():
continue
job_dict[flow.flow_id] = flow.to_dict()
job_dict[flow.flow_id]["avail-bw"] = scheduling_result[flow.flow_id]
task_dict[job.job_id] = job_dict
res.body = json.dumps(task_dict)


class ManagementIPLookupEntry(object):
Expand Down

0 comments on commit 092ea28

Please sign in to comment.