本文整理汇总了Python中cyder.cydns.domain.models.Domain.save方法的典型用法代码示例。如果您正苦于以下问题:Python Domain.save方法的具体用法?Python Domain.save怎么用?Python Domain.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cyder.cydns.domain.models.Domain
的用法示例。
在下文中一共展示了Domain.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bad_delete
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例2: test_domain_records_perms
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例3: test_bad_resize
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例4: gen_domain
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例5: test_soa_perms
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例6: test_cleanup_cname
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
def test_cleanup_cname(self):
# Make sure CNAME record block
c = Domain(name='foo1')
c.save()
self.assertFalse(c.purgeable)
s, _ = SOA.objects.get_or_create(primary="foo", contact="Foo",
comment="dddfoo")
f_c = Domain(name='foo.foo1')
f_c.soa = s
f_c.save()
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"))
示例7: test_domain_records_perms
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例8: test_basic_add_remove3
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
def test_basic_add_remove3(self):
# MAke sure that if a domain is set to not purgeable the prune stops at
# that domain when a record exists in a domain
c = Domain(name='foo')
c.save()
self.assertFalse(c.purgeable)
f_c = Domain(name='foo.foo')
s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
comment="foo.foo")
f_c.soa = s
f_c.save()
self.assertFalse(f_c.purgeable)
fqdn = "bar.x.y.z.foo.foo"
label, the_domain = ensure_label_domain(fqdn)
txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
txt.save()
self.assertTrue(the_domain.purgeable)
# txt makes the domain un-purgeable.
self.assertFalse(prune_tree(the_domain))
txt.delete()
# The tree should have pruned itself
# Make sure stuff was deleted.
self.assertFalse(Domain.objects.filter(name="x.y.z.foo.foo"))
self.assertFalse(Domain.objects.filter(name="y.z.foo.foo"))
self.assertFalse(Domain.objects.filter(name="z.foo.foo"))
self.assertTrue(Domain.objects.filter(name="foo.foo"))
示例9: test_cleanup_cname
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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"))
示例10: DeleteStaticInterTests
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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))
示例11: test_delegation_add_domain
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例12: test_basic_add_remove2
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [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"))
示例13: test_remove_domain
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
def test_remove_domain(self):
c = Domain( name = 'com')
c.save()
f_c = Domain( name = 'foo.com')
f_c.save()
f_c.delete()
foo = Domain( name = 'foo.com' )
str(foo)
foo.__repr__()
示例14: SSHFPTests
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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)
示例15: DomainViewTests
# 需要导入模块: from cyder.cydns.domain.models import Domain [as 别名]
# 或者: from cyder.cydns.domain.models.Domain import save [as 别名]
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()
}