jumpserver/jperm/models.py

61 lines
2.2 KiB
Python
Raw Normal View History

2015-04-20 02:12:11 +00:00
import datetime
from django.db import models
2015-12-19 09:26:34 +00:00
from jasset.models import Asset, AssetGroup
from juser.models import User, UserGroup
2015-04-20 02:12:11 +00:00
2015-12-19 09:26:34 +00:00
class PermLog(models.Model):
datetime = models.DateTimeField(auto_now_add=True)
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-04-20 02:12:11 +00:00
2015-12-19 09:26:34 +00:00
class PermSudo(models.Model):
name = models.CharField(max_length=100, unique=True)
date_added = models.DateTimeField(auto_now=True)
commands = models.TextField()
comment = models.CharField(max_length=100, null=True, blank=True, default='')
2015-04-20 02:12:11 +00:00
def __unicode__(self):
2015-12-19 09:26:34 +00:00
return self.name
2015-04-20 02:12:11 +00:00
2015-12-19 09:26:34 +00:00
class PermRole(models.Model):
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)
date_added = models.DateTimeField(auto_now=True)
sudo = models.ManyToManyField(PermSudo, related_name='perm_role')
2015-04-20 02:12:11 +00:00
def __unicode__(self):
return self.name
2015-12-19 09:26:34 +00:00
class PermRule(models.Model):
date_added = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100, unique=True)
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')
2015-04-20 02:12:11 +00:00
def __unicode__(self):
2015-12-19 09:26:34 +00:00
return self.name
class PermPush(models.Model):
asset = models.ForeignKey(Asset, related_name='perm_push')
role = models.ForeignKey(PermRole, related_name='perm_push')
is_public_key = models.BooleanField(default=False)
is_password = models.BooleanField(default=False)
success = models.BooleanField(default=False)
result = models.TextField(default='')
date_added = models.DateTimeField(auto_now=True)
2015-04-20 02:12:11 +00:00