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 string +--ro comment? string +--ro edit* [edit-id] +--ro edit-id string +--ro operation enumeration +--ro target target-resource-offset +--ro point? target-resource-offset +--ro where? enumeration +--ro value? +--ro source-value?
module ietf-nmda-compare { yang-version 1.1; namespace "urn:ietf:params:xml:ns:yang:ietf-nmda-compare"; prefix cmp; import ietf-yang-types { prefix yang; reference "RFC 6991: Common YANG Data Types"; } import ietf-datastores { prefix ds; reference "RFC 8342: Network Management Datastore Architecture (NMDA)"; } import ietf-yang-patch { prefix ypatch; reference "RFC 8072: YANG Patch Media Type"; } import ietf-netconf { prefix nc; reference "RFC 6241: Network Configuration Protocol (NETCONF)"; } organization "IETF NETMOD (Network Modeling) Working Group"; contact "WG Web: <https://datatracker.ietf.org/wg/netmod/> WG List: <mailto:netmod@ietf.org> Author: Alexander Clemm <mailto:ludwig@clemm.org> Author: Yingzhen Qu <mailto:yqu@futurewei.com> Author: Jeff Tantsura <mailto:jefftant.ietf@gmail.com> Author: Andy Bierman <mailto:andy@yumaworks.com>"; description "The YANG data model defines a new operation, <compare>, that can be used to compare NMDA datastores. Copyright (c) 2021 IETF Trust and the persons identified as authors of the code. All rights reserved. Redistribution and use in source and binary forms, with or without modification, is permitted pursuant to, and subject to the license terms contained in, the Revised BSD License set forth in Section 4.c of the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info). This version of this YANG module is part of RFC 9144; see the RFC itself for full legal notices."; revision 2021-12-10 { description "Initial revision."; reference "RFC 9144: Comparison of Network Management Datastore Architecture (NMDA) Datastores"; } /* RPC */ rpc compare { description "NMDA datastore compare operation."; input { leaf source { type identityref { base ds:datastore; } mandatory true; description "The source datastore to be compared."; } leaf target { type identityref { base ds:datastore; } mandatory true; description "The target datastore to be compared."; } leaf all { type empty; description "When this leaf is provided, all data nodes are compared, whether their schema node pertains to both datastores or not. When this leaf is omitted, a prefiltering step is automatically applied that excludes data nodes from the comparison that can occur in only one datastore but not the other. Specifically, if one of the datastores (source or target) contains only configuration data and the other datastore is <operational>, data nodes for the config that is false are excluded from the comparison."; } leaf report-origin { type empty; description "When this leaf is provided, origin metadata is included as part of RPC output. When this leaf is omitted, origin metadata in comparisons that involve <operational> is by default omitted."; } choice filter-spec { description "Identifies the portions of the datastores to be compared."; anydata subtree-filter { description "This parameter identifies the portions of the target datastore to retrieve."; reference "RFC 6241, Section 6."; } leaf xpath-filter { if-feature "nc:xpath"; type yang:xpath1.0; description "This parameter contains an XPath expression identifying the portions of the target datastore to retrieve."; reference "RFC 6991: Common YANG Data Types"; } } } output { choice compare-response { description "Comparison results."; leaf no-matches { type empty; description "This leaf indicates that the filter did not match anything and nothing was compared."; } container differences { description "The list of differences, encoded per RFC 8072 with an augmentation to include source values where applicable. When a datastore node in the source is not present in the target, this can be indicated either as a 'delete' or as a 'remove' as there is no difference between them for the purposes of the comparison."; uses ypatch:yang-patch { augment "yang-patch/edit" { description "Provides the value of the source of the patch, respectively of the source of the comparison, in addition to the target value, where applicable."; anydata source-value { when "../operation = 'delete'" + "or ../operation = 'merge'" + "or ../operation = 'move'" + "or ../operation = 'replace'" + "or ../operation = 'remove'"; description "The anydata 'value' is only used for 'delete', 'move', 'merge', 'replace', and 'remove' operations."; } reference "RFC 8072: YANG Patch Media Type"; } } } } } } }
container interfaces { description "Interface parameters."; list interface { key "name"; leaf name { type string; description "The name of the interface."; } leaf description { type string; description "A textual description of the interface."; } leaf enabled { type boolean; default "true"; description "This leaf contains the configured, desired state of the interface."; } } }
<!--INTENDED--> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>eth0</name> <enabled>false</enabled> <description>ip interface</description> </interface> </interfaces>
<!--OPERATIONAL--> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:or="urn:ietf:params:xml:ns:yang:ietf-origin"> <interface or:origin="or:learned"> <name>eth0</name> <enabled>true</enabled> </interface> </interfaces>
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <compare xmlns="urn:ietf:params:xml:ns:yang:ietf-nmda-compare" xmlns:ds="urn:ietf:params:xml:ns:yang:ietf-datastores"> <source>ds:operational</source> <target>ds:intended</target> <report-origin/> <xpath-filter xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces"> /if:interfaces </xpath-filter> </compare> </rpc>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101"> <differences xmlns="urn:ietf:params:xml:ns:yang:ietf-nmda-compare" xmlns:or="urn:ietf:params:xml:ns:yang:ietf-origin"> <yang-patch> <patch-id>interface status</patch-id> <comment> diff between operational (source) and intended (target) </comment> <edit> <edit-id>1</edit-id> <operation>replace</operation> <target>/ietf-interfaces:interface=eth0/enabled</target> <value> <if:enabled>false</if:enabled> </value> <source-value> <if:enabled or:origin="or:learned">true</if:enabled> </source-value> </edit> <edit> <edit-id>2</edit-id> <operation>create</operation> <target>/ietf-interfaces:interface=eth0/description</target> <value> <if:description>ip interface</if:description> </value> </edit> </yang-patch> </differences> </rpc-reply>
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" } }
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" : { "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" } } ] } } } }