Commit 8b9c2aa2 authored by Simon Redman's avatar Simon Redman

Configure and enable ospf6d on all nodes

parent 95387b9a
......@@ -51,6 +51,11 @@ INTERFACE_LINE_TEMPLATE = "interface {interface}"
# One of these per interface should be put in the router_info section
ROUTER_LINE_TEMPLATE = "\tarea range {range}\n\tinterface {interface} area"
OSPF_CONF_FILENAME = "/etc/frr/ospf6d.conf"
CONFIG_PUSH_COMMAND_TEMPLATE = "sudo echo '{config}' > {filename}"
ENABLE_DAEMON_COMMAND_TEMPLATE = "sudo sed -i 's/{daemon}=no/{daemon}=yes/' /etc/frr/daemons"
def build_ospf_conf_for_host(host, hostname, interfaces):
......@@ -87,6 +92,57 @@ def build_ospf_conf_for_host(host, hostname, interfaces):
return config
def build_ospf_confs_for_network(netgraph):
Build the ospf6d conf file for all nodes in the network
:param netgraph: networkx graph
:return: mapping of hosts to configurations
ospf_confs = {}
for host in netgraph.nodes:
interfaces = netgraph._node[host]['interfaces']
hostname = netgraph._node[host]['label']
ospf_confs[host] = (build_ospf_conf_for_host(ipaddress.ip_address(host), hostname, interfaces))
return ospf_confs
def configure_nodes(netgraph):
Create ospf6d and zebra conf files, push them to the relevant nodes, and enable the daemons
:param netgraph: networkx graph object representing the network
:return: None
sessions = []
ospf_push_commands = []
ospf_enable_commands = []
hosts = [host for host in netgraph.nodes]
ospf_confs = build_ospf_confs_for_network(netgraph)
for host in hosts:
push_command = CONFIG_PUSH_COMMAND_TEMPLATE.format(
ssh_helper.run_commands_on_many_hosts(sessions, ospf_push_commands)
# Enable ospf6d
for host in hosts:
enable_command = ENABLE_DAEMON_COMMAND_TEMPLATE.format(
ssh_helper.run_commands_on_many_hosts(sessions, ospf_enable_commands)
if __name__ == "__main__":
parser = argparse.ArgumentParser("Configure Free Range Routing's OSPFv6 and Zebra for all nodes in the network")
parser.add_argument("--in-file", action='store', type=str, required=True,
......@@ -99,5 +155,6 @@ if __name__ == "__main__":
netgraph = NetJsonParser(file=args.in_file)
ssh_helper.network_graph_login(netgraph.graph, args.username)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment