Add helper to get nmcli connection show cmd by ifname

Signed-off-by: Coiby Xu <coxu@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Coiby Xu 2021-04-01 15:32:10 +08:00 committed by Kairui Song
parent c69578ca43
commit 0c292f49c7
1 changed files with 14 additions and 0 deletions

View File

@ -406,6 +406,20 @@ get_nmcli_connection_apath_by_ifname()
echo -n "$_apath"
}
# Get nmcli connection show cmd by ifname
#
# "$_apath" is supposed to not contain any chracter that
# need to be escapded, e.g. space. Otherwise get_nmcli_value_by_field
# would fail.
get_nmcli_connection_show_cmd_by_ifname()
{
local _ifname="$1"
local _apath=$(get_nmcli_connection_apath_by_ifname "$_ifname")
local _nm_show_cmd="connection show $_apath"
echo -n "$_nm_show_cmd"
}
get_ifcfg_by_device()
{
grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \