pyang [--canonical] [--ietf] [-o outfile] [-f format] [-p path] [-W what]
module
...
pyang [ -h | --help ]
pyang [ -v | --version ]
Only the most common options are listed here. See below for a complete list of options.
The pyang program is used to validate YANG modules. It is also used to convert YANG modules into equivalent YIN modules. From a valid module, a W3C XML Schema (XSD) or hybrid DSDL schema (RELAX NG with additional annotations) can be generated.
If no format is given, the specified
modules are validated, and the program exits with exit code 0 if
all modules are valid.
-h
--help
Print a short help text and exit.
-v
--version
Print the version number and exit.
-e
--list-errors
Print a listing of all error codes and messages pyang might generate, and then exit.
-Werror
Treat warnings as errors.
-Wnone
Do not print any warnings.
--canonical
Validate the module(s) according to the canonical YANG order.
--ietf
Validate the module(s) according to IETF rules as
specified in draft-ietf-netmod-yang-usage. In addition,
it checks that the module is in canonical order, and that
--max-line-length is 72 so that the
module fits into an RFC.
--max-line-length
maxlen
Give a warning if any line is longer than
maxlen.
--max-identifier-length
maxlen
Give a error if any identifier is longer than
maxlen.
-f
--format
format
Convert the module(s) into
format. Some translators
require a single module, and some can translate multiple
modules at one time. If no
outfile file is specified, the
result is printed on stdout. The supported formats are
listed in
Output Formats
below.
-o
--output
outfile
Write the output to the file
outfile instead of stdout.
-p
--path
path
path is a colon (:) separated
list of directories to search for imported modules. This
option may be given multiple times.
The following directories are always added to the search path:
current directory
$YANG_MODPATH
$HOME/yang/modules
$YANG_INSTALL/yang/modules
OR if $YANG_INSTALL is unset
<the default installation
directory>/yang/modules (on Unix
systems: /usr/share/yang/modules)
--plugindir
plugindir
Load all YANG plugins found in the directory plugindir. This option may be given multiple times.
list of directories to search for pyang plugins. The following directories are always added to the search path:
pyang/plugins from
where pyang is installed
$PYANG_PLUGINPATH
module...
These are the names of the files containing the modules to be validated, or the module to be converted.
If pyang plugins are installed, these plugins may define
their own options, or add new formats to the -f
option. These options and formats are listed in pyang
-h.
the XML syntax of YANG
normal YANG syntax
Hybrid DSDL schema (RELAX NG with annotations)
W3C XML Schema
Prints a Makefile dependency rule for the module
tree structure of the module
Options for the yang output format:
--yang-canonicalGenerate all statements in the canonical order.
Options for the yin output format:
--yin-canonicalGenerate all statements in the canonical order.
--yin-pretty-stringsPretty print strings, i.e. print with extra whitespace in the string. This is not strictly correct, since the whitespace is significant within the strings in XML, but the output is more readable.
Options for the dsdl output format:
--dsdl-no-documentationDo not print documentation annotations
--dsdl-no-dublin-coreDo not print Dublin Core metadata terms
--dsdl-record-defsRecord translations of all top-level typedefs and groupings in the output schema, even if they are not used. This is useful for translating library modules.
Options for the xsd output format:
--xsd-no-appinfoDo not print YANG specific appinfo.
--xsd-no-lectureDo not print the lecture about how the XSD can be used.
--xsd-no-importsDo not generate any xs:imports.
--xsd-no-includesDo not generate any xs:includes.
--xsd-break-patternBreak long patterns so that they fit into RFCs. The resulting patterns might not always be valid XSD, so use with care.
The depend output generates a Makefile dependency rule for files based on a YANG module. This is useful if files are generated from the module. For example, suppose a .c file is generated from each YANG module. If the YANG module imports other modules, or includes submodules, the .c file needs to be regenerated if any of the imported or included modules change. Such a dependency rule can be generated like this:
$ pyang -f depend --depend-target mymod.c \
--depend-extension .yang mymod.yang
mymod.c : ietf-yang-types.yang my-types.yangOptions for the depend output format:
--depend-targetMakefile rule target. Default is the modulename.
--depend-extensionYANG module file name extension. Default is no extension.
--depend-no-submodulesDo not generate dependencies for included submodules.
The tree output prints the resulting schema
tree from one or more modules. Use pyang
--tree-help to print a description on the symbols
used by this format.
Tree output specific option:
--tree-helpPrint help on symbols used in the tree output and exit.
The following example validates the standard YANG modules with derived types:
$ pyang ietf-yang-types.yang ietf-inet-types.yang
The following example converts the ietf-yang-types module into YIN:
$ pyang -f yin -o ietf-yang-types.yin ietf-yang-types.yang
pyang searches for referred modules in the colon (:) separated
path defined by the environment variable
$YANG_MODPATH and in the directory
$YANG_INSTALL/yang/modules.
pyang searches for plugins in the colon (:) separated path
defined by the environment variable
$PYANG_PLUGINDIR.
The XPath arguments for the must and when statements are checked only for basic syntax errors.
The translation of XPath expressions performed by the DSDL plugin doesn't add a prefix to local names that match the keyword of an XPath operator ("and", "or", "div", "mod") even if syntactically it cannot be such an operator. As a workaround, it is necessary to use an explicit prefix for these conflicting names in YANG.