Added a new fact: network address for an interface
This commit is contained in:
parent
0f1d98e46b
commit
3b6717245c
1 changed files with 3 additions and 0 deletions
3
setup
3
setup
|
@ -242,6 +242,9 @@ def get_network_facts(facts):
|
||||||
facts[iface]['ipv4'] = {}
|
facts[iface]['ipv4'] = {}
|
||||||
facts[iface]['ipv4'] = { 'address': data[1].split(':')[1],
|
facts[iface]['ipv4'] = { 'address': data[1].split(':')[1],
|
||||||
'netmask': data[-1].split(':')[1] }
|
'netmask': data[-1].split(':')[1] }
|
||||||
|
ip = struct.unpack("!L", socket.inet_aton(facts[iface]['ipv4']['address']))[0]
|
||||||
|
mask = struct.unpack("!L", socket.inet_aton(facts[iface]['ipv4']['netmask']))[0]
|
||||||
|
facts[iface]['ipv4']['network'] = socket.inet_ntoa(struct.pack("!L", ip & mask))
|
||||||
if 'inet6 addr' in line:
|
if 'inet6 addr' in line:
|
||||||
(ip, prefix) = data[2].split('/')
|
(ip, prefix) = data[2].split('/')
|
||||||
scope = data[3].split(':')[1].lower()
|
scope = data[3].split(':')[1].lower()
|
||||||
|
|
Loading…
Reference in a new issue