Browse Source

fix: 修复批量命令的bug

pull/7910/head
ibuler 3 years ago committed by 老广
parent
commit
a3cddd5d34
  1. 3
      apps/audits/api.py
  2. 4
      apps/ops/models/command.py
  3. 3
      apps/ops/serializers/adhoc.py

3
apps/audits/api.py

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

4
apps/ops/models/command.py

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

3
apps/ops/serializers/adhoc.py

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

Loading…
Cancel
Save