Browse Source

Refactoring devstack-plugin-glusterfs code

This patch does the following:

* Moved variable setting part from plugin.sh to settings file.

* By default all Gluster-[Glance|Nova|Cinder|Manila] integrations
disabled. Look at README file to know how to enable.

* Keeping CINDER_ENABLED_BACKENDS intact when
CONFIGURE_GLUSTERFS_CINDER=False (Bug #1500381)

* Renamed CONFIGURE_GLUSTERFS_BACKUP to
CONFIGURE_GLUSTERFS_CINDER_BACKUP

* Avoid setting unnecessary variable when speicific configuraiton
is disabled.

* Documented the steps to enable in README.md file of this project.

Closes-Bug: #1500381
Depends-On: Id6967499729dfaa12d8a338d8f72471ebc90fb0d
Change-Id: I36f35f8af8e3491c8b0cffb40ba3980b7beab5df
Bharat Kumar Kobagana 3 years ago
parent
commit
f53859f89e
5 changed files with 162 additions and 118 deletions
  1. 31
    6
      README.md
  2. 1
    1
      devstack/gluster-functions.sh
  3. 3
    2
      devstack/override-defaults
  4. 3
    95
      devstack/plugin.sh
  5. 124
    14
      devstack/settings

+ 31
- 6
README.md View File

@@ -3,13 +3,38 @@ Devstack GlusterFS Plugin
3 3
 
4 4
 # Goals
5 5
 
6
-* To install GlusterFS (client and server) packages
7
-* Creates GlusterFS volumes to provide them as shares to Cinder
8
-* Configures Cinder with GlusterFS backend
9
-* Also cleans up the GlusterFS volumes and data related to GlusterFS
6
+As part of "stack.sh":
7
+* To install Glusterfs (client and server) packages
8
+* By default all Gluster-[Glance|Nova|Cinder|Manila] integrations disabled. Look at "How to use" section, to know how to enable.
9
+* Configures Glusterfs as a backend for Glance, Nova, Cinder and Manila as per localrc configuration
10
+* Creates Gluster volumes to provide them as storage to Glance, Nova, Cinder or Manila
11
+
12
+As part of "unstack.sh":
13
+* Also cleans up the Gluster volumes and data related to Gluster
10 14
 * Uninstalls the Gluster packages when we run "unstack.sh"
11 15
 
12
-# How to use
16
+# How to use (localrc configuration)
17
+
18
+* Enable devstack-plugin-glusterfs plugin:
19
+     [[local|localrc]]
20
+     enable_plugin devstack-plugin-glusterfs https://github.com/stackforge/devstack-plugin-glusterfs
21
+
22
+* To enable Gluster as a backend for Glance:
23
+     CONFIGURE_GLUSTERFS_GLANCE=True
24
+
25
+* To enable Gluster as a backend for Nova:
26
+     CONFIGURE_GLUSTERFS_NOVA=True
27
+
28
+* To enable Gluster as a backend for Cinder:
29
+     CONFIGURE_GLUSTERFS_CINDER=True
30
+  Also we can enable/disable glusterfs as a backend for Cinder Backup (c-bak) driver:
31
+     # By default set to True when CONFIGURE_GLUSTERFS_CINDER=True
32
+     enable_service c-bak
33
+     CONFIGURE_GLUSTERFS_CINDER_BACKUP=[True OR False]
34
+
35
+* To enable Gluster as a backend for Manila:
36
+     CONFIGURE_GLUSTERFS_MANILA=True
37
+  Also select specific gluster backend type for manila, default is "glusterfs":
38
+     GLUSTERFS_MANILA_DRIVER_TYPE=[glusterfs OR glusterfs-native]
13 39
 
14
-* Add "enable_plugin glusterfs https://github.com/stackforge/devstack-plugin-glusterfs" to localrc file inside devstack.
15 40
 * Then run "stack.sh"

+ 1
- 1
devstack/gluster-functions.sh View File

@@ -93,7 +93,7 @@ function cleanup_glusterfs {
93 93
     fi
94 94
 
95 95
     # Cleaning up Cinder Backup GlusterFS shares
96
-    if [ "$CONFIGURE_GLUSTERFS_BACKUP" = "True" ]; then
96
+    if [ "$CONFIGURE_GLUSTERFS_CINDER_BACKUP" = "True" ]; then
97 97
         _delete_gluster_shares $CINDER_GLUSTERFS_BACKUP_SHARE
98 98
     fi
99 99
     # Cleaning up Glance GlusterFS share

+ 3
- 2
devstack/override-defaults View File

@@ -1,4 +1,5 @@
1 1
 # Plug-in overrides
2 2
 
3
-CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-glusterfs:glusterfs,lvm:lvm1}
4
-
3
+if [ "$CONFIGURE_GLUSTERFS_CINDER" == "True" ]; then
4
+    CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-glusterfs:glusterfs,lvm:lvm1}
5
+fi

+ 3
- 95
devstack/plugin.sh View File

@@ -20,103 +20,11 @@
20 20
 # - stop_glusterfs
21 21
 # - cleanup_glusterfs
22 22
 
23
-# Defaults
24
-# --------
25
-
26
-# Set CONFIGURE_GLUSTERFS_CINDER to true, to enable GlusterFS as a backend for Cinder.
27
-CONFIGURE_GLUSTERFS_CINDER=${CONFIGURE_GLUSTERFS_CINDER:-True}
28
-
29
-# Set CONFIGURE_GLUSTERFS_BACKUP to true, to configure GlusterFS as a backup driver for Cinder.
30
-CONFIGURE_GLUSTERFS_BACKUP=${CONFIGURE_GLUSTERFS_BACKUP:-$CONFIGURE_GLUSTERFS_CINDER}
31
-
32
-# Set CONFIGURE_GLUSTERFS_GLANCE to true, to configure GlusterFS as a backend for Glance.
33
-CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-False}
34
-
35
-# Set CONFIGURE_GLUSTERFS_NOVA to true, to configure GlusterFS as a backend for Nova.
36
-CONFIGURE_GLUSTERFS_NOVA=${CONFIGURE_GLUSTERFS_NOVA:-False}
37
-
38
-# Set CONFIGURE_GLUSTERFS_MANILA to true, to configure GlusterFS as a backend for Manila.
39
-CONFIGURE_GLUSTERFS_MANILA=${CONFIGURE_GLUSTERFS_MANILA:-False}
40
-
41
-# Set GLUSTERFS_MANILA_DRIVER_TYPE to either 'glusterfs' or 'glusterfs-native'.
42
-GLUSTERFS_MANILA_DRIVER_TYPE=${GLUSTERFS_MANILA_DRIVER_TYPE:-glusterfs}
43
-
44
-# Set GLUSTERFS_VG_NAME to the name of volume group.
45
-GLUSTERFS_VG_NAME=${GLUSTERFS_VG_NAME:-glusterfs-vg}
46
-
47
-# Set GLUSTERFS_THIN_POOL_NAME to the name of thinpool.
48
-GLUSTERFS_THIN_POOL_NAME=${GLUSTERFS_THIN_POOL_NAME:-glusterfs-thinpool}
49
-
50
-# Error out when devstack-plugin-glusterfs is enabled, but not selected as a backend for Cinder, Glance or Nova.
51
-if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$CONFIGURE_GLUSTERFS_GLANCE" = "False" ] && [ "$CONFIGURE_GLUSTERFS_NOVA" = "False" ] && [ "$CONFIGURE_GLUSTERFS_MANILA" = "False" && [ "$CONFIGURE_GLUSTERFS_BACKUP" = "False" ];  then
52
-    echo "GlusterFS plugin enabled but not selected as a backend for Cinder, Glance, Nova or Manila."
53
-    echo "Please set CONFIGURE_GLUSTERFS_CINDER, CONFIGURE_GLUSTERFS_BACKUP, CONFIGURE_GLUSTERFS_GLANCE, CONFIGURE_GLUSTERFS_NOVA and/or CONFIGURE_GLUSTERFS_MANILA to True in localrc."
54
-    exit 1
55
-fi
56
-
57
-# When CONFIGURE_GLUSTERFS_CINDER is true, CINDER_ENABLED_BACKENDS should have
58
-# at least one backend of type 'glusterfs', error out otherwise.
59
-local is_gluster_backend_configured=False
60
-for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
61
-    if [ "${be%%:*}" = "glusterfs" ]; then
62
-        is_gluster_backend_configured=True
63
-        break
64
-    fi
65
-done
66
-if [ "$CONFIGURE_GLUSTERFS_CINDER" = "True" ] && [ "$is_gluster_backend_configured" = "False" ]; then
67
-    echo "CONFIGURE_GLUSTERFS_CINDER is set to True, to configure GlusterFS as a backend for Cinder."
68
-    echo "But, glusterfs backend type not present in CINDER_ENABLED_BACKENDS."
69
-    echo "Please enable at least one backend of type glusterfs in CINDER_ENABLED_BACKENDS."
70
-    exit 1
71
-elif [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$is_gluster_backend_configured" = "True" ]; then
72
-    echo "Configured Glusterfs as backend type in CINDER_ENABLED_BACKENDS. But CONFIGURE_GLUSTERFS_CINDER set to False."
73
-    exit 1
74
-fi
75
-
76
-# GLUSTERFS_PLUGIN_DIR contains the path to devstack-plugin-glusterfs/devstack directory
77
-GLUSTERFS_PLUGIN_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
78
-
79
-# Set ``GLUSTERFS_DATA_DIR`` to the location of GlusterFS drives.
80
-# Default is /var/lib/glusterfs.
81
-GLUSTERFS_DATA_DIR=${GLUSTERFS_DATA_DIR:-/var/lib/glusterfs}
82
-GLUSTERFS_DISK_IMAGE=${DATA_DIR}/cinder/glusterfs.img
83
-
84
-# DevStack will create a loop-back disk formatted as XFS to store the
85
-# GlusterFS data. Set ``GLUSTERFS_LOOPBACK_DISK_SIZE`` to the disk size in
86
-# GB.
87
-# Default is 4 gigabyte. But we can configure through localrc.
88
-GLUSTERFS_LOOPBACK_DISK_SIZE=${GLUSTERFS_LOOPBACK_DISK_SIZE:-4G}
89
-
90
-# Devstack will create GlusterFS shares to store Cinder volumes.
91
-# Those shares can be configured by seting CINDER_GLUSTERFS_SHARES.
92
-# By default CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1"
93
-CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol"}
94
-
95
-# GlusterFS shares for Cinder backup
96
-CINDER_GLUSTERFS_BACKUP_SHARE=${CINDER_GLUSTERFS_BACKUP_SHARE:-"127.0.0.1:/backup_vol"}
97
-
98
-# Glance GlusterFS share
99
-GLANCE_GLUSTERFS_SHARE=${GLANCE_GLUSTERFS_SHARE:-"127.0.0.1:/glance-vol"}
100
-
101
-# Glance Nova share
102
-NOVA_GLUSTERFS_SHARE=${NOVA_GLUSTERFS_SHARE:-"127.0.0.1:/nova-vol"}
103
-
104
-# Adding GlusterFS repo to CentOS / RHEL 7 platform.
105
-GLUSTERFS_CENTOS_REPO=${GLUSTERFS_CENTOS_REPO:-"http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo"}
106
-
107
-# Initializing gluster specific functions
108
-source $GLUSTERFS_PLUGIN_DIR/gluster-functions.sh
109
-
110 23
 if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
111
-    if is_service_enabled manila && [[ "$CONFIGURE_GLUSTERFS_MANILA" == "True" ]]; then
112
-        echo_summary "Installing GlusterFS 3.7"
113
-        install_glusterfs 3.7
114
-    else
115
-        echo_summary "Installing GlusterFS 3.6"
116
-        install_glusterfs 3.6
117
-    fi
24
+    echo_summary "Installing GlusterFS 3.7"
25
+    install_glusterfs 3.7
118 26
 elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
119
-    if is_service_enabled c-bak && [[ "$CONFIGURE_GLUSTERFS_BACKUP" == "True" ]]; then
27
+    if is_service_enabled c-bak && [[ "$CONFIGURE_GLUSTERFS_CINDER_BACKUP" == "True" ]]; then
120 28
         echo_summary "Configuring GlusterFS as a backend for Cinder backup driver"
121 29
         configure_cinder_backup_backend_glusterfs
122 30
     fi

+ 124
- 14
devstack/settings View File

@@ -1,22 +1,132 @@
1 1
 # Devstack settings
2 2
 
3
-# We have to add glusterfs to enabled services for screen_it to work
4
-enable_service glusterfs
3
+# Defaults
4
+# --------
5 5
 
6
-# Cinder encrypted volume tests are not supported with a GlusterFS
7
-# backend due to bug 1473363
8
-ATTACH_ENCRYPTED_VOLUME_AVAILABLE=False
9 6
 
10
-# Below are GlusterFS specific settings, with their defaults
11
-TEMPEST_STORAGE_PROTOCOL=glusterfs
7
+######### Plugin Specific #########
8
+
9
+# GLUSTERFS_PLUGIN_DIR contains the path to devstack-plugin-glusterfs/devstack directory
10
+GLUSTERFS_PLUGIN_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
11
+
12
+# Set ``GLUSTERFS_DATA_DIR`` to the location of GlusterFS drives.
13
+# Default is /var/lib/glusterfs.
14
+GLUSTERFS_DATA_DIR=${GLUSTERFS_DATA_DIR:-/var/lib/glusterfs}
15
+GLUSTERFS_DISK_IMAGE=${DATA_DIR}/glusterfs.img
16
+
17
+# DevStack will create a loop-back disk formatted as XFS to store the
18
+# GlusterFS data. Set ``GLUSTERFS_LOOPBACK_DISK_SIZE`` to the disk size in GB.
19
+# Default is 8 gigabyte. But we can configure through localrc.
12 20
 GLUSTERFS_LOOPBACK_DISK_SIZE=${GLUSTERFS_LOOPBACK_DISK_SIZE:-8G}
13
-CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol1;127.0.0.1:/cinder-vol2"}
14 21
 
15
-# Set default volume prov type to thick as we don't yet support backup for thin (qcow2) files
16
-GLUSTERFS_VOLUME_PROV_TYPE=${GLUSTERFS_VOLUME_PROV_TYPE:-thick}
17 22
 
18
-# Enabling GlusterFS as a backend for Glace
19
-CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-True}
23
+# GlusterFS repo for CentOS/RHEL 7 platform
24
+if [[ ${DISTRO} =~ rhel7 ]] && [[ ! -f /etc/yum.repos.d/glusterfs-epel.repo ]]; then
25
+    GLUSTERFS_CENTOS_REPO=${GLUSTERFS_CENTOS_REPO:-"http://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-epel.repo"}
26
+fi
27
+
28
+TEMPEST_STORAGE_PROTOCOL=glusterfs
29
+
30
+######### Glance Specific Configuration #########
31
+
32
+# Set CONFIGURE_GLUSTERFS_GLANCE to true, to configure GlusterFS as a backend for Glance.
33
+CONFIGURE_GLUSTERFS_GLANCE=${CONFIGURE_GLUSTERFS_GLANCE:-False}
34
+
35
+if [ "$CONFIGURE_GLUSTERFS_GLANCE" == "True" ]; then
36
+    # Glance GlusterFS share
37
+    GLANCE_GLUSTERFS_SHARE=${GLANCE_GLUSTERFS_SHARE:-"127.0.0.1:/glance-vol"}
38
+fi
39
+
40
+######### Nova Specific Configuration #########
41
+
42
+# Set CONFIGURE_GLUSTERFS_NOVA to true, to configure GlusterFS as a backend for Nova.
43
+CONFIGURE_GLUSTERFS_NOVA=${CONFIGURE_GLUSTERFS_NOVA:-False}
44
+
45
+if [ "$CONFIGURE_GLUSTERFS_NOVA" == "True" ]; then
46
+    # Glance Nova share
47
+    NOVA_GLUSTERFS_SHARE=${NOVA_GLUSTERFS_SHARE:-"127.0.0.1:/nova-vol"}
48
+fi
49
+
50
+######### Cinder Specific Configuration #########
51
+
52
+# Set CONFIGURE_GLUSTERFS_CINDER to true, to enable GlusterFS as a backend for Cinder.
53
+CONFIGURE_GLUSTERFS_CINDER=${CONFIGURE_GLUSTERFS_CINDER:-False}
54
+
55
+if [ "$CONFIGURE_GLUSTERFS_CINDER" == "True" ]; then
56
+    CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-glusterfs:glusterfs,lvm:lvm1}
57
+
58
+    # Devstack will create GlusterFS shares to store Cinder volumes.
59
+    # Those shares can be configured by seting CINDER_GLUSTERFS_SHARES.
60
+    # By default CINDER_GLUSTERFS_SHARES="127.0.0.1:/vol1"
61
+    CINDER_GLUSTERFS_SHARES=${CINDER_GLUSTERFS_SHARES:-"127.0.0.1:/cinder-vol1;127.0.0.1:/cinder-vol2"}
62
+
63
+    # Set default volume prov type to thick as we don't yet support backup for thin (qcow2) files
64
+    GLUSTERFS_VOLUME_PROV_TYPE=${GLUSTERFS_VOLUME_PROV_TYPE:-thick}
65
+
66
+    # Cinder encrypted volume tests are not supported with a GlusterFS
67
+    # backend due to bug 1473363
68
+    ATTACH_ENCRYPTED_VOLUME_AVAILABLE=False
69
+fi
70
+
71
+######### Cinder Backup Specific Configuration #########
72
+
73
+# Set CONFIGURE_GLUSTERFS_CINDER_BACKUP to true, to configure GlusterFS as a backup driver for Cinder.
74
+CONFIGURE_GLUSTERFS_CINDER_BACKUP=${CONFIGURE_GLUSTERFS_CINDER_BACKUP:-$CONFIGURE_GLUSTERFS_CINDER}
75
+
76
+if [ "$CONFIGURE_GLUSTERFS_CINDER_BACKUP" == "True" ]; then
77
+    # GlusterFS shares for Cinder backup
78
+    CINDER_GLUSTERFS_BACKUP_SHARE=${CINDER_GLUSTERFS_BACKUP_SHARE:-"127.0.0.1:/backup_vol"}
79
+fi
80
+
81
+######### Manila Specific Configuration #########
82
+
83
+# Set CONFIGURE_GLUSTERFS_MANILA to true, to configure GlusterFS as a backend for Manila.
84
+CONFIGURE_GLUSTERFS_MANILA=${CONFIGURE_GLUSTERFS_MANILA:-False}
85
+
86
+if [ "$CONFIGURE_GLUSTERFS_MANILA" == "True" ]; then
87
+    # Set GLUSTERFS_MANILA_DRIVER_TYPE to either 'glusterfs' or 'glusterfs-native'.
88
+    GLUSTERFS_MANILA_DRIVER_TYPE=${GLUSTERFS_MANILA_DRIVER_TYPE:-glusterfs}
89
+
90
+    # Set GLUSTERFS_VG_NAME to the name of volume group.
91
+    GLUSTERFS_VG_NAME=${GLUSTERFS_VG_NAME:-glusterfs-vg}
92
+
93
+    # Set GLUSTERFS_THIN_POOL_NAME to the name of thinpool.
94
+    GLUSTERFS_THIN_POOL_NAME=${GLUSTERFS_THIN_POOL_NAME:-glusterfs-thinpool}
95
+fi
96
+
97
+
98
+# Validation
99
+# ----------
100
+
101
+# Error out when devstack-plugin-glusterfs is enabled, but not selected as a
102
+# backend for Cinder, Glance or Nova.
103
+if [ "$CONFIGURE_GLUSTERFS_CINDER" == "False" ] && [ "$CONFIGURE_GLUSTERFS_GLANCE" == "False" ] && [ "$CONFIGURE_GLUSTERFS_NOVA" == "False" ] && [ "$CONFIGURE_GLUSTERFS_MANILA" == "False" ] && [ "$CONFIGURE_GLUSTERFS_CINDER_BACKUP" == "False" ];  then
104
+    echo "GlusterFS plugin enabled but not selected as a backend for Cinder, Glance, Nova or Manila."
105
+    echo "Please set CONFIGURE_GLUSTERFS_CINDER, CONFIGURE_GLUSTERFS_CINDER_BACKUP, CONFIGURE_GLUSTERFS_GLANCE, CONFIGURE_GLUSTERFS_NOVA and/or CONFIGURE_GLUSTERFS_MANILA to True in localrc."
106
+    exit 1
107
+fi
108
+
109
+# When CONFIGURE_GLUSTERFS_CINDER is true, CINDER_ENABLED_BACKENDS should have
110
+# at least one backend of type 'glusterfs', error out otherwise.
111
+local is_gluster_backend_configured=False
112
+for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
113
+    if [ "${be%%:*}" == "glusterfs" ]; then
114
+        is_gluster_backend_configured=True
115
+        break
116
+    fi
117
+done
118
+
119
+if [ "$CONFIGURE_GLUSTERFS_CINDER" == "True" ] && [ "$is_gluster_backend_configured" == "False" ]; then
120
+    echo "CONFIGURE_GLUSTERFS_CINDER is set to True, to configure GlusterFS as a backend for Cinder."
121
+    echo "But, glusterfs backend type not present in CINDER_ENABLED_BACKENDS."
122
+    echo "So please set one backend of type glusterfs to CINDER_ENABLED_BACKENDS."
123
+    exit 1
124
+elif [ "$CONFIGURE_GLUSTERFS_CINDER" == "False" ] && [ "$is_gluster_backend_configured" == "True" ]; then
125
+    echo "Configured Glusterfs as backend type in CINDER_ENABLED_BACKENDS. But CONFIGURE_GLUSTERFS_CINDER set to False."
126
+    exit 1
127
+fi
128
+
129
+# Initializing gluster specific functions
130
+# ---------------------------------------
20 131
 
21
-# Enabling GlusterFS as a backend for Nova
22
-CONFIGURE_GLUSTERFS_NOVA=${CONFIGURE_GLUSTERFS_NOVA:-True}
132
+source $GLUSTERFS_PLUGIN_DIR/gluster-functions.sh

Loading…
Cancel
Save