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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
from django.db import models
# Create your models here.
class Host(models.Model):
NETGROUP_CHOICES = (
('none', 'none'),('cave', 'cave'),('ccst', 'ccst'),('mcs', 'mcs'),
('mmlab', 'mmlab'),('sp', 'sp'),('red', 'red'),('virtual', 'virtual'),
('win', 'win'),('xterm', 'xterm'),('lcrc', 'lcrc'),('anlext', 'anlext'),
('teragrid', 'teragrid')
)
STATUS_CHOICES = (
('active','active'),('dormant','dormant')
)
SUPPORT_CHOICES = (
('green','green'),('yellow','yellow'),('red','red')
)
CLASS_CHOICES = (
('scientific','scientific'),
('operations','operations'),('guest','guest'),
('confidential','confidential'),('public','public')
)
WHATAMI_CHOICES = (
('aix-3', 'aix-3'), ('aix-4', 'aix-4'),
('aix-5', 'aix-5'), ('baytech', 'baytech'),
('decserver', 'decserver'), ('dialup', 'dialup'),
('dos', 'dos'), ('freebsd', 'freebsd'),
('hpux', 'hpux'), ('irix-5', 'irix-5'),
('irix-6', 'irix-6'), ('linux', 'linux'),
('linux-2', 'linux-2'), ('linux-rh73', 'linux-rh73'),
('linux-rh8', 'linux-rh8'), ('linux-sles8', 'linux-sles8'),
('linux-sles8-64', 'linux-sles8-64'), ('linux-sles8-ia32', 'linux-sles8-ia32'),
('linux-sles8-ia64', 'linux-sles8-ia64'), ('mac', 'mac'),
('network', 'network'), ('next', 'next'),
('none', 'none'), ('osf', 'osf'), ('printer', 'printer'),
('robot', 'robot'), ('solaris-2', 'solaris-2'),
('sun4', 'sun4'), ('unknown', 'unknown'), ('virtual', 'virtual'),
('win31', 'win31'), ('win95', 'win95'),
('winNTs', 'winNTs'), ('winNTw', 'winNTw'),
('win2k', 'win2k'), ('winXP', 'winXP'), ('xterm', 'xterm')
)
hostname = models.CharField(maxlength=64)
whatami = models.CharField(maxlength=16)
netgroup = models.CharField(maxlength=32, choices=NETGROUP_CHOICES)
security_class = models.CharField('class', maxlength=16)
support = models.CharField(maxlength=8, choices=SUPPORT_CHOICES)
csi = models.CharField(maxlength=32, blank=True)
printq = models.CharField(maxlength=32, blank=True)
outbound_smtp = models.BooleanField()
primary_user = models.EmailField()
administrator = models.EmailField(blank=True)
location = models.CharField(maxlength=16)
comments = models.TextField(blank=True)
expiration_date = models.DateField(null=True, blank=True)
last = models.DateField(auto_now=True, auto_now_add=True)
status = models.CharField(maxlength=7, choices=STATUS_CHOICES)
dirty = models.BooleanField()
class Admin:
list_display = ('hostname', 'last')
search_fields = ['hostname']
def __str__(self):
return self.hostname
class Interface(models.Model):
TYPE_CHOICES = (
('eth', 'ethernet'), ('wl', 'wireless'), ('virtual', 'virtual'), ('myr', 'myr'),
('mgmt', 'mgmt'), ('tape', 'tape'), ('fe', 'fe'), ('ge', 'ge'), ('virtual', 'virtual')
)
host = models.ForeignKey(Host, edit_inline=models.TABULAR, num_in_admin=2)
mac_addr = models.CharField(maxlength=32, core=True)
hdwr_type = models.CharField('type', maxlength=16, choices=TYPE_CHOICES,
radio_admin=True, blank=True)
dhcp = models.BooleanField()
def __str__(self):
return self.mac_addr
class Admin:
list_display = ('mac_addr', 'host')
search_fields = ['mac_addr']
class IP(models.Model):
interface = models.ForeignKey(Interface,
edit_inline=models.TABULAR, num_in_admin=1)
ip_addr = models.IPAddressField(core=True)
def __str__(self):
return self.ip_addr
class Admin:
pass
class Meta:
ordering = ('ip_addr', )
class MX(models.Model):
priority = models.IntegerField(blank=True)
mx = models.CharField(maxlength=64, core=True, blank=True)
def __str__(self):
return (" ".join([str(self.priority), self.mx]))
class Admin:
pass
class Name(models.Model):
DNS_CHOICES = (
('global','global'),('internal','ANL internal'),
('private','private')
)
ip = models.ForeignKey(IP, edit_inline=models.TABULAR, num_in_admin=1)
name = models.CharField(maxlength=64, core=True)
dns_view = models.CharField(maxlength=16, choices=DNS_CHOICES)
only = models.BooleanField(blank=True)
mxs = models.ManyToManyField(MX)
def __str__(self):
return self.name
class Admin:
pass
class CName(models.Model):
name = models.ForeignKey(Name, edit_inline=models.TABULAR, num_in_admin=1)
cname = models.CharField(maxlength=64, core=True)
def __str__(self):
return self.cname
class Admin:
pass
class Nameserver(models.Model):
name = models.CharField(maxlength=64, blank=True)
def __str__(self):
return self.name
class Admin:
pass
class ZoneAddress(models.Model):
ip_addr = models.IPAddressField(blank=True)
def __str__(self):
return self.ip_addr
class Admin:
pass
class Zone(models.Model):
zone = models.CharField(maxlength=64)
serial = models.IntegerField()
admin = models.CharField(maxlength=64)
primary_master = models.CharField(maxlength=64)
expire = models.IntegerField()
retry = models.IntegerField()
refresh = models.IntegerField()
ttl = models.IntegerField()
nameservers = models.ManyToManyField(Nameserver, blank=True)
mxs = models.ManyToManyField(MX, blank=True)
addresses = models.ManyToManyField(ZoneAddress, blank=True)
aux = models.TextField(blank=True)
def __str__(self):
return self.zone
class Admin:
pass
class Log(models.Model):
hostname = models.CharField(maxlength=64)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
log = models.TextField()
def __str__(self):
return self.hostname
class ZoneLog(models.Model):
zone = models.CharField(maxlength=64)
date = models.DateTimeField(auto_now=True, auto_now_add=True)
log = models.TextField()
def __str__(self):
return self.zone
|