From d5bb7188f0620ff2f3d7d513a89d30aafd484925 Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Thu, 30 May 2013 00:06:57 +0100 Subject: [PATCH] Add Solaris network facts. IPv6 details overwrite IPv4 per interface, needs further work. --- system/setup | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/system/setup b/system/setup index 23c2ebe8d64..9244f120cc6 100644 --- a/system/setup +++ b/system/setup @@ -1259,7 +1259,7 @@ class GenericBsdIfconfigNetwork(Network): all_ipv4_addresses = [], all_ipv6_addresses = [], ) - rc, out, err = module.run_command([ifconfig_path]) + rc, out, err = module.run_command([ifconfig_path, '-a']) for line in out.split('\n'): @@ -1328,6 +1328,8 @@ class GenericBsdIfconfigNetwork(Network): def parse_inet_line(self, words, current_if, ips): address = {'address': words[1]} # deal with hex netmask + if re.match('([0-9a-f]){8}', words[3]) and len(words[3]) == 8: + words[3] = '0x' + words[3] if words[3].startswith('0x'): address['netmask'] = socket.inet_ntoa(struct.pack('!L', int(words[3], base=16))) else: @@ -1401,6 +1403,22 @@ class DarwinNetwork(GenericBsdIfconfigNetwork, Network): current_if['media_options'] = self.get_options(words[3]) +class SunOSNetwork(GenericBsdIfconfigNetwork, Network): + """ + This is the SunOS Network Class. + It uses the GenericBsdIfconfigNetwork unchanged + """ + platform = 'SunOS' + + # Solaris displays single digit octets in MAC addresses e.g. 0:1:2:d:e:f + # Add leading zero to each octet where needed. + def parse_ether_line(self, words, current_if, ips): + macaddress = '' + for octet in words[1].split(':'): + octet = ('0' + octet)[-2:None] + macaddress += (octet + ':') + current_if['macaddress'] = macaddress[0:-1] + class FreeBSDNetwork(GenericBsdIfconfigNetwork, Network): """ This is the FreeBSD Network Class.