Need help to run pyang --tailf-sanitize to remove symlinks

Hi Team,

I’m trying to use pyang tool to replace symlinked data structures with actual ones in my yang files.
I’m currently using pyang 2.4.0 version, but looks 2.4.0 doesn’t support --tailf-sanitize option.

user:~/pyang_sanitise$ /usr/local/bin/pyang -v
pyang 2.4.0
user:~/pyang_sanitise$ /usr/local/bin/pyang -f yang --tailf-sanitize system.yang                  
Usage: pyang [options] [<filename>...]

Validates the YANG module in <filename> (or stdin), and all its dependencies.

pyang: error: no such option: --tailf-sanitize
user:~/pyang_sanitise$

I also tried using older pyang version where --tailf-sanitize option is supported, but in older version symlink keyword is not being detected.

user:~/pyang_sanitise$ 
pyang -f yang --tailf-sanitize system.yang
system.yang:61: error: extension "symlink" is not defined in module tailf-common
system.yang:62: error: extension "path" is not defined in module tailf-common

Could you please help me pyang version where I can use --tailf-sanitize option to remove symlink.

Thanks,
Usha

There are two problems, actually:

  1. The pyang version distributed with ConfD is bit dated and is known to fail on some perfectly legal modules. On the other hand, it includes the tailf plugin which implements --tailf-sanitize; so if your datamodel can be swallowed by that pyang version, use it. The other option is to take the tailf plugin and provide it to the newer version of pyang (the one from github or PyPI). Unfortunately, the plugin is not entirely compatible so some modifications would be needed.

  2. The other problem is that the extension symlink has been removed from the module tailf-common distributed with recent ConfD versions - that’s why you get the “not defined” errors. You can either use tailf-common from an older ConfD release if you have it (i.e. supply --path /old/confd/dir/src/confd/yang to pyang), or just take the one you have and add the two extensions (possibly to a copy of the module), like this:

     extension symlink {
       argument name {
         tailf:arg-type {
           type tailf:identifier;
         }
       }
     }
     extension path {
       argument path {
         tailf:arg-type {
           type string;
         }
       }
     }

Btw. if what you want is to remove symlinks, you need to add --tailf-remove-symlink too.

1 Like

Thanks Martin, After using a tailf-common.yang file which has symlink extension definition, able to run pyang tool to remove symlinks.
but the same command( is replacing the symlink with actual container data) is working for some files where as it’s not working for some files.
Didn’t notice any errors which might cause this.

I would say that this is one of the problem I mentioned above - the old pyang distributed with ConfD is not capable of processing some YANG modules and just silently ignores them or produces incomplete data.