• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.AddressRecord类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test2

    def test2(self):
        ip_start = "10.0.1.0"
        ip_end = "10.0.1.99"
        ptr = PTR(name="foo.mz", ip_str="10.0.1.3", ip_type="4")
        ptr.full_clean()
        ptr.save()

        a = AddressRecord(label="foo", domain=self.domain, ip_str="10.0.1.3", ip_type="4")
        a.full_clean()
        a.save()

        s = create_fake_host(hostname="foo.mozilla.com")
        s.save()
        sreg = StaticReg.objects.create(label="foo", domain=self.domain, ip_str="10.0.1.4", ip_type="4", system=s)

        istart, iend, ipf_q = start_end_filter(ip_start, ip_end, "4")
        addrs = list(AddressRecord.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
        ptrs = list(PTR.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
        sregs = list(StaticReg.objects.filter(ipf_q).order_by("ip_lower").order_by("ip_upper"))
        self.assertEqual(a.pk, addrs[0].pk)
        self.assertEqual(ptr.pk, ptrs[0].pk)
        self.assertEqual(sreg.pk, sregs[0].pk)

        range_details = range_usage(ip_start, ip_end, "4")
        self.assertEqual(98, range_details["unused"])
        self.assertEqual(2, range_details["used"])
        self.assertEqual(
            [(int(istart) + 0, int(istart) + 2), (int(istart) + 5, int(istart) + 99)], range_details["free_ranges"]
        )
开发者ID:rrsc,项目名称:inventory-1,代码行数:29,代码来源:usage_tests.py


示例2: test1

    def test1(self):
        ip_start = "10.0.0.10"
        ip_end = "10.0.0.19"

        ptr = PTR(name="foo.mz", ip_str="10.0.0.15", ip_type='4')
        ptr.full_clean()
        ptr.save()

        a = AddressRecord(
            label="foo", domain=self.domain, ip_str="10.0.0.16", ip_type='4')
        a.full_clean()
        a.save()

        istart, iend, ipf_q = start_end_filter(ip_start, ip_end, '4')
        addrs = list(AddressRecord.objects.filter(ipf_q).
                     order_by('ip_lower').order_by('ip_upper'))
        ptrs = list(PTR.objects.filter(ipf_q).
                    order_by('ip_lower').order_by('ip_upper'))
        intrs = list(StaticInterface.objects.filter(ipf_q).
                     order_by('ip_lower').order_by('ip_upper'))
        self.assertEqual(a.pk, addrs[0].pk)
        self.assertEqual(ptr.pk, ptrs[0].pk)
        self.assertFalse(intrs)

        range_details = range_usage(ip_start, ip_end, '4')
        self.assertEqual(8, range_details['unused'])
        self.assertEqual(2, range_details['used'])
        self.assertEqual([(int(istart), int(istart) + 4),
                          (int(istart) + 7, int(istart) + 9)],
                         range_details['free_ranges'])
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:30,代码来源:usage_tests.py


示例3: test_integration5_ip

    def test_integration5_ip(self):
        root_domain = create_fake_zone("wee5.wee.mozilla.com", "")
        create_fake_zone("10.in-addr.arpa", "")
        res, error = compile_to_django("10.in-addr.arpa OR "
                                       "wee5.wee.mozilla.com")
        self.assertFalse(error)
        self.assertEqual(len(res['SOA']), 2)
        self.assertEqual(len(res['NS']), 2)
        self.assertEqual(len(res['DOMAIN']), 2)
        ptr = PTR(name="host1.wee2.wee.mozilla.com", ip_str="10.0.0.1",
                  ip_type="4")
        ptr.save()
        addr = AddressRecord(label="host1", domain=root_domain,
                             ip_str="10.0.0.1", ip_type="4")
        addr.save()

        res, error = compile_to_django(ptr.ip_str)
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 1)
        self.assertEqual(len(res['A']), 1)

        res, error = compile_to_django("10.0.0.2")
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 0)
        self.assertEqual(len(res['A']), 0)

        res, error = compile_to_django("ip=:10.0.0.1")
        self.assertFalse(error)
        self.assertEqual(len(res['PTR']), 1)
        self.assertEqual(len(res['A']), 1)
开发者ID:Marlburo,项目名称:inventory,代码行数:30,代码来源:integration.py


示例4: test_bad_nameserver_soa_state_case_3_0

    def test_bad_nameserver_soa_state_case_3_0(self):
        # This is Case 3
        root_domain = create_fake_zone("asdf30")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        soa = ns.domain.soa
        ns.domain.soa = None
        root_domain.soa = None  # Shit's getting cached
        ns.domain.save()
        soa.delete()

        # At his point we should have a domain pointed at no SOA record with no
        # records attached to it. It also has no child domains.

        # Add a record to the domain.
        a = AddressRecord(
            label='', domain=root_domain, ip_type="6", ip_str="1::")
        a.save()

        s = SOA(primary="asdf.asdf", contact="asdf.asdf", description="asdf")
        s.save()
        root_domain.soa = s

        self.assertRaises(ValidationError, root_domain.save)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:25,代码来源:tests.py


示例5: test_no_update_when_glue

    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:bclary,项目名称:inventory,代码行数:28,代码来源:tests.py


示例6: test_manual_assign_of_glue

    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,代码行数:34,代码来源:tests.py


示例7: do_remove_AAAA_record

    def do_remove_AAAA_record(self, aname, domain, ip):
        aret = AddressRecord(
            label=aname, domain=domain, ip_str=ip, ip_type='6')
        aret.save()
        self.assertTrue(aret)

        aret.delete()

        nret = AddressRecord.objects.filter(
            label=aname, domain=domain, ip_str=ip)
        self.assertFalse(nret)
开发者ID:bclary,项目名称:inventory,代码行数:11,代码来源:tests.py


示例8: test_update_glue_to_no_glue

    def test_update_glue_to_no_glue(self):
        glue = AddressRecord(label='ns3', domain=self.r,
                             ip_str='128.193.1.10', ip_type='4')
        glue.save()
        data = {'domain': self.r, 'server': 'ns3.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)

        ns.server = "ns4.wee"
        ns.save()
        self.assertTrue(ns.glue is None)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:11,代码来源:tests.py


示例9: test_delete_ns

    def test_delete_ns(self):
        glue = AddressRecord(label='ns4', domain=self.f_r,
                             ip_str='128.196.1.10', ip_type='4')
        glue.save()
        data = {'domain': self.f_r, 'server': 'ns4.foo.ru'}
        ns = self.do_add(**data)
        self.assertTrue(ns.glue)
        self.assertEqual(ns.server, ns.glue.fqdn)

        ns.delete()
        nsret = Nameserver.objects.filter(
            server='ns2.foo.ru', domain=self.f_r)
        self.assertFalse(nsret)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:13,代码来源:tests.py


示例10: test_basic_add_remove9

    def test_basic_add_remove9(self):
        # Make sure all record types block
        f_c = create_fake_zone("foo.foo22", suffix="")
        self.assertFalse(f_c.purgeable)
        fqdn = "y.z.foo.foo22"
        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label, domain=the_domain,
                             ip_type='4', ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))

        f_c = create_fake_zone("y.z.foo.foo22", suffix="")
        self.assertFalse(f_c.purgeable)
开发者ID:Marlburo,项目名称:inventory,代码行数:13,代码来源:full_name.py


示例11: test_bad_nameserver_soa_state_case_2_0

    def test_bad_nameserver_soa_state_case_2_0(self):
        # This is Case 2
        root_domain = create_fake_zone("asdf20")
        self.assertEqual(root_domain.nameserver_set.count(), 1)
        ns = root_domain.nameserver_set.all()[0]

        # At his point we should have a domain at the root of a zone with one
        # ns record associated to the domain.

        a = AddressRecord(
            label='', domain=root_domain, ip_type="6", ip_str="1::")
        a.save()

        self.assertRaises(ValidationError, ns.delete)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:14,代码来源:tests.py


示例12: test_existing_record_new_domain

    def test_existing_record_new_domain(self):
        name = "bo"
        b_dom, _ = Domain.objects.get_or_create(name=name, delegated=False)

        name = "to.bo"
        t_dom, _ = Domain.objects.get_or_create(name=name, delegated=False)

        arec1 = AddressRecord(label="no", domain=t_dom, ip_str="128.193.99.9",
                              ip_type='4')
        arec1.save()

        name = "no.to.bo"
        n_dom = Domain(name=name, delegated=False)
        self.assertRaises(ValidationError, n_dom.save)
开发者ID:caseybecking,项目名称:inventory,代码行数:14,代码来源:basic.py


示例13: test_invalid_create

    def test_invalid_create(self):
        glue = AddressRecord(label='ns2', domain=self.r,
                             ip_str='128.193.1.10', ip_type='4')
        glue.save()

        data = {'domain': self.r, 'server': 'ns2 .ru'}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {'domain': self.r, 'server': 'ns2$.ru'}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {'domain': self.r, 'server': 'ns2..ru'}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {'domain': self.r, 'server': 'ns2.ru '}
        self.assertRaises(ValidationError, self.do_add, **data)
        data = {'domain': self.r, 'server': ''}
        self.assertRaises(ValidationError, self.do_add, **data)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:15,代码来源:tests.py


示例14: test2_bad_add_for_a_ptr

 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,代码行数:16,代码来源:ipv6_basic.py


示例15: do_add_record6

 def do_add_record6(self, data):
     rec = AddressRecord(label=data['label'], domain=data[
                         'domain'], ip_str=data['ip'], ip_type='6')
     rec.save()
     self.assertTrue(rec.__repr__())
     self.assertTrue(rec.get_absolute_url())
     self.assertTrue(rec.get_edit_url())
     self.assertTrue(rec.get_delete_url())
     self.assertTrue(rec.details())
开发者ID:bclary,项目名称:inventory,代码行数:9,代码来源:tests.py


示例16: test_delegation

    def test_delegation(self):
        name = "boom"
        dom = Domain(name=name, delegated=True)
        dom.save()

        # Creating objects in the domain should be locked.
        arec = AddressRecord(label="ns1", domain=dom, ip_str="128.193.99.9",
                             ip_type='4')
        self.assertRaises(ValidationError, arec.save)

        ns = Nameserver(domain=dom, server="ns1." + dom.name)
        self.assertRaises(ValidationError, ns.save)

        cn = CNAME(label="999asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn.full_clean)

        # Undelegate (unlock) the domain.
        dom.delegated = False
        dom.save()

        # Add glue and ns record.
        arec.save()
        ns.save()

        # Re delegate the domain.
        dom.delegated = True
        dom.save()

        # Creation should still be locked
        arec1 = AddressRecord(
            label="ns2", domain=dom, ip_str="128.193.99.9", ip_type='4')
        self.assertRaises(ValidationError, arec1.save)

        cn1 = CNAME(label="1000asdf", domain=dom, target="asdf.asdf")
        self.assertRaises(ValidationError, cn1.full_clean)

        # Editing should be allowed.
        arec = AddressRecord.objects.get(pk=arec.pk)
        arec.ip_str = "129.193.88.2"
        arec.save()

        # Adding new A records that have the same name as an NS should
        # be allowed.
        arec1 = AddressRecord(label="ns1", domain=dom, ip_str="128.193.100.10",
                              ip_type='4')
        arec1.save()
开发者ID:caseybecking,项目名称:inventory,代码行数:46,代码来源:basic.py


示例17: migrate_AAAA

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,代码行数:34,代码来源:zone_migrate.py


示例18: test_cleanup_address

    def test_cleanup_address(self):
        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))

        fqdn = "bar.x.y.z.foo.poo"
        label, the_domain = ensure_label_domain(fqdn)
        addr = AddressRecord(label=label, domain=the_domain,
                             ip_type='4', ip_str="10.2.3.4")
        addr.save()
        self.assertFalse(prune_tree(the_domain))
        addr.delete()

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.poo"))
        self.assertFalse(Domain.objects.filter(name="z.foo.poo"))
        self.assertTrue(Domain.objects.filter(name="foo.poo"))
开发者ID:Marlburo,项目名称:inventory,代码行数:18,代码来源:auto_delete.py


示例19: test_private_view_case_1_addr

 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,代码行数:8,代码来源:tests.py


示例20: test_bad_nameserver_soa_state_case_2_1

    def test_bad_nameserver_soa_state_case_2_1(self):
        # This is Case 2
        root_domain = create_fake_zone("asdf21")
        self.assertEqual(root_domain.nameserver_set.count(), 1)
        ns = root_domain.nameserver_set.all()[0]

        # At his point we should have a domain at the root of a zone with one
        # ns record associated to the domain.

        # Let's create a child domain and add a record there, then try to
        # delete the NS record
        cdomain = Domain(name="test." + root_domain.name)
        cdomain.soa = root_domain.soa
        cdomain.save()

        a = AddressRecord(label='', domain=cdomain, ip_type="6", ip_str="1::")
        a.save()

        self.assertRaises(ValidationError, ns.delete)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:19,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Domain类代码示例发布时间:2022-05-27
下一篇:
Python mozdevice.DeviceManagerADB类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap