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


Python AddressRecord.domain方法代码示例

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


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

示例1: test_no_update_when_glue

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import domain [as 别名]
    def test_no_update_when_glue(self):
        """A record shouldn't update it's label or domain when it is a glue record"""
        label = 'ns99'
        glue = AddressRecord(label=label, domain=self.o_e,
                             ip_str='128.193.1.10', ip_type='4')
        glue.save()

        server = "%s.%s" % (label, self.o_e)
        ns = Nameserver(domain=self.o_e, server=server)
        ns.save()
        self.assertTrue(ns.glue == glue)

        # Shouldn't be able to edit label or domain.
        glue.label = "ns100"
        self.assertRaises(ValidationError, glue.save)
        glue.domain = self.m_o_e
        self.assertRaises(ValidationError, glue.save)

        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.label = "ns101"
        glue.domain = self.e
        self.assertRaises(ValidationError, glue.save)

        # Ip can change.
        glue = AddressRecord.objects.get(pk=glue.pk)
        glue.ip_str = "192.192.12.12"
        glue.save()
开发者ID:Ziaunys,项目名称:chili,代码行数:29,代码来源:test_models.py

示例2: populate_forward_dns

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import domain [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

示例3: AddressRecord

# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import domain [as 别名]
                addrs = AddressRecord.objects.filter(fqdn=domain_name)
                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,
开发者ID:alecdhuse,项目名称:cyder,代码行数:33,代码来源:dns_build.py


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