* add CINDER_MULTI_LVM_BACKEND parameter
* if CINDER_MULTI_LVM_BACKEND = True, creates 2 LVM volumes
- Name : stack-volumes and stack-volumes2
- Size : 5GB for each of them
Change-Id: I6e03b96e6b2aed0f0c166472300139fba9eaa68b
... | ... |
@@ -50,8 +50,13 @@ else |
50 | 50 |
CINDER_BIN_DIR=$(get_python_exec_prefix) |
51 | 51 |
fi |
52 | 52 |
|
53 |
-# Name of the lvm volume group to use/create for iscsi volumes |
|
53 |
+# Support for multi lvm backend configuration (default is no support) |
|
54 |
+CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND) |
|
55 |
+ |
|
56 |
+# Name of the lvm volume groups to use/create for iscsi volumes |
|
57 |
+# VOLUME_GROUP2 is used only if CINDER_MULTI_LVM_BACKEND = True |
|
54 | 58 |
VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes} |
59 |
+VOLUME_GROUP2=${VOLUME_GROUP2:-stack-volumes2} |
|
55 | 60 |
VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-} |
56 | 61 |
|
57 | 62 |
# _clean_volume_group removes all cinder volumes from the specified volume group |
... | ... |
@@ -106,6 +111,9 @@ function cleanup_cinder() { |
106 | 106 |
|
107 | 107 |
# Campsite rule: leave behind a volume group at least as clean as we found it |
108 | 108 |
_clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX |
109 |
+ if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then |
|
110 |
+ _clean_volume_group $VOLUME_GROUP2 $VOLUME_NAME_PREFIX |
|
111 |
+ fi |
|
109 | 112 |
} |
110 | 113 |
|
111 | 114 |
# configure_cinder() - Set config files, create data dirs, etc |
... | ... |
@@ -164,8 +172,18 @@ function configure_cinder() { |
164 | 164 |
cp $CINDER_DIR/etc/cinder/cinder.conf.sample $CINDER_CONF |
165 | 165 |
iniset $CINDER_CONF DEFAULT auth_strategy keystone |
166 | 166 |
iniset $CINDER_CONF DEFAULT verbose True |
167 |
- iniset $CINDER_CONF DEFAULT volume_group $VOLUME_GROUP |
|
168 |
- iniset $CINDER_CONF DEFAULT volume_name_template ${VOLUME_NAME_PREFIX}%s |
|
167 |
+ if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then |
|
168 |
+ iniset $CINDER_CONF DEFAULT enabled_backends lvmdriver-1,lvmdriver-2 |
|
169 |
+ iniset $CINDER_CONF lvmdriver-1 volume_group $VOLUME_GROUP |
|
170 |
+ iniset $CINDER_CONF lvmdriver-1 volume_driver cinder.volume.drivers.lvm.LVMISCSIDriver |
|
171 |
+ iniset $CINDER_CONF lvmdriver-1 volume_backend_name LVM_iSCSI |
|
172 |
+ iniset $CINDER_CONF lvmdriver-2 volume_group $VOLUME_GROUP2 |
|
173 |
+ iniset $CINDER_CONF lvmdriver-2 volume_driver cinder.volume.drivers.lvm.LVMISCSIDriver |
|
174 |
+ iniset $CINDER_CONF lvmdriver-2 volume_backend_name LVM_iSCSI |
|
175 |
+ else |
|
176 |
+ iniset $CINDER_CONF DEFAULT volume_group $VOLUME_GROUP |
|
177 |
+ iniset $CINDER_CONF DEFAULT volume_name_template ${VOLUME_NAME_PREFIX}%s |
|
178 |
+ fi |
|
169 | 179 |
iniset $CINDER_CONF DEFAULT iscsi_helper tgtadm |
170 | 180 |
local dburl |
171 | 181 |
database_connection_url dburl cinder |
... | ... |
@@ -263,12 +281,14 @@ function create_cinder_cache_dir() { |
263 | 263 |
} |
264 | 264 |
|
265 | 265 |
create_cinder_volume_group() { |
266 |
- # Configure a default volume group called '`stack-volumes`' for the volume |
|
267 |
- # service if it does not yet exist. If you don't wish to use a file backed |
|
268 |
- # volume group, create your own volume group called ``stack-volumes`` before |
|
269 |
- # invoking ``stack.sh``. |
|
266 |
+ # According to the CINDER_MULTI_LVM_BACKEND value, configure one or two default volumes |
|
267 |
+ # group called ``stack-volumes`` (and ``stack-volumes2``) for the volume |
|
268 |
+ # service if it (they) does (do) not yet exist. If you don't wish to use a |
|
269 |
+ # file backed volume group, create your own volume group called ``stack-volumes`` |
|
270 |
+ # and ``stack-volumes2`` before invoking ``stack.sh``. |
|
270 | 271 |
# |
271 |
- # By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``. |
|
272 |
+ # By default, the two backing files are 5G in size, and are stored in |
|
273 |
+ # ``/opt/stack/data``. |
|
272 | 274 |
|
273 | 275 |
if ! sudo vgs $VOLUME_GROUP; then |
274 | 276 |
VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file} |
... | ... |
@@ -283,6 +303,23 @@ create_cinder_volume_group() { |
283 | 283 |
sudo vgcreate $VOLUME_GROUP $DEV |
284 | 284 |
fi |
285 | 285 |
fi |
286 |
+ if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then |
|
287 |
+ #set up the second volume if CINDER_MULTI_LVM_BACKEND is enabled |
|
288 |
+ |
|
289 |
+ if ! sudo vgs $VOLUME_GROUP2; then |
|
290 |
+ VOLUME_BACKING_FILE2=${VOLUME_BACKING_FILE2:-$DATA_DIR/${VOLUME_GROUP2}-backing-file} |
|
291 |
+ |
|
292 |
+ # Only create if the file doesn't already exists |
|
293 |
+ [[ -f $VOLUME_BACKING_FILE2 ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE2 |
|
294 |
+ |
|
295 |
+ DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE2` |
|
296 |
+ |
|
297 |
+ # Only create if the loopback device doesn't contain $VOLUME_GROUP |
|
298 |
+ if ! sudo vgs $VOLUME_GROUP2; then |
|
299 |
+ sudo vgcreate $VOLUME_GROUP2 $DEV |
|
300 |
+ fi |
|
301 |
+ fi |
|
302 |
+ fi |
|
286 | 303 |
|
287 | 304 |
mkdir -p $CINDER_STATE_PATH/volumes |
288 | 305 |
} |
... | ... |
@@ -314,6 +351,9 @@ function init_cinder() { |
314 | 314 |
sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true |
315 | 315 |
# Start with a clean volume group |
316 | 316 |
_clean_volume_group $VOLUME_GROUP $VOLUME_NAME_PREFIX |
317 |
+ if [ "$CINDER_MULTI_LVM_BACKEND" = "True" ]; then |
|
318 |
+ _clean_volume_group $VOLUME_GROUP2 $VOLUME_NAME_PREFIX |
|
319 |
+ fi |
|
317 | 320 |
fi |
318 | 321 |
fi |
319 | 322 |
|