Open jessica19921 opened 5 years ago
Try using jinja2 with python, in jinja2 you can create a template
Here's an example I'm using, still work in progress:
#1:48
diagram:
fill: "#ffffff"
columns: 8
rows: 7
gridLines: False
title:
color: lightgrey
heightPercentage: 5
logoFill: lightgrey
logoUrl: http://your-logo-url-here.png
stroke: lightgrey
company: YourCompany
subText: "Confidential and Proprietary"
author: {{ username }}
text: "{{ cores[0][0:5] }} Initial Diagram - Physical"
type: "bar"
defaults: &defaults
color: "white"
fill: "#555555"
iconFamily: "cisco"
cisco: &cisco
stroke: "none"
color: "black"
iconFamily: "cisco"
fill: "none"
preserveWhite: "true"
cores: &cores
<<: *cisco
x: "+3"
icon: "layer3switch"
textLocation: "topMiddle"
lanswitch: &lanswitch
<<: *cisco
x: "+1"
icon: "workgroupswitch"
textLocation: "bottomMiddle"
icons:
{# position the first core #}
{{ cores[0] }}: {<<: *cores, x: 2, y: 6}
{# Second core will follow a x+3 position #}
{% for items in cores[1:] %}
{{ items }}: {<<: *cores }
{% endfor %}
{# Position the first lan switch statically #}
{{ lans [0] }}: {<<: *lanswitch, x: 0, y: 4}
{# Rest of LAN switches will follow x+1 position #}
{% for x in lans[1:] %}
{{ x }}: {<<: *lanswitch }
{% endfor %}
{# group: &group
fill: "none"
color: darkslategray
stroke: lightgrey
groups:
cores_sw: { <<: *group, textLocation: leftMiddle, name: CORE, members: {{ cores }} }
lan_sw: { <<: *group, textLocation: leftMiddle, name: LAN, members: {{ lans }} } #}
connectionDefaults: &connectionDefaults
color: "black"
stroke: "black"
strokeDashArray: "10,5"
connectionCore2: &connectionCore2
color: "red"
stroke: "black"
strokeDashArray: "10,5"
connections:
{# Connect two cores together on port 1 #}
- { <<: *connectionDefaults, endpoints: [{% for core in cores %} {{ core + ":Port1"}}, {% endfor %}]}
{% for lan in lans %}
{# Loop through all lan switches[from port 1], start at 5 - note loop.index +4 means that it will start at Port5
meaning connect all Lan switches to Core Switch1 - starting on port 5, ports 1-4 are used for fireawlls/mgmt #}
- {<<: *connectionDefaults, endpoints: [ {{ lan }}:Port1, {{ cores[0] }}:Port{{ loop.index + 4}}]}
{# Connect all LAN switches[from port 2] to Core Switch2 port 5+ #}
- {<<: *connectionCore2, endpoints: [ {{ lan }}:Port2, {{ cores[1] }}:Port{{ loop.index + 4}}]}
{% endfor %}
# {# - { <<: *connectionDefaults, endpoints: [cores_sw:any,lan_sw:any] } #}```
Basically you can use python to run through your devices and do show cdp neighbors, you can use a parser like txtfsm from 'ntc-templates' and then just pass those neighbors as variables to your jinja2 template.
First of all, thank you to the creator for making such an awesome tool for the community (just brilliant).
I am sorry that I have opened this ticket as the issue, but it's not an issue, I am looking for help (maybe someone can change the category as I am new to GitHub).
I have read the readme section in the github and I understand that to draw the diagram I have to write the lines in dot(graphiz format) for the tool to draw the topology.
Here is what I was trying to do, I have a network of 100 odd cisco devices, so I was thinking of doing SNMP walk and write a script that will do show cdp neighbor and then give me an output which will have .csv or .txt file, that will give me the following information
example
Parent Device Name Parent Device Port No. Child Device Name Child Device Port No. Cisco SW Gi 0/1 Cisco Router Gi 0/2
so imagine this list will have 1000 of entries due to the number of devices.
so is there a way that I can convert or make these lines in below format as shown in the editor of http://go.drawthe.net/
example wwrt001: &wwrt001 {<<: cisco, icon: "router"} wwrt002: &wwrt002 {<<: cisco, x: "+1", icon: "router"} wwrt003: &wwrt003 {<<: *cisco, x: "-1", y: "+1", icon: "nexus5000"}
I hope someone can help me to understand how I can convert the output which I have collected from the devices ( and sorted out in tabular format), I would like to convert this .csv/.txt or any file in the format that I can past on drawthe.net tool to make the topologies
Any help and guidance will be highly appreciated.
Many thanks in advance.
Jessica B