mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
add host_status_counts to adhoc command event
This commit is contained in:
@@ -3443,6 +3443,25 @@ class AdHocCommandSerializer(UnifiedJobSerializer):
|
|||||||
return vars_validate_or_raise(value)
|
return vars_validate_or_raise(value)
|
||||||
|
|
||||||
|
|
||||||
|
class AdHocCommandDetailSerializer(AdHocCommandSerializer):
|
||||||
|
|
||||||
|
host_status_counts = serializers.SerializerMethodField(
|
||||||
|
help_text=_('A count of hosts uniquely assigned to each status.'),
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = AdHocCommand
|
||||||
|
fields = ('*', 'host_status_counts',)
|
||||||
|
|
||||||
|
def get_host_status_counts(self, obj):
|
||||||
|
try:
|
||||||
|
counts = obj.ad_hoc_command_events.only('event_data').get(event='playbook_on_stats').get_host_status_counts()
|
||||||
|
except AdHocCommandEvent.DoesNotExist:
|
||||||
|
counts = {}
|
||||||
|
|
||||||
|
return counts
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandCancelSerializer(AdHocCommandSerializer):
|
class AdHocCommandCancelSerializer(AdHocCommandSerializer):
|
||||||
|
|
||||||
can_cancel = serializers.BooleanField(read_only=True)
|
can_cancel = serializers.BooleanField(read_only=True)
|
||||||
|
|||||||
@@ -4553,7 +4553,7 @@ class HostAdHocCommandsList(AdHocCommandList, SubListCreateAPIView):
|
|||||||
class AdHocCommandDetail(UnifiedJobDeletionMixin, RetrieveDestroyAPIView):
|
class AdHocCommandDetail(UnifiedJobDeletionMixin, RetrieveDestroyAPIView):
|
||||||
|
|
||||||
model = AdHocCommand
|
model = AdHocCommand
|
||||||
serializer_class = AdHocCommandSerializer
|
serializer_class = AdHocCommandDetailSerializer
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandCancel(RetrieveAPIView):
|
class AdHocCommandCancel(RetrieveAPIView):
|
||||||
|
|||||||
@@ -607,6 +607,9 @@ class BaseCommandEvent(CreatedModifiedModel):
|
|||||||
'''
|
'''
|
||||||
return self.event
|
return self.event
|
||||||
|
|
||||||
|
def get_host_status_counts(self):
|
||||||
|
return create_host_status_counts(getattr(self, 'event_data', {}))
|
||||||
|
|
||||||
|
|
||||||
class AdHocCommandEvent(BaseCommandEvent):
|
class AdHocCommandEvent(BaseCommandEvent):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user