mirror of https://github.com/jumpserver/jumpserver
feat: 支持执行目录切换,修改字段显示
parent
25b9739ce3
commit
dcbdb0af4d
|
@ -113,6 +113,13 @@ class JobExecution(JMSOrgBaseModel):
|
|||
def job_type(self):
|
||||
return self.job.type
|
||||
|
||||
def compile_shell(self):
|
||||
if self.job.type != 'adhoc':
|
||||
return
|
||||
result = "{}{}{} ".format('\'', self.job.args, '\'')
|
||||
result += "chdir={}".format(self.job.chdir)
|
||||
return result
|
||||
|
||||
def get_runner(self):
|
||||
inv = self.job.inventory
|
||||
inv.write_to_file(self.inventory_path)
|
||||
|
@ -122,8 +129,9 @@ class JobExecution(JMSOrgBaseModel):
|
|||
extra_vars = {}
|
||||
|
||||
if self.job.type == 'adhoc':
|
||||
args = self.compile_shell()
|
||||
runner = AdHocRunner(
|
||||
self.inventory_path, self.job.module, module_args=self.job.args,
|
||||
self.inventory_path, self.job.module, module_args=args,
|
||||
pattern="all", project_dir=self.private_dir, extra_vars=extra_vars,
|
||||
)
|
||||
elif self.job.type == 'playbook':
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from common.drf.fields import ReadableHiddenField
|
||||
|
@ -17,5 +15,5 @@ class AdHocSerializer(BulkOrgResourceModelSerializer, serializers.ModelSerialize
|
|||
|
||||
class Meta:
|
||||
model = AdHoc
|
||||
fields = ["id", "name", "module", "row_count", "size", "args", "creator", "comment", "date_created",
|
||||
"date_updated"]
|
||||
read_only_field = ["id", "row_count", "size", "creator", "date_created", "date_updated"]
|
||||
fields = read_only_field + ["id", "name", "module", "args", "comment"]
|
||||
|
|
|
@ -24,6 +24,7 @@ class PlaybookSerializer(BulkOrgResourceModelSerializer, serializers.ModelSerial
|
|||
|
||||
class Meta:
|
||||
model = Playbook
|
||||
fields = [
|
||||
"id", "name", "path", "comment", "date_created", "creator", "date_updated"
|
||||
read_only_fields = ["id", "date_created", "date_updated"]
|
||||
fields = read_only_fields + [
|
||||
"id", "name", "comment", "creator",
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue