Browse Source

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
Bharat Kumar Kobagana 3 years ago
parent
commit
51d7091ed6
3 changed files with 43 additions and 3 deletions
  1. 25
    0
      devstack/gluster-functions.sh
  2. 15
    3
      devstack/plugin.sh
  3. 3
    0
      devstack/settings

+ 25
- 0
devstack/gluster-functions.sh View File

@@ -91,6 +91,11 @@ function cleanup_glusterfs {
91 91
         _delete_gluster_shares $CINDER_GLUSTERFS_SHARES
92 92
     fi
93 93
 
94
+    # Cleaning up Glance GlusterFS share
95
+    if [ "$CONFIGURE_GLUSTERFS_GLANCE" = "True" ]; then
96
+        _delete_gluster_shares $GLANCE_GLUSTERFS_SHARE
97
+    fi
98
+
94 99
     if [[ -e ${GLUSTERFS_DISK_IMAGE} ]]; then
95 100
         sudo rm -f ${GLUSTERFS_DISK_IMAGE}
96 101
     fi
@@ -155,3 +160,23 @@ function configure_cinder_backend_glusterfs {
155 160
         echo "$CINDER_GLUSTERFS_SHARES" | tee "$CINDER_CONF_DIR/glusterfs-shares-$be_name.conf"
156 161
     fi
157 162
 }
163
+
164
+# Mount gluster volume
165
+function _mount_gluster_volume {
166
+    local mount_dir=$1
167
+    local gluster_share=$2
168
+
169
+    # Delete existing files in directory
170
+    rm -rf $mount_dir
171
+    mkdir -p $mount_dir
172
+
173
+    sudo mount -t glusterfs $gluster_share $mount_dir
174
+    sudo chown -R $STACK_USER:$STACK_USER $DATA_DIR
175
+}
176
+
177
+# Configure GlusterFS as a backend for Glance
178
+function configure_glance_backend_glusterfs {
179
+    _create_gluster_volumes $GLANCE_GLUSTERFS_SHARE
180
+
181
+    _mount_gluster_volume $GLANCE_IMAGE_DIR $GLANCE_GLUSTERFS_SHARE
182
+}

+ 15
- 3
devstack/plugin.sh View File

@@ -13,6 +13,7 @@
13 13
 # - install_glusterfs
14 14
 # - start_glusterfs
15 15
 # - configure_cinder_backend_glusterfs
16
+# - configure_glance_backend_glusterfs
16 17
 # - stop_glusterfs
17 18
 # - cleanup_glusterfs
18 19
 
@@ -22,10 +23,13 @@
22 23
 # Set CONFIGURE_GLUSTERFS_CINDER to true, to enable GlusterFS as a backend for Cinder.
23 24
 CONFIGURE_GLUSTERFS_CINDER=${CONFIGURE_GLUSTERFS_CINDER:-True}
24 25
 
26
+# Set CONFIGURE_GLUSTERFS_GLANCE to true, to configure GlusterFS as a backend for Glance.
27
+CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-False}
28
+
25 29
 # Error out when devstack-plugin-glusterfs is enabled, but not selected as a backend for cinder.
26
-if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ]; then
27
-    echo "GlusterFS plugin enabled but not selected as a backend for Cinder."
28
-    echo "Please set CONFIGURE_GLUSTERFS_CINDER to True in localrc."
30
+if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$CONFIGURE_GLUSTERFS_GLANCE" = "False" ]; then
31
+    echo "GlusterFS plugin enabled but not selected as a backend for Cinder or Glance."
32
+    echo "Please set CONFIGURE_GLUSTERFS_CINDER and/or CONFIGURE_GLUSTERFS_GLANCE to True in localrc."
29 33
     exit 1
30 34
 fi
31 35
 
@@ -67,6 +71,9 @@ GLUSTERFS_LOOPBACK_DISK_SIZE=${GLUSTERFS_LOOPBACK_DISK_SIZE:-4G}
67 71
 # By default CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1"
68 72
 CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol"}
69 73
 
74
+# Glance GlusterFS share
75
+GLANCE_GLUSTERFS_SHARE=${GLANCE_GLUSTERFS_SHARE:-"127.0.0.1:/glance-vol"}
76
+
70 77
 # Adding GlusterFS repo to CentOS / RHEL 7 platform.
71 78
 GLUSTERFS_CENTOS_REPO=${GLUSTERFS_CENTOS_REPO:-"http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo"}
72 79
 
@@ -76,6 +83,11 @@ source $GLUSTERFS_PLUGIN_DIR/gluster-functions.sh
76 83
 if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
77 84
     echo_summary "Installing GlusterFS"
78 85
     install_glusterfs
86
+elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
87
+    if is_service_enabled glance && [[ "$CONFIGURE_GLUSTERFS_GLANCE" == "True" ]]; then
88
+        echo_summary "Configuring GlusterFS as a backend for Glance"
89
+        configure_glance_backend_glusterfs
90
+    fi
79 91
 fi
80 92
 
81 93
 if [[ "$1" == "unstack" ]]; then

+ 3
- 0
devstack/settings View File

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

Loading…
Cancel
Save