summaryrefslogtreecommitdiffstats
path: root/tools/glusterfind
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2015-06-18 00:21:59 +0200
committerNiels de Vos <ndevos@redhat.com>2015-08-25 08:50:55 -0700
commit55b44094436bc8630b6c3ff2d232e6551d40630c (patch)
treedff3f88c49ab1eddf9c61c051381f158c57bf13a /tools/glusterfind
parent130697b8b706432153d9a0fda49b896065289aaa (diff)
rpm: include required directory for glusterfind
The directory was marked as %ghost, which causes the following installation failure: Error unpacking rpm package glusterfs-server-3.8dev-0.446.git45e13fe.el7.centos.x86_64 error: unpacking of archive failed on file /var/lib/glusterd/hooks/1/delete/post/S57glusterfind-delete-post.py;5581f20e: cpio: open Also, *all* Python files should be part of the RPM package. This includes generated .pyc and .pyo files. BUG: 1256307 Change-Id: Iee74905b101912c4a845257742c470c3fe42ce2a Signed-off-by: Niels de Vos <ndevos@redhat.com> Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/11298 Reviewed-on: http://review.gluster.org/12000 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tools/glusterfind')
-rw-r--r--tools/glusterfind/Makefile.am12
-rwxr-xr-xtools/glusterfind/S57glusterfind-delete-post.py60
2 files changed, 71 insertions, 1 deletions
diff --git a/tools/glusterfind/Makefile.am b/tools/glusterfind/Makefile.am
index c5a05d61061..514c37c14ad 100644
--- a/tools/glusterfind/Makefile.am
+++ b/tools/glusterfind/Makefile.am
@@ -1,10 +1,20 @@
SUBDIRS = src
-EXTRA_DIST =
+EXTRA_DIST = S57glusterfind-delete-post.py
bin_SCRIPTS = glusterfind
CLEANFILES = $(bin_SCRIPTS)
+deletehookscriptsdir = $(libexecdir)/glusterfs/glusterfind/
+deletehookscripts_SCRIPTS = S57glusterfind-delete-post.py
+
+uninstall-local:
+ rm -f $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/S57glusterfind-delete-post.py
+
install-data-local:
$(MKDIR_P) $(DESTDIR)$(GLUSTERD_WORKDIR)/glusterfind/.keys
+ $(MKDIR_P) $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/
+ rm -f $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/S57glusterfind-delete-post.py
+ ln -s $(libexecdir)/glusterfs/glusterfind/S57glusterfind-delete-post.py \
+ $(DESTDIR)$(GLUSTERD_WORKDIR)/hooks/1/delete/post/S57glusterfind-delete-post.py
diff --git a/tools/glusterfind/S57glusterfind-delete-post.py b/tools/glusterfind/S57glusterfind-delete-post.py
new file mode 100755
index 00000000000..70edb563320
--- /dev/null
+++ b/tools/glusterfind/S57glusterfind-delete-post.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+import os
+import shutil
+from errno import ENOENT
+from subprocess import Popen, PIPE
+from argparse import ArgumentParser
+
+
+DEFAULT_GLUSTERD_WORKDIR = "/var/lib/glusterd"
+
+
+def handle_rm_error(func, path, exc_info):
+ if exc_info[1].errno == ENOENT:
+ return
+
+ raise exc_info[1]
+
+
+def get_glusterd_workdir():
+ p = Popen(["gluster", "system::", "getwd"],
+ stdout=PIPE, stderr=PIPE)
+
+ out, _ = p.communicate()
+
+ if p.returncode == 0:
+ return out.strip()
+ else:
+ return DEFAULT_GLUSTERD_WORKDIR
+
+
+def get_args():
+ parser = ArgumentParser(description="Volume delete post hook script")
+ parser.add_argument("--volname")
+ return parser.parse_args()
+
+
+def main():
+ args = get_args()
+ glusterfind_dir = os.path.join(get_glusterd_workdir(), "glusterfind")
+
+ # Check all session directories, if any directory found for
+ # the deleted volume, cleanup all the session directories
+ for session in os.listdir(glusterfind_dir):
+ # Possible session directory
+ volume_session_path = os.path.join(glusterfind_dir,
+ session,
+ args.volname)
+ if os.path.exists(volume_session_path):
+ shutil.rmtree(volume_session_path, onerror=handle_rm_error)
+
+ # Try to Remove directory, if any other dir exists for different
+ # volume, then rmdir will fail with ENOTEMPTY which is fine
+ try:
+ os.rmdir(os.path.join(glusterfind_dir, session))
+ except (OSError, IOError):
+ pass
+
+
+if __name__ == "__main__":
+ main()