Add additional checking of net type in agent

When we call method IPAddr.new("some non api string")
it stuck on several seconds in VMware, with several
interfaces we have several minutes additional timeout.

Change-Id: I25e784eef2e471922cb5128c0cbf94eff8ba3726
Closes-bug: #1284571
This commit is contained in:
Evgeniy L 2014-02-25 15:30:57 +04:00
parent e2556c38b8
commit e67ea5c139
1 changed files with 4 additions and 1 deletions

View File

@ -442,7 +442,10 @@ class NodeAgent
def _master_ip_and_mac
@os[:network][:interfaces].each do |_, intinfo|
intinfo[:addresses].each do |k, v|
if !(IPAddr.new(k) rescue nil).nil?
# Here we need to check family because IPAddr.new with bad
# data works very slow on some environments
# https://bugs.launchpad.net/fuel/+bug/1284571
if v[:family] == 'inet' && !(IPAddr.new(k) rescue nil).nil?
net = IPAddr.new("#{k}/#{v[:netmask]}")
if net.include? @api_ip
mac = intinfo[:addresses].find { |_, info| info[:family] == 'lladdr' }[0]