mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
make jobs_running more rich in OPTIONS
* Expose jobs_running as an IntegerField
This commit is contained in:
parent
c7ecbb7d2a
commit
8438331563
@ -4506,6 +4506,12 @@ class InstanceSerializer(BaseSerializer):
|
||||
consumed_capacity = serializers.SerializerMethodField()
|
||||
percent_capacity_remaining = serializers.SerializerMethodField()
|
||||
jobs_running = serializers.SerializerMethodField()
|
||||
jobs_running = serializers.IntegerField(
|
||||
help_text=_('Count of jobs in the running or waiting state that '
|
||||
'are targeted for this instance'),
|
||||
read_only=True
|
||||
)
|
||||
|
||||
|
||||
class Meta:
|
||||
model = Instance
|
||||
@ -4529,9 +4535,6 @@ class InstanceSerializer(BaseSerializer):
|
||||
else:
|
||||
return float("{0:.2f}".format(((float(obj.capacity) - float(obj.consumed_capacity)) / (float(obj.capacity))) * 100))
|
||||
|
||||
def get_jobs_running(self, obj):
|
||||
return UnifiedJob.objects.filter(execution_node=obj.hostname, status__in=('running', 'waiting',)).count()
|
||||
|
||||
|
||||
class InstanceGroupSerializer(BaseSerializer):
|
||||
|
||||
|
@ -85,6 +85,10 @@ class Instance(models.Model):
|
||||
# NOTE: TODO: Likely to repurpose this once standalone ramparts are a thing
|
||||
return "awx"
|
||||
|
||||
@property
|
||||
def jobs_running(self):
|
||||
return UnifiedJob.objects.filter(execution_node=self.hostname, status__in=('running', 'waiting',)).count()
|
||||
|
||||
def is_lost(self, ref_time=None, isolated=False):
|
||||
if ref_time is None:
|
||||
ref_time = now()
|
||||
|
Loading…
Reference in New Issue
Block a user