File kdump-net-0011-general-wicked-conf.patch of Package kdump

From: Petr Tesarik <ptesarik@suse.com>
Date: Fri, 2 Sep 2016 10:19:39 +0200
Subject: Generalize kdump_wicked_conf
References: bsc#980328
Patch-mainline: v0.8.16
Git-commit: 32f25e1b8a6cc44ccf4d2ff4a33b437d530b75b9

Allow passing a complete wicked xpath expression instead of just
the XPath element. This allows to replace some direct invocations
of "wicked show-config" with the function and maintain a single
place for handling wicked configuration.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 init/setup-kdump.functions |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

--- a/init/setup-kdump.functions
+++ b/init/setup-kdump.functions
@@ -62,15 +62,15 @@ function kdump_route2dev()						   # {{{
 #
 # Parameters:
 #   1) ifname  network interface name
-#   2) conf    configuration XPath under /interface
+#   *) conf    wicked xpath expression(s) under /interface
 # Output:
 #   configuration value
 function kdump_wicked_conf()						   # {{{
 {
     local ifname="$1"
-    local conf="$2"
-
-    wicked show-config | wicked xpath "%{/interface[name='$ifname']/$conf}"
+    shift
+    wicked show-config | \
+	wicked xpath --reference "/interface[name='$ifname']" "$@"
 }									   # }}}
 
 #
@@ -123,10 +123,12 @@ function kdump_netdev_mode()						   # {
 
     # get mode using wicked if possible
     if [ -n "$(type -P wicked)" -a \
-	"$(kdump_wicked_conf "$ifname" name)" = "$ifname" ]
+	"$(kdump_wicked_conf "$ifname" "%{name}")" = "$ifname" ]
     then
-	local dhcpv4=$(kdump_wicked_conf "$ifname" ipv4:dhcp/enabled)
-	local dhcpv6=$(kdump_wicked_conf "$ifname" ipv6:dhcp/enabled)
+	local dhcpv4 dhcpv6
+	eval $( kdump_wicked_conf "$ifname" \
+		"dhcpv4=%{ipv4:dhcp/enabled}" \
+		"dhcpv6=%{ipv6:dhcp/enabled}" )
 	if [ "$dhcpv4" = true -o "$dhcpv6" = true ] ; then
 	    BOOTPROTO=dhcp
 	else
@@ -207,8 +209,7 @@ function kdump_ifkind()							   # {{{
 	var="${elems[@]}"
 	var="${var//[-:]/_}"
 	local $var
-	eval  $(wicked show-config | \
-		wicked xpath --reference "/interface[name='$if']" "${opt#;}")
+	eval $( kdump_wicked_conf "$if" "${opt#;}" )
 
 	for elem in "${elems[@]}"
 	do
@@ -340,9 +341,8 @@ function kdump_vlan_config()						   # {
     # use wicked to read VLAN configuration, if possible
     if [ -n "$(type -P wicked)" ]
     then
-	eval $( wicked show-config |
-		wicked xpath --reference "/interface[name='$if']" \
-		    "vid=%{vlan/tag}; if=%{vlan/device}" )
+	eval $( kdump_wicked_conf "$if" \
+		"vid=%{vlan/tag}; if=%{vlan/device}" )
     fi
 
     # fall back to sysfs
openSUSE Build Service is sponsored by