diff --git a/man/man1/pyang.1 b/man/man1/pyang.1 index ca8849427..71671778e 100644 --- a/man/man1/pyang.1 +++ b/man/man1/pyang.1 @@ -33,9 +33,9 @@ pyang \- validate and convert YANG modules to various formats .HP \w'\fBpyang\fR\ 'u \fBpyang\fR [\-\-verbose] [\-\-canonical] [\-\-strict] [\-\-lint] [\-\-ietf] [\-\-lax\-quote\-checks] [\-\-lax\-xpath\-checks] [\-\-features\ \fIfeatures\fR] [\-\-max\-status\ \fImaxstatus\fR] [\-\-hello] [\-\-check\-update\-from\ \fIoldfile\fR] [\-o\ \fIoutfile\fR] [\-f\ \fIformat\fR] [\-p\ \fIpath\fR] [\-W\ \fIwarning\fR] [\-E\ \fIerror\fR] \fIfile\fR... .HP \w'\fBpyang\fR\ 'u -\fBpyang\fR \-h | \-\-help +\fBpyang\fR \-h | \-\-help .HP \w'\fBpyang\fR\ 'u -\fBpyang\fR \-v | \-\-version +\fBpyang\fR \-v | \-\-version .PP One or more \fIfile\fR @@ -440,6 +440,25 @@ to control this path\&. is a colon (:) separated list of directories to search for imported modules\&. This option may be given multiple times\&. .RE .PP +\fB\-D\fR \fB\-\-check\-update\-from\-deviation\-module\fR \fIolddeviation\fR +.RS 4 +\fIolddeviation\fR +is an old deviation module of the old module\&. This option may be given multiple times\&. +.sp +For example, to check updates of a module with some deviations applied, do: +.sp +.if n \{\ +.RS 4 +.\} +.nf +$ pyang \-\-check\-update\-from\-deviation\-module oldmod\-devs\&.yang \-\-check\-update\-from oldmod\&.yang + \-\-deviation\-module newmod\-devs\&.yang newmod\&.yang +.fi +.if n \{\ +.RE +.\} +.RE +.PP \fIfile\&.\&.\&.\fR .RS 4 These are the names of the files containing the modules to be validated, or the module to be converted\&. @@ -1049,7 +1068,7 @@ leaf my\-port { path "deref(\&.\&./my\-ip)/\&.\&./port"; } } - + .fi .if n \{\ .RE @@ -1090,7 +1109,7 @@ The following example converts the ietf\-netconf\-monitoring module into a UML d ietf\-netconf\-monitoring\&.uml $ java \-jar plantuml\&.jar ietf\-netconf\-monitoring\&.uml $ open img/ietf\-netconf\-monitoring\&.png - + .fi .if n \{\ .RE diff --git a/pyang/plugins/check_update.py b/pyang/plugins/check_update.py index 4c19d2514..506f4dfdb 100644 --- a/pyang/plugins/check_update.py +++ b/pyang/plugins/check_update.py @@ -38,9 +38,9 @@ def add_opts(self, optparser): dest="old_deviation", default=[], action="append", - help="Deviation module of the OLDMODULE, or" \ - " module augmenting the OLDMODULE. This" \ - " option can be given multiple times."), + help="Old deviation module of the OLDMODULE." \ + " This option can be given multiple" \ + " times."), ] optparser.add_options(optlist) diff --git a/test/test_update/Makefile b/test/test_update/Makefile index c90a4a361..9b1c890d7 100644 --- a/test/test_update/Makefile +++ b/test/test_update/Makefile @@ -1,6 +1,7 @@ PYANG = pyang --print-error-code --check-update-from -MODULES = a +MODULES = a b +DEVIATION_MODULES = d e test: @for m in $(MODULES); do \ @@ -12,5 +13,15 @@ test: echo " ok"; \ done + @for m in $(DEVIATION_MODULES); do \ + echo "trying b+$$m..." | tr -d '\012'; \ + $(PYANG) b.yang --check-update-from-deviation-module $$m.yang \ + --deviation-module $$m@2014-04-01.yang b@2014-04-01.yang 2> $$m.out; \ + diff expect/$$m.out $$m.out > $$m.diff || \ + { cat $$m.diff; exit 1; }; \ + rm -f $$m.diff; \ + echo " ok"; \ + done + clean: rm -rf *.out *.diff diff --git a/test/test_update/b@2014-04-01.yang b/test/test_update/b@2014-04-01.yang new file mode 100644 index 000000000..e0b2d551b --- /dev/null +++ b/test/test_update/b@2014-04-01.yang @@ -0,0 +1,26 @@ +module b { + namespace "urn:b"; + prefix b; + + revision 2014-04-01; + + identity b; + identity b2; + + container b { + leaf q { + type string; + } + leaf q3 { + type string; + } + } + container c { + leaf q { + type string; + } + } + feature foo { + status obsolete; + } +} \ No newline at end of file diff --git a/test/test_update/d.yang b/test/test_update/d.yang new file mode 100644 index 000000000..b944ba6e7 --- /dev/null +++ b/test/test_update/d.yang @@ -0,0 +1,16 @@ +module d { + namespace urn:d; + prefix d; + + import b { + prefix b; + } + + revision 2014-03-01; + + deviation /b:b/b:q { + deviate add { + default 'dummy'; + } + } +} diff --git a/test/test_update/d@2014-04-01.yang b/test/test_update/d@2014-04-01.yang new file mode 100644 index 000000000..8f9d5c00a --- /dev/null +++ b/test/test_update/d@2014-04-01.yang @@ -0,0 +1,17 @@ +module d { + namespace urn:d; + prefix d; + + import b { + prefix b; + revision-date 2014-04-01; + } + + revision 2014-04-01; + + deviation /b:b/b:q { + deviate add { + default 'smarty'; + } + } +} diff --git a/test/test_update/e.yang b/test/test_update/e.yang new file mode 100644 index 000000000..7013347bc --- /dev/null +++ b/test/test_update/e.yang @@ -0,0 +1,16 @@ +module c { + namespace urn:c; + prefix c; + + import b { + prefix b; + } + + revision 2014-03-01; + + deviation /b:b/b:q { + deviate add { + default 'dummy'; + } + } +} diff --git a/test/test_update/e@2014-04-01.yang b/test/test_update/e@2014-04-01.yang new file mode 100644 index 000000000..b8dd55b9c --- /dev/null +++ b/test/test_update/e@2014-04-01.yang @@ -0,0 +1,17 @@ +module c { + namespace urn:c; + prefix c; + + import b { + prefix b; + revision-date 2014-04-01; + } + + revision 2014-04-01; + + deviation /b:b/b:q { + deviate add { + default 'dummy'; + } + } +} diff --git a/test/test_update/expect/b.out b/test/test_update/expect/b.out new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_update/expect/d.out b/test/test_update/expect/d.out new file mode 100644 index 000000000..5b6f92205 --- /dev/null +++ b/test/test_update/expect/d.out @@ -0,0 +1 @@ +d@2014-04-01.yang:14: error: CHK_DEF_CHANGED diff --git a/test/test_update/expect/e.out b/test/test_update/expect/e.out new file mode 100644 index 000000000..e69de29bb