support for port ranges in nat extension
Scott Baker [Fri, 15 Aug 2014 00:24:00 +0000 (17:24 -0700)]
planetstack/neutron_extension/1:2013.2.2-0ubuntu1~cloud0/ovs_neutron_plugin.py

index cacf165..b7771f8 100644 (file)
@@ -607,11 +607,22 @@ class OVSNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
             if entry['l4_protocol'] not in valid_protocols:
                 msg = _("nat:forward_ports: invalid protocol (only tcp and udp allowed)")
                 raise q_exc.InvalidInput(error_message=msg)
-            try:
-                l4_port = int(entry['l4_port'])
-            except:
-                msg = _("nat:forward_ports: l4_port must be an integer")
-                raise q_exc.InvalidInput(error_message=msg)
+
+            l4_port = entry['l4_port']
+            if ":" in l4_port:
+                try:
+                    (first, last) = l4_port.split(":")
+                    first = int(first)
+                    last = int(last)
+                except:
+                    msg = _("nat:forward_ports: l4_port range must be integer:integer")
+                    raise q_exc.InvalidInput(error_message=msg)
+            else:
+                try:
+                    l4_port = int(l4_port)
+                except:
+                    msg = _("nat:forward_ports: l4_port must be an integer")
+                    raise q_exc.InvalidInput(error_message=msg)
 
         return forward_ports