Add remove-missing-force config option.
This commit is contained in:
parent
e9404f6d75
commit
50368a21f0
@ -101,6 +101,13 @@ options:
|
|||||||
description: |
|
description: |
|
||||||
If True, charm will attempt to remove missing physical volumes from
|
If True, charm will attempt to remove missing physical volumes from
|
||||||
volume group, if logical volumes are not allocated on them.
|
volume group, if logical volumes are not allocated on them.
|
||||||
|
remove-missing-force:
|
||||||
|
default: False
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
If True, charm will attempt to remove missing physical volumes from
|
||||||
|
volume group, even when logical volumes are allocated on them. The
|
||||||
|
'remove-missing' option must also be set to True.
|
||||||
database-user:
|
database-user:
|
||||||
default: cinder
|
default: cinder
|
||||||
type: string
|
type: string
|
||||||
|
@ -129,7 +129,8 @@ def config_changed():
|
|||||||
configure_lvm_storage(block_devices,
|
configure_lvm_storage(block_devices,
|
||||||
conf['volume-group'],
|
conf['volume-group'],
|
||||||
conf['overwrite'] in ['true', 'True', True],
|
conf['overwrite'] in ['true', 'True', True],
|
||||||
conf['remove-missing'])
|
conf['remove-missing'],
|
||||||
|
conf['remove-missing-force'])
|
||||||
|
|
||||||
if git_install_requested():
|
if git_install_requested():
|
||||||
if config_value_changed('openstack-origin-git'):
|
if config_value_changed('openstack-origin-git'):
|
||||||
|
@ -343,6 +343,17 @@ def reduce_lvm_volume_group_missing(volume_group):
|
|||||||
subprocess.check_call(['vgreduce', '--removemissing', volume_group])
|
subprocess.check_call(['vgreduce', '--removemissing', volume_group])
|
||||||
|
|
||||||
|
|
||||||
|
def force_reduce_lvm_volume_group_missing(volume_group):
|
||||||
|
'''
|
||||||
|
Remove all missing physical volumes from the volume group, even if
|
||||||
|
logical volumes are allocated on them.
|
||||||
|
|
||||||
|
:param volume_group: str: Name of volume group to reduce.
|
||||||
|
'''
|
||||||
|
command = ['vgreduce', '--removemissing', '--force', volume_group]
|
||||||
|
subprocess.check_call(command)
|
||||||
|
|
||||||
|
|
||||||
def extend_lvm_volume_group(volume_group, block_device):
|
def extend_lvm_volume_group(volume_group, block_device):
|
||||||
'''
|
'''
|
||||||
Extend an LVM volume group onto a given block device.
|
Extend an LVM volume group onto a given block device.
|
||||||
@ -362,7 +373,7 @@ def log_lvm_info():
|
|||||||
|
|
||||||
|
|
||||||
def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
||||||
remove_missing=False):
|
remove_missing=False, remove_missing_force=False):
|
||||||
''' Configure LVM storage on the list of block devices provided
|
''' Configure LVM storage on the list of block devices provided
|
||||||
|
|
||||||
:param block_devices: list: List of whitelisted block devices to detect
|
:param block_devices: list: List of whitelisted block devices to detect
|
||||||
@ -371,6 +382,9 @@ def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
|||||||
not already in-use
|
not already in-use
|
||||||
:param remove_missing: bool: Remove missing physical volumes from volume
|
:param remove_missing: bool: Remove missing physical volumes from volume
|
||||||
group if logical volume not allocated on them
|
group if logical volume not allocated on them
|
||||||
|
:param remove_missing_force: bool: Remove missing physical volumes from
|
||||||
|
volume group even if logical volumes are allocated
|
||||||
|
on them. 'remove_missing' must also be True.
|
||||||
'''
|
'''
|
||||||
log_lvm_info()
|
log_lvm_info()
|
||||||
devices = []
|
devices = []
|
||||||
@ -413,6 +427,9 @@ def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
|||||||
|
|
||||||
# Remove missing physical volumes from volume group
|
# Remove missing physical volumes from volume group
|
||||||
if remove_missing:
|
if remove_missing:
|
||||||
|
if remove_missing_force:
|
||||||
|
force_reduce_lvm_volume_group_missing(volume_group)
|
||||||
|
else:
|
||||||
reduce_lvm_volume_group_missing(volume_group)
|
reduce_lvm_volume_group_missing(volume_group)
|
||||||
|
|
||||||
if len(new_devices) > 0:
|
if len(new_devices) > 0:
|
||||||
|
@ -156,7 +156,7 @@ class TestChangedHooks(CharmTestCase):
|
|||||||
self.assertTrue(conf_https.called)
|
self.assertTrue(conf_https.called)
|
||||||
self.configure_lvm_storage.assert_called_with(['sdb'],
|
self.configure_lvm_storage.assert_called_with(['sdb'],
|
||||||
'cinder-volumes',
|
'cinder-volumes',
|
||||||
False, False)
|
False, False, False)
|
||||||
|
|
||||||
@patch.object(hooks, 'configure_https')
|
@patch.object(hooks, 'configure_https')
|
||||||
@patch.object(hooks, 'git_install_requested')
|
@patch.object(hooks, 'git_install_requested')
|
||||||
@ -174,7 +174,7 @@ class TestChangedHooks(CharmTestCase):
|
|||||||
self.configure_lvm_storage.assert_called_with(
|
self.configure_lvm_storage.assert_called_with(
|
||||||
['sdb', '/dev/sdc', 'sde'],
|
['sdb', '/dev/sdc', 'sde'],
|
||||||
'cinder-new',
|
'cinder-new',
|
||||||
True, True)
|
True, True, False)
|
||||||
|
|
||||||
@patch.object(hooks, 'configure_https')
|
@patch.object(hooks, 'configure_https')
|
||||||
@patch.object(hooks, 'git_install_requested')
|
@patch.object(hooks, 'git_install_requested')
|
||||||
|
Loading…
Reference in New Issue
Block a user