Search IP--mac pair for mutli-rack deployments

This search need, because in multi-rack deployments there are no
local IP addresses in the master node APIs subnet.

Co-Authored-By: Sergey Vasilenko <svasilenko@mirantis.com>
Change-Id: I33c47273e8b6cb047eddb248e61e3848b6112ffa
Closes-bug: #1499007
This commit is contained in:
Nikita Koshikov 2015-09-23 18:30:34 -05:00 committed by Sergey Vasilenko
parent d66f188a18
commit 2ad43a6ab1
1 changed files with 22 additions and 4 deletions

26
agent
View File

@ -620,9 +620,7 @@ class NodeAgent
info
end
def _master_ip_and_mac
def _get_ip_mac_pair_for(local_addr)
@os[:network][:interfaces].each do |_, intinfo|
next unless intinfo.has_key?(:addresses)
intinfo[:addresses].each do |k, v|
@ -631,7 +629,7 @@ class NodeAgent
# 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
if net.include? local_addr
mac = intinfo[:addresses].find { |_, info| info[:family] == 'lladdr' }[0]
return {:ip => k, :mac => mac}
end
@ -641,6 +639,26 @@ class NodeAgent
{}
end
def _master_ip_and_mac_for_multirack
rv = {}
if File.exist?('/etc/astute.yaml')
conf = YAML::load_file('/etc/astute.yaml')
return {} unless conf.is_a?(Hash)
e_point_name = conf.fetch('network_scheme', {}).fetch('roles', {}).fetch('admin/pxe', nil)
e_point_ips = conf.fetch('network_scheme', {}).fetch('endpoints', {}).fetch(e_point_name, {}).fetch('IP', [])
e_point_ips.each do |admin_ip|
rv = _get_ip_mac_pair_for(admin_ip)
break unless rv.empty?
end
end
return rv
end
def _master_ip_and_mac
rv = _get_ip_mac_pair_for(@api_ip)
return (rv.empty? ? _master_ip_and_mac_for_multirack : rv)
end
def _data
res = {
:mac => (@os[:macaddress] rescue nil),