diff --git a/devstack/gluster-functions.sh b/devstack/gluster-functions.sh index 5325f9f..6fa5832 100644 --- a/devstack/gluster-functions.sh +++ b/devstack/gluster-functions.sh @@ -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 +} diff --git a/devstack/plugin.sh b/devstack/plugin.sh index a6acdb6..31b50c9 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -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 diff --git a/devstack/settings b/devstack/settings index 0d27442..9d091c1 100644 --- a/devstack/settings +++ b/devstack/settings @@ -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}