Code Monkey home page Code Monkey logo

clab-io-draw's Introduction

clab-io-draw

The clab-io-draw project unifies two tools, clab2drawio and drawio2clab. These tools facilitate the conversion between Containerlab YAML files and Draw.io diagrams, making it easier for network engineers and architects to visualize, document, and share their network topologies.

Drawio Example

clab2drawio

clab2drawio is a Python script that automatically generates Draw.io diagrams from Containerlab YAML configurations. It aims to simplify the visualization of network designs by providing a graphical representation of container-based network topologies.

For detailed information on clab2drawio, including features (like Grafana Dashboard creation), options, and usage instructions, please refer to the clab2drawio.md file located in the same directory as this README.

drawio2clab

drawio2clab is a Python script that converts Draw.io diagrams into Containerlab-compatible YAML files. This tool is designed to assist in the setup of container-based networking labs by parsing .drawio XML files and generating structured YAML representations of the network.

For more details on drawio2clab, including features, constraints for drawing, and how to run the tool, please see the drawio2clab.md file in this directory.

Quick Usage

Running with Containerlab

containerlab graph --drawio -t topo.yml
containerlab graph --drawio -t topo.drawio

Running with Docker

To simplify dependency management and execution, the tools can be run inside a Docker container. Follow these instructions to build and run the tool using Docker.

Pulling from dockerhub

docker pull ghcr.io/srl-labs/clab-io-draw:latest

Running the Tools

Run drawio2clab or clab2drawio within a Docker container by mounting the directory containing your .drawio/.yaml files as a volume. Specify the input and output file paths relative to the mounted volume:

docker run -it -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i lab-examples/clos03/cfg-clos.clab.yml

Note: The -it option is for interactive mode and is only needed if using -I.

docker run -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i output.drawio

Replace your_input_file.drawio and your_output_file.yaml with the names of your actual files. This command mounts your current directory to /data inside the container.

Running locally

Requirements

  • Python 3.6+

Installation

Virtual Environment Setup

It's recommended to use a virtual environment for Python projects. This isolates your project dependencies from the global Python environment. To set up and activate a virtual environment:

python3 -m venv venv
source venv/bin/activate  

Installing Dependencies

After activating the virtual environment, install the required packages from the requirements.txt file:

pip install -r requirements.txt

Usage

This section provides a brief overview on how to use the drawio2clab and clab2drawio tools. For detailed instructions, including command-line options and examples, please refer to the dedicated usage sections in their respective documentation files.

Detailed Usages: drawio2clab.md and clab2drawio.md

drawio2clab

python drawio2clab.py -i <input_file.drawio>

-i, --input: Specifies the path to your input .drawio file. Make sure to replace <input_file.drawio> with the path to your .drawio file

For more comprehensive guidance, including additional command-line options, please see the Usage section in drawio2clab.md

clab2drawio

python clab2drawio.py -i <input_file.yaml>

-i, --input: Specifies the path to your input YAML file. Make sure to replace <input_file.yaml> with the path to your .drawio file

For more comprehensive guidance, including additional command-line options, please see the Usage section in clab2drawio.md

clab-io-draw's People

Contributors

flosch62 avatar sacckth avatar hellt avatar toweber avatar

Stargazers

 avatar Sebastian Rieger avatar Severin Dellsperger avatar  avatar Rodrigo H Padilla avatar Mathis Bramkamp avatar Thomas Hendriks avatar  avatar Renato Westphal avatar  avatar Tiago Amado avatar  avatar Thomas Grimonet avatar  avatar Marlon Paz avatar

Watchers

 avatar  avatar Marlon Paz avatar

clab-io-draw's Issues

Automatic (precaned) grafana dashboards from drawio

Starting from a clab file, it would be coo. to have a tool (can be another python script) that generates the JSON grafana dashboard displaying some pre-caned things like the link speed on each of the ports.
Some things to take into account:

  • the metrics format is determined by the collector (e.g, gnmic and processors), so the key values need to be probably used as input parameters.
  • The metrics tags can also be changed in grafana and they need to be consistent for the flowcharts plugin to work
  • Goal is not to have a do it all tool, but rather a simple dashboard that can be further expanded and customized for every lab...

Link and its label IDs should have more meaningful names

A meaningful ID, would help to create grafana dashboards, with the flowchart plugin.

<mxCell id="6955bd28e4f532e5d3c134ab6a0aed99-trgt" value="e1-32" style="labelBackgroundColor=#ffffff;;" parent="6955bd28e4f532e5d3c134ab6a0aed99" vertex="1" connectable="0">

Label aligment is prevented

I noticed shape labels of generated drawio diagrams cannot be positioned (Top, bottom etc.) Labes don't follow position setting. I found out it is because of duplicate style attributes. There are many of those.

image

Suggestions for visual improvements

I got inspired by the work you guys are doing to visualize network topologies. As network diagrams has been my passion for years I would like to contribute to this project by trying to describe some ideas to make the project even better.

Here I'm mostly focusing on Leaf / Spine type of networks. Many of these techniques apply to other type of topologies as well.

I already started to implement the features I'm going to describe here, but soon realized my most valuable contribution might be to share ideas in detail.

Limitations of current implementation

Current implementation works well with small topologies like this:

image

However, when trying to add more leafs to visualize production grade topologies, it starts to fall apart:

image

Here interface names starts to overlap. Links starts to overlap in the Spine end as well. It becomes really hard to see exactly what is connected where. Also in these examples we are using really short version of interface names. If you want to have something like "Gi0/0/0/34" it starts to become even more mesh. In other words the implementation is lacking visual scalability features.

Luckily there are techniques we can leverage to make diagrams way more scalable.

Suggestion for improvements

Let's take last diagram with 12 leafs and make it better. What if diagram looks like this:

image

Routing links more scalable way

First improvement is to route links between devices more scalable way. It means links are links are orthogonal (simple) with curved corners. Links should also have line jump style as gap so that we don't confuse jumps and corners.

Spine interfaces (read = upper level device interfaces) are moved further down the cable to the place where they have more space.

All interface names are rotated. In this diagram style you can easily fit in longer interface names.

Note, link between Spine and leaf consists of four separate connectors. Here they are colored for sake of clarity:

image

We need four to be able to have these arrow connectors for Grafana to visualize traffic rates. If that is not needed three would be enough.

Placement of shapes in adjacent layers

One additional need when using style like this is to prevent devices on adjacent layers (we could have more than 2 layers) to be located too close to each other in x-axis. If this is not done link routing becomes mesh:

image

So some spacing is needed to prevent this happening.

Something else

Hmmm.. I just got idea we could have four arrows to be able to illustrate both in and out traffic rates:

image

One additional thing I usually do when drawing diagrams like this is to locate device label (hostnames etc.) like this:

image

It makes it even more scalable as you can place leafs way more near to each other. For some reason shapes the code generates don't follow text positioning features of drawio (top, bottom etc..). Would be nice to fix this as well.

Small details

  • No need to group interfaces with their device
  • No need to adjust traffic rate labels randomly (as in current implementation)

Any comments

What do you think? Would it be useful to have something like this? Any other practices which could be used to make diagrams better?

A smart entrypoint that detects the input type

@FloSch62 here is another ux improvement.
Instead of having the entrypoint.sh that calls a certain script that we require a user to pass as an env var, lets make a smart entrypoint (I presume a python one) that would check if the input file has a yml/yaml extension or a drawio or no extension.

In the first case it is clear that we need to use clab2draw

And in the 2nd one it is the work for draw2clab.

With this logic it is not anymore required for a user to juggle with the env var passed at runtime.

clab2drawio interactive mode

I think it would be helpful to have an interactive mode for the drawio generation. The graph-level and icon options are not needed for clab and I personally would like to keep them out of the clab file while still keeping this awesome feature of creating a drawio diagram. This mode could be optional by invoking the command with an "interactive" flag while the current mode can still be the default way to go.

I am thinking of an interactive menu where the user can choose the options on the fly after the clab file has been parsed.

Example
Parsing clab file... Found 8 nodes... Done.

DEFINE GRAPH LEVELS
Choose level 1 nodes:
[X] borderleaf1
[X] borderleaf2
[ ] spine1
[ ] spine2
[ ] leaf1
[ ] leaf2
[ ] host1
[ ] host2

OK!


Choose level 2 nodes:
[X] spine1
[X] spine2
[ ] leaf1
[ ] leaf2
[ ] host1
[ ] host2

OK!

Choose level 3 nodes:
[X] leaf1
[X] leaf2
[ ] host1
[ ] host2

OK!

Choose level 4 nodes:
[X] host1
[X] host2

OK!

No more nodes left. Done!

DEFINE GRAPH ICONS
Choose dcgw icon nodes:
[X] borderleaf1
[X] borderleaf2
[ ] spine1
[ ] spine2
[ ] leaf1
[ ] leaf2
[ ] host1
[ ] host2

OK!


Choose spine icon nodes:
[X] spine1
[X] spine2
[ ] leaf1
[ ] leaf2
[ ] host1
[ ] host2

OK!

Choose leaf icon nodes:
[X] leaf1
[X] leaf2
[ ] host1
[ ] host2

OK!

Choose server icon nodes:
[X] host1
[X] host2

OK!

No more nodes left. Done!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.