]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: implement storage endpoint
authorGuillaume Abrioux <gabrioux@ibm.com>
Thu, 6 Apr 2023 12:56:48 +0000 (14:56 +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/storage'
to gather and return data about physical drives.

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

index 76d5183541595e8e300ebd75f383d01a856de3c3..483bdb90a7aefb506e0882a63a6fc03739509526 100644 (file)
@@ -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
index 6e4da362329b35266545112a5ea3024e481001c9..11ce48890d94d54ef656d25ff71b101536ddae29 100644 (file)
@@ -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()})