示例#1
0
    def do_generic_add(self, ip_str, fqdn, ip_type, domain=None):
        ret = PTR(name=fqdn, ip_str=ip_str, ip_type=ip_type)
        ret.full_clean()
        ret.save()

        self.assertTrue(ret.details())
        self.assertTrue(ret.get_detail_url())
        self.assertTrue(ret.get_update_url())
        self.assertTrue(ret.get_delete_url())

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn,
                                 ip_upper=ip.ip_upper,
                                 ip_lower=ip.ip_lower)
        ptr.__repr__()
        self.assertTrue(ptr)
        ip_str = ip_str.lower()
        self.assertEqual(ptr[0].ip_str, ip_str)
        if domain:
            if ptr[0].name == "":
                self.assertEqual(fqdn, domain.name)
            else:
                self.assertEqual(fqdn, ptr[0].name + "." + domain.name)
        else:
            self.assertEqual(fqdn, ptr[0].name)
        return ret
示例#2
0
 def test_bad_create(self):
     ip = Ip(ip_str="66.193.1.2", ip_type='x')
     self.assertRaises(ValidationError, ip.clean_ip)
     ip = Ip(ip_str="66.193.1.2", ip_type=None)
     self.assertRaises(ValidationError, ip.clean_ip)
     ip = Ip(ip_str="66.193.1.2", ip_type=99)
     self.assertRaises(ValidationError, ip.clean_ip)
示例#3
0
    def do_generic_add(self, ip_str, fqdn, ip_type, domain=None):
        ret = PTR(name=fqdn, ip_str=ip_str, ip_type=ip_type)
        ret.full_clean()
        ret.save()

        self.assertTrue(ret.details())
        self.assertTrue(ret.get_detail_url())
        self.assertTrue(ret.get_update_url())
        self.assertTrue(ret.get_delete_url())

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower)
        ptr.__repr__()
        self.assertTrue(ptr)
        ip_str = ip_str.lower()
        self.assertEqual(ptr[0].ip_str, ip_str)
        if domain:
            if ptr[0].name == "":
                self.assertEqual(fqdn, domain.name)
            else:
                self.assertEqual(fqdn, ptr[0].name + "." + domain.name)
        else:
            self.assertEqual(fqdn, ptr[0].name)
        return ret
示例#4
0
    def test_creation(self):
        rd = create_reverse_domain('130', ip_type='4')

        ip = Ip(ip_str="111:22:3::", ip_type='6')
        ip.clean_ip()

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
示例#5
0
    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
示例#6
0
    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
示例#7
0
文件: tests.py 项目: ngokevin/cyder
    def test_creation(self):
        rd = ReverseDomain(name="130", ip_type="4")
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
示例#8
0
    def do_generic_remove(self, ip_str, fqdn, ip_type):
        ptr = PTR.objects.create(
            ip_str=ip_str, fqdn=fqdn, ip_type=ip_type, ctnr=self.c1)

        ptr.delete()

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        self.assertFalse(PTR.objects.filter(
            fqdn=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower).exists())
示例#9
0
    def test_ipv4_str(self):
        rd = create_reverse_domain('192', ip_type='4')
        ip_str = '192.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

        rd = create_reverse_domain('128', ip_type='4')
        ip_str = '128.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()
示例#10
0
 def test_large_ipv6(self):
     rd = create_reverse_domain('f', ip_type='6')
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2 ** 64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str, ip_upper=ip_upper,
                 ip_lower=ip_lower, ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
示例#11
0
    def do_generic_remove(self, ip, fqdn, ip_type):
        ptr = PTR(ip_str=ip, name=fqdn, ip_type=ip_type)
        ptr.full_clean()
        ptr.save()

        ptr.delete()

        ip = Ip(ip_str=ip, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn, ip_upper=ip.ip_upper, ip_lower=ip.ip_lower)
        self.assertFalse(ptr)
示例#12
0
    def test_ipv4_str(self):
        rd = self.create_domain(name='192', ip_type='4')
        rd.save()
        ip_str = '192.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

        rd = self.create_domain(name='128', ip_type='4')
        rd.save()
        ip_str = '128.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()
示例#13
0
 def test_large_ipv6(self):
     rd = create_reverse_domain('f', ip_type='6')
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2**64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str,
                 ip_upper=ip_upper,
                 ip_lower=ip_lower,
                 ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
示例#14
0
    def do_generic_remove(self, ip, fqdn, ip_type):
        ptr = PTR(ip_str=ip, name=fqdn, ip_type=ip_type)
        ptr.full_clean()
        ptr.save()

        ptr.delete()

        ip = Ip(ip_str=ip, ip_type=ip_type)
        ip.clean_ip()
        ptr = PTR.objects.filter(name=fqdn,
                                 ip_upper=ip.ip_upper,
                                 ip_lower=ip.ip_lower)
        self.assertFalse(ptr)
示例#15
0
    def do_generic_remove(self, ip_str, fqdn, ip_type):
        ptr = PTR.objects.create(ip_str=ip_str,
                                 fqdn=fqdn,
                                 ip_type=ip_type,
                                 ctnr=self.c1)

        ptr.delete()

        ip = Ip(ip_str=ip_str, ip_type=ip_type)
        ip.clean_ip()
        self.assertFalse(
            PTR.objects.filter(fqdn=fqdn,
                               ip_upper=ip.ip_upper,
                               ip_lower=ip.ip_lower).exists())
示例#16
0
 def test_large_ipv6(self):
     try:
         rd = boot_strap_ipv6_reverse_domain('f')
         rd.save()
     except ValidationError:
         pass
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2 ** 64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str, ip_upper=ip_upper,
                 ip_lower=ip_lower, ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
示例#17
0
    def test_bad_create(self):
        ip = Ip(ip_str="111:22:3::")  # Default type is IPv4
        self.assertRaises(ValidationError, ip.clean_ip)

        ip = Ip(ip_str="130.193.1.2", ip_type='6')
        self.assertRaises(ValidationError, ip.clean_ip)

        ip = Ip(ip_str="66.193.1.2", ip_type='x')
        self.assertRaises(ValidationError, ip.clean_ip)

        ip = Ip(ip_str="66.193.1.2", ip_type=None)
        self.assertRaises(ValidationError, ip.clean_ip)

        ip = Ip(ip_str="66.193.1.2", ip_type=99)
        self.assertRaises(ValidationError, ip.clean_ip)
示例#18
0
 def test_large_ipv6(self):
     try:
         rd = boot_strap_ipv6_reverse_domain('f')
         rd.save()
     except ValidationError:
         pass
     ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = ipaddr.IPv6Address(ip_str)
     ip_upper, ip_lower = ipv6_to_longs(ip_str)
     self.assertEqual(ip.__int__(), (2**64) * ip_upper + ip_lower)
     new_ip = Ip(ip_str=ip_str,
                 ip_upper=ip_upper,
                 ip_lower=ip_lower,
                 ip_type='6')
     new_ip.clean_ip()
     self.assertEqual(ip_str, new_ip.ip_str)
     self.assertEqual(ip.__int__(), new_ip.__int__())
示例#19
0
    def test_creation(self):
        rd = create_reverse_domain('130', ip_type='4')

        ip = Ip(ip_str="111:22:3::", ip_type='6')
        ip.clean_ip()

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
示例#20
0
    def test_ipv6_str(self):
        boot_strap_ipv6_reverse_domain('1.2.3.4')

        ip_str = '1234:1234:1243:1243:1243::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

        ip_str = '1234:432:3:0:3414:22::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)
示例#21
0
    def test_update_ipv4_str(self):
        ip_str = '66.168.1.1'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip = Ip(ip_str=ip_str, ip_type='4')
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

        # Make sure ip_lower is update.
        ip_str = '66.213.1.9'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip.ip_str = ip_str
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))
示例#22
0
    def test_update_ipv4_str(self):
        ip_str = '66.168.1.1'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip = Ip(ip_str=ip_str, ip_type='4')
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

        # Make sure ip_lower is update.
        ip_str = '66.213.1.9'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip.ip_str = ip_str
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))
示例#23
0
    def test_ipv6_str(self):
        rd = boot_strap_ipv6_reverse_domain('1.2.3.4')

        ip_str = '1234:1234:1243:1243:1243::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

        ip_str = '1234:432:3:0:3414:22::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)
示例#24
0
        ip.clean_ip()
        ip.__int__()
        ip.__repr__()

    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
        ip.clean_ip()
        self.assertTrue(ip.ip_upper == 0 and ip.ip_lower and ip.reverse_domain)

    def test_bad_create(self):
        ip = Ip(ip_str="66.193.1.2", ip_type='x')
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=None)
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=99)
        self.assertRaises(ValidationError, ip.clean_ip)

    def test_ipv6_to_longs(self):
        addr = "herp derp, not an ip"
        self.assertRaises(ValidationError, ipv6_to_longs, addr)
示例#25
0
 def test_int_ip(self):
     rd = create_reverse_domain('129', ip_type='4')
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = create_reverse_domain('e', ip_type='6')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
示例#26
0
 def test_int_ip(self):
     rd = self.create_domain(name='129', ip_type='4')
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain('e')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
示例#27
0
        ip.clean_ip()
        ip.__int__()
        ip.__repr__()

    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
        ip.clean_ip()
        self.assertTrue(
            ip.ip_upper == 0 and ip.ip_lower and ip.reverse_domain)

    def test_bad_create(self):
        ip = Ip(ip_str="66.193.1.2", ip_type='x')
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=None)
        self.assertRaises(ValidationError, ip.clean_ip)
        ip = Ip(ip_str="66.193.1.2", ip_type=99)
        self.assertRaises(ValidationError, ip.clean_ip)

    def test_ipv6_to_longs(self):
        addr = "herp derp, not an ip"
示例#28
0
 def test_int_ip(self):
     rd = self.create_domain(name='129', ip_type='4')
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain('e')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
示例#29
0
class SimpleTest(TestCase):
    def setUp(self):
        self.arpa = self.create_domain(name='arpa')
        self.arpa.save()
        self.i_arpa = self.create_domain(name='in-addr.arpa')
        self.i_arpa.save()
        self.i6_arpa = self.create_domain(name='ip6.arpa')
        self.i6_arpa.save()

        rd = self.create_domain(name='66', ip_type='4')
        rd.save()

    def create_domain(self, name, ip_type=None, delegated=False):
        if ip_type is None:
            ip_type = '4'
        if name in ('arpa', 'in-addr.arpa', 'ip6.arpa'):
            pass
        else:
            name = ip_to_domain_name(name, ip_type=ip_type)
        d = Domain(name=name, delegated=delegated)
        d.clean()
        self.assertTrue(d.is_reverse)
        return d

    def test_ipv4_str(self):
        rd = self.create_domain(name='192', ip_type='4')
        rd.save()
        ip_str = '192.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

        rd = self.create_domain(name='128', ip_type='4')
        rd.save()
        ip_str = '128.168.1.1'
        ipaddr.IPv4Address(ip_str)
        Ip(ip_str=ip_str, ip_type='4').clean_ip()

    def test_update_ipv4_str(self):
        ip_str = '66.168.1.1'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip = Ip(ip_str=ip_str, ip_type='4')
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

        # Make sure ip_lower is update.
        ip_str = '66.213.1.9'
        v_ip = ipaddr.IPv4Address(ip_str)
        ip.ip_str = ip_str
        ip.clean_ip()
        self.assertEqual(ip.ip_upper, 0)
        self.assertEqual(ip.ip_lower, int(v_ip))

    def test_ipv6_str(self):
        boot_strap_ipv6_reverse_domain('1.2.3.4')

        ip_str = '1234:1234:1243:1243:1243::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

        ip_str = '1234:432:3:0:3414:22::'
        new_ip = Ip(ip_str=ip_str, ip_type='6')
        new_ip.clean_ip()

        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(new_ip.ip_upper, ip_upper)
        self.assertEqual(new_ip.ip_lower, ip_lower)

    def test_large_ipv6(self):
        try:
            rd = boot_strap_ipv6_reverse_domain('f')
            rd.save()
        except ValidationError:
            pass
        ip_str = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
        ip = ipaddr.IPv6Address(ip_str)
        ip_upper, ip_lower = ipv6_to_longs(ip_str)
        self.assertEqual(ip.__int__(), (2**64) * ip_upper + ip_lower)
        new_ip = Ip(ip_str=ip_str,
                    ip_upper=ip_upper,
                    ip_lower=ip_lower,
                    ip_type='6')
        new_ip.clean_ip()
        self.assertEqual(ip_str, new_ip.ip_str)
        self.assertEqual(ip.__int__(), new_ip.__int__())

    def bad_ipv6(self):
        self.assertRaises(ValidationError, ipv6_to_longs, {'addr': "1::::"})

    def test_int_ip(self):
        rd = self.create_domain(name='129', ip_type='4')
        rd.save()
        ip = Ip(ip_str="129.193.1.1", ip_type='4')
        ip.clean_ip()
        ip.__int__()
        ip.__repr__()
        rd = boot_strap_ipv6_reverse_domain('e')
        ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
        ip = Ip(ip_str=ip_str, ip_type='6')
        ip.clean_ip()
        ip.__int__()
        ip.__repr__()

    def test_creation(self):
        rd = self.create_domain(name='130', ip_type='4')
        rd.save()
        try:
            ip = Ip(ip_str="130.193.1.2")  # Forget the ip_type
            ip.clean_ip()

        except ValidationError, e:
            pass
        self.assertEqual(ValidationError, type(e))

        ip = Ip(ip_str="130.193.1.2", ip_type='4')
        self.assertFalse(ip.ip_upper and ip.ip_lower and ip.reverse_domain)
示例#30
0
文件: tests.py 项目: ngokevin/cyder
 def test_int_ip(self):
     rd = ReverseDomain(name="129", ip_type="4")
     rd.save()
     ip = Ip(ip_str="129.193.1.1", ip_type="4")
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = boot_strap_ipv6_reverse_domain("e")
     ip_str = "efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"
     ip = Ip(ip_str=ip_str, ip_type="6")
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
示例#31
0
 def test_int_ip(self):
     rd = create_reverse_domain('129', ip_type='4')
     ip = Ip(ip_str="129.193.1.1", ip_type='4')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
     rd = create_reverse_domain('e', ip_type='6')
     ip_str = 'efff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'
     ip = Ip(ip_str=ip_str, ip_type='6')
     ip.clean_ip()
     ip.__int__()
     ip.__repr__()
示例#32
0
文件: test.py 项目: osunws/cyder
def add_some_records():
    s1, s1_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="foo.gaz2")
    s2, s2_c = SOA.objects.get_or_create(primary = "ns1.foo.gaz", contact = "hostmaster.foo", comment="baz.gaz2")
    d, _ = Domain.objects.get_or_create(name="gaz")
    d.soa = None
    d.save()
    d1, _ = Domain.objects.get_or_create(name="foo.gaz")
    if s1_c:
        d1.soa = s1
        d1.save()
    d, _ = Domain.objects.get_or_create(name="baz.foo.gaz")
    if s1_c:
        d.soa = s1
        d.save()
    d, _ = Domain.objects.get_or_create(name="bar.foo.gaz")
    if s1_c:
        d.soa = s1
        d.save()
    d, _ = Domain.objects.get_or_create(name="baz.gaz")
    if s2_c:
        d.soa = s2
        d.save()
    d, _ = Domain.objects.get_or_create(name="gaz.gaz")
    d.soa = None
    d.save()

    _128 , _= ReverseDomain.objects.get_or_create(name='128')

    rs, _ = ReverseNameserver.objects.get_or_create( reverse_domain= _128, server="ns1.foo.com")
    rs.save()
    rs = ReverseNameserver.objects.get_or_create( reverse_domain= _128, server="ns1.foo1.com")
    rs.save()

    test_ip = Ip( ip_str = "128.193.0.1", ip_type = '4' )
    test_ip.save()
    try:
        _, _ = AddressRecord.objects.get_or_create( label = '', domain= d1 , ip = test_ip , ip_type='4')
    except ValidationError:
        pass

    test_ip1 = Ip( ip_str = "128.193.0.1", ip_type = '4' )
    test_ip1.save()
    try:
        _, _ = AddressRecord.objects.get_or_create( label = 'fdjoo',domain= d1 , ip = test_ip1 , ip_type='4')
    except ValidationError:
        pass

    test_ip2 = Ip( ip_str = "128.193.0.1", ip_type = '4' )
    test_ip2.save()
    try:
        _, _ = AddressRecord.objects.get_or_create( label = 'baddr',domain= d1 , ip = test_ip2 , ip_type='4')
    except ValidationError:
        pass

    data = { 'domain':d1 , 'server':'ns2.moot.ru' }
    try:
        _, _ = Nameserver.objects.get_or_create( **data )
    except ValidationError:
        pass

    data = { 'domain':d1 , 'server':'ns3.moot.ru' }
    try:
        _, _ = Nameserver.objects.get_or_create( **data )
    except ValidationError:
        pass