fix: 修复批量命令的bug

pull/7910/head
ibuler 3 years ago committed by 老广
parent 26b3c60e5c
commit a3cddd5d34

@ -132,7 +132,8 @@ class CommandExecutionHostRelationViewSet(OrgRelationMixin, OrgBulkModelViewSet)
search_fields = ('asset__hostname', ) search_fields = ('asset__hostname', )
http_method_names = ['options', 'get'] http_method_names = ['options', 'get']
rbac_perms = { rbac_perms = {
'GET': 'ops.view_commandexecution' 'GET': 'ops.view_commandexecution',
'list': 'ops.view_commandexecution',
} }
def get_queryset(self): def get_queryset(self):

@ -55,6 +55,10 @@ class CommandExecution(OrgModelMixin):
def user_display(self): def user_display(self):
return str(self.user) return str(self.user)
@lazyproperty
def hosts_display(self):
return ','.join(self.hosts.all().values_list('hostname', flat=True))
@property @property
def result(self): def result(self):
if self._result: if self._result:

@ -136,8 +136,7 @@ class CommandExecutionSerializer(serializers.ModelSerializer):
fields_mini = ['id'] fields_mini = ['id']
fields_small = fields_mini + [ fields_small = fields_mini + [
'command', 'result', 'log_url', 'command', 'result', 'log_url',
'is_finished', 'is_finished', 'date_created', 'date_finished'
'date_created', 'date_finished'
] ]
fields_fk = ['run_as'] fields_fk = ['run_as']
fields_m2m = ['hosts'] fields_m2m = ['hosts']

Loading…
Cancel
Save