mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-11-02 23:13:41 +00:00
perf: 优化 ops task
This commit is contained in:
@@ -52,26 +52,26 @@ class PlaybookViewSet(OrgBulkModelViewSet):
|
||||
if 'multipart/form-data' in self.request.headers['Content-Type']:
|
||||
src_path = safe_join(settings.MEDIA_ROOT, instance.path.name)
|
||||
dest_path = safe_join(settings.DATA_DIR, "ops", "playbook", instance.id.__str__())
|
||||
|
||||
try:
|
||||
unzip_playbook(src_path, dest_path)
|
||||
except RuntimeError as e:
|
||||
except RuntimeError:
|
||||
raise JMSException(code='invalid_playbook_file', detail={"msg": "Unzip failed"})
|
||||
|
||||
if 'main.yml' not in os.listdir(dest_path):
|
||||
raise PlaybookNoValidEntry
|
||||
|
||||
else:
|
||||
if instance.create_method == 'blank':
|
||||
dest_path = safe_join(settings.DATA_DIR, "ops", "playbook", instance.id.__str__())
|
||||
os.makedirs(dest_path)
|
||||
with open(safe_join(dest_path, 'main.yml'), 'w') as f:
|
||||
f.write('## write your playbook here')
|
||||
elif instance.create_method == 'blank':
|
||||
dest_path = safe_join(settings.DATA_DIR, "ops", "playbook", instance.id.__str__())
|
||||
os.makedirs(dest_path)
|
||||
with open(safe_join(dest_path, 'main.yml'), 'w') as f:
|
||||
f.write('## write your playbook here')
|
||||
|
||||
|
||||
class PlaybookFileBrowserAPIView(APIView):
|
||||
permission_classes = (RBACPermission,)
|
||||
rbac_perms = {
|
||||
'GET': 'ops.change_playbook',
|
||||
'GET': 'ops.view_playbook',
|
||||
'POST': 'ops.change_playbook',
|
||||
'DELETE': 'ops.change_playbook',
|
||||
'PATCH': 'ops.change_playbook',
|
||||
|
||||
Reference in New Issue
Block a user