1bc331e22SVijay*** Settings *** 2bc331e22SVijay 3d03f2ce1SSushil SinghDocumentation Test lock management feature of management console on BMC. 4bc331e22SVijay 5bc331e22SVijayResource ../../lib/resource.robot 6bc331e22SVijayResource ../../lib/openbmc_ffdc.robot 7566daaf3SGeorge KeishingResource ../../lib/bmc_redfish_utils.robot 8d03f2ce1SSushil SinghResource ../../lib/external_intf/management_console_utils.robot 9*728ef9c9SSushil SinghLibrary ../../lib/bmc_network_utils.py 10bc331e22SVijay 1140ef0eb7SSushil SinghSuite Setup Run Keyword And Ignore Error Delete All Redfish Sessions 12d03f2ce1SSushil SinghSuite Teardown Redfish.Logout 13d03f2ce1SSushil SinghTest Setup Printn 14d03f2ce1SSushil SinghTest Teardown FFDC On Test Case Fail 15bc331e22SVijay 16bc331e22SVijay*** Variables *** 17bc331e22SVijay 18d03f2ce1SSushil Singh${BAD_REQUEST} Bad Request 19bc331e22SVijay 20bc331e22SVijay*** Test Cases *** 21bc331e22SVijay 22d03f2ce1SSushil SinghAcquire Read Write Lock 23bc331e22SVijay [Documentation] Acquire and release different read locks. 24d03f2ce1SSushil Singh [Tags] Acquire_Read_Write_Lock 25d03f2ce1SSushil Singh [Template] Acquire Lock On Resource 26bc331e22SVijay 27d03f2ce1SSushil Singh # client_id lock_type reboot_flag 28d03f2ce1SSushil Singh HMCID-01 ReadCase1 False 29d03f2ce1SSushil Singh HMCID-01 ReadCase2 False 30d03f2ce1SSushil Singh HMCID-01 ReadCase3 False 31d03f2ce1SSushil Singh HMCID-01 WriteCase1 False 32d03f2ce1SSushil Singh HMCID-01 WriteCase2 False 33d03f2ce1SSushil Singh HMCID-01 WriteCase3 False 34bc331e22SVijay 35bc331e22SVijay 36d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot 37d03f2ce1SSushil Singh [Documentation] Acquire lock and check after reboot it remain same. 38d03f2ce1SSushil Singh [Tags] Check_Lock_Persistency_On_BMC_Reboot 39d03f2ce1SSushil Singh [Template] Acquire Lock On Resource 40bc331e22SVijay 41d03f2ce1SSushil Singh # client_id lock_type reboot_flag 42d03f2ce1SSushil Singh HMCID-01 ReadCase1 True 43d03f2ce1SSushil Singh HMCID-01 ReadCase2 True 44d03f2ce1SSushil Singh HMCID-01 ReadCase3 True 45d03f2ce1SSushil Singh HMCID-01 WriteCase1 True 46d03f2ce1SSushil Singh HMCID-01 WriteCase2 True 47d03f2ce1SSushil Singh HMCID-01 WriteCase3 True 48bc331e22SVijay 49bc331e22SVijay 50d03f2ce1SSushil SinghAcquire Read Lock On Read Lock 51d03f2ce1SSushil Singh [Documentation] Acquire read lock on another read lock. 52d03f2ce1SSushil Singh [Tags] Acquire_Read_Lock_On_Read_Lock 53d03f2ce1SSushil Singh [Template] Acquire Lock On Another Lock 54bc331e22SVijay 55d03f2ce1SSushil Singh # client_id 56d03f2ce1SSushil Singh HMCID-01 57bc331e22SVijay 58bc331e22SVijay 59d03f2ce1SSushil SinghGet Lock Records Empty For Invalid Session 60d03f2ce1SSushil Singh [Documentation] Record of lock list is empty for invalid session. 61d03f2ce1SSushil Singh [Tags] Get_Lock_Records_Empty_For_Invalid_Session 62d03f2ce1SSushil Singh [Template] Verify Empty Lock Records For Invalid Session 63355daac7SVijay 64d03f2ce1SSushil Singh # client_id 65d03f2ce1SSushil Singh HMCID-01 66355daac7SVijay 67355daac7SVijay 68d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock 69d03f2ce1SSushil Singh [Documentation] Fail to acquire another lock. 70d03f2ce1SSushil Singh [Tags] Fail_To_Acquire_Lock_On_Another_Lock 71d03f2ce1SSushil Singh [Template] Verify Acquire Lock Fails On Another Lock 7285610eeeSVijay 73d03f2ce1SSushil Singh # client_id lock_type 74d03f2ce1SSushil Singh HMCID-01 ReadCase2,WriteCase2 75d03f2ce1SSushil Singh HMCID-01 WriteCase2,WriteCase2 76d03f2ce1SSushil Singh HMCID-01 WriteCase2,ReadCase2 77566daaf3SGeorge Keishing 78566daaf3SGeorge Keishing 79e33c6e6aSSushil SinghAcquire Lock After Reboot 80e33c6e6aSSushil Singh [Documentation] Acquire and release read and write locks after reboot. 81e33c6e6aSSushil Singh [Tags] Acquire_Lock_After_Reboot 82e33c6e6aSSushil Singh [Template] Verify Acquire Lock After Reboot 83e33c6e6aSSushil Singh 84e33c6e6aSSushil Singh # client_id lock_type 85e33c6e6aSSushil Singh HMCID-01 ReadCase1 86e33c6e6aSSushil Singh HMCID-01 ReadCase2 87e33c6e6aSSushil Singh HMCID-01 ReadCase3 88e33c6e6aSSushil Singh HMCID-01 WriteCase1 89e33c6e6aSSushil Singh HMCID-01 WriteCase2 90e33c6e6aSSushil Singh HMCID-01 WriteCase3 91e33c6e6aSSushil Singh 92e33c6e6aSSushil Singh 93d03f2ce1SSushil SinghAcquire And Release Lock In Loop 94d03f2ce1SSushil Singh [Documentation] Acquire and release read, write locks in loop. 95d03f2ce1SSushil Singh [Tags] Acquire_And_Release_Lock_In_Loop 96d03f2ce1SSushil Singh [Template] Verify Acquire And Release Lock In Loop 97566daaf3SGeorge Keishing 98d03f2ce1SSushil Singh # client_id lock_type 99d03f2ce1SSushil Singh HMCID-01 ReadCase1 100d03f2ce1SSushil Singh HMCID-01 ReadCase2 101d03f2ce1SSushil Singh HMCID-01 ReadCase3 102d03f2ce1SSushil Singh HMCID-01 WriteCase1 103d03f2ce1SSushil Singh HMCID-01 WriteCase2 104d03f2ce1SSushil Singh HMCID-01 WriteCase3 10585610eeeSVijay 10685610eeeSVijay 107d03f2ce1SSushil SinghVerify Release Of Valid Locks 108d03f2ce1SSushil Singh [Documentation] Release all valid locks. 109d03f2ce1SSushil Singh [Tags] Verify_Release_Of_Valid_Locks 110d03f2ce1SSushil Singh [Template] Acquire And Release Multiple Locks 111afdd2a1dSVijay 112d03f2ce1SSushil Singh # client_id lock_type release_lock_type 113d03f2ce1SSushil Singh HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction 114d03f2ce1SSushil Singh HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session 115afdd2a1dSVijay 116afdd2a1dSVijay 117d03f2ce1SSushil SinghInvalid Locks Fail To Release 118d03f2ce1SSushil Singh [Documentation] Release in-valid lock result in fail. 119d03f2ce1SSushil Singh [Tags] Invalid_Locks_Fail_To_Release 120d03f2ce1SSushil Singh [Template] Verify Invalid Locks Fail To Release 121afdd2a1dSVijay 122d03f2ce1SSushil Singh # client_id lock_type release_lock_type 123d03f2ce1SSushil Singh HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction 124d03f2ce1SSushil Singh 12345 ReadCase2,ReadCase2,ReadCase2 Transaction 125d03f2ce1SSushil Singh HMCID ReadCase3,ReadCase3,ReadCase3 Transaction 126afdd2a1dSVijay 127afdd2a1dSVijay 128d03f2ce1SSushil SinghFail To Release Lock For Another Session 129d03f2ce1SSushil Singh [Documentation] Failed to release locks from another session. 130d03f2ce1SSushil Singh [Tags] Fail_To_Release_Lock_For_Another_Session 131d03f2ce1SSushil Singh [Template] Verify Fail To Release Lock For Another Session 132afdd2a1dSVijay 133d03f2ce1SSushil Singh # client_id lock_type 134d03f2ce1SSushil Singh HMCID-01,HMCID-02 ReadCase1,ReadCase1 135afdd2a1dSVijay 136afdd2a1dSVijay 137e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking 138e33c6e6aSSushil Singh [Documentation] Failed to acquire lock for invalid resource id data type. 139e33c6e6aSSushil Singh [Tags] Test_Invalid_Resource_ID_Data_Type_Locking 140e33c6e6aSSushil Singh [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type 141e33c6e6aSSushil Singh 142e33c6e6aSSushil Singh # client_id lock_type 143e33c6e6aSSushil Singh HMCID-01 ReadCase1 144e33c6e6aSSushil Singh HMCID-01 ReadCase2 145e33c6e6aSSushil Singh HMCID-01 ReadCase3 146e33c6e6aSSushil Singh HMCID-01 WriteCase1 147e33c6e6aSSushil Singh HMCID-01 WriteCase2 148e33c6e6aSSushil Singh HMCID-01 WriteCase3 149e33c6e6aSSushil Singh 150e33c6e6aSSushil Singh 151d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type 152d03f2ce1SSushil Singh [Documentation] Failed to acquire read, write lock for invalid lock data passed. 153d03f2ce1SSushil Singh [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type 154d03f2ce1SSushil Singh [Template] Verify Fail To Acquire Lock For Invalid Lock Data 155afdd2a1dSVijay 156d03f2ce1SSushil Singh # client_id lock_type message 157d03f2ce1SSushil Singh HMCID-01 ReadCase1 ${BAD_REQUEST} 158d03f2ce1SSushil Singh HMCID-01 ReadCase2 ${BAD_REQUEST} 159d03f2ce1SSushil Singh HMCID-01 ReadCase3 ${BAD_REQUEST} 160d03f2ce1SSushil Singh HMCID-01 ReadCase4 ${BAD_REQUEST} 161d03f2ce1SSushil Singh HMCID-01 ReadCase5 ${BAD_REQUEST} 162d03f2ce1SSushil Singh HMCID-01 WriteCase1 ${BAD_REQUEST} 163d03f2ce1SSushil Singh HMCID-01 WriteCase2 ${BAD_REQUEST} 164d03f2ce1SSushil Singh HMCID-01 WriteCase3 ${BAD_REQUEST} 165d03f2ce1SSushil Singh HMCID-01 WriteCase4 ${BAD_REQUEST} 166d03f2ce1SSushil Singh HMCID-01 WriteCase5 ${BAD_REQUEST} 167afdd2a1dSVijay 168afdd2a1dSVijay 169d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag 170d03f2ce1SSushil Singh [Documentation] Failed to acquire read write lock for invalid lock flag passed. 171d03f2ce1SSushil Singh [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag 172d03f2ce1SSushil Singh [Template] Verify Fail To Acquire Lock For Invalid Lock Data 173afdd2a1dSVijay 174d03f2ce1SSushil Singh # client_id lock_type message 175d03f2ce1SSushil Singh HMCID-01 ReadCase6 ${BAD_REQUEST} 176d03f2ce1SSushil Singh HMCID-01 ReadCase7 ${BAD_REQUEST} 177d03f2ce1SSushil Singh HMCID-01 ReadCase8 ${BAD_REQUEST} 178d03f2ce1SSushil Singh HMCID-01 ReadCase9 ${BAD_REQUEST} 179d03f2ce1SSushil Singh HMCID-01 ReadCase10 ${BAD_REQUEST} 180d03f2ce1SSushil Singh HMCID-01 ReadCase11 ${BAD_REQUEST} 181d03f2ce1SSushil Singh HMCID-01 WriteCase6 ${BAD_REQUEST} 182d03f2ce1SSushil Singh HMCID-01 WriteCase7 ${BAD_REQUEST} 183d03f2ce1SSushil Singh HMCID-01 WriteCase8 ${BAD_REQUEST} 184d03f2ce1SSushil Singh HMCID-01 WriteCase9 ${BAD_REQUEST} 185d03f2ce1SSushil Singh HMCID-01 WriteCase10 ${BAD_REQUEST} 186d03f2ce1SSushil Singh HMCID-01 WriteCase11 ${BAD_REQUEST} 187afdd2a1dSVijay 188afdd2a1dSVijay 189d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag 190d03f2ce1SSushil Singh [Documentation] Failed to acquire read write lock for invalid segment flag passed. 191d03f2ce1SSushil Singh [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag 192d03f2ce1SSushil Singh [Template] Verify Fail To Acquire Lock For Invalid Lock Data 193d03f2ce1SSushil Singh 194d03f2ce1SSushil Singh # client_id lock_type message 195d03f2ce1SSushil Singh HMCID-01 ReadCase12 ${BAD_REQUEST} 196d03f2ce1SSushil Singh HMCID-01 ReadCase13 ${BAD_REQUEST} 197d03f2ce1SSushil Singh HMCID-01 ReadCase14 ${BAD_REQUEST} 198d03f2ce1SSushil Singh HMCID-01 WriteCase12 ${BAD_REQUEST} 199d03f2ce1SSushil Singh HMCID-01 WriteCase13 ${BAD_REQUEST} 200d03f2ce1SSushil Singh HMCID-01 WriteCase14 ${BAD_REQUEST} 201afdd2a1dSVijay 202bace3005SSushil Singh 203bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired 204bace3005SSushil Singh [Documentation] If session does not acquire locks then get lock should return 205bace3005SSushil Singh ... empty lock records. 206bace3005SSushil Singh [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired 207bace3005SSushil Singh [Template] Verify No Locks Records For Session With No Acquired Lock 208bace3005SSushil Singh 209bace3005SSushil Singh # client_id 210bace3005SSushil Singh HMCID-01 211bace3005SSushil Singh 212*728ef9c9SSushil Singh 213*728ef9c9SSushil SinghGet Lock Records For Multiple Session 214*728ef9c9SSushil Singh [Documentation] Get lock records of multiple session. 215*728ef9c9SSushil Singh [Tags] Get_Lock_Records_For_Multiple_Session 216*728ef9c9SSushil Singh [Template] Verify Lock Records Of Multiple Session 217*728ef9c9SSushil Singh 218*728ef9c9SSushil Singh # client_ids lock_type 219*728ef9c9SSushil Singh HMCID-01,HMCID-02 ReadCase1,ReadCase1 220*728ef9c9SSushil Singh 221*728ef9c9SSushil Singh 222bc331e22SVijay*** Keywords *** 223bc331e22SVijay 224d03f2ce1SSushil SinghCreate Redfish Session With ClientID 225d03f2ce1SSushil Singh [Documentation] Create redifish session with client id. 226d03f2ce1SSushil Singh [Arguments] ${client_id} 22785610eeeSVijay 22885610eeeSVijay # Description of argument(s): 229d03f2ce1SSushil Singh # client_id This client id can contain string value 230d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 23185610eeeSVijay 232d03f2ce1SSushil Singh ${session_info}= Create Dictionary 233d03f2ce1SSushil Singh ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}} 23485610eeeSVijay 235d03f2ce1SSushil Singh Set To Dictionary ${session_info} SessionIDs ${session['Id']} 236d03f2ce1SSushil Singh Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]} 23785610eeeSVijay 238d03f2ce1SSushil Singh [Return] ${session_info} 23985610eeeSVijay 24085610eeeSVijay 241d03f2ce1SSushil SinghRW General Dictionary 242d03f2ce1SSushil Singh [Documentation] Create dictionay of lock request. 243d03f2ce1SSushil Singh [Arguments] ${read_case} ${res_id} 244bc331e22SVijay 245bc331e22SVijay # Description of argument(s): 246d03f2ce1SSushil Singh # read_case Read or Write lock type. 247d03f2ce1SSushil Singh # res_id Resource id. 248bc331e22SVijay 249d03f2ce1SSushil Singh ${request_dict}= Create Dictionary 250566daaf3SGeorge Keishing 251d03f2ce1SSushil Singh FOR ${key} IN @{read_case.keys()} 252d03f2ce1SSushil Singh Set To Dictionary ${request_dict} LockType ${key} 253d03f2ce1SSushil Singh Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]} 254d03f2ce1SSushil Singh END 255bc331e22SVijay 256d03f2ce1SSushil Singh Set To Dictionary ${request_dict} ResourceID ${res_id} 257d03f2ce1SSushil Singh 258d03f2ce1SSushil Singh [Return] ${request_dict} 259bc331e22SVijay 260bc331e22SVijay 261d03f2ce1SSushil SinghReturn Description Of Response 262d03f2ce1SSushil Singh [Documentation] Return description of REST response. 263bc331e22SVijay [Arguments] ${resp_text} 264bc331e22SVijay 265bc331e22SVijay # Description of argument(s): 266d03f2ce1SSushil Singh # resp_text REST response body. 267bc331e22SVijay 268d03f2ce1SSushil Singh # resp_text after successful partition file upload looks like: 269d03f2ce1SSushil Singh # { 270d03f2ce1SSushil Singh # "Description": "File Created" 271d03f2ce1SSushil Singh # } 272bc331e22SVijay 273d03f2ce1SSushil Singh ${message}= Evaluate json.loads('''${resp_text}''') json 274d03f2ce1SSushil Singh 275d03f2ce1SSushil Singh [Return] ${message} 276bc331e22SVijay 277bc331e22SVijay 278d03f2ce1SSushil SinghRedfish Post Acquire Lock 279d03f2ce1SSushil Singh [Documentation] Acquire and release lock. 280d03f2ce1SSushil Singh [Arguments] ${lock_type} ${status_code}=${HTTP_OK} 281bc331e22SVijay 282bc331e22SVijay # Description of argument(s): 283d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 284d03f2ce1SSushil Singh # status_code HTTP status code. 285bc331e22SVijay 286e33c6e6aSSushil Singh ${lock_dict_param}= Form Data To Acquire Lock ${lock_type} 287e33c6e6aSSushil Singh ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 288d03f2ce1SSushil Singh Should Be Equal As Strings ${resp.status_code} ${status_code} 289d03f2ce1SSushil Singh ${resp}= Return Description Of Response ${resp.content} 290bc331e22SVijay 291d03f2ce1SSushil Singh [Return] ${resp} 292bc331e22SVijay 293bc331e22SVijay 294d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock 295d03f2ce1SSushil Singh [Documentation] Redfish to post request to acquire in-valid lock. 296d03f2ce1SSushil Singh [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK} 297bc331e22SVijay 298bc331e22SVijay # Description of argument(s): 299d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 300d03f2ce1SSushil Singh # message Return message from URI. 301d03f2ce1SSushil Singh # status_code HTTP status code. 302bc331e22SVijay 303e33c6e6aSSushil Singh ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type} 304e33c6e6aSSushil Singh ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 305d03f2ce1SSushil Singh Should Be Equal As Strings ${resp.status_code} ${status_code} 306d03f2ce1SSushil Singh Valid Value message ['${resp.content}'] 307d03f2ce1SSushil Singh 308d03f2ce1SSushil Singh [Return] ${resp} 309bc331e22SVijay 310bc331e22SVijay 311e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID 312e33c6e6aSSushil Singh [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id. 313e33c6e6aSSushil Singh [Arguments] ${lock_type} ${status_code}=${HTTP_OK} 314e33c6e6aSSushil Singh 315e33c6e6aSSushil Singh # Description of argument(s): 316e33c6e6aSSushil Singh # lock_type Read lock or Write lock. 317e33c6e6aSSushil Singh # status_code HTTP status code. 318e33c6e6aSSushil Singh 319e33c6e6aSSushil Singh ${lock_dict_param}= Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type} 320e33c6e6aSSushil Singh ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 321e33c6e6aSSushil Singh Should Be Equal As Strings ${resp.status_code} ${status_code} 322e33c6e6aSSushil Singh 323e33c6e6aSSushil Singh [Return] ${resp} 324e33c6e6aSSushil Singh 325e33c6e6aSSushil Singh 326d03f2ce1SSushil SinghForm Data To Acquire Lock 327d03f2ce1SSushil Singh [Documentation] Create a dictionay for lock request. 328d03f2ce1SSushil Singh [Arguments] ${lock_type} 329d03f2ce1SSushil Singh 330d03f2ce1SSushil Singh # Description of argument(s): 331d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 332d03f2ce1SSushil Singh 333d03f2ce1SSushil Singh ${lock_res_info}= Get Lock Resource Information 334d03f2ce1SSushil Singh ${resp}= RW General Dictionary 335d03f2ce1SSushil Singh ... ${lock_res_info["Valid Case"]["${lock_type}"]} 336d03f2ce1SSushil Singh ... ${lock_res_info["Valid Case"]["ResourceID"]} 337d03f2ce1SSushil Singh ${temp_list}= Create List ${resp} 338e33c6e6aSSushil Singh ${lock_request_dict}= Create Dictionary Request=${temp_list} 339d03f2ce1SSushil Singh 340e33c6e6aSSushil Singh [Return] ${lock_request_dict} 341e33c6e6aSSushil Singh 342e33c6e6aSSushil Singh 343e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID 344e33c6e6aSSushil Singh [Documentation] Create a dictionay for in-valid lock request. 345e33c6e6aSSushil Singh [Arguments] ${lock_type} 346e33c6e6aSSushil Singh 347e33c6e6aSSushil Singh # Description of argument(s): 348e33c6e6aSSushil Singh # lock_type Read lock or Write lock. 349e33c6e6aSSushil Singh 350e33c6e6aSSushil Singh ${lock_res_info}= Get Lock Resource Information 351e33c6e6aSSushil Singh ${resp}= RW General Dictionary 352e33c6e6aSSushil Singh ... ${lock_res_info["Valid Case"]["${lock_type}"]} 353e33c6e6aSSushil Singh ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]} 354e33c6e6aSSushil Singh ${temp_list}= Create List ${resp} 355e33c6e6aSSushil Singh ${lock_request_dict}= Create Dictionary Request=${temp_list} 356e33c6e6aSSushil Singh 357e33c6e6aSSushil Singh [Return] ${lock_request_dict} 358d03f2ce1SSushil Singh 359d03f2ce1SSushil Singh 360d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock 361d03f2ce1SSushil Singh [Documentation] Create a dictionay for in-valid lock request. 362d03f2ce1SSushil Singh [Arguments] ${lock_type} 363d03f2ce1SSushil Singh 364d03f2ce1SSushil Singh # Description of argument(s): 365d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 366d03f2ce1SSushil Singh 367d03f2ce1SSushil Singh ${lock_res_info}= Get Lock Resource Information 368d03f2ce1SSushil Singh ${resp}= RW General Dictionary 369d03f2ce1SSushil Singh ... ${lock_res_info["Invalid Case"]["${lock_type}"]} 370d03f2ce1SSushil Singh ... ${lock_res_info["Valid Case"]["ResourceID"]} 371d03f2ce1SSushil Singh ${temp_list}= Create List ${resp} 372e33c6e6aSSushil Singh ${lock_request_dict}= Create Dictionary Request=${temp_list} 373d03f2ce1SSushil Singh 374e33c6e6aSSushil Singh [Return] ${lock_request_dict} 375d03f2ce1SSushil Singh 376d03f2ce1SSushil Singh 377d03f2ce1SSushil SinghGet Locks List On Resource 378bc331e22SVijay [Documentation] Get locks list. 379d03f2ce1SSushil Singh [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK} 380bc331e22SVijay 381bc331e22SVijay # Description of argument(s): 382d03f2ce1SSushil Singh # session_info Session information in dict. 383d03f2ce1SSushil Singh # exp_status_code Expected HTTP status code. 384bc331e22SVijay 385d03f2ce1SSushil Singh ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]} 386566daaf3SGeorge Keishing ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList 387566daaf3SGeorge Keishing ... data=${data} 388bc331e22SVijay ${locks}= Evaluate json.loads('''${resp.text}''') json 389bc331e22SVijay 390bc331e22SVijay [Return] ${locks["Records"]} 391bc331e22SVijay 392bc331e22SVijay 393d03f2ce1SSushil SinghVerify Lock On Resource 394d03f2ce1SSushil Singh [Documentation] Verify lock on resource. 395d03f2ce1SSushil Singh [Arguments] ${session_info} ${transaction_id} 396bc331e22SVijay 397bc331e22SVijay # Description of argument(s): 398d03f2ce1SSushil Singh # session_info Session information in dict. 399d03f2ce1SSushil Singh # transaction_id Transaction id in list stored in dict. 400bc331e22SVijay 401d03f2ce1SSushil Singh ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']} 402d03f2ce1SSushil Singh Rprint Vars sessions 403d03f2ce1SSushil Singh ${lock_list}= Get Locks List On Resource ${session_info} 404d03f2ce1SSushil Singh ${lock_length}= Get Length ${lock_list} 405d03f2ce1SSushil Singh ${tran_id_length}= Get Length ${transaction_id} 406d03f2ce1SSushil Singh Should Be Equal As Integers ${tran_id_length} ${lock_length} 407afdd2a1dSVijay 408d03f2ce1SSushil Singh FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list} 409d03f2ce1SSushil Singh Valid Value session_info['ClientID'] ['${lock['HMCID']}'] 410d03f2ce1SSushil Singh Valid Value session_info['SessionIDs'] ['${lock['SessionID']}'] 411d03f2ce1SSushil Singh Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']} 412bc331e22SVijay END 413bc331e22SVijay 414bc331e22SVijay 415d03f2ce1SSushil SinghAcquire Lock On Resource 416d03f2ce1SSushil Singh [Documentation] Acquire lock on resource. 417d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False 418bc331e22SVijay 419bc331e22SVijay # Description of argument(s): 420d03f2ce1SSushil Singh # client_id This client id can contain string value 421d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 422d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 423d03f2ce1SSushil Singh # reboot_flag Flag is used to run reboot the BMC code. 424d03f2ce1SSushil Singh # (e.g. True or False). 425bc331e22SVijay 426d03f2ce1SSushil Singh ${trans_id_list}= Create List 427d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 428d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type} 429d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 430d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 431566daaf3SGeorge Keishing 432e33c6e6aSSushil Singh ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 433bc331e22SVijay 434d03f2ce1SSushil Singh Run Keyword If '${reboot_flag}' == 'True' 435d03f2ce1SSushil Singh ... Run Keywords Redfish OBMC Reboot (off) AND 436d03f2ce1SSushil Singh ... Redfish Login AND 437e33c6e6aSSushil Singh ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 438d03f2ce1SSushil Singh ... Verify Lock On Resource ${session_info} ${trans_id_list} AND 439d03f2ce1SSushil Singh ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 440bc331e22SVijay 441d03f2ce1SSushil Singh Run Keyword If '${reboot_flag}' == 'False' 442d03f2ce1SSushil Singh ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 443bc331e22SVijay 444d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 445d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 446d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 447bc331e22SVijay 448bc331e22SVijay 449d03f2ce1SSushil SinghForm Data To Release Lock 450d03f2ce1SSushil Singh [Documentation] Create a dictonay to release lock. 451d03f2ce1SSushil Singh [Arguments] ${trans_id_list} 452355daac7SVijay 453355daac7SVijay # Description of argument(s): 454d03f2ce1SSushil Singh # trans_id_list 455355daac7SVijay 456d03f2ce1SSushil Singh @{tran_ids}= Create List 457355daac7SVijay 458d03f2ce1SSushil Singh FOR ${item} IN @{trans_id_list} 459d03f2ce1SSushil Singh Append To List ${tran_ids} ${item['TransactionID']} 460d03f2ce1SSushil Singh END 461d03f2ce1SSushil Singh 462d03f2ce1SSushil Singh [Return] ${tran_ids} 463d03f2ce1SSushil Singh 464d03f2ce1SSushil Singh 465d03f2ce1SSushil SinghRelease Locks On Resource 466d03f2ce1SSushil Singh [Documentation] Redfish request to release a lock. 467d03f2ce1SSushil Singh [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK} 468d03f2ce1SSushil Singh 469d03f2ce1SSushil Singh # Description of argument(s): 470d03f2ce1SSushil Singh # session_info Session information in dict. 471d03f2ce1SSushil Singh # trans_id_list Transaction id list. 472d03f2ce1SSushil Singh # release_lock_type Release lock by Transaction, Session. 473d03f2ce1SSushil Singh # status_code HTTP status code. 474d03f2ce1SSushil Singh 475d03f2ce1SSushil Singh ${tran_ids}= Form Data To Release Lock ${trans_id_list} 476d03f2ce1SSushil Singh ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}} 477d03f2ce1SSushil Singh ${data}= Evaluate json.dumps(${data}) json 478d03f2ce1SSushil Singh ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data} 479d03f2ce1SSushil Singh Should Be Equal As Strings ${resp.status_code} ${status_code} 480d03f2ce1SSushil Singh 481d03f2ce1SSushil Singh 482d03f2ce1SSushil SinghAcquire Lock On Another Lock 483d03f2ce1SSushil Singh [Documentation] Acquire lock on another lock. 484d03f2ce1SSushil Singh [Arguments] ${client_id} 485d03f2ce1SSushil Singh 486d03f2ce1SSushil Singh # Description of argument(s): 487d03f2ce1SSushil Singh # client_id This client id can contain string value 488d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 489d03f2ce1SSushil Singh 490d03f2ce1SSushil Singh ${trans_id_list}= Create List 491d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 492d03f2ce1SSushil Singh 493d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ReadCase1 494d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 495d03f2ce1SSushil Singh 496d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ReadCase1 497d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 498d03f2ce1SSushil Singh 499d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 500d03f2ce1SSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} 501d03f2ce1SSushil Singh 502d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 503d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 504d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 505d03f2ce1SSushil Singh 506d03f2ce1SSushil Singh 507d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session 508d03f2ce1SSushil Singh [Documentation] Verify no lock record found for invalid session. 509d03f2ce1SSushil Singh [Arguments] ${client_id} 510d03f2ce1SSushil Singh 511d03f2ce1SSushil Singh # Description of argument(s): 512d03f2ce1SSushil Singh # client_id This client id can contain string value 513d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 514d03f2ce1SSushil Singh 515d03f2ce1SSushil Singh ${session_info1}= Create Redfish Session With ClientID ${client_id} 516d03f2ce1SSushil Singh 517d03f2ce1SSushil Singh ${lock_list1}= Get Locks List On Resource ${session_info1} 518d03f2ce1SSushil Singh ${lock_length1}= Get Length ${lock_list1} 519d03f2ce1SSushil Singh 520d03f2ce1SSushil Singh ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True 521d03f2ce1SSushil Singh set to dictionary ${session_info2} SessionIDs xxyXyyYZZz 522d03f2ce1SSushil Singh 523d03f2ce1SSushil Singh ${lock_list2}= Get Locks List On Resource ${session_info2} 524d03f2ce1SSushil Singh ${lock_length2}= Get Length ${lock_list1} 525d03f2ce1SSushil Singh 526d03f2ce1SSushil Singh Valid Value lock_length1 ${lock_list2} 527d03f2ce1SSushil Singh 528d03f2ce1SSushil Singh Redfish Delete Session ${session_info1} 529d03f2ce1SSushil Singh 530d03f2ce1SSushil Singh 531d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock 532d03f2ce1SSushil Singh [Documentation] Verify acquire lock on another lock fails. 533d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} 534d03f2ce1SSushil Singh 535d03f2ce1SSushil Singh # Description of argument(s): 536d03f2ce1SSushil Singh # client_id This client id can contain string value 537d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 538d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 539d03f2ce1SSushil Singh 540d03f2ce1SSushil Singh @{lock_type_list}= Split String ${lock_type} , 541d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 542d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 543d03f2ce1SSushil Singh 544d03f2ce1SSushil Singh ${trans_id_list}= Create List 545d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 546d03f2ce1SSushil Singh 547d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 548d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT} 549d03f2ce1SSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} 550d03f2ce1SSushil Singh 551d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 552d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 553d03f2ce1SSushil Singh 554d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 555d03f2ce1SSushil Singh 556d03f2ce1SSushil Singh 557e33c6e6aSSushil SinghVerify Acquire Lock After Reboot 558e33c6e6aSSushil Singh [Documentation] Acquire read and write lock after the reboot and release lock. 559e33c6e6aSSushil Singh [Arguments] ${client_id} ${lock_type} 560e33c6e6aSSushil Singh 561e33c6e6aSSushil Singh # Description of argument(s): 562e33c6e6aSSushil Singh # client_id This client id can contain string value 563e33c6e6aSSushil Singh # (e.g. 12345, "HMCID"). 564e33c6e6aSSushil Singh # lock_type Read lock or Write lock. 565e33c6e6aSSushil Singh 566e33c6e6aSSushil Singh ${trans_id_list}= Create List 567e33c6e6aSSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 568e33c6e6aSSushil Singh ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 569e33c6e6aSSushil Singh Redfish OBMC Reboot (off) 570e33c6e6aSSushil Singh Redfish Login 571e33c6e6aSSushil Singh Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} 572e33c6e6aSSushil Singh 573e33c6e6aSSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type} 574e33c6e6aSSushil Singh Append To List ${trans_id_list} ${trans_id} 575e33c6e6aSSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 576e33c6e6aSSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 577e33c6e6aSSushil Singh 578e33c6e6aSSushil Singh ${trans_id_emptylist}= Create List 579e33c6e6aSSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 580e33c6e6aSSushil Singh Redfish Delete Session ${session_info} 581e33c6e6aSSushil Singh 582e33c6e6aSSushil Singh 583d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop 584d03f2ce1SSushil Singh [Documentation] Acquire lock in loop. 585d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} 586d03f2ce1SSushil Singh 587d03f2ce1SSushil Singh # Description of argument(s): 588d03f2ce1SSushil Singh # client_id This client id can contain string value 589d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 590d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 591d03f2ce1SSushil Singh 592d03f2ce1SSushil Singh FOR ${count} IN RANGE 1 11 593d03f2ce1SSushil Singh ${trans_id_list}= Create List 594d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 595d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type} 596d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 597d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 598d03f2ce1SSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 599d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 600d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 601d03f2ce1SSushil Singh END 602d03f2ce1SSushil Singh 603d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 604d03f2ce1SSushil Singh 605d03f2ce1SSushil Singh 606d03f2ce1SSushil SinghAcquire And Release Multiple Locks 607d03f2ce1SSushil Singh [Documentation] Acquire mutilple locks on resource. 608d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} ${release_lock_type} 609d03f2ce1SSushil Singh 610d03f2ce1SSushil Singh # Description of argument(s): 611d03f2ce1SSushil Singh # client_id This client id can contain string value 612d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 613d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 614d03f2ce1SSushil Singh # release_lock_type The value can be Transaction or Session. 615d03f2ce1SSushil Singh 616d03f2ce1SSushil Singh @{lock_type_list}= Split String ${lock_type} , 617d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 618d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 619d03f2ce1SSushil Singh 620d03f2ce1SSushil Singh ${trans_id_list}= Create List 621d03f2ce1SSushil Singh 622d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 623d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 624d03f2ce1SSushil Singh 625d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 626d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2] 627d03f2ce1SSushil Singh 628d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 629d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_list} 630d03f2ce1SSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type} 631d03f2ce1SSushil Singh 632d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 633d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 634d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 635d03f2ce1SSushil Singh 636d03f2ce1SSushil Singh 637d03f2ce1SSushil SinghVerify Invalid Locks Fail To Release 638d03f2ce1SSushil Singh [Documentation] Verify invalid locks fails to be released. 639d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} ${release_lock_type} 640d03f2ce1SSushil Singh 641d03f2ce1SSushil Singh # Description of argument(s): 642d03f2ce1SSushil Singh # client_id This client id can contain string value 643d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 644d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 645d03f2ce1SSushil Singh # release_lock_type The value can be Transaction or Session. 646d03f2ce1SSushil Singh 647d03f2ce1SSushil Singh ${trans_id_list}= Create List 648d03f2ce1SSushil Singh @{lock_type_list}= Split String ${lock_type} , 649d03f2ce1SSushil Singh 650d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 651d03f2ce1SSushil Singh 652d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 653d03f2ce1SSushil Singh ${value}= Get From Dictionary ${trans_id} TransactionID 654d03f2ce1SSushil Singh ${value}= Evaluate ${value} + 10 655d03f2ce1SSushil Singh Set To Dictionary ${trans_id} TransactionID ${value} 656d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 657d03f2ce1SSushil Singh 658d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 659d03f2ce1SSushil Singh ${value}= Get From Dictionary ${trans_id} TransactionID 660d03f2ce1SSushil Singh ${value}= Evaluate ${value} + 10 661d03f2ce1SSushil Singh Set To Dictionary ${trans_id} TransactionID ${value} 662d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 663d03f2ce1SSushil Singh 664d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2] 665d03f2ce1SSushil Singh ${value}= Get From Dictionary ${trans_id} TransactionID 666d03f2ce1SSushil Singh ${value}= Evaluate ${value} + 10 667d03f2ce1SSushil Singh Set To Dictionary ${trans_id} TransactionID ${value} 668d03f2ce1SSushil Singh Append To List ${trans_id_list} ${trans_id} 669d03f2ce1SSushil Singh 670d03f2ce1SSushil Singh Release Locks On Resource 671d03f2ce1SSushil Singh ... ${session_info} ${trans_id_list} 672d03f2ce1SSushil Singh ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST} 673d03f2ce1SSushil Singh Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session 674d03f2ce1SSushil Singh 675d03f2ce1SSushil Singh ${trans_id_emptylist}= Create List 676d03f2ce1SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 677d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 678d03f2ce1SSushil Singh 679d03f2ce1SSushil Singh 680d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session 681d03f2ce1SSushil Singh [Documentation] Verify failed to release the lock form another session. 682d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} 683d03f2ce1SSushil Singh 684d03f2ce1SSushil Singh # Description of argument(s): 685d03f2ce1SSushil Singh # client_id This client id can contain string value 686d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 687d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 688d03f2ce1SSushil Singh 689d03f2ce1SSushil Singh ${client_ids}= Split String ${client_id} , 690d03f2ce1SSushil Singh ${lock_type_list}= Split String ${lock_type} , 691d03f2ce1SSushil Singh ${trans_id_list1}= Create List 692d03f2ce1SSushil Singh ${trans_id_list2}= Create List 693d03f2ce1SSushil Singh 694d03f2ce1SSushil Singh ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0] 695d03f2ce1SSushil Singh 696d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 697d03f2ce1SSushil Singh Append To List ${trans_id_list1} ${trans_id} 698d03f2ce1SSushil Singh Verify Lock On Resource ${session_info1} ${trans_id_list1} 699d03f2ce1SSushil Singh 700d03f2ce1SSushil Singh ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1] 701d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 702d03f2ce1SSushil Singh Append To List ${trans_id_list2} ${trans_id} 703d03f2ce1SSushil Singh Verify Lock On Resource ${session_info2} ${trans_id_list2} 704d03f2ce1SSushil Singh 705d03f2ce1SSushil Singh Release Locks On Resource 706d03f2ce1SSushil Singh ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED} 707d03f2ce1SSushil Singh Verify Lock On Resource ${session_info1} ${trans_id_list1} 708d03f2ce1SSushil Singh Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session 709d03f2ce1SSushil Singh Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session 710d03f2ce1SSushil Singh Redfish Delete Session ${session_info1} 711d03f2ce1SSushil Singh Redfish Delete Session ${session_info2} 712d03f2ce1SSushil Singh 713d03f2ce1SSushil Singh 714e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type 715e33c6e6aSSushil Singh [Documentation] Verify fail to acquire the lock with invalid resource id data type. 716e33c6e6aSSushil Singh [Arguments] ${client_id} ${lock_type} 717e33c6e6aSSushil Singh 718e33c6e6aSSushil Singh # Description of argument(s): 719e33c6e6aSSushil Singh # client_id This client id can contain string value 720e33c6e6aSSushil Singh # (e.g. 12345, "HMCID"). 721e33c6e6aSSushil Singh # lock_type Read lock or Write lock. 722e33c6e6aSSushil Singh 723e33c6e6aSSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 724e33c6e6aSSushil Singh Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID 725e33c6e6aSSushil Singh ... ${lock_type} status_code=${HTTP_BAD_REQUEST} 726e33c6e6aSSushil Singh Redfish Delete Session ${session_info} 727e33c6e6aSSushil Singh 728e33c6e6aSSushil Singh 729d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data 730e33c6e6aSSushil Singh [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segement flags. 731d03f2ce1SSushil Singh [Arguments] ${client_id} ${lock_type} ${message} 732d03f2ce1SSushil Singh 733d03f2ce1SSushil Singh # Description of argument(s): 734d03f2ce1SSushil Singh # client_id This client id can contain string value 735d03f2ce1SSushil Singh # (e.g. 12345, "HMCID"). 736d03f2ce1SSushil Singh # lock_type Read lock or Write lock. 737d03f2ce1SSushil Singh # message Return message from URI. 738d03f2ce1SSushil Singh 739d03f2ce1SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 740d03f2ce1SSushil Singh ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST} 741d03f2ce1SSushil Singh Redfish Delete Session ${session_info} 742bace3005SSushil Singh 743bace3005SSushil Singh 744bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock 745bace3005SSushil Singh [Documentation] Verify no records found for a session where no lock is acquired. 746bace3005SSushil Singh [Arguments] ${client_id} 747bace3005SSushil Singh 748bace3005SSushil Singh # Description of argument(s): 749bace3005SSushil Singh # client_id This client id can contain string value 750bace3005SSushil Singh # (e.g. 12345, "HMCID"). 751bace3005SSushil Singh 752bace3005SSushil Singh ${session_info}= Create Redfish Session With ClientID ${client_id} 753bace3005SSushil Singh ${trans_id_emptylist}= Create List 754bace3005SSushil Singh Verify Lock On Resource ${session_info} ${trans_id_emptylist} 755bace3005SSushil Singh Redfish Delete Session ${session_info} 756*728ef9c9SSushil Singh 757*728ef9c9SSushil Singh 758*728ef9c9SSushil SinghCreate List Of Session ID 759*728ef9c9SSushil Singh [Documentation] Create session id list from session dict info. 760*728ef9c9SSushil Singh [Arguments] ${session_dict_info} 761*728ef9c9SSushil Singh 762*728ef9c9SSushil Singh # Description of argument(s): 763*728ef9c9SSushil Singh # session_dict_info Session information in dict. 764*728ef9c9SSushil Singh 765*728ef9c9SSushil Singh @{session_id_list}= Create List 766*728ef9c9SSushil Singh 767*728ef9c9SSushil Singh FOR ${session} IN @{session_dict_info} 768*728ef9c9SSushil Singh Append To List ${session_id_list} ${session["SessionIDs"]} 769*728ef9c9SSushil Singh END 770*728ef9c9SSushil Singh 771*728ef9c9SSushil Singh ${num_id}= Get Length ${session_id_list} 772*728ef9c9SSushil Singh Should Not Be Equal As Integers ${num_id} ${0} 773*728ef9c9SSushil Singh 774*728ef9c9SSushil Singh ${session_id_list}= Evaluate json.dumps(${session_id_list}) json 775*728ef9c9SSushil Singh 776*728ef9c9SSushil Singh [Return] ${session_id_list} 777*728ef9c9SSushil Singh 778*728ef9c9SSushil Singh 779*728ef9c9SSushil SinghGet Locks List On Resource With Session List 780*728ef9c9SSushil Singh [Documentation] Get locks list from session of list. 781*728ef9c9SSushil Singh [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK} 782*728ef9c9SSushil Singh 783*728ef9c9SSushil Singh # Description of argument(s): 784*728ef9c9SSushil Singh # session_id_list Session ids list. 785*728ef9c9SSushil Singh # exp_status_code Expected HTTP status code. 786*728ef9c9SSushil Singh 787*728ef9c9SSushil Singh ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList 788*728ef9c9SSushil Singh ... data={"SessionIDs": ${session_id_list}} 789*728ef9c9SSushil Singh ${locks}= Evaluate json.loads('''${resp.text}''') json 790*728ef9c9SSushil Singh 791*728ef9c9SSushil Singh [Return] ${locks} 792*728ef9c9SSushil Singh 793*728ef9c9SSushil Singh 794*728ef9c9SSushil SinghVerify List Of Session Lock On Resource 795*728ef9c9SSushil Singh [Documentation] Verify list of lock record from list of sessions. 796*728ef9c9SSushil Singh [Arguments] ${session_dict_info} ${transaction_id_list} 797*728ef9c9SSushil Singh 798*728ef9c9SSushil Singh # Description of argument(s): 799*728ef9c9SSushil Singh # session_dict_info Session information in dict. 800*728ef9c9SSushil Singh # transaction_id_list Transaction id in list stored in dict. 801*728ef9c9SSushil Singh 802*728ef9c9SSushil Singh ${session_id_list}= Create List Of Session ID ${session_dict_info} 803*728ef9c9SSushil Singh ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list} 804*728ef9c9SSushil Singh ${lock_list}= Set Variable ${lock_list_resp['Records']} 805*728ef9c9SSushil Singh 806*728ef9c9SSushil Singh FOR ${session_id} ${tran_id} ${lock_record} IN ZIP ${session_dict_info} ${transaction_id_list} ${lock_list} 807*728ef9c9SSushil Singh Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}'] 808*728ef9c9SSushil Singh Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']} 809*728ef9c9SSushil Singh END 810*728ef9c9SSushil Singh 811*728ef9c9SSushil Singh 812*728ef9c9SSushil SinghVerify Lock Records Of Multiple Session 813*728ef9c9SSushil Singh [Documentation] Verify all records found for a multiple sessions. 814*728ef9c9SSushil Singh [Arguments] ${client_ids} ${lock_type} 815*728ef9c9SSushil Singh 816*728ef9c9SSushil Singh # Description of argument(s): 817*728ef9c9SSushil Singh # client_ids This client id can contain string value 818*728ef9c9SSushil Singh # (e.g. 12345, "HMCID"). 819*728ef9c9SSushil Singh # lock_type Read lock or Write lock. 820*728ef9c9SSushil Singh 821*728ef9c9SSushil Singh ${client_id_list}= Split String ${client_ids} , 822*728ef9c9SSushil Singh ${lock_type_list}= Split String ${lock_type} , 823*728ef9c9SSushil Singh ${trans_id_list1}= Create List 824*728ef9c9SSushil Singh ${trans_id_list2}= Create List 825*728ef9c9SSushil Singh 826*728ef9c9SSushil Singh ${session_dict_list}= Create List 827*728ef9c9SSushil Singh ${lock_list}= Create List 828*728ef9c9SSushil Singh 829*728ef9c9SSushil Singh ${client_id1}= Create List 830*728ef9c9SSushil Singh Append To List ${client_id1} ${client_id_list}[0] 831*728ef9c9SSushil Singh ${session_info1}= Create Session With List Of ClientID ${client_id1} 832*728ef9c9SSushil Singh Append To List ${session_dict_list} ${session_info1}[0] 833*728ef9c9SSushil Singh Verify A Session Created With ClientID ${client_id1} ${session_info1} 834*728ef9c9SSushil Singh 835*728ef9c9SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 836*728ef9c9SSushil Singh Append To List ${trans_id_list1} ${trans_id} 837*728ef9c9SSushil Singh Append To List ${lock_list} ${trans_id} 838*728ef9c9SSushil Singh Verify Lock On Resource ${session_info1}[0] ${trans_id_list1} 839*728ef9c9SSushil Singh 840*728ef9c9SSushil Singh 841*728ef9c9SSushil Singh ${client_id2}= Create List 842*728ef9c9SSushil Singh Append To List ${client_id2} ${client_id_list}[1] 843*728ef9c9SSushil Singh ${session_info2}= Create Session With List Of ClientID ${client_id2} 844*728ef9c9SSushil Singh Append To List ${session_dict_list} ${session_info2}[0] 845*728ef9c9SSushil Singh Verify A Session Created With ClientID ${client_id2} ${session_info2} 846*728ef9c9SSushil Singh 847*728ef9c9SSushil Singh ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 848*728ef9c9SSushil Singh Append To List ${trans_id_list2} ${trans_id} 849*728ef9c9SSushil Singh Append To List ${lock_list} ${trans_id} 850*728ef9c9SSushil Singh Verify Lock On Resource ${session_info2}[0] ${trans_id_list2} 851*728ef9c9SSushil Singh 852*728ef9c9SSushil Singh Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list} 853*728ef9c9SSushil Singh 854*728ef9c9SSushil Singh ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken 855*728ef9c9SSushil Singh Set Global Variable ${XAUTH_TOKEN} ${session_token} 856*728ef9c9SSushil Singh 857*728ef9c9SSushil Singh Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction 858*728ef9c9SSushil Singh 859*728ef9c9SSushil Singh ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken 860*728ef9c9SSushil Singh Set Global Variable ${XAUTH_TOKEN} ${session_token} 861*728ef9c9SSushil Singh 862*728ef9c9SSushil Singh Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction 863*728ef9c9SSushil Singh 864*728ef9c9SSushil Singh ${trans_id_emptylist}= Create List 865*728ef9c9SSushil Singh Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist} 866*728ef9c9SSushil Singh Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist} 867*728ef9c9SSushil Singh 868*728ef9c9SSushil Singh Redfish Delete List Of Session ${session_dict_list} 869