testutils: add openflow_ports()

This function replaces the common boilerplate code that gets a list of port
numbers from the config dictionary and checks that enough ports are available
for the test.

I changed the OF 1.3 tests to use this function.
diff --git a/tests-1.3/match.py b/tests-1.3/match.py
index c8bf51d..c807ee8 100644
--- a/tests-1.3/match.py
+++ b/tests-1.3/match.py
@@ -34,9 +34,7 @@
         dicts mapping from string names (used in log messages) to string
         packet data.
         """
-        ports = sorted(config["port_map"].keys())
-        in_port = ports[0]
-        out_port = ports[1]
+        in_port, out_port = openflow_ports(2)
 
         logging.info("Running match test for %s", match.show())
 
@@ -89,10 +87,7 @@
     Match on ingress port
     """
     def runTest(self):
-        ports = sorted(config["port_map"].keys())
-        in_port = ports[0]
-        out_port = ports[1]
-        bad_port = ports[2]
+        in_port, out_port, bad_port = openflow_ports(3)
 
         match = ofp.match([
             ofp.oxm.in_port(in_port)