Merge branch 'ipv6-domain-addr'
This commit is contained in:
commit
d523b4ae99
6 files changed
+974
-854
No files matched your search
+9
-3
@@ -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,9 +113,15 @@ class DomainARecordInline(admin.TabularInline):
|
||||
extra = 0
|
||||
|
||||
|
||||
class DomainAAAARecordInline(admin.TabularInline):
|
||||
model = DomainAAAARecord
|
||||
extra = 0
|
||||
|
||||
|
||||
class DomainAdmin(admin.ModelAdmin):
|
||||
inlines = [DomainSrvRecordInline, DomainTxtRecordInline, DomainARecordInline, DomainCnameRecordInline]
|
||||
list_display = ['domain_name', 'domain_soa', 'domain_admin', 'num_records', 'domain_ipaddr']
|
||||
inlines = [DomainSrvRecordInline, DomainTxtRecordInline, DomainARecordInline, DomainAAAARecordInline,
|
||||
DomainCnameRecordInline]
|
||||
list_display = ['domain_name', 'domain_soa', 'domain_admin', 'num_records', 'domain_ipaddr', 'domain_ip6addr']
|
||||
search_fields = ['domain_name']
|
||||
|
||||
|
||||
|
||||
+880
-849
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import re
|
||||
import django.core.validators
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mdb', '0008_auto_20151004_1258'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='domain',
|
||||
name='domain_ip6addr',
|
||||
field=models.GenericIPAddressField(null=True, protocol='IPv6', blank=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='host',
|
||||
name='hostname',
|
||||
field=models.CharField(max_length=64, validators=[django.core.validators.RegexValidator(regex=re.compile('^(?!-)[-a-z0-9]+(?<!-)$', 2), message='Enter a valid hostname', code='invalid')]),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='interface',
|
||||
name='macaddr',
|
||||
field=models.CharField(max_length=17, validators=[django.core.validators.RegexValidator(regex=re.compile('^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$', 2), message='Enter a valid MAC address', code='invalid')]),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- 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'),
|
||||
),
|
||||
]
|
||||
+24
-1
@@ -40,6 +40,7 @@ class Domain(models.Model):
|
||||
domain_minimum_ttl = models.IntegerField(default=86400)
|
||||
domain_admin = models.EmailField()
|
||||
domain_ipaddr = models.GenericIPAddressField(protocol='IPv4')
|
||||
domain_ip6addr = models.GenericIPAddressField(protocol='IPv6', blank=True, null=True)
|
||||
domain_filename = models.CharField(max_length=256)
|
||||
created_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
@@ -92,6 +93,9 @@ class Domain(models.Model):
|
||||
if self.domain_ipaddr is not None:
|
||||
content += "@\tIN\tA\t%s\n" % self.domain_ipaddr
|
||||
|
||||
if self.domain_ip6addr is not None:
|
||||
content += "@\tIN\tAAAA\t%s\n" % self.domain_ip6addr
|
||||
|
||||
content += "; SRV records\n"
|
||||
|
||||
for srv in self.domainsrvrecord_set.all():
|
||||
@@ -102,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():
|
||||
@@ -187,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)
|
||||
|
||||
@@ -198,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()
|
||||
|
||||
+1
-1
@@ -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
|
||||
Reference in new issue
Block a user