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


Python models.Domain类代码示例

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


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

示例1: gen_domain

    def gen_domain( self, domain, dname ):
        self.cur.execute("SELECT * FROM `zone_mx` WHERE `domain`='%s' ORDER BY `name`;" % (domain))
        bad_dnames = ['', '.', '_']
        cdomain = None
        if dname not in bad_dnames:
            # Other baddies
            if dname.find('in-addr.arpa') >= 0:
                return None
            else:
                # IT's a good domain. First see if it exists already. Else create it.
                cdomain = Domain( name = dname )
                try:
                    cdomain.save()
                except ValidationError, e:
                    arecs = AddressRecord.objects.filter(fqdn=dname)
                    ip_strs = []
                    mxs = MX.objects.filter(fqdn=dname)
                    mx_data = []
                    for arec in arecs:
                        ip_strs.append(arec.ip_str)
                        print "Re-Adding A record {0} to domain {1}".format(arec, dname)
                        arec.delete()

                    for mx in mxs:
                        print "Re-Adding MX record {0} to domain {1}".format(mx, dname)
                        mx_data.append((mx.server, mx.priority, mx.ttl))
                        mx.delete()

                    cdomain.save()
                    for ip_str in ip_strs:
                        AddressRecord(label="", domain=cdomain, ip_str=ip_str, ip_type='4').save()
                    for server, prio, ttl in mx_data:
                        mx = MX(label="", domain=cdomain, server=server, priority=prio, ttl=ttl)
                        mx.save()
                        print "Adding: {0} MX {1}".format(mx.fqdn, mx.server)
开发者ID:osunws,项目名称:cyder,代码行数:35,代码来源:zone.py

示例2: test_cleanup_cname

    def test_cleanup_cname(self):
        # Make sure CNAME record block
        c = Domain(name='foo1')
        c.save()
        self.assertFalse(c.purgeable)
        f_c = create_fake_zone('foo.foo1', suffix="")
        self.assertEqual(f_c.name, 'foo.foo1')

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

        self.assertFalse(f_c.purgeable)
        fqdn = "cname.x.y.z.foo.foo1"
        label, the_domain = ensure_label_domain(fqdn)

        cname = CNAME(label=label, domain=the_domain, target="foo")
        cname.save()
        self.assertFalse(prune_tree(the_domain))
        cname.delete()

        self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo1"))
        self.assertFalse(Domain.objects.filter(name="y.z.foo.foo1"))
        self.assertFalse(Domain.objects.filter(name="z.foo.foo1"))
        fqdn = "bar.x.y.z.foo.poo"
        self.assertTrue(Domain.objects.filter(name="foo.foo1"))
开发者ID:alecdhuse,项目名称:cyder,代码行数:27,代码来源:auto_delete.py

示例3: test_soa_perms

    def test_soa_perms(self):
        """
        Test SOA perms
        """
        self.setup_request()

        perm_table = {
            'cyder_admin': ['all'],
            'admin': ['view'],
            'user': ['view'],
            'guest': ['view'],
        }

        # initialize obj into ctnrs
        obj = SOA()
        obj.primary = '192.168.1.1'
        obj.contact = '192.168.1.1'
        obj.save()
        domain = Domain(id=None, name='foo')
        domain.soa = obj
        domain.save()
        self.ctnr_admin.domains.add(domain)
        self.ctnr_user.domains.add(domain)
        self.ctnr_guest.domains.add(domain)
        self.save_all_ctnrs()

        self.check_perms_each_user(obj, perm_table)
开发者ID:Ziaunys,项目名称:chili,代码行数:27,代码来源:tests.py

示例4: setUp

 def setUp(self):
     self.o = Domain( name = "org" )
     self.o.save()
     self.o_e = Domain( name = "oregonstate.org")
     self.o_e.save()
     self.b_o_e = Domain( name = "bar.oregonstate.org")
     self.b_o_e.save()
开发者ID:ngokevin,项目名称:cyder,代码行数:7,代码来源:tests.py

示例5: setUp

    def setUp(self):
        primary = "ns5.oregonstate.edu"
        contact = "admin.oregonstate.edu"
        retry = 1234
        refresh = 1234123
        self.soa = SOA(primary=primary, contact=contact,
                       retry=retry, refresh=refresh)
        self.soa.save()

        self.g = Domain(name="gz")
        self.g.save()
        self.c_g = Domain(name="coo.gz")
        self.c_g.soa = self.soa
        self.c_g.save()
        self.d = Domain(name="dz")
        self.d.save()

        self.arpa = self.create_domain(name='arpa')
        self.arpa.save()
        self.i_arpa = self.create_domain(name='in-addr.arpa')
        self.i_arpa.save()
        self.r1 = self.create_domain(name="10")
        self.r1.save()

        self.s = System()
        self.s.save()
开发者ID:Ziaunys,项目名称:chili,代码行数:26,代码来源:test_models.py

示例6: test_bad_resize

    def test_bad_resize(self):
        network = "129.0.0.0"
        prefixlen = "24"
        kwargs = {'network': network, 'prefixlen': prefixlen, 'ip_type': '4'}
        s = self.do_basic_add(**kwargs)
        self.assertTrue(s)

        d = Domain(name="asdf")
        d.save()

        start_str = "129.0.0.1"
        end_str = "129.0.0.255"
        default_domain = d
        network = s
        rtype = 's'
        ip_type = '4'

        r = Range(start_str=start_str, end_str=end_str, network=network)
        r.save()

        self.assertEqual(r.network, s)
        self.assertTrue(len(s.range_set.all()) == 1)

        s.network_str = "129.0.0.0/25"
        self.assertRaises(ValidationError, s.clean)
开发者ID:Ziaunys,项目名称:chili,代码行数:25,代码来源:tests.py

示例7: test_domain_records_perms

    def test_domain_records_perms(self):
        """Test common domain record perms (CNAME, MX, TXT, SRV, NS)"""
        self.setup_request()

        perm_table = {
            'cyder_admin': ['all'],
            'admin': ['all'],
            'user': ['all'],
            'guest': [ACTION_VIEW],
        }
        ns_perm_table = {
            'cyder_admin': ['all'],
            'admin': [ACTION_VIEW],
            'user': [ACTION_VIEW],
            'guest': [ACTION_VIEW],
        }

        # Initialize objs into ctnrs.
        domain = Domain(id=None, name='foo')
        domain.save()
        self.ctnr_admin.domains.add(domain)
        self.ctnr_user.domains.add(domain)
        self.ctnr_guest.domains.add(domain)
        self.save_all_ctnrs()
        domain_records = []
        domain_records.append(AddressRecord(domain=domain))
        domain_records.append(CNAME(domain=domain))
        domain_records.append(MX(domain=domain))
        domain_records.append(SRV(domain=domain))
        domain_records.append(TXT(domain=domain))

        self.check_perms_each_user(Nameserver(domain=domain), ns_perm_table)

        for obj in domain_records:
            self.check_perms_each_user(obj, perm_table, set_same_ctnr=True)
开发者ID:church29,项目名称:cyder,代码行数:35,代码来源:test_perms.py

示例8: test_domain_records_perms

    def test_domain_records_perms(self):
        """
        Test common domain record perms (cname, mx, txt, srv, ns)
        """
        self.setup_request()

        perm_table = {
            'cyder_admin': ['all'],
            'admin': ['all'],
            'user': ['all'],
            'guest': ['view'],
        }

        # Initialize objs into ctnrs.
        domain = Domain(id=None, name='foo')
        domain.save()
        self.ctnr_admin.domains.add(domain)
        self.ctnr_user.domains.add(domain)
        self.ctnr_guest.domains.add(domain)
        self.save_all_ctnrs()
        domain_records = []
        domain_records.append(AddressRecord(domain=domain))
        domain_records.append(CNAME(domain=domain))
        domain_records.append(MX(domain=domain))
        domain_records.append(SRV(domain=domain))
        domain_records.append(TXT(domain=domain))
        domain_records.append(Nameserver(domain=domain))

        for obj in domain_records:
            self.check_perms_each_user(obj, perm_table)
开发者ID:Ziaunys,项目名称:chili,代码行数:30,代码来源:tests.py

示例9: test_bad_delete

    def test_bad_delete(self):
        network = "129.0.0.0"
        prefixlen = "24"
        kwargs = {'network': network, 'prefixlen': prefixlen, 'ip_type': '4'}
        s = self.do_basic_add(**kwargs)
        s_pk = s.pk
        self.assertTrue(s)

        d = Domain(name="asdf")
        d.save()

        start_str = "129.0.0.1"
        end_str = "129.0.0.255"
        default_domain = d
        network = s
        rtype = 's'
        ip_type = '4'

        r = Range(start_str=start_str, end_str=end_str, network=network)
        r.clean()
        r.save()

        self.assertEqual(r.network, s)
        self.assertTrue(len(s.range_set.all()) == 1)

        self.assertRaises(ValidationError, s.delete)
        self.assertTrue(Network.objects.get(pk=s_pk))

        r.delete()
        s.delete()
        self.assertEqual(len(Network.objects.filter(pk=s_pk)), 0)
开发者ID:Ziaunys,项目名称:chili,代码行数:31,代码来源:tests.py

示例10: DeleteStaticInterTests

class DeleteStaticInterTests(TestCase):
    def create_domain(self, name, ip_type=None, delegated=False):
        if ip_type is None:
            ip_type = '4'
        if name in ('arpa', 'in-addr.arpa', 'ipv6.arpa'):
            pass
        else:
            name = ip_to_domain_name(name, ip_type=ip_type)
        d = Domain(name=name, delegated=delegated)
        d.clean()
        self.assertTrue(d.is_reverse)
        return d

    def setUp(self):
        self.arpa = self.create_domain(name='arpa')
        self.arpa.save()
        self.i_arpa = self.create_domain(name='in-addr.arpa')
        self.i_arpa.save()

        self.c = Domain(name="ccc")
        self.c.save()
        self.f_c = Domain(name="foo.ccc")
        self.f_c.save()
        self.r1 = self.create_domain(name="10")
        self.r1.save()
        self.n = System()
        self.n.clean()
        self.n.save()
        View.objects.get_or_create(name="private")

    def do_add(self, mac, label, domain, ip_str, system, ip_type='4'):
        r = StaticInterface(mac=mac, label=label, domain=domain, ip_str=ip_str,
                            ip_type=ip_type, system=system)
        r.clean()
        r.save()
        return r

    def do_delete(self, r):
        ip_str = r.ip_str
        fqdn = r.fqdn
        r.delete()
        self.assertFalse(
            AddressRecord.objects.filter(ip_str=ip_str, fqdn=fqdn))

    def test1_delete_basic(self):
        # Does deleting a system delete it's interfaces?
        mac = "11:22:33:44:55:66"
        label = "foo"
        domain = self.f_c
        ip_str = "10.0.0.2"
        system = System(hostname="foo")
        system.save()
        kwargs = {'mac': mac, 'label': label, 'domain': domain, 'ip_str': ip_str,
                  'system': system}
        i = self.do_add(**kwargs)
        intr_pk = i.pk
        self.assertTrue(StaticInterface.objects.filter(**kwargs))
        system.delete()
        self.assertFalse(StaticInterface.objects.filter(**kwargs))
开发者ID:Ziaunys,项目名称:chili,代码行数:59,代码来源:deletetion.py

示例11: test_delegation_add_domain

    def test_delegation_add_domain(self):
        name = "boom1"
        dom = Domain( name = name, delegated=True )
        dom.save()

        name = "boom.boom1"
        dom = Domain( name = name, delegated=False )
        self.assertRaises(ValidationError, dom.save)
开发者ID:osunws,项目名称:cyder,代码行数:8,代码来源:tests.py

示例12: setUp

 def setUp(self):
     s, _ = SOA.objects.get_or_create(primary="foo", contact="Foo",
                                      comment="foo")
     self.c = Domain(name='poo')
     self.c.save()
     self.assertFalse(self.c.purgeable)
     self.f_c = Domain(name='foo.poo')
     self.f_c.soa = s
     self.f_c.save()
开发者ID:Ziaunys,项目名称:chili,代码行数:9,代码来源:auto_delete.py

示例13: SSHFPTests

class SSHFPTests(TestCase):
    def setUp(self):
        self.o = Domain(name="org")
        self.o.save()
        self.o_e = Domain(name="mozilla.org")
        self.o_e.save()

    def do_generic_add(self, data):
        sshfp = SSHFP(**data)
        sshfp.__repr__()
        sshfp.save()
        self.assertTrue(sshfp.details())
        self.assertTrue(sshfp.get_detail_url())
        self.assertTrue(sshfp.get_update_url())
        self.assertTrue(sshfp.get_delete_url())
        rsshfp = SSHFP.objects.filter(**data)
        self.assertTrue(len(rsshfp) == 1)
        return sshfp

    def do_remove(self, data):
        sshfp = self.do_generic_add(data)
        sshfp.delete()
        rmx = SSHFP.objects.filter(**data)
        self.assertTrue(len(rmx) == 0)

    def test_add_remove_sshfp(self):
        label = "asdf"
        data = "asdf"
        s_type = 1
        a_type = 1
        data = {'label': label, 'key': data, 'domain': self.o_e,
                'algorithm_number': a_type, 'fingerprint_type': s_type}
        sshfp1 = self.do_generic_add(data)

        label = "asdf"
        data = "asdfasfd"
        s_type = 1
        a_type = 1
        data = {'label': label, 'key': data, 'domain': self.o_e,
                'algorithm_number': a_type, 'fingerprint_type': s_type}
        sshfp1 = self.do_generic_add(data)

        label = "df"
        data = "aasdf"
        s_type = 1
        a_type = 1
        data = {'label': label, 'key': data, 'domain': self.o_e,
                'algorithm_number': a_type, 'fingerprint_type': s_type}
        sshfp1 = self.do_generic_add(data)

        label = "12314"
        data = "dd"
        s_type = 1
        a_type = 1
        data = {'label': label, 'key': data, 'domain': self.o,
                'algorithm_number': a_type, 'fingerprint_type': s_type}
        sshfp1 = self.do_generic_add(data)
开发者ID:Ziaunys,项目名称:chili,代码行数:57,代码来源:test_models.py

示例14: DomainViewTests

class DomainViewTests(cyder.base.tests.TestCase):
    def setUp(self):
        soa = SOA(primary=random_label(
        ), contact=random_label(), comment=random_label())
        self.test_obj = Domain(name=random_label())
        self.test_obj.save()
        self.test_obj.soa = soa
        self.test_obj.save()

    def test_base_cydns_app_domain(self):
        resp = self.client.get(reverse('domain-list'), follow=True)
        self.assertEqual(resp.status_code, 200)

    def test_get_create_domain(self):
        resp = self.client.get(reverse('domain-create'), follow=True)
        self.assertEqual(resp.status_code, 200)

    def test_post_create_domain(self):
        resp = self.client.post(reverse('domain-create'),
                                self.post_data(), follow=True)
        self.assertTrue(resp.status_code in (302, 200))

    def test_get_object_update_domain(self):
        resp = self.client.get(reverse('domain-update',
                                       args=[self.test_obj.pk]),
                               follow=True)
        self.assertEqual(resp.status_code, 200)

    def test_post_object_update_domain(self):
        resp = self.client.post(reverse('domain-update',
                                        args=[self.test_obj.pk]),
                                self.post_data(), follow=True)
        self.assertTrue(resp.status_code in (302, 200))

    def test_post_object_update_domain(self):
        resp = self.client.post(reverse('domain-update',
                                        args=[self.test_obj.pk]),
                                {'soa': ''}, follow=True)
        self.assertTrue(resp.status_code in (302, 200))

    def test_get_object_details_domain(self):
        resp = self.client.get(reverse('domain-detail',
                                       args=[self.test_obj.pk]),
                               follow=True)
        self.assertEqual(resp.status_code, 200)

    def test_get_object_delete_domain(self):
        resp = self.client.get(reverse('domain-delete',
                                       args=[self.test_obj.pk]),
                               follow=True)
        self.assertEqual(resp.status_code, 200)

    def post_data(self):
        return {
            'name': random_label()
        }
开发者ID:Ziaunys,项目名称:chili,代码行数:56,代码来源:test_views.py

示例15: build_sample_domain

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", comment=random_label())
    soa.save()
    domain.soa = soa
    domain.save()
    return domain
开发者ID:Ziaunys,项目名称:chili,代码行数:10,代码来源:basic.py


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