'--block.db': {
'dest': 'block_db',
'help': 'Path to bluestore block.db logical volume or device',
+ 'type': arg_validators.ValidDevice(as_string=True),
},
'--block.db-size': {
'dest': 'block_db_size',
'--block.wal': {
'dest': 'block_wal',
'help': 'Path to bluestore block.wal logical volume or device',
+ 'type': arg_validators.ValidDevice(as_string=True),
},
'--block.wal-size': {
'dest': 'block_wal_size',
},
'--journal': {
'help': 'A logical volume (vg_name/lv_name), or path to a device',
+ 'type': arg_validators.ValidDevice(as_string=True),
},
'--journal-size': {
'help': 'Size of journal LV in case a raw block device was passed in --journal',
mocked_device.return_value = MagicMock(
is_partition=True,
has_gpt_headers=False,
+ has_partitions=False,
)
with pytest.raises(ArgumentError):
arg_validators.ValidBatchDevice()('foo')
import os
from ceph_volume import exceptions
from ceph_volume.util import arg_validators
+from mock.mock import patch, PropertyMock
class TestOSDPath(object):
with pytest.raises(argparse.ArgumentError):
self.validator('/device/does/not/exist')
+ @patch('ceph_volume.util.arg_validators.Device.has_partitions', new_callable=PropertyMock, return_value=True)
+ @patch('ceph_volume.util.arg_validators.Device.exists', new_callable=PropertyMock, return_value=True)
+ @patch('ceph_volume.api.lvm.get_single_lv', return_value=None)
+ def test_dev_has_partitions(self, m_get_single_lv, m_exists, m_has_partitions, fake_call):
+ with pytest.raises(RuntimeError):
+ self.validator('/dev/foo')
+
class TestValidFraction(object):
# __init__
elif device.has_gpt_headers and not self.gpt_ok:
error = "GPT headers found, they must be removed on: %s" % dev_path
-
+ if device.has_partitions:
+ raise RuntimeError("Device {} has partitions.".format(dev_path))
if error:
raise argparse.ArgumentError(None, error)
-
return device
vg_free -= extent_size
return [vg_free]
+ @property
+ def has_partitions(self):
+ '''
+ Boolean to determine if a given device has partitions.
+ '''
+ if self.sys_api.get('partitions'):
+ return True
+ return False
+
def _check_generic_reject_reasons(self):
reasons = [
('removable', 1, 'removable'),
if self.has_gpt_headers:
rejected.append('Has GPT headers')
+ if self.has_partitions:
+ rejected.append('Has partitions')
return rejected
def _check_lvm_reject_reasons(self):