YANG Patch Media TypeYumaWorksandy@yumaworks.comTail-f Systemsmbj@tail-f.comJuniper Networkskwatsen@juniper.net
This document describes a method for applying patches
to configuration datastores using data defined with the YANG
data modeling language.
There is a need for standard mechanisms to patch
datastores defined in ,
which contain conceptual data that conforms to
schema specified with YANG .
An "ordered edit list"
approach is needed to provide RESTCONF client developers with
more precise RESTCONF client control of the edit procedure than
existing mechanisms found in .
This document defines a media type for a YANG-based editing
mechanism that can be used with the HTTP PATCH method .
YANG Patch is designed to support the RESTCONF protocol,
defined in .
This document only specifies the use of the YANG Patch media type
with the RESTCONF protocol.
It may be possible to use YANG Patch with other protocols
besides RESTCONF. This is outside the scope of this document.
For any protocol which supports the YANG Patch media type,
if the entire patch document cannot be successfully applied,
then the server MUST NOT apply any of the changes.
It may be possible to use YANG Patch with datastore
types other than a configuration datastore.
This is outside the scope of this document.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
.
The following terms are defined in :
configuration data
datastore
configuration datastore
protocol operation
running configuration datastore
state data
user
The following terms are defined in :
header field
message-body
query
request URI
The following terms are defined in :
method
request
resource
The following terms are defined in :
container
data node
leaf
leaf-list
list
RPC operation (now called protocol operation)
The following terms are defined in :
application/yang-data+xml
application/yang-data+json
data resource
datastore resource
patch
RESTCONF capability
target resource
YANG data template
The following terms are used within this document:
RESTCONF client: a client which implements the RESTCONF protocol.
RESTCONF server: a server which implements the RESTCONF protocol.
YANG Patch: a conceptual edit request using the "yang‑patch"
YANG Patch template, defined in .
In HTTP, refers to a PATCH method where a representation uses
either the media type "application/yang‑patch+xml" or "application/yang‑patch+json".
YANG Patch Status: a conceptual edit status response using
the YANG "yang‑patch‑status" YANG data template, defined in .
In HTTP, refers to a response message for a PATCH method,
where it has a representation with either the media type
"application/yang‑data+xml" or "application/yang‑data+json".
YANG Patch template: this is similar to a YANG data template, except
it has a representation with the media type "application/yang‑patch+xml"
or "application/yang‑patch+json".
Some protocol message lines within examples throughout the document
are split into multiple lines for display purposes only.
When a line ends with backslash ('\') as the last character,
the line is wrapped for display purposes. It is to be
considered to be joined to the next line by deleting the
backslash, the following line break,
and the leading whitespace of the next line.
A simplified graphical representation of the data model is used in
this document. The meaning of the symbols in these
diagrams is as follows:
Brackets "[" and "]" enclose list keys.
Abbreviations before data node names: "rw" means configuration
data (read-write), "ro" state data (read-only), and "x"
operation resource (executable)
Symbols after data node names: "?" means an optional node and "*"
denotes a "list" and "leaf‑list".
Parentheses enclose choice and case nodes, and case nodes are also
marked with a colon (":").
Ellipsis ("...") stands for contents of subtrees that are not shown.
A "YANG Patch" is an ordered list of edits that are applied
to the target datastore by the RESTCONF server. The specific fields
are defined in the YANG module in .
The YANG Patch operation is invoked
by the RESTCONF client by sending a PATCH method request with
a representation using either the "application/yang‑patch+xml"
or "application/yang‑patch+json" media type. This
message-body representing the YANG Patch input parameters MUST be present.
YANG Patch has some features that are not possible with
the PATCH method in RESTCONF:
YANG Patch allows multiple sub-resources to be edited
within the same PATCH method.
YANG Patch allows more precise edit operations than RESTCONF.
There are 7 operations supported
(create, delete, insert, merge, move, replace, remove).
YANG Patch uses an edit list with an explicit processing order.
The edits are processed in client-specified order, and error
processing can be precise even when multiple errors occur
in the same patch request.
The YANG Patch "patch‑id" may be useful for debugging,
and SHOULD be present in any audit audit logging records
generated by the RESTCONF server for a patch.
The RESTCONF server MUST return the Accept-Patch header field
in an OPTIONS response, as specified in ,
which includes the media type for YANG Patch.
This is needed by a client to determine the
message encoding formats supported by the server
(e.g., XML, JSON, or both). An example is shown
in Figure 1.
Note that YANG Patch can only edit data resources.
The PATCH method cannot be used to replace the datastore resource.
Although the "ietf‑yang‑patch" YANG module is written using
YANG version 1.1 , an implementation
of YANG Patch can be used with content defined in YANG version 1
as well.
A YANG Patch can be encoded in XML format according
to . It can also be encoded in
JSON, according to "JSON Encoding of Data Modeled with YANG"
. If any meta-data needs to
be sent in a JSON message, it is encoded according
to "Defining and Using Metadata with YANG" .
The YANG Patch operation uses the RESTCONF target resource URI
to identify the resource that will be patched.
This can be the datastore resource itself, i.e., "{+restconf}/data",
to edit top-level configuration data resources,
or it can be a configuration data resource within the
datastore resource, e.g., "{+restconf}/data/ietf‑interfaces:interfaces",
to edit sub-resources within a top-level configuration
data resource.
The target resource MUST identify exactly one resource instance.
If more than one resource instance is identified, then
the request MUST NOT be processed, and
a "400 Bad Request" error response MUST be sent by the server.
If the target resource does not identify any existing
resource instance then
the request MUST NOT be processed, and
a "404 Not Found" error response MUST be sent by the server.
Each edit with a YANG Patch identifies a target data node
for the associated edit. This is described in .
A YANG patch is optionally identified by a unique "patch‑id" and it
may have an optional comment. A patch is an ordered collection of
edits. Each edit is identified by an "edit‑id" and it has an edit
operation (create, delete, insert, merge, move, replace, remove)
that is applied to the target resource. Each edit can be applied
to a sub-resource "target" within the target resource.
If the operation is "insert" or "move", then the "where"
parameter indicates how the node is inserted or moved.
For values "before" and "after", the "point" parameter
specifies the data node insertion point.
The merge, replace, create, delete, and remove edit operations
have the exact same meaning
as defined for the "operation" attribute in section 7.2 of .
Each edit within a YANG Patch MUST identify exactly one data
resource instance.
If an edit represents more than one resource instance, then
the request MUST NOT be processed, and
a "400 Bad Request" error response MUST be sent by the server.
If the edit does not identify any existing resource instance,
and the operation for the edit is not "create", then
the request MUST NOT be processed, and
a "404 Not Found" error response MUST be sent by the server.
A "yang‑patch‑status" response MUST be sent by the server identifying
the edit(s) that are not valid.
YANG Patch does not provide any access to specific datastores.
It is an implementation detail how a server processes an edit
if it is co-located with a NETCONF server that does provide
access to individual datastores. A complete datastore cannot
be replaced in the same manner as provided by
the "copy‑config" operation defined in section 7.3 of .
Only the specified nodes in a YANG Patch are affected.
A message-body representing the YANG Patch is sent
by the RESTCONF client to specify the edit operation request.
When used with the HTTP PATCH method, this data is identified
by the YANG Patch media type.
YANG tree diagram for "yang‑patch" Container
A message-body representing the YANG Patch Status is returned
to the RESTCONF client to report the detailed status of the edit operation.
When used with the HTTP PATCH method, this data is identified
by the YANG Patch Status media type, and the syntax specification
is defined in .
YANG tree diagram for "yang‑patch‑status" Container:
The target data node for each edit operation is determined
by the value of the target resource in the request and the
"target" leaf within each "edit" entry.
If the target resource specified in the request URI identifies
a datastore resource, then the path string in the "target" leaf
is treated as an absolute path expression identifying the
target data node for the corresponding edit. The first node specified
in the "target" leaf is a top-level data node defined within
a YANG module. The "target" leaf MUST NOT contain a single
forward slash "/", since this would identify the datastore resource,
not a data resource.
If the target resource specified in the request URI identifies
a configuration data resource, then the path string in the "target" leaf
is treated as a relative path expression. The first node specified
in the "target" leaf is a child configuration data node of
the data node associated with the target resource.
If the "target" leaf contains a single
forward slash "/", then the target data node is
the target resource data node.
Each YANG patch edit specifies one edit operation on
the target data node. The set of operations is aligned
with the NETCONF edit operations, but also includes
some new operations.
OperationDescriptioncreatecreate a new data resource if it does not already exist or errordeletedelete a data resource if it already exists or errorinsertinsert a new user-ordered data resourcemergemerge the edit value with the target data resource; create if it does not already existmovere-order the target data resourcereplacereplace the target data resource with the edit valueremoveremove a data resource if it already exists
If a YANG Patch is completed without errors, the RESTCONF server MUST
return a "yang‑patch‑status" message with a global-status choice
set to 'ok'.
The RESTCONF server will save the running datastore to non-volatile storage
if it supports non-volatile storage, and if the running datastore
contents have changed, as specified in .
Refer to for a example of a successful
YANG Patch response.
If a well-formed, schema-valid YANG Patch message is received, then
the RESTCONF server will process the supplied edits in ascending order.
The following error modes apply to the processing of this edit list:
If a YANG Patch is completed with errors, the RESTCONF server SHOULD
return a "yang‑patch‑status" message. It is possible (e.g., within
a distributed implementation), that an invalid request will
be rejected before the YANG patch edits are processed. In this case,
the server MUST send the appropriate HTTP error response instead.
Refer to for a example of an error
YANG Patch response.
A URI is defined to identify the YANG Patch extension to
the base RESTCONF protocol. If the RESTCONF server supports the
YANG Patch media type, then the "yang‑patch" RESTCONF capability
defined in MUST be present in the
"capability" leaf-list in the
"ietf‑restconf‑monitoring" module defined in .
The "ietf‑yang‑patch" module defines conceptual definitions
with the 'yang‑data' extension statements,
which are not meant to be implemented
as datastore contents by a RESTCONF server.
The "ietf‑restconf" module from
is used by this module for the 'yang‑data' extension definition.
RFC Ed.: update the date below with the date of RFC publication and
remove this note.
<CODE BEGINS> file "ietf-yang-patch@2016-11-09.yang"<CODE ENDS>
This document registers one URI as a namespace in the IETF XML registry
. Following the format in RFC 3688, the following
registration is requested to be made.
This document registers one YANG module in the YANG Module Names
registry .
This document registers one capability identifier in
"RESTCONF Protocol Capability URNs" registry
The YANG Patch media type does not introduce any significant
new security threats, beyond what is described in
.
This document defines edit processing instructions for a
variant of the PATCH method, as used within the RESTCONF protocol.
Message integrity is provided by the RESTCONF protocol.
There is no additional capability to validate that a patch
has not been altered.
It may be possible to use YANG Patch with other protocols
besides RESTCONF, which is outside the scope of this document.
For RESTCONF, both the client and server MUST be authenticated,
according to section 2 of .
It is important for RESTCONF server implementations to carefully
validate all the edit request parameters in some manner.
If the entire YANG Patch request cannot be completed,
then no configuration changes to the system are done.
A PATCH request MUST be applied atomically, as specified
in section 2 of .
A RESTCONF server implementation SHOULD attempt to prevent
system disruption due to incremental processing of the
YANG Patch edit list. It may be possible to construct
an attack on such a RESTCONF server, which relies on the
edit processing order mandated by YANG Patch.
A server SHOULD apply only the fully validated configuration
to the underlying system. For example, an edit list
which deleted an interface and then recreated it
could cause system disruption if the edit list was incrementally
applied.
A RESTCONF server implementation SHOULD attempt to prevent
system disruption due to excessive resource consumption
required to fulfill YANG Patch edit requests.
It may be possible to construct
an attack on such a RESTCONF server, which attempts to
consume all available memory or other resource types.
Key words for use in RFCs to Indicate Requirement LevelsHarvard UniversityIn many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, collaborative, hypertext information systems. This document provides an overview of HTTP architecture and its associated terminology, defines the "http" and "https" Uniform Resource Identifier (URI) schemes, defines the HTTP/1.1 message syntax and parsing requirements, and describes related security concerns for implementations.
Hypertext Transfer Protocol (HTTP/1.1): Semantics and ContentThe Hypertext Transfer Protocol (HTTP) is a stateless \%application- level protocol for distributed, collaborative, hypertext information systems. This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header fields, along with the payload of messages (metadata and body content) and mechanisms for content negotiation.The IETF XML Registry
This document describes an IANA maintained registry for IETF standards which use Extensible Markup Language (XML) related items such as Namespaces, Document Type Declarations (DTDs), Schemas, and Resource Description Framework (RDF) Schemas.
PATCH Method for HTTPSeveral applications extending the Hypertext Transfer Protocol (HTTP) require a feature to do partial resource modification. The existing HTTP PUT method only allows a complete replacement of a document. This proposal adds a new HTTP method, PATCH, to modify an existing HTTP resource. [STANDARDS-TRACK]Network Configuration Protocol (NETCONF)YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)YANG is a data modeling language used to model configuration and state data manipulated by the Network Configuration Protocol (NETCONF), NETCONF remote procedure calls, and NETCONF notifications. [STANDARDS TRACK]The YANG 1.1 Data Modeling LanguageYANG is a data modeling language used to model configuration data, state data, Remote Procedure Calls, and notifications for network management protocols. This document describes the syntax and semantics of 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. There are a small number of backward incompatibilities from YANG version 1. This document also specifies the YANG mappings to the Network Configuration Protocol (NETCONF).RESTCONF ProtocolYumaWorksTail-f SystemsJuniper NetworksJSON Encoding of Data Modeled with YANGThis document defines encoding rules for representing configuration data, state data, parameters of Remote Procedure Call (RPC) operations or actions, and notifications defined using YANG as JavaScript Object Notation (JSON) text.Defining and Using Metadata with YANGThis document defines a YANG extension that allows for defining metadata annotations in YANG modules. The document also specifies XML and JSON encoding of annotations and other rules for annotating instances of YANG data nodes.
The JavaScript Object Notation (JSON) Data Interchange Format
JavaScript Object Notation (JSON) is a lightweight, text-based, language-independent data interchange format. It was derived from the ECMAScript Programming Language Standard. JSON defines a small set of formatting rules for the portable representation of structured data.
This document removes inconsistencies with other specifications of JSON, repairs specification errors, and offers experience-based interoperability guidance.
Extensible Markup Language (XML) 1.0 (Fifth Edition)
The authors would like to thank the following people for
their contributions to this document: Rex Fernando.
Contributions to this material by Andy Bierman are based upon work
supported by the The Space & Terrestrial Communications Directorate
(S&TCD) under Contract No. W15P7T-13-C-A616. Any opinions, findings
and conclusions or recommendations expressed in this material are
those of the author(s) and do not necessarily reflect the views of
The Space & Terrestrial Communications Directorate (S&TCD).
The YANG Patch issue tracker can be found here:
https://github.com/netconf-wg/yang-patch/issues
clarifications based on IESG reviews
clarify target resource must exist
fix errors in some examples
change application/yang-patch-xml to application/yang-patch+xml
clarified some section titles
clarified error responses for multiple edit instances
made patch-id field mandatory
referenced NETCONF operation attribute
change application/yang-patch to application/yang-patch-xml
change server to RESTCONF server and remove NETCONF server term
change client to RESTCONF client and remove NETCONF client term
clarified that YANG 1.0 content can be used in a YANG Patch
implementation
clarified more terminology
fixed missing keys in edit examples
added insert list example
change yang-patch+xml to yang-patch
clarify application/yang-patch+json media type
add edit datastore example
change data-resource-offset typedef so it is consistent for XML and JSON
change RFC 7158 reference to RFC 7159 reference
change RFC 2616 reference to RFC 7230 reference
remove unused HTTP terms
remove import-by-revision of ietf-restconf; not needed
change application/yang.patch media type to application/yang-patch
remove application/yang.patch-status media type; use application/yang-data
instead
clarified target datastore and target data node terms
clarified that target leaf can be single forward slash '/'
added Successful edit response handling section
clarified that YANG Patch draft is for RESTCONF protocol only
but may be defined for other protocols outside this document
clarified that YANG Patch draft is for configuration datastores
only but may be defined for other datastore types outside this document
fixed typos
converted YANG module to YANG 1.1
changed anyxml value to anydata value
updated import revision date for ietf-restconf
updated revision date for ietf-yang-patch because import-by-revision date
needed to be changed
changed errors example so a full request and error
response is shown in XML format
fixed error-path to match instance-identifier encoding
for both XML and JSON
added references for YANG to JSON and YANG Metadata drafts
clarified that YANG JSON drafts are used for encoding, not plain JSON
updated reference to RESTCONF
removed NETCONF specific text
changed data-resource-offset typedef from a relative URI
to an XPath absolute path expression
clarified insert operation
removed requirement that edits MUST be applied in ascending order
change SHOULD keep datastore unchanged on error
to MUST (this is required by HTTP PATCH)
removed length restriction on 'comment' leaf
updated YANG tree for example-jukebox library
added usage of restconf-media-type extension to map
the yang-patch and yang-patch-status groupings
to media types
added yang-patch RESTCONF capability URI
Added sub-section for terms used from RESTCONF
filled in security considerations section
Reversed order of change log
Clarified anyxml structure of "value" parameter within
a YANG patch request (github issue #1)
Updated RESTCONF reference
Added note to open issues section to check github instead
Added text requiring support for Accept-Patch header field,
and removed 'Identification of YANG Patch capabilities' open
issue.
Removed 'location' leaf from yang-patch-status grouping
Removed open issue 'Protocol independence' because the
location leaf was removed.
Removed open issue 'RESTCONF coupling' because there is no
concern about a normative reference to RESTCONF.
There may need to be a YANG 1.1 mechanism to allow protocol
template usage (instead of grouping wrapper).
Removed open issue 'Is the delete operation needed'.
It was decided that both delete and remove should remain
as operations and clients can choose which one to use.
This is not an implementation burden on the server.
Removed open issue 'global-errors needed'.
It was decided that they are needed as defined
because the global <ok/> is needed and the special
key value for edit=global error only allows for 1 global error.
Removed open issue 'Is location leaf needed'.
It was decided that it is not needed so this leaf has been removed.
Removed open issue 'Bulk editing support in yang-patch-status'.
The 'location' leaf has been removed so this issue is no longer
applicable.
Removed open issue 'Edit list mechanism'.
Added text to the 'edit' list description-stmt
about how the individual edits must be processed.
There is no concern about duplicate edits which cause
intermediate results to be altered by subsequent edits
in the same edit list.
Created open issues section
Refer to the github issue tracker for any open issues:
https://github.com/netconf-wg/yang-patch/issues
The example YANG module used in this document represents
a simple media jukebox interface. The "example‑jukebox"
YANG module is defined in .
YANG tree diagram for "example‑jukebox" Module:
This section includes RESTCONF examples.
Most examples are shown in JSON encoding , and some
are shown in XML encoding .
The following example shows several songs being added to
an existing album. Each edit contains one song.
The first song already exists, so an error will be
reported for that edit. The rest of the edits were not attempted,
since the first edit failed. The XML encoding is used in this example.
Request from the RESTCONF client:
XML Response from the RESTCONF server:
JSON Response from the RESTCONF server:
The following response is shown in JSON format to highlight the
difference in the "error‑path" object encoding. For JSON, the
instance-identifier encoding in the "JSON Encoding of YANG
Data" draft is used.
The following example shows several songs being added to
an existing album.
Each of 2 edits contains one song.
Both edits succeed and new sub-resources are created
Request from the RESTCONF client:
Response from the RESTCONF server:
The following example shows a song being inserted within
an existing playlist. Song "6" in playlist "Foo‑One" is
being inserted after song "5" in the playlist.
The operation succeeds, so a non-error reply example can be shown.
The following example shows a song being moved within
an existing playlist. Song "1" in playlist "Foo‑One" is
being moved after song "3" in the playlist.
Note that no "value" parameter is needed for a "move" operation.
The operation succeeds, so a non-error reply example can be shown.
Request from the RESTCONF client:
Response from the RESTCONF server:
The following example shows how 3 top-level data nodes from
different modules can be edited at the same time.
Example module "foo" defines leaf X.
Example module "bar" defines container Y, with child leafs A and B.
Example module "baz" defines list Z, with key C and child leafs D and E.
Request from the RESTCONF client:
Response from the RESTCONF server: