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


Python Domain.soa方法代码示例

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


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

示例1: test_basic_add_remove2

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_basic_add_remove2(self):
        # MAke sure that if a domain is set to not purgeable the prune stops at
        # that domain.
        c = Domain(name='edu')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.edu')
        s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
                                         description="foo.edu")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.edu"
        label, the_domain = ensure_label_domain(fqdn)
        self.assertEqual(label, "bar")
        self.assertEqual(the_domain.name, "x.y.z.foo.edu")
        self.assertTrue(the_domain.purgeable)
        self.assertEqual(the_domain.master_domain.name, "y.z.foo.edu")
        self.assertTrue(the_domain.master_domain.purgeable)
        self.assertEqual(
            the_domain.master_domain.master_domain.name, "z.foo.edu")
        self.assertTrue(the_domain.master_domain.master_domain.purgeable)
        self.assertEqual(
            the_domain.master_domain.master_domain.master_domain.name,
            "foo.edu")
        self.assertFalse(
            the_domain.master_domain.master_domain.master_domain.purgeable)

        # See if purgeable stops prune
        the_domain.purgeable = False
        the_domain.save()
        self.assertFalse(prune_tree(the_domain))
        the_domain.purgeable = True
        the_domain.save()
        # Ok, reset

        y_z = Domain.objects.get(name="y.z.foo.edu")
        y_z.purgeable = False
        y_z.save()

        # Refresh the domain
        the_domain = Domain.objects.get(pk=the_domain.pk)
        # This should delete up to and stop at the domain "y.z.foo.edu"
        self.assertTrue(prune_tree(the_domain))

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.edu"))
        self.assertTrue(Domain.objects.filter(name="y.z.foo.edu"))
        self.assertTrue(Domain.objects.filter(name="z.foo.edu"))
        self.assertTrue(Domain.objects.filter(name="foo.edu"))

        # If we delete y.z.foo.com and then call prune on z.foo.com is should
        # delete z.foo.com
        Domain.objects.get(name="y.z.foo.edu").delete()

        self.assertTrue(prune_tree(Domain.objects.get(name="z.foo.edu")))
        self.assertFalse(Domain.objects.filter(name="z.foo.edu"))
        self.assertTrue(Domain.objects.filter(name="foo.edu"))
开发者ID:Marlburo,项目名称:inventory,代码行数:59,代码来源:full_name.py

示例2: test_delete_with_domains

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
 def test_delete_with_domains(self):
     data = {'primary': "ns1asfdadsf.foo.com", 'contact': "email.foo.com"}
     soa = SOA(**data)
     soa.save()
     d0 = Domain(name='com')
     d0.save()
     d1 = Domain(name='foo.com', soa=soa)
     d1.soa = soa
     d1.save()
     self.assertRaises(ValidationError, soa.delete)
开发者ID:caseybecking,项目名称:inventory,代码行数:12,代码来源:model_tests.py

示例3: build_sample_domain

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
def build_sample_domain():
    domain_name = ''
    for i in range(2):
        domain_name = random_label()
        domain = Domain(name=domain_name)
    soa = SOA(
        primary=random_label(), contact="asf", description=random_label())
    soa.save()
    domain.soa = soa
    domain.save()
    return domain
开发者ID:caseybecking,项目名称:inventory,代码行数:13,代码来源:ptr.py

示例4: test_no_soa_block2

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_no_soa_block2(self):
        c = Domain(name='moo')
        c.save()
        f_c = Domain(name='foo.moo')
        f_c.save()
        s, _ = SOA.objects.get_or_create(primary="bar23", contact="Foo",
                                         description="bar")
        f_c.soa = s
        f_c.save()

        self.assertRaises(ValidationError, ensure_label_domain, "baz.moo")
开发者ID:Marlburo,项目名称:inventory,代码行数:13,代码来源:auto_create.py

示例5: test_delegation_block

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_delegation_block(self):
        s, _ = SOA.objects.get_or_create(primary="foo", contact="Foo",
                                         description="foo")
        c = Domain(name='com')
        c.soa = s
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.com')
        f_c.delegated = True
        f_c.save()
        self.assertFalse(f_c.purgeable)
        self.assertTrue(f_c.delegated)

        fqdn = "z.baz.foo.com"
        self.assertRaises(ValidationError, ensure_label_domain, fqdn)
开发者ID:Marlburo,项目名称:inventory,代码行数:17,代码来源:auto_create.py

示例6: test_bad_nameserver_soa_state_case_1_3

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_1_3(self):
        # This is Case 1 ... with ptr's
        root_domain = create_fake_zone("13.in-addr.arpa", suffix="")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        # At his point we should have a domain at the root of a zone with no
        # other records in it.

        # Let's create a child domain and try to add a record there.
        cdomain = Domain(name="10.13.in-addr.arpa")
        cdomain.soa = root_domain.soa
        cdomain.save()

        # Adding a record shouldn't be allowed because there is no NS record on
        # the zone's root domain.
        ptr = PTR(name="asdf", ip_str="13.10.1.1", ip_type="4")
        self.assertRaises(ValidationError, ptr.save)
开发者ID:Marlburo,项目名称:inventory,代码行数:20,代码来源:tests.py

示例7: test_bad_nameserver_soa_state_case_2_1

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    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()

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

        self.assertRaises(ValidationError, ns.delete)
开发者ID:Marlburo,项目名称:inventory,代码行数:21,代码来源:tests.py

示例8: create_domains

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def create_domains(self):
        private = View(name="private")
        private.save()
        public = View(name="public")
        public.save()
        d0 = create_fake_zone("dc.mozilla.com", suffix="")
        s = d0.soa
        d = Domain(name='vlan.dc.mozilla.com')
        d.save()
        d.soa = s
        d.save()
        Domain(name='arpa').save()
        Domain(name='in-addr.arpa').save()

        # Create Reverse Domains
        d = create_fake_zone("10.in-addr.arpa", suffix="")

        d = create_fake_zone("66.in-addr.arpa", suffix="")

        vlan = Vlan(name='vlan', number=99)
        vlan.save()
        site = Site(name='dc')
        site.save()
        network = Network(network_str="10.0.0.0/8", ip_type='4')
        network2 = Network(network_str="66.66.66.0/24", ip_type='4')
        network2.update_network()
        network2.save()
        network.vlan = vlan
        network.site = site
        network.update_network()
        network.save()
        r = Range(
            start_str='10.99.99.1',
            end_str='10.99.99.254',
            network=network,)
        r.clean()
        r.save()
        r = Range(
            start_str='66.66.66.1',
            end_str='66.66.66.254',
            network=network2,)
        r.clean()
        r.save()
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:45,代码来源:tests.py

示例9: test_bad_nameserver_soa_state_case_2_3

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_2_3(self):
        # This is Case 2 ... with ptrs
        root_domain = create_fake_zone("10.23.in-addr.arpa", suffix="")
        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()

        ptr = PTR(name="asdf", ip_str="23.10.1.1", ip_type="4")
        ptr.save()

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

示例10: test_bad_nameserver_soa_state_case_1_1

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_1_1(self):
        # This is Case 1
        root_domain = create_fake_zone("asdf111")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        # At his point we should have a domain at the root of a zone with no
        # other records in it.

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

        # Adding a record shouldn't be allowed because there is no NS record on
        # the zone's root domain.
        a = AddressRecord(label='', domain=cdomain, ip_type="6", ip_str="1::")
        self.assertRaises(ValidationError, a.save)
        cn = CNAME(label='', domain=cdomain, target="asdf")
        self.assertRaises(ValidationError, cn.save)
开发者ID:Marlburo,项目名称:inventory,代码行数:22,代码来源:tests.py

示例11: test_bad_nameserver_soa_state_case_1_4

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_1_4(self):
        # This is Case 1 ... with StaticInterfaces's
        reverse_root_domain = create_fake_zone("14.in-addr.arpa", suffix="")
        root_domain = create_fake_zone("asdf14")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        # At his point we should have a domain at the root of a zone with no
        # other records in it.

        # Let's create a child domain and try to add a record there.
        cdomain = Domain(name="10.14.in-addr.arpa")
        cdomain.soa = reverse_root_domain.soa
        cdomain.save()

        # Adding a record shouldn't be allowed because there is no NS record on
        # the zone's root domain.
        intr = StaticInterface(
            label="asdf", domain=root_domain, ip_str="14.10.1.1", ip_type="4",
            mac="11:22:33:44:55:66", system=self.s)
        self.assertRaises(ValidationError, intr.save)
开发者ID:rtucker-mozilla,项目名称:mozilla_inventory,代码行数:23,代码来源:tests.py

示例12: test_basic_add_remove1

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_basic_add_remove1(self):
        c = Domain(name='com')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = Domain(name='foo.com')
        s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
                                         description="foo.zfoo.comom")
        f_c.soa = s
        f_c.save()
        self.assertFalse(f_c.purgeable)
        fqdn = "bar.x.y.z.foo.com"
        label, the_domain = ensure_label_domain(fqdn)
        self.assertEqual(label, "bar")
        self.assertEqual(the_domain.name, "x.y.z.foo.com")
        self.assertTrue(the_domain.purgeable)
        self.assertEqual(the_domain.master_domain.name, "y.z.foo.com")
        self.assertTrue(the_domain.master_domain.purgeable)
        self.assertEqual(
            the_domain.master_domain.master_domain.name, "z.foo.com")
        self.assertTrue(the_domain.master_domain.master_domain.purgeable)
        self.assertEqual(
            the_domain.master_domain.master_domain.master_domain.name,
            "foo.com")
        self.assertFalse(
            the_domain.master_domain.master_domain.master_domain.purgeable)

        # Now call prune tree one the_domain
        self.assertTrue(prune_tree(the_domain))

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.com"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.com"))
        self.assertFalse(Domain.objects.filter(name="z.foo.com"))
        self.assertTrue(Domain.objects.filter(name="foo.com"))

        # Make sure other domain's can't be pruned
        self.assertFalse(prune_tree(f_c))
        self.assertTrue(Domain.objects.filter(name="foo.com"))
        self.assertFalse(prune_tree(c))
        self.assertTrue(Domain.objects.filter(name="com"))
开发者ID:Marlburo,项目名称:inventory,代码行数:41,代码来源:full_name.py

示例13: test_bad_nameserver_soa_state_case_3_3

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_3_3(self):
        # This is Case 3 ... with ptrs
        root_domain = create_fake_zone("33.in-addr.arpa", suffix="")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        # At his point we should have a domain pointed at an SOA record with no
        # records attached to it (esspecially no ns recods). It also has no
        # child domains.
        # Try case 3 but add a record to a child domain of root_domain
        cdomain = Domain(name="10.33.in-addr.arpa")
        cdomain.save()

        # Add a record to the domain.
        ptr = PTR(name="asdf", ip_str="33.10.1.1", ip_type="4")
        ptr.save()

        # Now try to add the domain to the zone that has no NS records at it's
        # root
        cdomain.soa = root_domain.soa

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

示例14: test_bad_nameserver_soa_state_case_3_1

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_bad_nameserver_soa_state_case_3_1(self):
        # This is Case 3
        root_domain = create_fake_zone("asdf31")
        for ns in root_domain.nameserver_set.all():
            ns.delete()

        # At his point we should have a domain pointed at an SOA record with no
        # records attached to it (esspecially no ns recods). It also has no
        # child domains.
        # Try case 3 but add a record to a child domain of root_domain
        cdomain = Domain(name="test." + root_domain.name)
        cdomain.save()

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

        # Now try to add the domain to the zone that has no NS records at it's
        # root
        cdomain.soa = root_domain.soa

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

示例15: test_soa_validators

# 需要导入模块: from mozdns.domain.models import Domain [as 别名]
# 或者: from mozdns.domain.models.Domain import soa [as 别名]
    def test_soa_validators(self):
        m = Domain(name='moo')
        m.save()

        f_m = Domain(name='foo.moo')
        f_m.save()

        n_f_m = Domain(name='noo.foo.moo')
        n_f_m.save()

        b_m = Domain(name='baz.moo')
        b_m.save()

        s = SOA(primary="ns1.foo.com", contact="asdf", description="test")
        s.save()

        f_m.soa = s
        f_m.save()

        b_m.soa = s
        self.assertRaises(ValidationError, b_m.save)

        n_f_m = Domain.objects.get(pk=n_f_m.pk)  # Refresh object
        n_f_m.soa = s
        n_f_m.save()

        m.soa = s
        m.save()

        b_m.soa = s
        b_m.save()

        m.soa = None
        self.assertRaises(ValidationError, m.save)

        s2 = SOA(primary="ns1.foo.com", contact="asdf", description="test2")
        s2.save()

        m.soa = s2
        self.assertRaises(ValidationError, m.save)
开发者ID:caseybecking,项目名称:inventory,代码行数:42,代码来源:basic.py


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