开源软件名称(OpenSource Name):DMTF/python-redfish-library开源软件地址(OpenSource Url):https://github.com/DMTF/python-redfish-library开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):python-redfish-libraryDescriptionAs of version 3.0.0, Python2 is no longer supported. If Python2 is required, REST (Representational State Transfer) is a web based software architectural style consisting of a set of constraints that focuses on a system's resources. The Redfish library performs GET, POST, PUT, PATCH and DELETE HTTP operations on resources within a Redfish service. Go to the wiki for more details. Installingpip install redfish Building from zip file sourcepython setup.py sdist --formats=zip (this will produce a .zip file)
cd dist
pip install redfish-x.x.x.zip RequirementsEnsure the system does not have the OpenStack "python-redfish" module installed on the target system. This module is using a conflicting package name that this library already uses. The module in question can be found here: https://pypi.org/project/python-redfish/ UsageA set of examples is provided under the examples directory of this project. In addition to the directives present in this paragraph, you will find valuable implementation tips and tricks in those examples. Import the relevant Python moduleFor a Redfish conformant application import the relevant Python module. For Redfish conformant application: import redfish Create a Redfish objectThe Redfish object contains three required parameters:
There are several optional parameters:
To crete a Redfish object, call the REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
password=login_password, default_prefix='/redfish/v1/') Login to the serviceAfter creating the REDFISH_OBJ, perform the
REDFISH_OBJ.login(auth="session") Perform a GET operationA simple GET operation can be performed to obtain the data present in any valid path. An example of GET operation on the path "/redfish/v1/systems/1" is shown below: response = REDFISH_OBJ.get("/redfish/v1/systems/1", None) Perform a POST operationA POST operation can be performed to create a resource or perform an action. An example of a POST operation on the path "/redfish/v1/systems/1/Actions/ComputerSystem.Reset" is shown below: body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body) Working with tasksA POST and PATCH operations may result in a task, describing an operation with a duration greater than the span of a single request.
The action message object that body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
if(response.is_processing):
task = response.monitor(context)
while(task.is_processing):
retry_time = task.retry_after
task_status = task.dict['TaskState']
time.sleep(retry_time if retry_time else 5)
task = response.monitor(context) Logout the created sessionEnsure you perform a REDFISH_OBJ.logout() The Using proxiesThere are two methods for using proxies: configuring environment variables or directly providing proxy information. Environment variablesYou can use a proxy by specifying the export HTTP_PROXY="http://192.168.1.10:8888"
export HTTPS_PROXY="http://192.168.1.10:8888" Directly providedYou can use a proxy by building a dictionary containing the proxy information and providing it to the proxies = {
'http': 'http://192.168.1.10:8888',
'https': 'http://192.168.1.10:8888',
}
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
password=login_password, proxies=proxies) SOCKS proxy supportAn additional package is required to use SOCKS proxies. pip install -U requests[socks] Once installed, the proxy can be configured using environment variables or directly provided like any other proxy. For example: export HTTP_PROXY="socks5h://localhost:8123"
export HTTPS_PROXY="socks5h://localhost:8123" Release Process
Copyright and LicenseCopyright Notice: Copyright 2016-2022 DMTF. All rights reserved. License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论