Created
February 27, 2015 07:54
-
-
Save BugRoger/af71c9531e17bbc7f147 to your computer and use it in GitHub Desktop.
Ceph Mon Orchestration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -n "$MON_NAME" ]; then | |
echo "ERROR- MON_NAME must be defined as the name of the monitor" | |
exit 1 | |
fi | |
if [ ! -n "$MON_IP" ]; then | |
echo "ERROR- MON_IP must be defined as the IP address of the monitor" | |
exit 1 | |
fi | |
CLUSTER=${CLUSTER:-ceph} | |
CLUSTER_PATH=/ceph/$CLUSTER | |
if ! etcdctl get ${CLUSTER_PATH}/completed > /dev/null 2>%1 ; then | |
if etcdctl get ${CLUSTER_PATH}/monitor-lock > /dev/null 2>&1 ; then | |
while monitor=$(etcdctl get ${CLUSTER_PATH}/monitor-lock 2> /dev/null) ; do | |
echo "waiting for monitor ${monitor} to finish initialization" | |
sleep 1 | |
done | |
else | |
echo "aquiring lock for ${MON_NAME}" | |
etcdctl mk ${CLUSTER_PATH}/monitor-lock ${MON_NAME} --ttl 15 > /dev/null 2>&1 | |
sleep 10 | |
echo "completed initialization for ${MON_NAME}" | |
etcdctl set ${CLUSTER_PATH}/completed true --ttl 10 > /dev/null 2>&1 | |
etcdctl rm ${CLUSTER_PATH}/monitor-lock > /dev/null 2>&1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment