本文整理汇总了Python中AutoNetkit.default_route方法的典型用法代码示例。如果您正苦于以下问题:Python AutoNetkit.default_route方法的具体用法?Python AutoNetkit.default_route怎么用?Python AutoNetkit.default_route使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoNetkit
的用法示例。
在下文中一共展示了AutoNetkit.default_route方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_netkit
# 需要导入模块: import AutoNetkit [as 别名]
# 或者: from AutoNetkit import default_route [as 别名]
def configure_netkit(self):
"""Generates Netkit and Zebra/Quagga specific configuration files."""
# Sets up netkit related files
tap_host = ank.get_tap_host(self.network)
ank_version = pkg_resources.get_distribution("AutoNetkit").version
date = time.strftime("%Y-%m-%d %H:%M", time.localtime())
lab_template = lookup.get_template("netkit/lab.mako")
startup_template = lookup.get_template("netkit/startup.mako")
zebra_daemons_template = lookup.get_template(
"quagga/zebra_daemons.mako")
zebra_template = lookup.get_template("quagga/zebra.mako")
sshd_template = lookup.get_template("linux/sshd.mako")
motd_template = lookup.get_template("quagga/motd.mako")
# Shared (common) configuration
startup_daemon_list = []
#Setup ssh
shutil.copy(resource_filename("AutoNetkit","lib/shadow"), shared_etc_dir())
startup_daemon_list.append("ssh")
# Need to chown root dir for ssh keys
# refer http://list.dia.uniroma3.it/pipermail/netkit.users/2010-February/000552.html
use_ssh_key = False
if config.settings['Netkit']['ssh key']:
#chown root:root /root
use_ssh_key = True
f_startup = open( os.path.join(lab_dir(), "shared.startup"), 'wb')
f_startup.write(startup_template.render(
interfaces=[],
add_localhost=True,
#don't send out the tap interface
del_default_route=True,
daemons=startup_daemon_list,
use_ssh_key = use_ssh_key,
))
f_startup.close()
# Files for indvidual node configuration
#TODO: this needs to be created for each netkit host machine
f_lab = open(os.path.join(lab_dir(), "lab.conf"), 'wb')
lab_conf = {}
tap_list_strings = {}
ibgp_routers = ank.ibgp_routers(self.network)
ebgp_routers = ank.ebgp_routers(self.network)
igp_graph = ank.igp_graph(self.network)
dns_servers = set(self.network.dns_servers())
routers = set(self.network.routers())
for node in self.network.devices():
#TODO: see if rtr label is still needed, if so replace with
# appropriate naming module function
rtr_folder_name = ank.rtr_folder_name(self.network, node)
# sshd options
f_sshd = open( os.path.join(sshd_dir(self.network, node), "sshd_config"), 'wb')
f_sshd.write(sshd_template.render())
f_sshd.close()
lab_conf[rtr_folder_name] = []
startup_daemon_list = ["zebra"]
startup_int_list = []
# convert tap list from ips into strings
# tap_int_id cannot conflict with already allocated interfaces
# assume edges number sequentially, so next free int id is number of
# edges
node_tap_id = self.tap_interface_id(self.network, node)
tap_list_strings[rtr_folder_name] = (node_tap_id,
self.network[node].get('tap_ip'))
if node in dns_servers:
startup_daemon_list.append("bind")
dns_memory = 64 # Allocate more memory to DNS server
#TODO: remove key, val and make it just key: val
lab_conf[rtr_folder_name].append( ('mem', dns_memory))
if config.settings['Netkit']['ssh key']:
f_auth_keys = open(os.path.join(dot_ssh_dir(self.network, node), "authorized_keys"), "wb")
f_auth_keys.write(config.settings['Netkit']['ssh key'])
f_auth_keys.close()
# Zebra Daemons
zebra_daemon_list = []
f_zdaemons = open( os.path.join(zebra_dir(self.network, node),
"daemons"), 'wb')
# Always start Zebra
zebra_daemon_list.append("zebra")
if igp_graph.degree(node) > 0:
zebra_daemon_list.append("ospfd") # Only start IGP process if IGP links
if (node in ibgp_routers) or (node in ebgp_routers):
zebra_daemon_list.append("bgpd")
#.........这里部分代码省略.........