ConfD User Community

Is there any statements to forbid a "config false" leaf-list to hold same values?


#1

Hi,

In Chapter 7.7 of rfc7950, it says

In configuration data, the values in a leaf-list MUST be unique.

I think it implies that a “config false” leaf-list can hold same values.

But while I try with ConfD(v6.5.3), it seems that values in “config false” leaf-list must be unique too.

Here is my test.

Yang module

module bak {
  namespace "http://tail-f.com/ns/example/bak";
  prefix bak;

  container hardware-state {
    config false;
    list component {
      key name;
      leaf name {type string;}
      leaf class {type string;}
      leaf-list foo {type uint32;}
    }
  }
}

Commands:

homura@ubuntu:~/confd653/examples.confd/user_guide_examples/simple_cdb.num_ins$ confd_cmd -o -m -c "cdb_create /bak:hardware-state/bak:component{abc}"
homura@ubuntu:~/confd653/examples.confd/user_guide_examples/simple_cdb.num_ins$ confd_cmd -o -m -c "mcreate /bak:hardware-state/bak:component{abc}/bak:foo{1}"
homura@ubuntu:~/confd653/examples.confd/user_guide_examples/simple_cdb.num_ins$ make cli
/home/homura/confd653/bin/confd_cli --user=admin --groups=admin \
                --interactive || echo Exit

admin connected from 192.168.56.1 using ssh on ubuntu
admin@ubuntu> show hardware-state 
NAME  CLASS  FOO    
--------------------
abc   -      [ 1 ]  

[ok][2018-05-21 03:03:38]
admin@ubuntu> q
homura@ubuntu:~/confd653/examples.confd/user_guide_examples/simple_cdb.num_ins$ confd_cmd -o -m -c "mcreate /bak:hardware-state/bak:component{abc}/bak:foo{1}"
FAILED: maapi_create(ms, mtid, argv[0]), Error: item already exists (2): , in function do_maapi_create, line 1446

Was I wrong on something?

Br
Lu Kai


#2

In 1.1 of RFC 7950, Summary of Changes from RFC 6020, the following is stated:

o Allow non-unique values in non-configuration leaf-lists (see
Section 7.7).

To get the YANG 1.1 behavior, you will need to add the following statement in your YANG module to specify that it uses YANG 1.1:

yang-version 1.1;

#3

I just added the yang-version 1.1 statement to the module and retry, but still it gave the some outcome as before.


#4

Non unique stat data in leaf-lists doesn’t seem to be supported. You may want to use a keyless list with one single leaf to achieve something similar:

module bak {
  namespace "http://tail-f.com/ns/example/bak";
  prefix bak;

  container hardware-state {
    config false;
    list component {
      key name;
      leaf name {type string;}
      leaf class {type string;}
      list foo {leaf foo {type uint32;}}
    }
  }
}
$ confd_cmd -dd -o -c 'mcreate /bak:hardware-state/bak:component{abc}; mcreate /bak:hardware-state/bak:component{abc}/bak:foo{0}; mset /bak:hardware-state/bak:component{abc}/bak:foo{0}/foo 1; mcreate /bak:hardware-state/bak:component{abc}/bak:foo{1}; mset /bak:hardware-state/bak:component{abc}/bak:foo{1}/foo 1'

mcreate "/bak:hardware-state/bak:component{abc}" ; mcreate "/bak:hardware-state/bak:component{abc}/bak:foo{0}" ; mset "/bak:hardware-state/bak:component{abc}/bak:foo{0}/foo" "1" ; mcreate "/bak:hardware-state/bak:component{abc}/bak:foo{1}" ; mset "/bak:hardware-state/bak:component{abc}/bak:foo{1}/foo" "1"
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION  --> CONFD_OK
TRACE MAAPI_START_TRANS  --> CONFD_OK
TRACE MAAPI_CREATE /bak:hardware-state/bak:component{abc} --> CONFD_OK
TRACE MAAPI_CREATE /bak:hardware-state/bak:component{abc}/bak:foo{0} --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /bak:hardware-state/bak:component{abc}/bak:foo{0}/foo --> CONFD_OK
TRACE MAAPI_CREATE /bak:hardware-state/bak:component{abc}/bak:foo{1} --> CONFD_OK
TRACE MAAPI_SET_ELEM2 /bak:hardware-state/bak:component{abc}/bak:foo{1}/foo --> CONFD_OK
TRACE MAAPI_APPLY_TRANS  --> CONFD_OK
TRACE MAAPI_STOP_TRANS  --> CONFD_OK
TRACE MAAPI_END_USER_SESSION  --> CONFD_OK

$ confd_load -o -F p -p /hardware-state/component{"abc"}/foo
<config xmlns="http://tail-f.com/ns/config/1.0">
  <hardware-state xmlns="http://tail-f.com/ns/example/bak">
  <component>
    <name>abc</name>
      <foo>
        <foo>1</foo>
      </foo>
      <foo>
        <foo>1</foo>
      </foo>
  </component>
  </hardware-state>
</config>

$ confd_cli --noaaa
> show hardware-state 
NAME  CLASS  FOO  
----------------
abc   -      1  
             1 

#5

Well, it is not supported in CDB-operational, since CDB (as of ConfD-6.5) implements leaf-lists the same way as lists, and lists must have unique keys (corresponds to the elements of a leaf-list). But it should work with an external data provider.


#6

Many thx Cohult, but I’m not facing such requirements at the moment, thus I’m not looking for a workaround here. My purpose is to confirm what I understand is right, and also, want to know ConfD’s strategy and plan on that.

Let say, if “config false” leaf-list should be able to contain non unique values, and ConfD will to support it in the future, then how will the APIs hehave?

e.g. If we call maapi_delete(sock, thandle, “/path/to/leaf-list{value}”);
Will it just remove one leaf of that value? Or will it remove all the leaves of that value?