]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume batch: use disk.Size for size args
authorJan Fajerski <jfajerski@suse.com>
Fri, 19 Jun 2020 10:58:17 +0000 (12:58 +0200)
committerJan Fajerski <jfajerski@suse.com>
Fri, 2 Oct 2020 07:47:42 +0000 (09:47 +0200)
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
(cherry picked from commit 0bc7f7424cdd0a2c5f2cd777467814dbb3959fb4)

src/ceph-volume/ceph_volume/devices/lvm/batch.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py

index 56c5a59f95c1e366454c27f38464c6628664ca74..b2f667d9d653864f440d38c56b87203111b35de6 100644 (file)
@@ -233,7 +233,7 @@ class Batch(object):
         )
         parser.add_argument(
             '--block-db-size',
-            type=int,
+            type=disk.Size.parse,
             help='Set (or override) the "bluestore_block_db_size" value, in bytes'
         )
         parser.add_argument(
@@ -243,7 +243,7 @@ class Batch(object):
         )
         parser.add_argument(
             '--block-wal-size',
-            type=int,
+            type=disk.Size.parse,
             help='Set (or override) the "bluestore_block_wal_size" value, in bytes'
         )
         parser.add_argument(
@@ -253,7 +253,7 @@ class Batch(object):
         )
         parser.add_argument(
             '--journal-size',
-            type=int,
+            type=disk.Size.parse,
             help='Override the "osd_journal_size" value, in megabytes'
         )
         parser.add_argument(
@@ -556,4 +556,6 @@ class Batch(object):
             return report
 
         def report_json(self):
-            return self._get_osd_plan()
+            # cast all values to string so that the report can be dumped in to
+            # json.dumps
+            return {k: str(v) for k, v in self._get_osd_plan().items()}
index cd1c4b7af4d9faabef55ac93c1599eef130c9455..874acd6b70d475226d3068014dad37319b127d0f 100644 (file)
@@ -19,6 +19,27 @@ class TestBatch(object):
             batch.ensure_disjoint_device_lists(devices, db_devices)
         assert 'Device lists are not disjoint' in str(disjoint_ex.value)
 
+    @pytest.mark.parametrize('format_', ['pretty', 'json', 'json-pretty'])
+    def test_json_report(self, format_, factory, conf_ceph_stub, mock_device_generator):
+        # just ensure reporting works
+        conf_ceph_stub('[global]\nfsid=asdf-lkjh')
+        devs = [mock_device_generator() for _ in range(5)]
+        args = factory(data_slots=1,
+                       osds_per_device=1,
+                       osd_ids=[],
+                       report=True,
+                       format=format_,
+                       devices=devs,
+                       db_devices=[],
+                       wal_devices=[],
+                       bluestore=True,
+                       block_db_size="1G",
+                      )
+        b = batch.Batch([])
+        plan = b.get_plan(args)
+        b.args = args
+        b.report(plan)
+
     def test_get_physical_osds_return_len(self, factory,
                                           mock_devices_available,
                                           osds_per_device):