]> git.sesse.net Git - nms/commitdiff
Factored out some code into zyxelcommon.py.
authorSteinar H. Gunderson <sesse@samfundet.no>
Thu, 6 Apr 2006 13:04:34 +0000 (13:04 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Thu, 6 Apr 2006 13:04:34 +0000 (13:04 +0000)
zyxel/konfgen.py
zyxel/zyxelcommon.py [new file with mode: 0644]

index ea5a9e20d222be966dc55e8999a2d6095f78dd5d..1e21c2b3097f97e7053ce1fd1294a46bcd4f4bca 100755 (executable)
 p1 = 1
 p2 = 24+1
 
-NETWORK="194.0"
-TRAPHOST="194.0.255.20"
-LOGHOST="194.0.255.20"
-
 #MODE="RAW"
 MODE="minicom"
 
@@ -35,6 +31,7 @@ MODE="minicom"
 import sys
 import os
 import time
+from zyxelcommon import *
 
 sys.stderr = open("/tmp/err","w+")
 #sys.stdout = open("/tmp/out","w+")
@@ -86,25 +83,6 @@ def send(text):
     else: 
         sys.stdout.write(text + "\n")
 
-# No Z-constant for you!
-def retSubnet(sw):
-    (rad,num) = sw
-    if rad <= 7 or (rad == 8 and (sw <= 3 or sw == 6)):
-        return "241"
-    if rad <= 13 or (rad == 14 and sw != 4) or (rad == 15 and sw <= 3):
-        return "242"
-    if rad <= 22 or (rad == 23 and sw >= 4) or (rad == 24 and sw == 4):
-        return "243"
-    if rad <= 29 or (rad == 30 and (sw == 4 or sw == 5)):
-        return "244"
-    return "245"
-
-def retIP(sw):
-    (rad,num) = sw
-    gangefaktor = rad - ((rad - 1) / 2)
-    lopenr = 2 + 6 * gangefaktor + num
-    return NETWORK + ".%s.%s" % (retSubnet(sw), lopenr)
-
 sw = deduceSwitch()
 
 if ((sw[0] % 2) == 0):
diff --git a/zyxel/zyxelcommon.py b/zyxel/zyxelcommon.py
new file mode 100644 (file)
index 0000000..a122140
--- /dev/null
@@ -0,0 +1,23 @@
+NETWORK="194.0"
+TRAPHOST="194.0.255.20"
+LOGHOST="194.0.255.20"
+
+# No Z-constant for you!
+def retSubnet(sw):
+    (rad,num) = sw
+    if rad <= 7 or (rad == 8 and (sw <= 3 or sw == 6)):
+        return "241"
+    if rad <= 13 or (rad == 14 and sw != 4) or (rad == 15 and sw <= 3):
+        return "242"
+    if rad <= 22 or (rad == 23 and sw >= 4) or (rad == 24 and sw == 4):
+        return "243"
+    if rad <= 29 or (rad == 30 and (sw == 4 or sw == 5)):
+        return "244"
+    return "245"
+
+def retIP(sw):
+    (rad,num) = sw
+    gangefaktor = rad - ((rad - 1) / 2)
+    lopenr = 2 + 6 * gangefaktor + num
+    return NETWORK + ".%s.%s" % (retSubnet(sw), lopenr)
+