本文整理汇总了Python中cyder.cydns.address_record.models.AddressRecord.ip_str方法的典型用法代码示例。如果您正苦于以下问题:Python AddressRecord.ip_str方法的具体用法?Python AddressRecord.ip_str怎么用?Python AddressRecord.ip_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cyder.cydns.address_record.models.AddressRecord
的用法示例。
在下文中一共展示了AddressRecord.ip_str方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_update_when_glue
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import ip_str [as 别名]
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()
示例2: test_invalid_update_to_existing
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import ip_str [as 别名]
def test_invalid_update_to_existing(self):
rec1 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str="128.193.40.1", ip_type='4')
rec2 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str="128.193.40.2", ip_type='4')
rec3 = AddressRecord(label='foo', domain=self.z_o_e,
ip_str="128.193.40.1", ip_type='4')
rec3.save()
rec2.save()
rec1.save()
rec1.label = "foo"
self.assertRaises(ValidationError, rec1.save)
rec3.label = "bar"
self.assertRaises(ValidationError, rec3.save)
osu_block = "633:105:F000:"
rec1 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str=osu_block + ":1", ip_type='6')
rec2 = AddressRecord(label='bar', domain=self.z_o_e,
ip_str=osu_block + ":2", ip_type='6')
rec3 = AddressRecord(label='foo', domain=self.z_o_e,
ip_str=osu_block + ":1", ip_type='6')
rec1.save()
rec2.save()
rec3.save()
rec2.ip_str = osu_block + ":1"
self.assertRaises(ValidationError, rec2.save)
rec3.label = 'bar'
self.assertRaises(ValidationError, rec3.save)
示例3: test_delegation
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import ip_str [as 别名]
def test_delegation(self):
boom = create_zone('boom')
bleh = Domain.objects.create(name='bleh.boom', delegated=True)
self.ctnr.domains.add(bleh)
# Creating objects in the domain should be disallowed.
arec = AddressRecord(
label="ns1", ctnr=self.ctnr, domain=bleh, ip_str="128.193.99.9",
ip_type='4')
self.assertRaises(ValidationError, arec.save)
ns = Nameserver(ctnr=self.ctnr, domain=bleh, server="ns1." + bleh.name)
self.assertRaises(ValidationError, ns.save)
cn = CNAME(label="999asdf", ctnr=self.ctnr, domain=bleh,
target="asdf.asdf")
self.assertRaises(ValidationError, cn.save)
# Undelegate the domain.
bleh.delegated = False
bleh.save()
# Add glue and NS record.
arec.save()
ns.save()
# Re-delegate the domain.
bleh.delegated = True
bleh.save()
# Creation should still be disallowed.
self.assertRaises(
ValidationError, AddressRecord.objects.create,
label="ns2", ctnr=self.ctnr, domain=bleh, ip_str="128.193.99.9",
ip_type='4')
self.assertRaises(
ValidationError, CNAME.objects.create,
label="1000asdf", ctnr=self.ctnr, domain=bleh,
target="asdf.asdf")
# 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.
AddressRecord.objects.create(
label="ns1", ctnr=self.ctnr, domain=bleh, ip_str="128.193.100.10",
ip_type='4')
示例4: test_delegation
# 需要导入模块: from cyder.cydns.address_record.models import AddressRecord [as 别名]
# 或者: from cyder.cydns.address_record.models.AddressRecord import ip_str [as 别名]
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 allows.
arec1 = AddressRecord(
label="ns1", domain=dom, ip_str="128.193.100.10", ip_type='4')
arec1.save()