04-29-2021 02:43 AM
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
05-06-2021 12:07 PM
Hi,
From the RFC 8072, chap. "2.1 Target Resource":
The target resource MUST identify exactly one resource instance.
Cheers, Toby
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide