napalm-automation-community / napalm-sros

NAPALM driver for Nokia SR OS
Apache License 2.0
17 stars 17 forks source link

Port diffs show a port number instead port name #55

Open jk2lx opened 2 years ago

jk2lx commented 2 years ago

When showing the diff for a port admin-state change on an SR-7s, the diff does shows port numbers which cannot be correlated to any port:

[
    "change",
    [
        "configure",
        "port",
        0,
        "admin-state"
    ],
    [
        "enable",
        "disable"
    ]
]

Instead the diff should show the actual port name:

[
    "change",
    [
        "configure",
        "port",
        "1/1/c1",
        "admin-state"
    ],
    [
        "enable",
        "disable"
    ]
]

diff.json.txt

JonLundstrom commented 2 years ago

Thanks for catching this issue @jan-linx. We'll investigate why the output isn't correct.

omron93 commented 2 years ago

Haven't seen your reply before, but if that helps the reason why the diff is like that is because that's exactly how dictdiffer package works. It takes ports as a list of elements so showing 0 for difference in first port element.

jbemmel commented 2 years ago

@jk2lx would your usage of the API be affected if we were to change the output of compare_config to simply be:

A:admin@c# /configure port 1/1/1 admin-state disable 

*(gl)[/]

A:admin@c# compare 

    configure {

        port 1/1/1 {

-           admin-state enable

+           admin-state disable

        }

        port 1/1/c7 {

+           admin-state enable

        }

    }

i.e. the output of the CLI 'compare' command, with '+' and '-' to denote additions/changes?