forked from qitan/devops-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
101 lines (81 loc) · 4.17 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python
# coding: utf8
'''
@author: qitan
@contact: [email protected]
@file: models.py
@time: 2017/3/30 15:34
@desc:
'''
from __future__ import unicode_literals
from django.db import models
from django.core.validators import RegexValidator
# Create your models here.
class ServerAsset(models.Model):
nodename = models.CharField(max_length=50, unique=True, default=None, verbose_name=u'Salt主机')
hostname = models.CharField(max_length=50, unique=True, verbose_name=u'主机名')
manufacturer = models.CharField(max_length=20, blank=True, verbose_name=u'厂商')
productname = models.CharField(max_length=100, blank=True, verbose_name=u'型号')
sn = models.CharField(max_length=20, blank=True, verbose_name=u'序列号')
cpu_model = models.CharField(max_length=100, blank=True, verbose_name=u'CPU型号')
cpu_nums = models.PositiveSmallIntegerField(verbose_name=u'CPU线程')
memory = models.CharField(max_length=20, verbose_name=u'内存')
disk = models.TextField(blank=True, verbose_name=u'硬盘')
network = models.TextField(blank=True, verbose_name=u'网络接口')
os = models.CharField(max_length=200, blank=True, verbose_name=u'操作系统')
virtual = models.CharField(max_length=20, blank=True, verbose_name=u'虚拟化')
kernel = models.CharField(max_length=200, blank=True, verbose_name=u'内核')
shell = models.CharField(max_length=10, blank=True, verbose_name=u'Shell')
zmqversion = models.CharField(max_length=10, blank=True, verbose_name=u'ZeroMQ')
saltversion = models.CharField(max_length=10, blank=True, verbose_name=u'Salt版本')
locale = models.CharField(max_length=200, blank=True, verbose_name=u'编码')
selinux = models.CharField(max_length=50, blank=True, verbose_name=u'Selinux')
idc = models.CharField(max_length=50, blank=True, verbose_name=u'机房')
def __unicode__(self):
return self.hostname
class Meta:
default_permissions = ()
permissions = (
("view_asset", u"查看资产"),
("edit_asset", u"管理资产"),
)
verbose_name = u'主机资产信息'
verbose_name_plural = u'主机资产信息管理'
class IdcAsset(models.Model):
idc_name = models.CharField(max_length=20, verbose_name=u'机房名称')
idc_type = models.CharField(max_length=20, blank=True, verbose_name=u'机房类型')
idc_location = models.CharField(max_length=100, verbose_name=u'机房位置')
contract_date = models.CharField(max_length=30, verbose_name=u'合同时间')
idc_contacts = models.CharField(max_length=30, verbose_name=u'联系电话', validators=[
RegexValidator(regex='^[^0]\d{6,7}$|^[1]\d{10}$', message='请输入正确的电话或手机号码', code='号码错误')],
error_messages={'required': u'联系电话不能为空'})
remark = models.TextField(max_length=255, blank=True, verbose_name=u'备注', default='')
def __unicode__(self):
return self.idc_name
class Meta:
default_permissions = ()
verbose_name = u'IDC资产信息'
verbose_name_plural = u'IDC资产信息管理'
class Provinces(models.Model):
provinceid = models.CharField(max_length=20, unique=True, verbose_name=u'省份代码')
province = models.CharField(max_length=50, verbose_name=u'省份')
def __unicode__(self):
return self.province
class Meta:
default_permissions = ()
class Cities(models.Model):
cityid = models.CharField(max_length=20, unique=True, verbose_name=u'城市代码')
city = models.CharField(max_length=50, verbose_name=u'城市')
province = models.ForeignKey(Provinces, verbose_name=u'省份', related_name='province_city_set')
def __unicode__(self):
return self.city
class Meta:
default_permissions = ()
class Areas(models.Model):
areaid = models.CharField(max_length=20, unique=True, verbose_name=u'区域代码')
area = models.CharField(max_length=50, verbose_name=u'区县')
city = models.ForeignKey(Cities, verbose_name=u'城市', related_name='city_area_set')
def __unicode__(self):
return self.area
class Meta:
default_permissions = ()