From dc154a1652508d8631c43f44145bda03dcba5069 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Fri, 19 Oct 2018 14:22:05 +0100 Subject: [PATCH] Fix BMC IP address detection on CoreOS images On CoreOS images, IPA runs in a Debian Jessie chroot which uses mawk as its default awk implementation. However, mawk doesn't support POSIX character classes such as [:space:], which means get_bmc_address() fails to parse the BMC IP address from the output of ipmitool. This patch replaces the use of [[:space:]] by [ \t] which is equivalent for the purpose of parsing the output of ipmitool. Note that matching on tab characters is not strictly required as the packaged version of ipmitool only uses space characters, but is left in case tabs are used in other versions. Change-Id: I0e3306a4d4584ca28e03608e9f7270b770960a39 Story: #2004121 Task: #27571 (cherry picked from commit 8eecadb0a8a36eb541b96d6d2fcce12dbb121181) --- ironic_python_agent/hardware.py | 2 +- .../fix-bmc-ip-detection-for-coreos-483be0286593e393.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-bmc-ip-detection-for-coreos-483be0286593e393.yaml diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index bd12a209c..97a858c2c 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -971,7 +971,7 @@ class GenericHardwareManager(HardwareManager): # types of communication media and protocols and effectively used for channel in range(1, 8): out, e = utils.execute( - "ipmitool lan print {} | awk '/IP Address[[:space:]]*:/" + "ipmitool lan print {} | awk '/IP Address[ \\t]*:/" " {{print $4}}'".format(channel), shell=True) if e.startswith("Invalid channel"): continue diff --git a/releasenotes/notes/fix-bmc-ip-detection-for-coreos-483be0286593e393.yaml b/releasenotes/notes/fix-bmc-ip-detection-for-coreos-483be0286593e393.yaml new file mode 100644 index 000000000..1a33130ff --- /dev/null +++ b/releasenotes/notes/fix-bmc-ip-detection-for-coreos-483be0286593e393.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes detection of IPMI address in CoreOS-based images, by ensuring that + parsing of ``ipmitool`` output is compatible with the bundled + implementation of ``awk`` (``mawk``).