Commit 5bff8173 authored by Simon Redman's avatar Simon Redman

Unify interface to always want networkx graphs

parent 8464dcc4
......@@ -37,7 +37,7 @@ def parse_ipv4_networks(netgraph):
"""
For each ssh session, query the remote for its interfaces, then parse that for its IPv4 address
:param netgraph: topology map, annotated with logged-in ssh sessions
:param netgraph: networkx topology graph, annotated with logged-in ssh sessions
:return: mapping of hosts to map of interfaces to that interface's IPv6 interface address
"""
hosts = []
......@@ -45,11 +45,11 @@ def parse_ipv4_networks(netgraph):
commands = []
interface_map = {}
for host in netgraph.graph.nodes:
for host in netgraph.nodes:
interface_map[host] = {}
# Build an ordered list of hosts, sessions, and commands
hosts.append(host)
sessions.append(netgraph.graph._node[host]['session'])
sessions.append(netgraph._node[host]['session'])
commands.append(IPV4_COMMAND)
outputs = ssh_helper.run_commands_on_many_hosts(sessions, commands)
......@@ -77,7 +77,7 @@ def parse_local_interface_addresses(netgraph):
"""
For each ssh session, query the remote for its interfaces, then parse that for its IPv6 interface ID on each interface
:param netgraph: topology map, annotated with logged-in ssh sessions
:param netgraph: networkx topology graph, annotated with logged-in ssh sessions
:return: mapping of hosts to map of interfaces to that interface's IPv4 address
"""
hosts = []
......@@ -85,11 +85,11 @@ def parse_local_interface_addresses(netgraph):
commands = []
interface_map = {}
for host in netgraph.graph.nodes:
for host in netgraph.nodes:
interface_map[host] = {}
# Build an ordered list of hosts, sessions, and commands
hosts.append(host)
sessions.append(netgraph.graph._node[host]['session'])
sessions.append(netgraph._node[host]['session'])
commands.append(LINK_LOCAL_COMMAND)
outputs = ssh_helper.run_commands_on_many_hosts(sessions, commands)
......@@ -203,8 +203,8 @@ if __name__ == "__main__":
sessions, passwords = ssh_helper.log_in_many_sessions(hostnames, usernames)
for host_idx in range(len(hostnames)):
netgraph.graph._node[hostnames[host_idx]]['session'] = sessions[host_idx]
link_local_map = parse_local_interface_addresses(netgraph)
ipv4_map = parse_ipv4_networks(netgraph)
link_local_map = parse_local_interface_addresses(netgraph.graph)
ipv4_map = parse_ipv4_networks(netgraph.graph)
ULA_map = construct_ULAs(link_local_map, ipv4_map)
......
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