Ivan Kolodyazhny | 447f141 | 2016-07-28 18:42:25 +0300 | [diff] [blame] | 1 | #!/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) |
| 26 | set +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 |
| 37 | function 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 |
| 47 | function 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 Verkhovsky | f63ddd6 | 2018-02-25 14:48:05 +0000 | [diff] [blame] | 53 | iniset $CINDER_CONF $be_name target_helper "$CINDER_ISCSI_HELPER" |
Ivan Kolodyazhny | 447f141 | 2016-07-28 18:42:25 +0300 | [diff] [blame] | 54 | 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 |
| 63 | function 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: |