From: Tim Serong Date: Tue, 20 Sep 2022 05:42:51 +0000 (+1000) Subject: python-common: Add 'KB' to supported suffixes in SizeMatcher X-Git-Tag: v18.1.0~1134^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F48184%2Fhead;p=ceph.git python-common: Add 'KB' to supported suffixes in SizeMatcher Fixes: https://tracker.ceph.com/issues/57609 Signed-off-by: Tim Serong --- diff --git a/src/python-common/ceph/deployment/drive_selection/matchers.py b/src/python-common/ceph/deployment/drive_selection/matchers.py index 8203796659b3..f423c2f43eea 100644 --- a/src/python-common/ceph/deployment/drive_selection/matchers.py +++ b/src/python-common/ceph/deployment/drive_selection/matchers.py @@ -175,9 +175,9 @@ class SizeMatcher(Matcher): """ SUFFIXES = ( - ["MB", "GB", "TB"], - ["M", "G", "T"], - [1e+6, 1e+9, 1e+12] + ["KB", "MB", "GB", "TB"], + ["K", "M", "G", "T"], + [1e+3, 1e+6, 1e+9, 1e+12] ) supported_suffixes = SUFFIXES[0] + SUFFIXES[1] diff --git a/src/python-common/ceph/tests/test_disk_selector.py b/src/python-common/ceph/tests/test_disk_selector.py index 0b7826c4b069..b08236130e06 100644 --- a/src/python-common/ceph/tests/test_disk_selector.py +++ b/src/python-common/ceph/tests/test_disk_selector.py @@ -122,6 +122,12 @@ class TestSizeMatcher(object): assert matcher.low[0] == '50' assert matcher.low[1] == 'GB' + def test_to_byte_KB(self): + """ I doubt anyone ever thought we'd need to understand KB """ + + ret = drive_selection.SizeMatcher('size', '4K').to_byte(('4', 'KB')) + assert ret == 4 * 1e+3 + def test_to_byte_GB(self): """ Pretty nonesense test.."""