]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: add normalize_dict() function
authorGuillaume Abrioux <gabrioux@ibm.com>
Thu, 11 May 2023 11:23:22 +0000 (13:23 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 14:43:29 +0000 (14:43 +0000)
this is to make sure all keys are converted into
lowercase.

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
src/cephadm/node-proxy/redfish_dell.py
src/cephadm/node-proxy/util.py

index 9a611fb7bbe1a4d1a5e76e29a3f6497440443294..c4ccd9add4a6eb86da9dad57ad4f2605c8598a1a 100644 (file)
@@ -1,5 +1,5 @@
 from redfish_system import RedfishSystem
-from util import logger
+from util import logger, normalize_dict
 
 log = logger(__name__)
 
@@ -25,7 +25,7 @@ class RedfishDell(RedfishSystem):
             result[interface_id]['name'] = interface_info['Name']
             result[interface_id]['speed_mbps'] = interface_info['SpeedMbps']
             result[interface_id]['status'] = interface_info['Status']
-        self._system['network'] = result
+        self._system['network'] = normalize_dict(result)
 
     def _update_processors(self):
         cpus_path = self._system['Processors']['@odata.id']
@@ -45,7 +45,7 @@ class RedfishDell(RedfishSystem):
             result[cpu_id]['model'] = cpu_info['Model']
             result[cpu_id]['status'] = cpu_info['Status']
             result[cpu_id]['manufacturer'] = cpu_info['Manufacturer']
-        self._system['processors'] = result
+        self._system['processors'] = normalize_dict(result)
 
     def _update_storage(self):
         storage_path = self._system['Storage']['@odata.id']
@@ -67,7 +67,7 @@ class RedfishDell(RedfishSystem):
                 result[drive_id]['serial_number'] = drive_info['SerialNumber']
                 result[drive_id]['status'] = drive_info['Status']
                 result[drive_id]['location'] = drive_info['PhysicalLocation']
-        self._system['storage'] = result
+        self._system['storage'] = normalize_dict(result)
 
     def _update_metadata(self):
         log.info("Updating metadata")
index d70e99fc4f380ecf462cc71fd9b56896590896cd..f976814c0ce199b890edf5afe577c4222ee84719 100644 (file)
@@ -10,3 +10,12 @@ def logger(name, level=logging.INFO):
     logger.addHandler(handler)
 
     return logger
+
+def normalize_dict(test_dict):
+    res = dict()
+    for key in test_dict.keys():
+        if isinstance(test_dict[key], dict):
+            res[key.lower()] = normalize_dict(test_dict[key])
+        else:
+            res[key.lower()] = test_dict[key]
+    return res