pyloxi: reduce boilerplate code required for each module

All the important inheritance hierarchies are grouped together in python
modules like "of13.action". Previously creating a new module required 5 code
changes: the `modules` dictionary in lang_python.py, the `roots` dictionary in
codegen.py, a new `generate_*` function in codegen.py, and imports in the
init.py and module.py templates.

The new code gets rid of the `targets` dictionary left over from very old
loxigen. It uses the result of build_ofclasses to determine the set of modules
for a particular openflow version. The only code change required to create a
new module is defining its inheritance root in the `roots` dictionary.
4 files changed
tree: bf99361fe106e4efe6078a88d87d5deaf5828293
  1. .abat-automerge
  2. .build/
  3. .gitignore
  4. .hooks/
  5. AUTHORS
  6. INTERNALS
  7. LoxiGen.mk
  8. Makefile
  9. README.md
  10. TODO
  11. c_gen/
  12. cmdline.py
  13. generic_utils.py
  14. java_gen/
  15. lang_c.py
  16. lang_java.py
  17. lang_python.py
  18. lang_wireshark.py
  19. loxi_front_end/
  20. loxi_globals.py
  21. loxi_ir/
  22. loxi_utils/
  23. loxigen.py
  24. openflow_input/
  25. py_gen/
  26. pyparsing.py
  27. setup.cfg
  28. template_utils.py
  29. tenjin.py
  30. test_data/
  31. utest/
  32. wireshark_gen/
README.md

Introduction

LoxiGen is a tool that generates OpenFlow protocol libraries for a number of languages. It is composed of a frontend that parses wire protocol descriptions and a backend for each supported language (currently C, Python, and Java, with an auto-generated wireshark dissector in Lua on the way).

LoxiGen currently supports OpenFlow Versions 1.0, 1.1, 1.2, and 1.3.1. Versions 1.0 and 1.3.1 are actively used in production. Support for versions 1.1 and 1.2 is considered experimental.

Loxigen is free and open source software. The Loxigen tool itself is licensed under the Eclipse Public License, version 1.0 (EPL), with an exception allowing for the distribution of the generated artifacts under terms of your choice (copyright notices must be retained, see the loxigen.py header for details.)

Prerequisites

Running the unit tests requires nosetests. You can install it via easy_install,

easy_install nose

pip,

pip install nose

or via your distribution's package manager (example for Debian/Ubuntu):

sudo apt-get install python-nose

Nosetests is only required for running the unit tests, not for running LoxiGen itself. We do ask you to install it and use it before submitting pull requests, though.

Running the Java unit tests requires Maven 3: sudo apt-get install maven.

Usage

You can run LoxiGen directly from the repository. There's no need to install it, and it has no dependencies beyond Python 2.7+.

To generate the libraries for all languages:

make

To generate the library for a single language:

make c

The currently supported languages are c, python and java. There is an experimental/partially completed backend that generates a lua wireshark dissector (wireshark).

The generated libraries will be under the loxi_output directory. This can be changed with the LOXI_OUTPUT_DIR environment variable when using the Makefile.

Each generated library comes with its own set of documentation in the standard format for that language. Please see that documentation for more details on using the generated libraries.

Contributing

Please fork the repository on GitHub and send us a pull request. You might also be interested in the INTERNALS file which has notes about how LoxiGen works.

Loxigen comes with a set of internal unit-tests, as well as with a set of tests for the generated artifacts. Be sure to run

make check-all

and correct any problems before submitting a pull request.