Ask Your Question
1

REST API DELETE FLOWS

asked 2015-03-04 18:01:12 -0700

rolecram gravatar image

Hi guys: Two days ago I posted a question about how to delete a group of flows using REST API. The answer was: using cookie. An attribute of a JSON structure.

It was great!!!!

But, to delete a flow using the REST API you have to send an HTTP DELETE, there is not payload, you do not use a JSON structure.

So, How I can specify the cookie in a DELETE post?

Thank you in advance, marcelo

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2015-03-05 11:28:19 -0700

jamoluhrsen gravatar image

updated 2015-03-06 10:31:50 -0700

Marcelo,

you can issue a DELETE with data, the same way you would with a POST. Not sure how you are sending your REST calls, but with curl you would just make the request DELETE (-X delete) and pass the flow data with --data-binary.

I have not tried this with OpenDaylight, but hoping it's as simple as that.

here is the python code. I took it from a library I've used for a different controller platform, trimmed it down for brevity and modified it a bit to hopefully work with OpenDaylight (Bearer header, for example), but I have not tried it. Hopefully you can get it to work:

import urllib2
from urllib2 import HTTPError

def genericREST(method,url,data,xAuthToken,debug=False):
    req = urllib2.Request(url, data)
    try:
        req.get_method=lambda: method
        if xAuthToken != None:
            req.add_header("Bearer",xAuthToken)

        req.add_header("Content-type","application/x-www-form-urlencoded")
        response = urllib2.urlopen(req)
        return response
    except Exception as e:
        return "Error: %s"%e


def deleteREST(url,data,xAuthToken,debug=False):
    return genericREST("DELETE", url, data, xAuthToken, debug)
edit flag offensive delete publish link more

Comments

Hi jamoluhrsen: thank you for your response. But I think it is not as simple. If you have time, take a look to this article: https://groups.google.com/a/openflowhub.org/forum/#!topic/floodlight-dev/CF7_Zwt-WVA Regards, marcelo

rolecram ( 2015-03-05 13:32:00 -0700 )edit

Thanks for the info Marcelo, looks like spec-wise it's not going to work. I do know that some REST utilities will allow it, so if you are not stuck with a tool that disallows it you might get it to work. I can dig up some python code I've used before that does this, if that would be helpful.

jamoluhrsen ( 2015-03-05 15:43:35 -0700 )edit

Jamo, i half remember that Michal gave you a different REST call to delete flows that in Operations table but not Config, i believe that could do it.

Chris O'Shea ( 2015-03-06 01:36:35 -0700 )edit

Jamo & Chris: Thanks a lot. Jamo, if you can, please send me the pyton code you mention. Regards, Marcelo

rolecram ( 2015-03-06 06:15:26 -0700 )edit

Thanks for the reminder Chris. Maybe not totally helpful, but here is the thread: https://lists.opendaylight.org/pipermail/openflowplugin-dev/2014-September/001972.html I was trying to remove a flow that only existed in the operational store. That was with a POST.

jamoluhrsen ( 2015-03-06 10:35:33 -0700 )edit
0

answered 2015-03-05 06:25:46 -0700

Nuno gravatar image

updated 2015-03-08 17:49:34 -0700

I don't know about deleting the flow using cookie. I personally send a request like this which deletes the flow from table and from switch if you specify the node id, table id where the flow is and the flow id.

Something like this:

http://<controller-ip>:8181/restconf/config/opendaylight-inventory:nodes/node/<node id="">/table//flow/<flow id="">

Change the fields between '<>' to your values.

If you want to delete an entire table the procedure is the same and is something like this: http://<controller-ip>:8181/restconf/config/opendaylight-inventory:nodes/node/<node id="">/table/</node></controller-ip>

</flow>
/

Regards, Nuno B.

</node></controller-ip>

edit flag offensive delete publish link more

Comments

Thank you Nuno for your response. But I need to delete a set of flows using the cookie attribute, so, how can I specify this attribute into the URL (perhaps using query parameters?)

rolecram ( 2015-03-05 09:37:44 -0700 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

Follow
2 followers

Stats

Asked: 2015-03-04 18:01:12 -0700

Seen: 1,146 times

Last updated: Mar 08 '15