From 924f5b5467d3ee395fa957e992ea716ce5c3a835 Mon Sep 17 00:00:00 2001 From: Anatoly Pugachev Date: Wed, 20 Feb 2019 18:46:54 +0300 Subject: [PATCH] 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 --- lib/ansible/module_utils/facts/network/fc_wwn.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ansible/module_utils/facts/network/fc_wwn.py b/lib/ansible/module_utils/facts/network/fc_wwn.py index 5640ae45e31..b4f1e6dadb1 100644 --- a/lib/ansible/module_utils/facts/network/fc_wwn.py +++ b/lib/ansible/module_utils/facts/network/fc_wwn.py @@ -43,4 +43,20 @@ class FcWwnInitiatorFactCollector(BaseFactCollector): for fcfile in glob.glob('/sys/class/fc_host/*/port_name'): for line in get_file_lines(fcfile): 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