devstack-plugin-glusterfs: GlusterFS as a backend for glance

This patch enables GlusterFS as a backend for Glance. This
patch introduces two new configuration parameters:
 * CONFIGURE_GLUSTERFS_GLANCE - set to 'True', to enable GlusterFS
as a backend for Glance. By default set to True.
 * GLANCE_GLUSTERFS_SHARE - which specifies the GlusterFS share
to store glance images.

Change-Id: I613e4c7a3e359235f5d54abc820df95b521b8697
This commit is contained in:
Bharat Kumar Kobagana 2015-08-06 13:24:43 +05:30 committed by Deepak C Shetty
parent 860ee45312
commit 51d7091ed6
3 changed files with 43 additions and 3 deletions

View File

@ -91,6 +91,11 @@ function cleanup_glusterfs {
_delete_gluster_shares $CINDER_GLUSTERFS_SHARES
fi
# Cleaning up Glance GlusterFS share
if [ "$CONFIGURE_GLUSTERFS_GLANCE" = "True" ]; then
_delete_gluster_shares $GLANCE_GLUSTERFS_SHARE
fi
if [[ -e ${GLUSTERFS_DISK_IMAGE} ]]; then
sudo rm -f ${GLUSTERFS_DISK_IMAGE}
fi
@ -155,3 +160,23 @@ function configure_cinder_backend_glusterfs {
echo "$CINDER_GLUSTERFS_SHARES" | tee "$CINDER_CONF_DIR/glusterfs-shares-$be_name.conf"
fi
}
# Mount gluster volume
function _mount_gluster_volume {
local mount_dir=$1
local gluster_share=$2
# Delete existing files in directory
rm -rf $mount_dir
mkdir -p $mount_dir
sudo mount -t glusterfs $gluster_share $mount_dir
sudo chown -R $STACK_USER:$STACK_USER $DATA_DIR
}
# Configure GlusterFS as a backend for Glance
function configure_glance_backend_glusterfs {
_create_gluster_volumes $GLANCE_GLUSTERFS_SHARE
_mount_gluster_volume $GLANCE_IMAGE_DIR $GLANCE_GLUSTERFS_SHARE
}

View File

@ -13,6 +13,7 @@
# - install_glusterfs
# - start_glusterfs
# - configure_cinder_backend_glusterfs
# - configure_glance_backend_glusterfs
# - stop_glusterfs
# - cleanup_glusterfs
@ -22,10 +23,13 @@
# Set CONFIGURE_GLUSTERFS_CINDER to true, to enable GlusterFS as a backend for Cinder.
CONFIGURE_GLUSTERFS_CINDER=${CONFIGURE_GLUSTERFS_CINDER:-True}
# Set CONFIGURE_GLUSTERFS_GLANCE to true, to configure GlusterFS as a backend for Glance.
CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-False}
# Error out when devstack-plugin-glusterfs is enabled, but not selected as a backend for cinder.
if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ]; then
echo "GlusterFS plugin enabled but not selected as a backend for Cinder."
echo "Please set CONFIGURE_GLUSTERFS_CINDER to True in localrc."
if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$CONFIGURE_GLUSTERFS_GLANCE" = "False" ]; then
echo "GlusterFS plugin enabled but not selected as a backend for Cinder or Glance."
echo "Please set CONFIGURE_GLUSTERFS_CINDER and/or CONFIGURE_GLUSTERFS_GLANCE to True in localrc."
exit 1
fi
@ -67,6 +71,9 @@ GLUSTERFS_LOOPBACK_DISK_SIZE=${GLUSTERFS_LOOPBACK_DISK_SIZE:-4G}
# By default CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1"
CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol"}
# Glance GlusterFS share
GLANCE_GLUSTERFS_SHARE=${GLANCE_GLUSTERFS_SHARE:-"127.0.0.1:/glance-vol"}
# Adding GlusterFS repo to CentOS / RHEL 7 platform.
GLUSTERFS_CENTOS_REPO=${GLUSTERFS_CENTOS_REPO:-"http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo"}
@ -76,6 +83,11 @@ source $GLUSTERFS_PLUGIN_DIR/gluster-functions.sh
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
echo_summary "Installing GlusterFS"
install_glusterfs
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
if is_service_enabled glance && [[ "$CONFIGURE_GLUSTERFS_GLANCE" == "True" ]]; then
echo_summary "Configuring GlusterFS as a backend for Glance"
configure_glance_backend_glusterfs
fi
fi
if [[ "$1" == "unstack" ]]; then

View File

@ -14,3 +14,6 @@ CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol1;127.0
# Set default volume prov type to thick as we don't yet support backup for thin (qcow2) files
GLUSTERFS_VOLUME_PROV_TYPE=${GLUSTERFS_VOLUME_PROV_TYPE:-thick}
# Enabling GlusterFS as a backend for Glace
CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-True}