From 2f9fc8896399a5550e3eca23ad5b7f64412c9bff Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 14 May 2021 09:30:08 +0800 Subject: [PATCH] Add helper to get nmcli connection apath by ifname Resolves: bz1919052 Upstream: Fedora Conflict: None commit c69578ca431998d7460d40e58769a05b58bab0e8 Author: Coiby Xu Date: Thu Apr 1 15:32:09 2021 +0800 Add helper to get nmcli connection apath by ifname apath (a D-Bus active connection path) is used for nmcli connection operations, e.g. $ nmcli connection show $apath Signed-off-by: Coiby Xu Acked-by: Kairui Song Signed-off-by: Coiby Xu --- kdump-lib.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kdump-lib.sh b/kdump-lib.sh index 795f952..0a1bfd9 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -392,6 +392,20 @@ get_nmcli_value_by_field() echo -n "$val" } +# Get nmcli connection apath (a D-Bus active connection path ) by ifname +# +# apath is used for nmcli connection operations, e.g. +# $ nmcli connection show $apath +get_nmcli_connection_apath_by_ifname() +{ + local _ifname=$1 + local _nm_show_cmd="device show $_ifname" + + local _apath=$(get_nmcli_value_by_field "$_nm_show_cmd" "GENERAL.CON-PATH") + + echo -n "$_apath" +} + get_ifcfg_by_device() { grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \