Advertise the correct address when using IPv6
Parse the output of "ip route get $IP" taking IPv6 into consideration. Also wrap the IP address in square brackets if it is IPv6. Change-Id: Ifc44e5aa3c5b814b6ceba04461bb68fe1d75c22b Closes-Bug: #1650533
This commit is contained in:
@ -22,6 +22,7 @@ import sys
|
||||
import netifaces
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import netutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
@ -213,3 +214,9 @@ def interface_has_carrier(interface_name):
|
||||
LOG.debug('No carrier information for interface %s',
|
||||
interface_name)
|
||||
return False
|
||||
|
||||
|
||||
def wrap_ipv6(ip):
|
||||
if netutils.is_valid_ipv6(ip):
|
||||
return "[%s]" % ip
|
||||
return ip
|
||||
|
Reference in New Issue
Block a user