jumpserver/jasset/models.py

44 lines
1.5 KiB
Python
Raw Normal View History

import datetime
2014-12-22 09:18:51 +00:00
from django.db import models
2015-01-10 05:35:56 +00:00
from juser.models import UserGroup
2014-12-22 09:18:51 +00:00
2014-12-22 15:14:29 +00:00
class IDC(models.Model):
name = models.CharField(max_length=40, unique=True)
comment = models.CharField(max_length=80, blank=True, null=True)
2014-12-22 15:14:29 +00:00
def __unicode__(self):
return self.name
2015-01-10 05:30:01 +00:00
2015-01-10 05:35:56 +00:00
class BisGroup(models.Model):
name = models.CharField(max_length=80, unique=True)
comment = models.CharField(max_length=160, blank=True, null=True)
def __unicode__(self):
return self.name
2014-12-22 15:14:29 +00:00
class Asset(models.Model):
LOGIN_TYPE_CHOICES = (
('L', 'LDAP'),
('S', 'SSH_KEY'),
('P', 'PASSWORD'),
('M', 'MAP'),
)
2014-12-22 15:14:29 +00:00
ip = models.IPAddressField(unique=True)
port = models.SmallIntegerField(max_length=5)
2014-12-22 15:14:29 +00:00
idc = models.ForeignKey(IDC)
2015-01-10 05:30:01 +00:00
user_group = models.ManyToManyField(UserGroup)
2015-01-10 05:35:56 +00:00
bis_group = models.ManyToManyField(BisGroup)
login_type = models.CharField(max_length=1, choices=LOGIN_TYPE_CHOICES, default='L')
username_common = models.CharField(max_length=20, blank=True, null=True)
password_common = models.CharField(max_length=80, blank=True, null=True)
username_super = models.CharField(max_length=20, blank=True, null=True)
password_super = models.CharField(max_length=80, blank=True, null=True)
2015-01-10 05:30:01 +00:00
date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now(), null=True)
is_active = models.BooleanField(default=True)
2014-12-22 15:14:29 +00:00
comment = models.CharField(max_length=100, blank=True, null=True)
def __unicode__(self):
return self.ip