From b8f15088b5c3b70ae2c12ecd8185064a0159a6e1 Mon Sep 17 00:00:00 2001 From: Alan Bishop Date: Wed, 17 May 2017 15:53:49 -0400 Subject: [PATCH] Restore iscsi loopback LVM volume group on startup This change restores the loopback device and LVM volume group used by the iscsi driver each time the system restarts. This essentially allows the volume group to survive a reboot. Closes-Bug: #1581092 Change-Id: Ifcd74b41d9d14b1c2a176fe9994a3927ae2a552a --- manifests/setup_test_volume.pp | 8 ++++++++ spec/classes/cinder_setup_test_volume_spec.rb | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/manifests/setup_test_volume.pp b/manifests/setup_test_volume.pp index 644e632c..1a3d248c 100644 --- a/manifests/setup_test_volume.pp +++ b/manifests/setup_test_volume.pp @@ -58,4 +58,12 @@ class cinder::setup_test_volume( unless => "vgdisplay | grep ${volume_name}", refreshonly => true, } + + # Ensure the loopback device and volume group are restored if the system + # were to reboot. + exec { "losetup -f ${volume_path}/${volume_name} && udevadm settle && vgchange -a y ${volume_name}": + path => ['/bin','/usr/bin','/sbin','/usr/sbin'], + unless => "losetup -l | grep ${volume_path}/${volume_name}", + before => Anchor['cinder::service::begin'], + } } diff --git a/spec/classes/cinder_setup_test_volume_spec.rb b/spec/classes/cinder_setup_test_volume_spec.rb index b62f6282..3d67db84 100644 --- a/spec/classes/cinder_setup_test_volume_spec.rb +++ b/spec/classes/cinder_setup_test_volume_spec.rb @@ -20,4 +20,8 @@ describe 'cinder::setup_test_volume' do :mode => '0640' ) end + + it 'should restore loopback device and volume group' do + is_expected.to contain_exec('losetup -f /var/lib/cinder/cinder-volumes && udevadm settle && vgchange -a y cinder-volumes') + end end