用于python的redfish api客户端
redfish-client的Python项目详细描述
此存储库包含redfish api的最简python客户端。
快速启动
使用此客户端最简单和最安全的方法是将其安装到 专用虚拟环境:
$ virtualenv venv && . venv/bin/activate (venv) $ pip install redfish-client
现在我们可以启动交互式python解释器并与 API:
(venv) $ python >>> import redfish_client >>> import json >>> root = redfish_client.connect( ... "redfish.address", "username", "password" ... ) >>> print(json.dumps(root.raw, indent=2, sort_keys=True)) { "@odata.context": "/redfish/v1/$metadata#ServiceRoot.ServiceRoot", "@odata.etag": "W/\"bb7f4494b922dde991a940cc8251e8fc\"", "@odata.id": "/redfish/v1", "@odata.type": "#ServiceRoot.v1_2_0.ServiceRoot", "AccountService": { "@odata.id": "/redfish/v1/AccountService/" }, # More content here "UpdateService": { "@odata.id": "/redfish/v1/UpdateService/" } } >>> system = root.Systems.Members[0] >>> print(json.dumps(system.raw, indent=2, sort_keys=True)) { "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", "@odata.etag": "W/\"788f9827a97be1a4c8cbe9c085ef4d8b\"", "@odata.id": "/redfish/v1/Systems/1/", "@odata.type": "#ComputerSystem.v1_4_0.ComputerSystem", # More content here "SystemType": "Physical", "UUID": "REMOVED_FROM_MOCK" } >>> print(system.SystemType) Physical