- Timestamp:
- Sep 30, 2012, 8:34:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/getrange.py
r10052 r11514 26 26 27 27 28 def get_ranges(interlink, size, aantal): 28 bezet_cache = None 29 def get_ranges(interlink, size, aantal, use_history=False): 30 global bezet_cache 29 31 numaddrs = 1 << (32 - size) 30 32 31 bezet = {} 32 substs = {} 33 def add_ip(address): 34 if '/' not in address: 35 address += "/32" 33 if not use_history or (use_history and not bezet_cache): 34 bezet = {} 35 substs = {} 36 def add_ip(address): 37 if '/' not in address: 38 address += "/32" 36 39 37 addr, mask = address.split('/') 38 if addr in substs: 39 addr = substs[addr] 40 try: 41 addr = parseaddr(addr) 42 mask = int(mask) 43 addr = addr & ~((1 << (32 - mask)) - 1) 44 for i in range(0, (1 << (32 - mask))): 45 bezet[addr + i] = 1 46 except ValueError, e: 47 print "[FOUT] in address %s node %s" % (address, node) 40 addr, mask = address.split('/') 41 if addr in substs: 42 addr = substs[addr] 43 try: 44 addr = parseaddr(addr) 45 mask = int(mask) 46 addr = addr & ~((1 << (32 - mask)) - 1) 47 for i in range(0, (1 << (32 - mask))): 48 bezet[addr + i] = 1 49 except ValueError, e: 50 print "[FOUT] in address %s node %s" % (address, node) 51 52 for node in gformat.get_hostlist(): 53 datadump = gformat.get_yaml(node) 54 55 add_ip(datadump['masterip']) 56 for key in datadump['autogen_iface_keys']: 57 add_ip(datadump[key]['ip']) 58 59 # Fetching smallest in use IP 60 # XXX: Currently not used for anything 61 i = parseaddr("255.255.255.255") 62 for k in bezet.keys(): 63 if k < i: 64 i = k 65 else: 66 bezet = bezet_cache 48 67 49 for node in gformat.get_hostlist(): 50 datadump = gformat.get_yaml(node) 51 52 add_ip(datadump['masterip']) 53 for key in datadump['autogen_iface_keys']: 54 add_ip(datadump[key]['ip']) 55 56 # Fetching smallest in use IP 57 # XXX: Currently not used for anything 58 i = parseaddr("255.255.255.255") 59 for k in bezet.keys(): 60 if k < i: 61 i = k 62 68 63 69 # Interlinks are living in special ranges usually 64 70 if interlink: … … 84 90 bezet[i] = 1 85 91 92 bezet_cache = bezet 86 93 return ranges 87 94
Note:
See TracChangeset
for help on using the changeset viewer.