xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision f4de7d770b7cc3e6fbeeea2e2e870770b5fc99a0)
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
9977f8f58SSushil SinghResource                ../../lib/rest_response_code.robot
10728ef9c9SSushil SinghLibrary                 ../../lib/bmc_network_utils.py
11fbd67007SGeorge KeishingLibrary                 JSONLibrary
12bc331e22SVijay
1376806df6SSushil SinghSuite Setup              Run Keyword And Ignore Error  Delete All Redfish Sessions
1476806df6SSushil SinghSuite Teardown           Run Keyword And Ignore Error  Delete All Redfish Sessions
1576806df6SSushil SinghTest Setup               Printn
1676806df6SSushil SinghTest Teardown            FFDC On Test Case Fail
17bc331e22SVijay
18bc331e22SVijay*** Variables ***
19bc331e22SVijay
20e3f2e3baSSushil Singh${CONFLICT_RQUEST}       Conflict
21d03f2ce1SSushil Singh${BAD_REQUEST}           Bad Request
228d420bf6SSushil Singh&{default_trans_id}      TransactionID=${1}
23bc331e22SVijay
24bc331e22SVijay*** Test Cases ***
25bc331e22SVijay
26d03f2ce1SSushil SinghAcquire Read Write Lock
27bc331e22SVijay    [Documentation]  Acquire and release different read locks.
28d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
29d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
30bc331e22SVijay
31d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
32d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
33d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
34d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
35d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
36d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
37d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
38bc331e22SVijay
39bc331e22SVijay
40d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
41d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
42d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
43d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
44bc331e22SVijay
45d03f2ce1SSushil Singh    # client_id
46d03f2ce1SSushil Singh    HMCID-01
47bc331e22SVijay
48bc331e22SVijay
49d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
50d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
51d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
52d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
5385610eeeSVijay
54d03f2ce1SSushil Singh    # client_id    lock_type
555d05994bSSushil Singh    HMCID-01       ReadCase7,WriteCase6
565d05994bSSushil Singh    HMCID-01       WriteCase6,WriteCase6
575d05994bSSushil Singh    HMCID-01       WriteCase6,ReadCase7
58566daaf3SGeorge Keishing
59566daaf3SGeorge Keishing
60e33c6e6aSSushil SinghAcquire Lock After Reboot
61e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
62e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
63e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
64e33c6e6aSSushil Singh
65e33c6e6aSSushil Singh    # client_id    lock_type
66e33c6e6aSSushil Singh    HMCID-01       ReadCase1
67e33c6e6aSSushil Singh    HMCID-01       ReadCase2
68e33c6e6aSSushil Singh    HMCID-01       ReadCase3
69e33c6e6aSSushil Singh    HMCID-01       WriteCase1
70e33c6e6aSSushil Singh    HMCID-01       WriteCase2
71e33c6e6aSSushil Singh    HMCID-01       WriteCase3
72e33c6e6aSSushil Singh
73e33c6e6aSSushil Singh
74d03f2ce1SSushil SinghAcquire And Release Lock In Loop
75d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
76d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
77d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
78566daaf3SGeorge Keishing
79d03f2ce1SSushil Singh    # client_id    lock_type
80d03f2ce1SSushil Singh    HMCID-01       ReadCase1
81d03f2ce1SSushil Singh    HMCID-01       ReadCase2
82d03f2ce1SSushil Singh    HMCID-01       ReadCase3
83d03f2ce1SSushil Singh    HMCID-01       WriteCase1
84d03f2ce1SSushil Singh    HMCID-01       WriteCase2
85d03f2ce1SSushil Singh    HMCID-01       WriteCase3
8685610eeeSVijay
8785610eeeSVijay
88977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
89977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
90977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
91977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
92977f8f58SSushil Singh
93e3f2e3baSSushil Singh    # client_id    lock_type               status_code
94e3f2e3baSSushil Singh    HMCID-01       ReadCase1,WriteCase1    ${HTTP_CONFLICT}
95e3f2e3baSSushil Singh    HMCID-01       WriteCase1,ReadCase1    ${HTTP_CONFLICT}
96e3f2e3baSSushil Singh    HMCID-01       WriteCase1,WriteCase1   ${HTTP_CONFLICT}
97e3f2e3baSSushil Singh
98e3f2e3baSSushil Singh
99e3f2e3baSSushil SinghAcquire Read In Single Request
100e3f2e3baSSushil Singh    [Documentation]  Acquire read in single request.
101e3f2e3baSSushil Singh    [Tags]  Acquire_Read_In_Single_Request
102e3f2e3baSSushil Singh    [Template]  Verify Acquire Read In Single Request
103e3f2e3baSSushil Singh
104977f8f58SSushil Singh    # client_id    lock_type
105e3f2e3baSSushil Singh    HMCID-01       ReadCase1,ReadCase1
106977f8f58SSushil Singh
107977f8f58SSushil Singh
108df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
109df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
110df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
111df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
112df390b61SSushil Singh
113df390b61SSushil Singh    # client_id    lock_type
114df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
115df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
116df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
117df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
118df390b61SSushil Singh
119df390b61SSushil Singh
120d03f2ce1SSushil SinghVerify Release Of Valid Locks
121d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
122d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
123d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
124afdd2a1dSVijay
125d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
126d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
127d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
128afdd2a1dSVijay
129afdd2a1dSVijay
13094116c61Ssusilsi7Release Lock When Session Deleted
13194116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
13294116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
13394116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
13494116c61Ssusilsi7
13594116c61Ssusilsi7    # client_id    lock_type
13694116c61Ssusilsi7    HMCID-01       ReadCase1
13794116c61Ssusilsi7    HMCID-01       WriteCase1
13894116c61Ssusilsi7
13994116c61Ssusilsi7
14059011d08SSushil SinghFail To Release Lock With Invalid TransactionID
14159011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
14259011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
14359011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
14459011d08SSushil Singh
14559011d08SSushil Singh    # client_id    lock_type     release_lock_type
14659011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
14743b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
14859011d08SSushil Singh
14959011d08SSushil Singh
1501b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
151d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1521b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1531b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
154afdd2a1dSVijay
155d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
156d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
157d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
158d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
159afdd2a1dSVijay
160afdd2a1dSVijay
1618bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1629614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1638bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1648bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1658bee358fSSushil Singh
1668bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1678bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1688bee358fSSushil Singh
1698bee358fSSushil Singh
1701d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1711d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1721d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1731d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1741d7b996cSsusilsi7
1751d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
1761d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
1771d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
1781d7b996cSsusilsi7
1791d7b996cSsusilsi7
180d03f2ce1SSushil SinghFail To Release Lock For Another Session
181d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
182d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
183d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
184afdd2a1dSVijay
185d03f2ce1SSushil Singh    # client_id          lock_type
186d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
187afdd2a1dSVijay
188afdd2a1dSVijay
18976806df6SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
19076806df6SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
19176806df6SSushil Singh    ...  maintained.
19276806df6SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
19376806df6SSushil Singh    [Template]  Acquire Lock On Resource
19476806df6SSushil Singh
19576806df6SSushil Singh    # client_id    lock_type     reboot_flag
19676806df6SSushil Singh    HMCID-01       ReadCase1     True
19776806df6SSushil Singh    HMCID-01       ReadCase2     True
19876806df6SSushil Singh    HMCID-01       ReadCase3     True
19976806df6SSushil Singh    HMCID-01       WriteCase1    True
20076806df6SSushil Singh    HMCID-01       WriteCase2    True
20176806df6SSushil Singh    HMCID-01       WriteCase3    True
20276806df6SSushil Singh
20376806df6SSushil Singh
204e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
205e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
206e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
207e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
208e33c6e6aSSushil Singh
209e33c6e6aSSushil Singh    # client_id    lock_type
210e33c6e6aSSushil Singh    HMCID-01       ReadCase1
211e33c6e6aSSushil Singh    HMCID-01       ReadCase2
212e33c6e6aSSushil Singh    HMCID-01       ReadCase3
213e33c6e6aSSushil Singh    HMCID-01       WriteCase1
214e33c6e6aSSushil Singh    HMCID-01       WriteCase2
215e33c6e6aSSushil Singh    HMCID-01       WriteCase3
216e33c6e6aSSushil Singh
217e33c6e6aSSushil Singh
218d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
219d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
220d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
221d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
222afdd2a1dSVijay
223d03f2ce1SSushil Singh    # client_id    lock_type      message
224d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
225d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
226d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
227d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
228d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
229d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
230d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
231d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
232d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
233d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
234afdd2a1dSVijay
235afdd2a1dSVijay
236d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
237d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
238d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
239d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
240afdd2a1dSVijay
241d03f2ce1SSushil Singh    # client_id    lock_type       message
242d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
243d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
244d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
245d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
246d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
247d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
248d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
249d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
250d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
251d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
252d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
253d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
254afdd2a1dSVijay
255afdd2a1dSVijay
25676806df6SSushil SinghCheck After Reboot Transaction ID Set To Default
25776806df6SSushil Singh    [Documentation]  After reboot, the transaction id starts with default i.e. 1,
25876806df6SSushil Singh    ...  if any lock is acquired.
25976806df6SSushil Singh    [Tags]  Check_After_Reboot_Transaction_ID_Set_To_Default
26076806df6SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
26176806df6SSushil Singh
26276806df6SSushil Singh    # client_id    lock_type     reboot_flag
26376806df6SSushil Singh    HMCID-01       ReadCase1     True
26476806df6SSushil Singh    HMCID-01       WriteCase1    True
26576806df6SSushil Singh
26676806df6SSushil Singh
267d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
268d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
269d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
270d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
271d03f2ce1SSushil Singh
272d03f2ce1SSushil Singh    # client_id    lock_type       message
273d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
274d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
275d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
276d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
277d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
278d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
279afdd2a1dSVijay
280bace3005SSushil Singh
2813b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2823b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2833b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2843b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2853b3a7ecaSSushil Singh
2863b3a7ecaSSushil Singh    # client_id    lock_type       message
2873b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2883b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2893b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2903b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2913b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2923b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2933b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2943b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2953b3a7ecaSSushil Singh
2963b3a7ecaSSushil Singh
297bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
298bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
299bace3005SSushil Singh    ...              empty lock records.
300bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
301bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
302bace3005SSushil Singh
303bace3005SSushil Singh    # client_id
304bace3005SSushil Singh    HMCID-01
305bace3005SSushil Singh
306728ef9c9SSushil Singh
307f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
308f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
309f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
310f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
311f9a536caSSushil Singh
312f9a536caSSushil Singh    # client_id
313f9a536caSSushil Singh    HMCID-01
314f9a536caSSushil Singh
315f9a536caSSushil Singh
316728ef9c9SSushil SinghGet Lock Records For Multiple Session
317728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
318728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
319728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
320728ef9c9SSushil Singh
321728ef9c9SSushil Singh    # client_ids         lock_type
322728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
323728ef9c9SSushil Singh
324728ef9c9SSushil Singh
325f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
326f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
327f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
328f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
329f9a536caSSushil Singh
330f9a536caSSushil Singh    # client_id
331f9a536caSSushil Singh    HMCID-01
332f9a536caSSushil Singh
33311949a2cSSushil Singh
33411949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
33511949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
33611949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
33711949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
33811949a2cSSushil Singh
33911949a2cSSushil Singh    # client_id          lock_type
34011949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
34111949a2cSSushil Singh
342bc331e22SVijay*** Keywords ***
343bc331e22SVijay
344d03f2ce1SSushil SinghCreate Redfish Session With ClientID
345d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
346d03f2ce1SSushil Singh    [Arguments]  ${client_id}
34785610eeeSVijay
34885610eeeSVijay    # Description of argument(s):
349d03f2ce1SSushil Singh    # client_id    This client id can contain string value
350d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
35185610eeeSVijay
352d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
353*f4de7d77SSushil Singh
354*f4de7d77SSushil Singh    ${session}=  Redfish Login  kwargs="Context": "${client_id}"
35585610eeeSVijay
356d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
357*f4de7d77SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Context"]}
35885610eeeSVijay
359d03f2ce1SSushil Singh    [Return]  ${session_info}
36085610eeeSVijay
36185610eeeSVijay
362d03f2ce1SSushil SinghRW General Dictionary
36316b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
364d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
365bc331e22SVijay
366bc331e22SVijay    # Description of argument(s):
367d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
368d03f2ce1SSushil Singh    # res_id       Resource id.
369bc331e22SVijay
370d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
371566daaf3SGeorge Keishing
372d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
373d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
374d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
375d03f2ce1SSushil Singh    END
376bc331e22SVijay
377d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
378d03f2ce1SSushil Singh
379d03f2ce1SSushil Singh    [Return]  ${request_dict}
380bc331e22SVijay
381bc331e22SVijay
382d03f2ce1SSushil SinghReturn Description Of Response
383d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
384bc331e22SVijay    [Arguments]  ${resp_text}
385bc331e22SVijay
386bc331e22SVijay    # Description of argument(s):
387d03f2ce1SSushil Singh    # resp_text    REST response body.
388bc331e22SVijay
389d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
390d03f2ce1SSushil Singh    # {
391d03f2ce1SSushil Singh    #    "Description": "File Created"
392d03f2ce1SSushil Singh    # }
393bc331e22SVijay
394d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
395d03f2ce1SSushil Singh
396d03f2ce1SSushil Singh    [Return]  ${message}
397bc331e22SVijay
398bc331e22SVijay
399a7d71f02SSushil SinghVerify Redfish Session Deleted
400a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
401a7d71f02SSushil Singh    [Arguments]  ${session_info}
402a7d71f02SSushil Singh
403a7d71f02SSushil Singh    # Description of argument(s):
404a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
405a7d71f02SSushil Singh
406a7d71f02SSushil Singh    # ${session_info} = {
407a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
408a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
409a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
410a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
411a7d71f02SSushil Singh    # }
412a7d71f02SSushil Singh
413a7d71f02SSushil Singh    # SessionIDs   : Session IDs
414a7d71f02SSushil Singh    # ClientID     : Client ID
415a7d71f02SSushil Singh    # SessionToken : Session token
416a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
417a7d71f02SSushil Singh
418a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
419a7d71f02SSushil Singh
420a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
4218a3efe7cSSushil Singh      Should Not Be Equal As Strings
4228a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
423a7d71f02SSushil Singh    END
424a7d71f02SSushil Singh
425a7d71f02SSushil Singh
426a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
427a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
428a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
429a7d71f02SSushil Singh
430a7d71f02SSushil Singh    # Description of argument(s):
431a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
432a7d71f02SSushil Singh
433a7d71f02SSushil Singh    # ${session_info_list} = [{
434a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
435a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
436a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
437a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
438a7d71f02SSushil Singh    # }]
439a7d71f02SSushil Singh
440a7d71f02SSushil Singh    # SessionIDs   : Session IDs
441a7d71f02SSushil Singh    # ClientID     : Client ID
442a7d71f02SSushil Singh    # SessionToken : Session token
443a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
444a7d71f02SSushil Singh
445a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
446a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
447a7d71f02SSushil Singh    END
448a7d71f02SSushil Singh
449a7d71f02SSushil Singh
450d03f2ce1SSushil SinghRedfish Post Acquire Lock
451d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
452d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
453bc331e22SVijay
454bc331e22SVijay    # Description of argument(s):
455d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
456d03f2ce1SSushil Singh    # status_code    HTTP status code.
457bc331e22SVijay
458e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
459fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4608a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4618a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
462fbd67007SGeorge Keishing    ...  expected_status=any
463d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
464df390b61SSushil Singh
465df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
466df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
467df390b61SSushil Singh    ...  ELSE
468df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
469bc331e22SVijay
470d03f2ce1SSushil Singh    [Return]  ${resp}
471bc331e22SVijay
472bc331e22SVijay
473977f8f58SSushil SinghRedfish Post Acquire List Lock
474977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
475977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
476977f8f58SSushil Singh
477977f8f58SSushil Singh    # Description of argument(s):
478977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
479977f8f58SSushil Singh    # status_code    HTTP status code.
480977f8f58SSushil Singh
481977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
482fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4838a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4848a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
485fbd67007SGeorge Keishing    ...   expected_status=any
486977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
487977f8f58SSushil Singh
488e3f2e3baSSushil Singh    Run Keyword If  ${status_code} == ${HTTP_CONFLICT}
489e3f2e3baSSushil Singh    ...    Should Be Equal As Strings  ${CONFLICT_RQUEST}  ${resp.content}
490e3f2e3baSSushil Singh    ...  ELSE
491e3f2e3baSSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
492e3f2e3baSSushil Singh
493977f8f58SSushil Singh    [Return]  ${resp}
494977f8f58SSushil Singh
495977f8f58SSushil Singh
496d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
497d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
498d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
499bc331e22SVijay
500bc331e22SVijay    # Description of argument(s):
501d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
502d03f2ce1SSushil Singh    # message        Return message from URI.
503d03f2ce1SSushil Singh    # status_code    HTTP status code.
504bc331e22SVijay
505e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
506fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5078a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5088a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
509d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
5103b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
5113b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
512d03f2ce1SSushil Singh
513d03f2ce1SSushil Singh    [Return]  ${resp}
514bc331e22SVijay
515bc331e22SVijay
516e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
517e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
518e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
519e33c6e6aSSushil Singh
520e33c6e6aSSushil Singh    # Description of argument(s):
521e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
522e33c6e6aSSushil Singh    # status_code    HTTP status code.
523e33c6e6aSSushil Singh
5248a3efe7cSSushil Singh    ${lock_dict_param}=
5258a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
526fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5278a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5288a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
529e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
530e33c6e6aSSushil Singh
531e33c6e6aSSushil Singh    [Return]  ${resp}
532e33c6e6aSSushil Singh
533e33c6e6aSSushil Singh
534d03f2ce1SSushil SinghForm Data To Acquire Lock
53516b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
536d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
537d03f2ce1SSushil Singh
538d03f2ce1SSushil Singh    # Description of argument(s):
539d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
540d03f2ce1SSushil Singh
541d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
542d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
543d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
544d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
545d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
546e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
547d03f2ce1SSushil Singh
548e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
549e33c6e6aSSushil Singh
550e33c6e6aSSushil Singh
551977f8f58SSushil SinghCreate Data To Acquire List Of Lock
55216b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
553977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
554977f8f58SSushil Singh
555977f8f58SSushil Singh    # Description of argument(s):
556977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
557977f8f58SSushil Singh
558977f8f58SSushil Singh    ${temp_list}=  Create List
559977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
560977f8f58SSushil Singh
561977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
562977f8f58SSushil Singh      ${resp}=  RW General Dictionary
563977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
564977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
565977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
566977f8f58SSushil Singh    END
567977f8f58SSushil Singh
568977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
569977f8f58SSushil Singh
570977f8f58SSushil Singh    [Return]  ${lock_request_dict}
571977f8f58SSushil Singh
572977f8f58SSushil Singh
573e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
57416b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
575e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
576e33c6e6aSSushil Singh
577e33c6e6aSSushil Singh    # Description of argument(s):
578e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
579e33c6e6aSSushil Singh
580e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
581e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
582e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
583e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
584e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
585e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
586e33c6e6aSSushil Singh
587e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
588d03f2ce1SSushil Singh
589d03f2ce1SSushil Singh
590d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
59116b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
592d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
593d03f2ce1SSushil Singh
594d03f2ce1SSushil Singh    # Description of argument(s):
595d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
596d03f2ce1SSushil Singh
597d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
598d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
599d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
600d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
601d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
602e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
603d03f2ce1SSushil Singh
604e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
605d03f2ce1SSushil Singh
606d03f2ce1SSushil Singh
607d03f2ce1SSushil SinghGet Locks List On Resource
608bc331e22SVijay    [Documentation]  Get locks list.
609d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
610bc331e22SVijay
611bc331e22SVijay    # Description of argument(s):
612d03f2ce1SSushil Singh    # session_info       Session information in dict.
613d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
614bc331e22SVijay
615d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
616566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
617566daaf3SGeorge Keishing    ...  data=${data}
618bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
619bc331e22SVijay
620bc331e22SVijay    [Return]  ${locks["Records"]}
621bc331e22SVijay
622bc331e22SVijay
623d03f2ce1SSushil SinghVerify Lock On Resource
624d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
625d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
626bc331e22SVijay
627bc331e22SVijay    # Description of argument(s):
628d03f2ce1SSushil Singh    # session_info      Session information in dict.
629d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
630bc331e22SVijay
631d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
632d03f2ce1SSushil Singh    Rprint Vars  sessions
633d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
634d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
635d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
636d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
637afdd2a1dSVijay
638d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
639d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
640d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
641d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
642bc331e22SVijay    END
643bc331e22SVijay
644bc331e22SVijay
645d03f2ce1SSushil SinghAcquire Lock On Resource
646d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
647d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
648bc331e22SVijay
649bc331e22SVijay    # Description of argument(s):
650d03f2ce1SSushil Singh    # client_id    This client id can contain string value
651d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
652d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
653d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
654d03f2ce1SSushil Singh    #               (e.g. True or False).
655bc331e22SVijay
6568a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
657d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6588a3efe7cSSushil Singh
659d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
660d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
661d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6628a3efe7cSSushil Singh
663d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
664566daaf3SGeorge Keishing
665e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
666bc331e22SVijay
667d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6688a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
669e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
67007b25344SSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
6718a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6728a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
673bc331e22SVijay
674d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
675d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
676bc331e22SVijay
677d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
678d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
679d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
680bc331e22SVijay
681bc331e22SVijay
682d03f2ce1SSushil SinghForm Data To Release Lock
683d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
684d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
685355daac7SVijay
686355daac7SVijay    # Description of argument(s):
687d03f2ce1SSushil Singh    # trans_id_list
688355daac7SVijay
689d03f2ce1SSushil Singh    @{tran_ids}=  Create List
690355daac7SVijay
691d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
692d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
693d03f2ce1SSushil Singh    END
694d03f2ce1SSushil Singh
695d03f2ce1SSushil Singh    [Return]  ${tran_ids}
696d03f2ce1SSushil Singh
697d03f2ce1SSushil Singh
698d03f2ce1SSushil SinghRelease Locks On Resource
699d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
7008a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
7018a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
702d03f2ce1SSushil Singh
703d03f2ce1SSushil Singh    # Description of argument(s):
704d03f2ce1SSushil Singh    # session_info        Session information in dict.
705d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
706d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
707d03f2ce1SSushil Singh    # status_code         HTTP status code.
708d03f2ce1SSushil Singh
709d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
710d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
711d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
712d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
713d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
714d03f2ce1SSushil Singh
715d03f2ce1SSushil Singh
716df390b61SSushil SinghRelease locks And Delete Session
717df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
718df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
719df390b61SSushil Singh
720df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
721df390b61SSushil Singh
722df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
723df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
724df390b61SSushil Singh
725df390b61SSushil Singh    Redfish Delete Session  ${session_info}
726df390b61SSushil Singh
727df390b61SSushil Singh
728d03f2ce1SSushil SinghAcquire Lock On Another Lock
729d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
730d03f2ce1SSushil Singh    [Arguments]  ${client_id}
731d03f2ce1SSushil Singh
732d03f2ce1SSushil Singh    # Description of argument(s):
733d03f2ce1SSushil Singh    # client_id    This client id can contain string value
734d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
735d03f2ce1SSushil Singh
736d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
737d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
738d03f2ce1SSushil Singh
739d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
740d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
741d03f2ce1SSushil Singh
742d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
743d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
744d03f2ce1SSushil Singh
745d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
746d03f2ce1SSushil Singh
747df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
748d03f2ce1SSushil Singh
749d03f2ce1SSushil Singh
750977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
751977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
752e3f2e3baSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${status_code}
753e3f2e3baSSushil Singh
754e3f2e3baSSushil Singh    # Description of argument(s):
755e3f2e3baSSushil Singh    # client_id     This client id can contain string value
756e3f2e3baSSushil Singh    #               (e.g. 12345, "HMCID").
757e3f2e3baSSushil Singh    # lock_type     Read lock or Write lock.
758e3f2e3baSSushil Singh    # status_code   HTTP status code
759e3f2e3baSSushil Singh
760e3f2e3baSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
761e3f2e3baSSushil Singh
762e3f2e3baSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
763e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${status_code}
764e3f2e3baSSushil Singh    Redfish Delete Session  ${session_info}
765e3f2e3baSSushil Singh
766e3f2e3baSSushil Singh
767e3f2e3baSSushil SinghVerify Acquire Read In Single Request
768e3f2e3baSSushil Singh    [Documentation]  Verify acquire read in single request.
769977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
770977f8f58SSushil Singh
771977f8f58SSushil Singh    # Description of argument(s):
772977f8f58SSushil Singh    # client_id    This client id can contain string value
773977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
774977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
775977f8f58SSushil Singh
776e3f2e3baSSushil Singh    ${trans_id_list}=  Create List
777977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
778977f8f58SSushil Singh
779977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
780e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}
781e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
782e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
783e3f2e3baSSushil Singh
784e3f2e3baSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
785e3f2e3baSSushil Singh    Remove From List  ${trans_id_list}  1
786e3f2e3baSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
787e3f2e3baSSushil Singh
788977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
789977f8f58SSushil Singh
790977f8f58SSushil Singh
791d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
792d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
793d03f2ce1SSushil Singh    [Arguments]  ${client_id}
794d03f2ce1SSushil Singh
795d03f2ce1SSushil Singh    # Description of argument(s):
796d03f2ce1SSushil Singh    # client_id    This client id can contain string value
797d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
798d03f2ce1SSushil Singh
799d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
800d03f2ce1SSushil Singh
801d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
802d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
803d03f2ce1SSushil Singh
804d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
805d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
806d03f2ce1SSushil Singh
807d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
808f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
809d03f2ce1SSushil Singh
810f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
811d03f2ce1SSushil Singh
812d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
813d03f2ce1SSushil Singh
814d03f2ce1SSushil Singh
815d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
816d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
817d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
818d03f2ce1SSushil Singh
819d03f2ce1SSushil Singh    # Description of argument(s):
820d03f2ce1SSushil Singh    # client_id    This client id can contain string value
821d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
822d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
823d03f2ce1SSushil Singh
824d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
825d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
826d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
827d03f2ce1SSushil Singh
828d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
829d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
830d03f2ce1SSushil Singh
831d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
832d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
833d03f2ce1SSushil Singh
834df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
835d03f2ce1SSushil Singh
836d03f2ce1SSushil Singh
837e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
838e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
839e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
840e33c6e6aSSushil Singh
841e33c6e6aSSushil Singh    # Description of argument(s):
842e33c6e6aSSushil Singh    # client_id    This client id can contain string value
843e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
844e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
845e33c6e6aSSushil Singh
846e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
847f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
848ac229c79SSushil Singh
849e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
850ac229c79SSushil Singh    Redfish BMC Reset Operation
851e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
85207b25344SSushil Singh    Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled
853ac229c79SSushil Singh    Is BMC Standby
854e33c6e6aSSushil Singh
855e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
856e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
857e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
858e33c6e6aSSushil Singh
859df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
860df390b61SSushil Singh
861df390b61SSushil Singh
862df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
863df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
864df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
865df390b61SSushil Singh
866df390b61SSushil Singh    # Description of argument(s):
867df390b61SSushil Singh    # client_id    This client id can contain string value
868df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
869df390b61SSushil Singh    # lock_type    Read lock or Write lock.
870df390b61SSushil Singh
871df390b61SSushil Singh    ${trans_id_list}=  Create List
872df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
873df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
874df390b61SSushil Singh
875df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
876df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
877df390b61SSushil Singh
878df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
879df390b61SSushil Singh
880df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
881df390b61SSushil Singh
882df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
883e33c6e6aSSushil Singh
884e33c6e6aSSushil Singh
8858d420bf6SSushil SinghPost Reboot Acquire Lock
8868d420bf6SSushil Singh    [Documentation]  Post reboot acquire lock and verify the transaction id is 1.
8878d420bf6SSushil Singh    [Arguments]  ${session_info}  ${lock_type}
8888d420bf6SSushil Singh
8898d420bf6SSushil Singh    # Description of argument(s):
8908d420bf6SSushil Singh    # session_info     Session information.
8918d420bf6SSushil Singh    # lock_type        Read lock or Write lock.
8928d420bf6SSushil Singh
8938d420bf6SSushil Singh    ${trans_id_list}=  Create List
8948d420bf6SSushil Singh    ${trans_id_list_var}=  Create List
8958d420bf6SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
8968d420bf6SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
8978d420bf6SSushil Singh    Append To List  ${trans_id_list_var}  ${default_trans_id}
8988d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
8998d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list_var}
9008d420bf6SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
9018d420bf6SSushil Singh    ${trans_id_emptylist}=  Create List
9028d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9038d420bf6SSushil Singh
9048d420bf6SSushil Singh
905d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
906d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
9078d420bf6SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
908d03f2ce1SSushil Singh
909d03f2ce1SSushil Singh    # Description of argument(s):
910d03f2ce1SSushil Singh    # client_id    This client id can contain string value
911d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
912d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
9138d420bf6SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
9148d420bf6SSushil Singh    #               (e.g. True or False).
915d03f2ce1SSushil Singh
916d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
917d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
918d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
919d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
920d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
921d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
922d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
923d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
924d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9258d420bf6SSushil Singh      Redfish Delete Session  ${session_info}
926d03f2ce1SSushil Singh    END
927d03f2ce1SSushil Singh
9288d420bf6SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9298d420bf6SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
9308d420bf6SSushil Singh
9318d420bf6SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
9328d420bf6SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
9338d420bf6SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
93407b25344SSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
9358d420bf6SSushil Singh    ...  Is BMC Standby  AND
9368d420bf6SSushil Singh    ...  Post Reboot Acquire Lock  ${session_info}  ${lock_type}
937d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
938d03f2ce1SSushil Singh
939d03f2ce1SSushil Singh
940d03f2ce1SSushil SinghAcquire And Release Multiple Locks
941d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
942d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
943d03f2ce1SSushil Singh
944d03f2ce1SSushil Singh    # Description of argument(s):
945d03f2ce1SSushil Singh    # client_id          This client id can contain string value
946d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
947d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
948d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
949d03f2ce1SSushil Singh
950d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
951d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
952d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
953d03f2ce1SSushil Singh
954d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
955d03f2ce1SSushil Singh
956d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
957d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
958d03f2ce1SSushil Singh
959d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
960d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
961d03f2ce1SSushil Singh
962d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
963d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
964d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
965d03f2ce1SSushil Singh
966d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
967d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
968d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
969d03f2ce1SSushil Singh
970d03f2ce1SSushil Singh
97194116c61Ssusilsi7Verify Release Lock When Session Deleted
97294116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
97394116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
97494116c61Ssusilsi7
97594116c61Ssusilsi7    # Description of argument(s):
97694116c61Ssusilsi7    # client_ids    This client id can contain string value
97794116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
97894116c61Ssusilsi7    # lock_type     Read lock or Write lock.
97994116c61Ssusilsi7
98094116c61Ssusilsi7    ${trans_id_list}=  Create List
98194116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
98294116c61Ssusilsi7
98394116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
98494116c61Ssusilsi7
98594116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
98694116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
98794116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
98894116c61Ssusilsi7
98994116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
99094116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
99194116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
99294116c61Ssusilsi7
99394116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
99494116c61Ssusilsi7
99594116c61Ssusilsi7
99694116c61Ssusilsi7
99759011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
99816b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
99959011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
100059011d08SSushil Singh
100159011d08SSushil Singh    # Description of argument(s):
100259011d08SSushil Singh    # client_id          This client id can contain string value
100359011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
100459011d08SSushil Singh    # lock_type          Read lock or Write lock.
100559011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
100659011d08SSushil Singh
100759011d08SSushil Singh    ${trans_id_list}=  Create List
100859011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
100959011d08SSushil Singh
101059011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
101159011d08SSushil Singh
101259011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
101359011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
101459011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
101559011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
101659011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
101759011d08SSushil Singh
101859011d08SSushil Singh    Release Locks On Resource
101959011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
102059011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
102159011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
102259011d08SSushil Singh
102359011d08SSushil Singh    ${trans_id_emptylist}=  Create List
102459011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
102559011d08SSushil Singh    Redfish Delete Session  ${session_info}
102659011d08SSushil Singh
102759011d08SSushil Singh
10281b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
10291b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
1030d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
1031d03f2ce1SSushil Singh
1032d03f2ce1SSushil Singh    # Description of argument(s):
1033d03f2ce1SSushil Singh    # client_id          This client id can contain string value
1034d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
1035d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
1036d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
1037d03f2ce1SSushil Singh
1038d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
1039d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
1040d03f2ce1SSushil Singh
1041d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1042d03f2ce1SSushil Singh
1043d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1044d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1045d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1046d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1047d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1048d03f2ce1SSushil Singh
1049d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1050d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1051d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1052d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1053d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1054d03f2ce1SSushil Singh
1055d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
1056d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1057d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1058d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1059d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1060d03f2ce1SSushil Singh
1061d03f2ce1SSushil Singh    Release Locks On Resource
1062d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
1063d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
1064d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
1065d03f2ce1SSushil Singh
1066d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
1067d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1068d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1069d03f2ce1SSushil Singh
1070d03f2ce1SSushil Singh
10718bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
10729614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
10738bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10748bee358fSSushil Singh
10758bee358fSSushil Singh    # Description of argument(s):
10768bee358fSSushil Singh    # client_id          This client id can contain string value
10778bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
10788bee358fSSushil Singh    # lock_type          Read lock or Write lock.
10798bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
10808bee358fSSushil Singh
10818bee358fSSushil Singh    ${trans_id_list}=  Create List
10828bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
10838bee358fSSushil Singh
10848bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10858bee358fSSushil Singh
10868bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10878bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10888bee358fSSushil Singh
10898bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
10908bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
10918bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
10928bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
10938bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10948bee358fSSushil Singh
10958bee358fSSushil Singh    Release Locks On Resource
10968bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10978bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10988bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10998bee358fSSushil Singh
11008bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
11018bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11028bee358fSSushil Singh    Redfish Delete Session  ${session_info}
11038bee358fSSushil Singh
11048bee358fSSushil Singh
11051d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
11069614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
11071d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
11081d7b996cSsusilsi7
11091d7b996cSsusilsi7    # Description of argument(s):
11101d7b996cSsusilsi7    # client_id          This client id can contain string value
11111d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
11121d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
11131d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
11141d7b996cSsusilsi7
11151d7b996cSsusilsi7    ${trans_id_list}=  Create List
11161d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
11171d7b996cSsusilsi7
11181d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11191d7b996cSsusilsi7
11201d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
11211d7b996cSsusilsi7
11221d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
11231d7b996cSsusilsi7
1124*f4de7d77SSushil Singh    ${temp_trans_id_list}=  Copy List  ${trans_id_list}  deepcopy=True
11251d7b996cSsusilsi7
11261d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
11271d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
11281d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
11291d7b996cSsusilsi7
11301d7b996cSsusilsi7    Release Locks On Resource
11311d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
11321d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
11331d7b996cSsusilsi7
11341d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
11351d7b996cSsusilsi7
11361d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
11371d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11381d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
11391d7b996cSsusilsi7
11401d7b996cSsusilsi7
1141d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1142d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1143d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1144d03f2ce1SSushil Singh
1145d03f2ce1SSushil Singh    # Description of argument(s):
1146d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1147d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1148d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1149d03f2ce1SSushil Singh
1150d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1151d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1152d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1153d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1154d03f2ce1SSushil Singh
1155d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1156d03f2ce1SSushil Singh
1157d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1158d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1159d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1160d03f2ce1SSushil Singh
1161d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1162d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1163d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1164d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1165d03f2ce1SSushil Singh
1166d03f2ce1SSushil Singh    Release Locks On Resource
1167e3f2e3baSSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_BAD_REQUEST}
1168d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1169d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1170d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1171d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1172d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1173d03f2ce1SSushil Singh
1174d03f2ce1SSushil Singh
1175e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1176e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1177e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1178e33c6e6aSSushil Singh
1179e33c6e6aSSushil Singh    # Description of argument(s):
1180e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1181e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1182e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1183e33c6e6aSSushil Singh
1184e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1185e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1186e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1187e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1188e33c6e6aSSushil Singh
1189e33c6e6aSSushil Singh
1190d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
119116b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1192d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1193d03f2ce1SSushil Singh
1194d03f2ce1SSushil Singh    # Description of argument(s):
1195d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1196d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1197d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1198d03f2ce1SSushil Singh    # message      Return message from URI.
1199d03f2ce1SSushil Singh
1200d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
12018a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
12028a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1203d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1204bace3005SSushil Singh
1205bace3005SSushil Singh
1206bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1207bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1208bace3005SSushil Singh    [Arguments]  ${client_id}
1209bace3005SSushil Singh
1210bace3005SSushil Singh    # Description of argument(s):
1211bace3005SSushil Singh    # client_id    This client id can contain string value
1212bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1213bace3005SSushil Singh
1214bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1215bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1216bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1217bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1218728ef9c9SSushil Singh
1219728ef9c9SSushil Singh
1220728ef9c9SSushil SinghCreate List Of Session ID
1221728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1222728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1223728ef9c9SSushil Singh
1224728ef9c9SSushil Singh    # Description of argument(s):
1225728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1226728ef9c9SSushil Singh
1227728ef9c9SSushil Singh    @{session_id_list}=  Create List
1228728ef9c9SSushil Singh
1229728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1230728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1231728ef9c9SSushil Singh    END
1232728ef9c9SSushil Singh
1233728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1234728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1235728ef9c9SSushil Singh
1236728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1237728ef9c9SSushil Singh
1238728ef9c9SSushil Singh    [Return]  ${session_id_list}
1239728ef9c9SSushil Singh
1240728ef9c9SSushil Singh
1241728ef9c9SSushil SinghGet Locks List On Resource With Session List
1242728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1243728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1244728ef9c9SSushil Singh
1245728ef9c9SSushil Singh    # Description of argument(s):
1246728ef9c9SSushil Singh    # session_id_list    Session ids list.
1247728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1248728ef9c9SSushil Singh
1249728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1250fbd67007SGeorge Keishing    ...  data={"SessionIDs":${session_id_list}}  expected_status=any
125194116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1252728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1253728ef9c9SSushil Singh
1254728ef9c9SSushil Singh    [Return]  ${locks}
1255728ef9c9SSushil Singh
1256728ef9c9SSushil Singh
1257728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1258728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1259728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1260728ef9c9SSushil Singh
1261728ef9c9SSushil Singh    # Description of argument(s):
1262728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1263728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1264728ef9c9SSushil Singh
1265728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1266728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1267728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1268728ef9c9SSushil Singh
12698a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
12708a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1271728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1272728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1273728ef9c9SSushil Singh    END
1274728ef9c9SSushil Singh
1275728ef9c9SSushil Singh
1276728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1277728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1278728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1279728ef9c9SSushil Singh
1280728ef9c9SSushil Singh    # Description of argument(s):
1281728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1282728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1283728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1284728ef9c9SSushil Singh
1285728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1286728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1287728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1288728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1289728ef9c9SSushil Singh
1290728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1291728ef9c9SSushil Singh    ${lock_list}=  Create List
1292728ef9c9SSushil Singh
1293728ef9c9SSushil Singh    ${client_id1}=  Create List
1294728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1295728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1296728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1297728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1298728ef9c9SSushil Singh
1299728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1300728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1301728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1302728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1303728ef9c9SSushil Singh
1304728ef9c9SSushil Singh
1305728ef9c9SSushil Singh    ${client_id2}=  Create List
1306728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1307728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1308728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1309728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1310728ef9c9SSushil Singh
1311728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1312728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1313728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1314728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1315728ef9c9SSushil Singh
1316728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1317728ef9c9SSushil Singh
1318728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1319728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1320728ef9c9SSushil Singh
1321728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1322728ef9c9SSushil Singh
1323728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1324728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1325728ef9c9SSushil Singh
1326728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1327728ef9c9SSushil Singh
1328728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1329728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1330728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1331728ef9c9SSushil Singh
1332728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1333f9a536caSSushil Singh
1334f9a536caSSushil Singh
1335f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1336f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1337f9a536caSSushil Singh    [Arguments]  ${client_id}
1338f9a536caSSushil Singh
1339f9a536caSSushil Singh    # Description of argument(s):
1340f9a536caSSushil Singh    # client_id    This client id can contain string value
1341f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1342f9a536caSSushil Singh
1343f9a536caSSushil Singh    ${session_dict_list}=  Create List
1344f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1345f9a536caSSushil Singh
1346f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1347f9a536caSSushil Singh
1348f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1349f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1350f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1351f9a536caSSushil Singh
1352f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1353f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1354f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1355f9a536caSSushil Singh
1356f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1357f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1358f9a536caSSushil Singh
1359f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1360f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1361f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1362f9a536caSSushil Singh
1363f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1364f9a536caSSushil Singh
1365f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
136611949a2cSSushil Singh
136711949a2cSSushil Singh
136811949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
136911949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
137011949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
137111949a2cSSushil Singh
137211949a2cSSushil Singh    # Description of argument(s):
137311949a2cSSushil Singh    # client_ids    This client id can contain string value
137411949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
137511949a2cSSushil Singh    # lock_type     Read lock or Write lock.
137611949a2cSSushil Singh
137711949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
137811949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
137911949a2cSSushil Singh    ${trans_id_list1}=  Create List
138011949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
138111949a2cSSushil Singh
138211949a2cSSushil Singh    ${session_dict_list}=  Create List
138311949a2cSSushil Singh    ${lock_list}=  Create List
138411949a2cSSushil Singh
138511949a2cSSushil Singh    ${client_id1}=  Create List
138611949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
138711949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
138811949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
138911949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
139011949a2cSSushil Singh
139111949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
139211949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
139311949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
139411949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
139511949a2cSSushil Singh
1396*f4de7d77SSushil Singh    ${session_info2}=  Copy List  ${session_info1}  deepcopy=True
139711949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
139811949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
139911949a2cSSushil Singh
140011949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
140111949a2cSSushil Singh
140211949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
140311949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
140411949a2cSSushil Singh
140511949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
140611949a2cSSushil Singh
140711949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
140811949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
140911949a2cSSushil Singh
141011949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
14117e49fd5dSGeorge Keishing
14127e49fd5dSGeorge Keishing
14137e49fd5dSGeorge KeishingDelete All Redfish and HMC Sessions
14147e49fd5dSGeorge Keishing    [Documentation]  Delete all active redfish sessions.
14157e49fd5dSGeorge Keishing
14167e49fd5dSGeorge Keishing    ${saved_session_info}=  Get Redfish Session Info
14177e49fd5dSGeorge Keishing
14187e49fd5dSGeorge Keishing    ${resp_list}=  Redfish_Utils.Get Member List
14197e49fd5dSGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
14207e49fd5dSGeorge Keishing
14217e49fd5dSGeorge Keishing    # Remove the current login session from the list.
14227e49fd5dSGeorge Keishing    Remove Values From List  ${resp_list}  ${saved_session_info["location"]}
14237e49fd5dSGeorge Keishing
14247e49fd5dSGeorge Keishing    FOR  ${session}  IN  @{resp_list}
14257e49fd5dSGeorge Keishing        Run Keyword And Ignore Error  Redfish.Delete  ${session}
14267e49fd5dSGeorge Keishing    END
14277e49fd5dSGeorge Keishing
14287e49fd5dSGeorge Keishing
14297e49fd5dSGeorge KeishingRestart Bmcweb On Failure
14307e49fd5dSGeorge Keishing    [Documentation]  Restart bmcweb only if test failed.
14317e49fd5dSGeorge Keishing
14327e49fd5dSGeorge Keishing    Return From Keyword If  "${TEST_STATUS}" == "PASS"
14337e49fd5dSGeorge Keishing
14347e49fd5dSGeorge Keishing    # This procedure is needs to be corrected or removed, when we figure out
14357e49fd5dSGeorge Keishing    # what is causing the real failure here.
14367e49fd5dSGeorge Keishing
14377e49fd5dSGeorge Keishing    Log To Console  Likely ConnectionResetError: Restarting bmcweb
14387e49fd5dSGeorge Keishing
14397e49fd5dSGeorge Keishing    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command
14407e49fd5dSGeorge Keishing    ...  systemctl restart bmcweb  print_out=1
14417e49fd5dSGeorge Keishing
14427e49fd5dSGeorge Keishing    Should Be Empty  ${stderr}
14437e49fd5dSGeorge Keishing
14447e49fd5dSGeorge Keishing    Sleep  10s  reason=Wait for service to restart properly.
1445