8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Merge branch 'graph_topo' into 'master'

suppression des doubles liens

See merge request federez/re2o!168
This commit is contained in:
chirac 2018-05-30 22:15:22 +02:00
commit 2703cb94ba
2 changed files with 13 additions and 11 deletions

View file

@ -1,5 +1,5 @@
{% block graph_dot %} {% block graph_dot %}
strict digraph { digraph {
graph [label="TOPOLOGIE DU RÉSEAU", labelloc=t, fontsize=40]; graph [label="TOPOLOGIE DU RÉSEAU", labelloc=t, fontsize=40];
node [fontname=Helvetica fontsize=8 shape=plaintext]; node [fontname=Helvetica fontsize=8 shape=plaintext];
edge[arrowhead=none]; edge[arrowhead=none];
@ -132,4 +132,4 @@ node [label=<
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
} }
{% endblock %} {% endblock %}

View file

@ -1033,7 +1033,7 @@ def make_machine_graph():
dico['alone'].append({ dico['alone'].append({
'id': switch.id, 'id': switch.id,
'name': switch.main_interface().domain.name 'name': switch.main_interface().domain.name
}) })
dot_data=generate_dot(dico,'topologie/graph_switch.dot') # generate the dot file dot_data=generate_dot(dico,'topologie/graph_switch.dot') # generate the dot file
@ -1071,19 +1071,21 @@ def recursive_switchs(switch_start, switch_before, detected):
:param switch_before: the switch that you come from. None if switch_start is the first one :param switch_before: the switch that you come from. None if switch_start is the first one
:param detected: list of all switchs already visited. None if switch_start is the first one :param detected: list of all switchs already visited. None if switch_start is the first one
:return: A list of all the links found and a list of all the switchs visited""" :return: A list of all the links found and a list of all the switchs visited"""
detected.append(switch_start)
links_return=[] # list of dictionaries of the links to be detected links_return=[] # list of dictionaries of the links to be detected
for port in switch_start.ports.filter(related__isnull=False): # Ports that are related to another switch for port in switch_start.ports.filter(related__isnull=False): # create links to every switchs below
if port.related.switch != switch_before and port.related.switch != port.switch: # Not the switch that we come from, not the current switch if port.related.switch != switch_before and port.related.switch != port.switch and port.related.switch not in detected: # Not the switch that we come from, not the current switch
links = { # Dictionary of a link links = { # Dictionary of a link
'depart':switch_start.id, 'depart':switch_start.id,
'arrive':port.related.switch.id 'arrive':port.related.switch.id
} }
if port.related.switch not in detected: # The switch at the end of this link has not been visited
links_down, detected = recursive_switchs(port.related.switch, switch_start, detected) # explore it and get the results
for link in links_down: # Add the non empty links to the current list
if link:
links_return.append(link)
links_return.append(links) # Add current and below levels links links_return.append(links) # Add current and below levels links
detected.append(switch_start) # This switch is considered detected
for port in switch_start.ports.filter(related__isnull=False): # go down on every related switchs
if port.related.switch not in detected: # The switch at the end of this link has not been visited
links_down, detected = recursive_switchs(port.related.switch, switch_start, detected) # explore it and get the results
for link in links_down: # Add the non empty links to the current list
if link:
links_return.append(link)
return (links_return, detected) return (links_return, detected)