blob: 3ffd9a678529addd497d6c1f6c11acb0a599f50c [file] [log] [blame]
Ivan Kolodyazhny447f1412016-07-28 18:42:25 +03001#!/bin/bash
2#
3# lib/cinder_backends/lvm
4# Configure the LVM backend
5
6# Enable with:
7#
8# CINDER_ENABLED_BACKENDS+=,fake_gate:lvmname
9
10# Dependencies:
11#
12# - ``functions`` file
13# - ``cinder`` configurations
14
15# CINDER_CONF
16# DATA_DIR
17# VOLUME_GROUP_NAME
18
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
25_XTRACE_CINDER_LVM=$(set +o | grep xtrace)
26set +o xtrace
27
28
29# TODO: resurrect backing device...need to know how to set values
30#VOLUME_BACKING_DEVICE=${VOLUME_BACKING_DEVICE:-}
31
32# Entry Points
33# ------------
34
35# cleanup_cinder_backend_lvm - Delete volume group and remove backing file
36# cleanup_cinder_backend_lvm $be_name
37function cleanup_cinder_backend_lvm {
38 local be_name=$1
39
40 # Campsite rule: leave behind a volume group at least as clean as we found it
41 clean_lvm_volume_group $VOLUME_GROUP_NAME-$be_name
42 clean_lvm_filter
43}
44
45# configure_cinder_backend_lvm - Set config files, create data dirs, etc
46# configure_cinder_backend_lvm $be_name
47function configure_cinder_backend_lvm {
48 local be_name=$1
49
50 iniset $CINDER_CONF $be_name volume_backend_name $be_name
51 iniset $CINDER_CONF $be_name volume_driver "cinder.tests.fake_driver.FakeGateDriver"
52 iniset $CINDER_CONF $be_name volume_group $VOLUME_GROUP_NAME-$be_name
Lenny Verkhovskyf63ddd62018-02-25 14:48:05 +000053 iniset $CINDER_CONF $be_name target_helper "$CINDER_ISCSI_HELPER"
Ivan Kolodyazhny447f1412016-07-28 18:42:25 +030054 iniset $CINDER_CONF $be_name lvm_type "$CINDER_LVM_TYPE"
55
56 if [[ "$CINDER_VOLUME_CLEAR" == "non" ]]; then
57 iniset $CINDER_CONF $be_name volume_clear none
58 fi
59}
60
61# init_cinder_backend_lvm - Initialize volume group
62# init_cinder_backend_lvm $be_name
63function init_cinder_backend_lvm {
64 local be_name=$1
65
66 # Start with a clean volume group
67 init_lvm_volume_group $VOLUME_GROUP_NAME-$be_name $VOLUME_BACKING_FILE_SIZE
68}
69
70# Restore xtrace
71$_XTRACE_CINDER_LVM
72
73# mode: shell-script
74# End: