Skip to content

Commit 72edb1e

Browse files
committed
Fix: enable device-specific attributes regardless of lab devices
When we added device-specific attributes (eos.serialnumber), we enabled them only when the device was used in lab topology, making it impossible to use the same topology with other devices. This fix enables device-specific attributes regardless of what devices are used in the current incarnation of the lab topology, allowing you to specify device-specific data in generic topologies.
1 parent 9ae0aa2 commit 72edb1e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

netsim/augment/devices.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ def merge_daemons(topology: Box) -> None:
295295

296296
devices[dname].daemon_parent = devices[dname].parent # Save the parent for future use (it is removed when merging parent device data)
297297

298+
"""
299+
Add device-specific attributes
300+
"""
301+
def add_device_attributes(topology: Box) -> None:
302+
for dev_def in topology.defaults.devices.values(): # Iterate over all devices
303+
if 'attributes' in dev_def: # ... and add device specific attributes to the data model
304+
topology.defaults.attributes = topology.defaults.attributes + dev_def.attributes
305+
298306
"""
299307
Initial device setting augmentation:
300308
@@ -312,6 +320,7 @@ def augment_device_settings(topology: Box) -> None:
312320
log.fatal(f'Internal error: definition of device {dname} is not a dictionary')
313321

314322
merge_daemons(topology)
323+
add_device_attributes(topology)
315324
process_device_inheritance(topology)
316325
build_module_support_lists(topology)
317326

netsim/augment/nodes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ def find_node_device(n: Box, topology: Box) -> bool:
300300
for group in dev_def.features.get('group',[]):
301301
groups.add_node_to_group(n.name,group,topology)
302302

303-
if 'attributes' in dev_def: # Add any device specific attributes to the data model
304-
topology.defaults.attributes = topology.defaults.attributes + dev_def.attributes
305-
306303
return True
307304

308305
"""

0 commit comments

Comments
 (0)