1bb347bbeSSushil Singh*** Settings ***
2bb347bbeSSushil Singh
3bb347bbeSSushil SinghDocumentation     Redfish request library which provide keywords for creating session,
4bb347bbeSSushil Singh...               sending POST, PUT, DELETE, PATCH, GET etc. request using redfish_request.py
5bb347bbeSSushil Singh...               library file. It also contain other keywords which uses redfish_request.py
64b729499SGeorge Keishing...               library infrastructure.
7bb347bbeSSushil Singh
8bb347bbeSSushil SinghResource          openbmc_ffdc.robot
9bb347bbeSSushil SinghResource          bmc_redfish_resource.robot
10bb347bbeSSushil SinghResource          rest_response_code.robot
11bb347bbeSSushil SinghLibrary           redfish_request.py
12bb347bbeSSushil Singh
13bb347bbeSSushil Singh*** Keywords ***
14bb347bbeSSushil Singh
15bb347bbeSSushil SinghRedfish Generic Login Request
16bb347bbeSSushil Singh    [Documentation]  Do Redfish login request.
17bb347bbeSSushil Singh    [Arguments]  ${user_name}  ${password}
18bb347bbeSSushil Singh
19bb347bbeSSushil Singh    # Description of argument(s):
20bb347bbeSSushil Singh    # user_name   User name of BMC.
21bb347bbeSSushil Singh    # password    Password of BMC.
22bb347bbeSSushil Singh
23bb347bbeSSushil Singh    ${client_id}=  Create Dictionary  ClientID=None
24bb347bbeSSushil Singh    ${oem_data}=  Create Dictionary  OpenBMC=${client_id}
25bb347bbeSSushil Singh    ${data}=  Create Dictionary  UserName=${user_name}  Password=${password}  Oem=${oem_data}
26bb347bbeSSushil Singh
27bb347bbeSSushil Singh    Set Test Variable  ${uri}  /redfish/v1/SessionService/Sessions
28bb347bbeSSushil Singh    ${resp}=  Request_Login  headers=None  url=${uri}  credential=${data}
29bb347bbeSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_CREATED}
30bb347bbeSSushil Singh
31bb347bbeSSushil Singh    [Return]  ${resp}
32bb347bbeSSushil Singh
33bb347bbeSSushil Singh
34bb347bbeSSushil SinghRedfish Generic Session Request
35bb347bbeSSushil Singh    [Documentation]  Do Redfish login request and store the session details.
36bb347bbeSSushil Singh    [Arguments]  ${user_name}  ${password}
37bb347bbeSSushil Singh
38bb347bbeSSushil Singh    # Description of argument(s):
39bb347bbeSSushil Singh    # user_name   User name of BMC.
40bb347bbeSSushil Singh    # password    Password of BMC.
41bb347bbeSSushil Singh
42bb347bbeSSushil Singh    ${session_dict}=   Create Dictionary
43bb347bbeSSushil Singh    ${session_resp}=   Redfish Generic Login Request  ${user_name}  ${password}
44bb347bbeSSushil Singh
45bb347bbeSSushil Singh    ${auth_token}=  Create Dictionary  X-Auth-Token  ${session_resp.headers['X-Auth-Token']}
46bb347bbeSSushil Singh
47bb347bbeSSushil Singh    Set To Dictionary  ${session_dict}  headers  ${auth_token}
48bb347bbeSSushil Singh    Set To Dictionary  ${session_dict}  Location  ${session_resp.headers['Location']}
49bb347bbeSSushil Singh
50bb347bbeSSushil Singh
51*fbd67007SGeorge Keishing    Set To Dictionary  ${session_dict}  Content  ${session_resp.content}
52bb347bbeSSushil Singh
53bb347bbeSSushil Singh    Set Global Variable  ${active_session_info}  ${session_dict}
54bb347bbeSSushil Singh    Append To List  ${session_dict_list}  ${session_dict}
55bb347bbeSSushil Singh
56bb347bbeSSushil Singh    [Return]  ${session_dict}
57