Skip to content

Commit dbfadf2

Browse files
committed
Fix: load plugins before initializing device data
Plugins were loaded after the device data inheritance has already been processed, forcing us to declare device features for every child device in device families like junos/ios. This "simple" change in initialization sequence loads plugins (and their default settings) before the device features are inherited, making it easy to specify a single feature entry covering the whole family of devices. Please note that this change also requires daemon features to be defined under 'daemons' not 'devices' (the 'daemons' parameters are copied into 'devices' parameters during device initialization)
1 parent c99b479 commit dbfadf2

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

netsim/augment/main.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,37 @@
1515
from . import addressing
1616
from .. import roles
1717

18+
"""
19+
Initializing the topology transformation:
20+
21+
* The global variables (stored in topology defaults) are initialized
22+
* The attribute lists are adjusted
23+
* The search paths are expanded into absolute paths and pruned
24+
* Plugins are loaded
25+
* Device settings are initialized, including daemon- and child device
26+
inheritance
27+
28+
Note that the plugins have to be loaded before the device settings are
29+
inherited, or we cannot specify the new features for generic devices.
30+
"""
1831
def topology_init(topology: Box) -> None:
1932
global_vars.init(topology)
2033
augment.config.attributes(topology)
2134
augment.config.paths(topology)
35+
augment.plugin.init(topology)
2236
augment.devices.augment_device_settings(topology)
2337

2438
def transform_setup(topology: Box) -> None:
25-
topology_init(topology)
26-
augment.topology.topology_sanity_check(topology)
27-
versioning.check_topology_version(topology)
39+
topology_init(topology) # Initialize variables, load plugins
40+
augment.topology.topology_sanity_check(topology) # Do the basic sanity check
41+
versioning.check_topology_version(topology) # Check topology/netlab version mismatch
2842
topology.nodes = augment.nodes.create_node_dict(topology.nodes)
29-
augment.groups.precheck_groups(topology)
30-
augment.plugin.init(topology) # Initialize plugins very early on in case they modify extra attributes
31-
roles.init(topology) # Initialize node roles
32-
augment.plugin.execute('topology_expand',topology) # topology-expanding plugins must be called before link checks
43+
augment.groups.precheck_groups(topology) # Do basic sanity checks on groups
44+
roles.init(topology) # Initialize node roles
45+
augment.plugin.execute('topology_expand',topology) # Topology-expanding plugins must be called before link checks
3346

3447
if 'links' in topology:
35-
augment.links.links_init(topology)
48+
augment.links.links_init(topology) # Rewrite links into canonical form
3649

3750
log.exit_on_error()
3851

netsim/extra/bgp.session/defaults.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# bgp.session default settings -- mostly attributes
22
#
33
---
4-
devices:
4+
daemons:
55
bird:
66
daemon_config:
77
bgp@session: /etc/bird/bgp.session.conf
@@ -15,6 +15,7 @@ devices:
1515
rs: True
1616
rs_client: True
1717
timers: True
18+
devices:
1819
dellos10.features.bgp:
1920
allowas_in: True
2021
bfd: True

0 commit comments

Comments
 (0)