Skip to content

Commit

Permalink
Deep merge when copying gateway attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jbemmel committed Dec 14, 2024
1 parent 63d8bd7 commit 4702a67
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion netsim/modules/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,10 @@ def link_pre_link_transform(self, link: Box, topology: Box) -> None:
vdata = intf_node.vlans[link_vlan]
for attr in topology.defaults.vlan.attributes.copy_vlan_to_intf: # else copy IP attributes
if attr in vdata:
intf[attr] = vdata[attr]
if not attr in intf: # ... have to do the deep merge manually as
intf[attr] = vdata[attr] # ... we cannot just replace interface data structure
elif isinstance(vdata[attr],Box) and isinstance(intf[attr],Box):
intf[attr] = vdata[attr] + intf[attr] # Sample case: gateway attribute (only one right now)

"""
We're almost done, but there's still some hard work to do:
Expand Down

0 comments on commit 4702a67

Please sign in to comment.