From d5cb42f0592ea6f930a5d8616532f13074c83e93 Mon Sep 17 00:00:00 2001 From: Lukas Bezdicka Date: Sat, 10 Oct 2015 15:32:02 +0200 Subject: [PATCH] Fix IPv6 Change-Id: Ide88c35590a69bbb7e18a77a688103d5996ffa03 --- packstack/installer/utils/network.py | 4 ++-- .../packstack/lib/puppet/parser/functions/force_ip.rb | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packstack/installer/utils/network.py b/packstack/installer/utils/network.py index f87e1d9e6..868b8806f 100644 --- a/packstack/installer/utils/network.py +++ b/packstack/installer/utils/network.py @@ -102,7 +102,7 @@ def is_ipv6(host): ) host = host.strip() try: - return netaddr.IPAddress(host).version == 6 + return netaddr.IPAddress(host.strip('[]')).version == 6 except netaddr.core.AddrFormatError: # Most probably a hostname return False @@ -122,7 +122,7 @@ def is_ipv4(host): def force_ip(host, allow_localhost=False): - if not is_ipv6(host) or not is_ipv4(host): + if not(is_ipv6(host) or is_ipv4(host)): host = host2ip(host, allow_localhost=allow_localhost) return host diff --git a/packstack/puppet/modules/packstack/lib/puppet/parser/functions/force_ip.rb b/packstack/puppet/modules/packstack/lib/puppet/parser/functions/force_ip.rb index 2c8a31f42..9599849e0 100644 --- a/packstack/puppet/modules/packstack/lib/puppet/parser/functions/force_ip.rb +++ b/packstack/puppet/modules/packstack/lib/puppet/parser/functions/force_ip.rb @@ -1,5 +1,6 @@ require 'resolv' +require 'ipaddr' module Puppet::Parser::Functions @@ -10,6 +11,10 @@ module Puppet::Parser::Functions "force_ip(): Wrong number of arguments given (#{args.size} for 1)" ) end - Resolv.getaddress args[0] + if (!!IPAddr.new(args[0]) rescue false) + args[0] + else + Resolv.getaddress args[0] + end end end