1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add Solaris network facts. IPv6 details overwrite IPv4 per interface, needs further work.

This commit is contained in:
Chris Gardner 2013-05-30 00:06:57 +01:00
parent dbfad567bc
commit 6809b56233

View file

@ -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.