Commit 89696d6c authored by Simon Redman's avatar Simon Redman

Add helpers to start/stop frr

parent 216af09b
......@@ -46,6 +46,7 @@ ZEBRA_CONF_TEMPLATE = """#
#
hostname {hostname}
password zebra
enable password zebra
log file /var/log/frr/zebra.log
{interfaces}
......@@ -75,6 +76,9 @@ CONFIG_PUSH_COMMAND_TEMPLATE = "echo '{config}' | sudo tee {filename}"
ENABLE_DAEMON_COMMAND_TEMPLATE = "sudo sed -i 's/{daemon}=no/{daemon}=yes/' /etc/frr/daemons"
START_DAEMON_COMMAND = "sudo systemctl restart frr"
STOP_DAEMON_COMMAND = "sudo systemctl stop frr"
def build_ospf_conf_for_host(host, hostname, interfaces):
"""
......@@ -209,7 +213,29 @@ def configure_nodes(netgraph):
zebra_enable_commands.append(enable_command)
outputs = ssh_helper.run_commands_on_many_hosts(sessions, zebra_enable_commands)
pass
def start_frr_on_network(netgraph):
"""
Restart (or start) frr on all nodes in the network
:param netgraph: networkx graph representing the network
:return: None
"""
sessions = [session for session in map(lambda host : netgraph._node[host]['session'], netgraph.nodes)]
commands = [START_DAEMON_COMMAND for session in sessions]
ssh_helper.run_commands_on_many_hosts(sessions, commands)
def stop_frr_on_network(netgraph):
"""
Stop frr on all nodes in the network
:param netgraph: networkx graph representing the network
:return: None
"""
sessions = [session for session in map(lambda host : netgraph._node[host]['session'], netgraph.nodes)]
commands = [STOP_DAEMON_COMMAND for session in sessions]
ssh_helper.run_commands_on_many_hosts(sessions, commands)
if __name__ == "__main__":
......@@ -225,5 +251,6 @@ if __name__ == "__main__":
ssh_helper.network_graph_login(netgraph.graph, args.username)
configure_nodes(netgraph.graph)
start_frr_on_network(netgraph.graph)
ssh_helper.network_graph_logout(netgraph.graph)
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