Fix the directory layout, make it work within devstack too.

Depends-On: Icb7347d55dc5b22720269405b6d2b4053c2ad819

Change-Id: I015001028cd9486c0d89e90c1b40c848d5fe8485
This commit is contained in:
Philipp Marek 2015-06-15 14:21:06 +02:00
parent 965b6ed026
commit 15e2783769
6 changed files with 198 additions and 220 deletions

183
devstack/lib/drbd_devstack Executable file
View File

@ -0,0 +1,183 @@
#!/bin/bash
# vim: set et ts=4 sw=4 ft=sh :
function pre_install_drbd_devstack {
# Install OS packages, if necessary
if [[ ! -d "${FILES:?FILES not set yet}" ]]; then
mkdir "${FILES}"
fi
packages=('drbd-utils_8.9.3rc1-1_amd64.deb' 'drbd8-utils_8.9.3rc1-1_amd64.deb' 'drbd-dkms_9.0.0rc3-1_all.deb' 'python-drbdmanage_0.36-1_all.deb');
# get packages
for p in "${packages[@]}"; do
if [[ ! -f "${FILES}/${p}" ]]; then
# If there are newer packages, change the download number here.
wget "http://openstack-ci-pkgs.linbit.com/packages/001/trusty/$p" -O "${FILES}/${p}"
fi
done
# install packages
for i in "${packages[@]}"; do
if [[ -f "${FILES}/${i}" ]]; then
echo "installing ${i}"
sudo dpkg -i "${FILES}/${i}" || true
fi
done
# Hotfix, until DRBDmanage 0.42 is released.
sudo sed -i "s/NAME_MAXLEN\s*=.*/NAME_MAXLEN = 4095/" /usr/lib/python2.7/dist-packages/drbdmanage/storage/storagecore.py
# now go fetch :)
echo echo "installing deps"
#sudo apt-get update
sudo apt-get install -f -y
sudo apt-get install python-dbus -y
return 0
}
function install_drbd_devstack {
# Install the service.
# write /etc/drbdmanage*.conf
#echo "drbdctrl-vg = $DRBD_DRBDCTRL_VG" >> /etc/drbdmanaged.conf
#echo "volume-group = $DRBD_DATA_VG" >> /etc/drbdmanaged-lvm.conf
sudo sed -i "s/^drbdctrl-vg\s*=.*/drbdctrl-vg = ${DRBD_DRBDCTRL_VG}/g" /etc/drbdmanaged.conf
sudo sed -i "s/^volume-group\s*=.*/volume-group = ${DRBD_DATA_VG}/g" /etc/drbdmanaged-lvm.conf
sudo sed -i "s/^volume-group\s*=.*/volume-group = ${DRBD_DATA_VG}/g" /etc/drbdmanaged-lvm-thinpool.conf
sudo sed -i "s/^volume-group\s*=.*/volume-group = ${DRBD_DATA_VG}/g" /etc/drbdmanaged-lvm-thinlv.conf
# Use the single-thinpool driver for these tests.
# sudo sed -i "s/^storage-plugin\s*=.*/storage-plugin = drbdmanage.storage.lvm_thinpool_ng.LvmThinPoolNg/g" /etc/drbdmanaged.conf
sudo sed -i "s/^storage-plugin\s*=.*/storage-plugin = drbdmanage.storage.lvm_thinlv.LvmThinLv/g" /etc/drbdmanaged.conf
# allow the stack user access to drbdmanage
sudo tee /etc/dbus-1/system.d/org.drbd.drbdmanaged-stack.conf > /dev/null << "EOF"
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="stack">
<allow send_destination="org.drbd.drbdmanaged"/>
</policy>
</busconfig>
EOF
# done.
}
function _drbd_make_vg {
local vg_name="${1:?No VG name given}"
local vg_size="$2"
local vg_lo_dev="$3"
local vg_dev="/dev/${vg_lo_dev}"
# If the VG exists, there's nothing left to do.
if sudo vgdisplay | grep -q "${vg_name}" ; then
return
fi
# if the file exists, don't destroy it...
if [[ ! -f "${FILES}/${vg_name}" ]]; then
sudo truncate -s "${vg_size}" "${FILES}/${vg_name}"
fi
# if the loop device is present, don't recreate it...
if [[ ! -e "${vg_dev}" ]]; then
local vg_lo_minor="$(echo "${vg_lo_dev}" | sed 's/loop//g')"
sudo mknod -m 660 "${vg_dev}" b 7 "${vg_lo_minor}"
fi
# if the file is already assigned a loop device, don't reassign
if ! sudo losetup -a | grep "${vg_lo_dev}" | grep -q "${vg_name}" ; then
sudo losetup "${vg_dev}" "${FILES}/${vg_name}"
fi
local lvm_cfg="devices { global_filter=[ 'a|$vg_lo_dev|' ] }"
# # if the lvm.conf already accepts the loop device, don't insert it again
# if ! sudo grep -q "${vg_lo_dev}" /etc/lvm/lvm.conf ; then
# sudo sed -i.drbdctrl-bak "s/global_filter = \[ /global_filter = \[ \"a|${vg_lo_dev}|\", /g" /etc/lvm/lvm.conf
# fi
# if theres already a pv signature, don't try to recreate
if ! sudo pvdisplay | grep -q "${vg_lo_dev}" ; then
sudo pvscan --config "$lvm_cfg"
if sudo pvdisplay | grep -q "${vg_lo_dev}" ; then
sudo pvcreate --config "$lvm_cfg" "${vg_dev}"
fi
fi
# if theres already a vg, don't try to recreate
if ! sudo vgdisplay | grep -q "${vg_name}" ; then
sudo vgscan
if ! sudo vgdisplay | grep -q "${vg_name}" ; then
sudo vgcreate --config "$lvm_cfg" "${vg_name}" "${vg_dev}"
fi
fi
}
function configure_drbd_devstack {
# Configure the service.
# This gets called before starting the c-vol service; the next callback,
# init_drbd_devstack, is too late for that, so we need to make DRBDmanage
# operational here.
local be_name="${1:-drbdmanage}"
# Initialize and start the service.
# need to setup loopback device(s) for DRBD
_drbd_make_vg "${DRBD_DRBDCTRL_VG:?DRBD_DRBDCTRL_VG is not set}" "${DRBD_DRBDCTRL_VG_SZ}" "${DRBD_DRBDCTRL_LODEV}"
# Do the same thing for the DATA volume group
_drbd_make_vg "${DRBD_DATA_VG:?DRBD_DATA_VG is not set}" "${DRBD_DATA_VG_SZ}" "${DRBD_DATA_LODEV}"
local thinpool_size=$(echo $(LC_ALL=C sudo vgdisplay --columns --units M --noheadings -o vg_free --nosuffix "${DRBD_DATA_VG}") \* 30 / 32 - 64 | bc)
if ! sudo lvdisplay "${DRBD_DATA_VG}/drbdthinpool" ; then
sudo /sbin/lvcreate -L "${thinpool_size}"M -T "${DRBD_DATA_VG}/drbdthinpool"
fi
# initialize drbdmanage
sudo drbdmanage init --quiet
sudo drbdmanage shutdown --quiet
sudo drbdmanage debug 'set loglevel=debug'
# FIXME: multi-node setups
iniset $CINDER_CONF "$be_name" volume_backend_name "$be_name"
iniset $CINDER_CONF "$be_name" volume_driver cinder.volume.drivers.drbdmanagedrv.DrbdManageDriver
}
function init_drbd_devstack {
true
}
function shutdown_drbd_devstack {
# Shut the service down.
# drbdadm down all
# drbdmanage shutdown --quiet
echo "shutdown drbd devstack"
}
function cleanup_drbd_devstack {
# Cleanup the service.
# something like
# drbdmanage list-resource --short | xargs -l drbdmanage remove-resource
# ???
# drbdmanage resources -m | sed 's/,.*//g' | xargs -l drbdmanage remove-resource --quiet
echo "cleanup drbd devstack"
}
#debug main
#source $(dirname '$0')/../settings
#pre_install_drbd_devstack
#install_drbd_devstack
#configure_drbd_devstack
#init_drbd_devstack
# Tell emacs to use shell-script-mode
## Local variables:
## mode: shell-script
## End:

View File

@ -1,12 +1,16 @@
# check for service enabled
if is_service_enabled drbd_devstack; then
if [[ "$1" == "source" ]]; then
# Initial source of lib script
source $(dirname "$0")/lib/drbd_devstack
fi
# order of calls is
# pre_install_drbd_devstack
# install_drbd_devstack
# configure_drbd_devstack
# init_drbd_devstack
if is_service_enabled drbd-devstack; then
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
source "$dir/devstack/settings"
# Set up system services
source "$dir/devstack/lib/drbd_devstack"
echo_summary "Configuring system services drbd_devstack"
pre_install_drbd_devstack
@ -28,14 +32,14 @@ if is_service_enabled drbd_devstack; then
if [[ "$1" == "unstack" ]]; then
# Shut down drbd_devstack services
# no-op
source "$dir/devstack/lib/drbd_devstack"
shutdown_drbd_devstack
fi
if [[ "$1" == "clean" ]]; then
# Remove state and transient data
# Remember clean.sh first calls unstack.sh
# no-op
source "$dir/devstack/lib/drbd_devstack"
cleanup_drbd_devstack
fi
fi

View File

@ -1,10 +1,10 @@
# Devstack settings
TEMPEST_STORAGE_PROTOCOL=drbd
FILES="${FILES:-$TOP_DIR/files}"
TEMPEST_STORAGE_PROTOCOL=iSCSI
DRBD_DRBDCTRL_VG_SZ=1G
DRBD_DRBDCTRL_LODEV=loop66
DRBD_DRBDCTRL_VG=drbdpool
DRBD_DATA_VG_SZ=7G
DRBD_DATA_VG_SZ="$VOLUME_BACKING_FILE_SIZE"
DRBD_DATA_VG=drbddata
DRBD_DATA_LODEV=loop67

View File

@ -1,209 +0,0 @@
#!/bin/bash
# vim: set et ts=4 sw=4 ft=sh :
# Can we set global variables here?
# Hash to access LINBIT repositories
FILES="$(dirname '$0')/files"
function pre_install_drbd_devstack {
# Install OS packages, if necessary
# see wget logic in https://github.com/openstack-dev/devstack/blob/master/pkg/elasticsearch.sh
# drbdmanage, drbd-dkms, drbd-utils
if [[ ! -d ${FILES} ]]; then
mkdir ${FILES}
fi
# drbd-dkms="drbd-dkms_9.0.0rc2-1_all.deb"
# drbd-utils="drbd-utils_8.9.2+linbit-1_amd64.deb"
# drbd-manage="python-drbdmanage_0.20-33_all.deb"
packages=('drbd-utils_8.9.3rc1-1_amd64.deb' 'drbd8-utils_8.9.3rc1-1_amd64.deb' 'drbd-dkms_9.0.0rc3-1_all.deb' 'python-drbdmanage_0.34-1_all.deb');
# get packages
for p in "${packages[@]}"; do
if [[ ! -f ${FILES}/${p}* ]]; then
# If there are newer packages, change the download number here.
wget "http://openstack-ci-pkgs.linbit.com/packages/001/trusty/$p" -O ${FILES}/${p}
fi
done
# install packages
for i in "${packages[@]}"; do
if [[ -f "${FILES}/${i}" ]]; then
echo "installing ${i}"
sudo dpkg -i ${FILES}/${i} || true
fi
done
# now go fetch :)
echo echo "installing deps"
#sudo apt-get update
sudo apt-get install -f -y
sudo apt-get install python-dbus -y
return 0
}
function install_drbd_devstack {
# Install the service.
# write /etc/drbdmanage*.conf
#echo "drbdctrl-vg = $DRBD_DRBDCTRL_VG" >> /etc/drbdmanaged.conf
#echo "volume-group = $DRBD_DATA_VG" >> /etc/drbdmanaged-lvm.conf
sudo sed -i "s/^drbdctrl-vg\s*=.*/drbdctrl-vg = ${DRBD_DRBDCTRL_VG}/g" /etc/drbdmanaged.conf
sudo sed -i "s/^volume-group\s*=.*/volume-group = ${DRBD_DATA_VG}/g" /etc/drbdmanaged-lvm.conf
# allow the stack user access to drbdmanage
sudo echo << "EOF" > /etc/dbus-1/system.d/org.drbd.drbdmanaged-stack.conf
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="stack">
<allow send_destination="org.drbd.drbdmanaged"/>
</policy>
</busconfig>
EOF
# done.
}
function configure_drbd_devstack {
# Configure the service.
local be_name="${1:-drbdmanage}"
iniset $CINDER_CONF "$be_name" volume_backend_name "$be_name"
iniset $CINDER_CONF "$be_name" volume_driver cinder.volume.drivers.drbdmanagedrv.DrbdManageDriver
}
function init_drbd_devstack {
# Initialize and start the service.
# need to setup loopback device(s) for DRBD
# dd if=/dev/zero of=${FILES}/${DRBD_DRBDCTRL_VG} count=1 bs=${DRBD_DRBDCTRL_VG_SZ}
# mknod -m 660 /dev/${DRBD_DRBDCTRL_LODEV} b 7 66
# losetup ${FILES}/${DRBD_DRBDCTRL_VG}
# sed -i 's/global_filter = \[ /global_filter = \[ "a|loop3|", /g' /etc/lvm/lvm.conf
# pvcreate /dev/loop3
# vgcreate ${DRBD_DRBDCTRL_VG}
# if the file exists, don't destroy it...
if [[ ! -f ${FILES}/${DRBD_DRBDCTRL_VG} ]]; then
#dd if=/dev/zero of=${FILES}/${DRBD_DRBDCTRL_VG} count=1 bs=${DRBD_DRBDCTRL_VG_SZ}
sudo truncate -s ${DRBD_DRBDCTRL_VG_SZ} ${FILES}/${DRBD_DRBDCTRL_VG}
fi
# if the loop device is present, don't recreate it...
if [[ ! -e /dev/${DRBD_DRBDCTRL_LODEV} ]]; then
DRBDCTRL_LO_MINOR=`echo ${DRBD_DRBDCTRL_LODEV} | sed 's/loop//g'`
sudo mknod -m 660 /dev/${DRBD_DRBDCTRL_LODEV} b 7 ${DRBDCTRL_LO_MINOR}
fi
# if the file is already assigned a loop device, don't reassign
sudo losetup -a | grep ${DRBD_DRBDCTRL_LODEV} | grep -q ${DRBD_DRBDCTRL_VG}
if [[ $? -ne 0 ]]; then
sudo losetup /dev/${DRBD_DRBDCTRL_LODEV} ${FILES}/${DRBD_DRBDCTRL_VG}
fi
# if the lvm.conf already accepts the loop device, don't insert it again
sudo grep -q ${DRBD_DRBDCTRL_LODEV} /etc/lvm/lvm.conf
if [[ $? -ne 0 ]]; then
sudo sed -i.drbdctrl-bak "s/global_filter = \[ /global_filter = \[ \"a|${DRBD_DRBDCTRL_LODEV}|\", /g" /etc/lvm/lvm.conf
fi
# if theres already a pv signature, don't try to recreate
sudo pvdisplay | grep -q ${DRBD_DRBDCTRL_LODEV}
if [[ $? -ne 0 ]]; then
sudo pvscan
sudo pvdisplay | grep -q ${DRBD_DRBDCTRL_LODEV}
if [[ $? -ne 0 ]]; then
sudo pvcreate /dev/${DRBD_DRBDCTRL_LODEV}
fi
fi
# if theres already a vg, don't try to recreate
sudo vgdisplay | grep -q ${DRBD_DRBDCTRL_VG}
if [[ $? -ne 0 ]]; then
sudo vgscan
sudo vgdisplay | grep -q ${DRBD_DRBDCTRL_VG}
if [[ $? -ne 0 ]]; then
sudo vgcreate ${DRBD_DRBDCTRL_VG} /dev/${DRBD_DRBDCTRL_LODEV}
fi
fi
# Do the same thing for the DATA volume group
# dd if=/dev/zero of=${FILES}/${DRBD_DATA_VG} count=1 bs=${DRBD_DATA_VG_SZ}
# losetup ${FILES}/${DRBD_DATA_VG}
# sed -i 's/global_filter = \[ /global_filter = \[ "a|loop4|", /g' /etc/lvm/lvm.conf
# pvcreate /dev/loop4
# vgcreate ${DRBD_DATA_VG}
# if the file exists, don't destroy it...
if [[ ! -f ${FILES}/${DRBD_DATA_VG} ]]; then
#dd if=/dev/zero of=${FILES}/${DRBD_DATA_VG} count=1 bs=${DRBD_DATA_VG_SZ}
sudo truncate -s ${DRBD_DATA_VG_SZ} ${FILES}/${DRBD_DATA_VG}
fi
# if the loop device is present, don't recreate it...
if [[ ! -e /dev/${DRBD_DATA_LODEV} ]]; then
DATA_LO_MINOR=`echo ${DRBD_DATA_LODEV} | sed 's/loop//g'`
sudo mknod -m 660 /dev/${DRBD_DATA_LODEV} b 7 ${DATA_LO_MINOR}
fi
# if the file is already assigned a loop device, don't reassign
sudo losetup -a | grep ${DRBD_DATA_LODEV} | grep -q ${DRBD_DATA_VG}
if [[ $? -ne 0 ]]; then
sudo losetup /dev/${DRBD_DATA_LODEV} ${FILES}/${DRBD_DATA_VG}
fi
# if the lvm.conf already accepts the loop device, don't insert it again
sudo grep -q ${DRBD_DATA_LODEV} /etc/lvm/lvm.conf
if [[ $? -ne 0 ]]; then
sudo sed -i.drbddata-bak "s/global_filter = \[ /global_filter = \[ \"a|${DRBD_DATA_LODEV}|\", /g" /etc/lvm/lvm.conf
fi
# if theres already a pv signature, don't try to recreate
sudo pvdisplay | grep -q ${DRBD_DATA_LODEV}
if [[ $? -ne 0 ]]; then
sudo pvscan
sudo pvdisplay | grep -q ${DRBD_DATA_LODEV}
if [[ $? -ne 0 ]]; then
sudo pvcreate /dev/${DRBD_DATA_LODEV}
fi
fi
# if theres already a vg, don't try to recreate
sudo vgdisplay | grep -q ${DRBD_DATA_VG}
if [[ $? -ne 0 ]]; then
sudo vgscan
sudo vgdisplay | grep -q ${DRBD_DATA_VG}
if [[ $? -ne 0 ]]; then
sudo vgcreate ${DRBD_DATA_VG} /dev/${DRBD_DATA_LODEV}
fi
fi
# initialize drbdmanage
sudo drbdmanage init --quiet
# FIXME: multi-node setups
}
function shutdown_drbd_devstack {
# Shut the service down.
# drbdadm down all
# drbdmanage shutdown --quiet
echo "shutdown drbd devstack"
}
function cleanup_drbd_devstack {
# Cleanup the service.
# something like
# drbdmanage list-resource --short | xargs -l drbdmanage remove-resource
# ???
# drbdmanage resources -m | sed 's/,.*//g' | xargs -l drbdmanage remove-resource --quiet
echo "cleanup drbd devstack"
}
#debug main
#source $(dirname '$0')/../settings
#pre_install_drbd_devstack
#install_drbd_devstack
#configure_drbd_devstack
#init_drbd_devstack
# Tell emacs to use shell-script-mode
## Local variables:
## mode: shell-script
## End: