How to add tailf:annotate for groupings?

As suggestion, when implementing a standard YANG module, it is better to keep the Tail-f extension statements in a separate annotation file. But how to add tailf:annotate for groupings?

module test {
   namespace "http://tail-f.com/test";
   prefix "t";

   import ietf-inet-types {
      prefix inet;
   }
   grouping gg {
        leaf g_1 {
        //tailf:xxx;
        };
        leaf g_2 {
        //tailf:xxx
        };
        leaf g_3{
        //tailf:xxx 
        }; 
  }
   container top {
      leaf a {
          type int32;
          config false;
      }
      leaf b {
         type string;
      }
      leaf ip {
         type inet:ipv4-address;
      }
      uses gg;
   }
}

module test-ann {
   namespace "http://tail-f.com/test-ann";
   prefix "ta";

   import test {
      prefix t;
   }
   import tailf-common {
      prefix tailf;
   }

tailf:annotate "t:gg/t:g_1" { //it doesn't work this way!!!
      tailf:xxxx;?????
}
   tailf:annotate "/t:top/t:a" {
       tailf:callpoint mycp;
   }

   tailf:annotate "/t:top" {
       tailf:annotate "t:b" {  // recursive annotation
           tailf:validate myvalcp {
               tailf:dependency "../t:a";
           }
       }
   }
}

You annotate the resulting YANG model. Here, the grouping is merged with the top container, so the path to g_1 will be /top/g_t:

tailf:annotate "/t:top/t:g_1" { //works better
       tailf:xxxx;?????
}

Thanks cohult, this is what i’m doing.
but as you know, when we define grouping, because it is used many times, in this situation should us expand all the container that uses grouping? eg

grouping gg {}

container a {
    uses gg;
}

container b {
    uses gg;
}

container ...{
    uses gg;
}

container n {
    uses gg;
}

if we have m tailf:xxx in each grouping, and this grouping is used n containers, shall we have to expand the tailf:annotate m x n times?

You can do that, or you can use the tailf:annotate-module and tailf:annotate-statement like this:

   tailf:annotate-module "test" {
       tailf:annotate-statement grouping[name='gg'] {
           tailf:annotate-statement leaf[name='g_1'] {
               tailf:xxxx;?????
           }
       }
   }

It’s cool!
That is what I want, thank you @cohult!!

hi @cohult, i met a problem about tailf:annotate-module, for example:
i defined two module
module A – A.yang(define some common groups); module B – B.yang
and i want to extend B module, so i define B-ann.yang

Note that i annotate both A and B in the B-ann.yang like below

  import A {
    prefix A;
  }

  tailf:annotate-module "A" {
    tailf:annotate-statement grouping[xx] {
      tailf:annotate-statement container[xx] {
        tailf:callpoint xx {
          tailf:transaction-hook subtree;
        }
      }
    }
 
  tailf:annotate-module B{
    tailf:annotate-statement grouping[name=XX] {
      tailf:annotate-statement list[name=XX] {
        tailf:callpoint XX {
          tailf:transaction-hook subtree;
        }
      }
    }

and when i compile the yang file, it complained can’t find module A
${CONFDPATH}/confdc --fail-on-warnings -c $YANGCCAP/B.yang --yangpath $YANGCCAP -a B-ann.yang
if i comment “tailf:annotate-module B” out, it can compile successfully.
Do you know the reason ? Did it support annotate two modules in one file?

Hi @jluo0201, use one annotation file per yang model/module when compiling the yang model with the annotation file.
A generic Makefile example can be found here: