Skip to content

Commit 4d4e0c0

Browse files
committed
Fix: device-specific attributes like ios.debug can be global
When a device-specific is defined as a global attribute, it has to be applied to every device in the lab topology (similar to what we're doing with the propagated module settings). This fix implements the simple merge-from-global behavior. I had to change the parameters of the 'augment_node_device_data' function because it needs access to topology data.
1 parent 423f69b commit 4d4e0c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

netsim/augment/nodes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ def augment_node_system_data(topology: Box) -> None:
419419
augment_node_device_data: copy attributes that happen to be node attributes from device defaults into node data
420420
"""
421421

422-
def augment_node_device_data(n: Box, defaults: Box) -> None:
422+
def augment_node_device_data(n: Box, topology: Box) -> None:
423+
defaults = topology.defaults
423424
node_attr = defaults.attributes.get('node',[])
424425
dev_data = devices.get_consolidated_device_data(n,defaults)
425426

@@ -432,6 +433,9 @@ def augment_node_device_data(n: Box, defaults: Box) -> None:
432433
if not k in n:
433434
n[k] = defaults.devices[n.device].node[k]
434435

436+
if n.device in topology: # Do we have global device-specific settings?
437+
n[n.device] = topology[n.device] + n[n.device]
438+
435439
if dev_data.get('daemon',False): # Special handling of daemons
436440
n._daemon = True # First, set the daemon flag so we don't have to look up the device data
437441
n._daemon_parent = dev_data.daemon_parent # Next, remember the parent device -- we need that in template search paths
@@ -485,7 +489,7 @@ def transform(topology: Box, defaults: Box, pools: Box) -> None:
485489
log.fatal(f"Internal error: node does not have a name {n}",'nodes')
486490
return
487491

488-
augment_node_device_data(n,defaults)
492+
augment_node_device_data(n,topology)
489493

490494
n.af = {} # Nodes must have AF attribute
491495

0 commit comments

Comments
 (0)