From 11e8dbddb25bd9b4ba77c2413f14b88c80b03531 Mon Sep 17 00:00:00 2001 From: Maksim Malchuk Date: Wed, 31 Aug 2016 17:18:21 +0300 Subject: [PATCH] Correctly support all NetworkManager versions This change adds support of the all versions of the nmcli command. Change-Id: Icc5f93d052c451116b23c2922fe18e23e3f72746 Closes-Bug: #1617453 Signed-off-by: Maksim Malchuk --- functions/product.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/product.sh b/functions/product.sh index 68caa1c..1668fe2 100755 --- a/functions/product.sh +++ b/functions/product.sh @@ -164,10 +164,18 @@ enable_outbound_network_for_product_vm() { nameserver="$(execute grep '^nameserver' /etc/resolv.conf | egrep -v 'nameserver\s*(127\.|.*:)' | head -3)" fi if [ -z "$nameserver" ] && execute test -x /usr/bin/nmcli; then + # + if [ -z "`execute LANG=C nmcli nm help 2>&1 | grep \"Error\"`" ]; then + nmcli_status="nm" + nmcli_settings="list" + else + nmcli_status="general" + nmcli_settings="show" + fi # Get DNS from network manager - if [ -n "`execute LANG=C nmcli nm | grep \"running\s\+connected\"`" ]; then + if [ -n "`execute LANG=C nmcli ${nmcli_status} | grep \"\bconnected\"`" ]; then # we should exclude loopback and IPv6 addresses from the nameservers list - nameserver="$(execute nmcli dev list | grep 'IP[46].DNS' | sed -e 's/IP[46]\.DNS\[[0-9]\+\]:\s\+/nameserver /'| grep -v 'nameserver\s*(127\.|.*:)' | head -3)" + nameserver="$(execute nmcli device ${nmcli_settings} | grep 'IP[46].DNS' | sed -e 's/IP[46]\.DNS\[[0-9]\+\]:\s\+/nameserver /'| grep -v 'nameserver\s*(127\.|.*:)' | head -3)" fi fi if [ -z "$nameserver" ]; then @@ -327,4 +335,4 @@ ENDOFEXPECT ) echo "OK" return 0 -} \ No newline at end of file +}