Setting timeout for calling lshw

In some cases lshw may take too long like when we have
lot of partitions > 600. We avoid this problem with
setting timeout for lshw.

Change-Id: I67748bc18023f3f6edce0cc20d4f0486877723b2
Closes-bug: #1559167
This commit is contained in:
Krzysztof Szukiełojć 2016-03-21 12:09:55 +01:00
parent 08625168b3
commit 28dc110ea5
1 changed files with 10 additions and 10 deletions

20
agent
View File

@ -902,21 +902,21 @@ class NodeAgent
end
def _get_pci_dev_list
lshw_path = `which lshw`.chomp
exitstatus = $?
if exitstatus == 0
data = `#{lshw_path} -json`
exitstatus = $?
if exitstatus == 0
return JSON.parse(data)
lshw_timeout = @settings['lshw_timeout'] || 60
Timeout::timeout(lshw_timeout) do
lshw_path = `which lshw`.chomp
if $?.success?
data = `#{lshw_path} -json`
return JSON.parse(data) if $?.success?
@logger.warn("Can't get data from lshw. Reason: lshw exited with status #{$?.exitstatus}")
else
@logger.warn("Can't get data from lshw. Reason: lshw exited with status #{exitstatus}")
@logger.warn("Can't find lshw. Reason: 'which lshw' returned exit status #{$?.exitstatus}")
end
else
@logger.warn("Can't find lshw. Reason: 'which lshw' returned exit status #{exitstatus}")
end
{}
rescue => e
@logger.warn("Can't get data from lshw. Reason: #{e.message}")
{}
end
def get_numa_topology