Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of facts gathering WWNs on AIX OS #51704

Merged
merged 9 commits into from
Apr 10, 2019
3 changes: 3 additions & 0 deletions changelogs/fragments/fibre_channel_wwn_fact_aix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- gather Fibre Channel WWNs fact on AIX (extends https://github.com/ansible/ansible/pull/37043)
20 changes: 20 additions & 0 deletions lib/ansible/module_utils/facts/network/fc_wwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,24 @@ def collect(self, module=None, collected_facts=None):
for line in fcinfo_out.splitlines():
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')
cmd = cmd + " -Cc adapter -l fcs*"
rc, lsdev_out, err = module.run_command(cmd)
if lsdev_out:
lscfg_cmd = module.get_bin_path('lscfg')
for line in lsdev_out.splitlines():
# if device is available (not in defined state), get its WWN
if 'Available' in line:
data = line.split(' ')
cmd = lscfg_cmd + " -vl %s" % data[0]
rc, lscfg_out, err = module.run_command(cmd)
# example output
# lscfg -vpl fcs3 | grep "Network Address"
# Network Address.............10000090FA551509
for line in lscfg_out.splitlines():
if 'Network Address' in line:
data = line.split('.')
fc_facts['fibre_channel_wwn'].append(data[-1].rstrip())
return fc_facts