Question about deviate statement in yang

When I try to call a callpoint in deviate statement , error is seen.
So

import tailf-common { prefix tailf;}

deviation “/if:interfs/if:interf/oxu:oxu” {
deviate add {
config false;
tailf:callpoint operExec;
}
}
Is the syntax of tailf:callpoint statement correct.
Following error is seen:
error: unexpected keyword ‘tailf:callpoint’

When compiling a YANG module, instead of trying to deviate a tailf-common YANG extension from a YANG module (which doesn’t work), best practice is to annotate the YANG module with callpoints, actionpoints and validation elements from a separate annotation file.
This is useful for example when implementing a standard YANG module, without modifying the original file.

See ConfD UG, and the examples.confd/validate/c example:

$ pwd
/Users/tailf/confd-6.4/examples.confd/validate/c
$ cat mtest.yang
module mtest {
  namespace "http://tail-f.com/ns/example/mtest";
  prefix mtest;
  container mtest {
    leaf a_number {
      type int64;
      default 42;
    }
    leaf b_number {
      type int64;
      default 7;
    }
  }
}

$ cat mtest.annot.yang 
module mtest.annot {
  namespace "http://tail-f.com/ns/example/mtest.annot";
  prefix mtesta;

  import mtest {
    prefix m;
  }

  import tailf-common {
    prefix tailf;
  }

  tailf:annotate "/m:mtest/m:a_number" {
    tailf:validate vp1;
  }
}

$ pyang -a mtest.annot.yang -f yang mtest.yang
module mtest {
  namespace "http://tail-f.com/ns/example/mtest";
  prefix mtest;

  import tailf-common {
    prefix tailf;
  }

  container mtest {
    leaf a_number {
      type int64;
      default "42";
      tailf:validate "vp1";
    }
    leaf b_number {
      type int64;
      default "7";
    }
  }
}
$ make all start
...
/Users/tailf/confd-6.4/bin/confdc -c -a mtest.annot.yang mtest.yang
...
$ netconf-console --get-schema mtest
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"><![CDATA[module mtest {
  namespace "http://tail-f.com/ns/example/mtest";
  prefix mtest;
  container mtest {
    leaf a_number {
      type int64;
      default 42;
    }
    leaf b_number {
      type int64;
      default 7;
    }
  }
}
]]></data>
</rpc-reply>

In the given example if I add config false; then I get error error: unexpected keyword ‘config’
Can you please whats wrong if I add config false for some leaf or container?

tailf:annotate "/m:mtest/m:a_number" {
    config false;
    tailf:validate vp1;
  }

The documentation (e.g. tailf_yang_extensions(5)) says:

   tailf:annotate target
       Annotates an existing statement with a 'tailf' statement or a
       validation statement. [...]

       Any 'tailf' statement, except 'symlink' and 'action' can be annotated.
       The statements 'symlink' and 'action' modifies the data model, and are
       thus not allowed.

       The validation statements 'must', 'min-elements', 'max-elements',
       'mandatory', 'unique', and 'when' can also be annotated.

       A 'description' can also be annotated.

And thus you can’t add config false via tailf:annotate. But you can add it via a deviation, as the original example in this thread shows. Its mistake was to try to add a callpoint via deviation.

1 Like