10-16-2020 07:52 AM
Options for pushing multiple services in one restconf push.
I was reading over the docs and was thinking about using yang-patch to push multiple services using multiple edits in one commit. Does anybody have any other options they have used to complete this? I think the other option would be to convert the two services into stacked service and control with a parent service.
Thanks
Solved! Go to Solution.
10-26-2020 06:36 AM
10-21-2020 02:23 AM
Hello,
I am not sure if I get your question right but for instance if you want to push 2 instances of the service test defined at the root level you can use the base RESTCONF URL like this:
Before:
admin@scratch# show running-config test
% No entries found.
Request (extracted from local POSTMAN):
curl --location --request PATCH 'http://127.0.0.1:8080/restconf/data' \
--header 'Content-Type: application/yang-data+json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{
"test:test": [
{
"name": 42
},
{
"name": 43
}
]
}'
admin@scratch# show running-config test
test 42
!
test 43
!
10-21-2020 02:28 AM
note - in XML you can use a container data around the multiple services
CURL:
curl --location --request PATCH 'http://127.0.0.1:8080/restconf/data' \
--header 'Content-Type: application/yang-data+xml' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '<data>
<test>
<name>42</name>
<dummy>1.1.1.2</dummy>
</test>
<test>
<name>43</name>
<dummy>1.1.1.3</dummy>
</test>
</data>'
10-21-2020 06:35 AM
Looks like XML will work. I was trying to push two different services from a 3rd party vendor (itential) using JSON to produce a single dry-run for the end-user. Using your example above I found a way to push XML instead of JSON so that will work. The idea was like below, instead of pushing two instances of the test, it would be service-1 and service-2 in the same payload. Thanks
curl --location --request PATCH 'http://127.0.0.1:8080/restconf/data' \ --header 'Content-Type: application/yang-data+xml' \ --header 'Authorization: Basic YWRtaW46YWRtaW4=' \ --data-raw '<data> <service-1> <name>42</name> <dummy>1.1.1.2</dummy> </service-1> <service-2> <name>43</name> <dummy>1.1.1.3</dummy> </service-2> </data>'
10-26-2020 06:36 AM
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