mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
calcuate consumed capacity in same way in metrics
We should be consistent about this. Also this takes us from doing a as many queries to the UnifiedJob table as we have instances to doing 1 query to the UnifiedJob table (and both do 1 query to Instances table)
This commit is contained in:
@@ -34,14 +34,14 @@ class TaskManagerInstance:
|
||||
|
||||
|
||||
class TaskManagerInstances:
|
||||
def __init__(self, active_tasks, instances=None):
|
||||
def __init__(self, active_tasks, instances=None, instance_fields=['node_type', 'capacity', 'hostname', 'enabled']):
|
||||
self.instances_by_hostname = dict()
|
||||
self.instance_objects = []
|
||||
if instances is None:
|
||||
instances = (
|
||||
Instance.objects.filter(hostname__isnull=False, enabled=True).exclude(node_type='hop').only('node_type', 'capacity', 'hostname', 'enabled')
|
||||
)
|
||||
instances = Instance.objects.filter(hostname__isnull=False, enabled=True).exclude(node_type='hop').only(*instance_fields)
|
||||
for instance in instances:
|
||||
self.instances_by_hostname[instance.hostname] = TaskManagerInstance(instance)
|
||||
self.instance_objects.append(instance)
|
||||
|
||||
# initialize remaining capacity based on currently waiting and running tasks
|
||||
for task in active_tasks:
|
||||
|
||||
Reference in New Issue
Block a user