mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-19 10:26:27 +00:00
perf: 持续优化作业创建
This commit is contained in:
@@ -136,7 +136,7 @@ class JobExecution(JMSOrgBaseModel):
|
||||
)
|
||||
elif self.job.type == 'playbook':
|
||||
runner = PlaybookRunner(
|
||||
self.inventory_path, self.job.playbook.work_path
|
||||
self.inventory_path, self.job.playbook.entry
|
||||
)
|
||||
else:
|
||||
raise Exception("unsupported job type")
|
||||
|
@@ -5,6 +5,7 @@ from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from ops.exception import PlaybookNoValidEntry
|
||||
from orgs.mixins.models import JMSOrgBaseModel
|
||||
|
||||
|
||||
@@ -16,5 +17,10 @@ class Playbook(JMSOrgBaseModel):
|
||||
comment = models.CharField(max_length=1024, default='', verbose_name=_('Comment'), null=True, blank=True)
|
||||
|
||||
@property
|
||||
def work_path(self):
|
||||
return os.path.join(settings.DATA_DIR, "ops", "playbook", self.id.__str__(), "main.yaml")
|
||||
def entry(self):
|
||||
work_dir = os.path.join(settings.DATA_DIR, "ops", "playbook", self.id.__str__())
|
||||
valid_entry = ('main.yml', 'main.yaml', 'main')
|
||||
for f in os.listdir(work_dir):
|
||||
if f in valid_entry:
|
||||
return os.path.join(work_dir, f)
|
||||
raise PlaybookNoValidEntry
|
||||
|
Reference in New Issue
Block a user