Browse Source

Configure Manila with glusterfs.py share driver

This patch configures Manila with glusterfs.py share driver.

Change-Id: I53c51dd213bd64c35fec54c45db92d22139d0e0e
Bharat Kumar Kobagana 3 years ago
parent
commit
f0ce598c9b
2 changed files with 70 additions and 4 deletions
  1. 64
    4
      devstack/gluster-functions.sh
  2. 6
    0
      devstack/plugin.sh

+ 64
- 4
devstack/gluster-functions.sh View File

@@ -193,13 +193,73 @@ function configure_nova_backend_glusterfs {
193 193
     _mount_gluster_volume $NOVA_INSTANCES_PATH $NOVA_GLUSTERFS_SHARE
194 194
 }
195 195
 
196
-# Configure GlusterFS-NFS as backend for Manila
196
+# Create Manila GlusterFS Volume
197
+function _create_thin_lv_pool {
198
+    # Create a Volume Group
199
+    init_lvm_volume_group $GLUSTERFS_VG_NAME 20G
200
+
201
+    # Create a think pool
202
+    sudo lvcreate -l 5110 -T $GLUSTERFS_VG_NAME/$GLUSTERFS_THIN_POOL_NAME
203
+}
204
+
205
+# Creating Thin LV
206
+function _create_thin_lv_gluster_vol {
207
+    local vol_name=$1
208
+    local vol_size=$2
209
+
210
+    sudo lvcreate -V $vol_size -T $GLUSTERFS_VG_NAME/$GLUSTERFS_THIN_POOL_NAME -n $vol_name
211
+
212
+    # Format the LV.
213
+    sudo mkfs.xfs -i size=512 /dev/$GLUSTERFS_VG_NAME/$vol_name
214
+
215
+    # Mount the filesystem
216
+    mkdir -p $MANILA_STATE_PATH/export/$vol_name
217
+    sudo mount /dev/$GLUSTERFS_VG_NAME/$vol_name $MANILA_STATE_PATH/export/$vol_name
218
+
219
+    # Create a directory that would serve as a brick.
220
+    sudo mkdir -p $MANILA_STATE_PATH/export/$vol_name/brick
221
+
222
+    # Create a GlusterFS Volume.
223
+    sudo gluster --mode=script vol create $vol_name $(hostname):$MANILA_STATE_PATH/export/$vol_name/brick
224
+
225
+    # Start gluster volume
226
+    sudo gluster --mode=script volume start $vol_name
227
+}
228
+
229
+# Configure manila.conf to use glusterfs.py driver
230
+function _configure_manila_glusterfs {
231
+    local share_driver=manila.share.drivers.glusterfs.GlusterfsShareDriver
232
+    local group_name=$1
233
+    local gluster_vol=$2
234
+
235
+    iniset $MANILA_CONF $group_name share_driver $share_driver
236
+    iniset $MANILA_CONF $group_name share_backend_name GLUSTERFS
237
+    iniset $MANILA_CONF $group_name glusterfs_target $(hostname):/$gluster_vol
238
+    iniset $MANILA_CONF $group_name driver_handles_share_servers False
239
+}
240
+
241
+# Configure glusterfs.py as backend driver for Manila
197 242
 function _configure_manila_glusterfs_nfs {
198
-    #TODO(BharatK): Add script to configure GlusterFS-NFS as a backend for Manila.
199
-    echo "Need to add script to configure GlusterFS-NFS as a backend for Manila."
243
+    # Create Thin lvpool
244
+    _create_thin_lv_pool
245
+
246
+    # Create Gluster Volume
247
+    _create_thin_lv_gluster_vol manila-glusterfs-vol 20G
248
+
249
+    # Configure manila.conf
250
+    _configure_manila_glusterfs glusternfs1 manila-glusterfs-vol
251
+
252
+    # Setting enabled_share_protocols to NFS
253
+    iniset $MANILA_CONF DEFAULT enabled_share_protocols NFS
254
+
255
+    # Overrinding MANILA_ENABLED_BACKENDS to have only glusternfs1 backend
256
+    MANILA_ENABLED_BACKENDS=glusternfs1
257
+
258
+    # Setting enabled_share_backends
259
+    iniset $MANILA_CONF DEFAULT enabled_share_backends $MANILA_ENABLED_BACKENDS
200 260
 }
201 261
 
202
-# Configure GlusterFS-Native as backend for Manila
262
+# Configure glusterfsnative.py as backend driver for Manila
203 263
 function _configure_manila_glusterfs_native {
204 264
     #TODO(BharatK): Add script to configure GlusterFS-Native as a backend for Manila.
205 265
     echo "Need to add script to configure GlusterFS-Native as a backend for Manila."

+ 6
- 0
devstack/plugin.sh View File

@@ -37,6 +37,12 @@ CONFIGURE_GLUSTERFS_MANILA=${CONFIGURE_GLUSTERFS_MANILA:-False}
37 37
 # Set GLUSTERFS_MANILA_DRIVER_TYPE to either 'glusterfs' or 'glusterfs-native'.
38 38
 GLUSTERFS_MANILA_DRIVER_TYPE=${GLUSTERFS_MANILA_DRIVER_TYPE:-glusterfs}
39 39
 
40
+# Set GLUSTERFS_VG_NAME to the name of volume group.
41
+GLUSTERFS_VG_NAME=${GLUSTERFS_VG_NAME:-glusterfs-vg}
42
+
43
+# Set GLUSTERFS_THIN_POOL_NAME to the name of thinpool.
44
+GLUSTERFS_THIN_POOL_NAME=${GLUSTERFS_THIN_POOL_NAME:-glusterfs-thinpool}
45
+
40 46
 # Error out when devstack-plugin-glusterfs is enabled, but not selected as a backend for Cinder, Glance or Nova.
41 47
 if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$CONFIGURE_GLUSTERFS_GLANCE" = "False" ] && [ "$CONFIGURE_GLUSTERFS_NOVA" = "False" ] && [ "$CONFIGURE_GLUSTERFS_MANILA" = "False" ];  then
42 48
     echo "GlusterFS plugin enabled but not selected as a backend for Cinder, Glance, Nova or Manila."

Loading…
Cancel
Save