From c37014083afd68e4e63b7c14f4d0357b29d754b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20Lu=C8=9B=C4=83?= Date: Fri, 11 May 2012 17:17:59 +0300 Subject: [PATCH] Added a new fact: network address for an interface --- library/setup | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/setup b/library/setup index 0f99a6cc0f8..1cf06b3f2d3 100755 --- a/library/setup +++ b/library/setup @@ -242,6 +242,9 @@ def get_network_facts(facts): facts[iface]['ipv4'] = {} facts[iface]['ipv4'] = { 'address': 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: (ip, prefix) = data[2].split('/') scope = data[3].split(':')[1].lower()