Page MenuHomeVyOS Platform

vyos.configdict.node_changed does not return keys per adding
Closed, ResolvedPublicBUG

Description

vyos.configdict.node_changed does not return keys per adding but only for deleting.

Check if a leaf node was altered. If it has been altered - values has been
changed, or it was added/removed, we will return the old value. If nothing
has been changed, None is returned

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.5-rolling-202312181606
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

This can be reproduced by:

add container image alpine
conf
set container name alp01 image 'alpine'
set container name alp01 network NET01 address '10.0.0.12'
set container network NET01 prefix '10.0.0.0/24'
commit

Assign another network to network CLI node, but node_changed() does not recognize this

set container network NET01 prefix '2001:db8::/64'
set container name alp01 network NET01 address '2001:db8::12'
commit

node_changes() implementation only handles delete

def node_changed(conf, path, key_mangling=None, recursive=False):
    """
    Check if a leaf node was altered. If it has been altered - values has been
    changed, or it was added/removed, we will return the old value. If nothing
    has been changed, None is returned
    """
    from vyos.configdiff import get_config_diff, Diff
    D = get_config_diff(conf, key_mangling)
    # get_child_nodes() will return dict_keys(), mangle this into a list with PEP448
    keys = D.get_child_nodes_diff(path, expand_nodes=Diff.DELETE, recursive=recursive)['delete'].keys()
    return list(keys)
c-po moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.
c-po moved this task from Need Triage to Finished on the VyOS 1.5 Circinus board.