add --of-version option
This option is used to choose which OpenFlow protocol module is aliased to
"ofp", which the controller and tests import. When we have an OpenFlow protocol
module that works with all versions of OpenFlow we can remove this hack without
changing the command line interface or test API.
diff --git a/oft b/oft
index 20ea660..11e181b 100755
--- a/oft
+++ b/oft
@@ -34,7 +34,6 @@
import oftest
from oftest import config
-import oftest.testutils
import oftest.ofutils
import oftest.help_formatter
@@ -79,6 +78,7 @@
"platform_args" : None,
"platform_dir" : os.path.join(root_dir, "platforms"),
"interfaces" : [],
+ "openflow_version" : "1.0",
# Logging options
"log_file" : "oft.log",
@@ -171,6 +171,8 @@
group.add_option("--platform-dir", type="string", help="Directory containing platform modules")
group.add_option("--interface", "-i", type="interface", dest="interfaces", metavar="INTERFACE", action="append",
help="Specify a OpenFlow port number and the dataplane interface to use. May be given multiple times. Example: 1@eth1")
+ group.add_option("--of-version", "-V", dest="openflow_version", choices=["1.0", "1.1", "1.2"],
+ help="OpenFlow version to use")
parser.add_option_group(group)
group = optparse.OptionGroup(parser, "Logging options")
@@ -343,6 +345,24 @@
logging_setup(config)
logging.info("++++++++ " + time.asctime() + " ++++++++")
+# Pick an OpenFlow protocol module based on the configured version
+# This will go away once we have a single protocol module that
+# can handle all OpenFlow versions.
+if config["openflow_version"] == "1.0":
+ import of10
+ sys.modules["ofp"] = of10
+elif config["openflow_version"] == "1.1":
+ import of11
+ sys.modules["ofp"] = of11
+elif config["openflow_version"] == "1.2":
+ import of12
+ sys.modules["ofp"] = of12
+else:
+ assert(False)
+
+# HACK: testutils.py imports controller.py, which needs the ofp module
+import oftest.testutils
+
# Allow tests to import each other
sys.path.append(config["test_dir"])
diff --git a/src/python/oftest/base_tests.py b/src/python/oftest/base_tests.py
index 343cdf8..5c6c9cf 100644
--- a/src/python/oftest/base_tests.py
+++ b/src/python/oftest/base_tests.py
@@ -12,7 +12,7 @@
from oftest import config
import oftest.controller as controller
import oftest.dataplane as dataplane
-import of10 as ofp
+import ofp
class SimpleProtocol(unittest.TestCase):
"""
diff --git a/src/python/oftest/controller.py b/src/python/oftest/controller.py
index a18168e..d6d2c70 100644
--- a/src/python/oftest/controller.py
+++ b/src/python/oftest/controller.py
@@ -35,7 +35,7 @@
from threading import Thread
from threading import Lock
from threading import Condition
-import of10 as ofp
+import ofp
import ofutils