Page MenuHomeVyOS Platform

XML: Python default dictionary returns wrong dictionary level(s)
Closed, ResolvedPublicBUG


While working on T2653 and transforming the MACsec interface into a get_config_dict() approach it was noticed that the default dictionary does not obey the given XML levels.

We have a default priority for the MACsec key agreement protocol of 255, when adding this into the XML and querying the result the level is not taken into account

diff --git c/interface-definitions/ i/interface-definitions/
index 36605ab5..dfef387d 100644
--- c/interface-definitions/
+++ i/interface-definitions/
@@ -83,6 +83,7 @@
                         <validator name="numeric" argument="--range 0-255" />
+                    <defaultValue>255</defaultValue>
>>> from vyos.xml import defaults
>>> from pprint import pprint
>>> base = ['interfaces', 'macsec']
>>> pprint(defaults(base))
{'security_mka_priority': '255'}

I'd rather expect the following dictionary representing the same level as get_config_dict():
{'security': {'mka': {'priority': '255'}}}


Difficulty level
Unknown (require assessment)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Behavior change
Issue type
Internal change (not visible to end users)

Event Timeline

c-po triaged this task as High priority.
c-po created this task.

@cpo, you can change the defaults from True to False in the patch if this is what you want to do.


>>> pprint(defaults(base, flat=False))
{'security': {'mka': {'priority': '255'}}}

We should make this a default option, not much functions using it and also it makes no sense to be to use the "flattened" dict as it can't be merged with a dict from `get_config_dict()

(15:07) cpo lnx01:~/vyos-1x [current] # git grep "vyos.xml" src/
src/conf_mode/ vyos.xml import defaults
src/conf_mode/ vyos.xml import defaults
src/conf_mode/ vyos.xml import defaults
erkin set Issue type to Internal change (not visible to end users).Aug 29 2021, 2:01 PM
erkin removed a subscriber: Active contributors.