From 701cf2589113f2766b5d8d39c15edde0647fb8af Mon Sep 17 00:00:00 2001 From: Anatoly Pugachev Date: Thu, 18 Apr 2019 23:31:40 +0300 Subject: [PATCH] [cosmetic] solaris wwn fix (#55154) * Solaris WWN parsing cosmetic fix (commit 924f5b5467) * simplify module.run_command by removing use_unsafe_shell and remove calling of external grep * add changelog fragment --- .../fibre_channel_wwn_fact_solaris_minor.yaml | 2 ++ lib/ansible/module_utils/facts/network/fc_wwn.py | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/fibre_channel_wwn_fact_solaris_minor.yaml diff --git a/changelogs/fragments/fibre_channel_wwn_fact_solaris_minor.yaml b/changelogs/fragments/fibre_channel_wwn_fact_solaris_minor.yaml new file mode 100644 index 0000000000..ed482e6291 --- /dev/null +++ b/changelogs/fragments/fibre_channel_wwn_fact_solaris_minor.yaml @@ -0,0 +1,2 @@ +minor_changes: + - cosmetic change, simplify FC WWN facts gathering on Solaris diff --git a/lib/ansible/module_utils/facts/network/fc_wwn.py b/lib/ansible/module_utils/facts/network/fc_wwn.py index 4f6ca67fe9..9d9bfc5bc0 100644 --- a/lib/ansible/module_utils/facts/network/fc_wwn.py +++ b/lib/ansible/module_utils/facts/network/fc_wwn.py @@ -46,19 +46,20 @@ class FcWwnInitiatorFactCollector(BaseFactCollector): elif sys.platform.startswith('sunos'): """ on solaris 10 or solaris 11 should use `fcinfo hba-port` - on solaris 9, `prtconf -pv` + TBD (not implemented): on solaris 9 use `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) + cmd = cmd + " hba-port" + rc, fcinfo_out, err = module.run_command(cmd) """ # 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()) + if 'Port WWN' in line: + data = line.split(' ') + fc_facts['fibre_channel_wwn'].append(data[-1].rstrip()) elif sys.platform.startswith('aix'): # get list of available fibre-channel devices (fcs) cmd = module.get_bin_path('lsdev')