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

Add support of facts gathering WWNs on Solaris 10 and Solaris 11 OS (#52091)

* Add support of facts gathering WWNs on Solaris 10 and Solaris 11 OS

Extends PR #37043 / git commit c65909d "Add network fact to obtain FC
WWN initiator ports" for Solaris OS support.

$ fcinfo hba-port | grep 'Port WWN'
HBA Port WWN: 10000090fa1658de
HBA Port WWN: 10000090fa1658df
HBA Port WWN: 10000090fa165b5c
HBA Port WWN: 10000090fa165b5d

* use module.get_bin_path() instead of hardcoded cmd path
This commit is contained in:
Anatoly Pugachev 2019-02-20 18:46:54 +03:00 committed by Brian Coca
parent 62feba3d15
commit 924f5b5467

View file

@ -43,4 +43,20 @@ class FcWwnInitiatorFactCollector(BaseFactCollector):
for fcfile in glob.glob('/sys/class/fc_host/*/port_name'): for fcfile in glob.glob('/sys/class/fc_host/*/port_name'):
for line in get_file_lines(fcfile): for line in get_file_lines(fcfile):
fc_facts['fibre_channel_wwn'].append(line.rstrip()[2:]) fc_facts['fibre_channel_wwn'].append(line.rstrip()[2:])
elif sys.platform.startswith('sunos'):
"""
on solaris 10 or solaris 11 should use `fcinfo hba-port`
on solaris 9, `prtconf -pv`
"""
cmd = module.get_bin_path('fcinfo')
cmd = cmd + " hba-port | grep 'Port WWN'"
rc, fcinfo_out, err = module.run_command(cmd, use_unsafe_shell=True)
"""
# fcinfo hba-port | grep "Port WWN"
HBA Port WWN: 10000090fa1658de
"""
if fcinfo_out:
for line in fcinfo_out.splitlines():
data = line.split(' ')
fc_facts['fibre_channel_wwn'].append(data[-1].rstrip())
return fc_facts return fc_facts