dragonflow/devstack/etcd_driver
Eran Gampel cc8d1d7e6e Do not fail on mkdir for etcd version upgrade
Change-Id: I42af9ba1d92c6ace9f869b159e13a6c27df32f71
2015-11-30 15:46:26 +02:00

59 lines
1.7 KiB
Bash

#!/bin/bash
#
#
# ``plugin.sh`` calls the following methods in the sourced driver:
#
# - nb_db_driver_install_server
# - nb_db_driver_install_client
# - nb_db_driver_start_server
# - nb_db_driver_stop_server
# - nb_db_driver_clean
ETCD_VERSION=v2.2.2
function nb_db_driver_install_server {
if is_service_enabled df-etcd-server ; then
echo "Installing etcd"
rm -rf $DEST/etcd/db.etcd
if [ ! -f "$DEST/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd" ]; then
echo "Installing etcd server"
mkdir -p $DEST/etcd
wget https://github.com/coreos/etcd/releases/download/$ETCD_VERSION/etcd-$ETCD_VERSION-linux-amd64.tar.gz -O $DEST/etcd/etcd-$ETCD_VERSION-linux-amd64.tar.gz
tar xzvf $DEST/etcd/etcd-$ETCD_VERSION-linux-amd64.tar.gz -C $DEST/etcd
fi
fi
}
function nb_db_driver_install_client {
local _pwd=$(pwd)
if [ ! -d $DEST/python-etcd ] ; then
echo "Installing etcd client"
git clone https://github.com/jplana/python-etcd.git $DEST/python-etcd
cd $DEST/python-etcd
sudo python setup.py install
cd $_pwd
echo "Finished installing etcd"
fi
}
function nb_db_driver_status_server
{
TEMP_PIDS=`ps cax | grep etcd`
if [ -z "$TEMP_PIDS" ]; then
return 1
fi
return 0
}
function nb_db_driver_start_server {
if is_service_enabled df-etcd-server ; then
$DEST/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd --listen-client-urls http://$REMOTE_DB_IP:4001 --advertise-client-urls http://$REMOTE_DB_IP:4001 --data-dir $DEST/etcd/db.etcd &
fi
}
function nb_db_driver_stop_server {
if is_service_enabled df-etcd-server ; then
sudo killall etcd 2&> /dev/null
fi
}