NFS-Ganesha : Implement refresh-config

It is important that we give an automatic way of refreshing the config
when the user has changed the export file manually.
Without this, the user will be forced to restart the server.
Implementing refresh_config by utilizing two other scripts
that are already in place.
Making a few changes to make sure that "--help"
doesn't throw unnecessary error messages.

Change-Id: I6559b89e858526717168ba286e1ff7d9977097c6
BUG: 1233624
Signed-off-by: Meghana M <mmadhusu@redhat.com>
Reviewed-on: http://review.gluster.org/11331
Reviewed-by: soumya k <skoduri@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
This commit is contained in:
Meghana M 2015-06-19 05:48:05 +05:30 committed by Kaleb KEITHLEY
parent 21f2719bf4
commit 1ff820381b
2 changed files with 89 additions and 15 deletions

View File

@ -4,14 +4,16 @@ declare -i EXPORT_ID
GANESHA_DIR=${1%/}
OPTION=$2
VOL=$3
CONF=$(cat /etc/sysconfig/ganesha | grep "CONFFILE" | cut -f 2 -d "=")
cfgline=$(grep ^CONFFILE= /etc/sysconfig/ganesha)
eval $(echo ${cfgline} | grep -F CONFFILE=)
CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
function check_cmd_status()
{
if [ "$1" != "0" ]
then
rm -rf $GANESHA_DIR/exports/export.$VOL.conf
sed -i /$VOL.conf/d $CONF
exit 1
fi
}
@ -20,7 +22,7 @@ function check_cmd_status()
function dynamic_export_add()
{
count=`ls -l $GANESHA_DIR/exports/*.conf | wc -l`
if [ "$count" = "1" ] ;
if [ "$count" = "0" ] ;
then
EXPORT_ID=2
else

View File

@ -32,6 +32,17 @@ GANESHA_CONF=${CONFFILE:-/etc/ganesha/ganesha.conf}
RHEL6_PCS_CNAME_OPTION="--name"
usage() {
echo "Usage : add|delete|status"
echo "Add-node : ganesha-ha.sh --add <HA_CONF_DIR> \
<NODE-HOSTNAME> <NODE-VIP>"
echo "Delete-node: ganesha-ha.sh --delete <HA_CONF_DIR> \
<NODE-HOSTNAME>"
echo "Refresh-config : ganesha-ha.sh --refresh-config <HA_CONFDIR>\
<volume>"
}
determine_service_manager () {
if [ -e "/usr/bin/systemctl" ];
@ -171,12 +182,17 @@ setup_finalize()
setup_copy_config()
{
local short_host=$(hostname -s)
local tganesha_conf=$(mktemp -u)
if [ -e /var/lib/glusterd/nfs/secret.pem ]; then
while [[ ${1} ]]; do
if [ ${short_host} != ${1} ]; then
current_host=`echo ${1} | cut -d "." -f 1`
if [ ${short_host} != ${current_host} ]; then
cp ${HA_CONFDIR}/ganesha-ha.conf ${tganesha_conf}
scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
/var/lib/glusterd/nfs/secret.pem ${1}:${HA_CONFDIR}/ganesha-ha.conf ${1}:${HA_CONFDIR}/
/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_conf}\
${1}:${HA_CONFDIR}/ganesha-ha.conf
rm -rf ${tganesha_conf}
if [ $? -ne 0 ]; then
logger "warning: scp ganesha-ha.conf to ${1} failed"
fi
@ -188,6 +204,56 @@ setup_copy_config()
fi
}
refresh_config ()
{
local short_host=$(hostname -s)
local VOL=${1}
local HA_CONFDIR=${2}
local tganesha_export=$(mktemp -u)
removed_id=`cat $HA_CONFDIR/exports/export.$VOL.conf |\
grep Export_Id | cut -d " " -f8`
if [ -e /var/lib/glusterd/nfs/secret.pem ]; then
while [[ ${3} ]]; do
current_host=`echo ${3} | cut -d "." -f 1`
if [ ${short_host} != ${current_host} ]; then
cp ${HA_CONFDIR}/exports/export.$VOL.conf ${tganesha_export}
scp -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
/var/lib/glusterd/nfs/secret.pem ${short_host}:${tganesha_export} \
${current_host}:${HA_CONFDIR}/exports/export.$VOL.conf
rm -rf ${tganesha_export}
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --print-reply --system \
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id"
sleep 1
ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no -i \
/var/lib/glusterd/nfs/secret.pem root@${current_host} "dbus-send --system \
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \
string:\"EXPORT(Path=/$VOL)\""
if [ $? -ne 0 ]; then
echo "warning: refresh-config failed on ${current_host}"
fi
fi
shift
done
else
echo "warning: refresh-config failed on ${1}"
fi
#Run the same command on the localhost,
dbus-send --print-reply --system \
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
org.ganesha.nfsd.exportmgr.RemoveExport uint16:$removed_id
sleep 1
dbus-send --system \
--dest=org.ganesha.nfsd /org/ganesha/nfsd/ExportMgr \
org.ganesha.nfsd.exportmgr.AddExport string:$HA_CONFDIR/exports/export.$VOL.conf \
string:"EXPORT(Path=/$VOL)"
}
copy_export_config ()
{
local new_node=${1}
@ -740,7 +806,14 @@ setup_state_volume()
main()
{
local cmd=${1}; shift
if [[ ${cmd} == *help ]]
then
usage
exit 0
fi
HA_CONFDIR=${1}; shift
local ha_conf=${HA_CONFDIR}/ganesha-ha.conf
local node=""
@ -864,18 +937,17 @@ $HA_CONFDIR/ganesha-ha.conf
;;
refresh-config | --refresh-config)
VOL=${1}
determine_servers "refresh-config"
refresh_config ${VOL} ${HA_CONFDIR} ${HA_SERVERS}
;;
help | --help)
echo "Usage : add|delete|status"
echo "Add-node : ganesha-ha.sh --add <HA_CONFDIR> \
<NODE-IP/HOSTNAME> <NODE-VIP>"
echo "Delete-node: ganesha-ha.sh --delete <HA_CONFDIR> \
<NODE-IP/HOSTNAME>"
;;
*)
# setup and teardown are not intended to be used by a
# casual user
usage
logger "Usage: ganesha-ha.sh add|delete|status"
;;