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

don't use full path to command instead use module.get_bin_path

This commit is contained in:
Boris Manojlovic 2015-03-10 19:44:39 +01:00
parent 0f4cf8cb43
commit a59784a581

View file

@ -2179,35 +2179,40 @@ class AIXNetwork(GenericBsdIfconfigNetwork, Network):
self.parse_inet6_line(words, current_if, ips) self.parse_inet6_line(words, current_if, ips)
else: else:
self.parse_unknown_line(words, current_if, ips) self.parse_unknown_line(words, current_if, ips)
uname_path = module.get_bin_path('uname')
if uname_path:
rc, out, err = module.run_command([uname_path, '-W'])
# don't bother with wpars it does not work
# zero means not in wpar
if out.split()[0] == '0':
if current_if['macaddress'] == 'unknown' and re.match('^en', current_if['device']):
entstat_path = module.get_bin_path('entstat')
if entstat_path:
rc, out, err = module.run_command([entstat_path, current_if['device'] ])
if rc != 0:
break
for line in out.split('\n'):
if not line:
pass
buff = re.match('^Hardware Address: (.*)', line)
if buff:
current_if['macaddress'] = buff.group(1)
rc, out, err = module.run_command(['/usr/bin/uname', '-W']) buff = re.match('^Device Type:', line)
# don't bother with wpars it does not work if buff and re.match('.*Ethernet', line):
# zero means not in wpar current_if['type'] = 'ether'
if out.split()[0] == '0': # device must have mtu attribute in ODM
if current_if['macaddress'] == 'unknown' and re.match('^en', current_if['device']): if 'mtu' not in current_if:
rc, out, err = module.run_command(['/usr/bin/entstat', current_if['device'] ]) lsattr_path = module.get_bin_path('lsattr')
if rc != 0: if lsattr_path:
break rc, out, err = module.run_command([lsattr_path,'-El', current_if['device'] ])
for line in out.split('\n'): if rc != 0:
if not line: break
pass for line in out.split('\n'):
buff = re.match('^Hardware Address: (.*)', line) if line:
if buff: words = line.split()
current_if['macaddress'] = buff.group(1) if words[0] == 'mtu':
current_if['mtu'] = words[1]
buff = re.match('^Device Type:', line)
if buff and re.match('.*Ethernet', line):
current_if['type'] = 'ether'
# device must have mtu attribute in ODM
if 'mtu' not in current_if:
rc, out, err = module.run_command(['/usr/sbin/lsattr','-El', current_if['device'] ])
if rc != 0:
break
for line in out.split('\n'):
if line:
words = line.split()
if words[0] == 'mtu':
current_if['mtu'] = words[1]
return interfaces, ips return interfaces, ips
# AIX 'ifconfig -a' does not inform about MTU, so remove current_if['mtu'] here # AIX 'ifconfig -a' does not inform about MTU, so remove current_if['mtu'] here