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