当前位置: 首页>>代码示例>>Python>>正文


Python AddressRecord.clean方法代码示例

本文整理汇总了Python中mozdns.address_record.models.AddressRecord.clean方法的典型用法代码示例。如果您正苦于以下问题:Python AddressRecord.clean方法的具体用法?Python AddressRecord.clean怎么用?Python AddressRecord.clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mozdns.address_record.models.AddressRecord的用法示例。


在下文中一共展示了AddressRecord.clean方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: migrate_AAAA

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
def migrate_AAAA(zone, root_domain, soa, views):
    for (name, ttl, rdata) in zone.iterate_rdatas('AAAA'):
        name = name.to_text().strip('.')
        print str(name) + " AAAA " + str(rdata)
        exists_domain =  Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            if label.startswith('unused'):
                continue
            domain_name = '.'.join(name.split('.')[1:])
            domain = ensure_domain(domain_name, force=True)

        ip_upper, ip_lower = ipv6_to_longs(rdata.to_text())
        if AddressRecord.objects.filter(label=label,
                domain=domain, ip_upper=ip_upper, ip_lower=ip_lower,
                ip_type='6').exists():
            a = AddressRecord.objects.get(
                label=label, domain=domain, ip_type='6', ip_upper=ip_upper,
                ip_lower=ip_lower
            )
        else:
            a = AddressRecord(
                label=label, domain=domain, ip_str=rdata.to_text(),
                ip_type='6', description=rdata.comment, ttl=ttl
            )
            a.clean()
            a.save()

        for view in views:
            a.views.add(view)
            a.save()
开发者ID:Marlburo,项目名称:inventory,代码行数:36,代码来源:zone_migrate.py

示例2: test_manual_assign_of_glue

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
    def test_manual_assign_of_glue(self):
        # Test that assigning a different glue record doesn't get overriden by
        # the auto assinging during the Nameserver's clean function.
        glue = StaticReg.objects.create(
            label='ns25', domain=self.f_r, ip_str='128.193.99.10',
            ip_type='4', system=self.s
        )
        data = {'domain': self.f_r, 'server': 'ns25.foo.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.glue, glue)

        glue2 = AddressRecord(label='ns25', domain=self.f_r, ip_str=
                              '128.193.1.78', ip_type='4')
        glue2.clean()
        glue2.save()

        ns.clean()

        # Make sure things didn't get overriden.
        self.assertEqual(ns.glue, glue)

        ns.glue = glue2
        ns.save()
        # Refresh the object
        ns = Nameserver.objects.get(pk=ns.pk)
        # Again, Make sure things didn't get overriden.
        self.assertEqual(ns.glue, glue2)
        # Make sure we still can't delete.
        self.assertRaises(ValidationError, glue2.delete)
        self.assertRaises(ValidationError, ns.glue.delete)

        # We shuold be able to delelte the other one.
        glue.delete()
开发者ID:Marlburo,项目名称:inventory,代码行数:36,代码来源:tests.py

示例3: test_private_view_case_1_addr

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
 def test_private_view_case_1_addr(self):
     a = AddressRecord(label="asf", domain=self.f_o, ip_str="10.0.0.1",
                       ip_type="4")
     a.clean()
     a.save()
     # Object has to exist before views can be assigned.
     a.views.add(self.private)
     a.save()
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:10,代码来源:tests.py

示例4: test_delete_with_cname_pointing_to_a

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
 def test_delete_with_cname_pointing_to_a(self):
     label = 'foo100'
     a = AddressRecord(label=label, domain=self.o_e, ip_str=
                       '128.193.1.10', ip_type='4')
     a.clean()
     a.save()
     cn = CNAME(label="foomom", domain=self.o_e, target=label + "." +
                self.o_e.name)
     cn.clean()
     cn.save()
     self.assertRaises(ValidationError, a.delete)
     a.delete(check_cname=False)
开发者ID:bclary,项目名称:inventory,代码行数:14,代码来源:tests.py

示例5: test_disallow_name_update_of_glue_A

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
    def test_disallow_name_update_of_glue_A(self):
        # Glue records should not be allowed to change their name.
        glue = AddressRecord(label='ns39', domain=self.f_r, ip_str=
                             '128.193.1.77', ip_type='4')
        glue.clean()
        glue.save()
        data = {'domain': self.f_r, 'server': 'ns39.foo.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.glue, glue)

        glue.label = "ns22"
        self.assertRaises(ValidationError, glue.clean)
开发者ID:Marlburo,项目名称:inventory,代码行数:15,代码来源:tests.py

示例6: test2_bad_add_for_a_ptr

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
 def test2_bad_add_for_a_ptr(self):
     # PTR and A exist, then try add sreg
     label = "9988fdfood"
     domain = self.c
     ip_str = "1112::11:22:33:44:55:66"
     kwargs = {'label': label, 'domain': domain,
               'ip_str': ip_str}
     ip_type = '6'
     a = AddressRecord(label=label, domain=domain, ip_str=ip_str,
                       ip_type=ip_type)
     a.clean()
     a.save()
     ptr = PTR(ip_str=ip_str, ip_type=ip_type, name=a.fqdn)
     ptr.clean()
     ptr.save()
     self.assertRaises(ValidationError, self.do_add, **kwargs)
开发者ID:Marlburo,项目名称:inventory,代码行数:18,代码来源:ipv6_basic.py

示例7: test_add_ns_in_domain

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
    def test_add_ns_in_domain(self):
        # Use an A record as a glue record.
        glue = AddressRecord(label='ns2', domain=self.r,
                             ip_str='128.193.1.10', ip_type='4')
        glue.clean()
        glue.save()
        data = {'domain': self.r, 'server': 'ns2.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.server, ns.glue.fqdn)
        self.assertRaises(ValidationError, glue.delete)

        glue = AddressRecord(label='ns3', domain=self.f_r, ip_str=
                             '128.193.1.10', ip_type='4')
        glue.save()
        data = {'domain': self.f_r, 'server': 'ns3.foo.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.server, ns.glue.fqdn)
开发者ID:Marlburo,项目名称:inventory,代码行数:21,代码来源:tests.py

示例8: test_add_A_address_records

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
    def test_add_A_address_records(self):
        rec = AddressRecord(label='', domain=self.o_e,
                            ip_str="128.193.0.1", ip_type='4')
        rec.clean()
        rec.save()
        self.assertEqual(rec.__str__(), "oregonstate.edu A 128.193.0.1")

        data = {'label': 'foob1ar', 'domain': self.f_o_e, 'ip':
                "128.193.0.10"}
        self.do_add_record(data)

        data = {'label': 'foob1ar', 'domain': self.o_e, 'ip': "128.193.0.5"}
        self.do_add_record(data)
        data = {'label': 'foo2', 'domain': self.f_o_e, 'ip': "128.193.0.7"}
        self.do_add_record(data)
        data = {'label': 'foo2', 'domain': self.o_e, 'ip': "128.193.0.2"}
        self.do_add_record(data)
        data = {'label': 'ba-r', 'domain': self.f_o_e, 'ip': "128.193.0.9"}
        self.do_add_record(data)
        data = {'label': 'ba-r', 'domain': self.o_e, 'ip': "128.193.0.4"}
        self.do_add_record(data)
开发者ID:bclary,项目名称:inventory,代码行数:23,代码来源:tests.py

示例9: test_private_view_case_3_addr

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
    def test_private_view_case_3_addr(self):
        a = AddressRecord(label="asf3", domain=self.f_o, ip_str="10.0.0.1",
                          ip_type="4")
        a.clean()
        a.save()
        a.views.add(self.private)
        a.save()
        # Object has to exist before views can be assigned.
        a.views.add(self.public)
        self.assertFalse(a.views.filter(name="public"))

        a = AddressRecord(label="asf3", domain=self.f_o, ip_str="172.30.0.1",
                          ip_type="4")
        a.clean()
        a.save()
        a.views.add(self.private)
        a.save()
        # Object has to exist before views can be assigned.
        a.views.add(self.public)
        self.assertFalse(a.views.filter(name="public"))

        a = AddressRecord(label="asf3", domain=self.f_o, ip_str="192.168.0.1",
                          ip_type="4")
        a.clean()
        a.save()
        a.views.add(self.private)
        a.save()
        # Object has to exist before views can be assigned.
        a.views.add(self.public)
        self.assertFalse(a.views.filter(name="public"))
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:32,代码来源:tests.py

示例10: do_add_a

# 需要导入模块: from mozdns.address_record.models import AddressRecord [as 别名]
# 或者: from mozdns.address_record.models.AddressRecord import clean [as 别名]
 def do_add_a(self, label, domain, ip_str, ip_type='4'):
     a = AddressRecord(label=label, domain=domain, ip_str=ip_str,
                       ip_type=ip_type)
     a.clean()
     a.save()
     return a
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:8,代码来源:A_tests.py


注:本文中的mozdns.address_record.models.AddressRecord.clean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。