blob: 43e13e4dac0f5cc7790b0b565f7875c31b66df86 [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
50 iniset $CINDER_CONF $be_name volume_driver "cinder.volume.drivers.lvm.LVMISCSIDriver"
Daniel Genind4708672014-10-31 15:01:29 -040051 iniset $CINDER_CONF $be_name volume_group $VOLUME_GROUP_NAME-$be_name
Dean Troyer09718332014-07-03 10:46:57 -050052
53 if [[ "$CINDER_SECURE_DELETE" == "False" ]]; then
54 iniset $CINDER_CONF $be_name volume_clear none
55 fi
56}
57
Daniel Genind4708672014-10-31 15:01:29 -040058# init_cinder_backend_lvm - Initialize volume group
59# init_cinder_backend_lvm $be_name
Dean Troyer09718332014-07-03 10:46:57 -050060function init_cinder_backend_lvm {
61 local be_name=$1
62
Dean Troyer09718332014-07-03 10:46:57 -050063 # Start with a clean volume group
Daniel Genind4708672014-10-31 15:01:29 -040064 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
Dean Troyer09718332014-07-03 10:46:57 -050065}
66
Dean Troyer09718332014-07-03 10:46:57 -050067# Restore xtrace
68$MY_XTRACE
69
70# mode: shell-script
71# End: