How confd_cli avoids loading failed on conflict command?

     1 vci-configuration
     2  interface 10gei-5/1/0.1
     3   pppoe template wyy1
     4   max-ipox-session  48000
     5   max-pppox-session 48000
     6   encapsulation     multi
     7   access-delay 0
     8   pre-domain        ""
     9   sal               ""
    10  !
    11  interface 10gei-5/1/0.2
    12   pppoe template wyy1
    13   max-ipox-session  48000
    14   max-pppox-session 48000
    15   encapsulation     multi
    16   access-delay 0
    17   pre-domain        ""
    18   sal               ""
    19  !
    20  interface 10gei-5/1/0.3
    21   pppoe template wyy1
    22   max-ipox-session  48000
    23   max-pppox-session 48000
    24   encapsulation     multi
    25   access-delay 0
    26   pre-domain        ""
    27   sal               ""
    28  !
    29 !
       
    30 interface 10gei-5/1/0.1
    31  ipv4 address 13.1.1.1 24
    32  dot1q-range 1 to 20
    33 !
    34 interface 10gei-5/1/0.2
    35  ipv4 address 14.1.1.1 24
    36  dot1q 21
    37  dot1q 4094
    38 !

When I load this configuration saved by confd_cli save commond, it fails on line 31. I think it because the intercae 10gei-5/1/0.1(in line 30) is still in mode vci-configuration, so how to fix it?

The last interface is command in the root, the above interface are sub-commands under vci-configuration.

Can you include details of the error and your YANG model?

Yang:

  container vci-configration {
      tailf:cli-add-mode;
      tailf:cli-full-command;
      list interface {
          key name;
          leaf name {type string;}
          leaf max-ipox-session {type int32;}
          leaf access-delay {type int32;}
      }   
  }
  list interface {
      key name;
      leaf name {type string;}
      container ip {
          leaf address {type string;}
      }   
      leaf dot1q {type int32;}
  }

Configuration:

localhost# config 
Entering configuration mode terminal
localhost(config)# vci-configration 
localhost(config-vci-configration)# interface a
localhost(config-interface-a)# access-delay 0 max-ipox-session 18
localhost(config-interface-a)# exit
localhost(config-vci-configration)# exit
localhost(config)# interface aa ip address 111 
localhost(config-interface-aa)# dot1q 2
localhost(config)# commit
localhost(config)# save a.txt
localhost(config)# load merge a.txt 
Loading.
Error: on line 64:  ip address 111
localhost(config)# 

line 55-66 of a.txt

    55  vci-configration
    56   interface a
    57    max-ipox-session 18
    58    access-delay     0
    59   !
    60   interface aa
    61   !
    62  !
    63  interface aa
    64   ip address 111
    65   dot1q 2
    66  !

If you change the name of the second interface list that is outside of the vci-configuration container to something like new-interface, then the load command will work fine. This is likely a bug. I will file an internal ticket on this issue.

An alternative is to save your configuration in xml format as follows:

save a.xml xml

then when you perform the load command of:

load merge a.xml

it will work just fine.

OK, thanks for the alternative, it works. But I’m still looking forward the plain text solution.

There exists two solutions to this issue:

Add the cli-explicit-exit tailf annotation to your YANG model as follows:

container vci-configration {
    tailf:cli-add-mode;
    tailf:cli-full-command;
    tailf:cli-explicit-exit;
    list interface {
        key name;
        leaf name {type string;}
        leaf max-ipox-session {type int32;}
        leaf access-delay {type int32;}
    }   
}

or change the cModeExitFormat option in confd.conf as follows:

<confdConfig xmlns="http://tail-f.com/ns/confd_cfg/1.0">
...
<cli>
  <cModeExitFormat>exit</cModeExitFormat>
</cli>
...
</confdConfig>

The second solution instructs the CLI to globally emit a custom exit statement after exiting a mode.

Hi wai, thank you very much.