Browse Source

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>
tags/10.0.0rc1
Maksim Malchuk 2 years ago
parent
commit
16c48fc045
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      functions/product.sh

+ 11
- 3
functions/product.sh View File

@@ -164,10 +164,18 @@ enable_outbound_network_for_product_vm() {
164 164
       nameserver="$(execute grep '^nameserver' /etc/resolv.conf | egrep -v 'nameserver\s*(127\.|.*:)' | head -3)"
165 165
     fi
166 166
     if [ -z "$nameserver" ] && execute test -x /usr/bin/nmcli; then
167
+      #
168
+      if [ -z "`execute LANG=C nmcli nm help 2>&1 | grep \"Error\"`" ]; then
169
+        nmcli_status="nm"
170
+        nmcli_settings="list"
171
+      else
172
+        nmcli_status="general"
173
+        nmcli_settings="show"
174
+      fi
167 175
       # Get DNS from network manager
168
-      if [ -n "`execute LANG=C nmcli nm | grep \"running\s\+connected\"`" ]; then
176
+      if [ -n "`execute LANG=C nmcli ${nmcli_status} | grep \"\bconnected\"`" ]; then
169 177
         # we should exclude loopback and IPv6 addresses from the nameservers list
170
-        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)"
178
+        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)"
171 179
       fi
172 180
     fi
173 181
     if [ -z "$nameserver" ]; then
@@ -327,4 +335,4 @@ ENDOFEXPECT
327 335
     )
328 336
     echo "OK"
329 337
     return 0
330
-}
338
+}

Loading…
Cancel
Save