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 <mmalchuk@mirantis.com>
This commit is contained in:
Maksim Malchuk 2016-08-31 17:18:21 +03:00
parent 984547cc1f
commit 16c48fc045
1 changed files with 11 additions and 3 deletions

View File

@ -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
}
}