On Wed, 20 Jun 2018 12:11:59 +0900,
Marcio Vinicius de Queiroz Santos wrote:
>
> [1 <multipart/alternative (7bit)>]
> [1.1 <text/plain; UTF-8 (7bit)>]
> Dear,
>
> My Friend is facing difficulties to perform a route deletion using Ryu and
> REST API. So, I'm here to show you the following message from him. Could
> someone help with this case? I'll be very thankfull.
>
> "Hi friends!
>
> I'm trying to delete a route from inside a python program *extract.py*,
> using the simple topology: h1-s1.
> *extract.py* extends *wflow.py*, and this one is a version from the
> *rest_router.py* and *simple_monitor.py* with some modifications.
simple_monitor.py's flow stat handler assumes something on flow match
fields. Flows generated by rest_router.py don't work well there.
> I am using this code to delete a route:
>
> *print(">>>>>>>>>>>>>> EXTRACT.PY", stat.duration_sec)*
> * if stat.duration_sec == 120:*
> * print("changing routes....")*
>
> * url = 'http://localhost:8080/router/0000000000000001
> <http://localhost:8080/router/0000000000000001>'*
> * payload = '{"route_id": "2"}'*
> * res = requests.delete(url, data=payload)*
>
> But it's not working. The messages that I receive are:
>
> *('>>>>>>>>>>>>>> EXTRACT.PY', 120)*
> *changing routes....*
> *Starting new HTTP connection (1): localhost*
>
> After a few seconds I receive:
>
> *(31783) accepted ('127.0.0.1', 55789)*
> *Setting read timeout to None*
> *127.0.0.1 - - [20/Jun/2018 01:26:39] "DELETE /router/0000000000000001
> HTTP/1.1" 200 218 1.001163*
> *"DELETE /router/0000000000000001 HTTP/1.1" 200 109*
> *('>>>>>>>>>>>>>> EXTRACT.PY', 12090)*
> *changing routes....*
> *Starting new HTTP connection (1): localhost*
>
> After a more few seconds I receive:
>
>
> *Setting read timeout to None*
> *(31783) accepted ('127.0.0.1', 55790)*
> *127.0.0.1 - - [20/Jun/2018 01:27:10] "DELETE /router/0000000000000001
> HTTP/1.1" 200 218 1.000890*
> *"DELETE /router/0000000000000001 HTTP/1.1" 200 109*
It seems the delete command has succeeded.
> And then:
>
> *Logged from file wflow.py, line 77*
> *SimpleMonitor13: Exception occurred during handler processing. Backtrace
> from offending handler [_flow_stats_reply_handler] servicing event
> [EventOFPFlowStatsReply] follows.*
> *Traceback (most recent call last):*
> * File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py",
> line 290, in _event_loop*
> * handler(ev)*
> * File "/home/wilson_siqueira/8-berrondo/wflow.py", line 81, in
> _flow_stats_reply_handler*
> * key=lambda flow: (flow.match['in_port'],*
> * File "/home/wilson_siqueira/8-berrondo/wflow.py", line 81, in <lambda>*
> * key=lambda flow: (flow.match['in_port'],*
> * File
> "/usr/local/lib/python2.7/dist-packages/ryu/ofproto/ofproto_v1_3_parser.py",
> line 857, in __getitem__*
> * return dict(self._fields2)[key]*
> *KeyError: 'in_port'*
Flows generated by rest_router.py don't have in_port match field, but
such flows are somehow fed to simple_monitor's flow stats handler.
If you need to use rest_router and simple_monitor together,
the simplest way would be to write your flow stats handler.
> The switch was configured with the script below when I start the controller
> from the first time:
>
> curl -X POST -d '{"address": "10.0.0.2/8"}' http://localhost:8080/router/
> 0000000000000001
> curl -X POST -d '{"destination": "20.0.0.0/8", "gateway": "10.0.0.1"}'
> http://localhost:8080/router/0000000000000001
> curl -X POST -d '{"destination": "30.0.0.0/8", "gateway": "10.0.0.1"}'
> http://localhost:8080/router/0000000000000001
>
>
> When I delete the route manualy it works.
> I don't face the problem when I POST the routes from inside this same
> program (extract.py) with the command below:
>
> *url = 'http://localhost:8080/router/0000000000000001
> <http://localhost:8080/router/0000000000000001>'*
> * payload = '{"destination": "40.0.0.0/8 <http://40.0.0.0/8>",
> "gateway": "10.0.0.1"}'*
> * res = requests.post(url, data=payload)*
>
> It seems that the controller looses its configuration when I try to delete
> a route. "Data is nothing" was one of the messages that I saw when I used
> pdb to trace the problem.
> So what I have to do to delete a route from a python program?"
--
IWAMOTO Toshihiro
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel