cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
845
Views
5
Helpful
1
Replies

[NSO-5.2.2] Restconf Yang-patch

romaincy
Cisco Employee
Cisco Employee

Hello,

I started using the yang-patch feature and I don't really understand why the following request don't work. I have simplified it to show only the edit with an issue but my final goal is to do deletion and merge in the same transaction. Otherwise I could use a simple patch over Restconf.

curl --location --request PATCH 'http://localhost:8000/restconf/data/?dry-run=native' \
--header 'Accept: application/yang-data+json' \
--header 'Content-Type: application/yang-patch+json' \
--header 'Authorization: Basic **************'' \
--data-raw '{
    "ietf-yang-patch:yang-patch": {
        "patch-id": "mtu-configure",
        "edit": [
            {
                "edit-id": "change-mtu-XR_LAB_1",
                "operation": "merge",
                "target": "/tailf-ncs:devices/device=XR_LAB_1/config/tailf-ned-cisco-ios-xr:interface",
                "value": {
                    "tailf-ned-cisco-ios-xr:interface": {
                        "GigabitEthernet": [
                            {
                                "id": "0/0/0/0",
                                "tailf-ned-cisco-ios-xr:mtu": 9216
                            },
                             {
                                "id": "0/0/0/1",
                                "tailf-ned-cisco-ios-xr:mtu": 9216
                            }
                        ]
                    }
                }
            }
        ]
    }
}'

Only this work:

curl --location --request PATCH 'http://localhost:8000/restconf/data/?dry-run=native' \
--header 'Accept: application/yang-data+json' \
--header 'Content-Type: application/yang-patch+json' \
--header 'Authorization: Basic **************' \
--data-raw '{
    "ietf-yang-patch:yang-patch": {
        "patch-id": "mtu-configure",
        "edit": [
            {
                "edit-id": "change-mtu-XR_LAB_1_0.0.0.0",
                "operation": "merge",
                "target": "/tailf-ncs:devices/device=XR_LAB_1/config/tailf-ned-cisco-ios-xr:interface/GigabitEthernet=0%2F0%2F0%2F0/mtu",
                "value": {
                    "tailf-ned-cisco-ios-xr:mtu": "9216"
                }
            },
            {
                "edit-id": "change-mtu-XR_LAB_1_0.0.0.1",
                "operation": "merge",
                "target": "/tailf-ncs:devices/device=XR_LAB_1/config/tailf-ned-cisco-ios-xr:interface/GigabitEthernet=0%2F0%2F0%2F1/mtu",
                "value": {
                    "tailf-ned-cisco-ios-xr:mtu": "9216"
                }
            }
        ]
    }
}'

What are the limitation of yang-patch when it comes to the value field ?

 

PS: I'm using NSO 5.5.2

 

1 Reply 1

ttornkvi
Cisco Employee
Cisco Employee

Hi,

 

From the RFC 8072, chap. "2.1 Target Resource":

 

The target resource MUST identify exactly one resource instance.

 

Cheers, Toby