]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
node-proxy: implement processors endpoint
authorGuillaume Abrioux <gabrioux@ibm.com>
Thu, 6 Apr 2023 12:53:41 +0000 (14:53 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 14:43:29 +0000 (14:43 +0000)
This adds the required logic for the endpoint '/system/processors'
to gather and return data about CPUs.

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

index de80d83d87d05901be9ddc2a02187193cf095aa4..3d05718be171db471e9ff05c4715f6ecd5819e73 100644 (file)
@@ -37,8 +37,8 @@ class RedfishSystem(System):
     def get_power(self):
         return self._system['power']
 
-    def get_processor(self):
-        return self._system['processor']
+    def get_processors(self):
+        return self._system['processors']
 
     def get_network(self):
         return self._system['network']
@@ -75,6 +75,27 @@ class RedfishSystem(System):
             interface_info = self.client.get_path(interface_path)
             self._system['network'][interface_info['Id']] = interface_info
 
+    def _update_processors(self):
+        cpus_path = self._system['Processors']['@odata.id']
+        log.info("Updating processors")
+        cpus_info = self.client.get_path(cpus_path)
+        self._system['processors'] = {}
+        result = dict()
+        for cpu in cpus_info['Members']:
+            cpu_path = cpu['@odata.id']
+            cpu_info = self.client.get_path(cpu_path)
+            cpu_id = cpu_info['Id']
+            result[cpu_id] = dict()
+            result[cpu_id]['description'] = cpu_info['Description']
+            result[cpu_id]['cores'] = cpu_info['TotalCores']
+            result[cpu_id]['threads'] = cpu_info['TotalThreads']
+            result[cpu_id]['type'] = cpu_info['ProcessorType']
+            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
+
+
     def _update_storage(self):
         log.info("Updating storage")
         pass
@@ -99,6 +120,7 @@ class RedfishSystem(System):
                 self._update_memory()
                 self._update_power()
                 self._update_network()
+                self._update_processors()
                 self._update_storage()
                 sleep(3)
         # Catching 'Exception' is probably not a good idea (devel only)
index 8928cf8de0eb491190ac5b7703864358c85fb9f3..6e4da362329b35266545112a5ea3024e481001c9 100644 (file)
@@ -37,6 +37,10 @@ def get_system_memory():
 def get_system_network():
     return jsonify({'network': system.get_network()})
 
+@app.route('/system/processors', methods=['GET'])
+def get_system_processors():
+    return jsonify({'processors': system.get_processors()})
+
 @app.route('/system/status', methods=['GET'])
 def get_system_status():
     return jsonify({'status': system.get_status()})
index c43bd35ebf0c6ffd1b9d50394ebba8956e93acae..cab408d1a7fd318ff1e9bfc6d43835b2984a9a30 100644 (file)
@@ -13,8 +13,8 @@ class System:
     def get_metadata(self):
         return self._system['metadata']
 
-    def get_processor(self):
-        return self._system['processor']
+    def get_processors(self):
+        return self._system['processors']
 
     def get_memory(self):
         return self._system['memory']