From 4c2616433aae84d6d65ad519a1ce2ced69f375c1 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Mon, 27 Apr 2020 11:27:08 +0200 Subject: [PATCH] ceph-volume: prepare/create - size args as Size class This add the disk.Size class as all size related argument types. We often create this class form args like this anyway and it enables users to pass not only bytes but also strings like 50G. Signed-off-by: Jan Fajerski (cherry picked from commit 2ff37321640a614fd965d7df6e20d8f9d1430fa3) --- src/ceph-volume/ceph_volume/devices/lvm/common.py | 14 +++++++++----- src/ceph-volume/ceph_volume/devices/lvm/prepare.py | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/common.py b/src/ceph-volume/ceph_volume/devices/lvm/common.py index 7c51f9cdca6d0..e8d976540b3a8 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/common.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/common.py @@ -1,4 +1,4 @@ -from ceph_volume.util import arg_validators +from ceph_volume.util import arg_validators, disk from ceph_volume import process, conf from ceph_volume import terminal import argparse @@ -44,7 +44,8 @@ common_args = { }, '--data-size': { 'help': 'Size of data LV in case a device was passed in --data', - 'default': 0, + 'default': '0', + 'type': disk.Size.parse }, '--data-slots': { 'help': ('Intended number of slots on data device. The new OSD gets one' @@ -92,7 +93,8 @@ bluestore_args = { '--block.db-size': { 'dest': 'block_db_size', 'help': 'Size of block.db LV in case device was passed in --block.db', - 'default': 0, + 'default': '0', + 'type': disk.Size.parse }, '--block.db-slots': { 'dest': 'block_db_slots', @@ -108,7 +110,8 @@ bluestore_args = { '--block.wal-size': { 'dest': 'block_wal_size', 'help': 'Size of block.wal LV in case device was passed in --block.wal', - 'default': 0, + 'default': '0', + 'type': disk.Size.parse }, '--block.wal-slots': { 'dest': 'block_wal_slots', @@ -129,7 +132,8 @@ filestore_args = { }, '--journal-size': { 'help': 'Size of journal LV in case a raw block device was passed in --journal', - 'default': 0, + 'default': '0', + 'type': disk.Size.parse }, } diff --git a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py index e91e6507df5a2..fdda66646a884 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/prepare.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/prepare.py @@ -175,7 +175,7 @@ class Prepare(object): 1), } if size != 0: - kwargs['size'] = disk.Size.parse(size) + kwargs['size'] = size lv = api.create_lv( lv_type, uuid, @@ -212,7 +212,7 @@ class Prepare(object): } logger.debug('data device size: {}'.format(self.args.data_size)) if self.args.data_size != 0: - kwargs['size'] = disk.Size.parse(self.args.data_size) + kwargs['size'] = self.args.data_size return api.create_lv( lv_name_prefix, osd_uuid, -- 2.39.5