83 lines
3.1 KiB
Bash
83 lines
3.1 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
|
|
|
|
RAMCLOUD=$DEST/ramcloud
|
|
RAMCLOUD_LIB=$RAMCLOUD/lib
|
|
RAMCLOUD_BIN=$RAMCLOUD/bin
|
|
RAMCLOUD_MASTER_IP=${RAMCLOUD_MASTER_IP:-"$HOST_IP"}
|
|
RAMCLOUD_COORDINATOR_IP=${RAMCLOUD_COORDINATOR_IP:-"$HOST_IP"}
|
|
RAMCLOUD_MASTER_PORT=${RAMCLOUD_MASTER_PORT:-'21221'}
|
|
RAMCLOUD_COORDINATOR_PORT=${RAMCLOUD_COORDINATOR_PORT:-'21222'}
|
|
RAMCLOUD_TRANSPORT=${RAMCLOUD_TRANSPORT:-'fast+udp'}
|
|
RAMCLOUD_TABLE_NAMES=${RAMCLOUD_TABLE_NAMES:-'secgroup','dragonflow','chassis','lswitch','lport','lrouter','tunnel_key'}
|
|
|
|
function nb_db_driver_install_server {
|
|
if is_service_enabled df-rcmaster ; then
|
|
echo "Installing Dependencies"
|
|
if is_ubuntu; then
|
|
install_package libboost-program-options1.54 libprotobuf8 libboost-filesystem1.54.0
|
|
elif is_suse || is_oraclelinux; then
|
|
install_package libboost_program_options1_54_0 libprotobuf8 libboost_filesystem1_54_0
|
|
elif is_fedora; then
|
|
install_package libboost_program_options1_54_0 protobuf libboost_filesystem1_54_0
|
|
fi
|
|
echo "Installing RAMCloud server"
|
|
git_clone https://github.com/dsivov/RamCloudBin.git $RAMCLOUD
|
|
echo export LD_LIBRARY_PATH="$RAMCLOUD_LIB":"$LD_LIBRARY_PATH" | tee -a $HOME/.bashrc
|
|
fi
|
|
}
|
|
|
|
function nb_db_driver_install_client {
|
|
echo "Installing RAMCloud client"
|
|
git_clone https://github.com/dsivov/RamCloudBin.git $RAMCLOUD
|
|
}
|
|
|
|
function nb_db_driver_status_server
|
|
{
|
|
if is_service_enabled df-rccoordinator ; then
|
|
TEMP_PIDS=`ps cax | grep coordinator`
|
|
if [ -z "$TEMP_PIDS" ]; then
|
|
return 1
|
|
fi
|
|
fi
|
|
if is_service_enabled df-rcmaster ; then
|
|
TEMP_PIDS=`ps cax | grep " server"`
|
|
if [ -z "$TEMP_PIDS" ]; then
|
|
return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
function nb_db_driver_start_server {
|
|
if is_service_enabled df-rccoordinator ; then
|
|
$RAMCLOUD_BIN/coordinator -C ${RAMCLOUD_TRANSPORT}:host=${RAMCLOUD_COORDINATOR_IP},port=${RAMCLOUD_COORDINATOR_PORT} 2&> /dev/null || true &
|
|
fi
|
|
if is_service_enabled df-rcmaster ; then
|
|
sleep 10
|
|
$RAMCLOUD_BIN/server -L ${RAMCLOUD_TRANSPORT}:host=${RAMCLOUD_MASTER_IP},port=${RAMCLOUD_MASTER_PORT} -C ${RAMCLOUD_TRANSPORT}:host=${RAMCLOUD_COORDINATOR_IP},port=${RAMCLOUD_COORDINATOR_PORT} 2&> /dev/null || true &
|
|
echo "Sleep for 20 secs. Giving time for db to start working!!!"
|
|
sleep 20
|
|
echo "CREATING RAMCLOUD TABLES..."
|
|
export PYTHONPATH=$PYTHONPATH:$DEST/dragonflow/
|
|
python $DEST/dragonflow/dragonflow/db/drivers/table_setup_ramcloud.py -d ramcloud -t ${RAMCLOUD_TABLE_NAMES} -i ${RAMCLOUD_COORDINATOR_IP} -p ${RAMCLOUD_COORDINATOR_PORT} > /dev/null || true
|
|
fi
|
|
}
|
|
|
|
function nb_db_driver_stop_server {
|
|
if is_service_enabled df-rccoordinator ; then
|
|
sudo killall coordinator 2&> /dev/null || true
|
|
fi
|
|
if is_service_enabled df-rcmaster ; then
|
|
sudo killall server 2&> /dev/null || true
|
|
fi
|
|
}
|