...
The following page discusses about two proposed standards for Delta report:
Intention of RFC 9144
RFC 9144 YANG data model that defines RPCs intended to be used in conjunction with NETCONF [RFC6241] or RESTCONF [RFC8040]. These RPCs allow a client to request a server to compare two NMDA datastores and report any differences.
RFC 9144 Data Model and RFC6902 JSON Patch format
The core of the RFC 9144 solution is a new management operation, <compare>, that compares the data tree contents of two datastores. The operation checks whether there are any differences in values or in data nodes that are contained in either datastore and returns any differences as output. The output is returned in the format specified in YANG Patch [RFC8072].
Example Delta generated as part of RFC9144
...
title | Sample delta as per RFC9144 |
---|
collapse | true |
---|
...
Open Questions/Issues/Decisions
Questions/Issues | Notes | Decisions |
---|
- Are there any major advantages of using RFC 9144?
- Does it have major differences when compared to RFC6902?
- Can it be modified as per requirements of CPS? For example, using xpath format.
| Both RFC have their pros and cons. - RFC 6902 thrives with its simple approach but lacks proper categorization of data.
- RFC 9144 benefits because of proper categorization of data and detailed information provided as part of the report. But in doing so it complicates things by making it mandatory to persist the delta and adding and "edit-id" field to identify each delta report entity uniquely. And this approach does not report the paths of individual data nodes that changed, instead it reports only one path that was sent as part of request.
| CPS delta report takes inspiration from both RFCs and cherry pics the best of both worlds to achieve its goals. - Keeping the simplicity in mind the Delta report will only contain 4 fields:
- action, xpath, source-data and target-data.
- The operation field present in both RFCs is replaced with "action" field because in CPS we want to report the action that was performed on the data.
- The JSON path is replaced with xpath as CPS is based around xpaths. And the delta report will have the xpaths of every data node changed.
- To properly categorize the data, we take the source-data and target-data fields from RFC 9144, this provides better data visualization over a combined field of "values" defined in RFC 6902.
- Persisting of delta report is not needed in case of CPS.
|
The documentation of RFC 9144 defines a POST operation to find the delta. The reason for this is, according to the approach both source and target data are sent as JSON payload (as seen in source and target fields).
| Code Block |
---|
title | Sample POST request from RFC9144 |
---|
collapse | true |
---|
| POST /restconf/operations/ietf-nmda-compare:compare HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
Accept: application/yang-data+json
{ "ietf-nmda-compare:input" : {
"source" : "ietf-datastores:source",
"target" : "ietf-datastores:target",
"report-origin" : null,
"xpath-filter |
|
...
...
...
...
| - The first Delta API does not require any payload to be sent as it uses 2 anchors and data stored under them to generate the delta. Hence it will be a GET API.
- The second Delta API is going to generate delta between an anchor and JSON payload. Hence following the best practice, the second API will be a POST operation.
|
- RFC 9144 defines a model which will be helpful when persisting the Delta Report,
- But if we go with the approach where the generated delta is not persisted then what will be the benefit of using the model?
| | CPS does not require persisting of the delta generated. So, only a few key points from this RFC are taken into consideration. Such as categorization of data as source and target data. |
Intention of RFC 9144
RFC 9144 model defines Remote Procedure Calls (RPCs) intended to be used in conjunction with NETCONF or RESTCONF. These RPCs allow a client to request a server to compare two NMDA datastores and report any differences.
RFC 9144 Data Model and RFC6902 JSON Patch format
- The core of the RFC 9144 solution is a new operator, <compare>, that compares the data tree contents of two datastores. The operation checks whether there are any differences in values or in data nodes that are contained in either datastore and returns any differences as output. The output is returned in the format specified in YANG Patch [RFC8072].
- The RFC6902 approach of Delta generation follows the JSON patch format. A JSON Patch document represents an array of objects, where each object contains exactly one operation, path and associated values. The operation can have following values: add, remove, replace, move, copy and test. The path represents the JSON path and the values contain the difference in source and target values.
Brief summary of JSON patch can be found in the following page: CPS Delta: Conventions to be used for Delta Report
Example Delta generated as part of RFC9144 | Example JSON Patch document, transferred in an HTTP PATCH request: |
---|
Code Block |
---|
title | Sample delta as per RFC9144 |
---|
collapse | true |
---|
| { "ietf-nmda-compare:output" : {
"differences" : {
"ietf-yang-patch:yang-patch" : {
"patch-id" : "interface status",
"comment" : "diff between intended (source) and operational",
"edit" : [
{
"edit-id" : "1",
"operation" : "replace",
"target" : "/ietf-interfaces:interface=eth0/enabled",
"value" : {
"ietf-interfaces:interface/enabled" : "false"
},
"source-value" : {
"ietf-interfaces:interface/enabled" : "true",
"@ietf-interfaces:interface/enabled" : {
"ietf-origin:origin" : "ietf-origin:learned"
}
}
},
{
"edit-id" : "2",
"operation" : "create",
"target" : "/ietf-interfaces:interface=eth0/description",
"value" : {
"ietf-interface:interface/description" : "ip interface"
}
}
]
}
}
}
} |
|
Code Block |
---|
title | Sample JSON Patch document as per RFC6902 |
---|
collapse | true |
---|
| PATCH /my/data HTTP/1.1
Host: example.org
Content-Length: 326
Content-Type: application/json-patch+json
If-Match: "abc123"
[
{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
] |
|
---|
RFC 9144 example using RESTCONF
The model defines a <compare> operator used in an RPC. The operation takes the following input parameters:
- source: the source datastore. This is comparable to source anchor or source data in CPS Delta feature.
- target: the datastore to be compared against the source datastore. In CPS this will be the target anchor, or the JSON payload sent as part of delta request.
- filter-spec: a path-based filter to specify the data nodes to be compared in a given datastore. This allows a comparison operation to be applied only to a specific part of the datastore that is of interest, such as a particular subtree. This is comparable to xpath in cps.
- all: When set, this parameter indicates that all differences should be included, including differences pertaining to schema nodes that exist in only one of the datastores. When this parameter is not included, a prefiltering step is automatically applied to exclude data from the comparison that does not pertain to both datastores.
- report-origin: this parameter is used to indicate whether to include origin or source data in delta report or not.
The operation provides the following output parameters:
- differences: This parameter contains the list of differences. Those differences are encoded per the YANG Patch data model defined in [RFC8072]. And contain the following details:
- edit-id: unique id given to a delta entity
- operation: the type of operation, i.e add, remove or update
- target-value: data in target datastore
- source-value: data in source datastore
Code Block |
---|
title | Structure of ietf-nmda-compare. Source: RFC9144 |
---|
collapse | true |
---|
|
module: ietf-nmda-compare
rpcs:
+---x compare
|
The approach RFC6902 approach to Delta report generation follows the JSON patch format. A JSON Patch document represents an array of objects, where each object contains exactly one operation, path and associated values. The operation can have following values: add, remove, replace, move, copy and test. The path represents the JSON patch and the values contain the difference in source and target values.
Brief summary of JSON patch can be found in the following page: CPS Delta
Example JSON Patch document, transferred in an HTTP PATCH request:
Code Block |
---|
title | Sample JSON Patch document |
---|
collapse | true |
---|
|
PATCH /my/data HTTP/1.1
Host: example.org
Content-Length: 326
Content-Type: application/json-patch+json
If-Match: "abc123"
[
{ "op": "test", "path": "/a/b/c", "value": "foo" },
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
] |
RFC 9144 example using RESTCONF
The YANG data model defines the <compare> operation as a new RPC. The operation takes the following input parameters:
- source: the source or reference datastore
- target: the datastore to be compared against the source datastore
- filter-spec: a xpath based filter to specify the data nodes to be compared in a given datastore. This allows a comparison operation to be applied only to a specific part of the datastore that is of interest, such as a particular subtree.
- all: When set, this parameter indicates that all differences should be included, including differences pertaining to schema nodes that exist in only one of the datastores. When this parameter is not included, a prefiltering step is automatically applied to exclude data from the comparison that does not pertain to both datastores.
- report-origin: this parameter is used to indicate whether to include origin or source data in delta report or not.
The operation provides the following output parameters:
- differences: This parameter contains the list of differences. Those differences are encoded per the YANG Patch data model defined in [RFC8072].
Code Block |
---|
title | Structure of ietf-nmda-compare. Source: RFC9144 |
---|
collapse | true |
---|
|
module: ietf-nmda-compare
rpcs:
+---x compare
+---w input
| +---w source identityref
| +---w target identityref
| +---w all? empty
| +---w report-origin? empty
| +---w (filter-spec)?
| +--:(subtree-filter)
| | +---w subtree-filter?
| +--:(xpath-filter)
| +---w xpath-filter? yang:xpath1.0 {nc:xpath}?
+--ro output
+--ro (compare-response)?
+--:(no-matches)
| +--ro no-matches? empty
+--:(differences)
+--ro differences
+--ro yang-patch
+--ro patch-id stringw input
| +---w source +--ro comment?identityref
string
| +---w target identityref
| +--ro edit* [edit-id]
-w all? empty
| +---row editreport-idorigin? stringempty
| +---w (filter-spec)?
| +--ro operation:(subtree-filter)
| enumeration
| +---w subtree-filter?
| +---ro target:(xpath-filter)
| target-resource-offset
+---w xpath-filter? yang:xpath1.0 {nc:xpath}?
++--ro point?output
target-resource-offset+--ro (compare-response)?
+--:(no-matches)
| +--ro whereno-matches? empty
enumeration
+--:(differences)
+--ro value?
differences
+--ro source-value? |
RESTCONF Example
Sample YANG Model
Code Block |
---|
title | YANG Model |
---|
collapse | true |
---|
|
container interfaces {yang-patch
description
"Interface parameters.";
list interface {
key "name";
leaf name {
+--ro patch-id type string;
description
"The name of the interface.";
}
+--ro comment? leaf description {string
type string;
description
"A textual description of the interface.";
+--ro edit* [edit-id]
}
leaf enabled {
type boolean;
default "true";
+--ro edit-id descriptionstring
"This leaf contains the configured, desired state of the
interface.";
+--ro operation }
}
} |
Sample Data
Code Block |
---|
title | Intended/Reference Data |
---|
collapse | true |
---|
|
{enumeration
"interfaces": {
"interface": {
"name": "eth0",
+--ro target "enabled": false,
"description": "ip interface"
target-resource-offset
}
}
} |
Code Block |
---|
title | Operational/Comparand/Target Data |
---|
collapse | true |
---|
|
{
"interfaces": {
"interface": {
"name": "eth0",
+--ro point? "enabled": true
target-resource-offset
}
}
} |
Request in RESTCONF
Code Block |
---|
title | POST Request |
---|
collapse | true |
---|
|
POST /restconf/operations/ietf-nmda-compare:compare HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
Accept: application/yang-data+json
{ "ietf-nmda-compare:input" : {
"source" : "ietf-datastores:operational",
"target" : "ietf-datastores:intended",
"report-origin" : null,
"xpath-filter" : "/ietf-interfaces:interfaces"
}
} |
Response in RESTCONF
+--ro where? enumeration
+--ro value?
+--ro source-value? |
RESTCONF Example
Sample Data
Code Block |
---|
title | Source Data |
---|
collapse | true |
---|
|
{
"interfaces" |
Code Block |
---|
title | Response |
---|
collapse | true |
---|
|
HTTP/1.1 200 OK
Date: Thu, 24 Jan 2019 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{ "ietf-nmda-compare:output" : {
"differencesinterface" : {
"ietf-yang-patch:yang-patch" : {name": "eth0",
"patch-idenabled" : "interface status"false,
"commentdescription" : "diff between intended (source) and operational",ip interface"
}
"edit" : [
}
} |
Code Block |
---|
title | Target Data |
---|
collapse | true |
---|
|
{
"interfaces": {
"interface": {
"edit-idname" : "1eth0",
"operationenabled" : "replace",true
}
}
} |
Request in RESTCONF
Code Block |
---|
title | POST Request |
---|
collapse | true |
---|
|
POST /restconf/operations/ietf-nmda-compare:compare HTTP/1.1
Host: example.com
Content-Type: application/yang-data+json
Accept: application/yang-data+json
{ "ietf-nmda-compare:input" : {
"source" : "ietf-datastores:source",
"target" : "ietf-datastores:target",
"report-origin" : null,
"path-filter" : "/ietf-interfaces:interfaces"
}
} |
Response in RESTCONF
Code Block |
---|
title | Response |
---|
collapse | true |
---|
|
HTTP/1.1 200 OK
Date: Thu, 24 Jan 2019 20:56:30 GMT
Server: example-server
Content-Type: application/yang-data+json
{ "ietf-nmda-compare:output" : {
"differences" : {
"target" : "/ietf-interfaces:interface=eth0/enabled",
"value" : {
"ietf-interfaces:interface/enabled" : "false"
},
"source-value" : {
"ietf-interfaces:interface/enabled" : "true",
"@ietf-interfaces:interface/enabled" : {
"ietf-origin:originyang-patch:yang-patch" : "ietf-origin:learned"{
"patch-id" : "interface status",
}
"comment" : "diff between intended (source) }and operational",
"edit" : },[
{
"edit-id" : "21",
"operation" : "createreplace",
"target" : "/ietf-interfaces:interface=eth0/descriptionenabled",
"value" : {
"ietf-interfaceinterfaces:interface/descriptionenabled" : "ip interfacefalse"
},
}
"source-value" : {
]
}
}
}
} |
Open Questions
...
The documentation of RFC 9144 defines a POST operation to find the delta. Does this mean this approach intends to persist the Delta generated to a database? If so will it be an indefinite persistence of delta report or will the delta be removed from storage after a specific time period.
...
title | POST operation as defined in RFC 9144 |
---|
collapse | true |
---|
...
"ietf-interfaces:interface/enabled" : "true",
"@ietf-interfaces:interface/enabled" : {
"ietf-origin:origin" : "ietf-origin:learned"
}
}
},
{
"edit-id" : "2",
"operation" : "create",
"target" : "/ietf- |
...
interfaces:interface=eth0/description",
|
...
...
...
...
...
...
The current approach that is being used for development of Delta feature in CPS is a GET operation with no intention to persist the delta report. It is meant to return the delta in following JSON format.
...
title | Sample delta report format |
---|
collapse | true |
---|
...
...
ietf-interface:interface/description" : " |
...
...
...
...
...
...
...
...
...
...
...
...
...
Decisions
The two RFCs used as reference for the delta feature have their own benefits and instead of following either of them as is, we decided to cherry pick the benefits of both the approaches to have the best suited Delta Report format for CPS.
The overall format of delta report closely resembles the format defined in RFC6902, this is because of the simplicity and minimal approach of this RFC while also providing all the necessary information in the delta report.
- From RFC 6902 the following features have been chosen:
- The fields in delta report will include action, xpath, source-data and target-data.
- From RFC 9144 the following features have been chosen:
- Instead of grouping the changes under one field named "values" as given in RFC 6902, we categorize then under source and target data.
- The first API will be a GET operation as it does not require any payload as part of the request. But the second API will be a POST operation as it needs the user to send a JSON payload.
"action": "DELETE",
"xpath": "/bookstore/categories/[@code=1]",
"payload": {
"code": 1,
"name": "Fiction"
}
},
{
"action": "UPDATE",
"xpath": "/bookstore/categories/[@code=2]",
"payload": {
"name": "Comic"
}
}
]RFC 9144 defines a yang data model which will be helpful when persisting the Delta Report, but if we go with the approach where the delta generated is not persisted then what will be the benefit of following the model as it is?
- Are we following any RFC specifications for PATCH operation?