...
 
Commits (2)
......@@ -20,6 +20,7 @@
import add_routable_ipv6_addrs
import frr_configurator
import json
import ospf_sniffer_configurator
import ssh_helper
import sysctl_configurator
import topomap_parser
......@@ -85,6 +86,10 @@ if __name__ == "__main__":
sysctl_configurator.configure_nodes(netgraph.graph,ignore_nodes=ovs_nodes)
ospf_sniffer_configurator.clone_repo_on_network(netgraph.graph, ignore_nodes=ovs_nodes + host_nodes)
ospf_sniffer_configurator.stop_sniffer_on_network(netgraph.graph, ignore_nodes=ovs_nodes + host_nodes) # Stopping with the app not running is not great, but better than starting twice
ospf_sniffer_configurator.start_sniffer_on_network(netgraph.graph, ignore_nodes=ovs_nodes + host_nodes)
ssh_helper.network_graph_logout(netgraph.graph)
if args.netgraph_write:
......
......@@ -68,7 +68,7 @@ def _generate_start_command(path:str=DEFAULT_CLONE_PATH,
)
def _generate_stop_command(pidfile: str=DEFAULT_PIDFILE) -> str:
return "kill $(cat {pidfile})".format(pidfile=pidfile)
return "kill $(cat {pidfile}) && rm {pidfile}".format(pidfile=pidfile)
def clone_repo_on_network(graph: networkx.Graph,
......@@ -170,9 +170,20 @@ def stop_sniffer_on_network(graph: networkx.Graph,
hosts = [host for host in graph.nodes if host not in ignore_nodes]
sessions = [graph._node[host]['session'] for host in hosts]
commands = [_generate_stop_command(pidfile=pidfile)] * len(hosts)
command = _generate_stop_command(pidfile=pidfile)
commands = [command] * len(hosts)
output = ssh_helper.run_commands_on_many_hosts(sessions, commands)
try:
output = ssh_helper.run_commands_on_many_hosts(sessions, commands)
except ssh_helper.SSHCommandErrorError as e:
acceptable_error = r".*{command}\s+cat: {pidfile}: No such file or directory.*".format(command=re.escape(command), pidfile=re.escape(pidfile))
while e is not None:
output = str.join(' ', e.output.splitlines()) # Get rid of newlines
if re.match(acceptable_error, output):
# Presumably this is a sign of the stop command being run more than once or before the sniffer was started: no problem
e = e.next
continue
raise
pass
......