cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
25
Views
0
Helpful
4
Replies
Highlighted
Cisco Employee

REST based multiple DELETEs

Hi all,

My customer is attempting to send multiple DELETEs via REST and running into issues where they’re only able send the delete command via curl one-by-one. They’re running NCS v3.4.1. Is this a product limitation where we cannot feed the delete command a JSON structure to carry out multiple deletes at one go ?

Thanks in advance.

 

We are able to edit multiple sections of tree using REST interface; however, DELETE commands can only be sent in from curl command line, deleting items one at a time. Feature request to be able to feed a DELETE command a JSON structure with multiple tree items so they can all be deleted at once

Everyone's tags (5)
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

Re: REST based multiple DELETEs

You can not do a selective DELETE; you can only a resource and everything under it will be deleted. That is, you can not specify that you want to delete container X and list instance Z and Y in one DELETE. As you noted you can 'create' more than one resource in one go by using PATCH, which merges with existing configuration.

There is talk in RESTCONF to support specifying what operation(merge, delete, create...) you want to do in a 'PATCH' call, similar to NETCONFs edit-config. But this is not something we have in a near future road map for NCS as far as I know.

4 REPLIES 4
Cisco Employee

Re: REST based multiple DELETEs

Please send the REST call that is not succeeding. Hard to know what "multiple deletes " means.

Cisco Employee

Re: REST based multiple DELETEs

Thanks Roque. I’ll get more info from them in the morning but here is what I have from the customer so far (JSON create and delete) for their EVPL service (see their Wiki notes below):

The following is an example of how to create a json structure that covers multiple devices. Please take note of placement of brackets and commas!

curl -v -u xxxx:xxxx -X PATCH -T twodevices.json -H "Content-Type: application/vnd.yang.data+json" http://localhost:8080/api/running?no-networking

twodevices.json file:

{

    "tailf-ncs:devices": {

      "tailf-ncs:device": [

       {

        "name": "sth1-er1",

        "config": {

          "junos:configuration": {

            "interfaces": {

              "interface": [

                {

                  "name": "ge-5/2/7",

                  "description": "NCS testing",

                  "unit": [

                    {

                      "name": "10",

                      "description": "testing",

                      "vlan-id": "10"

                    },

                    {

                      "name": "20",

                      "description": "blah blah",

                      "vlan-id": "20"

                    }

                  ]

                },

                {

                  "name": "ge-5/2/8",

                  "unit": {

                    "name": "10",

                    "description": "vlan 10"

                  }

                }

              ]

            }

          }

        }

      },

      {

        "name": "est1-er1",

        "config": {

          "junos:configuration": {

            "interfaces": {

              "interface": [

                {

                  "name": "ge-2/0/4",

                  "unit": [

                    {

                      "name": "10",

                      "description": "description goes here",

                      "vlan-id": "10"

                    },

                    {

                      "name": "20",

                      "description": "info",

                      "vlan-id": "20"

                    }

                  ]

                },

                {

                  "name": "ge-2/0/9",

                  "unit": {

                    "name": "10",

                    "description": "test test test"

                 }

                }

              ]

            }

         }

       }

     }

   ]

}

}

Here is a sample json structure for an EVPL service on a single device:

{

  "tailf-ncs:devices": {

    "tailf-ncs:device": {

      "ncs:name": "sth1-er1",

      "config": {

        "junos:configuration": {

          "interfaces": {

            "interface": {

              "name": "ge-5/2/7",

              "unit": {

                "name": "5219",

                "description": "VLXX/259066/TWCS - SILVER STAR TELECOM # 260906 [EVPL-S]",

                "encapsulation": "vlan-vpls",

                "bandwidth": "10m",

                "vlan-tags": {

                  "outer": "713",

                  "inner-list": "109"

                },

                "input-vlan-map": {

                   "pop":""

                },

                "output-vlan-map": {

                   "push":""

                }

              }

            }

          },

          "routing-instances": {

            "instance": {

              "name": "VLXX/259066/TWCS",

              "description": "VLXX/259066/TWCS - SILVER STAR TELECOM # 260906 [EVPL-S]",

              "instance-type": "vpls",

              "interface": { "name": "ge-5/2/7.5219" },

              "vrf-target": { "community": "target:4323:389975" },

              "protocols": {

                "vpls": {

                  "site-range": "2",

                  "no-mac-learning":"",

                  "no-tunnel-services":"",

                  "site": {

                    "name": "SITE2",

                    "site-identifier": "2"

                  }

                }

              }

            }

          }

        }

      }

    }

  }

}

Deletion Commands

Deletes need to be provided on the command-line. json file references will not work:

To delete interface ge-5/2/7 :

curl -v -u xxxx:xxxx -H "Accept: application/vnd.yang.data+json" -X DELETE http://localhost:8080/api/running/devices/device/sth1-er1/config/junos:configuration/interfaces/interface/%22ge-5/2/7%22?no-networking

To delete routing-instance VLXX/259066/TWCS :

curl -v -u xxxx:xxxx -H "Accept: application/vnd.yang.data+json" -X DELETE http://localhost:8080/api/running/devices/device/sth1-er1/config/junos:configuration/routing-instances/instance/%22VLXX/259066/TWCS%22?no-networking

Cisco Employee

Re: REST based multiple DELETEs

I'm not an expert on REST but AFAIK this is according to REST:

DELETE - Delete a resource identified by a URI.

Since you can only have one URI per call, you have to make two calls.

If you want to optimize this, I would recommend you looking at the JSON RPC API, there you can concatenate several operations and post them once to the server.

Cisco Employee

Re: REST based multiple DELETEs

You can not do a selective DELETE; you can only a resource and everything under it will be deleted. That is, you can not specify that you want to delete container X and list instance Z and Y in one DELETE. As you noted you can 'create' more than one resource in one go by using PATCH, which merges with existing configuration.

There is talk in RESTCONF to support specifying what operation(merge, delete, create...) you want to do in a 'PATCH' call, similar to NETCONFs edit-config. But this is not something we have in a near future road map for NCS as far as I know.

Content for Community-Ad
August's Community Spotlight Awards