LVM: Don't initialize VG with lvm_type='auto'

The 'auto' arg should be translated to 'thin'
for the lvm.LVM() call.

Otherwise the checks for lvm_type=='thin' in the LVM()
code do not function as intended.

Closes-Bug: #1701547

Change-Id: Ifad854e6f0ef23085ff7af608e290e62c2ad2554
(cherry picked from commit 7033774fbb)
This commit is contained in:
Eric Harney 2017-06-30 08:14:04 -04:00
parent e72dead5ce
commit 1c2bfa9e4f
3 changed files with 18 additions and 1 deletions

View File

@ -74,6 +74,9 @@ class LVM(executor.Executor):
self._supports_lvchange_ignoreskipactivation = None
self.vg_provisioned_capacity = 0.0
if lvm_type not in ['default', 'thin']:
raise exception.Invalid('lvm_type must be "default" or "thin"')
# Ensure LVM_SYSTEM_DIR has been added to LVM.LVM_CMD_PREFIX
# before the first LVM command is executed, and use the directory
# where the specified lvm_conf file is located as the value.

View File

@ -362,6 +362,10 @@ class LVMVolumeDriverTestCase(test_volume.DriverTestCase):
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_lv_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.activate_lv')
@mock.patch('cinder.brick.local_dev.lvm.LVM.'
'supports_lvchange_ignoreskipactivation')
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.supports_thin_provisioning',
@ -378,6 +382,10 @@ class LVMVolumeDriverTestCase(test_volume.DriverTestCase):
@mock.patch.object(cinder.volume.utils, 'get_all_volume_groups',
return_value=[{'name': 'cinder-volumes'}])
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_lv_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.activate_lv')
@mock.patch('cinder.brick.local_dev.lvm.LVM.'
'supports_lvchange_ignoreskipactivation')
@mock.patch('cinder.brick.local_dev.lvm.LVM.update_volume_group_info')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_all_physical_volumes')
@mock.patch('cinder.brick.local_dev.lvm.LVM.get_volume')

View File

@ -291,10 +291,16 @@ class LVMVolumeDriver(driver.VolumeDriver):
lvm_conf_file = None
try:
lvm_type = self.configuration.lvm_type
if lvm_type == 'auto':
if volutils.supports_thin_provisioning():
lvm_type = 'thin'
else:
lvm_type = 'default'
self.vg = lvm.LVM(
self.configuration.volume_group,
root_helper,
lvm_type=self.configuration.lvm_type,
lvm_type=lvm_type,
executor=self._execute,
lvm_conf=lvm_conf_file,
suppress_fd_warn=(