Changeset 8227 in genesis for nodes/getrange.py
- Timestamp:
- Aug 4, 2010, 6:51:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nodes/getrange.py
r8188 r8227 9 9 size = 30 10 10 if len(sys.argv) < 2: 11 print "Gebruik: python getrange.py <interlink|subnet> <size>" 12 print "\tdus voor een /28 interlink is het 'python getrange.py interlink 28'" 13 print "\ten voor een /25 subnet is het 'python getrange.py subnet 25'" 11 print "Gebruik: %s <interlink|subnet> <grootte> [aantal]" % sys.argv[0] 12 print "Voorbeelden:" 13 print "\tVoor drie /29 interlinks - '%s interlink 29 3'" % sys.argv[0] 14 print "\tVoor een (1) /24 subnet - '%s subnet 24'" % sys.argv[0] 14 15 exit(1) 15 16 16 17 interlink = sys.argv[1] == 'interlink' 17 18 size = int(sys.argv[2]) 19 try: 20 aantal = int(sys.argv[3]) 21 except (KeyError,IndexError): 22 aantal = 1 18 23 numaddrs = 1 << (32 - size) 19 24 … … 59 64 print "[FOUT] in bestand '%s' regel '%i': %s" % (fname, lineNr, l) 60 65 61 i = 0xffffffffL 66 # Fetching smallest in use IP 67 # XXX: Currently not used for anything 68 i = parseaddr("255.255.255.255") 62 69 for k in bezet.keys(): 63 70 if k < i: 64 71 i = k 65 72 66 i = 0xac100300 67 if not interlink: 68 i = 0xac110000 69 while 1: 70 while bezet.has_key(i): 71 i = i + numaddrs 72 okay = 1 73 for j in range(numaddrs): 74 if bezet.has_key(i + j): 73 # Interlinks are living in special ranges usually 74 if interlink: 75 i = parseaddr("172.16.3.0") 76 else: 77 i = parseaddr("172.17.0.0") 78 79 for n in xrange(aantal): 80 okay = False 81 while not okay: 82 while bezet.has_key(i): 75 83 i = i + numaddrs 76 okay = 0 77 break 78 if okay: 79 break 84 85 # Assume Ok, till we find a already used IP 86 okay = True 87 for j in range(numaddrs): 88 if bezet.has_key(i + j): 89 i = i + numaddrs 90 okay = False 91 break 80 92 81 print "%s/%d:" % (showaddr(i), size), 82 print " en ".join([showaddr(i) for i in range(i + 1, i + numaddrs - 1)]) 93 print "%s/%d:" % (showaddr(i), size), 94 if size > 28: 95 print " en ".join([showaddr(i) for i in range(i + 1, i + numaddrs - 1)]) 96 else: 97 print " en ".join([showaddr(i) for i in range(i + 1, i + 4)]), 98 print "...", 99 print " en ".join([showaddr(i) for i in range(i + numaddrs - 7, i + numaddrs - 4)]) 100 bezet[i] = 1
Note:
See TracChangeset
for help on using the changeset viewer.