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


Python AddressRecord.clean方法代码示例

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


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

示例1: test_manual_assign_of_glue

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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 = StaticInterface(
            label="ns25", domain=self.f_r, ip_str="128.193.99.10", ip_type="4", system=self.s, mac="11:22:33:44:55:66"
        )
        glue.clean()
        glue.save()
        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:Ziaunys,项目名称:chili,代码行数:36,代码来源:test_models.py

示例2: migrate_AAAA

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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')
            a.clean()
            a.save()
        for view in views:
            a.views.add(view)
            a.save()
开发者ID:Ziaunys,项目名称:chili,代码行数:32,代码来源:zone_migrate.py

示例3: test_private_view_case_1_addr

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:Ziaunys,项目名称:chili,代码行数:10,代码来源:tests.py

示例4: test_disallow_name_update_of_glue_A

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:Ziaunys,项目名称:chili,代码行数:14,代码来源:test_models.py

示例5: test_delete_with_cname_pointing_to_a

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:Ziaunys,项目名称:chili,代码行数:14,代码来源:test_models.py

示例6: testtest_add_ns_in_domain

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import clean [as 别名]
    def testtest_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:Ziaunys,项目名称:chili,代码行数:19,代码来源:test_models.py

示例7: test2_bad_add_for_a_ptr

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import clean [as 别名]
 def test2_bad_add_for_a_ptr(self):
     # PTR and A exist, then try add intr
     mac = "11:22:33:44:55:66"
     label = "9988fdfood"
     domain = self.c
     ip_str = "10.0.0.1"
     kwargs = {'mac': mac, 'label': label, 'domain': domain,
               'ip_str': ip_str}
     ip_type = '4'
     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:alecdhuse,项目名称:cyder,代码行数:19,代码来源:basic.py

示例8: test_add_A_address_records

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:ngokevin,项目名称:cyder,代码行数:21,代码来源:tests.py

示例9: testtest_add_ns_in_domain

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import clean [as 别名]
    def testtest_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:alecdhuse,项目名称:cyder,代码行数:21,代码来源:test_models.py

示例10: test_private_view_case_3_addr

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:Ziaunys,项目名称:chili,代码行数:32,代码来源:tests.py

示例11: populate_forward_dns

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import clean [as 别名]
def populate_forward_dns(zone, root_domain, views=None):
    for (name, ttl, rdata) in zone.iterate_rdatas('SOA'):
        print str(name) + " SOA " + str(rdata)
        exists = SOA.objects.filter(minimum=rdata.minimum,
                                    contact=rdata.rname.to_text().strip('.'),
                                    primary=rdata.mname.to_text().strip('.'), comment="SOA for"
                                    " {0}".format(root_domain))
        if exists:
            soa = exists[0]
        else:
            soa = SOA(serial=rdata.serial, minimum=rdata.minimum,
                      contact=rdata.rname.to_text().strip('.'),
                      primary=rdata.mname.to_text().strip('.'), comment="SOA for"
                      " {0}".format(root_domain))
            soa.clean()
            soa.save()
        domain_split = list(reversed(name.to_text().strip('.').split('.')))
        for i in range(len(domain_split)):
            domain_name = domain_split[:i + 1]
            base_domain, created = Domain.objects.get_or_create(name=
                                                                '.'.join(list(reversed(domain_name))))

        null_all_soas(base_domain)
        base_domain.soa = soa
        base_domain.save()
        set_all_soas(base_domain, soa)

    names = []
    for (name, ttl, rdata) in zone.iterate_rdatas('A'):
        names.append((name.to_text().strip('.'), rdata))
    sorted_names = list(sorted(names, cmp=lambda n1, n2: -1 if
                               len(n1[0].split('.')) > len(n2[0].split('.')) else 1))

    for name, rdata in sorted_names:
        print str(name) + " A " + str(rdata)
        exists_domain = Domain.objects.filter(name=name)
        if exists_domain:
            label = ''
            domain = exists_domain[0]
        else:
            label = name.split('.')[0]
            if label.find('unused') != -1:
                continue
            parts = list(reversed(name.split('.')[1:]))
            domain_name = ''
            for i in range(len(parts)):
                domain_name = parts[i] + '.' + domain_name
                domain_name = domain_name.strip('.')
                # We need to check for A records who have a name with this
                # domain.
                addrs = AddressRecord.objects.filter(fqdn=domain_name,
                                                     ip_type='4')
                clober_objects = []
                if addrs:
                    for exists_a in addrs:
                        # It got here. It exists
                        need_to_recreate_a = True
                        ip_str = exists_a.ip_str
                        exists_a.delete(check_cname=False)
                        a = AddressRecord(label='', ip_str=ip_str, ip_type='4')
                        clober_objects.append(a)
                domain, created = Domain.objects.get_or_create(name=
                                                               domain_name)
                for a in clober_objects:
                    a.domain = domain
                    a.clean()
                    try:
                        a.save()
                    except Exception, e:
                        pdb.set_trace()
                        pass

                if created and domain.master_domain and domain.master_domain.soa:
                    #domain.soa = domain.master_domain.soa
                    #domain.save()
                    null_all_soas(domain)
                    set_all_soas(domain, domain.master_domain.soa)
        a, _ = AddressRecord.objects.get_or_create(label=label,
                                                   domain=domain, ip_str=rdata.to_text(), ip_type='4')
        if views:
            for view in views:
                a.views.add(view)
                try:
                    a.save()
                except Exception, e:
                    pdb.set_trace()
                    pass
开发者ID:alecdhuse,项目名称:cyder,代码行数:89,代码来源:dns_build.py

示例12: AddressRecord

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import clean [as 别名]
                clober_objects = []
                if addrs:
                    for exists_a in addrs:
                        # It got here. It exists
                        need_to_recreate_a = True
                        ip_str = exists_a.ip_str
                        ip_type = exists_a.ip_type
                        exists_a.delete(check_cname=False)
                        a = AddressRecord(label='', ip_str=ip_str,
                                          ip_type=ip_type)
                        clober_objects.append(a)
                domain, created = Domain.objects.get_or_create(name=
                                                               domain_name)
                for a in clober_objects:
                    a.domain = domain
                    a.clean()
                    try:
                        a.save()
                    except Exception, e:
                        pdb.set_trace()
                        pass

                if created and domain.master_domain and domain.master_domain.soa:
                    #domain.soa = domain.master_domain.soa
                    #domain.save()
                    null_all_soas(domain)
                    set_all_soas(domain, domain.master_domain.soa)
        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():
开发者ID:alecdhuse,项目名称:cyder,代码行数:33,代码来源:dns_build.py

示例13: do_add_a

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.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:alecdhuse,项目名称:cyder,代码行数:8,代码来源:A_tests.py


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