diff --git a/library/ceph_volume.py b/library/ceph_volume.py index 4a6c5ff0c..b8f129947 100644 --- a/library/ceph_volume.py +++ b/library/ceph_volume.py @@ -114,6 +114,24 @@ options: - Only applicable if action is 'batch'. required: false default: -1 + journal_devices: + description: + - A list of devices for filestore journal to pass to the 'ceph-volume lvm batch' subcommand. + - Only applicable if action is 'batch'. + - Only applicable if objectstore is 'filestore'. + required: false + block_db_devices: + description: + - A list of devices for bluestore block db to pass to the 'ceph-volume lvm batch' subcommand. + - Only applicable if action is 'batch'. + - Only applicable if objectstore is 'bluestore'. + required: false + wal_devices: + description: + - A list of devices for bluestore block wal to pass to the 'ceph-volume lvm batch' subcommand. + - Only applicable if action is 'batch'. + - Only applicable if objectstore is 'bluestore'. + required: false report: description: - If provided the --report flag will be passed to 'ceph-volume lvm batch'. @@ -321,13 +339,16 @@ def batch(module, container_image): cmd.extend(batch_devices) if journal_devices and objectstore == 'filestore': - cmd.extend(['--journal-devices', ' '.join(journal_devices)]) + cmd.append('--journal-devices') + cmd.extend(journal_devices) if block_db_devices and objectstore == 'bluestore': - cmd.extend(['--db-devices', ' '.join(block_db_devices)]) + cmd.append('--db-devices') + cmd.extend(block_db_devices) if wal_devices and objectstore == 'bluestore': - cmd.extend(['--wal-devices', ' '.join(wal_devices)]) + cmd.append('--wal-devices') + cmd.extend(wal_devices) return cmd diff --git a/tests/library/test_ceph_volume.py b/tests/library/test_ceph_volume.py index 080204550..fc39565a4 100644 --- a/tests/library/test_ceph_volume.py +++ b/tests/library/test_ceph_volume.py @@ -351,7 +351,7 @@ class TestCephVolumeModule(object): 'journal_size': '100', 'cluster': 'ceph', 'batch_devices': ["/dev/sda", "/dev/sdb"], - 'journal_devices': ["/dev/sdc"]} + 'journal_devices': ["/dev/sdc", "/dev/sdd"]} fake_container_image = None expected_command_list = ['ceph-volume', @@ -366,7 +366,81 @@ class TestCephVolumeModule(object): '/dev/sda', '/dev/sdb', '--journal-devices', - '/dev/sdc'] + '/dev/sdc', + '/dev/sdd'] + result = ceph_volume.batch( + fake_module, fake_container_image) + assert result == expected_command_list + + def test_batch_bluestore_with_dedicated_db(self): + fake_module = MagicMock() + fake_module.params = {'objectstore': 'bluestore', + 'block_db_size': '-1', + 'cluster': 'ceph', + 'batch_devices': ["/dev/sda", "/dev/sdb"], + 'block_db_devices': ["/dev/sdc", "/dev/sdd"]} + + fake_container_image = None + expected_command_list = ['ceph-volume', + '--cluster', + 'ceph', + 'lvm', + 'batch', + '--bluestore', + '--yes', + '/dev/sda', + '/dev/sdb', + '--db-devices', + '/dev/sdc', + '/dev/sdd'] + result = ceph_volume.batch( + fake_module, fake_container_image) + assert result == expected_command_list + + def test_batch_bluestore_with_dedicated_wal(self): + fake_module = MagicMock() + fake_module.params = {'objectstore': 'bluestore', + 'cluster': 'ceph', + 'block_db_size': '-1', + 'batch_devices': ["/dev/sda", "/dev/sdb"], + 'wal_devices': ["/dev/sdc", "/dev/sdd"]} + + fake_container_image = None + expected_command_list = ['ceph-volume', + '--cluster', + 'ceph', + 'lvm', + 'batch', + '--bluestore', + '--yes', + '/dev/sda', + '/dev/sdb', + '--wal-devices', + '/dev/sdc', + '/dev/sdd'] + result = ceph_volume.batch( + fake_module, fake_container_image) + assert result == expected_command_list + + def test_batch_bluestore_with_custom_db_size(self): + fake_module = MagicMock() + fake_module.params = {'objectstore': 'bluestore', + 'cluster': 'ceph', + 'block_db_size': '4096', + 'batch_devices': ["/dev/sda", "/dev/sdb"]} + + fake_container_image = None + expected_command_list = ['ceph-volume', + '--cluster', + 'ceph', + 'lvm', + 'batch', + '--bluestore', + '--yes', + '--block-db-size', + '4096', + '/dev/sda', + '/dev/sdb'] result = ceph_volume.batch( fake_module, fake_container_image) assert result == expected_command_list