jumpserver/jperm/models.py

67 lines
2.5 KiB
Python
Raw Normal View History

2015-04-20 02:12:11 +00:00
import datetime
from django.db import models
2015-09-08 16:19:17 +00:00
from jasset.models import Asset, AssetGroup
2015-11-05 14:47:45 +00:00
from juser.models import User, UserGroup
2015-04-20 02:12:11 +00:00
2015-10-12 01:58:38 +00:00
class PermLog(models.Model):
datetime = models.DateTimeField(auto_now_add=True)
2015-10-21 12:44:28 +00:00
action = models.CharField(max_length=100, null=True, blank=True, default='')
results = models.CharField(max_length=1000, null=True, blank=True, default='')
is_success = models.BooleanField(default=False)
is_finish = models.BooleanField(default=False)
2015-10-24 15:52:06 +00:00
class SysUser(models.Model):
username = models.CharField(max_length=100)
password = models.CharField(max_length=100)
comment = models.CharField(max_length=100, null=True, blank=True, default='')
class PermSudo(models.Model):
name = models.CharField(max_length=100, unique=True)
date_added = models.DateTimeField(auto_now=True)
2015-11-29 07:18:05 +00:00
runas = models.CharField(max_length=200, default='root')
commands = models.TextField()
comment = models.CharField(max_length=100, null=True, blank=True, default='')
def __unicode__(self):
return self.name
2015-11-05 14:47:45 +00:00
class PermRole(models.Model):
2015-11-14 14:54:29 +00:00
name = models.CharField(max_length=100, unique=True)
comment = models.CharField(max_length=100, null=True, blank=True, default='')
password = models.CharField(max_length=100)
key_path = models.CharField(max_length=100)
2015-11-13 05:06:17 +00:00
date_added = models.DateTimeField(auto_now=True)
sudo = models.ManyToManyField(PermSudo, related_name='perm_role')
2015-11-05 14:47:45 +00:00
def __unicode__(self):
return self.name
2015-11-05 14:47:45 +00:00
2015-11-13 05:06:17 +00:00
class PermRule(models.Model):
date_added = models.DateTimeField(auto_now=True)
2015-11-17 06:10:46 +00:00
name = models.CharField(max_length=100, unique=True)
2015-11-13 05:06:17 +00:00
comment = models.CharField(max_length=100)
asset = models.ManyToManyField(Asset, related_name='perm_rule')
asset_group = models.ManyToManyField(AssetGroup, related_name='perm_rule')
user = models.ManyToManyField(User, related_name='perm_rule')
user_group = models.ManyToManyField(UserGroup, related_name='perm_rule')
role = models.ManyToManyField(PermRole, related_name='perm_rule')
def __unicode__(self):
return self.name
class PermPush(models.Model):
date_added = models.DateTimeField(auto_now=True)
asset = models.ManyToManyField(Asset, related_name='perm_push')
asset_group = models.ManyToManyField(AssetGroup, related_name='perm_push')
role = models.ManyToManyField(PermRole, related_name='perm_push')
is_public_key = models.BooleanField(default=False)
is_password = models.BooleanField(default=False)