Fix nic_alias fact error

If os-net-config is not installed, this fact causes a warning to be
generated. Let's check for os-net-config prior to trying to run it to
cleanup this error.

Change-Id: Ie55b96bbd7b60dae2342b89c24936d4d071cec10
Closes-Bug: #1794837
(cherry picked from commit 6fb8797f79)
This commit is contained in:
Alex Schultz 2018-09-27 11:03:11 -06:00
parent ab15b3468f
commit 123be2924e
1 changed files with 8 additions and 3 deletions

View File

@ -15,8 +15,13 @@
Facter.add('nic_alias') do
setcode do
mapping_report =
Facter::Core::Execution.execute('/usr/bin/os-net-config -i')
mapping_report.delete("{}' ")
os_net_config = '/usr/bin/os-net-config'
mapping_report = ''
if File.exist?(os_net_config)
mapping_report =
Facter::Core::Execution.execute("#{os_net_config} -i")
mapping_report.delete("{}' ")
end
mapping_report
end
end