OcNOS-SP : NetConf User Guide : OpenDaylight Controller : Patch or Merge Operation
Patch or Merge Operation
In the case of RFC 8040, resources for configuration and operational datastores start /rests/data/.
For example:
GET http://localhost:8181/rests/data/network-topology:network-topology with response of both datastores. It is allowed to use query parameters to distinguish between them.
GET http://localhost:8181/rests/data/network-topology:network-topology?content=config for configuration datastore
GET http://localhost:8181/rests/data/network-topology:network-topology?content=nonconfig for operational datastore.
Also in the case of RFC 8040, if a data node in the path expression is a YANG leaf-list or list node, the path segment has to be constructed by having leaf-list or list node name, followed by an “=” character, then followed by the leaf-list or list value. Any reserved characters must be percent-encoded.
For example:
GET http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf?content=config
Retrieves data from configuration datastore for topology-netconf value of topology list is equivalent to the deprecated request.
A patch request can be used to modify an existing configuration. Currently, only yang-patch (RFC 8072) is supported. The URL would be the same as the above PUT examples.
Using JSON for the body, the headers needed for the request would be:
Accept: application/yang.patch-status+json
content-Type: application/yang.patch+json
(Change the header-type for XML accordingly.)
JSON payload:
content-Type: application/yang.patch+json
{
"ietf-restconf:yang-patch" : {
"patch-id" : "0",
"edit" : [
{
"edit-id" : "edit1",
"operation" : "merge",
"target" : "/", //target value is the module to be configured
"value" : {
### configuration goes here ###
}
}
]
}
}
XML payload:
content-Type: application/yang.patch+xml
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<patch-id>0</patch-id>
<edit>
<edit-id>edit1</edit-id>
<operation>merge</operation>
<target>/ </target> //target value is the module to be configured
<value>
### config goes here ###
</value>
</edit>
</yang-patch>
This example shows a patch operation to edit ip-address for interface using ODL:
PATCH
@
http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=123a/yang-ext:mount/ipi-interface:interfaces/interface=eth3/ipi-if-ip:ipv4
JSON payload:
content-Type: application/yang.patch+json
{
"ietf-restconf:yang-patch": {
"patch-id": "",
"edit": [
{
"edit-id": "edit1",
"operation": "merge",
"target": "/ipi-if-ip:config",
"value": {
"ipi-if-ip:config": {
"primary-ip-addr": "x.x.x.x/24"
}
}
}
]
}
}
XML payload:
content-Type: application/yang.patch+xml
<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<patch-id>0</patch-id>
<edit>
<edit-id>edit1</edit-id>
<operation>merge</operation>
<target>/ipi-if-ip:config</target>
<value>
<config xmlns="http://www.ipinfusion.com/yang/ocnos/ipi-if-ip">
<primary-ip-addr>x.x.x.x/24</primary-ip-addr>
</config>
</value>
</edit>
</yang-patch>
Header for the action:
Last modified date: 08/17/2023