3604df
From b45d1de28c5bc3806af09e2753c5f3396ca9e199 Mon Sep 17 00:00:00 2001
3604df
From: Jiffin Tony Thottan <jthottan@redhat.com>
3604df
Date: Wed, 13 Jul 2016 12:09:43 +0530
3604df
Subject: [PATCH 60/86] ganesha/scripts : Modifying ganesha-ha.sh for share storage related changes
3604df
3604df
Currently the ganesha related configurations are "scp"ied for operations like
3604df
add, delete, refresh-config in ganesha-ha.sh. This is no more required since
3604df
all the conf files are available in shared storage and every node can directly
3604df
access them from shared storage.
3604df
3604df
More details can be found at http://review.gluster.org/#/c/15105/
3604df
3604df
Upstream reference:
3604df
>Change-Id: Ic025eb4dc246db61d6fbe969ca60214751fbf3ba
3604df
>BUG: 1355956
3604df
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
3604df
>Reviewed-on: http://review.gluster.org/14909
3604df
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: soumya k <skoduri@redhat.com>
3604df
>Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
>Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
3604df
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
3604df
3604df
Change-Id: Ic025eb4dc246db61d6fbe969ca60214751fbf3ba
3604df
BUG: 1348962
3604df
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/84779
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 extras/ganesha/scripts/ganesha-ha.sh |   76 +++++----------------------------
3604df
 1 files changed, 12 insertions(+), 64 deletions(-)
3604df
3604df
diff --git a/extras/ganesha/scripts/ganesha-ha.sh b/extras/ganesha/scripts/ganesha-ha.sh
3604df
index ada21cb..de7c425 100644
3604df
--- a/extras/ganesha/scripts/ganesha-ha.sh
3604df
+++ b/extras/ganesha/scripts/ganesha-ha.sh
3604df
@@ -106,6 +106,16 @@ manage_service ()
3604df
 {
3604df
         local action=${1}
3604df
         local new_node=${2}
3604df
+        local option=
3604df
+
3604df
+        if [ "$action" == "start" ]; then
3604df
+                option="yes"
3604df
+        else
3604df
+                option="no"
3604df
+        fi
3604df
+        ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
3604df
+${SECRET_PEM} root@${new_node} "/usr/libexec/ganesha/ganesha-ha.sh --setup-ganesha-conf-files $HA_CONFDIR $option"
3604df
+
3604df
         if [ "$SERVICE_MAN" == "/usr/bin/systemctl" ]
3604df
         then
3604df
                 ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
3604df
@@ -224,48 +234,20 @@ setup_finalize_ha()
3604df
 }
3604df
 
3604df
 
3604df
-setup_copy_config()
3604df
-{
3604df
-    local short_host=$(hostname -s)
3604df
-    local tganesha_conf=$(mktemp -u)
3604df
-
3604df
-    if [ -e ${SECRET_PEM} ]; then
3604df
-        while [[ ${1} ]]; do
3604df
-            current_host=`echo ${1} | cut -d "." -f 1`
3604df
-            if [ ${short_host} != ${current_host} ]; then
3604df
-                scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
3604df
-${SECRET_PEM} ${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/
3604df
-                if [ $? -ne 0 ]; then
3604df
-                    logger "warning: scp ganesha-ha.conf to ${1} failed"
3604df
-                fi
3604df
-            fi
3604df
-            shift
3604df
-        done
3604df
-    else
3604df
-        logger "warning: scp ganesha-ha.conf to ${1} failed"
3604df
-    fi
3604df
-}
3604df
-
3604df
 refresh_config ()
3604df
 {
3604df
         local short_host=$(hostname -s)
3604df
         local VOL=${1}
3604df
         local HA_CONFDIR=${2}
3604df
-        local tganesha_vol_conf=$(mktemp)
3604df
         local short_host=$(hostname -s)
3604df
 
3604df
-        cp ${HA_CONFDIR}/exports/export.$VOL.conf \
3604df
-${tganesha_vol_conf}
3604df
+        removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\
3604df
+grep Export_Id | awk -F"[=,;]" '{print$2}' | tr -d '[[:space:]]'`
3604df
 
3604df
         if [ -e ${SECRET_PEM} ]; then
3604df
         while [[ ${3} ]]; do
3604df
             current_host=`echo ${3} | cut -d "." -f 1`
3604df
             if [ ${short_host} != ${current_host} ]; then
3604df
-                removed_id=$(ssh -oPasswordAuthentication=no \
3604df
--oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \
3604df
-"cat $HA_CONFDIR/exports/export.$VOL.conf |\
3604df
-grep Export_Id | awk -F\"[=,;]\" '{print \$2}' | tr -d '[[:space:]]'")
3604df
-
3604df
                 output=$(ssh -oPasswordAuthentication=no \
3604df
 -oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \
3604df
 "dbus-send --print-reply --system --dest=org.ganesha.nfsd \
3604df
@@ -278,14 +260,6 @@ uint16:$removed_id 2>&1")
3604df
                        exit 1
3604df
                 fi
3604df
                 sleep 1
3604df
-                sed -i s/Export_Id.*/"Export_Id= $removed_id ;"/ \
3604df
-                        ${tganesha_vol_conf}
3604df
-
3604df
-                scp -q -oPasswordAuthentication=no \
3604df
--oStrictHostKeyChecking=no -i \
3604df
-${SECRET_PEM} ${tganesha_vol_conf} \
3604df
-${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf
3604df
-
3604df
                 output=$(ssh -oPasswordAuthentication=no \
3604df
 -oStrictHostKeyChecking=no -i ${SECRET_PEM} root@${current_host} \
3604df
 "dbus-send --print-reply --system --dest=org.ganesha.nfsd \
3604df
@@ -310,8 +284,6 @@ string:\"EXPORT(Path=/$VOL)\" 2>&1")
3604df
     fi
3604df
 
3604df
     # Run the same command on the localhost,
3604df
-        removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\
3604df
-grep Export_Id | awk -F"[=,;]" '{print$2}' | tr -d '[[:space:]]'`
3604df
         output=$(dbus-send --print-reply --system --dest=org.ganesha.nfsd \
3604df
 /org/ganesha/nfsd/ExportMgr org.ganesha.nfsd.exportmgr.RemoveExport \
3604df
 uint16:$removed_id 2>&1)
3604df
@@ -334,22 +306,6 @@ string:"EXPORT(Path=/$VOL)" 2>&1)
3604df
         else
3604df
                 echo "Success: refresh-config completed."
3604df
         fi
3604df
-        rm -f ${tganesha_vol_conf}
3604df
-
3604df
-}
3604df
-
3604df
-copy_export_config ()
3604df
-{
3604df
-    local new_node=${1}
3604df
-
3604df
-    # The add node should be executed from one of the nodes in ganesha
3604df
-    # cluster. So all the configuration file will be available in that
3604df
-    # node itself. So just copy that to new node
3604df
-    scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
3604df
-${SECRET_PEM} ${GANESHA_CONF} ${new_node}:${GANESHA_CONF}
3604df
-
3604df
-    scp -r -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
3604df
-${SECRET_PEM} ${HA_CONFDIR}/exports/ ${new_node}:${HA_CONFDIR}/
3604df
 }
3604df
 
3604df
 
3604df
@@ -870,8 +826,6 @@ main()
3604df
 
3604df
             setup_state_volume ${HA_SERVERS}
3604df
 
3604df
-            setup_copy_config ${HA_SERVERS}
3604df
-
3604df
         else
3604df
 
3604df
             logger "insufficient servers for HA, aborting"
3604df
@@ -898,8 +852,6 @@ main()
3604df
 
3604df
         logger "adding ${node} with ${vip} to ${HA_NAME}"
3604df
 
3604df
-        copy_export_config ${node} ${HA_CONFDIR}
3604df
-
3604df
         determine_service_manager
3604df
 
3604df
         manage_service "start" ${node}
3604df
@@ -925,8 +877,6 @@ main()
3604df
         sed -i s/HA_CLUSTER_NODES.*/"HA_CLUSTER_NODES=\"$NEW_NODES\""/ \
3604df
 $HA_CONFDIR/ganesha-ha.conf
3604df
         HA_SERVERS="${HA_SERVERS} ${node}"
3604df
-
3604df
-        setup_copy_config ${HA_SERVERS}
3604df
         ;;
3604df
 
3604df
     delete | --delete)
3604df
@@ -945,8 +895,6 @@ $HA_CONFDIR/ganesha-ha.conf
3604df
 
3604df
         deletenode_update_haconfig ${node}
3604df
 
3604df
-        setup_copy_config ${HA_SERVERS}
3604df
-
3604df
         rm -rf ${HA_VOL_MNT}/nfs-ganesha/${node}
3604df
 
3604df
         determine_service_manager
3604df
-- 
3604df
1.7.1
3604df