jumpserver/apps/ops/models/playbook.py

20 lines
678 B
Python
Raw Normal View History

2022-11-11 11:20:17 +00:00
import os.path
import uuid
from django.conf import settings
2022-09-29 12:44:45 +00:00
from django.db import models
from django.utils.translation import gettext_lazy as _
2022-11-11 11:20:17 +00:00
from common.db.models import BaseCreateUpdateModel
2022-10-08 08:55:14 +00:00
2022-11-11 11:20:17 +00:00
class Playbook(BaseCreateUpdateModel):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=128, verbose_name=_('Name'), null=True)
path = models.FileField(upload_to='playbooks/')
2022-10-08 08:55:14 +00:00
owner = models.ForeignKey('users.User', verbose_name=_("Owner"), on_delete=models.SET_NULL, null=True)
2022-11-11 11:20:17 +00:00
@property
def work_path(self):
2022-11-15 08:29:40 +00:00
return os.path.join(settings.DATA_DIR, "ops", "playbook", self.id.__str__(), "main.yaml")