cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1613
Views
0
Helpful
5
Replies

How to run commands on devices using RESTCONF

Alejandro Madurga Ainoza
Cisco Employee
Cisco Employee

Hi all,

I'm trying to run commands on devices (configurations) using the RESTCONF API, but I'm struggling to find how to execute multi line commands and then do a Dry-Run. I was able to run single line commands, but not commit them.

Any hint here?

 

Best regards,

Alex.

 

5 Replies 5

vleijon
Cisco Employee
Cisco Employee

What do you mean by 'multi-line commands'?

Hi, well I mean something like the load merge on the cli, where we can put a bunch of lines to configure multiple paths of the configuration in one shot.

The PATCH method in RESTCONF does something very similar to what load merge does in the CLI. The body of the message can contain several lines of XML/JSON. This might be what you want to use.

 

Have you tried utilizing 'load merge terminal' ?

rogaglia
Cisco Employee
Cisco Employee

Example of RESTCONF PATCH with multiple deletes in a single command.

 

I have not tried to do "dry-run" with PATCH media type, but I believe you need to add "?dryrun=native" to the URI:

'http://127.0.0.1:{{port_upper}}/restconf/data?dryrun=native' (Please let us know if that works)

 

Roque

 

curl -X PATCH \
  'http://127.0.0.1:{{port_upper}}/restconf/data' \
  -H 'Accept: application/yang-data+json' \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Content-Type: application/yang-patch+json' \
  -H 'Postman-Token: 2a398902-c503-45ab-8dfb-98074171c71d' \
  -H 'cache-control: no-cache' \
  -H 'password: admin' \
  -H 'username: admin' \
  -d '      {
        "ietf-yang-patch:yang-patch" : {
          "patch-id" : "delete-before-start-1",
          "edit" : [
            {
              "edit-id" : "edit1",
              "operation" : "delete",
              "target" : "/mef-legato-services:mef-services"
            },
            {
              "edit-id" : "edit2",
              "operation" : "delete",
              "target" : "/mef-legato-interfaces:mef-interfaces"
            },
      {
              "edit-id" : "edit3",
              "operation" : "delete",
              "target" : "/ietf-network:networks"
            }
          ]
        }
      }'

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: