Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EDB
MDB
Commits
acd082b2
Commit
acd082b2
authored
Oct 06, 2015
by
Nikolai Kristiansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starts zone file template
parent
c1bde861
Pipeline
#3
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
mdb/models.py
mdb/models.py
+11
-0
mdb/templates/zone_file.txt
mdb/templates/zone_file.txt
+31
-0
No files found.
mdb/models.py
View file @
acd082b2
from
django.db
import
models
from
django.db.models
import
Count
from
django.template.loader
import
render_to_string
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.translation
import
ugettext_lazy
as
_
from
mdb.utils
import
host_as_pxe_files
...
...
@@ -50,6 +51,9 @@ class Domain(models.Model):
def
__str__
(
self
):
return
self
.
domain_name
def
domain_admin_formatted
(
self
):
return
self
.
domain_admin
.
replace
(
"@"
,
"."
)
def
num_records
(
self
):
host_a_records
=
Host
.
objects
.
filter
(
interface__domain
=
self
).
count
()
size
=
{
...
...
@@ -136,6 +140,13 @@ class Domain(models.Model):
return
content
def
zone_file_contents_alt
(
self
):
context
=
{
'domain'
:
self
,
'now'
:
datetime
.
datetime
.
now
()
}
return
render_to_string
(
'zone_file.txt'
,
context
=
context
)
@
python_2_unicode_compatible
class
DomainSrvRecord
(
models
.
Model
):
...
...
mdb/templates/zone_file.txt
0 → 100644
View file @
acd082b2
; serial: {{ domain.domain_serial }}
; zone file for {{ domain.domain_name }}
; {{ now|date:"c" }}
; filename: {{ domain.domain_filename }}
$TTL {{ domain.domain_ttl }}
@ IN SOA {{ domain.domain_soa }}. {{ domain.domain_admin_formatted }}. (
{{ domain.domain_serial|stringformat:"-10s" }} ; serial
{{ domain.domain_refresh|stringformat:"-10s" }} ; refresh
{{ domain.domain_retry|stringformat:"-10s" }} ; retry
{{ domain.domain_expire|stringformat:"-10s" }} ; expire
{{ domain.domain_minimum_ttl }} ) ; minimum ttl
;
{% for nameserver in domain.domain_nameservers.all %}@ IN NS {{ nameserver.hostname }}.
{% endfor %}{% for mx in domain.domain_mailexchanges.all %}@ MX {{ mx.priority }} {{ mx.hostname }}.{% endfor %}
{% if domain.domain_ipaddr %}@ IN A {{ domain.domain_ipaddr }}{% endif %}
{% if domain.domain_ip6addr %}@ IN AAAA {{ domain.domain_ip6addr }}{% endif %}
; SRV records
{% for srv in domain.domainsrvrecord_set.all %}{{ srv.as_record }}{% endfor %}
; A records
{% for a in domain.domainarecord_set.all %}{{ a.as_record }}{% endfor %}
; AAAA records
{% for aaaa in domain.domainaaaarecord_set.all %}{{ aaaa.as_record }}{% endfor %}
; CNAME records
{% for cname in domain.domaincnamerecord_set.all %}{{ cname.name|stringformat:"-20s" }} IN CNAME {{ cname.target }}{% endfor %}
; TXT records
{% for txt in domain.domaintxtrecord_set.all %}{{ txt.as_record }}{% endfor %}
; HOST records
{% for interface in domain.interface_set.all %}
{% if interface.ip4address %}{{ interface.host.hostname|stringformat:"-20s" }} IN A {{ interface.ip4address.address }}{% endif %}
{% for ipv6addr in interface.ip6address_set.all %}{{ interface.host.hostname|stringformat:"-20s" }} IN AAAA {{ ipv6addr.full_address }}{% endfor %}
{% endfor %}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment