e3c68b
From 1fb89973551937f34f24b45e07072a6ce6c30ff9 Mon Sep 17 00:00:00 2001
e3c68b
From: Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
Date: Mon, 16 Oct 2017 14:18:31 +0530
e3c68b
Subject: [PATCH 053/124] Revert "packaging: (ganesha) remove glusterfs-ganesha
e3c68b
 subpackage and related files)"
e3c68b
e3c68b
This reverts commit 0cf2963f12a8b540a7042605d8c79f638fdf6cee.
e3c68b
e3c68b
Label: DOWNSTREAM ONLY
e3c68b
e3c68b
Change-Id: Id6e7585021bd4dd78a59580cfa4838bdd4e539a0
e3c68b
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/167102
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
 configure.ac                                       |   3 +
e3c68b
 extras/Makefile.am                                 |   3 +-
e3c68b
 extras/ganesha/Makefile.am                         |   2 +
e3c68b
 extras/ganesha/config/Makefile.am                  |   4 +
e3c68b
 extras/ganesha/config/ganesha-ha.conf.sample       |  19 ++++
e3c68b
 extras/ganesha/scripts/Makefile.am                 |   4 +
e3c68b
 extras/ganesha/scripts/create-export-ganesha.sh    |  91 +++++++++++++++
e3c68b
 extras/ganesha/scripts/dbus-send.sh                |  60 ++++++++++
e3c68b
 extras/ganesha/scripts/generate-epoch.py           |  48 ++++++++
e3c68b
 extras/hook-scripts/start/post/Makefile.am         |   2 +-
e3c68b
 extras/hook-scripts/start/post/S31ganesha-start.sh | 122 +++++++++++++++++++++
e3c68b
 glusterfs.spec.in                                  |  44 +++++++-
e3c68b
 12 files changed, 396 insertions(+), 6 deletions(-)
e3c68b
 create mode 100644 extras/ganesha/Makefile.am
e3c68b
 create mode 100644 extras/ganesha/config/Makefile.am
e3c68b
 create mode 100644 extras/ganesha/config/ganesha-ha.conf.sample
e3c68b
 create mode 100644 extras/ganesha/scripts/Makefile.am
e3c68b
 create mode 100755 extras/ganesha/scripts/create-export-ganesha.sh
e3c68b
 create mode 100755 extras/ganesha/scripts/dbus-send.sh
e3c68b
 create mode 100755 extras/ganesha/scripts/generate-epoch.py
e3c68b
 create mode 100755 extras/hook-scripts/start/post/S31ganesha-start.sh
e3c68b
e3c68b
diff --git a/configure.ac b/configure.ac
e3c68b
index 0d06f5a..125ae29 100644
e3c68b
--- a/configure.ac
e3c68b
+++ b/configure.ac
e3c68b
@@ -196,6 +196,9 @@ AC_CONFIG_FILES([Makefile
e3c68b
                 extras/init.d/glustereventsd-Debian
e3c68b
                 extras/init.d/glustereventsd-Redhat
e3c68b
                 extras/init.d/glustereventsd-FreeBSD
e3c68b
+                extras/ganesha/Makefile
e3c68b
+                extras/ganesha/config/Makefile
e3c68b
+                extras/ganesha/scripts/Makefile
e3c68b
                 extras/systemd/Makefile
e3c68b
                 extras/systemd/glusterd.service
e3c68b
                 extras/systemd/glustereventsd.service
e3c68b
diff --git a/extras/Makefile.am b/extras/Makefile.am
e3c68b
index ff5ca9b..983f014 100644
e3c68b
--- a/extras/Makefile.am
e3c68b
+++ b/extras/Makefile.am
e3c68b
@@ -11,7 +11,8 @@ EditorModedir = $(docdir)
e3c68b
 EditorMode_DATA = glusterfs-mode.el glusterfs.vim
e3c68b
 
e3c68b
 SUBDIRS = init.d systemd benchmarking hook-scripts $(OCF_SUBDIR) LinuxRPM \
e3c68b
-          $(GEOREP_EXTRAS_SUBDIR) snap_scheduler firewalld cliutils python
e3c68b
+          $(GEOREP_EXTRAS_SUBDIR) snap_scheduler firewalld cliutils python \
e3c68b
+		  ganesha
e3c68b
 
e3c68b
 confdir = $(sysconfdir)/glusterfs
e3c68b
 if WITH_SERVER
e3c68b
diff --git a/extras/ganesha/Makefile.am b/extras/ganesha/Makefile.am
e3c68b
new file mode 100644
e3c68b
index 0000000..542de68
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/Makefile.am
e3c68b
@@ -0,0 +1,2 @@
e3c68b
+SUBDIRS = scripts config
e3c68b
+CLEANFILES =
e3c68b
diff --git a/extras/ganesha/config/Makefile.am b/extras/ganesha/config/Makefile.am
e3c68b
new file mode 100644
e3c68b
index 0000000..c729273
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/config/Makefile.am
e3c68b
@@ -0,0 +1,4 @@
e3c68b
+EXTRA_DIST= ganesha-ha.conf.sample
e3c68b
+
e3c68b
+confdir = $(sysconfdir)/ganesha
e3c68b
+conf_DATA = ganesha-ha.conf.sample
e3c68b
diff --git a/extras/ganesha/config/ganesha-ha.conf.sample b/extras/ganesha/config/ganesha-ha.conf.sample
e3c68b
new file mode 100644
e3c68b
index 0000000..c22892b
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/config/ganesha-ha.conf.sample
e3c68b
@@ -0,0 +1,19 @@
e3c68b
+# Name of the HA cluster created.
e3c68b
+# must be unique within the subnet
e3c68b
+HA_NAME="ganesha-ha-360"
e3c68b
+#
e3c68b
+# N.B. you may use short names or long names; you may not use IP addrs.
e3c68b
+# Once you select one, stay with it as it will be mildly unpleasant to
e3c68b
+# clean up if you switch later on. Ensure that all names - short and/or
e3c68b
+# long - are in DNS or /etc/hosts on all machines in the cluster.
e3c68b
+#
e3c68b
+# The subset of nodes of the Gluster Trusted Pool that form the ganesha
e3c68b
+# HA cluster. Hostname is specified.
e3c68b
+HA_CLUSTER_NODES="server1,server2,..."
e3c68b
+#HA_CLUSTER_NODES="server1.lab.redhat.com,server2.lab.redhat.com,..."
e3c68b
+#
e3c68b
+# Virtual IPs for each of the nodes specified above.
e3c68b
+VIP_server1="10.0.2.1"
e3c68b
+VIP_server2="10.0.2.2"
e3c68b
+#VIP_server1_lab_redhat_com="10.0.2.1"
e3c68b
+#VIP_server2_lab_redhat_com="10.0.2.2"
e3c68b
diff --git a/extras/ganesha/scripts/Makefile.am b/extras/ganesha/scripts/Makefile.am
e3c68b
new file mode 100644
e3c68b
index 0000000..00a2c45
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/scripts/Makefile.am
e3c68b
@@ -0,0 +1,4 @@
e3c68b
+EXTRA_DIST= create-export-ganesha.sh generate-epoch.py dbus-send.sh
e3c68b
+
e3c68b
+scriptsdir = $(libexecdir)/ganesha
e3c68b
+scripts_SCRIPTS = create-export-ganesha.sh dbus-send.sh generate-epoch.py
e3c68b
diff --git a/extras/ganesha/scripts/create-export-ganesha.sh b/extras/ganesha/scripts/create-export-ganesha.sh
e3c68b
new file mode 100755
e3c68b
index 0000000..1ffba42
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/scripts/create-export-ganesha.sh
e3c68b
@@ -0,0 +1,91 @@
e3c68b
+#!/bin/bash
e3c68b
+
e3c68b
+#This script is called by glusterd when the user
e3c68b
+#tries to export a volume via NFS-Ganesha.
e3c68b
+#An export file specific to a volume
e3c68b
+#is created in GANESHA_DIR/exports.
e3c68b
+
e3c68b
+# Try loading the config from any of the distro
e3c68b
+# specific configuration locations
e3c68b
+if [ -f /etc/sysconfig/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/sysconfig/ganesha
e3c68b
+fi
e3c68b
+if [ -f /etc/conf.d/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/conf.d/ganesha
e3c68b
+fi
e3c68b
+if [ -f /etc/default/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/default/ganesha
e3c68b
+fi
e3c68b
+
e3c68b
+GANESHA_DIR=${1%/}
e3c68b
+OPTION=$2
e3c68b
+VOL=$3
e3c68b
+CONF=$GANESHA_DIR"/ganesha.conf"
e3c68b
+declare -i EXPORT_ID
e3c68b
+
e3c68b
+function check_cmd_status()
e3c68b
+{
e3c68b
+        if [ "$1" != "0" ]
e3c68b
+                 then
e3c68b
+                 rm -rf $GANESHA_DIR/exports/export.$VOL.conf
e3c68b
+                 sed -i /$VOL.conf/d $CONF
e3c68b
+                 exit 1
e3c68b
+        fi
e3c68b
+}
e3c68b
+
e3c68b
+
e3c68b
+if [ ! -d "$GANESHA_DIR/exports" ];
e3c68b
+        then
e3c68b
+        mkdir $GANESHA_DIR/exports
e3c68b
+        check_cmd_status `echo $?`
e3c68b
+fi
e3c68b
+
e3c68b
+function write_conf()
e3c68b
+{
e3c68b
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
e3c68b
+# changes made to this file. To avoid it, edit the
e3c68b
+# file and run ganesha-ha.sh --refresh-config."
e3c68b
+
e3c68b
+echo "EXPORT{"
e3c68b
+echo "      Export_Id = 2;"
e3c68b
+echo "      Path = \"/$VOL\";"
e3c68b
+echo "      FSAL {"
e3c68b
+echo "           name = "GLUSTER";"
e3c68b
+echo "           hostname=\"localhost\";"
e3c68b
+echo  "          volume=\"$VOL\";"
e3c68b
+echo "           }"
e3c68b
+echo "      Access_type = RW;"
e3c68b
+echo "      Disable_ACL = true;"
e3c68b
+echo '      Squash="No_root_squash";'
e3c68b
+echo "      Pseudo=\"/$VOL\";"
e3c68b
+echo '      Protocols = "3", "4" ;'
e3c68b
+echo '      Transports = "UDP","TCP";'
e3c68b
+echo '      SecType = "sys";'
e3c68b
+echo "     }"
e3c68b
+}
e3c68b
+if [ "$OPTION" = "on" ];
e3c68b
+then
e3c68b
+        if ! (cat $CONF | grep  $VOL.conf\"$ )
e3c68b
+        then
e3c68b
+                write_conf $@ > $GANESHA_DIR/exports/export.$VOL.conf
e3c68b
+                echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF
e3c68b
+                count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l`
e3c68b
+                if [ "$count" = "1" ] ; then
e3c68b
+                        EXPORT_ID=2
e3c68b
+                else
e3c68b
+                        EXPORT_ID=`cat $GANESHA_DIR/.export_added`
e3c68b
+                        check_cmd_status `echo $?`
e3c68b
+                        EXPORT_ID=EXPORT_ID+1
e3c68b
+                        sed -i s/Export_Id.*/"Export_Id= $EXPORT_ID ;"/ \
e3c68b
+                        $GANESHA_DIR/exports/export.$VOL.conf
e3c68b
+                        check_cmd_status `echo $?`
e3c68b
+                fi
e3c68b
+                echo $EXPORT_ID > $GANESHA_DIR/.export_added
e3c68b
+        fi
e3c68b
+else
e3c68b
+        rm -rf $GANESHA_DIR/exports/export.$VOL.conf
e3c68b
+        sed -i /$VOL.conf/d $CONF
e3c68b
+fi
e3c68b
diff --git a/extras/ganesha/scripts/dbus-send.sh b/extras/ganesha/scripts/dbus-send.sh
e3c68b
new file mode 100755
e3c68b
index 0000000..ec8d948
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/scripts/dbus-send.sh
e3c68b
@@ -0,0 +1,60 @@
e3c68b
+#!/bin/bash
e3c68b
+
e3c68b
+# Try loading the config from any of the distro
e3c68b
+# specific configuration locations
e3c68b
+if [ -f /etc/sysconfig/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/sysconfig/ganesha
e3c68b
+fi
e3c68b
+if [ -f /etc/conf.d/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/conf.d/ganesha
e3c68b
+fi
e3c68b
+if [ -f /etc/default/ganesha ]
e3c68b
+        then
e3c68b
+        . /etc/default/ganesha
e3c68b
+fi
e3c68b
+
e3c68b
+GANESHA_DIR=${1%/}
e3c68b
+OPTION=$2
e3c68b
+VOL=$3
e3c68b
+CONF=$GANESHA_DIR"/ganesha.conf"
e3c68b
+
e3c68b
+function check_cmd_status()
e3c68b
+{
e3c68b
+        if [ "$1" != "0" ]
e3c68b
+        then
e3c68b
+                logger "dynamic export failed on node :${hostname -s}"
e3c68b
+        fi
e3c68b
+}
e3c68b
+
e3c68b
+#This function keeps track of export IDs and increments it with every new entry
e3c68b
+function dynamic_export_add()
e3c68b
+{
e3c68b
+        dbus-send  --system \
e3c68b
+--dest=org.ganesha.nfsd  /org/ganesha/nfsd/ExportMgr \
e3c68b
+org.ganesha.nfsd.exportmgr.AddExport  string:$GANESHA_DIR/exports/export.$VOL.conf \
e3c68b
+string:"EXPORT(Path=/$VOL)"
e3c68b
+        check_cmd_status `echo $?`
e3c68b
+}
e3c68b
+
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
+        dbus-send --print-reply --system \
e3c68b
+--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
e3c68b
+org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id
e3c68b
+        check_cmd_status `echo $?`
e3c68b
+}
e3c68b
+
e3c68b
+if [ "$OPTION" = "on" ];
e3c68b
+then
e3c68b
+        dynamic_export_add $@
e3c68b
+fi
e3c68b
+
e3c68b
+if [ "$OPTION" = "off" ];
e3c68b
+then
e3c68b
+        dynamic_export_remove $@
e3c68b
+fi
e3c68b
diff --git a/extras/ganesha/scripts/generate-epoch.py b/extras/ganesha/scripts/generate-epoch.py
e3c68b
new file mode 100755
e3c68b
index 0000000..5db5e56
e3c68b
--- /dev/null
e3c68b
+++ b/extras/ganesha/scripts/generate-epoch.py
e3c68b
@@ -0,0 +1,48 @@
e3c68b
+#!/usr/bin/python
e3c68b
+#
e3c68b
+# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
e3c68b
+# This file is part of GlusterFS.
e3c68b
+#
e3c68b
+# This file is licensed to you under your choice of the GNU Lesser
e3c68b
+# General Public License, version 3 or any later version (LGPLv3 or
e3c68b
+# later), or the GNU General Public License, version 2 (GPLv2), in all
e3c68b
+# cases as published by the Free Software Foundation.
e3c68b
+#
e3c68b
+# Generates unique epoch value on each gluster node to be used by
e3c68b
+# nfs-ganesha service on that node.
e3c68b
+#
e3c68b
+# Configure 'EPOCH_EXEC' option to this script path in
e3c68b
+# '/etc/sysconfig/ganesha' file used by nfs-ganesha service.
e3c68b
+#
e3c68b
+# Construct epoch as follows -
e3c68b
+#        first 32-bit contains the now() time
e3c68b
+#        rest 32-bit value contains the local glusterd node uuid
e3c68b
+
e3c68b
+import time
e3c68b
+import binascii
e3c68b
+
e3c68b
+# Calculate the now() time into a 64-bit integer value
e3c68b
+def epoch_now():
e3c68b
+        epoch_time = int(time.mktime(time.localtime())) << 32
e3c68b
+        return epoch_time
e3c68b
+
e3c68b
+# Read glusterd UUID and extract first 32-bit of it
e3c68b
+def epoch_uuid():
e3c68b
+        file_name = '/var/lib/glusterd/glusterd.info'
e3c68b
+
e3c68b
+        for line in open(file_name):
e3c68b
+                if "UUID" in line:
e3c68b
+                        glusterd_uuid = line.split('=')[1].strip()
e3c68b
+
e3c68b
+        uuid_bin = binascii.unhexlify(glusterd_uuid.replace("-",""))
e3c68b
+
e3c68b
+        epoch_uuid = int(uuid_bin.encode('hex'), 32) & 0xFFFF0000
e3c68b
+        return epoch_uuid
e3c68b
+
e3c68b
+# Construct epoch as follows -
e3c68b
+#        first 32-bit contains the now() time
e3c68b
+#        rest 32-bit value contains the local glusterd node uuid
e3c68b
+epoch = (epoch_now() | epoch_uuid())
e3c68b
+print str(epoch)
e3c68b
+
e3c68b
+exit(0)
e3c68b
diff --git a/extras/hook-scripts/start/post/Makefile.am b/extras/hook-scripts/start/post/Makefile.am
e3c68b
index e32546d..792019d 100644
e3c68b
--- a/extras/hook-scripts/start/post/Makefile.am
e3c68b
+++ b/extras/hook-scripts/start/post/Makefile.am
e3c68b
@@ -1,4 +1,4 @@
e3c68b
-EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh
e3c68b
+EXTRA_DIST = S29CTDBsetup.sh S30samba-start.sh S31ganesha-start.sh
e3c68b
 
e3c68b
 hookdir = $(GLUSTERD_WORKDIR)/hooks/1/start/post/
e3c68b
 if WITH_SERVER
e3c68b
diff --git a/extras/hook-scripts/start/post/S31ganesha-start.sh b/extras/hook-scripts/start/post/S31ganesha-start.sh
e3c68b
new file mode 100755
e3c68b
index 0000000..90ba6bc
e3c68b
--- /dev/null
e3c68b
+++ b/extras/hook-scripts/start/post/S31ganesha-start.sh
e3c68b
@@ -0,0 +1,122 @@
e3c68b
+#!/bin/bash
e3c68b
+PROGNAME="Sganesha-start"
e3c68b
+OPTSPEC="volname:,gd-workdir:"
e3c68b
+VOL=
e3c68b
+declare -i EXPORT_ID
e3c68b
+ganesha_key="ganesha.enable"
e3c68b
+GANESHA_DIR="/var/run/gluster/shared_storage/nfs-ganesha"
e3c68b
+CONF1="$GANESHA_DIR/ganesha.conf"
e3c68b
+GLUSTERD_WORKDIR=
e3c68b
+
e3c68b
+function parse_args ()
e3c68b
+{
e3c68b
+        ARGS=$(getopt -l $OPTSPEC  -o "o" -name $PROGNAME $@)
e3c68b
+        eval set -- "$ARGS"
e3c68b
+
e3c68b
+        while true; do
e3c68b
+            case $1 in
e3c68b
+                --volname)
e3c68b
+                    shift
e3c68b
+                    VOL=$1
e3c68b
+                    ;;
e3c68b
+                --gd-workdir)
e3c68b
+                    shift
e3c68b
+                    GLUSTERD_WORKDIR=$1
e3c68b
+                    ;;
e3c68b
+                *)
e3c68b
+                    shift
e3c68b
+                    break
e3c68b
+                    ;;
e3c68b
+            esac
e3c68b
+            shift
e3c68b
+        done
e3c68b
+}
e3c68b
+
e3c68b
+
e3c68b
+
e3c68b
+#This function generates a new export entry as export.volume_name.conf
e3c68b
+function write_conf()
e3c68b
+{
e3c68b
+echo -e "# WARNING : Using Gluster CLI will overwrite manual
e3c68b
+# changes made to this file. To avoid it, edit the
e3c68b
+# file, copy it over to all the NFS-Ganesha nodes
e3c68b
+# and run ganesha-ha.sh --refresh-config."
e3c68b
+
e3c68b
+echo "EXPORT{"
e3c68b
+echo "      Export_Id = 2;"
e3c68b
+echo "      Path = \"/$VOL\";"
e3c68b
+echo "      FSAL {"
e3c68b
+echo "           name = \"GLUSTER\";"
e3c68b
+echo "           hostname=\"localhost\";"
e3c68b
+echo "           volume=\"$VOL\";"
e3c68b
+echo "           }"
e3c68b
+echo "      Access_type = RW;"
e3c68b
+echo "      Disable_ACL = true;"
e3c68b
+echo "      Squash=\"No_root_squash\";"
e3c68b
+echo "      Pseudo=\"/$VOL\";"
e3c68b
+echo "      Protocols = \"3\", \"4\" ;"
e3c68b
+echo "      Transports = \"UDP\",\"TCP\";"
e3c68b
+echo "      SecType = \"sys\";"
e3c68b
+echo "}"
e3c68b
+}
e3c68b
+
e3c68b
+#It adds the export dynamically by sending dbus signals
e3c68b
+function export_add()
e3c68b
+{
e3c68b
+        dbus-send --print-reply --system --dest=org.ganesha.nfsd \
e3c68b
+/org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.AddExport \
e3c68b
+string:$GANESHA_DIR/exports/export.$VOL.conf string:"EXPORT(Export_Id=$EXPORT_ID)"
e3c68b
+
e3c68b
+}
e3c68b
+
e3c68b
+# based on src/scripts/ganeshactl/Ganesha/export_mgr.py
e3c68b
+function is_exported()
e3c68b
+{
e3c68b
+        local volume="${1}"
e3c68b
+
e3c68b
+        dbus-send --type=method_call --print-reply --system \
e3c68b
+                  --dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
e3c68b
+                  org.ganesha.nfsd.exportmgr.ShowExports \
e3c68b
+            | grep -w -q "/${volume}"
e3c68b
+
e3c68b
+        return $?
e3c68b
+}
e3c68b
+
e3c68b
+# Check the info file (contains the volume options) to see if Ganesha is
e3c68b
+# enabled for this volume.
e3c68b
+function ganesha_enabled()
e3c68b
+{
e3c68b
+        local volume="${1}"
e3c68b
+        local info_file="${GLUSTERD_WORKDIR}/vols/${VOL}/info"
e3c68b
+        local enabled="off"
e3c68b
+
e3c68b
+        enabled=$(grep -w ${ganesha_key} ${info_file} | cut -d"=" -f2)
e3c68b
+
e3c68b
+        [ "${enabled}" == "on" ]
e3c68b
+
e3c68b
+        return $?
e3c68b
+}
e3c68b
+
e3c68b
+parse_args $@
e3c68b
+
e3c68b
+if ganesha_enabled ${VOL} && ! is_exported ${VOL}
e3c68b
+then
e3c68b
+        if [ ! -e ${GANESHA_DIR}/exports/export.${VOL}.conf ]
e3c68b
+        then
e3c68b
+                #Remove export entry from nfs-ganesha.conf
e3c68b
+                sed -i /$VOL.conf/d  $CONF1
e3c68b
+                write_conf ${VOL} > ${GANESHA_DIR}/exports/export.${VOL}.conf
e3c68b
+                EXPORT_ID=`cat $GANESHA_DIR/.export_added`
e3c68b
+                EXPORT_ID=EXPORT_ID+1
e3c68b
+                echo $EXPORT_ID > $GANESHA_DIR/.export_added
e3c68b
+                sed -i s/Export_Id.*/"Export_Id=$EXPORT_ID;"/ \
e3c68b
+                        $GANESHA_DIR/exports/export.$VOL.conf
e3c68b
+                echo "%include \"$GANESHA_DIR/exports/export.$VOL.conf\"" >> $CONF1
e3c68b
+        else
e3c68b
+                EXPORT_ID=$(grep ^[[:space:]]*Export_Id $GANESHA_DIR/exports/export.$VOL.conf |\
e3c68b
+                          awk -F"[=,;]" '{print $2}' | tr -d '[[:space:]]')
e3c68b
+        fi
e3c68b
+        export_add $VOL
e3c68b
+fi
e3c68b
+
e3c68b
+exit 0
e3c68b
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
e3c68b
index 0d57b49..dd7438c 100644
e3c68b
--- a/glusterfs.spec.in
e3c68b
+++ b/glusterfs.spec.in
e3c68b
@@ -299,7 +299,6 @@ Obsoletes:        hekafs
e3c68b
 Obsoletes:        %{name}-common < %{version}-%{release}
e3c68b
 Obsoletes:        %{name}-core < %{version}-%{release}
e3c68b
 Obsoletes:        %{name}-ufo
e3c68b
-Obsoletes:        %{name}-ganesha
e3c68b
 %if ( 0%{!?_with_gnfs:1} )
e3c68b
 Obsoletes:        %{name}-gnfs
e3c68b
 %endif
e3c68b
@@ -455,6 +454,30 @@ is in user space and easily manageable.
e3c68b
 This package provides support to FUSE based clients and inlcudes the
e3c68b
 glusterfs(d) binary.
e3c68b
 
e3c68b
+%if ( 0%{!?_without_server:1} )
e3c68b
+%package ganesha
e3c68b
+Summary:          NFS-Ganesha configuration
e3c68b
+Group:            Applications/File
e3c68b
+
e3c68b
+Requires:         %{name}-server%{?_isa} = %{version}-%{release}
e3c68b
+Requires:         nfs-ganesha-gluster, pcs, dbus
e3c68b
+%if ( 0%{?rhel} && 0%{?rhel} == 6 )
e3c68b
+Requires:         cman, pacemaker, corosync
e3c68b
+%endif
e3c68b
+
e3c68b
+%description ganesha
e3c68b
+GlusterFS is a distributed file-system capable of scaling to several
e3c68b
+petabytes. It aggregates various storage bricks over Infiniband RDMA
e3c68b
+or TCP/IP interconnect into one large parallel network file
e3c68b
+system. GlusterFS is one of the most sophisticated file systems in
e3c68b
+terms of features and extensibility.  It borrows a powerful concept
e3c68b
+called Translators from GNU Hurd kernel. Much of the code in GlusterFS
e3c68b
+is in user space and easily manageable.
e3c68b
+
e3c68b
+This package provides the configuration and related files for using
e3c68b
+NFS-Ganesha as the NFS server using GlusterFS
e3c68b
+%endif
e3c68b
+
e3c68b
 %if ( 0%{!?_without_georeplication:1} )
e3c68b
 %package geo-replication
e3c68b
 Summary:          GlusterFS Geo-replication
e3c68b
@@ -1111,6 +1134,12 @@ exit 0
e3c68b
 %endif
e3c68b
 %endif
e3c68b
 
e3c68b
+%if ( 0%{?_without_server:1} )
e3c68b
+#exclude ganesha related files
e3c68b
+%exclude %{_sysconfdir}/ganesha/*
e3c68b
+%exclude %{_libexecdir}/ganesha/*
e3c68b
+%endif
e3c68b
+
e3c68b
 %files api
e3c68b
 %exclude %{_libdir}/*.so
e3c68b
 # libgfapi files
e3c68b
@@ -1273,6 +1302,12 @@ exit 0
e3c68b
 %exclude %{_datadir}/glusterfs/tests/vagrant
e3c68b
 %endif
e3c68b
 
e3c68b
+%if ( 0%{!?_without_server:1} )
e3c68b
+%files ganesha
e3c68b
+%{_sysconfdir}/ganesha/*
e3c68b
+%{_libexecdir}/ganesha/*
e3c68b
+%endif
e3c68b
+
e3c68b
 %if ( 0%{!?_without_ocf:1} )
e3c68b
 %files resource-agents
e3c68b
 # /usr/lib is the standard for OCF, also on x86_64
e3c68b
@@ -1396,6 +1431,7 @@ exit 0
e3c68b
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post
e3c68b
             %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S29CTDBsetup.sh
e3c68b
             %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S30samba-start.sh
e3c68b
+            %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/post/S31ganesha-start.sh
e3c68b
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/start/pre
e3c68b
        %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop
e3c68b
 %ghost %dir %attr(0755,-,-) %{_sharedstatedir}/glusterd/hooks/1/stop/post
e3c68b
@@ -1868,6 +1904,9 @@ fi
e3c68b
 %endif
e3c68b
 
e3c68b
 %changelog
e3c68b
+* Fri Apr 5 2019 Jiffin Tony Thottan <jthottan@redhat.com>
e3c68b
+- Adding ganesha bits back in gluster repository
e3c68b
+
e3c68b
 * Wed Mar 6 2019 Kaleb S. KEITHLEY <kkeithle@redhat.com>
e3c68b
 - remove unneeded ldconfig in scriptlets
e3c68b
 -  reported by Igor Gnatenko in Fedora
e3c68b
@@ -1960,9 +1999,6 @@ fi
e3c68b
 * Thu Feb 16 2017 Niels de Vos <ndevos@redhat.com>
e3c68b
 - Obsolete and Provide python-gluster for upgrading from glusterfs < 3.10
e3c68b
 
e3c68b
-* Tue Feb 7 2017 Kaleb S. KEITHLEY <kkeithle@redhat.com>
e3c68b
-- remove ganesha (#1418417)
e3c68b
-
e3c68b
 * Wed Feb 1 2017 Poornima G <pgurusid@redhat.com>
e3c68b
 - Install /var/lib/glusterd/groups/metadata-cache by default
e3c68b
 
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b