Skip to content

Commit ce68f32

Browse files
committed
Refactor Graphviz graph generation to use shared graph data
* Implements ideas from #2535 and #2547 for Graphviz graphs * Adds generic 'object style' mechanism that replaces old 'colors' and 'margins' settings * Corrects #2534 for Graphviz
1 parent 0683329 commit ce68f32

File tree

6 files changed

+285
-177
lines changed

6 files changed

+285
-177
lines changed

docs/outputs/graph.md

Lines changed: 77 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,90 @@ A single formatting modifier can be used to specify the graph type:
1313

1414
## Modifying Graph Attributes
1515

16-
Graphing routines use **[default](topo-defaults)** topology settings to modify the generated DOT file's node- or link parameters. You can change these defaults.
16+
Graphing routines use **[default](topo-defaults)** topology settings to modify the generated DOT file's node- or link parameters. These defaults influence how your graphs look:
1717

18+
* **outputs.graph.as_clusters** (default: *True*) -- use BGP AS numbers to create graph clusters
19+
* **outputs.graph.groups** -- use the specified list of groups (or all groups when set to *True*) to create graph clusters
1820
* **outputs.graph.interface_labels** -- Add IP addresses to links in **topology** graph. Results in a cluttered image (but feel free to fix that and submit a pull request).
21+
* **outputs.graphs.node_address_label** (default: *True*) -- add node loopback IP addresses or IP addresses of the first interface (for hosts) to node labels.
22+
* **outputs.graph.rr_sessions** (default: *False*) -- draw IBGP sessions between BGP route reflectors and clients as directional connections.
23+
24+
You can also change the formatting of individual graph objects with the **outputs.styles._object_** defaults:
25+
26+
| Object | Description |
27+
|--------|-------------|
28+
| graph | Generic graph formatting |
29+
| node | Device formatting |
30+
| edge | Link formatting |
31+
| as | Autonomous system/group container formatting |
32+
| stub | Subnet formatting
33+
| ibgp | IBGP session formatting |
34+
| ebgp | IBGP session formatting |
35+
36+
Each **styles** parameter is a dictionary of *Graphviz* attributes and their values (see the following printout for an example).
37+
38+
You can also change graph colors and margins with old-style defaults:
39+
1940
* **outputs.graph.colors._object_** -- Specify background color for *as*, *node*, *stub* subnet, *ibgp* or *ebgp* session.
2041
* **outputs.graph.margins.as** -- Inner margin for graph clusters (BGP autonomous system or groups).
21-
* **outputs.graph.groups** -- use the specified list of groups (or all groups when set to *True*) to create graph clusters
22-
* **outputs.graphs.node_address_labels** -- add node loopback IP addresses or IP addresses of the first interface (for hosts) to node labels.
2342

24-
You could specify these attributes in your [topology file](defaults-topology) (where you would have to prefix them with **defaults**), in [per-user topology defaults](defaults-user-file), or with [environment variables](defaults-env) (even [more details](../defaults.md)). You could also specify them with the `-s` parameter of the **[netlab create](netlab-create)** command, yet again prefixed with **defaults** ([more details](netlab-create-set)).
43+
You could specify the graph defaults in your [topology file](defaults-topology) (where you would have to prefix them with **defaults**), in [per-user topology defaults](defaults-user-file), or with [environment variables](defaults-env) (even [more details](../defaults.md)). You could also specify them with the `-s` parameter of the **[netlab create](netlab-create)** command, yet again prefixed with **defaults** ([more details](netlab-create-set)).
2544

26-
The system defaults in *netlab* release 1.9.1 are included below; you can always inspect them with **netlab show defaults outputs.graph**
45+
The system defaults in *netlab* release 25.09 are included below; you can always inspect them with **netlab show defaults outputs.graph**
2746

2847
```
29-
outputs:
48+
% netlab show defaults outputs.graph
49+
50+
netlab default settings within the outputs.graph subtree
51+
=============================================================================
52+
53+
as_clusters: true
54+
attributes:
55+
link:
56+
_keys:
57+
linkorder:
58+
max_value: 200
59+
min_value: 1
60+
type: int
61+
type:
62+
type: str
63+
valid_values:
64+
- lan
65+
type: dict
66+
shared:
67+
- linkorder
68+
interface_labels: false
69+
node_address_label: true
70+
styles:
71+
as:
72+
bgcolor: '#e8e8e8'
73+
color: '#c0c0c0'
74+
fontname: Verdana
75+
margin: 16
76+
ebgp:
77+
color: '#b21a1a'
78+
penwidth: 2
79+
edge:
80+
fontname: Verdana
81+
labeldistance: 1.5
82+
labelfontsize: 8
3083
graph:
31-
interface_labels: False
32-
node_address_label: True
33-
as_clusters: True
34-
colors:
35-
as: "#e8e8e8"
36-
node: "#ff9f01"
37-
stub: "#d1bfab"
38-
ibgp: "#613913"
39-
ebgp: "#b21a1a"
40-
margins:
41-
as: 16
84+
bgcolor: transparent
85+
nodesep: 0.5
86+
ranksep: 1
87+
ibgp:
88+
color: '#613913'
89+
penwidth: 2
90+
node:
91+
bgcolor: '#ff9f01'
92+
fillcolor: '#ff9f01'
93+
fontname: Verdana
94+
margin: 0.3,0.1
95+
shape: box
96+
style: rounded,filled
97+
stub:
98+
bgcolor: '#d1bfab'
99+
fillcolor: '#d1bfab'
100+
fontsize: 11
101+
margin: 0.3,0.1
42102
```

0 commit comments

Comments
 (0)