]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orchestrator: fix device pretty-print, added unit test 26357/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 12 Feb 2019 07:22:58 +0000 (07:22 +0000)
committerRicardo Dias <rdias@suse.com>
Tue, 12 Feb 2019 07:22:58 +0000 (07:22 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/test_orchestrator.py

index 0f5c12ee1f0924864a4b311047975b0359934332..408c8ee514504c2681a044b827aa1329d030b887 100644 (file)
@@ -788,8 +788,9 @@ class InventoryDevice(object):
             return row_format.format("Device Path", "Type", "Size", "Rotates",
                                      "Available", "Model")
         else:
-            return row_format.format(self.id, self.type if self.type is not None else "",
-                                     format_bytes(self.size, 5, colored=False),
+            return row_format.format(str(self.id), self.type if self.type is not None else "",
+                                     format_bytes(self.size if self.size is not None else 0, 5,
+                                                  colored=False),
                                      str(self.rotates), str(self.available),
                                      self.dev_id if self.dev_id is not None else "")
 
index b0c8742b551ce2b832f1c822648ab00fd53cba30..4152cc8cfa4dd7d59913b15c4c0f2226d10e62dc 100644 (file)
@@ -2,7 +2,7 @@ from __future__ import absolute_import
 import pytest
 
 
-from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError
+from orchestrator import DriveGroupSpec, DeviceSelection, DriveGroupValidationError, InventoryDevice
 
 
 def test_DriveGroup():
@@ -34,3 +34,7 @@ def test_drive_selection():
     with pytest.raises(DriveGroupValidationError, match='exclusive'):
         DeviceSelection(paths=['/dev/sda'], rotates=False)
 
+def test_inventory_device():
+    i_d = InventoryDevice()
+    s = i_d.pretty_print()
+    assert len(s)