@@ -165,3 +165,122 @@ zot := localbin / "zot" + "-" + zot_os + "-" + zot_arch + "-" + zot_version
165
165
_ localreg : _zot
166
166
./ hack/ localreg.sh
167
167
{{ zot}} serve .zot/ config.json 2 >&1 | tee .zot/ log
168
+
169
+ #
170
+ # Generate diagrams for multiple environments in different formats and styles
171
+ #
172
+ test-diagram :
173
+ @ mkdir -p test-diagram
174
+ @ echo " ==============================================="
175
+ @ echo " Diagram generation test - various topologies, formats, and styles"
176
+ @ echo " ==============================================="
177
+
178
+ # Check if a VLAB is actually running
179
+ @ echo " === Checking for running VLAB ==="
180
+ @ VLAB_PIDS=$(pgrep -f " [h]hfab vlab up" 2 >/ dev/ null || echo " " ); \
181
+ if [ -n " $VLAB_PIDS" ] && [ -f " vlab/kubeconfig" ]; then \
182
+ echo " === Detected running VLAB, generating live diagrams ===" ; \
183
+ bin/ hhfab diagram --format drawio --style default --live --output test-diagram/ live-drawio-default.drawio || echo " Failed to generate live DrawIO diagram" ; \
184
+ bin/ hhfab diagram --format drawio --style cisco --live --output test-diagram/ live-drawio-cisco.drawio || echo " Failed to generate live DrawIO cisco diagram" ; \
185
+ bin/ hhfab diagram --format drawio --style hedgehog --live --output test-diagram/ live-drawio-hedgehog.drawio || echo " Failed to generate live DrawIO hedgehog diagram" ; \
186
+ bin/ hhfab diagram --format dot --live --output test-diagram/ live-dot.dot || echo " Failed to generate live DOT diagram" ; \
187
+ if command -v dot >/ dev/ null 2 >&1 && [ -f " test-diagram/live-dot.dot" ]; then \
188
+ dot -Tpng test-diagram/ live-dot.dot -o test-diagram/ live-dot.png; \
189
+ fi; \
190
+ bin/ hhfab diagram --format mermaid --live --output test-diagram/ live-mermaid.mermaid || echo " Failed to generate live Mermaid diagram" ; \
191
+ if [ -f " test-diagram/live-mermaid.mermaid" ]; then \
192
+ echo ' # Live Network Diagram' > test-diagram/ live-mermaid.md; \
193
+ echo ' ```mermaid' >> test-diagram/ live-mermaid.md; \
194
+ cat test-diagram/ live-mermaid.mermaid >> test-diagram/ live-mermaid.md; \
195
+ echo ' ```' >> test-diagram/ live-mermaid.md; \
196
+ fi; \
197
+ else \
198
+ echo " No running VLAB detected, skipping live diagrams" ; \
199
+ fi
200
+
201
+ @ echo -n " This will generate diagrams from multiple environments. Continue? [y/N] " && read ans && [ " $ans" = " y" -o " $ans" = " Y" ]
202
+
203
+ @ echo " === Generating diagrams for default VLAB topology ==="
204
+ bin/ hhfab init -f --dev --gw
205
+ bin/ hhfab vlab gen
206
+
207
+ # Generate all formats and styles for default topology
208
+ bin/ hhfab diagram --format drawio --style default --output test-diagram/ default-drawio-default.drawio
209
+ bin/ hhfab diagram --format drawio --style cisco --output test-diagram/ default-drawio-cisco.drawio
210
+ bin/ hhfab diagram --format drawio --style hedgehog --output test-diagram/ default-drawio-hedgehog.drawio
211
+ bin/ hhfab diagram --format dot --output test-diagram/ default-dot.dot
212
+ bin/ hhfab diagram --format mermaid --output test-diagram/ default-mermaid.mermaid
213
+
214
+ @ echo " === Generating diagrams for variant 3-spine topology ==="
215
+ bin/ hhfab vlab gen --spines-count 3 --mclag-leafs-count 2 --orphan-leafs-count 1 --eslag-leaf-groups 2
216
+
217
+ # Generate all formats and styles for 3-spine topology
218
+ bin/ hhfab diagram --format drawio --style default --output test-diagram/ 3 spine-drawio-default.drawio
219
+ bin/ hhfab diagram --format drawio --style cisco --output test-diagram/ 3 spine-drawio-cisco.drawio
220
+ bin/ hhfab diagram --format drawio --style hedgehog --output test-diagram/ 3 spine-drawio-hedgehog.drawio
221
+ bin/ hhfab diagram --format dot --output test-diagram/ 3 spine-dot.dot
222
+ bin/ hhfab diagram --format mermaid --output test-diagram/ 3 spine-mermaid.mermaid
223
+
224
+ # Convert DOT files to PNG if GraphViz is installed
225
+ @ echo " === Converting DOT files to PNG if GraphViz is installed ==="
226
+ @ if command -v dot >/ dev/ null 2 >&1 ; then \
227
+ for DOT_FILE in test-diagram/ *-dot.dot; do \
228
+ PNG_FILE=" ${DOT_FILE%.dot}.png" ; \
229
+ echo " Converting $DOT_FILE to $PNG_FILE" ; \
230
+ dot -Tpng " $DOT_FILE" -o " $PNG_FILE" ; \
231
+ done; \
232
+ else \
233
+ echo " GraphViz dot not installed, skipping PNG conversion" ; \
234
+ fi
235
+
236
+ # Create markdown files with embedded mermaid diagrams
237
+ @ echo " === Creating Markdown files with embedded Mermaid diagrams ==="
238
+ @ for MERMAID_FILE in test-diagram/ *-mermaid.mermaid; do \
239
+ MD_FILE=" ${MERMAID_FILE%.mermaid}.md" ; \
240
+ BASE_NAME=$(basename " $MERMAID_FILE" -mermaid.mermaid); \
241
+ echo " Creating $MD_FILE" ; \
242
+ echo " # $BASE_NAME Network Diagram" > " $MD_FILE" ; \
243
+ echo ' ```mermaid' >> " $MD_FILE" ; \
244
+ cat " $MERMAID_FILE" >> " $MD_FILE" ; \
245
+ echo ' ```' >> " $MD_FILE" ; \
246
+ done
247
+
248
+ @ echo " "
249
+ @ echo " All diagrams generated in test-diagram/ directory"
250
+ @ ls -la test-diagram/
251
+ @ echo " "
252
+ @ echo " Summary of generated files:"
253
+ @ echo " - Default VLAB topology: default-*"
254
+ @ echo " - 3-spine VLAB topology: 3spine-*"
255
+ @ echo " - Live diagrams (if VLAB running): live-*"
256
+ @ echo " "
257
+ @ echo " For each topology, these formats are available:"
258
+ @ echo " - DrawIO: *-drawio-{default,cisco,hedgehog}.drawio"
259
+ @ echo " - DOT: *-dot.dot (and PNG if GraphViz was installed)"
260
+ @ echo " - Mermaid: *-mermaid.mermaid (and embedded in markdown *.md)"
261
+
262
+ # Test lab-ci diagram
263
+ test-diagram-labci :
264
+ @ mkdir -p test-diagram
265
+ @ echo " ==============================================="
266
+ @ echo " Diagram generation test - lab-ci"
267
+ @ echo " ==============================================="
268
+
269
+ # Check if the lab-ci repo is available
270
+ @ if [ ! -d " lab-ci" ]; then \
271
+ echo " lab-ci repository not found. Please clone it:" ; \
272
+ echo " git clone https://github.com/githedgehog/lab-ci.git" ; \
273
+ exit 1 ; \
274
+ fi
275
+
276
+ @ echo " === Generating diagrams for lab-ci environment 1 ==="
277
+ bin/ hhfab init -f -c lab-ci/ envs/ env -ci-1.l/ hhfab.yaml -w lab-ci/ envs/ env -ci-1.l/ wiring-0-base .yaml -w lab-ci/ envs/ env -ci-1.l/ wiring-1-spine-leaf .yaml
278
+ bin/ hhfab diagram --format drawio --style default --output test-diagram/ labci1-drawio-default.drawio
279
+ bin/ hhfab diagram --format drawio --style cisco --output test-diagram/ labci1-drawio-cisco.drawio
280
+ bin/ hhfab diagram --format drawio --style hedgehog --output test-diagram/ labci1-drawio-hedgehog.drawio
281
+ bin/ hhfab diagram --format dot --output test-diagram/ labci1-dot.dot
282
+ bin/ hhfab diagram --format mermaid --output test-diagram/ labci1-mermaid.mermaid
283
+
284
+ @ echo " "
285
+ @ echo " All diagrams generated in test-diagram/ directory"
286
+ @ ls -la test-diagram/
0 commit comments