本文整理汇总了Python中AutoNetkit.reverse_subnet方法的典型用法代码示例。如果您正苦于以下问题:Python AutoNetkit.reverse_subnet方法的具体用法?Python AutoNetkit.reverse_subnet怎么用?Python AutoNetkit.reverse_subnet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoNetkit
的用法示例。
在下文中一共展示了AutoNetkit.reverse_subnet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_dns
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import reverse_subnet [as 别名]
#.........这里部分代码省略.........
logging = False,
))
f_named.close()
for server in auth_servers:
named_list = []
advertise_links = list(ank.advertise_links(server))
advertise_hosts = list(ank.dns_auth_children(server))
LOG.debug("DNS server %s advertises %s" % (server, advertise_links))
#TODO: make reverse dns handle domains other than /8 /16 /24
advertise_block = ip_as_allocs[server.asn]
# remove trailing fullstop
reverse_identifier = ank.rev_dns_identifier(advertise_block).rstrip(".")
#TODO: look at using advertise_block.network.reverse_dns - check what Bind needs
named_list.append(reverse_identifier)
f_named = open( os.path.join(bind_dir(self.network, server), "named.conf"), 'wb')
f_named.write(named_template.render(
domain = server.domain,
entry_list = named_list,
bind_dir = linux_bind_dir,
logging = False,
))
f_named.close()
for_entry_list = list( (self.interface_id(link.id), link.local_host.dns_host_portion_only, link.ip)
for link in advertise_links)
# Add loopbacks for routers
for_entry_list += ( (self.lo_interface(0), host.dns_host_portion_only, host.lo_ip.ip)
#TODO: make thise check l3 group rather than asn (generalise)
for host in advertise_hosts if host.is_router and host.asn == server.asn)
rev_entry_list = list(
(ank.reverse_subnet(link.ip, advertise_block.prefixlen), self.interface_id(link.id), link.local_host.dns_hostname)
for link in advertise_links)
# Add loopbacks for routers
rev_entry_list += ( (ank.reverse_subnet(host.lo_ip.ip, advertise_block.prefixlen), self.lo_interface(0), host.dns_host_portion_only)
#TODO: make thise check l3 group rather than asn (generalise)
for host in advertise_hosts if host.is_router and host.asn == server.asn)
#TODO: provide better way to get eg eth0.host than string concat inside the template
host_cname_list = []
for host in advertise_hosts:
if host.asn != server.asn:
# host is from another asn, skip.
#TODO: extend this to make sure matches same asn, l3group and l2group
continue
if host.is_router:
# has lo_ip
cname = "%s.%s" % (self.lo_interface(), host.dns_host_portion_only)
else:
# choose an interface - arbitrary choice, choose first host link
interface = self.interface_id(ank.server_interface_id(host))
cname = "%s.%s" % (interface, host.dns_host_portion_only)
host_cname_list.append( (host.dns_host_portion_only, cname))
#Sort to make format nicer
host_cname_list = sorted(host_cname_list, key = lambda x: x[1])
for_entry_list = sorted(for_entry_list)
for_entry_list = sorted(for_entry_list, key = lambda x: x[1])
f_forward = open ( os.path.join(bind_dir(self.network, server), "db.%s" % server.domain), 'wb')
f_forward.write(forward_template.render(