diff --git a/topologie/templates/topologie/graph_switch.dot b/topologie/templates/topologie/graph_switch.dot index c9dcaed3..6ca2b65b 100644 --- a/topologie/templates/topologie/graph_switch.dot +++ b/topologie/templates/topologie/graph_switch.dot @@ -11,6 +11,13 @@ edge[arrowhead=odot,arrowtail=dot] {% for sub in subs %} subgraph cluster_{{ sub.bat_id }} { label="Batiment {{ sub.bat_name }}"; + +{% block bornes %} +{% for borne in sub.bornes %} +node[label="{{borne.name}}"] {{borne.id}}; +{% endfor %} +{% endblock %} + {% block switchs %} {% for switch in sub.switchs %} node [label=< diff --git a/topologie/views.py b/topologie/views.py index c981fc94..ff6d65a1 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -944,21 +944,31 @@ def make_machine_graph(): """ Crée le fichier dot et l'image du graph des Switchs """ - dico={'subs':[],'links':[],'alone':[]} + dico={'subs':[],'links':[],'alone':[],'bornes':[]} missing=[] detected=[] for sw in Switch.objects.all(): if(sw not in detected): missing.append(sw) + for building in Building.objects.all():#Parcour tous les batiments - dico['subs'].append({'bat_id':building.id,'bat_name':building,'switchs':[]}) + + dico['subs'].append({'bat_id':building.id,'bat_name':building,'switchs':[],'bornes':[]}) + + for switch in Switch.objects.filter(switchbay__building=building):#Parcour tous les switchs de ce batiment dico['subs'][-1]['switchs'].append({'name':switch.main_interface().domain.name,'nombre':switch.number,'model':switch.model,'id':switch.id,'batiment':building,'ports':[]}) - - for p in switch.ports.all().filter(related__isnull=False):#Parcour tout les ports liés de ce switch dico['subs'][-1]['switchs'][-1]['ports'].append({'numero':p.port,'related':p.related.switch.main_interface().domain.name}) + + for ap in AccessPoint.all_ap_in(building): + dico['subs'][-1]['bornes'].append({'name':ap.short_name,'id':ap.id}) + dico['links'].append({'depart':ap.switch()[0].id,'arrive':ap.id}) + + + for ap in AccessPoint.objects.all(): + dico['bornes'].append({'name':str(ap)}) while(missing!=[]):#Tant que la liste des oubliés n'est pas vide i.e on les a pas tous passer links,new_detected=recursive_switchs(missing[0].ports.all().filter(related=None).first(),None,[missing[0]]) for link in links: @@ -1017,5 +1027,6 @@ def recursive_switchs(port_start, switch_before, detected): if(link!=[]): links_return.append(link) + return (links_return, detected)