|
| 1 | +# clab-io-draw |
| 2 | + |
| 3 | +The `clab-io-draw` project unifies two tools, `clab2drawio` and `drawio2clab`. These tools facilitate the conversion between [Containerlab](https://github.com/srl-labs/containerlab) YAML files and Draw.io diagrams, making it easier for network engineers and architects to visualize, document, and share their network topologies. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## clab2drawio |
| 8 | + |
| 9 | +`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. |
| 10 | + |
| 11 | +For detailed information on `clab2drawio`, including features, options, and usage instructions, please refer to the [clab2drawio.md](clab2drawio.md) file located in the same directory as this README. |
| 12 | + |
| 13 | +## drawio2clab |
| 14 | + |
| 15 | +`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. |
| 16 | + |
| 17 | +For more details on `drawio2clab`, including features, constraints for drawing, and how to run the tool, please see the [drawio2clab.md](drawio2clab.md) file in this directory. |
| 18 | + |
| 19 | +# Quick Usage |
| 20 | + |
| 21 | +## Running with Docker |
| 22 | +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. |
| 23 | + |
| 24 | +### Pulling from dockerhub |
| 25 | +```bash |
| 26 | +docker pull flosch62/clab-io-draw:latest |
| 27 | +``` |
| 28 | + |
| 29 | +### Building the Docker Image by yourself |
| 30 | + |
| 31 | +Navigate to the project directory and run: |
| 32 | + |
| 33 | +```bash |
| 34 | +docker build -t clab-io-draw . |
| 35 | +``` |
| 36 | +This command builds the Docker image of clab-io-draw with the tag clab-io-draw, using the Dockerfile located in the docker/ directory. |
| 37 | + |
| 38 | +### Running the Tools |
| 39 | +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: |
| 40 | +```bash |
| 41 | + docker run -e SCRIPT_NAME=clab2drawio.py -v "$(pwd)":/data flosch62/clab-io-draw -i /data/lab-examples/clos03/cfg-clos.clab.yml -o /data/output.drawio |
| 42 | +``` |
| 43 | +```bash |
| 44 | + docker run -e SCRIPT_NAME=drawio2clab.py -v "$(pwd)":/data flosch62/clab-io-draw -i /data/output.drawio -o /data/lab-examples/clos03/cfg-clos.clab.yml |
| 45 | +``` |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +## Running locally |
| 50 | + |
| 51 | +### Requirements |
| 52 | +- Python 3.6+ |
| 53 | + |
| 54 | +### Installation |
| 55 | + |
| 56 | +#### Virtual Environment Setup |
| 57 | + |
| 58 | +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: |
| 59 | + |
| 60 | +```bash |
| 61 | +python3 -m venv venv |
| 62 | +source venv/bin/activate |
| 63 | +``` |
| 64 | +#### Installing Dependencies |
| 65 | +After activating the virtual environment, install the required packages from the requirements.txt file: |
| 66 | +```bash |
| 67 | +pip install -r requirements.txt |
| 68 | +``` |
| 69 | + |
| 70 | +# Usage |
| 71 | + |
| 72 | +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. |
| 73 | + |
| 74 | +Detailed Usages: [drawio2clab.md](drawio2clab.md#usage) and [clab2drawio.md](drawio2clab.md#usage) |
| 75 | + |
| 76 | +## drawio2clab |
| 77 | + |
| 78 | +```bash |
| 79 | +python drawio2clab.py -i <input_file.drawio> -o <output_file.yaml> |
| 80 | +``` |
| 81 | +`-i, --input`: Specifies the path to your input .drawio file. |
| 82 | +`-o, --output`: Specifies the path for the output YAML file. |
| 83 | +Make sure to replace `<input_file.drawio>` with the path to your .drawio file and `<output_file.yaml>` with the desired output YAML file path. |
| 84 | + |
| 85 | +For more comprehensive guidance, including additional command-line options, please see the Usage section in [drawio2clab.md](drawio2clab.md#usage) |
| 86 | + |
| 87 | + |
| 88 | +## clab2drawio |
| 89 | + |
| 90 | +```bash |
| 91 | +python clab2drawio.py -i <input_file.yaml> -o <output_file.drawio> |
| 92 | +``` |
| 93 | +`-i, --input`: Specifies the path to your input YAML file. |
| 94 | +`-o, --output`: Specifies the path for the output drawio file. |
| 95 | +Make sure to replace `<input_file.yaml>` with the path to your .drawio file and `<output_file.drawio>` with the desired output YAML file path. |
| 96 | + |
| 97 | +For more comprehensive guidance, including additional command-line options, please see the Usage section in [clab2drawio.md](clab2drawio.md#usage) |
0 commit comments