nomad_running_jobs = {}
nomad_pending_jobs = {}
for (aggregate_key, group) in aggregated_jobs:
if not aggregate_key: continue
aggregated_pending = 0
aggregated_running = 0
for job in group:
children = job["JobSummary"]["Children"]
aggregated_pending = aggregated_pending + children["Pending"]
aggregated_running = aggregated_running + children["Running"]
nomad_pending_jobs[aggregate_key] = aggregated_pending
After Change
nomad_running_jobs = {}
nomad_pending_jobs = {}
for (aggregate_key, group) in aggregated_jobs:
nomad_pending_jobs[aggregate_key] = sum(job["JobSummary"]["Children"]["Pending"] for job in group)
nomad_running_jobs[aggregate_key] = sum(job["JobSummary"]["Children"]["Running"] for job in group)
return nomad_pending_jobs, nomad_running_jobs