Last change
on this file since 11712 was 10256, checked in by richardvm, 13 years ago |
duplicate rule: detected by Rick
|
-
Property svn:executable
set to
*
|
File size:
1015 bytes
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | import gformat
|
---|
4 |
|
---|
5 | nodes = gformat.get_nodelist()
|
---|
6 |
|
---|
7 | def list_ips(ip):
|
---|
8 | addr, mask = ip.split('/')[0], ip.split('/')[1]
|
---|
9 |
|
---|
10 | mask = 2 ** (32 - int(mask))
|
---|
11 | mask = int(mask)
|
---|
12 | addr = addr.split('.')
|
---|
13 | fourth = addr[3]
|
---|
14 | fourth = int(fourth)
|
---|
15 | start = fourth - (fourth % mask)
|
---|
16 | start = int(start)
|
---|
17 | end = int(start) + int(mask)
|
---|
18 | end = int(end)
|
---|
19 |
|
---|
20 | listing = []
|
---|
21 | for i in range(start, end):
|
---|
22 | ip2 = "%s.%s.%s.%i" % (addr[0], addr[1], addr[2], i)
|
---|
23 | listing.append(ip2)
|
---|
24 |
|
---|
25 | return listing
|
---|
26 |
|
---|
27 | f = open('client-ips.txt','w')
|
---|
28 |
|
---|
29 | for node in nodes:
|
---|
30 | ifaces = gformat.get_yaml(node)['interfaces'].split(',')
|
---|
31 | for iface in ifaces:
|
---|
32 | if gformat.get_yaml(node)['iface_%s' % iface]['dhcp'] == "no" :
|
---|
33 | continue
|
---|
34 | if gformat.get_yaml(node)['iface_%s' % iface]['dhcp'] == "False" :
|
---|
35 | continue
|
---|
36 | ip = gformat.get_yaml(node)['iface_%s' % iface]['ip']
|
---|
37 | node_short = node.replace('CNode', '').lower()
|
---|
38 | for client in list_ips(ip):
|
---|
39 | f.write("%s %s\n" % (node_short, client))
|
---|
40 |
|
---|
41 | f.close()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.