Log LVM info a few times during LVM setup.
This commit is contained in:
parent
989c424b88
commit
e9404f6d75
@ -355,6 +355,12 @@ def extend_lvm_volume_group(volume_group, block_device):
|
|||||||
subprocess.check_call(['vgextend', volume_group, block_device])
|
subprocess.check_call(['vgextend', volume_group, block_device])
|
||||||
|
|
||||||
|
|
||||||
|
def log_lvm_info():
|
||||||
|
"""Log some useful information about how LVM is setup."""
|
||||||
|
pvscan_output = subprocess.check_output(['pvscan'])
|
||||||
|
juju_log('pvscan: %s' % pvscan_output)
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
''' Configure LVM storage on the list of block devices provided
|
''' Configure LVM storage on the list of block devices provided
|
||||||
@ -366,6 +372,7 @@ def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
|||||||
: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
|
||||||
'''
|
'''
|
||||||
|
log_lvm_info()
|
||||||
devices = []
|
devices = []
|
||||||
for block_device in block_devices:
|
for block_device in block_devices:
|
||||||
(block_device, size) = _parse_block_device(block_device)
|
(block_device, size) = _parse_block_device(block_device)
|
||||||
@ -397,6 +404,8 @@ def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
|||||||
# Mark vg as found
|
# Mark vg as found
|
||||||
vg_found = True
|
vg_found = True
|
||||||
|
|
||||||
|
log_lvm_info()
|
||||||
|
|
||||||
if vg_found is False and len(new_devices) > 0:
|
if vg_found is False and len(new_devices) > 0:
|
||||||
# Create new volume group from first device
|
# Create new volume group from first device
|
||||||
create_lvm_volume_group(volume_group, new_devices[0])
|
create_lvm_volume_group(volume_group, new_devices[0])
|
||||||
@ -411,6 +420,8 @@ def configure_lvm_storage(block_devices, volume_group, overwrite=False,
|
|||||||
for new_device in new_devices:
|
for new_device in new_devices:
|
||||||
extend_lvm_volume_group(volume_group, new_device)
|
extend_lvm_volume_group(volume_group, new_device)
|
||||||
|
|
||||||
|
log_lvm_info()
|
||||||
|
|
||||||
|
|
||||||
def prepare_volume(device):
|
def prepare_volume(device):
|
||||||
clean_storage(device)
|
clean_storage(device)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from mock import patch, call, MagicMock
|
from mock import patch, call, MagicMock, Mock
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import os
|
import os
|
||||||
@ -14,6 +14,7 @@ TO_PATCH = [
|
|||||||
# helpers.core.hookenv
|
# helpers.core.hookenv
|
||||||
'config',
|
'config',
|
||||||
'log',
|
'log',
|
||||||
|
'juju_log',
|
||||||
'relation_get',
|
'relation_get',
|
||||||
'relation_set',
|
'relation_set',
|
||||||
'local_unit',
|
'local_unit',
|
||||||
@ -245,6 +246,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
cinder_utils.has_partition_table(block_device)
|
cinder_utils.has_partition_table(block_device)
|
||||||
_check.assert_called_with(['fdisk', '-l', '/dev/vdb'], stderr=-2)
|
_check.assert_called_with(['fdisk', '-l', '/dev/vdb'], stderr=-2)
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
||||||
@ -265,6 +267,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
reduce_lvm.assert_called_with('test')
|
reduce_lvm.assert_called_with('test')
|
||||||
extend_lvm.assert_called_with('test', '/dev/vdc')
|
extend_lvm.assert_called_with('test', '/dev/vdc')
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'has_partition_table')
|
@patch.object(cinder_utils, 'has_partition_table')
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@ -287,6 +290,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
reduce_lvm.assert_called_with('test')
|
reduce_lvm.assert_called_with('test')
|
||||||
extend_lvm.assert_called_with('test', '/dev/vdc')
|
extend_lvm.assert_called_with('test', '/dev/vdc')
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'has_partition_table')
|
@patch.object(cinder_utils, 'has_partition_table')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
def test_configure_lvm_storage_used_dev(self, reduce_lvm, has_part):
|
def test_configure_lvm_storage_used_dev(self, reduce_lvm, has_part):
|
||||||
@ -296,6 +300,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
cinder_utils.configure_lvm_storage(devices, 'test', False, True)
|
cinder_utils.configure_lvm_storage(devices, 'test', False, True)
|
||||||
reduce_lvm.assert_called_with('test')
|
reduce_lvm.assert_called_with('test')
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
||||||
@ -312,6 +317,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
reduce_lvm.assert_called_with('test')
|
reduce_lvm.assert_called_with('test')
|
||||||
self.assertFalse(extend_lvm.called)
|
self.assertFalse(extend_lvm.called)
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
||||||
@ -344,6 +350,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
extend_lvm.assert_called_with('test', '/dev/vdc')
|
extend_lvm.assert_called_with('test', '/dev/vdc')
|
||||||
self.assertFalse(self.create_lvm_volume_group.called)
|
self.assertFalse(self.create_lvm_volume_group.called)
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
||||||
@ -372,6 +379,7 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
extend_lvm.assert_called_with('test', '/dev/vdc')
|
extend_lvm.assert_called_with('test', '/dev/vdc')
|
||||||
self.assertFalse(self.create_lvm_volume_group.called)
|
self.assertFalse(self.create_lvm_volume_group.called)
|
||||||
|
|
||||||
|
@patch('cinder_utils.log_lvm_info', Mock())
|
||||||
@patch.object(cinder_utils, 'clean_storage')
|
@patch.object(cinder_utils, 'clean_storage')
|
||||||
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
@patch.object(cinder_utils, 'reduce_lvm_volume_group_missing')
|
||||||
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
@patch.object(cinder_utils, 'extend_lvm_volume_group')
|
||||||
@ -709,3 +717,11 @@ class TestCinderUtils(CharmTestCase):
|
|||||||
cinder_utils.check_db_initialised()
|
cinder_utils.check_db_initialised()
|
||||||
calls = [call(**{'cinder-db-initialised-echo': 'unit/1-1234'})]
|
calls = [call(**{'cinder-db-initialised-echo': 'unit/1-1234'})]
|
||||||
self.relation_set.assert_has_calls(calls)
|
self.relation_set.assert_has_calls(calls)
|
||||||
|
|
||||||
|
@patch('subprocess.check_output')
|
||||||
|
def test_log_lvm_info(self, _check):
|
||||||
|
output = "some output"
|
||||||
|
_check.return_value = output
|
||||||
|
cinder_utils.log_lvm_info()
|
||||||
|
_check.assert_called_with(['pvscan'])
|
||||||
|
self.juju_log.assert_called_with("pvscan: %s" % output)
|
||||||
|
Loading…
Reference in New Issue
Block a user