本文整理汇总了Python中cyder.cydns.address_record.models.AddressRecord.delete方法的典型用法代码示例。如果您正苦于以下问题:Python AddressRecord.delete方法的具体用法?Python AddressRecord.delete怎么用?Python AddressRecord.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cyder.cydns.address_record.models.AddressRecord
的用法示例。
在下文中一共展示了AddressRecord.delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_remove_AAAA_record
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
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)
示例2: test_delete_with_cname_pointing_to_a
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
def test_delete_with_cname_pointing_to_a(self):
label = 'foo100'
a = AddressRecord(label=label, domain=self.o_e, ip_str=
'128.193.1.10', ip_type='4')
a.clean()
a.save()
cn = CNAME(label="foomom", domain=self.o_e, target=label + "." +
self.o_e.name)
cn.clean()
cn.save()
self.assertRaises(ValidationError, a.delete)
a.delete(check_cname=False)
示例3: test_basic_add_remove5
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
def test_basic_add_remove5(self):
# Make sure all record types block
c = Domain(name='foo22')
c.save()
self.assertFalse(c.purgeable)
f_c = Domain(name='foo.foo22')
s, _ = SOA.objects.get_or_create(primary="foo", contact="foo",
comment="foo.foo22")
f_c.soa = s
f_c.save()
self.assertFalse(f_c.purgeable)
fqdn = "bar.x.y.z.foo.foo22"
label, the_domain = ensure_label_domain(fqdn)
txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
txt.save()
self.assertFalse(prune_tree(the_domain))
txt.delete()
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()
label, the_domain = ensure_label_domain(fqdn)
mx = MX(label=label, domain=the_domain, server="foo", priority=4)
mx.save()
self.assertFalse(prune_tree(the_domain))
mx.delete()
label, the_domain = ensure_label_domain(fqdn)
ns = Nameserver(domain=the_domain, server="asdfasffoo")
ns.save()
self.assertFalse(prune_tree(the_domain))
ns.delete()
label, the_domain = ensure_label_domain(fqdn)
srv = SRV(
label='_' + label, domain=the_domain, target="foo", priority=4,
weight=4, port=34)
srv.save()
self.assertFalse(prune_tree(the_domain))
srv.delete()
示例4: test_cleanup_address
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
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"))
示例5: test_basic_add_remove5
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
def test_basic_add_remove5(self):
# Make sure all record types block
f_c = create_fake_zone("foo.foo22", suffix="")
self.assertFalse(f_c.purgeable)
fqdn = "bar.x.y.z.foo.foo22"
label, the_domain = ensure_label_domain(fqdn)
txt = TXT(label=label, domain=the_domain, txt_data="Nthing")
txt.save()
self.assertFalse(prune_tree(the_domain))
txt.delete()
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()
label, the_domain = ensure_label_domain(fqdn)
mx = MX(label=label, domain=the_domain, server="foo", priority=4)
mx.save()
self.assertFalse(prune_tree(the_domain))
mx.delete()
label, the_domain = ensure_label_domain(fqdn)
ns = Nameserver(domain=the_domain, server="asdfasffoo")
ns.save()
self.assertFalse(prune_tree(the_domain))
ns.delete()
label, the_domain = ensure_label_domain(fqdn)
srv = SRV(
label='_' + label, domain=the_domain, target="foo", priority=4,
weight=4, port=34)
srv.save()
self.assertFalse(prune_tree(the_domain))
srv.delete()
示例6: NameserverForm
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import delete [as 别名]
class NameserverForm(DNSForm, UsabilityFormMixin):
glue_ip_str = forms.CharField(label="Glue's IP Address", required=False)
glue_ctnr = forms.ModelChoiceField(
queryset=Ctnr.objects.all(),
required=False,
label="Glue's Container")
class Meta:
model = Nameserver
fields = ('domain', 'server', 'views', 'ttl', 'glue_ip_str',
'glue_ctnr', 'description')
exclude = ('addr_glue', 'intr_glue')
widgets = {'views': forms.CheckboxSelectMultiple}
def __init__(self, *args, **kwargs):
super(NameserverForm, self).__init__(*args, **kwargs)
if not self.instance:
return
if not self.instance.glue:
# If it doesn't have glue, it doesn't need it.
return
addr_glue = AddressRecord.objects.filter(
label=self.instance.glue.label,
domain=self.instance.glue.domain)
intr_glue = StaticInterface.objects.filter(
label=self.instance.glue.label,
domain=self.instance.glue.domain)
glue_choices = []
for glue in addr_glue:
glue_choices.append(("addr_{0}".format(glue.pk), str(glue)))
for glue in intr_glue:
glue_choices.append(("intr_{0}".format(glue.pk), str(glue)))
if isinstance(self.instance.glue, AddressRecord):
initial = "addr_{0}".format(self.instance.glue.pk)
elif isinstance(self.instance.glue, StaticInterface):
initial = "intr_{0}".format(self.instance.glue.pk)
self.fields['glue'] = forms.ChoiceField(choices=glue_choices,
initial=initial)
def clean(self, *args, **kwargs):
self.glue = None
if self.instance.pk is None:
domain = self.cleaned_data['domain']
glue_ip_str, glue_ctnr = (self.cleaned_data['glue_ip_str'],
self.cleaned_data['glue_ctnr'])
server = self.cleaned_data['server'].strip('.')
if '.' in server:
if server.lower() != domain.name.lower():
glue_label, glue_domain = tuple(server.split('.', 1))
glue_domain = glue_domain.strip('.').lower()
else:
glue_label, glue_domain = "", server.lower()
else:
raise ValidationError(
"Please provide a fully qualified server name.")
if domain.delegated:
if glue_domain and glue_domain != domain.name.lower():
if glue_ip_str or glue_ctnr:
raise ValidationError(
"This record does not need glue, so "
"please leave the glue fields blank.")
else:
if not (glue_ip_str and glue_ctnr):
raise ValidationError(
"This zone is delegated, so "
"please provide information for glue.")
gluekwargs = {'domain': domain, 'label': glue_label,
'ip_str': glue_ip_str, 'ctnr': glue_ctnr}
try:
self.glue = AddressRecord.objects.get(**gluekwargs)
except AddressRecord.DoesNotExist:
self.glue = AddressRecord(**gluekwargs)
self.glue.set_is_glue()
self.glue.save()
for v in View.objects.all():
self.glue.views.add(v)
elif not domain.delegated and (glue_ip_str or glue_ctnr):
raise ValidationError("This zone is not delegated, so please "
"leave the glue fields blank.")
cleaned_data = super(NameserverForm, self).clean(*args, **kwargs)
return cleaned_data
def save(self, *args, **kwargs):
try:
super(NameserverForm, self).save(*args, **kwargs)
except Exception, e:
if self.glue and self.glue.pk is not None:
self.glue.delete(validate_glue=False)
raise ValidationError(e)