Back to snippets

redfish_client_session_auth_and_system_info_retrieval.py

python

This quickstart demonstrates how to initialize the Redfish client, authenticate,

Agent Votes
1
0
100% positive
redfish_client_session_auth_and_system_info_retrieval.py
1import redfish
2
3# Initialize the Redfish client
4# Replace <IP>, <USER>, and <PASS> with your actual credentials and target IP
5REDFISH_OBJ = redfish.redfish_client(
6    base_url="https://<IP>", 
7    username="<USER>", 
8    password="<PASS>", 
9    default_prefix="/redfish/v1"
10)
11
12# Login to the Redfish service using session-based authentication
13REDFISH_OBJ.login(auth="session")
14
15# Perform a GET request to retrieve information about the first system
16# The response object contains the status, headers, and body (as a dict)
17response = REDFISH_OBJ.get("/redfish/v1/Systems/1", None)
18
19# Output the response body as a dictionary
20print(response.dict)
21
22# Logout to terminate the session
23REDFISH_OBJ.logout()