mirror of
https://github.com/ansible/awx.git
synced 2026-03-23 11:55:04 -02:30
Merge pull request #6628 from rooftopcellist/cap-fix
Capacity percentage fix
This commit is contained in:
@@ -3465,7 +3465,10 @@ class InstanceSerializer(BaseSerializer):
|
|||||||
return obj.consumed_capacity
|
return obj.consumed_capacity
|
||||||
|
|
||||||
def get_percent_capacity_remaining(self, obj):
|
def get_percent_capacity_remaining(self, obj):
|
||||||
return float("{0:.2f}".format((float(obj.consumed_capacity) / float(obj.capacity)) * 100.0))
|
if not obj.capacity or obj.consumed_capacity == obj.capacity:
|
||||||
|
return 0.0
|
||||||
|
else:
|
||||||
|
return float("{0:.2f}".format(((float(obj.capacity) - float(obj.consumed_capacity)) / (float(obj.capacity))) * 100))
|
||||||
|
|
||||||
def get_jobs_running(self, obj):
|
def get_jobs_running(self, obj):
|
||||||
return UnifiedJob.objects.filter(execution_node=obj.hostname, status__in=('running', 'waiting',)).count()
|
return UnifiedJob.objects.filter(execution_node=obj.hostname, status__in=('running', 'waiting',)).count()
|
||||||
@@ -3494,7 +3497,10 @@ class InstanceGroupSerializer(BaseSerializer):
|
|||||||
return obj.consumed_capacity
|
return obj.consumed_capacity
|
||||||
|
|
||||||
def get_percent_capacity_remaining(self, obj):
|
def get_percent_capacity_remaining(self, obj):
|
||||||
return float("{0:.2f}".format((float(obj.consumed_capacity) / float(obj.capacity)) * 100.0))
|
if not obj.capacity or obj.consumed_capacity == obj.capacity:
|
||||||
|
return 0.0
|
||||||
|
else:
|
||||||
|
return float("{0:.2f}".format(((float(obj.capacity) - float(obj.consumed_capacity)) / (float(obj.capacity))) * 100))
|
||||||
|
|
||||||
def get_jobs_running(self, obj):
|
def get_jobs_running(self, obj):
|
||||||
return UnifiedJob.objects.filter(instance_group=obj, status__in=('running', 'waiting',)).count()
|
return UnifiedJob.objects.filter(instance_group=obj, status__in=('running', 'waiting',)).count()
|
||||||
|
|||||||
Reference in New Issue
Block a user