# Annotate enums in list with code-names

**URL:** <https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047>\
**Category:** YANG\
**Created:** [April 6, 2022, 3:41pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047 "2022-04-06T15:41:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)\
**Post date:** [April 6, 2022, 3:41pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047/1 "2022-04-06T15:41:27Z")

</div>

I was reading up on --allow-enum-conflicts, while trying to resolve the following when emitting c header files:

> Warning: the following symbols have been suppressed due to a  
> conflict with an enum or bit with the same mapped name but a different value:  
> ‘OTHER’, ‘UNKNOWN’.  
> Use tailf:code-name on the conflicting enums, bits, or nodes  
> to avoid the conflict.

I cannot modify the original yang module. Do I need to add an annotate for every leaf that uses the conflicting enums?

```auto
 module module-d {
     yang-version "1";
 
     namespace "urn:params:xml:ns:yang:project:m-d";
     prefix m-d;
 
     typedef module-d-type {
         type enumeration {
             enum OTHER { value 1; }
             enum UNKNOWN { value 0; }
         }
     }
 
     typedef module-d-type2 {
         type enumeration {
             enum OTHER { value 2; }
             enum UNKNOWN { value 3; }
         }
     }
 
     grouping module-d-grouping {
         container module-d-container {
             list module-d-list {
                 key module-d-leaf;
 
                 leaf module-d-leaf { type uint8; }
                 leaf object-b { type string; }
                 leaf object-c { type module-d-type; }
                 leaf object-d { type module-d-type2; }
             }
         }
     }
 
     grouping module-d2-grouping {
         leaf module-d-container { type uint32; }
     }
 }
...
pyang tree:
...
 module: module-a
   +--rw container-a
      +--rw container-b
         +--rw object-b? uint8
         +--rw module-b-container
         | +--rw module-b-list* [module-b-leaf]
         | | +--rw module-b-leaf uint8
         | | +--rw object-b? string
         | +--rw module-d-container
         | +--rw module-d-list* [module-d-leaf]
         | +--rw module-d-leaf uint8
         | +--rw object-b? string
         | +--rw object-c? module-d-type
         | +--rw object-d? module-d-type2
         +--rw module-c-container
            +--rw module-c-list* [module-c-leaf]
            | +--rw module-c-leaf uint8
            | +--rw object-b? string
            | +--rw object-c? module-c-type
            +--rw module-d-container? uint32

```

---

<div class="post-metadata">

**Author:** ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)\
**Post date:** [April 6, 2022, 4:18pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047/2 "2022-04-06T16:18:58Z")

</div>

This is what I’ve tried in my annotation file, but confdc gives me errors:

```auto
module module-d-ann {
    yang-version "1";

    namespace "urn:params:xml:ns:yang:project:m-d-ann";
    prefix m-d-ann;

    import tailf-common {
        prefix tailf;
    }
    import module-a {
        prefix m-a;
    }

    tailf:annotate /m-a:container-a/m-a:container-b/m-a:module-b-container/m-a:module-d-container {
        tailf:callpoint container-d-handler {
            tailf:transaction-hook subtree;
        }
    }

    tailf:annotate /m-a:container-a/m-a:container-b/m-a:module-c-container/m-a:module-d-container {
        tailf:callpoint container-d2-handler {
            tailf:transaction-hook subtree;
        }
    }

    tailf:annotate-module "module-d" {
        tailf:annotate-statement "grouping[name='module-d-grouping']" {
            tailf:annotate-statement "container [name='module-d-container']" {
                tailf:annotate-statement "list[name='module-d-list']" {
                    tailf:annotate-statement "leaf[name='object-d']" {
                        tailf:annotate-statement "enum[name='OTHER']" {
                            tailf:code-name "m-d-type2-OTHER";
                        }
                        tailf:annotate-statement "enum[name='UNKNOWN']" {
                            tailf:code-name "m-d-type2-UNKNOWN";
                        }
                    }
                }
            }
        }
    }
}

```

```auto
confdc -c --include-doc --fail-on-warnings --strict-yang --yangpath ../yang -a ../ann/module-a-ann.yang -a ../ann/module-b-ann.yang -a ../ann/module-c-ann.yang -a ../ann/module-d-ann.yang ../yang/module-d.yang 
../ann/module-d-ann.yang:14: error: node 'module-d-container' not found
../ann/module-d-ann.yang:20: error: node 'module-d-container' not found
../yang/module-b.yang:7: error: circular dependency for module 'module-d'
../yang/module-c.yang:7: error: circular dependency for module 'module-d'

```

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [April 6, 2022, 5:07pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047/3 "2022-04-06T17:07:51Z")

</div>

You do not need to import the YANG module that you are annotating from the annotation file. Also, note that the tailf:annotate-module/statement annotates the YANG model, not the resulting schema as tailf:annotate does.

So the tailf:annotate-module part should be something like this:

```java
module module-d-ann {
  namespace "urn:params:xml:ns:yang:project:m-d-ann";
  prefix m-d-ann;

  import tailf-common {
    prefix tailf;
  }

  revision 2022-04-06 {
    description
      "Initial revision";
  }
  tailf:annotate-module "module-d" {
    tailf:annotate-statement "typedef[name='module-d-type2']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='OTHER']" {
          tailf:code-name "m-d-type2-OTHER";
        }
      }
    }
    tailf:annotate-statement "typedef[name='module-d-type2']" {
      tailf:annotate-statement "type[name='enumeration']" {
        tailf:annotate-statement "enum[name='UNKNOWN']" {
          tailf:code-name "m-d-type2-UNKNOWN";
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)\
**Post date:** [April 6, 2022, 5:12pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047/4 "2022-04-06T17:12:18Z")

</div>

Won’t that break my callpoint annotates, that need to know the path?

---

<div class="post-metadata">

**Author:** ![colinmc](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@colinmc](https://dmap-community.ductus.global/u/colinmc)\
**Post date:** [April 6, 2022, 5:22pm UTC](https://dmap-community.ductus.global/t/annotate-enums-in-list-with-code-names/4047/5 "2022-04-06T17:22:18Z")

</div>

I think I’ve worked around this by having a “module-a-ann.yang” that contains all my callpoint annotations, and keeping the enum annotations within the “module-d-ann.yang”.
