Starts zone file template
This commit is contained in:
1 parent
c1bde8612b
commit
acd082b2f8
2 files changed
+42
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Count
|
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.encoding import python_2_unicode_compatible
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from mdb.utils import host_as_pxe_files
|
from mdb.utils import host_as_pxe_files
|
||||||
@@ -50,6 +51,9 @@ class Domain(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.domain_name
|
return self.domain_name
|
||||||
|
|
||||||
|
def domain_admin_formatted(self):
|
||||||
|
return self.domain_admin.replace("@", ".")
|
||||||
|
|
||||||
def num_records(self):
|
def num_records(self):
|
||||||
host_a_records = Host.objects.filter(interface__domain=self).count()
|
host_a_records = Host.objects.filter(interface__domain=self).count()
|
||||||
size = {
|
size = {
|
||||||
@@ -136,6 +140,13 @@ class Domain(models.Model):
|
|||||||
|
|
||||||
return content
|
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
|
@python_2_unicode_compatible
|
||||||
class DomainSrvRecord(models.Model):
|
class DomainSrvRecord(models.Model):
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
; 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 %}
|
||||||
Reference in new issue
Block a user