Commit c1bde861 authored by Nikolai Kristiansen's avatar Nikolai Kristiansen
Browse files

Adds AAAA records to Domain DNS zone

parent ada13fde
Pipeline #2 skipped
......@@ -2,7 +2,7 @@ from django.contrib import admin, messages
from mdb.models import Ip6Address, Interface, Ip4Address, DhcpOption, DhcpCustomField, DomainSrvRecord, DomainTxtRecord, \
DomainCnameRecord, DomainARecord, Domain, Host, Ip4Subnet, Ip6Subnet, Nameserver, MailExchange, OperatingSystem, \
HostType, DhcpConfig
HostType, DhcpConfig, DomainAAAARecord
class Ip6AddressInline(admin.TabularInline):
......@@ -113,8 +113,14 @@ class DomainARecordInline(admin.TabularInline):
extra = 0
class DomainAAAARecordInline(admin.TabularInline):
model = DomainAAAARecord
extra = 0
class DomainAdmin(admin.ModelAdmin):
inlines = [DomainSrvRecordInline, DomainTxtRecordInline, DomainARecordInline, DomainCnameRecordInline]
inlines = [DomainSrvRecordInline, DomainTxtRecordInline, DomainARecordInline, DomainAAAARecordInline,
DomainCnameRecordInline]
list_display = ['domain_name', 'domain_soa', 'domain_admin', 'num_records', 'domain_ipaddr', 'domain_ip6addr']
search_fields = ['domain_name']
......
......@@ -48,6 +48,36 @@
"model": "mdb.domain",
"pk": 1
},
{
"fields": {
"domain": 1,
"created_date": "2015-10-04T17:13:46.810",
"name": "www",
"target": "edb.technology."
},
"model": "mdb.domaincnamerecord",
"pk": 1
},
{
"fields": {
"domain": 1,
"created_date": "2015-10-04T17:13:46.807",
"name": "test",
"target": "127.0.0.1"
},
"model": "mdb.domainarecord",
"pk": 1
},
{
"fields": {
"domain": 1,
"created_date": "2015-10-04T17:13:46.809",
"name": "test",
"target": "::1"
},
"model": "mdb.domainaaaarecord",
"pk": 1
},
{
"fields": {
"ddns_update_style": "none",
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mdb', '0009_auto_20151004_1652'),
]
operations = [
migrations.CreateModel(
name='DomainAAAARecord',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=256)),
('target', models.GenericIPAddressField(protocol='IPv6')),
('created_date', models.DateTimeField(auto_now_add=True)),
('domain', models.ForeignKey(to='mdb.Domain')),
],
),
migrations.AlterField(
model_name='domainarecord',
name='target',
field=models.GenericIPAddressField(protocol='IPv4'),
),
]
......@@ -106,6 +106,11 @@ class Domain(models.Model):
for a in self.domainarecord_set.all():
content += a.as_record() + "\n"
content += "; AAAA records\n"
for aaaa in self.domainaaaarecord_set.all():
content += aaaa.as_record() + "\n"
content += "; CNAME records \n"
for cname in self.domaincnamerecord_set.all():
......@@ -191,7 +196,7 @@ class DomainCnameRecord(models.Model):
@python_2_unicode_compatible
class DomainARecord(models.Model):
name = models.CharField(max_length=256)
target = models.CharField(max_length=256)
target = models.GenericIPAddressField(protocol='IPv4')
domain = models.ForeignKey(Domain)
created_date = models.DateTimeField(auto_now_add=True)
......@@ -202,6 +207,20 @@ class DomainARecord(models.Model):
return self.as_record()
@python_2_unicode_compatible
class DomainAAAARecord(models.Model):
name = models.CharField(max_length=256)
target = models.GenericIPAddressField(protocol='IPv6')
domain = models.ForeignKey(Domain)
created_date = models.DateTimeField(auto_now_add=True)
def as_record(self):
return '{} IN AAAA {}'.format(self.name, self.target)
def __str__(self):
return self.as_record()
@python_2_unicode_compatible
class DhcpConfig(models.Model):
serial = models.IntegerField()
......
......@@ -52,5 +52,5 @@ class RunManagementCommands(TestCase):
def test_dhcp_sync(self):
expected_dhcp_file = ''
with io.BytesIO() as f:
call_command('dhcp-sync', ('--debug',), stdout=f)
call_command('dhcp-sync', stdout=f)
# TODO check expected_dhcp_file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment