From 693a05a0cb38f3ca91d8aa3a67c0da23a491aa23 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Thu, 6 Apr 2023 14:53:41 +0200 Subject: [PATCH] node-proxy: implement processors endpoint This adds the required logic for the endpoint '/system/processors' to gather and return data about CPUs. Signed-off-by: Guillaume Abrioux --- src/cephadm/node-proxy/redfish_system.py | 26 ++++++++++++++++++++++-- src/cephadm/node-proxy/server.py | 4 ++++ src/cephadm/node-proxy/system.py | 4 ++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/cephadm/node-proxy/redfish_system.py b/src/cephadm/node-proxy/redfish_system.py index de80d83d87d..3d05718be17 100644 --- a/src/cephadm/node-proxy/redfish_system.py +++ b/src/cephadm/node-proxy/redfish_system.py @@ -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) diff --git a/src/cephadm/node-proxy/server.py b/src/cephadm/node-proxy/server.py index 8928cf8de0e..6e4da362329 100644 --- a/src/cephadm/node-proxy/server.py +++ b/src/cephadm/node-proxy/server.py @@ -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()}) diff --git a/src/cephadm/node-proxy/system.py b/src/cephadm/node-proxy/system.py index c43bd35ebf0..cab408d1a7f 100644 --- a/src/cephadm/node-proxy/system.py +++ b/src/cephadm/node-proxy/system.py @@ -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'] -- 2.39.5