]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/nfs: Changes for get QoS command to return bandwidth in GiB instead of GB
authorShweta Bhosale <Shweta.Bhosale1@ibm.com>
Mon, 14 Apr 2025 09:30:28 +0000 (15:00 +0530)
committerShweta Bhosale <Shweta.Bhosale1@ibm.com>
Mon, 27 Apr 2026 12:49:15 +0000 (18:19 +0530)
Fixes: https://tracker.ceph.com/issues/69458
Signed-off-by: Shweta Bhosale <Shweta.Bhosale1@ibm.com>
src/pybind/mgr/nfs/qos_conf.py
src/pybind/mgr/nfs/tests/test_nfs.py

index 02863a756cafda894fa51c677b6c3e4b1612facd..ea2ccdd5a7eab5e4b9b9c5f10b1869e75710babf 100644 (file)
@@ -169,7 +169,7 @@ class QOSBandwidthControl(object):
 
     @staticmethod
     def bw_for_to_dict(bandwidth: int, ret_bw_in_bytes: bool = False) -> str:
-        return bytes_to_human(bandwidth) if not ret_bw_in_bytes else str(bandwidth)
+        return bytes_to_human(bandwidth, mode='binary') if not ret_bw_in_bytes else str(bandwidth)
 
     def to_dict(self, ret_bw_in_bytes: bool = False) -> Dict[str, Any]:
         r: dict[str, Any] = {}
index f574f48ecd3844e764fb1b21f9f8a6c87151d45a..e677086047b875e6c9bc7805b7718d83c04fe14a 100644 (file)
@@ -178,10 +178,10 @@ QOS_BLOCK {
         "enable_bw_control": True,
         "enable_qos": True,
         "combined_rw_bw_control": False,
-        "max_client_read_bw": "4.0MB",
-        "max_client_write_bw": "3.0MB",
-        "max_export_read_bw": "2.0MB",
-        "max_export_write_bw": "2.0MB",
+        "max_client_read_bw": bytes_to_human(4000000, mode='binary'),
+        "max_client_write_bw": bytes_to_human(3000000, mode='binary'),
+        "max_export_read_bw": bytes_to_human(2000000, mode='binary'),
+        "max_export_write_bw": bytes_to_human(2000000, mode='binary'),
         "qos_type": "PerShare_PerClient",
         "enable_iops_control": False
     }
@@ -202,10 +202,10 @@ QOS_BLOCK {
         "enable_bw_control": True,
         "enable_qos": True,
         "combined_rw_bw_control": False,
-        "max_client_read_bw": "4.0MB",
-        "max_client_write_bw": "3.0MB",
-        "max_export_read_bw": "2.0MB",
-        "max_export_write_bw": "2.0MB",
+        "max_client_read_bw": bytes_to_human(4000000, mode='binary'),
+        "max_client_write_bw": bytes_to_human(3000000, mode='binary'),
+        "max_export_read_bw": bytes_to_human(2000000, mode='binary'),
+        "max_export_write_bw": bytes_to_human(2000000, mode='binary'),
         "enable_iops_control": False
     }
     qos_export_dict_bw_in_bytes = {
@@ -1457,22 +1457,10 @@ EXPORT {
 
     def test_qos_from_dict(self):
         qos = QOS.from_dict(self.qos_cluster_dict, True)
-        assert qos.enable_qos == True
-        assert qos.bw_obj.enable_bw_ctrl == True
-        assert isinstance(qos.qos_type, QOSType)
-        assert qos.bw_obj.export_writebw == 2000000
-        assert qos.bw_obj.export_readbw == 2000000
-        assert qos.bw_obj.client_writebw == 3000000
-        assert qos.bw_obj.client_readbw == 4000000
+        assert qos.to_dict() == self.qos_cluster_dict
 
         qos = QOS.from_dict(self.qos_export_dict)
-        assert qos.enable_qos == True
-        assert qos.bw_obj.enable_bw_ctrl == True
-        assert qos.qos_type is None
-        assert qos.bw_obj.export_writebw == 2000000
-        assert qos.bw_obj.export_readbw == 2000000
-        assert qos.bw_obj.client_writebw == 3000000
-        assert qos.bw_obj.client_readbw == 4000000
+        assert qos.to_dict() == self.qos_export_dict
 
     @pytest.mark.parametrize("qos_block, qos_dict, qos_dict_bw_in_bytes", [
         (qos_cluster_block, qos_cluster_dict, qos_cluster_dict_bw_in_bytes),
@@ -1500,7 +1488,7 @@ EXPORT {
         out = cluster.get_cluster_qos(self.cluster_id)
         expected_out = {"enable_bw_control": True, "enable_qos": True, "combined_rw_bw_control": combined_bw_ctrl, "qos_type": qos_type.name, "enable_iops_control": False}
         for key in params:
-            expected_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(params[key]))
+            expected_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(params[key]), mode='binary')
         assert out == expected_out
         cluster.disable_cluster_qos_bw(self.cluster_id)
         out = cluster.get_cluster_qos(self.cluster_id)
@@ -1557,7 +1545,7 @@ EXPORT {
         out = export_mgr.get_export_qos(self.cluster_id, '/cephfs_a/')
         expected_out = {"enable_bw_control": True, "enable_qos": True, "combined_rw_bw_control": export_combined_bw_ctrl}
         for key in export_params:
-            expected_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(export_params[key]))
+            expected_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(export_params[key]), mode='binary')
         expected_out.update(clust_qos_conf)
         assert out == expected_out
         export_mgr.disable_export_qos_bw(self.cluster_id, '/cephfs_a/')
@@ -1686,7 +1674,7 @@ EXPORT {
         bw_out = {}
         ops_out = {}
         for key in bw_params:
-            bw_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(bw_params[key]))
+            bw_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(bw_params[key]), mode='binary')
         for key in ops_params:
             ops_out[QOSParams[key].value] = ops_params[key]
         expected_out.update(bw_out)
@@ -1763,7 +1751,7 @@ EXPORT {
         bw_out = {}
         ops_out = {}
         for key in export_bw_params:
-            bw_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(export_bw_params[key]))
+            bw_out[QOSParams[key].value] = bytes_to_human(with_units_to_int(export_bw_params[key]), mode='binary')
         for key in export_ops_params:
             ops_out[QOSParams[key].value] = export_ops_params[key]
         expected_out.update(bw_out)