Code-name not getting present in generated file

Is there any specific case where code-name does not get generated.

Instead I am seeing the leaf name is getting generated.

The only one I can come up with off the top of my head is something like this:

  container a {
    container a {
      tailf:code-name b;

But it fails already at compile time:

$ confdc -c a.yang
a.yang:10: error: The node ‘a’ and the node ‘a’ (at a.yang:9) have been assigned different code-names. When tailf:code-name is used, the same code-name must be assigned to all identifiers with the same name.

Please provide an example.

I have a list in a list which has many leaves. Some are mandatory.
The tags for the code-name are not getting generated for specific leaves.

Sorry, by “example” I meant actual data, i.e. a YANG module that demonstrates the problem.

Did not get the below – When tailf:code-name is used, the same code-name must be assigned to all identifiers with the same name.

list xxxx {
leaf name { <<<<<<<<<<< name used in list xxxx

tailf:code-name “xxxx_name”;
list yyyy {
leaf name { <<<<<<<<<< name used in list yyyy

tailf:code-name “yyyy_name”;

I’m still waiting for “a YANG module that demonstrates the problem”.

  list ip-pool {
      description "IP Pool Configuration.";
      max-elements 64;
      key name;
      unique "start-ip";
      ordered-by user;
      leaf name {
        description "Unique Name of the IP Pool.";
        type Name;
        tailf:code-name "ip-pool-name";
        must "not(/virtual-network[name = current()/../../name]/ip-pool[group-name = current()])" {
          error-message "pool-name should be different than all group-names";
          tailf:dependency ".";
      leaf start-ip {
        description "Starting IPv4 Address of the pool";
        type inet:ipv4-address;
        mandatory "true";
        tailf:code-name "ip-pool-start-ip";
        tailf:validate ip-pool-validation { tailf:dependency "../end-ip";      }
      leaf end-ip {
        description "End IPv4 Address of the pool";
        type inet:ipv4-address;
        tailf:code-name "ip-pool-end-ip";
        must "compare(current()/../start-ip,current()) = -1" {
          error-message "End-ip must be greater than start-ip";
          tailf:dependency ".";

That is still not “a YANG module that demonstrates the problem”, just a fragment. But wrapping it into something that actually is a compileable module, which requires turning the type ‘Name’ into ‘string’ since there is no typedef for ‘Name’, and removing the ‘must’ expressions that references nodes that aren’t included, I still don’t see any actual problem. All the tailf:code-name statements generate corresponding #define’s in the generated include file:

#define a_ip_pool_end_ip 1424737548
#define a_ip_pool_start_ip 1411652614
#define a_ip_pool_name 1998270519

Surely you don’t expect #define’s to be generated with literally ‘ip-pool-end-ip’ and the like, since that would just fail compilation - identifiers in C and most other programming languages cannot include the ‘-’ character.

If you still think there is a problem, please provide a complete, compileable YANG module, and clearly state exactly what you consider to be a problem. Otherwise I have nothing further to add here.

I was assuming some translation happening from “-” to “_”.

Just curious, i had multiple code-name with “-” as below.
[vagrant@vagrant hng]$ grep ip-pool schema/yang/unicloud-config-vrf.yang | grep code-name
tailf:code-name “ip-pool-name”;
tailf:code-name “ip-pool-start-ip”;
tailf:code-name “ip-pool-end-ip”;
tailf:code-name “ip-pool-group-name”;
tailf:code-name “ip-pool-status”;
tailf:code-name “ip-pool-type”;
tailf:code-name “ip-pool-priority”;
tailf:code-name “ip-pool-profile-name”;

[vagrant@vagrant hng]$ grep “ip_pool” schema/ix64_x86_hng/yang/inc/unicloud-config.h
#define unicloud_ip_pool_type 32229054
#define unicloud_ip_pool_group_name 331590344
#define unicloud_ip_pool_priority 266668040
#define unicloud_ip_pool_profile_name 890365160
#define unicloud_ip_pool 358989733
#define unicloud_ip_pool_status 1773790079

No idea how the #defines with “_” generated for the code-name.

Hm, if so I can’t quite see why you thought the #define’s were missing, but anyway I guess you have found them now.

Advanced algorithms in the compiler… pseudo code: if char == '-' then print '_' else print char. Actually other “illegal” characters are also mapped, to hex sequences. But of course this is primarily for the node names - it is completely pointless to give an argument to tailf:code-name that isn’t a valid identifier for the header file, since that is its only purpose. I.e. I’d suggest that you use ‘_’ instead of ‘-’ with tailf:code-name to avoid confusion.

I really dont know why for some leaf’s the code-name is not generated.
I just have a list in a list. This has many leaves.

And most of my code-names have “xxxx-yyyy” (hypen and not underscore)

So you still don’t get all of them generated. Well, no-one here can help you figure it out, unless you provide an actual, compilable YANG module that demonstrates this. So far you have only provided a fragment, where all code-name statements generated #defines, and ‘grep’ output, which is completely useless for analyzing what the problem is.

The data-model file is too big. Basically. i have a list having multiple lists in it.
Thanks for all the help/suggestions.

Well, you could try to incrementally trim it down, while checking that at least one of the code-name statements still doesn’t generate a #define, and post the result.

There’s no reason this should be a problem or even relevant. I just now tried creating a module consisting of a list with one key, one non-key leaf, and three sub-lists, repeated for three levels, for a total of 40 lists. Added tailf:code-name for all list and leaf nodes, i.e. a total of 120 of those. And every tailf:code-name generated a corresponding #define.

Just to double-check, you are not getting any errors or warnings, either when compiling (i.e. ‘confdc -c module.yang’) or when generating the header file (i.e. ‘confdc --emit-h module.h module.fxs’)?