Drop partition creation with ceph-volume
If a block device is due to be used for a LVM PV, don't bother creating a single partition as its not required and just adds a layer of complexity. This also allows partitions or bcache devices to be consumed as block devices for ceph OSD's. Change-Id: I6fac0c781e269c229fb4781dd6683a7236d8e960
This commit is contained in:
parent
4fb0fe3706
commit
3c7b6b3eee
|
@ -1822,8 +1822,8 @@ def _luks_uuid(dev):
|
|||
def _initialize_disk(dev, dev_uuid, encrypt=False,
|
||||
key_manager=CEPH_KEY_MANAGER):
|
||||
"""
|
||||
Initialize a raw block device with a single paritition
|
||||
consuming 100% of the avaliable disk space.
|
||||
Initialize a raw block device consuming 100% of the avaliable
|
||||
disk space.
|
||||
|
||||
Function assumes that block device has already been wiped.
|
||||
|
||||
|
@ -1834,45 +1834,30 @@ def _initialize_disk(dev, dev_uuid, encrypt=False,
|
|||
:raises: subprocess.CalledProcessError: if any parted calls fail
|
||||
:returns: str: Full path to new partition.
|
||||
"""
|
||||
partition = _partition_name(dev)
|
||||
use_vaultlocker = encrypt and key_manager == VAULT_KEY_MANAGER
|
||||
|
||||
if use_vaultlocker:
|
||||
# NOTE(jamespage): Check to see if already initialized as a LUKS
|
||||
# volume, which indicates this is a shared block
|
||||
# device for journal, db or wal volumes.
|
||||
luks_uuid = _luks_uuid(partition)
|
||||
luks_uuid = _luks_uuid(dev)
|
||||
if luks_uuid:
|
||||
return '/dev/mapper/crypt-{}'.format(luks_uuid)
|
||||
|
||||
dm_crypt = '/dev/mapper/crypt-{}'.format(dev_uuid)
|
||||
|
||||
if not os.path.exists(partition):
|
||||
subprocess.check_call([
|
||||
'parted', '--script',
|
||||
dev,
|
||||
'mklabel',
|
||||
'gpt',
|
||||
])
|
||||
subprocess.check_call([
|
||||
'parted', '--script',
|
||||
dev,
|
||||
'mkpart',
|
||||
'primary', '1', '100%',
|
||||
])
|
||||
|
||||
if use_vaultlocker and not os.path.exists(dm_crypt):
|
||||
subprocess.check_call([
|
||||
'vaultlocker',
|
||||
'encrypt',
|
||||
'--uuid', dev_uuid,
|
||||
partition,
|
||||
dev,
|
||||
])
|
||||
|
||||
if use_vaultlocker:
|
||||
return dm_crypt
|
||||
else:
|
||||
return partition
|
||||
return dev
|
||||
|
||||
|
||||
def _allocate_logical_volume(dev, lv_type, osd_fsid,
|
||||
|
|
|
@ -662,21 +662,8 @@ class CephInitializeDiskTestCase(unittest.TestCase):
|
|||
_luks_uuid.return_value = None
|
||||
self.assertEqual(utils._initialize_disk('/dev/sdb',
|
||||
'test-UUID'),
|
||||
'/dev/sdb1')
|
||||
_check_call.assert_has_calls([
|
||||
call([
|
||||
'parted', '--script',
|
||||
'/dev/sdb',
|
||||
'mklabel',
|
||||
'gpt',
|
||||
]),
|
||||
call([
|
||||
'parted', '--script',
|
||||
'/dev/sdb',
|
||||
'mkpart',
|
||||
'primary', '1', '100%',
|
||||
]),
|
||||
])
|
||||
'/dev/sdb')
|
||||
_check_call.assert_not_called()
|
||||
|
||||
@patch.object(utils, '_luks_uuid')
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
|
@ -690,23 +677,11 @@ class CephInitializeDiskTestCase(unittest.TestCase):
|
|||
True,
|
||||
'vault'),
|
||||
'/dev/mapper/crypt-test-UUID')
|
||||
_check_call.assert_has_calls([
|
||||
call([
|
||||
'parted', '--script',
|
||||
'/dev/sdb',
|
||||
'mklabel',
|
||||
'gpt',
|
||||
]),
|
||||
call([
|
||||
'parted', '--script',
|
||||
'/dev/sdb',
|
||||
'mkpart',
|
||||
'primary', '1', '100%',
|
||||
]),
|
||||
call(['vaultlocker', 'encrypt',
|
||||
'--uuid', 'test-UUID',
|
||||
'/dev/sdb1']),
|
||||
])
|
||||
_check_call.assert_called_once_with(
|
||||
['vaultlocker', 'encrypt',
|
||||
'--uuid', 'test-UUID',
|
||||
'/dev/sdb']
|
||||
)
|
||||
|
||||
@patch.object(utils, '_luks_uuid')
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
|
@ -724,18 +699,6 @@ class CephInitializeDiskTestCase(unittest.TestCase):
|
|||
'/dev/mapper/crypt-existing-UUID')
|
||||
_check_call.assert_not_called()
|
||||
|
||||
@patch.object(utils, '_luks_uuid')
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
@patch.object(utils.os.path, 'exists')
|
||||
def test_initialize_disk_exists(self, _exists, _check_call,
|
||||
_luks_uuid):
|
||||
_exists.return_value = True
|
||||
_luks_uuid.return_value = None
|
||||
self.assertEqual(utils._initialize_disk('/dev/sdb',
|
||||
'test-UUID'),
|
||||
'/dev/sdb1')
|
||||
_check_call.assert_not_called()
|
||||
|
||||
|
||||
class CephActiveBlueStoreDeviceTestCase(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue