Sushil Singh | c5e9ebc | 2020-04-09 03:32:57 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Management console utilities keywords. |
| 3 | |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 4 | Resource ../../lib/bmc_redfish_utils.robot |
Sushil Singh | c5e9ebc | 2020-04-09 03:32:57 -0500 | [diff] [blame] | 5 | Library ../../lib/gen_robot_valid.py |
| 6 | Library Collections |
| 7 | Library ../../lib/bmc_ssh_utils.py |
| 8 | Library SSHLibrary |
| 9 | |
| 10 | *** Variables *** |
| 11 | &{daemon_command} start=systemctl start avahi-daemon |
| 12 | ... stop=systemctl stop avahi-daemon |
| 13 | ... status=systemctl status avahi-daemon -l |
| 14 | &{daemon_message} start=Active: active (running) |
| 15 | ... stop=Active: inactive (dead) |
| 16 | |
| 17 | *** Keywords *** |
| 18 | |
| 19 | Set AvahiDaemon Service |
| 20 | [Documentation] To enable or disable avahi service. |
| 21 | [Arguments] ${command} |
| 22 | |
| 23 | # Description of argument(s): |
George Keishing | 1faaa46 | 2020-04-16 10:27:20 -0500 | [diff] [blame] | 24 | # command Get command from dictionary. |
Sushil Singh | c5e9ebc | 2020-04-09 03:32:57 -0500 | [diff] [blame] | 25 | |
| 26 | ${service_command}= Get From Dictionary ${daemon_command} ${command} |
| 27 | ${resp} ${stderr} ${rc}= BMC Execute Command ${service_command} print_out=1 |
| 28 | Should Be Equal As Integers ${rc} 0 |
| 29 | |
| 30 | |
| 31 | Verify AvahiDaemon Service Status |
| 32 | [Documentation] To check for avahi service. |
| 33 | [Arguments] ${message} |
| 34 | |
| 35 | # Description of argument(s): |
George Keishing | 1faaa46 | 2020-04-16 10:27:20 -0500 | [diff] [blame] | 36 | # message Get status message from dictionary. |
Sushil Singh | c5e9ebc | 2020-04-09 03:32:57 -0500 | [diff] [blame] | 37 | |
| 38 | ${service_command}= Get From Dictionary ${daemon_command} status |
| 39 | ${service_message}= Get From Dictionary ${daemon_message} ${message} |
| 40 | ${resp} ${stderr} ${rc}= BMC Execute Command ${service_command} print_out=1 |
| 41 | Should Contain ${resp} ${service_message} |
Sushil Singh | d03f2ce | 2020-09-17 08:54:41 -0500 | [diff] [blame] | 42 | |
| 43 | |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 44 | Create Session With ClientID |
| 45 | [Documentation] Create redifish session with client id. |
| 46 | [Arguments] ${client_id} |
| 47 | |
| 48 | # Description of argument(s): |
| 49 | # client_id This client id can contain string value |
| 50 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 51 | |
| 52 | ${session_info}= Create Dictionary |
| 53 | ${session_resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}} |
| 54 | |
| 55 | Set To Dictionary ${session_info} SessionIDs ${session_resp['Id']} |
| 56 | Set To Dictionary ${session_info} ClientID ${session_resp["Oem"]["OpenBMC"]["ClientID"]} |
| 57 | Set To Dictionary ${session_info} SessionToken ${XAUTH_TOKEN} |
| 58 | Set To Dictionary ${session_info} SessionResp ${session_resp} |
| 59 | |
| 60 | [Return] ${session_info} |
| 61 | |
| 62 | |
| 63 | Create Session With List Of ClientID |
| 64 | [Documentation] Create redifish session with client id. |
| 65 | [Arguments] ${client_id} |
| 66 | |
| 67 | # Description of argument(s): |
| 68 | # client_id This client id can contain string value |
| 69 | # (e.g. 12345, "EXTERNAL-CLIENT"). |
| 70 | |
| 71 | @{session_dict_list}= Create List |
| 72 | &{session_dict}= Create Dictionary |
| 73 | |
| 74 | FOR ${client} IN @{client_id} |
| 75 | ${session_dict}= Create Session With ClientID ${client} |
| 76 | Append To List ${session_dict_list} ${session_dict} |
| 77 | END |
| 78 | |
| 79 | [Return] ${session_dict_list} |
| 80 | |
| 81 | |
| 82 | Verify A Session Created With ClientID |
Sushil Singh | 5166ebd | 2021-05-31 01:24:16 -0500 | [diff] [blame] | 83 | [Documentation] Verify the session is created. |
Sushil Singh | 87e984c | 2020-10-20 01:43:47 -0500 | [diff] [blame] | 84 | [Arguments] ${client_id} ${session_ids} |
| 85 | |
| 86 | # Description of argument(s): |
| 87 | # client_id External client name. |
| 88 | # session_id This value is a session id. |
| 89 | |
| 90 | # { |
| 91 | # "@odata.id": "/redfish/v1/SessionService/Sessions/H8q2ZKucSJ", |
| 92 | # "@odata.type": "#Session.v1_0_2.Session", |
| 93 | # "Description": "Manager User Session", |
| 94 | # "Id": "H8q2ZKucSJ", |
| 95 | # "Name": "User Session", |
| 96 | # "Oem": { |
| 97 | # "OpenBMC": { |
| 98 | # "@odata.type": "#OemSession.v1_0_0.Session", |
| 99 | # "ClientID": "", |
| 100 | # "ClientOriginIP": "::ffff:x.x.x.x" |
| 101 | # } |
| 102 | # }, |
| 103 | # "UserName": "root" |
| 104 | # } |
| 105 | |
| 106 | FOR ${client} ${session} IN ZIP ${client_id} ${session_ids} |
| 107 | ${session_resp}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session["SessionIDs"]} |
| 108 | Rprint Vars session_resp |
| 109 | @{words} = Split String ${session_resp["ClientOriginIPAddress"]} : |
| 110 | ${ip_address}= Get Running System IP |
| 111 | Set Test Variable ${temp_ipaddr} ${words}[-1] |
| 112 | Valid Value client ['${session_resp["Oem"]["OpenBMC"]["ClientID"]}'] |
| 113 | Valid Value session["SessionIDs"] ['${session_resp["Id"]}'] |
| 114 | Valid Value temp_ipaddr ${ip_address} |
| 115 | END |
| 116 | |
| 117 | |
Sushil Singh | d03f2ce | 2020-09-17 08:54:41 -0500 | [diff] [blame] | 118 | Get Lock Resource Information |
| 119 | [Documentation] Get lock resource information. |
| 120 | |
| 121 | ${code_base_dir_path}= Get Code Base Dir Path |
| 122 | ${resource_lock_json}= Evaluate |
| 123 | ... json.load(open('${code_base_dir_path}data/resource_lock_table.json')) modules=json |
| 124 | Rprint Vars resource_lock_json |
| 125 | |
| 126 | [Return] ${resource_lock_json} |