clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
206 stars 69 forks source link

Unexpected behavior when re-entering top level command for the list element #512

Closed EvgeniiVR closed 2 months ago

EvgeniiVR commented 3 months ago

Hello team,

not sure if this question should be addressed to clixon space, probably to cligen, pls correct me if I'm wrong. Noticed unexpected behavior in case we re-enter top level command for the list element -> candidate config flushes all existing nodes within this element. Let me describe the issue in more details w/ example:

Entering list of "set" commands

> set routing table 10 VRF-10
> set routing table 10 VRF-10 address-family ipv4-unicast
> set routing table 10 VRF-10 address-family ipv6-unicast
> set routing table 20 VRF-20
> set routing table 20 VRF-20 address-family ipv4-unicast
> set routing table 20 VRF-20 address-family ipv6-unicast

Checking candidate

> show configuration | show cli
set routing table 10 VRF-10
set routing table 10 VRF-10 address-family ipv4-unicast
set routing table 10 VRF-10 address-family ipv6-unicast
set routing table 20 VRF-20
set routing table 20 VRF-20 address-family ipv4-unicast
set routing table 20 VRF-20 address-family ipv6-unicast

Commit. Backend debug output


 table(element) add
    id(element) add
    name(element) add
    address-family(element) add
       af-type(element) add
    address-family(element) add
       af-type(element) add

Re-enter top level command for any element within existin list

> set routing table 10 VRF-10

Checking candidate

> show configuration | show cli
set routing table 10 VRF-10
set routing table 20 VRF-20
set routing table 20 VRF-20 address-family ipv4-unicast
set routing table 20 VRF-20 address-family ipv6-unicast

Candidate misses previously configured nodes.

Commit. Backend debug output

 table(element) change
    id(element)
    name(element)
    address-family(element) delete
       af-type(element) delete
    address-family(element) delete
       af-type(element) delete

And we can see that internal nodes have "delete" flags, however we didn't push explicit cmd to delete them.

Is it expected behavior or not? pls advise.

EvgeniiVR commented 3 months ago

and some output from cli debug

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" cl:username="root" xmlns:cl="http://clicon.org/lib" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42"><get-config><source><candidate/></source><nc:filter nc:type="xpath" nc:select="/main:routing/vrf:table/vrf:id" xmlns:main="urn:com.example:yang:main" xmlns:vrf="urn:com.example:yang:vrf"/></get-config></rpc>
##

Apr 18 16:11:48.008299: clixon_msg_rcv11:599: Recv: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data><routing xmlns="urn:com.example:yang:main"><table xmlns="urn:com.example:yang:vrf"><id>10</id><name>VRF-10</name></table><table xmlns="urn:com.example:yang:vrf"><id>20</id><name>VRF-20</name></table><table xmlns="urn:com.example:yang:vrf"><id>30</id><name>VRF-30</name></table></routing></data></rpc-reply>
Apr 18 16:11:48.008671: clixon_msg_send:354: Send [/usr/local/var/run/cli.sock]:
#416
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" cl:username="root" xmlns:cl="http://clicon.org/lib" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="42"><get-config><source><candidate/></source><nc:filter nc:type="xpath" nc:select="/main:routing/vrf:table[vrf:id='20']/vrf:name" xmlns:main="urn:com.example:yang:main" xmlns:vrf="urn:com.example:yang:vrf"/></get-config></rpc>
##

Apr 18 16:11:48.009011: clixon_msg_rcv11:599: Recv: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><data><routing xmlns="urn:com.example:yang:main"><table xmlns="urn:com.example:yang:vrf"><id>20</id><name>VRF-20</name></table></routing></data></rpc-reply>
Apr 18 16:11:48.009335: clixon_msg_send:354: Send [/usr/local/var/run/cli.sock]:
#446
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" cl:username="root" xmlns:cl="http://clicon.org/lib" message-id="42"><edit-config><target><candidate/></target><default-operation>none</default-operation><config><routing xmlns="urn:com.example:yang:main"><table xmlns="urn:com.example:yang:vrf" nc:operation="replace"><id>20</id><name>VRF-20</name></table></routing></config></edit-config></rpc>

As we can see autocli sends "replace" operation in this case

olofhagsand commented 2 months ago

This is a re-occurring question and has to do with he nature of NETCONF operations (see https://datatracker.ietf.org/doc/html/rfc6241#section-7.2) and the autocli "set" command. You should probably use merge instead. I added a new subsection in the user guide to clarify, see https://clixon-docs.readthedocs.io/en/latest/cli.html#netconf-operations Thanks for pointing this out.

EvgeniiVR commented 2 months ago

Hello @olofhagsand, Got your point. Thank you for clarifying and strong support!