Setting tag pyplnet-4.3-9
[pyplnet.git] / plnet.py
index f12c173..76e1307 100755 (executable)
--- a/plnet.py
+++ b/plnet.py
@@ -43,7 +43,7 @@ def InitInterfaces(logger, plc, data, root="", files_only=False, program="NodeMa
     failedToGetSettings = False
 
     # NOTE: GetInterfaces/NodeNetworks does not necessarily order the interfaces
-    # returned.  Because 'interface'is decremented as each interface is processed,
+    # returned.  Because 'interface' is decremented as each interface is processed,
     # by the time is_primary=True (primary) interface is reached, the device
     # "eth%s" % interface, is not eth0.  But, something like eth-4, or eth-12.
     # This code sorts the interfaces, placing is_primary=True interfaces first.  
@@ -255,6 +255,7 @@ def InitInterfaces(logger, plc, data, root="", files_only=False, program="NodeMa
 
     # Process ifcfg-$dev changes / additions
     newdevs = []
+    table = 10
     for (dev, details) in devices_map.iteritems():
         (fd, tmpnam) = tempfile.mkstemp(dir=sysconfig)
         f = os.fdopen(fd, "w")
@@ -301,10 +302,7 @@ def InitInterfaces(logger, plc, data, root="", files_only=False, program="NodeMa
         src_route_changed = False
         if ('PRIMARY' not in details and 'GATEWAY' in details and
             details['GATEWAY'] != ''):
-            i = len(dev) - 1
-            while dev[i - 1].isdigit():
-                i -= 1
-            table = 10 + int(dev[i:])
+            table += 1
             (fd, rule_tmpnam) = tempfile.mkstemp(dir=sysconfig)
             os.write(fd, "from %s lookup %d\n" % (details['IPADDR'], table))
             os.close(fd)