Hi,
I used requests object.

import requests
import json

data1 = { 'port_name': 'eth3', 'type': 'linux-htb', 'max_rate':
'100000000', 'queues': [{'max_rate': '10000000'}, {'min_rate': '80000000'}]}
r1 = requests.post('http://localhost:8080/qos/queue/00007a9ebe04a549',
data=json.dumps(data1))

print "Queues on eth3 :", r1.text

Best
Gandhimathi


On 6 December 2015 at 07:55, Ezzat Zar <ezzar3...@gmail.com> wrote:

> Hello,
>
> I want to post my queue settings in python program and not in terminal
> using curl which Ryu document suggests. How can I do this?
>
> When I use:
>
> curl -X POST -d '{"port_name": "s1-eth1", "type": "linux-htb", "max_rate":
> "1000000", "queues": [{"max_rate": "500000"}, {"min_rate": "800000"}]}'
> http://localhost:8080/qos/queue/0000000000000001
>
> in terminal, it succeeds,
>
> but when I use it in python this way:
>
>     temp = path[i]
>     url = 'http://localhost:8080/qos/queue/'+str(temp).zfill(16)
>     portName = "s"+str(path[i])+"-eth"+str(portList[i])
>     params = urllib.urlencode({
>         "port_name": portName, "type": "linux-htb", "max_rate": "1000000",
> "queues": [{"max_rate": "500000"}, {"min_rate": "800000"}]
>     })
>     response = urllib2.urlopen(url, params).read()
>
> it fails with ValueError: No JSON object could be decoded
>
> I have checked portName & url strings and they are just like when I
> execute the terminal command but I don't know where the error comes from.
>
> Any help is highly appreciated.
>
> Bests.
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Go from Idea to Many App Stores Faster with Intel(R) XDK
> Give your users amazing mobile app experiences with Intel(R) XDK.
> Use one codebase in this all-in-one HTML5 development environment.
> Design, debug & build mobile apps & 2D/3D high-impact games for multiple
> OSs.
> http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
>
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to