From 7ef539bc37a02c80c6ad47a1b875619b45bac3d5 Mon Sep 17 00:00:00 2001 From: Alfredo Moralejo Date: Thu, 24 Sep 2020 13:33:22 +0200 Subject: [PATCH] Use netifaces instead of facter to find ip address Currently, neutron_350.py is using parsed output of `facter -p` in prescript_000.py which is actually not working fine in terms of getting the ip of a interface. This patch is using netifaces python library instead to get the ip address which is much easier to use and reliable. Note that netifaces was already a requirement in packstack so it's included in requirements.txt and as package requirement. Change-Id: Id4d2b4ca814129c485f491ed91bb6bb99e462114 Resolves: rhbz#1734354 --- packstack/plugins/neutron_350.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packstack/plugins/neutron_350.py b/packstack/plugins/neutron_350.py index 765ca0ecd..8711c2ef1 100644 --- a/packstack/plugins/neutron_350.py +++ b/packstack/plugins/neutron_350.py @@ -16,7 +16,7 @@ Installs and configures Neutron """ -import re +import netifaces from packstack.installer import basedefs from packstack.installer import utils from packstack.installer import validators @@ -807,11 +807,10 @@ def create_manifests(config, messages): n_host, config) else: iface = config['CONFIG_NEUTRON_OVS_TUNNEL_IF'] - ifip = ("ipaddress_%s" % iface) - ifip = re.sub(r'[\.\-\:]', '_', ifip) try: - src_host = config['HOST_DETAILS'][n_host][ifip] - except KeyError: + src_host = (netifaces.ifaddresses(iface) + [netifaces.AF_INET][0]['addr']) + except Exception: raise KeyError('Couldn\'t detect ipaddress of ' 'interface %s on node %s' % (iface, n_host))