简体   繁体   English

如何将杨转换为 XPath?

[英]How to convert Yang to XPath?

I need to know if there are any tools that can take.yang file as an input and return all the XPaths that will be present.我需要知道是否有任何工具可以将.yang 文件作为输入并返回将出现的所有 XPath。 (I tried pyang, but I couldn't find any option to convert to XPath) (我试过 pyang,但找不到任何转换为 XPath 的选项)

For example:
if .yang file is :
-------------------------------
grouping grouping-foo {
    leaf g-foo;
    leaf g-bar;
}
container foo {
    leaf bar;
    uses grouping-foo;
}
-------------------------------

Then output should be:
-------------------------------
/foo/bar
/foo/g-foo
/goo/g-bar
-------------------------------

You need to use pyang and the plugin xpath .您需要使用pyang和插件xpath

I started by installing pyang then i downloaded the xpath plugin and put it in a directory $HOME/pyang-plugin/我从安装 pyang 开始,然后我下载了 xpath 插件并将其放入目录$HOME/pyang-plugin/

Here an example that i used on Juniper yang model这是我在 Juniper yang model 上使用的示例

nabil@DESKTOP-8ECTID4:~/yang/vendor/juniper/22.1/22.1R1/junos/conf$ pyang  --plugindir $HOME/pyang-plugin/ -f xpath
junos-conf-access-profile@2019-01-01.yang  -p ../../common/
junos-conf-access-profile@2019-01-01.yang:10: warning: imported module "junos-common-types" not used

>>> module: junos-conf-access-profile
>>>  augment /jc:configuration:
/access-profile
/access-profile/access-profile-name
>>>  augment /jc:configuration/jc:groups:
/access-profile
/access-profile/access-profile-name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM