e3c68b
From 7a47c004b907ed5469b78d559cae6d151e4d626b Mon Sep 17 00:00:00 2001
e3c68b
From: Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
Date: Thu, 23 Feb 2017 16:21:52 +0530
e3c68b
Subject: [PATCH 065/124] ganesha/scripts : remove dependency over export
e3c68b
 configuration file for unexport
e3c68b
e3c68b
Currently unexport is performed by reading export id from volume configuration
e3c68b
file. So unexport has dependency over that file. This patch will unexport with
e3c68b
help of dbus command ShowExport. And it will only unexport the share which is
e3c68b
added via cli.
e3c68b
e3c68b
Label: DOWNSTREAM ONLY
e3c68b
e3c68b
Change-Id: I6f3c9b2bb48f0328b18e9cc0e4b9356174afd596
e3c68b
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
Reviewed-on: https://review.gluster.org/16771
e3c68b
Smoke: Gluster Build System <jenkins@build.gluster.org>
e3c68b
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
e3c68b
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
e3c68b
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
e3c68b
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
e3c68b
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/167150
e3c68b
Reviewed-by: Soumya Koduri <skoduri@redhat.com>
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 extras/ganesha/scripts/dbus-send.sh | 14 ++++++++++++--
e3c68b
 1 file changed, 12 insertions(+), 2 deletions(-)
e3c68b
e3c68b
diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh
e3c68b
index ec8d948..9d613a0 100755
e3c68b
--- a/extras/ganesha/scripts/dbus-send.sh
e3c68b
+++ b/extras/ganesha/scripts/dbus-send.sh
e3c68b
@@ -41,8 +41,18 @@ string:"EXPORT(Path=/$VOL)"
e3c68b
 #This function removes an export dynamically(uses the export_id of the export)
e3c68b
 function dynamic_export_remove()
e3c68b
 {
e3c68b
-        removed_id=`cat $GANESHA_DIR/exports/export.$VOL.conf |\
e3c68b
-grep Export_Id | awk -F"[=,;]" '{print$2}'| tr -d '[[:space:]]'`
e3c68b
+        # Below bash fetch all the export from ShowExport command and search
e3c68b
+        # export entry based on path and then get its export entry.
e3c68b
+        # There are two possiblities for path, either entire volume will be
e3c68b
+        # exported or subdir. It handles both cases. But it remove only first
e3c68b
+        # entry from the list based on assumption that entry exported via cli
e3c68b
+        # has lowest export id value
e3c68b
+	removed_id=$(dbus-send --type=method_call --print-reply --system \
e3c68b
+                    --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
e3c68b
+                    org.ganesha.nfsd.exportmgr.ShowExports | grep -B 1 -we \
e3c68b
+                    "/"$VOL -e "/"$VOL"/" | grep uint16 | awk '{print $2}' \
e3c68b
+		    | head -1)
e3c68b
+
e3c68b
         dbus-send --print-reply --system \
e3c68b
 --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
e3c68b
 org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b