Add configurable limit to size of stdout shown for a single job event in list view.

This commit is contained in:
Chris Church
2016-11-21 11:30:11 -05:00
parent b8e7170a72
commit b9eb619697
3 changed files with 33 additions and 0 deletions
+20
View File
@@ -2480,6 +2480,16 @@ class JobEventSerializer(BaseSerializer):
pass
return d
def to_representation(self, obj):
ret = super(JobEventSerializer, self).to_representation(obj)
# Show full stdout for event detail view, truncate only for list view.
if hasattr(self.context.get('view', None), 'retrieve'):
return ret
max_bytes = settings.EVENT_STDOUT_MAX_BYTES_DISPLAY
if max_bytes > 0 and 'stdout' in ret and len(ret['stdout']) >= max_bytes:
ret['stdout'] = ret['stdout'][:(max_bytes - 1)] + u'\u2026'
return ret
class AdHocCommandEventSerializer(BaseSerializer):
@@ -2501,6 +2511,16 @@ class AdHocCommandEventSerializer(BaseSerializer):
res['host'] = reverse('api:host_detail', args=(obj.host.pk,))
return res
def to_representation(self, obj):
ret = super(JobEventSerializer, self).to_representation(obj)
# Show full stdout for event detail view, truncate only for list view.
if hasattr(self.context.get('view', None), 'retrieve'):
return ret
max_bytes = settings.EVENT_STDOUT_MAX_BYTES_DISPLAY
if max_bytes > 0 and 'stdout' in ret and len(ret['stdout']) >= max_bytes:
ret['stdout'] = ret['stdout'][:(max_bytes - 1)] + u'\u2026'
return ret
class JobLaunchSerializer(BaseSerializer):