jumpserver/apps/assets/models/asset/database.py

35 lines
1.1 KiB
Python
Raw Normal View History

2022-04-02 10:35:46 +00:00
from django.db import models
2022-04-26 13:30:01 +00:00
from django.utils.translation import gettext_lazy as _
2022-04-02 10:35:46 +00:00
from .common import Asset
class Database(Asset):
2022-04-26 13:30:01 +00:00
db_name = models.CharField(max_length=1024, verbose_name=_("Database"), blank=True)
2022-11-30 03:28:51 +00:00
use_ssl = models.BooleanField(default=False, verbose_name=_("Use SSL"))
ca_cert = models.TextField(verbose_name=_("CA cert"), blank=True)
client_cert = models.TextField(verbose_name=_("Client cert"), blank=True)
client_key = models.TextField(verbose_name=_("Client key"), blank=True)
allow_invalid_cert = models.BooleanField(default=False, verbose_name=_('Allow invalid cert'))
2022-04-26 13:30:01 +00:00
2022-04-28 04:47:39 +00:00
def __str__(self):
2022-09-21 03:17:14 +00:00
return '{}({}://{}/{})'.format(self.name, self.type, self.address, self.db_name)
@property
def ip(self):
return self.address
2022-04-28 04:47:39 +00:00
2022-10-19 10:56:46 +00:00
@property
2022-11-01 03:52:51 +00:00
def specific(self):
2022-10-19 10:56:46 +00:00
return {
'db_name': self.db_name,
2022-11-30 03:28:51 +00:00
'use_ssl': self.use_ssl,
'ca_cert': self.ca_cert,
'client_cert': self.client_cert,
'client_key': self.client_key,
'allow_invalid_cert': self.allow_invalid_cert,
2022-10-19 10:56:46 +00:00
}
2022-04-26 13:30:01 +00:00
class Meta:
verbose_name = _("Database")