-
Notifications
You must be signed in to change notification settings - Fork 0
/
draft-yn-netmod-rfc7950bis.xml
10700 lines (10330 loc) · 493 KB
/
draft-yn-netmod-rfc7950bis.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc
[
<!ENTITY nbsp " ">
<!ENTITY zwsp "​">
<!ENTITY nbhy "‑">
<!ENTITY wj "⁠">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt"?>
<?rfc toc="yes"?>
<?rfc compact="no"?>
<?rfc subcompact="no"?>
<?rfc iprnotified="no"?>
<?rfc strict="yes"?>
<rfc ipr="pre5378Trust200902" category="std" submissionType="IETF" consensus="true"
xmlns:xi="http://www.w3.org/2001/XInclude" docName="draft-yn-netmod-rfc7950bis-latest">
<front>
<title abbrev="YANG 1.1">The YANG 1.1 Data Modeling Language</title>
INSERT_TEXT_FROM_FILE(.authors.txt)
<date/>
<area>Operations</area>
<workgroup>NETMOD Working Group</workgroup>
<keyword>data modeling</keyword>
<abstract>
<t>YANG is a data modeling language used to model configuration, operational
state, asynchronous notifications, and remote procedure calls (RPCs) for
network management. This document describes the syntax and semantics of
version 1.1 of the YANG language (YANG 1.1). YANG 1.1 is a
maintenance release of the YANG language, addressing ambiguities and
defects in the original specification. There are a small number of backward
incompatibilities from YANG version 1.0</t>
</abstract>
<note title="Production Process (to be removed by RFC Editor)">
<t>This document is developed on GitHub (<eref target="https://github.com/netmod-wg/rfc7950bis"/>).
If you wish to contribute, please consider opening a pull request (PR). Please see the
<eref target="https://github.com/netmod-wg/rfc7950bis/blob/main/README.md">README</eref>
file for details.</t>
</note>
<note title="Special Thanks">
<t>The following individuals were entrusted to review all of the design proposals
and specification updates made by authors.
INSERT_TEXT_FROM_FILE(.experts.txt)
</t>
</note>
</front>
<middle>
<section title="Introduction">
<t>YANG <xref target="RFC6020"/> <xref target="RFC7950"/> is a data modeling
language used to model configuration, operational state, asynchronous
notifications, and remote procedure calls (RPCs) for network management.
In this sense, YANG is a domain-specific data modeling language having,
e.g., first-class annotations for configuration and operational state,
with rules for how they relate.</t>
<t>Historically, YANG has been used to manage network elements such as
routers, switches, and firewalls. Thus said, it is observed that YANG
is suitable to any networked application having a programmatic interface
for configuration, operational state, asynchronous notifications, and/or
remote procedure calls (RPCs).</t>
<t>YANG is high-level data modeling language, independent of any specific
encoding or any specific protocol. Encodings (e.g., XML <xref target="RFC7950"/>,
JSON <xref target="RFC7951"/>, CBOR <xref target="I-D.ietf-core-yang-cbor"/>, etc.)
and protocols (e.g., NETCONF <xref target="RFC6241"/>, RESTCONF
<xref target="RFC8040"/>, CORECONF <xref target="I-D.ietf-core-comi"/>,
etc.) are out of scope for this specification.</t>
<t>This document describes the syntax and semantics of version 1.1
of the YANG language (YANG 1.1). YANG 1.1 is a maintenance
release of the YANG language, addressing ambiguities and defects in the
original specification. There are a small number of backward
incompatibilities from YANG version 1.0</t>
<t>Note that this document does not obsolete RFC 6020 <xref target="RFC6020"/>.
A mix of YANG module versions may be used to describe a complete data model,
as described in Section <xref target="coexistence"/>.</t>
<t>In terms of developing YANG data models, <xref target="RFC8407"/>
provides some guidelines and recommendations.</t>
<section title="Summary of Changes from RFC 7950">
<t>This document is effectively the same as RFC 7950 with two notable
distinctions:</t>
<ol>
<li>The "XML Encodings" sections have been removed. More specifically,
the information has been moved to <xref target="I-D.yn-netmod-yang-xml"/>.</li>
<li>The "NETCONF Operations" sections have been removed. More specifically,
the information has been moved to <xref target="I-D.yn-netmod-yang-proto"/>.</li>
</ol>
</section>
<section title="Summary of Changes from RFC 6020">
<t>This document defines version 1.1 of the YANG language. YANG version 1.1
is a maintenance release of the YANG language, addressing ambiguities and defects
in the original specification
<xref target="RFC6020"/>.</t>
<t>The following changes are not backward compatible with YANG version 1:</t>
<t>
<list style="symbols">
<t>Changed the rules for the interpretation of escaped characters in
double-quoted strings. This is a backward-incompatible change from YANG
version 1. When updating a YANG version 1 module to 1.1 and the module
uses a character sequence that is now illegal, the string must be changed
to match the new rules. See
<xref target="quoting"/> for details.</t>
<t>An unquoted string cannot contain any single or double quote
characters. This is a backward-incompatible change from YANG version 1.
When updating a YANG version 1 module to 1.1 and the module uses such
quote characters, the string must be changed to match the new rules. See
<xref target="quoting"/> for details.</t>
<t>Made "when" and "if‑feature" illegal on list keys. This is a
backward-incompatible change from YANG version 1. When updating a YANG
version 1 module to 1.1 and the module uses these constructs, they must be
removed to match the new rules.</t>
<t>Defined the legal characters in YANG modules. When updating a YANG
version 1 module to 1.1, any characters that are now illegal must be
removed. See
<xref target="syntax"/> for details.</t>
<t>Made noncharacters illegal in the built-in type "string". This change
affects the runtime behavior of YANG-based protocols.</t>
</list>
</t>
<t>The following additional changes have been done to YANG:</t>
<t>
<list style="symbols">
<t>Changed the YANG version from "1" to "1.1".</t>
<t>Made the "yang‑version" statement mandatory in YANG version "1.1".</t>
<t>Extended the "if‑feature" syntax to be a boolean expression over
feature names.</t>
<t>Allow "if‑feature" in "bit", "enum", and "identity".</t>
<t>Allow "if‑feature" in "refine".</t>
<t>Allow "choice" as a shorthand "case" statement (see
<xref target="case"/>).</t>
<t>Added a new substatement "modifier" to the "pattern" statement (see
<xref target="modifier"/>).</t>
<t>Allow "must" in "input", "output", and "notification".</t>
<t>Allow "require‑instance" in leafref.</t>
<t>Allow "description" and "reference" in "import" and "include".</t>
<t>Allow imports of multiple revisions of a module.</t>
<t>Allow "augment" to add conditionally mandatory nodes (see
<xref target="augment"/>).</t>
<t>Added a set of new XML Path Language (XPath) functions in
<xref target="xpath-functions"/>.</t>
<t>Clarified the XPath context's tree in
<xref target="xpath-context"/>.</t>
<t>Defined the string value of an identityref in XPath expressions (see
<xref target="identityref"/>).</t>
<t>Clarified what unprefixed names mean in leafrefs in typedefs (see
Sections
<xref target="xpath-context" format="counter"/> and
<xref target="path" format="counter"/>).</t>
<t>Allow identities to be derived from multiple base identities (see
Sections
<xref target="identity" format="counter"/> and
<xref target="identityref" format="counter"/>).</t>
<t>Allow enumerations and bits to be subtyped (see Sections
<xref target="enumeration" format="counter"/> and
<xref target="bits" format="counter"/>).</t>
<t>Allow leaf-lists to have default values (see
<xref target="leaf-list-default-value"/>).</t>
<t>Allow non-unique values in non-configuration leaf-lists (see
<xref target="leaf-list"/>).</t>
<t>Use syntax for case-sensitive strings (as per
<xref target="RFC7405"/>) in the grammar.</t>
<t>Changed the module advertisement mechanism (see
<xref target="announce"/>).</t>
<t>Changed the scoping rules for definitions in submodules. A submodule
can now reference all definitions in all submodules that belong to the
same module, without using the "include" statement.</t>
<t>Added a new statement "action", which is used to define operations tied
to data nodes.</t>
<t>Allow notifications to be tied to data nodes.</t>
<t>Added a new data definition statement "anydata" (see
<xref target="anydata"/>), which is RECOMMENDED to be used instead of
"anyxml" when the data can be modeled in YANG.</t>
<t>Allow types "empty" and "leafref" in unions.</t>
<t>Allow type "empty" in a key.</t>
<t>Removed the restriction that identifiers could not start with the
characters "xml".</t>
</list>
</t>
<t>The following changes have been done to the NETCONF mapping:</t>
<t>
<list style="symbols">
<t>A server advertises support for YANG 1.1 modules by using
ietf&nbhy;yang-library
<xref target="RFC8525"/> instead of listing them as capabilities in the
<hello> message.</t>
</list>
</t>
</section>
</section>
<section title="Key Words">
<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY",
and "OPTIONAL" in this document are to be interpreted as described
in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/>
when, and only when, they appear in all capitals, as shown here.</t>
</section>
<section title="Terminology" anchor="terminology">
<t></t>
<t>The following terms are used within this document:</t>
<t>
<list style="symbols">
<t>action: An operation defined for a node in the data tree.</t>
<t>anydata: A data node that can contain an unknown set of nodes that can be
modeled by YANG, except anyxml.</t>
<t>anyxml: A data node that can contain an unknown chunk of XML data.</t>
<t>augment: Adds new schema nodes to a previously defined schema node.</t>
<t>base type: The type from which a derived type was derived, which may be
either a built-in type or another derived type.</t>
<t>built-in type: A YANG data type defined in the YANG language, such as
uint32 or string.</t>
<t>choice: A schema node where only one of a number of identified alternatives
is valid.</t>
<t>client: An entity that can access YANG-defined data on a server, over some
network management protocol.</t>
<t>conformance: A measure of how accurately a server follows a data model.</t>
<t>container: An interior data node that exists in at most one instance in the
data tree. A container has no value, but rather a set of child nodes.</t>
<t>data definition statement: A statement that defines new data nodes. One of
"container", "leaf", "leaf&nbhy;list", "list", "choice", "case",
"augment", "uses", "anydata", and "anyxml".</t>
<t>data model: A data model describes how data is represented and
accessed.</t>
<t>data node: A node in the schema tree that can be instantiated in a data
tree. One of container, leaf, leaf-list, list, anydata, and anyxml.</t>
<t>data tree: An instantiated tree of any data modeled with YANG, e.g.,
configuration data, state data, combined configuration and state data, RPC or
action input, RPC or action output, or notification.</t>
<t>derived type: A type that is derived from a built-in type (such as uint32)
or another derived type.</t>
<t>extension: An extension attaches non-YANG semantics to statements. The
"extension" statement defines new statements to express these semantics.</t>
<t>feature: A mechanism for marking a portion of the model as optional.
Definitions can be tagged with a feature name and are only valid on servers
that support that feature.</t>
<t>grouping: A reusable set of schema nodes, which may be used locally in the
module and by other modules that import from it. The "grouping" statement is
not a data definition statement and, as such, does not define any nodes in the
schema tree.</t>
<t>identifier: A string used to identify different kinds of YANG items by
name.</t>
<t>identity: A globally unique, abstract, and untyped name.</t>
<t>instance identifier: A mechanism for identifying a particular node in a
data tree.</t>
<t>interior node: Nodes within a hierarchy that are not leaf nodes.</t>
<t>leaf: A data node that exists in at most one instance in the data tree. A
leaf has a value but no child nodes.</t>
<t>leaf-list: Like the leaf node but defines a set of uniquely identifiable
nodes rather than a single node. Each node has a value but no child nodes.</t>
<t>list: An interior data node that may exist in multiple instances in the
data tree. A list has no value, but rather a set of child nodes.</t>
<t>mandatory node: A mandatory node is one of:
<list style="symbols">
<t>A leaf, choice, anydata, or anyxml node with a "mandatory" statement
with the value "true".</t>
<t>A list or leaf-list node with a "min‑elements" statement with a value
greater than zero.</t>
<t>A container node without a "presence" statement and that has at least
one mandatory node as a child.</t>
</list></t>
<t>module: A YANG module defines hierarchies of schema nodes. With its
definitions and the definitions it imports or includes from elsewhere, a
module is self-contained and "compilable".</t>
<t>non-presence container: A container that has no meaning of its own,
existing only to contain child nodes.</t>
<t>presence container: A container where the presence of the container itself
carries some meaning.</t>
<t>RPC: A Remote Procedure Call.</t>
<t>RPC operation: A specific Remote Procedure Call.</t>
<t>schema node: A node in the schema tree. One of action, container, leaf,
leaf-list, list, choice, case, rpc, input, output, notification, anydata, and
anyxml.</t>
<t>schema node identifier: A mechanism for identifying a particular node in
the schema tree.</t>
<t>schema tree: The definition hierarchy specified within a module.</t>
<t>server: An entity that provides access to YANG-defined data to a client,
over some network management protocol.</t>
<t>server deviation: A failure of the server to implement a module
faithfully.</t>
<t>submodule: A partial module definition that contributes derived types,
groupings, data nodes, RPCs, actions, and notifications to a module. A YANG
module can be constructed from a number of submodules.</t>
<t>top-level data node: A data node where there is no other data node between
it and a "module" or "submodule" statement.</t>
<t>uses: The "uses" statement is used to instantiate the set of schema nodes
defined in a "grouping" statement. The instantiated nodes may be refined and
augmented to tailor them to any specific needs.</t>
<t>value space: For a data type; the set of values permitted by the data type.
For a leaf or leaf-list instance; the value space of its data type.</t>
</list>
</t>
<t>The following terms are defined in
<xref target="RFC6241"/>:</t>
<t>
<list style="symbols">
<t>configuration data</t>
<t>configuration datastore</t>
<t>datastore</t>
<t>state data</t>
</list>
</t>
<t>When modeled with YANG, a datastore is realized as an instantiated data tree.</t>
<t>When modeled with YANG, a configuration datastore is realized as an instantiated
data tree with configuration data.</t>
<section title="A Note on Examples">
<t>Throughout this document, there are many examples of YANG statements. These
examples are supposed to illustrate certain features and are not supposed to be
complete, valid YANG modules.</t>
</section>
</section>
<section title="YANG Overview">
<t>This non-normative section is intended to give a high-level overview of YANG to
first-time readers.</t>
<section title="Functional Overview">
<t>YANG is a language originally designed to model data for the NETCONF protocol.
A YANG module defines hierarchies of data that can be used for NETCONF-based
operations, including configuration, state data, RPCs, and notifications. This
allows a complete description of all data sent between a NETCONF client and
server. Although out of scope for this specification, YANG can also be used with
protocols other than NETCONF.</t>
<t>YANG models the hierarchical organization of data as a tree in which each node
has a name, and either a value or a set of child nodes. YANG provides clear and
concise descriptions of the nodes, as well as the interaction between those
nodes.</t>
<t>YANG structures data models into modules and submodules. A module can import
definitions from other external modules and can include definitions from
submodules. The hierarchy can be augmented, allowing one module to add data nodes
to the hierarchy defined in another module. This augmentation can be conditional,
with new nodes appearing only if certain conditions are met.</t>
<t>YANG data models can describe constraints to be enforced on the data,
restricting the presence or value of nodes based on the presence or value of other
nodes in the hierarchy. These constraints are enforceable by either the client or
the server.</t>
<t>YANG defines a set of built-in types and has a type mechanism through which
additional types may be defined. Derived types can restrict their base type's set
of valid values using mechanisms like range or pattern restrictions that can be
enforced by clients or servers. They can also define usage conventions for use of
the derived type, such as a string-based type that contains a hostname.</t>
<t>YANG permits the definition of reusable groupings of nodes. The usage of these
groupings can refine or augment the nodes, allowing it to tailor the nodes to its
particular needs. Derived types and groupings can be defined in one module and
used in either the same module or another module that imports it.</t>
<t>YANG data hierarchy constructs include defining lists where list entries are
identified by keys that distinguish them from each other. Such lists may be
defined as either sorted by user or automatically sorted by the system. For
user-sorted lists, operations are defined for manipulating the order of the list
entries.</t>
<t>YANG modules can be translated into an equivalent XML syntax called YANG
Independent Notation (YIN) (
<xref target="YIN"/>), allowing applications using XML parsers and Extensible
Stylesheet Language Transformations (XSLT) scripts to operate on the models. The
conversion from YANG to YIN is semantically lossless, so content in YIN can be
round-tripped back into YANG.</t>
<t>YANG is an extensible language, allowing extensions to be defined by standards
bodies, vendors, and individuals. The statement syntax allows these extensions to
coexist with standard YANG statements in a natural way, while extensions in a YANG
module stand out sufficiently for the reader to notice them.</t>
<t>YANG resists the tendency to solve all possible problems, limiting the problem
space to allow expression of data models for network management protocols such as
NETCONF, not arbitrary XML documents or arbitrary data models.</t>
<t>To the extent possible, YANG maintains compatibility with the Simple Network
Management Protocol's (SNMP's) SMIv2 (Structure of Management Information version
2
<xref target="RFC2578"/>
<xref target="RFC2579"/>). SMIv2-based MIB modules can be automatically
translated into YANG modules for read-only access
<xref target="RFC6643"/>. However, YANG is not concerned with reverse translation
from YANG to SMIv2.</t>
</section>
<section title="Language Overview">
<t>This section introduces some important constructs used in YANG that will aid in
the understanding of the language specifics in later sections.</t>
<section title="Modules and Submodules">
<t>YANG data models are defined in modules. A module contains a collection of
related definitions.</t>
<t>A module contains three types of statements: module header statements,
"revision" statements, and definition statements. The module header statements
describe the module and give information about the module itself, the
"revision" statements give information about the history of the module, and
the definition statements are the body of the module where the data model is
defined.</t>
<t>A server may implement a number of modules, allowing multiple views of the
same data or multiple views of disjoint subsections of the server's data.
Alternatively, the server may implement only one module that defines all
available data.</t>
<t>A module may have portions of its definitions separated into submodules,
based on the needs of the module designer. The external view remains that of a
single module, regardless of the presence or size of its submodules.</t>
<t>The "import" statement allows a module or submodule to reference
definitions defined in other modules.</t>
<t>The "include" statement is used in a module to identify each submodule that
belongs to it.</t>
</section>
<section title="Data Modeling Basics">
<t>YANG defines four main types of data nodes for data modeling. In each of
the following subsections, the examples show the YANG syntax as well as a
corresponding XML encoding. The syntax of YANG statements is defined in
<xref target="statements"/>.</t>
<section title="Leaf Nodes">
<t>A leaf instance contains simple data like an integer or a string. It
has exactly one value of a particular type and no child nodes.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
leaf host-name {
type string;
description
"Hostname for this system.";
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<host-name>my.example.com</host-name>
]]>
</artwork>
</figure>
<t>The "leaf" statement is covered in
<xref target="leaf"/>.</t>
</section>
<section title="Leaf-List Nodes">
<t>A leaf-list defines a sequence of values of a particular type.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
leaf-list domain-search {
type string;
description
"List of domain names to search.";
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<domain-search>high.example.com</domain-search>
<domain-search>low.example.com</domain-search>
<domain-search>everywhere.example.com</domain-search>
]]>
</artwork>
</figure>
<t>The "leaf‑list" statement is covered in
<xref target="leaf-list"/>.</t>
</section>
<section title="Container Nodes">
<t>A container is used to group related nodes in a subtree. A container
has only child nodes and no value. A container may contain any number of
child nodes of any type (leafs, lists, containers, leaf&nbhy;lists,
actions, and notifications).</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
container system {
container login {
leaf message {
type string;
description
"Message given at start of login session.";
}
}
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<system>
<login>
<message>Good morning</message>
</login>
</system>
]]>
</artwork>
</figure>
<t>The "container" statement is covered in
<xref target="container"/>.</t>
</section>
<section title="List Nodes">
<t>A list defines a sequence of list entries. Each entry is like a
container and is uniquely identified by the values of its key leafs if it
has any key leafs defined. A list can define multiple key leafs and may
contain any number of child nodes of any type (including leafs, lists,
containers, etc.).</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
list user {
key "name";
leaf name {
type string;
}
leaf full-name {
type string;
}
leaf class {
type string;
}
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<user>
<name>glocks</name>
<full-name>Goldie Locks</full-name>
<class>intruder</class>
</user>
<user>
<name>snowey</name>
<full-name>Snow White</full-name>
<class>free-loader</class>
</user>
<user>
<name>rzell</name>
<full-name>Rapun Zell</full-name>
<class>tower</class>
</user>
]]>
</artwork>
</figure>
<t>The "list" statement is covered in
<xref target="list"/>.</t>
</section>
<section title="Example Module">
<t>These statements are combined to define the module:</t>
<figure>
<artwork>
<![CDATA[
// Contents of "example-system.yang"
module example-system {
yang-version 1.1;
namespace "urn:example:system";
prefix "sys";
organization "Example Inc.";
contact "joe@example.com";
description
"The module for entities implementing the Example system.";
revision 2007-06-09 {
description "Initial revision.";
}
container system {
leaf host-name {
type string;
description
"Hostname for this system.";
}
leaf-list domain-search {
type string;
description
"List of domain names to search.";
}
container login {
leaf message {
type string;
description
"Message given at start of login session.";
}
list user {
key "name";
leaf name {
type string;
}
leaf full-name {
type string;
}
leaf class {
type string;
}
}
}
}
}
]]>
</artwork>
</figure>
</section>
</section>
<section title="Configuration and State Data">
<t>YANG can model state data, as well as configuration data, based on the
"config" statement. When a node is tagged with "config false", its
subhierarchy is flagged as state data. If it is tagged with "config true", its
subhierarchy is flagged as configuration data. Parent containers, lists, and
key leafs are reported also, giving the context for the state data.</t>
<t>In this example, two leafs are defined for each interface, a configured
speed and an observed speed.</t>
<figure>
<artwork>
<![CDATA[
list interface {
key "name";
config true;
leaf name {
type string;
}
leaf speed {
type enumeration {
enum 10m;
enum 100m;
enum auto;
}
}
leaf observed-speed {
type uint32;
config false;
}
}
]]>
</artwork>
</figure>
<t>The "config" statement is covered in
<xref target="config"/>.</t>
</section>
<section title="Built-In Types">
<t>YANG has a set of built-in types, similar to those of many programming
languages, but with some differences due to special requirements of network
management. The following table summarizes the built-in types discussed in
<xref target="built-in"/>:</t><?rfc compact="yes"?>
<texttable>
<ttcol align='left'>Name</ttcol>
<ttcol align='left'>Description</ttcol>
<c>binary</c>
<c>Any binary data</c>
<c>bits</c>
<c>A set of bits or flags</c>
<c>boolean</c>
<c>"true" or "false"</c>
<c>decimal64</c>
<c>64-bit signed decimal number</c>
<c>empty</c>
<c>A leaf that does not have any value</c>
<c>enumeration</c>
<c>One of an enumerated set of strings</c>
<c>identityref</c>
<c>A reference to an abstract identity</c>
<c>instance-identifier</c>
<c>A reference to a data tree node</c>
<c>int8</c>
<c>8-bit signed integer</c>
<c>int16</c>
<c>16-bit signed integer</c>
<c>int32</c>
<c>32-bit signed integer</c>
<c>int64</c>
<c>64-bit signed integer</c>
<c>leafref</c>
<c>A reference to a leaf instance</c>
<c>string</c>
<c>A character string</c>
<c>uint8</c>
<c>8-bit unsigned integer</c>
<c>uint16</c>
<c>16-bit unsigned integer</c>
<c>uint32</c>
<c>32-bit unsigned integer</c>
<c>uint64</c>
<c>64-bit unsigned integer</c>
<c>union</c>
<c>Choice of member types</c>
</texttable><?rfc compact="no"?>
<t>The "type" statement is covered in
<xref target="type"/>.</t>
</section>
<section title="Derived Types (typedef)">
<t>YANG can define derived types from base types using the "typedef"
statement. A base type can be either a built-in type or a derived type,
allowing a hierarchy of derived types.</t>
<t>A derived type can be used as the argument for the "type" statement.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
typedef percent {
type uint8 {
range "0 .. 100";
}
}
leaf completed {
type percent;
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<completed>20</completed>
]]>
</artwork>
</figure>
<t>The "typedef" statement is covered in
<xref target="typedef"/>.</t>
</section>
<section title="Reusable Node Groups (grouping)">
<t>Groups of nodes can be assembled into reusable collections using the
"grouping" statement. A grouping defines a set of nodes that are instantiated
with the "uses" statement.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
grouping target {
leaf address {
type inet:ip-address;
description "Target IP address.";
}
leaf port {
type inet:port-number;
description "Target port number.";
}
}
container peer {
container destination {
uses target;
}
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<peer>
<destination>
<address>2001:db8::2</address>
<port>830</port>
</destination>
</peer>
]]>
</artwork>
</figure>
<t>The grouping can be refined as it is used, allowing certain statements to
be overridden. In this example, the description is refined:</t>
<figure>
<artwork>
<![CDATA[
container connection {
container source {
uses target {
refine "address" {
description "Source IP address.";
}
refine "port" {
description "Source port number.";
}
}
}
container destination {
uses target {
refine "address" {
description "Destination IP address.";
}
refine "port" {
description "Destination port number.";
}
}
}
}
]]>
</artwork>
</figure>
<t>The "grouping" statement is covered in
<xref target="grouping"/>.</t>
</section>
<section title="Choices">
<t>YANG allows the data model to segregate incompatible nodes into distinct
choices using the "choice" and "case" statements. The "choice" statement
contains a set of "case" statements that define sets of schema nodes that
cannot appear together. Each "case" may contain multiple nodes, but each node
may appear in only one "case" under a "choice".</t>
<t>The choice and case nodes appear only in the schema tree and not in the
data tree. The additional levels of hierarchy are not needed beyond the
conceptual schema. The presence of a case is indicated by the presence of one
or more of the nodes within it.</t>
<t>Since only one of the choice's cases can be valid at any time, when a node
from one case is created in the data tree, all nodes from all other cases are
implicitly deleted. The server handles the enforcement of the constraint,
preventing incompatibilities from existing in the configuration.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
container food {
choice snack {
case sports-arena {
leaf pretzel {
type empty;
}
leaf beer {
type empty;
}
}
case late-night {
leaf chocolate {
type enumeration {
enum dark;
enum milk;
enum first-available;
}
}
}
}
}
]]>
</artwork>
</figure>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<food>
<pretzel/>
<beer/>
</food>
]]>
</artwork>
</figure>
<t>The "choice" statement is covered in
<xref target="choice"/>.</t>
</section>
<section title="Extending Data Models (augment)">
<t>YANG allows a module to insert additional nodes into data models, including
both the current module (and its submodules) and an external module. This is
useful, for example, for vendors to add vendor-specific parameters to standard
data models in an interoperable way.</t>
<t>The "augment" statement defines the location in the data model
hierarchy where new nodes are inserted, and the "when" statement defines the
conditions when the new nodes are valid.</t>
<t>When a server implements a module containing an "augment" statement, that
implies that the server's implementation of the augmented module contains the
additional nodes.</t>
<t>YANG Example:</t>
<figure>
<artwork>
<![CDATA[
augment /system/login/user {
when "class != 'wheel'";
leaf uid {
type uint16 {
range "1000 .. 30000";
}
}
}
]]>
</artwork>
</figure>
<t>This example defines a "uid" node that is valid only when the user's
"class" is not "wheel".</t>
<t>If a module augments another module, the XML elements that are added to the
encoding are in the namespace of the augmenting module. For example, if the
above augmentation were in a module with prefix "other", the XML would look
like:</t>
<t>XML Encoding Example:</t>
<figure>
<artwork>
<![CDATA[
<user>
<name>alicew</name>
<full-name>Alice N. Wonderland</full-name>
<class>drop-out</class>
<other:uid>1024</other:uid>
</user>
]]>
</artwork>
</figure>
<t>The "augment" statement is covered in
<xref target="augment"/>.</t>
</section>
<section title="Operation Definitions">
<t>YANG allows the definition of operations. The operations' names, input
parameters, and output parameters are modeled using YANG data definition
statements. Operations on the top level in a module are defined with the "rpc"
statement. Operations can also be tied to a container or list data node. Such
operations are defined with the "action" statement.</t>
<t>YANG Example for an operation at the top level:</t>
<figure>
<artwork>
<![CDATA[
rpc activate-software-image {
input {
leaf image-name {
type string;
}
}
output {
leaf status {
type string;
}
}
}
]]>
</artwork>
</figure>
<t>NETCONF XML Example:</t>
<figure>
<artwork>
<![CDATA[
<rpc message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<activate-software-image xmlns="http://example.com/system">
<image-name>example-fw-2.3</image-name>
</activate-software-image>
</rpc>
<rpc-reply message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<status xmlns="http://example.com/system">
The image example-fw-2.3 is being installed.
</status>
</rpc-reply>
]]>
</artwork>
</figure>
<t>YANG Example for an operation tied to a list data node:</t>
<figure>
<artwork>
<![CDATA[
list interface {
key "name";
leaf name {
type string;
}
action ping {
input {
leaf destination {
type inet:ip-address;
}
}
output {
leaf packet-loss {
type uint8;
}
}
}
}
]]>
</artwork>
</figure>
<t>NETCONF XML Example:</t>
<figure>
<artwork>
<![CDATA[
<rpc message-id="102"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<action xmlns="urn:ietf:params:xml:ns:yang:1">
<interface xmlns="http://example.com/system">
<name>eth1</name>
<ping>
<destination>192.0.2.1</destination>
</ping>
</interface>
</action>
</rpc>
<rpc-reply message-id="102"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:sys="http://example.com/system">
<sys:packet-loss>60</sys:packet-loss>
</rpc-reply>
]]>
</artwork>
</figure>
<t>The "rpc" statement is covered in
<xref target="rpc"/>, and the "action" statement is covered in
<xref target="action"/>.</t>
</section>
<section title="Notification Definitions">