add IPv6 support for choose_my_ip function

Several place need to use choose_my_ip function to know which IP offered
to packstack belongs to current node. Unfortunately, IPv6 version failed.
With this change, it will be OK no matter which IP version given.
For both ovs_agent and ovn_agent, add split ":" matching besides dot to
support IPv6.

Closes-Bug: #1838732

Change-Id: I0269db6641bca335685140d2d6439bc795cd8c46
Signed-off-by: Guo Larry <larry.guo@nokia-sbell.com>
This commit is contained in:
Guo Larry 2019-08-02 16:18:04 +08:00
parent 310a9733e4
commit 02bd30d943
3 changed files with 6 additions and 4 deletions

View File

@ -14,9 +14,11 @@ module Puppet::Parser::Functions
if not host_list.kind_of?(Array)
host_list = [host_list]
end
my_ips = lookupvar('interfaces').split(',').map do |interface|
my_ips = Array.new
lookupvar('interfaces').split(',').each do |interface|
interface.strip!
lookupvar("ipaddress_#{interface}")
my_ips.push(lookupvar("ipaddress_#{interface}"))
my_ips.push(lookupvar("ipaddress6_#{interface}"))
end
result = nil

View File

@ -1,7 +1,7 @@
class packstack::neutron::ovn_agent ()
{
$my_ip = choose_my_ip(hiera('HOST_LIST'))
$my_ip_without_dot = regsubst($my_ip, '\.', '_', 'G')
$my_ip_without_dot = regsubst($my_ip, '[\.\:]', '_', 'G')
$neutron_tunnel_rule_name = "FIREWALL_NEUTRON_TUNNEL_RULES_${my_ip_without_dot}"
create_resources(packstack::firewall, hiera($neutron_tunnel_rule_name, {}))

View File

@ -1,7 +1,7 @@
class packstack::neutron::ovs_agent ()
{
$my_ip = choose_my_ip(hiera('HOST_LIST'))
$my_ip_without_dot = regsubst($my_ip, '\.', '_', 'G')
$my_ip_without_dot = regsubst($my_ip, '[\.\:]', '_', 'G')
$neutron_tunnel_rule_name = "FIREWALL_NEUTRON_TUNNEL_RULES_${my_ip_without_dot}"
create_resources(packstack::firewall, hiera($neutron_tunnel_rule_name, {}))