blob: 35ad209db72c96bcf75b75d47cb0e8595a083a6f [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
Dan Smith6cdb2e02015-04-23 09:12:59 -070042 clean_lvm_filter
Dean Troyer09718332014-07-03 10:46:57 -050043}
44
45# configure_cinder_backend_lvm - Set config files, create data dirs, etc
Daniel Genind4708672014-10-31 15:01:29 -040046# configure_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050047function configure_cinder_backend_lvm {
48 local be_name=$1
49
Dean Troyer09718332014-07-03 10:46:57 -050050 iniset $CINDER_CONF $be_name volume_backend_name $be_name
Mike Pereza0126b62015-01-22 08:25:59 -080051 iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.lvm.LVMVolumeDriver"
Daniel Genind4708672014-10-31 15:01:29 -040052 iniset $CINDER_CONF $be_name volume_group $VOLUME_GROUP_NAME-$be_name
Attila Fazekasc70605d2015-01-26 15:44:47 +010053 iniset $CINDER_CONF $be_name iscsi_helper "$CINDER_ISCSI_HELPER"
Dean Troyer09718332014-07-03 10:46:57 -050054
55 if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then
56 iniset $CINDER_CONF $be_name volume_clear none
57 fi
58}
59
Daniel Genind4708672014-10-31 15:01:29 -040060# init_cinder_backend_lvm - Initialize volume group
61# init_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050062function init_cinder_backend_lvm {
63 local be_name=$1
64
Dean Troyer09718332014-07-03 10:46:57 -050065 # Start with a clean volume group
Daniel Genind4708672014-10-31 15:01:29 -040066 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
Dean Troyer09718332014-07-03 10:46:57 -050067}
68
Dean Troyer09718332014-07-03 10:46:57 -050069# Restore xtrace
70$MY_XTRACE
71
72# mode: shell-script
73# End: