Skip to content

Commit d06545b

Browse files
authored
Merge pull request #23 from srl-labs/refactor
Refactor
2 parents 3e11442 + deb61ff commit d06545b

File tree

155 files changed

+6280
-7382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+6280
-7382
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
venv/*
22
__pycache__
33
test/*
4-
launch.json
5-
lab-examples/**
4+
launch.json

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ COPY clab2drawio.py /app/
1010
COPY requirements.txt /app/
1111
COPY entrypoint.sh /app/
1212
COPY styles/ /app/styles/
13-
COPY lib/ /app/lib/
13+
COPY core/ /app/core/
14+
COPY cli/ /app/cli/
1415

1516
# Install any needed packages specified in requirements.txt
1617
RUN pip install --no-cache-dir -r /app/requirements.txt

README.md

+57-24
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,51 @@
22

33
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.
44

5-
![Drawio Example](docs/img/modern_dark.png)
5+
<p align="center">
6+
<img src="./docs/img/st.clab.drawio.svg" alt="Drawio Example">
7+
</p>
68

7-
## clab2drawio
89

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.
1010

11-
For detailed information on `clab2drawio`, including features (like [`Grafana`](docs/grafana.md) Dashboard creation), options, and usage instructions, please refer to the [clab2drawio.md](docs/clab2drawio.md) file located in the same directory as this README.
11+
## Overview
12+
13+
| Tool | Description |
14+
| :-----------: | :------------------------------------------------------------------------------------------------: |
15+
| **clab2drawio** | Converts Containerlab YAML files into Draw.io diagrams (with optional [Grafana](docs/grafana.md) support). |
16+
| **drawio2clab** | Converts Draw.io diagrams back into Containerlab-compatible YAML files, supporting quick lab setup.|
1217

13-
## drawio2clab
1418

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.
19+
> [!NOTE]
20+
> For detailed information on `clab2drawio`, options, and usage instructions, please refer to the [clab2drawio.md](docs/clab2drawio.md)
21+
22+
> [!NOTE]
23+
> For more details on `drawio2clab`, including features, constraints for drawing, and how to run the tool, please see the [drawio2clab.md](docs/drawio2clab.md)
1624
17-
For more details on `drawio2clab`, including features, constraints for drawing, and how to run the tool, please see the [drawio2clab.md](docs/drawio2clab.md) file in this directory.
1825

1926
## Quick Usage
2027

2128
### Running with Containerlab
2229
```bash
23-
containerlab graph --drawio -t topo.yml
24-
containerlab graph --drawio -t topo.drawio
30+
containerlab graph --drawio -t topo.clab.yml
31+
containerlab graph --drawio -t topo.clab.drawio
2532
```
2633

34+
> [!TIP]
35+
> The `containerlab graph --drawio` command simplifies your workflow by automatically detecting the input file type (`.yml` or `.drawio`) and running the appropriate script internally (`clab2drawio` or `drawio2clab`).
36+
>
37+
> You can also enhance your output by passing additional arguments. For example:
38+
> ~~~bash
39+
> sudo containerlab graph --drawio -t topo.clab.yml --drawio-args "--theme nokia_modern"
40+
> ~~~
41+
> This example applies the "nokia_modern" theme to your generated diagram.
42+
43+
2744
### Running with Docker
2845
29-
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.
46+
You can also use a Docker container for a quick start without installing Python and other dependencies locally.
3047
31-
#### Pulling from dockerhub
48+
49+
#### Pulling from Container registry
3250
3351
```bash
3452
docker pull ghcr.io/srl-labs/clab-io-draw:latest
@@ -39,27 +57,31 @@ docker pull ghcr.io/srl-labs/clab-io-draw:latest
3957
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:
4058
4159
```bash
42-
docker run -it -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i lab-examples/clos03/cfg-clos.clab.yml
60+
docker run -it -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i lab-examples/br01.clab.yml
4361
```
44-
*Note: The `-it` option is for interactive mode and is only needed if using `-I`.*
62+
> [!NOTE]
63+
> The `-it` option is used for interactive mode (`-I`).
64+
> If you do not need interactive prompts, you can omit `-it`.
4565
4666
```bash
4767
docker run -v "$(pwd)":/data ghcr.io/srl-labs/clab-io-draw -i output.drawio
4868
```
4969
50-
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.
70+
Replace `your_input_file.drawio` or `your_output_file.yaml` with the
71+
actual file names in your environment.
5172
5273
## Running locally
5374
54-
### Requirements
55-
56-
- Python 3.6+
75+
> [!IMPORTANT]
76+
> Python 3.6+ is required if you prefer running these tools locally.
5777
5878
### Installation
5979
6080
#### Virtual Environment Setup
6181
62-
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:
82+
> [!TIP]
83+
> Using a virtual environment is recommended to avoid version conflicts
84+
> with global Python packages.
6385
6486
```bash
6587
python3 -m venv venv
@@ -86,18 +108,29 @@ Detailed Usages: [drawio2clab.md](docs/drawio2clab.md#usage) and [clab2drawio.md
86108
python drawio2clab.py -i <input_file.drawio>
87109
```
88110
89-
`-i, --input`: Specifies the path to your input .drawio file.
90-
Make sure to replace `<input_file.drawio>` with the path to your .drawio file
111+
- `-i, --input`: path to your `.drawio` file.
112+
- `-o, --output`: path to your output `.yaml` file (optional).
91113
92-
For more comprehensive guidance, including additional command-line options, please see the Usage section in [drawio2clab.md](docs/drawio2clab.md#usage)
114+
> [!NOTE]
115+
> For more details on node-label constraints, usage examples, and additional
116+
> command-line options, refer to
117+
> [drawio2clab.md](docs/drawio2clab.md#usage).
93118
94119
## clab2drawio
95120
96121
```bash
97122
python clab2drawio.py -i <input_file.yaml>
98123
```
99124
100-
`-i, --input`: Specifies the path to your input YAML file.
101-
Make sure to replace `<input_file.yaml>` with the path to your .drawio file
125+
- `-i, --input`: path to your Containerlab YAML file.
126+
- `-o, --output`: path to your output `.drawio` file (optional).
127+
128+
> [!NOTE]
129+
> For advanced functionality—like
130+
> [Grafana Dashboard](docs/grafana.md) generation (`-g, --gf_dashboard`),interactive mode (`-I`), layout customizations, or theming (`--theme`) refer to [clab2drawio.md](docs/clab2drawio.md#usage).
131+
132+
## Contributions & Feedback
133+
134+
All feedback and contributions are welcome! If you have suggestions, please open an issue or pull request on the GitHub repository.
102135
103-
For more comprehensive guidance, including additional command-line options, please see the Usage section in [clab2drawio.md](docs/clab2drawio.md#usage)
136+
---

0 commit comments

Comments
 (0)