blob: d369c0c840a2985ebcc73fbfde3af715482e72df [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Dean Troyer09718332014-07-03 10:46:57 -05003# lib/cinder_backends/lvm
4# Configure the LVM backend
5
6# Enable with:
7#
8# CINDER_ENABLED_BACKENDS+=,lvm:lvmname
9
10# Dependencies:
11#
12# - ``functions`` file
13# - ``cinder`` configurations
14
15# CINDER_CONF
16# DATA_DIR
Daniel Genind4708672014-10-31 15:01:29 -040017# VOLUME_GROUP_NAME
Dean Troyer09718332014-07-03 10:46:57 -050018
19# clean_cinder_backend_lvm - called from clean_cinder()
20# configure_cinder_backend_lvm - called from configure_cinder()
21# init_cinder_backend_lvm - called from init_cinder()
22
23
24# Save trace setting
25MY_XTRACE=$(set +o | grep xtrace)
26set +o xtrace
27
28
Dean Troyer09718332014-07-03 10:46:57 -050029# TODO: resurrect backing device...need to know how to set values
30#VOLUME_BACKING_DEVICE=${VOLUME_BACKING_DEVICE:-}
31
Dean Troyer09718332014-07-03 10:46:57 -050032# Entry Points
33# ------------
34
Daniel Genind4708672014-10-31 15:01:29 -040035# cleanup_cinder_backend_lvm - Delete volume group and remove backing file
36# cleanup_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050037function cleanup_cinder_backend_lvm {
38 local be_name=$1
39
Dean Troyer09718332014-07-03 10:46:57 -050040 # Campsite rule: leave behind a volume group at least as clean as we found it
Daniel Genind4708672014-10-31 15:01:29 -040041 clean_lvm_volume_group $VOLUME_GROUP_NAME-$be_name
Dean Troyer09718332014-07-03 10:46:57 -050042}
43
44# configure_cinder_backend_lvm - Set config files, create data dirs, etc
Daniel Genind4708672014-10-31 15:01:29 -040045# configure_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050046function configure_cinder_backend_lvm {
47 local be_name=$1
48
Dean Troyer09718332014-07-03 10:46:57 -050049 iniset $CINDER_CONF $be_name volume_backend_name $be_name
Mike Pereza0126b62015-01-22 08:25:59 -080050 iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.lvm.LVMVolumeDriver"
Daniel Genind4708672014-10-31 15:01:29 -040051 iniset $CINDER_CONF $be_name volume_group $VOLUME_GROUP_NAME-$be_name
Attila Fazekasc70605d2015-01-26 15:44:47 +010052 iniset $CINDER_CONF $be_name iscsi_helper "$CINDER_ISCSI_HELPER"
Dean Troyer09718332014-07-03 10:46:57 -050053
54 if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then
55 iniset $CINDER_CONF $be_name volume_clear none
56 fi
57}
58
Daniel Genind4708672014-10-31 15:01:29 -040059# init_cinder_backend_lvm - Initialize volume group
60# init_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050061function init_cinder_backend_lvm {
62 local be_name=$1
63
Dean Troyer09718332014-07-03 10:46:57 -050064 # Start with a clean volume group
Daniel Genind4708672014-10-31 15:01:29 -040065 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
Dean Troyer09718332014-07-03 10:46:57 -050066}
67
Dean Troyer09718332014-07-03 10:46:57 -050068# Restore xtrace
69$MY_XTRACE
70
71# mode: shell-script
72# End: