]> git.sesse.net Git - nms/blob - zyxel/switchmap.py
Also print VLAN numbers after each switch in the map.
[nms] / zyxel / switchmap.py
1 #! /usr/bin/env python
2
3 from zyxelcommon import *
4 distro_num_switches = [ 0, 0, 0, 0, 0 ];
5
6 print "    ",
7 for sw in range(1,7):
8         print "%9u            " % sw,
9         if sw == 3:
10                 print "   ",
11 print ""
12
13 for row in range(1,75,2):
14         print "\e[37;0m%2u: " % row,
15         for sw in range(1,7):
16                 if (row <= 3 and sw <= 3) or (row >= 69 and (sw == 1 or sw == 6)):
17                         print "%-20s " % "",
18                 else:
19                         ip = retIP((row,sw))
20                         distro = int(retSubnet((row,sw))) - 241
21                         vlan = (distro * 100) + (distro_num_switches[distro] / 5) + 301
22                         distro_num_switches[distro] = distro_num_switches[distro] + 1
23
24                         text = "%s/%u" % (ip, vlan)
25                         
26                         padding1 = "".join(["="] * ((21-len(text))/2))
27                         padding2 = "".join(["="] * ((22-len(text))/2))
28                         print "".join(("\e[30;1m", padding1, retColor((row,sw)), text, "\e[30;1m", padding2)),
29                         
30                 if sw == 3:
31                         print "   ",
32         print ""
33         if row in (17, 33, 49, 67):
34                 print ""