Load merge fail with 'unknown command'

Configuration (config.cli) after saving config (save config.cli):

profiles
remote-logging remoteP
site pw-hng-site
server-type rsyslog
host myHost
port 88
protocol udp
!
!
!
system
timezone Asia/Kolkata
site pw-hng-site
!
node primary
hostname hng1tatya
!
node secondary
hostname hng2tatya
!
audit-trail
rotate
file-size 5 ! 5
file-count 10 ! 10
!
remote-logging
profile remoteP
node primary
source-ip virtual-network vn-mgf address 10.146.2.92
!
!
!
!

Yang changes:

    list remote-logging {
		....
        list site {
             description "Site remote-logging.";
             tailf:cli-delayed-auto-commit;

             key "name";
             max-elements 64;
             ordered-by user;

             uses site-param;
             when "(count(/system/site) > 0)" {
                 tailf:dependency "/system/site";
             }
       } // End of site
	   ...

When load merge or while bootup while applying above config, system/tag is not present (As system config is after profiles config) while configuring the profiles at line 2.
That’s why ‘when “(count(/system/site) > 0)”’ is not satisfied and config apply is failed on ‘site pw-hng-site’ with unknown command.

Is there any way to change the configuration save order so ‘profiles’ come after ‘system’.

The C- and I- CLI styles need to be parsed line-by-line, so ConfD needs to evaluate the when statement long before the relevant configuration is read. So you have following options:

  • Just edit the configuration files - move the profiles section after the system section.

  • Use another format, XML should work fine for instance; with that, ConfD first reads the full configuration and then evaluates constraints.

  • Change the data model such that the container /system is before /profiles and save the configuration again - that would make ConfD to generate the /system configuration first.

  • Perhaps when is actually not what you need; if you want to express that the instance of /profiles/remote-logging/site must correspond to an instance of /system/site, then you should use a leafref instead - leafref does not suffer from this problem.

Tatya: Yes, after manual edit of config file for above re-order its works fine.*

  • Use another format, XML should work fine for instance; with that, ConfD first reads the full configuration and then evaluates constraints.

Tatya: May be this option is not suitable for my case now*

  • Change the data model such that the container /system is before /profiles and save the configuration again - that would make ConfD to generate the /system configuration first.

Tatya: I tried this by changing submodules sequence but system always comes after profile. May be I need to spend more time here will do that. (So for this ordering of data model is not controlled by any priority flag right?)*

  • Perhaps when is actually not what you need; if you want to express that the instance of /profiles/remote-logging/site must correspond to an instance of /system/site, then you should use a leafref instead - leafref does not suffer from this problem.

Yes noted.

See inline comments with prefix Tatya:


edit (josephm): extracted Tatya’s comments indent to enhance readability a bit.

Maybe, that should definitely work. For plain show running-config or save there indeed are no priority flags. The idea that it does not matter whether container A comes before B or the other way round is quite central to transactions, so there is no good support for ordering.