本文整理汇总了Python中cyder.cydhcp.network.models.Network.save方法的典型用法代码示例。如果您正苦于以下问题:Python Network.save方法的具体用法?Python Network.save怎么用?Python Network.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cyder.cydhcp.network.models.Network
的用法示例。
在下文中一共展示了Network.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test8_create_ipv4_interface
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test8_create_ipv4_interface(self):
v, _ = Vlan.objects.get_or_create(name="8db", number=3)
s, _ = Site.objects.get_or_create(name="8scl3")
s1, _ = Site.objects.get_or_create(name="8dmz", parent=s)
d, _ = Domain.objects.get_or_create(name="8scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="8dmz.8scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="8db.8dmz.8scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="15.in-addr.arpa")
n = Network(network_str="15.0.0.0/8", ip_type="4")
n.clean()
n.site = s1
n.vlan = v
n.save()
r = Range(start_str="15.0.0.0", end_str="15.0.0.2",
network=n)
r.clean()
r.save()
intr, errors = create_ipv4_interface(
"foo", "8db", "8dmz.8scl3", self.system,
"11:22:33:44:55:66", "mozilla.com")
self.assertEqual(errors, None)
self.assertTrue(isinstance(intr, StaticInterface))
示例2: test2_create_ipv4_interface_from_domain
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test2_create_ipv4_interface_from_domain(self):
v, _ = Vlan.objects.get_or_create(name="private", number=3)
s, _ = Site.objects.get_or_create(name="phx1")
s1, _ = Site.objects.get_or_create(name="corp", parent=s)
d, _ = Domain.objects.get_or_create(name="phx1.mozilla.com")
d1, _ = Domain.objects.get_or_create(name="corp.phx1.mozilla.com")
d2, _ = Domain.objects.get_or_create(
name="private.corp.phx1.mozilla.com")
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="14.in-addr.arpa")
n = Network(network_str="14.0.0.0/8", ip_type="4")
n.clean()
n.site = s1
n.vlan = v
n.save()
r = Range(start_str="14.0.0.0", end_str="14.0.0.2",
network=n)
r.clean()
r.save()
intr, errors = create_ipv4_intr_from_domain(
"foo", "private.corp.phx1", self.system,
"11:22:33:44:55:66")
self.assertEqual(errors, None)
self.assertTrue(isinstance(intr, StaticInterface))
示例3: test1_create_ipv4_interface_from_domain
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test1_create_ipv4_interface_from_domain(self):
v, _ = Vlan.objects.get_or_create(name="private", number=3)
s, _ = Site.objects.get_or_create(name="phx1")
d, _ = Domain.objects.get_or_create(name="phx1.mozilla.com")
d, _ = Domain.objects.get_or_create(name="private.phx1.mozilla.com")
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="13.in-addr.arpa")
n = Network(network_str="13.0.0.0/8", ip_type="4")
n.clean()
n.site = s
n.vlan = v
n.save()
r = Range(start_str="13.0.0.0", end_str="13.0.0.2",
network=n, ip_type='4')
r.clean()
r.save()
intr, errors = create_ipv4_intr_from_domain(
label="foo", domain_name="private.phx1", system=self.system,
mac="11:22:33:44:55:66")
self.assertEqual(errors, None)
self.assertTrue(isinstance(intr, StaticInterface))
示例4: setUp
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def setUp(self):
self.system = System()
self.system.save()
d1 = create_fake_zone("oregonstate.com", suffix="")
soa = d1.soa
self.soa = soa
v, _ = Vlan.objects.get_or_create(name="private", number=3)
s, _ = Site.objects.get_or_create(name="phx1")
s1, _ = Site.objects.get_or_create(name="corp", parent=s)
d, _ = Domain.objects.get_or_create(name="phx1.oregonstate.com")
d.soa = soa
d.save()
d1, _ = Domain.objects.get_or_create(name="corp.phx1.oregonstate.com")
d1.soa = soa
d1.save()
d2, _ = Domain.objects.get_or_create(
name="private.corp.phx1.oregonstate.com")
d2.soa = soa
d2.save()
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="15.in-addr.arpa")
n = Network(network_str="15.0.0.0/8", ip_type="4")
n.clean()
n.site = s1
n.vlan = v
n.save()
r = Range(start_str="15.0.0.0", end_str="15.0.0.10",
network=n, ip_type='4')
r.clean()
r.save()
示例5: do_basic_add_network
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def do_basic_add_network(self, network, prefixlen, ip_type, name=None,
vlan=None, site=None):
n = Network(network_str=network + "/" + prefixlen, ip_type=ip_type,
site=site, vlan=vlan)
n.clean()
n.save()
return n
示例6: do_basic_add
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def do_basic_add(self, network, prefixlen, ip_type,
ame=None, number=None, site=None):
s = Network(network_str=network + "/" + prefixlen,
ip_type=ip_type, site=site)
s.clean()
s.save()
self.assertTrue(s)
return s
示例7: test_overlap_validation
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test_overlap_validation(self):
n1 = Network(network_str='1::/65', ip_type='6')
n1.update_network()
n1.save()
self.assertFalse(n1 in get_total_overlap(n1))
self.assertFalse(n1 in get_partial_overlap(n1))
n2 = Network(network_str='1::/66', ip_type='6')
n2.update_network()
self.assertEqual(n1.start_upper, n2.start_upper)
self.assertEqual(n1.end_upper, n2.end_upper)
self.assertFalse(n1 in get_total_overlap(n2))
self.assertTrue(n1 in get_partial_overlap(n2))
n2 = Network(network_str='1::/64', ip_type='6')
n2.update_network()
self.assertEqual(n1.start_upper, n2.start_upper)
self.assertEqual(n1.end_upper, n2.end_upper)
self.assertTrue(n1 in get_total_overlap(n2))
self.assertTrue(n1 in get_partial_overlap(n2))
n2 = Network(network_str='1:0:0:0:8000::/65', ip_type='6')
n2.update_network()
self.assertEqual(n1.start_upper, n2.start_upper)
self.assertEqual(n1.end_upper, n2.end_upper)
self.assertFalse(n1 in get_total_overlap(n2))
self.assertFalse(n1 in get_partial_overlap(n2))
n1 = Network(network_str='2::/16', ip_type='6')
n1.update_network()
n1.save()
self.assertFalse(n1 in get_total_overlap(n1))
self.assertFalse(n1 in get_partial_overlap(n1))
n2 = Network(network_str='2::/17', ip_type='6')
n2.update_network()
self.assertEqual(n1.start_upper, n2.start_upper)
self.assertNotEqual(n1.end_upper, n2.end_upper)
self.assertFalse(n1 in get_total_overlap(n2))
self.assertTrue(n1 in get_partial_overlap(n2))
n2 = Network(network_str='2::/15', ip_type='6')
n2.update_network()
self.assertEqual(n1.start_upper, n2.start_upper)
self.assertNotEqual(n1.end_upper, n2.end_upper)
self.assertTrue(n1 in get_total_overlap(n2))
self.assertTrue(n1 in get_partial_overlap(n2))
n2 = Network(network_str='3::/16', ip_type='6')
n2.update_network()
self.assertNotEqual(n1.start_upper, n2.start_upper)
self.assertNotEqual(n1.end_upper, n2.end_upper)
self.assertFalse(n1 in get_total_overlap(n2))
self.assertFalse(n1 in get_partial_overlap(n2))
示例8: test_check_valid_ranges_v4_valid
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test_check_valid_ranges_v4_valid(self):
n = Network(network_str='10.0.0.0/8')
n.full_clean()
n.save()
r = Range(ip_type='4', start_str='10.4.0.2', end_str='10.4.255.254',
network=n)
r.full_clean()
r.save()
n.network_str = '10.4.0.0/16'
n.full_clean()
n.save()
示例9: test_check_valid_ranges_v4_start_low_end_high
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test_check_valid_ranges_v4_start_low_end_high(self):
n = Network(network_str='10.0.0.0/8')
n.full_clean()
n.save()
r = Range(ip_type='4', start_str='10.3.0.2', end_str='10.5.255.254',
network=n)
r.full_clean()
r.save()
n.network_str = '10.4.0.0/16'
with self.assertRaises(ValidationError):
n.full_clean()
n.save()
示例10: test1_create_ipv4_interface_network_str
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test1_create_ipv4_interface_network_str(self):
v, _ = Vlan.objects.get_or_create(name="12db", number=3)
s, _ = Site.objects.get_or_create(name="12scl3")
d, _ = Domain.objects.get_or_create(name="12scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="12db.12scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="12.in-addr.arpa")
n = Network(network_str="12.0.0.0/24", ip_type="4")
n.clean()
n.site = s
n.vlan = v
n.save()
n1 = Network(network_str="12.0.1.0/24", ip_type="4")
n1.clean()
n1.site = s
n1.vlan = v
n1.save()
r = Range(start_str="12.0.0.0", end_str="12.0.0.2",
network=n)
r.clean()
r.save()
r1 = Range(start_str="12.0.1.0", end_str="12.0.1.2",
network=n1)
r1.clean()
r1.save()
intr, errors = create_ipv4_interface(
"foo", "12db", "12scl3", self.system,
"11:22:33:4e:55:66", "mozilla.com")
self.assertTrue('network' in errors)
self.assertTrue(
errors['network'][0].find("too many networks associated") != -1)
# Look for a non-existant network
intr, errors = create_ipv4_interface(
"foo", "12db", "12scl3", self.system,
"11:22:33:4e:55:66", "mozilla.com", network_str="12.0.99.0/24")
self.assertTrue('network' in errors)
intr, errors = create_ipv4_interface(
"foo", "12db", "12scl3", self.system,
"11:22:33:4e:55:66", "mozilla.com", network_str="12.0.0.0/24")
self.assertFalse(errors)
self.assertTrue(isinstance(intr, StaticInterface))
示例11: test6_create_ipv4_interface
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test6_create_ipv4_interface(self):
v, _ = Vlan.objects.get_or_create(name="6db", number=3)
s, _ = Site.objects.get_or_create(name="6scl3")
d, _ = Domain.objects.get_or_create(name="6scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="6db.6scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="11.in-addr.arpa")
n = Network(network_str="11.0.0.0/8", ip_type="4")
n.clean()
n.site = s
n.vlan = v
n.save()
r = Range(start_str="11.0.0.0", end_str="11.0.0.2",
network=n, ip_type='4')
r.clean()
r.save()
s = StaticInterface(label="fab", domain=d, ip_type="4",
ip_str="11.0.0.0", system=self.system,
mac="00:00:00:00:00:00")
s.clean()
s.save()
s = StaticInterface(label="fab", domain=d, ip_type="4",
ip_str="11.0.0.1", system=self.system,
mac="00:00:00:00:00:00")
s.clean()
s.save()
s = StaticInterface(label="fab", domain=d, ip_type="4",
ip_str="11.0.0.2", system=self.system,
mac="00:00:00:00:00:00")
s.clean()
s.save()
intr, errors = create_ipv4_interface(
"foo", "6db", "6scl3", self.system,
"11:22:33:44:55:66", "mozilla.com")
self.assertEqual(intr, None)
self.assertTrue("vlan" not in errors)
self.assertTrue("site" not in errors)
self.assertTrue("domain" not in errors)
self.assertTrue("network" not in errors)
self.assertTrue("range" not in errors)
self.assertTrue("ip" in errors)
示例12: test5_create_ipv4_interface
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def test5_create_ipv4_interface(self):
v, _ = Vlan.objects.get_or_create(name="5db", number=3)
s, _ = Site.objects.get_or_create(name="5scl3")
d, _ = Domain.objects.get_or_create(name="5scl3.mozilla.com")
d, _ = Domain.objects.get_or_create(name="5db.5scl3.mozilla.com")
n = Network(network_str="10.0.0.0/8", ip_type="4")
n.clean()
n.site = s
n.vlan = v
n.save()
intr, errors = create_ipv4_interface(
"foo", "5db", "5scl3", self.system,
"11:22:33:44:55:66", "mozilla.com")
self.assertEqual(intr, None)
self.assertTrue("vlan" not in errors)
self.assertTrue("site" not in errors)
self.assertTrue("domain" not in errors)
self.assertTrue("network" not in errors)
self.assertTrue("range" in errors)
示例13: setUp
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
def setUp(self):
self.system = System()
Domain.objects.get_or_create(name="com")
d1, _ = Domain.objects.get_or_create(name="mozilla.com")
soa, _ = SOA.objects.get_or_create(
primary="fo.bar", contact="foo.bar.com",
comment="foo bar")
self.s = soa
d1.soa = soa
d1.save()
v, _ = Vlan.objects.get_or_create(name="private", number=3)
s, _ = Site.objects.get_or_create(name="phx1")
s1, _ = Site.objects.get_or_create(name="corp", parent=s)
d, _ = Domain.objects.get_or_create(name="phx1.mozilla.com")
d.soa = soa
d.save()
d1, _ = Domain.objects.get_or_create(name="corp.phx1.mozilla.com")
d1.soa = soa
d1.save()
d2, _ = Domain.objects.get_or_create(
name="private.corp.phx1.mozilla.com")
d2.soa = soa
d2.save()
d, _ = Domain.objects.get_or_create(name="arpa")
d, _ = Domain.objects.get_or_create(name="in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="ipv6.arpa")
d, _ = Domain.objects.get_or_create(name="15.in-addr.arpa")
d, _ = Domain.objects.get_or_create(name="2.in-addr.arpa")
n = Network(network_str="15.0.0.0/8", ip_type="4")
n.clean()
n.site = s1
n.vlan = v
n.save()
r = Range(start_str="15.0.0.0", end_str="15.0.0.10",
network=n)
r.clean()
r.save()
示例14: V6RangeTests
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
class V6RangeTests(TestCase):
def setUp(self):
self.d = Domain(name="com")
self.s = Network(network_str="1234:1234:1234::/16", ip_type='6')
self.s.update_network()
self.s.save()
self.s1 = Network(network_str="1234:1134:1234::/32", ip_type='6')
self.s1.update_network()
self.s1.save()
self.s2 = Network(network_str="fff::/4", ip_type='6')
self.s2.update_network()
self.s2.save()
self.s3 = Network(network_str="ffff::/4", ip_type='6')
self.s3.update_network()
self.s3.save()
def do_add(self, start_str, end_str, default_domain, network, \
rtype, ip_type):
r = Range(start_str=start_str, end_str=end_str, network=network,
ip_type=ip_type)
r.__repr__()
r.save()
return r
def test1_create(self):
start_str = "1234:1234:1234:1::"
end_str = "1234:1234:1234:1234:1234:1234::"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '6'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain,
'network': network, 'rtype': rtype, 'ip_type': ip_type}
self.do_add(**kwargs)
def test2_create(self):
start_str = "1234:1234:1234:1234::"
end_str = "1234:1234:1235:1234:1234:1234::"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '6'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain,
'network': network, 'rtype': rtype, 'ip_type': ip_type}
self.do_add(**kwargs)
def test3_create(self):
start_str = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0"
end_str = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe"
default_domain = self.d
network = self.s3
rtype = 's'
ip_type = '6'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain,
'network': network, 'rtype': rtype, 'ip_type': ip_type}
r = self.do_add(**kwargs)
self.assertEqual(r.start_upper, 0xffffffffffffffff)
self.assertEqual(r.start_lower, 0xfffffffffffffff0)
self.assertEqual(r.end_upper, 0xffffffffffffffff)
self.assertEqual(r.end_lower, 0xfffffffffffffffe)
"""
def test1_bad_create(self):
# start == end
start_str = "1234:1235:1234:1234::"
end_str = "1234:1235:1234:1234::"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '6'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain,
'network': network, 'rtype': rtype, 'ip_type': ip_type}
self.assertRaises(ValidationError, self.do_add, **kwargs)
"""
def test2_bad_create(self):
# start > end
start_str = "1234:1235:1234:1235::"
end_str = "1234:1235:1234:1234::"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '6'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain,
'network': network, 'rtype': rtype, 'ip_type': ip_type}
self.assertRaises(ValidationError, self.do_add, **kwargs)
#.........这里部分代码省略.........
示例15: V4RangeTests
# 需要导入模块: from cyder.cydhcp.network.models import Network [as 别名]
# 或者: from cyder.cydhcp.network.models.Network import save [as 别名]
class V4RangeTests(TestCase):
def setUp(self):
self.d = Domain(name="com")
self.d.save()
Domain(name="arpa").save()
Domain(name="in-addr.arpa").save()
Domain(name="10.in-addr.arpa").save()
self.s = Network(network_str="10.0.0.0/16", ip_type='4')
self.s.update_network()
self.s.save()
self.s1 = Network(network_str="10.2.1.0/24", ip_type='4')
self.s1.update_network()
self.s1.save()
def do_add(self, start_str, end_str, default_domain, \
network, rtype, ip_type):
r = Range(start_str=start_str, end_str=end_str, network=network,
ip_type=ip_type)
r.__repr__()
r.save()
return r
def test1_create(self):
start_str = "10.0.0.1"
end_str = "10.0.0.55"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '4'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain, 'network': network,
'rtype': rtype, 'ip_type': ip_type}
self.do_add(**kwargs)
def test2_create(self):
start_str = "10.0.1.1"
end_str = "10.0.1.55"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '4'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain, 'network': network,
'rtype': rtype, 'ip_type': ip_type}
self.do_add(**kwargs)
def test1_bad_create(self):
# start == end
start_str = "10.0.0.0"
end_str = "10.1.0.0"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '4'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain, 'network': network,
'rtype': rtype, 'ip_type': ip_type}
self.assertRaises(ValidationError, self.do_add, **kwargs)
def test2_bad_create(self):
# start > end
start_str = "10.0.0.2"
end_str = "10.0.0.1"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '4'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain, 'network': network,
'rtype': rtype, 'ip_type': ip_type}
self.assertRaises(ValidationError, self.do_add, **kwargs)
def test3_bad_create(self):
# outside of network
start_str = "11.0.0.2"
end_str = "10.0.0.88"
default_domain = self.d
network = self.s
rtype = 's'
ip_type = '4'
kwargs = {'start_str': start_str, 'end_str': end_str,
'default_domain': default_domain, 'network': network,
'rtype': rtype, 'ip_type': ip_type}
self.assertRaises(ValidationError, self.do_add, **kwargs)
def test4_bad_create(self):
# outside of network
start_str = "10.2.0.0"
end_str = "10.2.1.88"
default_domain = self.d
network = self.s1
rtype = 's'
ip_type = '4'
#.........这里部分代码省略.........