POX webservice/JSON issue

While trying to enable the openflow.webservice.py and web.webcore.py modules from pox on RedHat 6.4 Linux… I kept receiving the following error…

[root@sdn-A4 Python-2.7.3]# python -u /opt/pox/pox.py --verbose forwarding.l2_pairs web.webcore openflow.webservice
POX 0.2.0 (carp) / Copyright 2011-2013 James McCauley, et al.
Traceback (most recent call last):
 File "/opt/pox/pox/boot.py", line 91, in do_import2
  __import__(name, level=0)
 File "/opt/pox/pox/openflow/webservice.py", line 50, in <module>
from pox.openflow.of_json import *
 File "/opt/pox/pox/openflow/of_json.py", line 111
 _unfix_map = {k:_unfix_null for k in of.ofp_match_data.keys()}
                                  ^
SyntaxError: invalid syntax
Could not import module: openflow.webservice

It was working fine on my MacOSx with Mavericks, but was getting the above error on Red Hat. After looking at the version of pox on both systems… I saw no difference. The only difference was Red Hat was running Python 2.6.6 and MacOSx was running 2.7.3.

The fix? Upgrade Python, BUT do not replace version 2.6.6 in the system path because YUM depends on it.

Run the following commands…

mkdir /opt/Python-273
cd /opt/Python-273
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar -xvzf Python-2.7.3.tgz
yum install gcc
cd Python-2.7.3
./configure
make altinstall
alias python273="/opt/Python-273/Python-2.7.3/python"

Now that python 2.7.3 is installed… just make sure you run POX with the new version alias command.

python273 pox.py

3 thoughts on “POX webservice/JSON issue

  1. Jorge

    Hi Daniel,

    I’m trying to gather information from POX using json…

    My script is like:
    —————————————————————————————————
    #!/usr/bin/env python
    import requests
    import simplejson as json

    url = “http://69.69.69.1:8000/OF/”
    of_command = {‘method’:’get_switches’}
    of_command_json = json.dumps(of_command, separators=(‘,’,’:’))
    headers = {‘Content-type’:’application/x-www-form-urlencoded’}
    r = requests.post(url,data=of_command_json,headers=headers)

    data = r.json()
    print len(data)
    print json.dumps(data,indent=4, separators=(‘,’, ‘:’))
    ——————————————————————————————-

    But never get information back from POX (apart from 200 result code)… Did you manage to get ir work?

    Any help will be more than valuable.

    Kind regards,
    Jorge

    Reply
    1. Daniel Fredrick Post author

      Hi Jorge,

      I started messing around with it with MiniNet and using curl from my mac. I wasn’t able to get anything to work except for the provided curl example. Maybe try using get instead of post?

      Good Luck,

      I will try to get back to it soon, I will post something with my results.

      -Dan

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *