From: Guillaume Abrioux Date: Thu, 6 Apr 2023 12:56:48 +0000 (+0200) Subject: node-proxy: implement storage endpoint X-Git-Tag: testing/wip-pdonnell-testing-20240430.123648-reef-debug~291^2~111 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f48a67e330bbe26b78ada9e7447708070bd4efdc;p=ceph-ci.git node-proxy: implement storage endpoint This adds the required logic for the endpoint '/system/storage' to gather and return data about physical drives. Signed-off-by: Guillaume Abrioux (cherry picked from commit d919132be3e69e5494e44519e46a864833802b96) --- diff --git a/src/cephadm/node-proxy/redfish_system.py b/src/cephadm/node-proxy/redfish_system.py index 76d51835415..483bdb90a7a 100644 --- a/src/cephadm/node-proxy/redfish_system.py +++ b/src/cephadm/node-proxy/redfish_system.py @@ -104,8 +104,26 @@ class RedfishSystem(System): def _update_storage(self): + storage_path = self._system['Storage']['@odata.id'] log.info("Updating storage") - pass + storage_info = self.client.get_path(storage_path) + result = dict() + for storage in storage_info['Members']: + entity_path = storage['@odata.id'] + entity_info = self.client.get_path(entity_path) + for drive in entity_info['Drives']: + drive_path = drive['@odata.id'] + drive_info = self.client.get_path(drive_path) + drive_id = drive_info['Id'] + result[drive_id] = dict() + result[drive_id]['description'] = drive_info['Description'] + result[drive_id]['capacity_bytes'] = drive_info['CapacityBytes'] + result[drive_id]['model'] = drive_info['Model'] + result[drive_id]['protocol'] = drive_info['Protocol'] + 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 def start_update_loop(self): self.run = True diff --git a/src/cephadm/node-proxy/server.py b/src/cephadm/node-proxy/server.py index 6e4da362329..11ce48890d9 100644 --- a/src/cephadm/node-proxy/server.py +++ b/src/cephadm/node-proxy/server.py @@ -41,6 +41,10 @@ def get_system_network(): def get_system_processors(): return jsonify({'processors': system.get_processors()}) +@app.route('/system/storage', methods=['GET']) +def get_system_storage(): + return jsonify({'storage': system.get_storage()}) + @app.route('/system/status', methods=['GET']) def get_system_status(): return jsonify({'status': system.get_status()})