idnits 2.17.1 draft-ietf-netmod-yang-metadata-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document updates RFC6110, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (March 11, 2016) is 2965 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '6' on line 555 -- Looks like a reference, but probably isn't: '3' on line 555 -- Looks like a reference, but probably isn't: '7' on line 555 -- Looks like a reference, but probably isn't: '8' on line 555 == Outdated reference: A later version (-14) exists of draft-ietf-netmod-rfc6020bis-11 == Outdated reference: A later version (-10) exists of draft-ietf-netmod-yang-json-09 ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) == Outdated reference: A later version (-18) exists of draft-ietf-netconf-restconf-09 Summary: 1 error (**), 0 flaws (~~), 4 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 NETMOD Working Group L. Lhotka 3 Internet-Draft CZ.NIC 4 Updates: 6110 (if approved) March 11, 2016 5 Intended status: Standards Track 6 Expires: September 12, 2016 8 Defining and Using Metadata with YANG 9 draft-ietf-netmod-yang-metadata-06 11 Abstract 13 This document defines a YANG extension statement that allows for 14 defining metadata annotations in YANG modules. The document also 15 specifies XML and JSON encoding of annotations and other rules for 16 annotating instances of YANG data nodes. 18 Status of This Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at http://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on September 12, 2016. 35 Copyright Notice 37 Copyright (c) 2016 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (http://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 53 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 54 2.1. Keywords . . . . . . . . . . . . . . . . . . . . . . . . 4 55 2.2. Terms Defined in Other Documents . . . . . . . . . . . . 5 56 2.3. Namespaces and Prefixes . . . . . . . . . . . . . . . . . 6 57 2.4. Definitions of New Terms . . . . . . . . . . . . . . . . 7 58 3. Defining Annotations in YANG . . . . . . . . . . . . . . . . 7 59 3.1. Example Definition . . . . . . . . . . . . . . . . . . . 8 60 4. Using Annotations . . . . . . . . . . . . . . . . . . . . . . 8 61 5. The Encoding of Annotations . . . . . . . . . . . . . . . . . 9 62 5.1. XML Encoding . . . . . . . . . . . . . . . . . . . . . . 9 63 5.2. JSON Encoding . . . . . . . . . . . . . . . . . . . . . . 10 64 5.2.1. Metadata Object and Annotations . . . . . . . . . . . 10 65 5.2.2. Adding Annotations to Anydata, Container and List 66 Entries . . . . . . . . . . . . . . . . . . . . . . . 11 67 5.2.3. Adding Annotations to Anyxml and Leaf Instances . . . 11 68 5.2.4. Adding Annotations to Leaf-list Entries . . . . . . . 12 69 6. Representing Annotations in DSDL Schemas . . . . . . . . . . 13 70 7. Metadata YANG Module . . . . . . . . . . . . . . . . . . . . 14 71 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 72 9. Security Considerations . . . . . . . . . . . . . . . . . . . 17 73 10. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 17 74 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 17 75 11.1. Normative References . . . . . . . . . . . . . . . . . . 17 76 11.2. Informative References . . . . . . . . . . . . . . . . . 18 77 Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 19 78 A.1. Changes Between Revisions -05 and -06 . . . . . . . . . . 19 79 A.2. Changes Between Revisions -04 and -05 . . . . . . . . . . 19 80 A.3. Changes Between Revisions -03 and -04 . . . . . . . . . . 19 81 A.4. Changes Between Revisions -02 and -03 . . . . . . . . . . 19 82 A.5. Changes Between Revisions -01 and -02 . . . . . . . . . . 19 83 A.6. Changes Between Revisions -00 and -01 . . . . . . . . . . 20 84 A.7. Changes Between draft-lhotka-netmod-yang-metadata-01 and 85 draft-ietf-netmod-yang-metadata-00 . . . . . . . . . . . 20 86 A.8. Changes Between draft-lhotka-netmod-yang-metadata-00 and 87 -01 . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 88 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 20 90 1. Introduction 92 There is a need to be able to annotate instances of 93 YANG [I-D.ietf-netmod-rfc6020bis] data nodes with metadata. Typical 94 use cases are: 96 o Complementing regular data model information with instance- 97 specific metadata, comments etc. 99 o Providing information about data rendering in user interfaces. 101 o Deactivating a subtree in a configuration datastore while keeping 102 the data in place. 104 o Network management protocols often use metadata annotations for 105 various purposes in both operation requests and responses. For 106 example, the operation in the NETCONF protocol (see 107 section 7.2 of [RFC6241]) uses annotations in the form of XML 108 attributes for identifying the location in a configuration 109 datastore and the type of the operation. 111 However, metadata annotations could potentially lead to 112 interoperability problems if they are used in an ad hoc fashion by 113 different parties and/or without proper documentation. A sound 114 metadata framework for YANG should therefore satisfy these 115 requirements: 117 1. The set of annotations must be extensible in a decentralised 118 manner so as to allow for defining new annotations without 119 running into the risk of collisions with annotations defined and 120 used by others. 122 2. Syntax and semantics of annotations must be documented and the 123 documentation must be easily accessible. 125 3. Clients of network management protocols such as NETCONF [RFC6241] 126 or RESTCONF [I-D.ietf-netconf-restconf] must be able to discover 127 all annotations supported by a given server and identify each of 128 them correctly. 130 4. Annotations sent by a server should not break clients that don't 131 support them. 133 This document proposes a systematic way for defining metadata 134 annotations. For this purpose, YANG extension statement "annotation" 135 is defined in the module "ietf-yang-metadata" (Section 7). Other 136 YANG modules importing this module can use the "annotation" statement 137 for defining one or more annotations. 139 The benefits of defining the metadata annotations in a YANG module 140 are the following: 142 o Each annotation is bound to a YANG module name and namespace URI. 143 This makes its encoding in instance documents (both XML and JSON) 144 straightforward and consistent with the encoding of YANG data node 145 instances. 147 o Annotations defined in IETF standard-track documents are 148 indirectly registered through IANA in the "YANG Module Names" 149 registry [RFC6020]. 151 o Annotations are included in the data model. YANG compilers and 152 tools supporting a certain annotation can thus take them into 153 account and modify their behavior accordingly. 155 o Semantics of an annotation are defined in the "description" and 156 "reference" statements. 158 o An annotation can be declared as conditional by using the "if- 159 feature" statement. 161 o The type of each annotation is explicitly specified; any YANG 162 built-in or derived type that is available for leaf or leaf-list 163 data nodes may be specified for annotations as well. 165 In the XML encoding, XML attributes are a natural instrument for 166 attaching annotations to data node instances. This document 167 deliberately adopts some restrictions in order to remain compatible 168 with the XML encoding of YANG data node instances and limitations of 169 XML attributes. Specifically, 171 o annotations can only be scalar values; 173 o annotations cannot be attached to a whole list or leaf-list 174 instance, only to individual list or leaf-list entries. 176 Due to the rules for YANG extensions (see sec. 6.3.1 in 177 [I-D.ietf-netmod-rfc6020bis]), annotation definitions posit 178 relatively weak conformance requirements. The alternative of 179 introducing a new built-in YANG statement for defining annotations 180 was considered, but it was seen as a major change to the language 181 that is inappropriate for YANG 1.1, which was chartered as a 182 maintenance revision. After evaluating real-life usage of metadata 183 annotations, it is conceivable that such a new built-in statement 184 might be added in a future revision of YANG. 186 2. Terminology 188 2.1. Keywords 190 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 191 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 192 document are to be interpreted as described in [RFC2119]. 194 2.2. Terms Defined in Other Documents 196 The following terms are defined in [RFC6241]: 198 o capability, 200 o client, 202 o datastore, 204 o message, 206 o protocol operation, 208 o server. 210 The following terms are defined in [I-D.ietf-netmod-rfc6020bis]: 212 o action, 214 o anydata, 216 o anyxml, 218 o built-in type, 220 o container, 222 o data model, 224 o data node, 226 o data tree, 228 o derived type, 230 o extension, 232 o leaf, 234 o leaf-list, 236 o list, 238 o module, 240 o RPC input and output. 242 The following terms are defined in [W3C.REC-xml-infoset-20040204]: 244 o attribute, 246 o document, 248 o element. 250 The following terms are defined in [W3C.REC-xml-names11-20060816]: 252 o local name, 254 o namespace name, 256 o prefix, 258 o qualified name. 260 The following terms are defined in [RFC7159]: 262 o array, 264 o member, 266 o object, 268 o primitive type. 270 2.3. Namespaces and Prefixes 272 In the following text, XML element names and YANG extension 273 statements are always written with explicit namespace prefixes that 274 are assumed to be bound to URI references as shown in Table 1. 276 +--------+------------------------------------------------+ 277 | Prefix | URI Reference | 278 +--------+------------------------------------------------+ 279 | elm | http://example.org/example-last-modified | 280 | md | urn:ietf:params:xml:ns:yang:ietf-yang-metadata | 281 | rng | http://relaxng.org/ns/structure/1.0 | 282 +--------+------------------------------------------------+ 284 Table 1: Used namespace prefixes and corresponding URI references 286 2.4. Definitions of New Terms 288 o annotation: a single item of metadata that is attached to YANG 289 data node instances. 291 o metadata: additional information that complements a data tree. 293 o metadata object: an object in JSON encoding that contains all 294 annotations attached to a given data node instance. 296 3. Defining Annotations in YANG 298 Metadata annotations are defined by YANG extension statement 299 "md:annotation". This YANG language extension is defined in the 300 module "ietf-yang-metadata" (Section 7). 302 Substatements of "md:annotation" are shown in Table 2. They are all 303 core YANG statements, and the numbers in the second column refer to 304 the corresponding section in [I-D.ietf-netmod-rfc6020bis] where each 305 statement is described. 307 +--------------+---------------------+-------------+ 308 | substatement | RFC 6020bis section | cardinality | 309 +--------------+---------------------+-------------+ 310 | description | 7.21.3 | 0..1 | 311 | if-feature | 7.20.2 | 0..n | 312 | reference | 7.21.4 | 0..1 | 313 | status | 7.21.2 | 0..1 | 314 | type | 7.6.3 | 1 | 315 | units | 7.3.3 | 0..1 | 316 +--------------+---------------------+-------------+ 318 Table 2: Substatements of "md:annotation". 320 An annotation carries a single value. The type substatement, which 321 MUST be present, takes as an argument the name of an existing built- 322 in or derived type, and the value of the annotation MUST match this 323 type. See Section 7.4 of [I-D.ietf-netmod-rfc6020bis] for details. 325 An annotation can be made conditional by using one or more "if- 326 feature" statements; the annotation is then supported only by servers 327 that advertise the corresponding feature. 329 The semantics and usage rules for an annotation SHOULD be fully 330 specified in "description", "reference" and "units" statements. 332 An annotation MUST NOT change the data tree semantics defined by 333 YANG. For example, it is illegal to define and use an annotation 334 that allows for overriding uniqueness of leaf-list entries. 336 The "status" statement can be used exactly as for YANG data nodes. 338 A YANG module containing one or more "md:annotation" extension 339 statements SHOULD NOT be used for defining data nodes or groupings. 340 Also, derived types, identities and features SHOULD NOT be defined in 341 such a module unless they are used by the definitions of annotations 342 in that module. 344 3.1. Example Definition 346 The following module defines the "last-modified" annotation: 348 module example-last-modified { 349 namespace "http://example.org/example-last-modified"; 350 prefix "elm"; 351 import ietf-yang-types { 352 prefix "yang"; 353 } 354 import ietf-yang-metadata { 355 prefix "md"; 356 } 357 md:annotation last-modified { 358 type yang:date-and-time; 359 description 360 "This annotation contains date and time when the 361 annotated instance was last modified (or created)."; 362 } 363 } 365 4. Using Annotations 367 By advertising a YANG module in which a metadata annotation is 368 defined using the "md:annotation" statement, a server indicates that 369 it is prepared to handle that annotation according to the 370 annotation's definition. That is, an annotation advertised by the 371 server may be attached to an instance of a data node defined in any 372 YANG module that is implemented by the server. 374 Depending on its semantics, an annotation may have an effect only in 375 certain data trees and/or on instances of specific data nodes types. 377 A client MUST NOT add a specific annotation to data node instances if 378 the server didn't advertise it. 380 Due care has to be exercised when introducing annotations in network 381 management systems in order to avoid interoperability problems and 382 software failures caused by a client that does not understand the 383 annotations' semantics. Generally, it is safe for a server to use 384 annotations in the following cases: 386 o An annotation is an integral part of a built-in or negotiated 387 protocol capability. 389 o An annotation contains auxiliary information that is not critical 390 for protocol operation. 392 o The client explicitly asks the server, e.g., via a parameter of a 393 protocol operation request, for including an annotation in the 394 response. 396 5. The Encoding of Annotations 398 XML attributes are a natural choice for encoding metadata in XML 399 instance documents. For JSON [RFC7159], there is no generally 400 established method for encoding metadata. This document thus 401 introduces a special encoding method that is consistent with the JSON 402 encoding of YANG data node instances as defined 403 in [I-D.ietf-netmod-yang-json]. 405 5.1. XML Encoding 407 Metadata annotations are added to XML-encoded instances of YANG data 408 nodes as XML attributes according to these rules: 410 o The local name of the attribute SHALL be the same as the name of 411 the annotation specified in the argument of the corresponding 412 "md:annotation" statement. 414 o The namespace of the attribute SHALL be identified by the URI that 415 appears as the argument of the "namespace" statement in the YANG 416 module where the annotation is defined. It is RECOMMENDED that 417 the prefix specified by the "prefix" statement in the same module 418 is used in the qualified name of the attribute. 420 o The attribute value SHALL be encoded in the same way as the value 421 of a YANG leaf instance having the same type, 422 see [I-D.ietf-netmod-rfc6020bis], sec. 9. 424 For example, the "last-modified" annotation defined in Section 3.1 425 may be encoded as follows: 427 429 ... 430 432 5.2. JSON Encoding 434 The JSON metadata encoding defined in this section has the following 435 properties: 437 1. The encoding of YANG data node instances as defined in 438 [I-D.ietf-netmod-yang-json] does not change. 440 2. Namespaces of metadata annotations are encoded in the same way as 441 namespaces of YANG data node instances, see 442 [I-D.ietf-netmod-yang-json]. 444 5.2.1. Metadata Object and Annotations 446 All metadata annotations assigned to a YANG data node instance are 447 encoded as members (name/value pairs) of a single JSON object, 448 henceforth denoted as the metadata object. The placement and name of 449 this object depends on the type of the data node as specified in the 450 following subsections. 452 The name of a metadata annotation (as a member of the metadata 453 object) has the following ABNF syntax [RFC5234], where the production 454 for "identifier" is defined in sec. 13 of 455 [I-D.ietf-netmod-rfc6020bis] 457 annotation-name = identifier ":" identifier 459 where the left identifier is the name of the YANG module in which the 460 annotation is defined, and the identifier on the right is the name of 461 the annotation specified in the argument of the corresponding 462 "md:annotation" statement. 464 Note that unlike member names of YANG data node instances in JSON 465 encoding (see sec. 4 in [I-D.ietf-netmod-yang-json]), for annotations 466 the explicit namespace identifier (module name) must always be 467 present. 469 The value of a metadata annotation SHALL be encoded in exactly the 470 same way as the value of a YANG leaf node having the same type as the 471 annotation, see [I-D.ietf-netmod-yang-json], sec. 6. 473 5.2.2. Adding Annotations to Anydata, Container and List Entries 475 For a data node instance that is encoded as a JSON object (i.e., a 476 container, list entry, or anydata node), the metadata object is added 477 as a new member of that object with the name "@". 479 Examples: 481 o "cask" is a container or anydata node: 483 "cask": { 484 "@": { 485 "example-last-modified:last-modified": 486 "2015-09-16T10:27:35+02:00" 487 }, 488 ... 489 } 491 o "seq" is a list whose key is "name", annotation "last-modified" is 492 added only to the first entry: 494 "seq": [ 495 { 496 "@": { 497 "example-last-modified:last-modified": 498 "2015-09-16T10:27:35+02:00" 499 }, 500 "name": "one", 501 ... 502 }, 503 { 504 "name": "two", 505 ... 506 } 507 ] 509 5.2.3. Adding Annotations to Anyxml and Leaf Instances 511 For an anyxml or leaf instance, the metadata object is added as a 512 sibling name/value pair whose name is the symbol "@" concatenated 513 with the name of the leaf or anyxml member that is being annotated. 514 The namespace part (module name) is included if and only if it is in 515 the name of the annotated member. 517 Examples: 519 o "flag" is a leaf node of the "boolean" type defined in module 520 "foo", and we assume the namespace name has to be expressed in its 521 JSON encoding: 523 "foo:flag": true, 524 "@foo:flag": { 525 "example-last-modified:last-modified": 526 "2015-09-16T10:27:35+02:00" 527 } 529 o "stuff" is an anyxml node: 531 "stuff": [1, null, "three"], 532 "@stuff": { 533 "example-last-modified:last-modified": 534 "2015-09-16T10:27:35+02:00" 535 } 537 5.2.4. Adding Annotations to Leaf-list Entries 539 For a leaf-list entry, which is represented as a JSON array with 540 values of a primitive type, annotations may be assigned to one or 541 more entries by adding a name/array pair as a sibling of the leaf- 542 list entry, where the name is symbol "@" concatenated with the name 543 of the leaf-list that is being annotated, and the value is a JSON 544 array whose i-th element is the metadata object with annotations 545 assigned to the i-th entry of the leaf-list entry, or null if the 546 i-th entry has no annotations. 548 Trailing null values in that array, i.e., those following the last 549 non-null metadata object, MAY be omitted. 551 For example, in the following leaf-list instance with four entries, 552 the "last-modified" annotation is added to the second and third entry 553 in the following way: 555 "bibliomod:folio": [6, 3, 7, 8], 556 "@bibliomod:folio": [ 557 null, 558 { "example-last-modified:last-modified": 559 "2015-06-18T17:01:14+02:00" 560 }, 561 { "example-last-modified:last-modified": 562 "2015-09-16T10:27:35+02:00" 563 } 564 ] 566 6. Representing Annotations in DSDL Schemas 568 [RFC6110] defines the standard mapping of YANG data models to 569 Document Schema Definition Languages (DSDL) [ISO.19757-1]. This 570 section specifies the mapping for the extension statement 571 "md:annotation" (Section 7), which enables validation of XML instance 572 documents containing metadata annotations. 574 The first step of the DSDL mapping procedure, i.e., the 575 transformation of the YANG data model to the hybrid schema (see 576 sec. 6 in [RFC6110]), is modified as follows: 578 1. If the data model contains at least one "md:annotation" 579 statement, then a RELAX NG named pattern definition MUST be added 580 as a child of the root element in the hybrid 581 schema. It is RECOMMENDED to use the name "__yang_metadata__" 582 for this named pattern. 584 2. A reference to the named pattern described in item 1 MUST be 585 included as a child of every pattern that 586 corresponds to an anydata, container, leaf, leaf-list or list 587 data node. 589 3. Every metadata annotation definition in the form 591 md:annotation ARGUMENT { 592 ... 593 } 595 is mapped to the following RELAX NG pattern: 597 598 599 ... 600 601 603 where PREFIX is the prefix bound to the namespace URI of the YANG 604 module that contains the "md:annotation" statement. The above 605 pattern SHALL be inserted as a child of the named pattern 606 described in item 1. 608 4. Substatements of "md:annotation" SHALL be mapped to children of 609 the "rng:attribute" pattern exactly as described in sec. 10 of 610 [RFC6110]. 612 For example, the named pattern (item 1), when constructed only for 613 the "last-modified" annotation, will have the following definition: 615 616 617 618 619 620 621 623 Every "rng:element" pattern that corresponds to an anydata, 624 container, leaf, list or leaf-list data node will then contain a 625 reference to the above named pattern, for example 627 628 629 ... 630 632 Note that it is not necessary to use such a reference for 633 "rng:element" patterns corresponding to anyxml data nodes because 634 they already permit any XML attributes to be attached to their 635 instances. 637 The second step of the DSDL mapping procedure, i.e., the 638 transformation of the hybrid schema to RELAX NG, Schematron and DSRL 639 schemas, is unaffected by the inclusion of "md:annotation". 641 7. Metadata YANG Module 643 RFC Editor: In this section, replace all occurrences of 'XXXX' with 644 the actual RFC number and all occurrences of the revision date below 645 with the date of RFC publication (and remove this note). 647 RFC Editor: Also please replace all occurrences of 'RFC 6020bis' with 648 the actual RFC number that will be assigned to 649 [I-D.ietf-netmod-rfc6020bis]. 651 file "ietf-yang-metadata@2016-03-11.yang" 653 module ietf-yang-metadata { 655 namespace "urn:ietf:params:xml:ns:yang:ietf-yang-metadata"; 657 prefix "md"; 659 organization 660 "IETF NETMOD (NETCONF Data Modeling Language) Working Group"; 662 contact 663 "WG Web: 664 WG List: 666 WG Chair: Lou Berger 667 669 WG Chair: Juergen Schoenwaelder 670 672 WG Chair: Kent Watsen 673 675 Editor: Ladislav Lhotka 676 "; 678 description 679 "This YANG module defines an extension statement that allows for 680 defining metadata annotations. 682 Copyright (c) 2016 IETF Trust and the persons identified as 683 authors of the code. All rights reserved. 685 Redistribution and use in source and binary forms, with or 686 without modification, is permitted pursuant to, and subject to 687 the license terms contained in, the Simplified BSD License set 688 forth in Section 4.c of the IETF Trust's Legal Provisions 689 Relating to IETF Documents 690 (http://trustee.ietf.org/license-info). 692 This version of this YANG module is part of RFC XXXX 693 (http://tools.ietf.org/html/rfcXXXX); see the RFC itself for 694 full legal notices."; 696 revision 2016-03-11 { 697 description 698 "Initial revision."; 699 reference 700 "RFC XXXX: Defining and Using Metadata with YANG"; 701 } 703 extension annotation { 704 argument name; 705 description 706 "This extension allows for defining metadata annotations in 707 YANG modules. The 'md:annotation' statement can appear only at 708 the top level of a YANG module or submodule, i.e. it becomes a 709 new alternative in the ABNF production rule for 'body-stmts' 710 (sec. 14 in RFC 6020bis). 712 The argument of the 'md:annotation' statement defines the name 713 of the annotation. Syntactically it is a YANG identifier as 714 defined in RFC 6020bis, sec. 6.2. 716 An annotation defined with this extension statement inherits 717 the namespace and other context from the YANG module in which 718 it is defined. 720 Data type of the annotation value is specified in the same way 721 as for a leaf data node using the 'type' statement. 723 Semantics of the annotation and other documentation can be 724 specified using the following standard YANG substatements (all 725 are optional): 'description', 'if-feature', 'reference', 726 'status', and 'units'. 728 A server announces support for a particular annotation by 729 including the module in which the annotation is defined among 730 the advertised YANG modules (e.g., in NETCONF hello message or 731 yang-library). The annotation then can be attached to any 732 instance of data node defined in any YANG module that is 733 advertised by the server. 735 XML and JSON encoding of annotations is defined in 736 RFC XXXX."; 737 } 738 } 740 742 8. IANA Considerations 744 RFC Editor: In this section, replace all occurrences of 'XXXX' with 745 the actual RFC number and all occurrences of the revision date below 746 with the date of RFC publication (and remove this note). 748 This document registers a URI in the "IETF XML registry" [RFC3688]. 749 Following the format in RFC 3688, the following registration has been 750 made. 752 --------------------------------------------------------------------- 753 URI: urn:ietf:params:xml:ns:yang:ietf-yang-metadata 755 Registrant Contact: The NETMOD WG of the IETF. 757 XML: N/A, the requested URI is an XML namespace. 758 --------------------------------------------------------------------- 759 This document registers a YANG module in the "YANG Module Names" 760 registry [RFC6020]. 762 --------------------------------------------------------------------- 763 name: ietf-yang-metadata 764 namespace: urn:ietf:params:xml:ns:yang:ietf-yang-metadata 765 prefix: md 766 reference: RFC XXXX 767 --------------------------------------------------------------------- 769 9. Security Considerations 771 This document introduces a mechanism for defining metadata 772 annotations in YANG modules and attaching them to instances of YANG 773 data nodes. By itself, this mechanism represents no security threat. 774 Security implications of a particular annotation defined using this 775 mechanism MUST be duly considered and documented in the the 776 annotation's definition. 778 An annotation SHOULD be subject to the same or stricter access 779 control rules as the data node instance to which the annotation is 780 attached. 782 10. Acknowledgments 784 The author wishes to thank Andy Bierman, Martin Bjorklund, Benoit 785 Claise, Juergen Schoenwaelder, and Kent Watsen for their helpful 786 comments and suggestions. 788 11. References 790 11.1. Normative References 792 [I-D.ietf-netmod-rfc6020bis] 793 Bjorklund, M., "The YANG 1.1 Data Modeling Language", 794 draft-ietf-netmod-rfc6020bis-11 (work in progress), 795 February 2016. 797 [I-D.ietf-netmod-yang-json] 798 Lhotka, L., "JSON Encoding of Data Modeled with YANG", 799 draft-ietf-netmod-yang-json-09 (work in progress), March 800 2016. 802 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 803 Requirement Levels", BCP 14, RFC 2119, 804 DOI 10.17487/RFC2119, March 1997, 805 . 807 [RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 808 DOI 10.17487/RFC3688, January 2004, 809 . 811 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 812 Specifications: ABNF", STD 68, RFC 5234, 813 DOI 10.17487/RFC5234, January 2008, 814 . 816 [RFC6020] Bjorklund, M., Ed., "YANG - A Data Modeling Language for 817 the Network Configuration Protocol (NETCONF)", RFC 6020, 818 DOI 10.17487/RFC6020, October 2010, 819 . 821 [RFC6110] Lhotka, L., Ed., "Mapping YANG to Document Schema 822 Definition Languages and Validating NETCONF Content", 823 RFC 6110, DOI 10.17487/RFC6110, February 2011, 824 . 826 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 827 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 828 2014, . 830 [W3C.REC-xml-infoset-20040204] 831 Cowan, J. and R. Tobin, "XML Information Set (Second 832 Edition)", World Wide Web Consortium Recommendation REC- 833 xml-infoset-20040204, February 2004, 834 . 836 [W3C.REC-xml-names11-20060816] 837 Bray, T., Hollander, D., Layman, A., and R. Tobin, 838 "Namespaces in XML 1.1 (Second Edition)", World Wide Web 839 Consortium Recommendation REC-xml-names11-20060816, August 840 2006, 841 . 843 11.2. Informative References 845 [I-D.ietf-netconf-restconf] 846 Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF 847 Protocol", draft-ietf-netconf-restconf-09 (work in 848 progress), December 2015. 850 [ISO.19757-1] 851 International Organization for Standardization, "Document 852 Schema Definition Languages (DSDL) - Part 1: Overview", 853 ISO/IEC 19757-1, November 2004. 855 [RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., 856 and A. Bierman, Ed., "Network Configuration Protocol 857 (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, 858 . 860 Appendix A. Change Log 862 RFC Editor: Remove this section upon publication as an RFC. 864 A.1. Changes Between Revisions -05 and -06 866 o Added explanation of why a YANG extension is used rather than a 867 built-in statement. 869 A.2. Changes Between Revisions -04 and -05 871 o Clarification regarding the type of an annotation. 873 A.3. Changes Between Revisions -03 and -04 875 o Added explanation of what "top level of a module" means. 877 A.4. Changes Between Revisions -02 and -03 879 o Section 4 was considerably simplified, also because member names 880 starting with "@" are now permitted by 881 [I-D.ietf-netmod-yang-json]. 883 A.5. Changes Between Revisions -01 and -02 885 o The "type" statement became mandatory. 887 o Terminology section was extended. 889 o The annotation "inactive" defined in the example module was 890 replaced with "last-modified" that is supposedly less 891 controversial. 893 o Introduction now states limitation due to XML attribute 894 properties. 896 o A recommendation was added to define annotations in a module by 897 themselves. 899 o Section "Using Annotations" was added. 901 o An example for "anyxml" was added. 903 o RFC 6241 was moved to informative references. 905 A.6. Changes Between Revisions -00 and -01 907 o Define JSON encoding for annotations attached to 'anydata' nodes. 909 A.7. Changes Between draft-lhotka-netmod-yang-metadata-01 and draft- 910 ietf-netmod-yang-metadata-00 912 o References to RFC 6020 were changed to the 6020bis I-D. 914 o Text about RFC 2119 key words was added to "ietf-yang-metadata" 915 module description. 917 A.8. Changes Between draft-lhotka-netmod-yang-metadata-00 and -01 919 o Encoding of annotations for anyxml nodes was changed to be the 920 same as for leafs. This was necessary because anyxml value now 921 needn't be an object. 923 o It is stated that "md:annotation" statement defines only the 924 syntax of an annotation. 926 o Allowed "if-feature" as a substatement of "md:annotation". 928 Author's Address 930 Ladislav Lhotka 931 CZ.NIC 933 Email: lhotka@nic.cz