xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision fbd67007d547af7913f49119e0e16825a696f9a1)
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
11*fbd67007SGeorge KeishingLibrary                 JSONLibrary
12bc331e22SVijay
1340ef0eb7SSushil SinghSuite Setup              Run Keyword And Ignore Error  Delete All Redfish Sessions
14df390b61SSushil SinghSuite Teardown           Run Keyword And Ignore Error  Delete All Redfish Sessions
15d03f2ce1SSushil SinghTest Setup               Printn
16d03f2ce1SSushil 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
40d8bf1424SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
41d8bf1424SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
42d8bf1424SSushil Singh    ...  maintained.
43d8bf1424SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
44d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
45bc331e22SVijay
46d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
47d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
48d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
49d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
50d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
51d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
52d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
53bc331e22SVijay
54bc331e22SVijay
558d420bf6SSushil SinghCheck After Reboot Transaction ID Set To Default
568d420bf6SSushil Singh    [Documentation]  After reboot, the transaction id starts with default i.e. 1,
577fd1ac06SGeorge Keishing    ...  if any lock is acquired.
588d420bf6SSushil Singh    [Tags]  Check_After_Reboot_Transaction_ID_Set_To_Default
598d420bf6SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
608d420bf6SSushil Singh
618d420bf6SSushil Singh    # client_id    lock_type     reboot_flag
628d420bf6SSushil Singh    HMCID-01       ReadCase1     True
638d420bf6SSushil Singh    HMCID-01       WriteCase1    True
648d420bf6SSushil Singh
658d420bf6SSushil Singh
66d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
67d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
68d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
69d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
70bc331e22SVijay
71d03f2ce1SSushil Singh    # client_id
72d03f2ce1SSushil Singh    HMCID-01
73bc331e22SVijay
74bc331e22SVijay
75d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
76d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
77d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
78d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
7985610eeeSVijay
80d03f2ce1SSushil Singh    # client_id    lock_type
815d05994bSSushil Singh    HMCID-01       ReadCase7,WriteCase6
825d05994bSSushil Singh    HMCID-01       WriteCase6,WriteCase6
835d05994bSSushil Singh    HMCID-01       WriteCase6,ReadCase7
84566daaf3SGeorge Keishing
85566daaf3SGeorge Keishing
86e33c6e6aSSushil SinghAcquire Lock After Reboot
87e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
88e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
89e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
90e33c6e6aSSushil Singh
91e33c6e6aSSushil Singh    # client_id    lock_type
92e33c6e6aSSushil Singh    HMCID-01       ReadCase1
93e33c6e6aSSushil Singh    HMCID-01       ReadCase2
94e33c6e6aSSushil Singh    HMCID-01       ReadCase3
95e33c6e6aSSushil Singh    HMCID-01       WriteCase1
96e33c6e6aSSushil Singh    HMCID-01       WriteCase2
97e33c6e6aSSushil Singh    HMCID-01       WriteCase3
98e33c6e6aSSushil Singh
99e33c6e6aSSushil Singh
100d03f2ce1SSushil SinghAcquire And Release Lock In Loop
101d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
102d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
103d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
104566daaf3SGeorge Keishing
105d03f2ce1SSushil Singh    # client_id    lock_type
106d03f2ce1SSushil Singh    HMCID-01       ReadCase1
107d03f2ce1SSushil Singh    HMCID-01       ReadCase2
108d03f2ce1SSushil Singh    HMCID-01       ReadCase3
109d03f2ce1SSushil Singh    HMCID-01       WriteCase1
110d03f2ce1SSushil Singh    HMCID-01       WriteCase2
111d03f2ce1SSushil Singh    HMCID-01       WriteCase3
11285610eeeSVijay
11385610eeeSVijay
114977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
115977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
116977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
117977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
118977f8f58SSushil Singh
119e3f2e3baSSushil Singh    # client_id    lock_type               status_code
120e3f2e3baSSushil Singh    HMCID-01       ReadCase1,WriteCase1    ${HTTP_CONFLICT}
121e3f2e3baSSushil Singh    HMCID-01       WriteCase1,ReadCase1    ${HTTP_CONFLICT}
122e3f2e3baSSushil Singh    HMCID-01       WriteCase1,WriteCase1   ${HTTP_CONFLICT}
123e3f2e3baSSushil Singh
124e3f2e3baSSushil Singh
125e3f2e3baSSushil SinghAcquire Read In Single Request
126e3f2e3baSSushil Singh    [Documentation]  Acquire read in single request.
127e3f2e3baSSushil Singh    [Tags]  Acquire_Read_In_Single_Request
128e3f2e3baSSushil Singh    [Template]  Verify Acquire Read In Single Request
129e3f2e3baSSushil Singh
130977f8f58SSushil Singh    # client_id    lock_type
131e3f2e3baSSushil Singh    HMCID-01       ReadCase1,ReadCase1
132977f8f58SSushil Singh
133977f8f58SSushil Singh
134df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
135df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
136df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
137df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
138df390b61SSushil Singh
139df390b61SSushil Singh    # client_id    lock_type
140df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
141df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
142df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
143df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
144df390b61SSushil Singh
145df390b61SSushil Singh
146d03f2ce1SSushil SinghVerify Release Of Valid Locks
147d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
148d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
149d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
150afdd2a1dSVijay
151d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
152d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
153d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
154afdd2a1dSVijay
155afdd2a1dSVijay
15694116c61Ssusilsi7Release Lock When Session Deleted
15794116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
15894116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
15994116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
16094116c61Ssusilsi7
16194116c61Ssusilsi7    # client_id    lock_type
16294116c61Ssusilsi7    HMCID-01       ReadCase1
16394116c61Ssusilsi7    HMCID-01       WriteCase1
16494116c61Ssusilsi7
16594116c61Ssusilsi7
16659011d08SSushil SinghFail To Release Lock With Invalid TransactionID
16759011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
16859011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
16959011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
17059011d08SSushil Singh
17159011d08SSushil Singh    # client_id    lock_type     release_lock_type
17259011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
17343b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
17459011d08SSushil Singh
17559011d08SSushil Singh
1761b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
177d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1781b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1791b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
180afdd2a1dSVijay
181d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
182d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
183d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
184d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
185afdd2a1dSVijay
186afdd2a1dSVijay
1878bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1889614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1898bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1908bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1918bee358fSSushil Singh
1928bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1938bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1948bee358fSSushil Singh
1958bee358fSSushil Singh
1961d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1971d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1981d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1991d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
2001d7b996cSsusilsi7
2011d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
2021d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
2031d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
2041d7b996cSsusilsi7
2051d7b996cSsusilsi7
206d03f2ce1SSushil SinghFail To Release Lock For Another Session
207d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
208d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
209d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
210afdd2a1dSVijay
211d03f2ce1SSushil Singh    # client_id          lock_type
212d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
213afdd2a1dSVijay
214afdd2a1dSVijay
215e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
216e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
217e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
218e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
219e33c6e6aSSushil Singh
220e33c6e6aSSushil Singh    # client_id    lock_type
221e33c6e6aSSushil Singh    HMCID-01       ReadCase1
222e33c6e6aSSushil Singh    HMCID-01       ReadCase2
223e33c6e6aSSushil Singh    HMCID-01       ReadCase3
224e33c6e6aSSushil Singh    HMCID-01       WriteCase1
225e33c6e6aSSushil Singh    HMCID-01       WriteCase2
226e33c6e6aSSushil Singh    HMCID-01       WriteCase3
227e33c6e6aSSushil Singh
228e33c6e6aSSushil Singh
229d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
230d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
231d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
232d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
233afdd2a1dSVijay
234d03f2ce1SSushil Singh    # client_id    lock_type      message
235d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
236d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
237d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
238d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
239d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
240d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
241d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
242d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
243d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
244d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
245afdd2a1dSVijay
246afdd2a1dSVijay
247d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
248d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
249d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
250d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
251afdd2a1dSVijay
252d03f2ce1SSushil Singh    # client_id    lock_type       message
253d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
254d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
255d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
256d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
257d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
258d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
259d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
260d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
261d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
262d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
263d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
264d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
265afdd2a1dSVijay
266afdd2a1dSVijay
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
353d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
35485610eeeSVijay
355d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
356d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
35785610eeeSVijay
358d03f2ce1SSushil Singh    [Return]  ${session_info}
35985610eeeSVijay
36085610eeeSVijay
361d03f2ce1SSushil SinghRW General Dictionary
36216b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
363d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
364bc331e22SVijay
365bc331e22SVijay    # Description of argument(s):
366d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
367d03f2ce1SSushil Singh    # res_id       Resource id.
368bc331e22SVijay
369d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
370566daaf3SGeorge Keishing
371d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
372d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
373d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
374d03f2ce1SSushil Singh    END
375bc331e22SVijay
376d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
377d03f2ce1SSushil Singh
378d03f2ce1SSushil Singh    [Return]  ${request_dict}
379bc331e22SVijay
380bc331e22SVijay
381d03f2ce1SSushil SinghReturn Description Of Response
382d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
383bc331e22SVijay    [Arguments]  ${resp_text}
384bc331e22SVijay
385bc331e22SVijay    # Description of argument(s):
386d03f2ce1SSushil Singh    # resp_text    REST response body.
387bc331e22SVijay
388d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
389d03f2ce1SSushil Singh    # {
390d03f2ce1SSushil Singh    #    "Description": "File Created"
391d03f2ce1SSushil Singh    # }
392bc331e22SVijay
393d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
394d03f2ce1SSushil Singh
395d03f2ce1SSushil Singh    [Return]  ${message}
396bc331e22SVijay
397bc331e22SVijay
398a7d71f02SSushil SinghVerify Redfish Session Deleted
399a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
400a7d71f02SSushil Singh    [Arguments]  ${session_info}
401a7d71f02SSushil Singh
402a7d71f02SSushil Singh    # Description of argument(s):
403a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
404a7d71f02SSushil Singh
405a7d71f02SSushil Singh    # ${session_info} = {
406a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
407a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
408a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
409a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
410a7d71f02SSushil Singh    # }
411a7d71f02SSushil Singh
412a7d71f02SSushil Singh    # SessionIDs   : Session IDs
413a7d71f02SSushil Singh    # ClientID     : Client ID
414a7d71f02SSushil Singh    # SessionToken : Session token
415a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
416a7d71f02SSushil Singh
417a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
418a7d71f02SSushil Singh
419a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
4208a3efe7cSSushil Singh      Should Not Be Equal As Strings
4218a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
422a7d71f02SSushil Singh    END
423a7d71f02SSushil Singh
424a7d71f02SSushil Singh
425a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
426a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
427a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
428a7d71f02SSushil Singh
429a7d71f02SSushil Singh    # Description of argument(s):
430a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
431a7d71f02SSushil Singh
432a7d71f02SSushil Singh    # ${session_info_list} = [{
433a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
434a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
435a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
436a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
437a7d71f02SSushil Singh    # }]
438a7d71f02SSushil Singh
439a7d71f02SSushil Singh    # SessionIDs   : Session IDs
440a7d71f02SSushil Singh    # ClientID     : Client ID
441a7d71f02SSushil Singh    # SessionToken : Session token
442a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
443a7d71f02SSushil Singh
444a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
445a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
446a7d71f02SSushil Singh    END
447a7d71f02SSushil Singh
448a7d71f02SSushil Singh
449d03f2ce1SSushil SinghRedfish Post Acquire Lock
450d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
451d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
452bc331e22SVijay
453bc331e22SVijay    # Description of argument(s):
454d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
455d03f2ce1SSushil Singh    # status_code    HTTP status code.
456bc331e22SVijay
457e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
458*fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4598a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4608a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
461*fbd67007SGeorge Keishing    ...  expected_status=any
462d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
463df390b61SSushil Singh
464df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
465df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
466df390b61SSushil Singh    ...  ELSE
467df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
468bc331e22SVijay
469d03f2ce1SSushil Singh    [Return]  ${resp}
470bc331e22SVijay
471bc331e22SVijay
472977f8f58SSushil SinghRedfish Post Acquire List Lock
473977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
474977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
475977f8f58SSushil Singh
476977f8f58SSushil Singh    # Description of argument(s):
477977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
478977f8f58SSushil Singh    # status_code    HTTP status code.
479977f8f58SSushil Singh
480977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
481*fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4828a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4838a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
484*fbd67007SGeorge Keishing    ...   expected_status=any
485977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
486977f8f58SSushil Singh
487e3f2e3baSSushil Singh    Run Keyword If  ${status_code} == ${HTTP_CONFLICT}
488e3f2e3baSSushil Singh    ...    Should Be Equal As Strings  ${CONFLICT_RQUEST}  ${resp.content}
489e3f2e3baSSushil Singh    ...  ELSE
490e3f2e3baSSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
491e3f2e3baSSushil Singh
492977f8f58SSushil Singh    [Return]  ${resp}
493977f8f58SSushil Singh
494977f8f58SSushil Singh
495d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
496d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
497d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
498bc331e22SVijay
499bc331e22SVijay    # Description of argument(s):
500d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
501d03f2ce1SSushil Singh    # message        Return message from URI.
502d03f2ce1SSushil Singh    # status_code    HTTP status code.
503bc331e22SVijay
504e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
505*fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5068a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5078a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
508d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
5093b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
5103b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
511d03f2ce1SSushil Singh
512d03f2ce1SSushil Singh    [Return]  ${resp}
513bc331e22SVijay
514bc331e22SVijay
515e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
516e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
517e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
518e33c6e6aSSushil Singh
519e33c6e6aSSushil Singh    # Description of argument(s):
520e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
521e33c6e6aSSushil Singh    # status_code    HTTP status code.
522e33c6e6aSSushil Singh
5238a3efe7cSSushil Singh    ${lock_dict_param}=
5248a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
525*fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5268a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5278a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
528e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
529e33c6e6aSSushil Singh
530e33c6e6aSSushil Singh    [Return]  ${resp}
531e33c6e6aSSushil Singh
532e33c6e6aSSushil Singh
533d03f2ce1SSushil SinghForm Data To Acquire Lock
53416b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
535d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
536d03f2ce1SSushil Singh
537d03f2ce1SSushil Singh    # Description of argument(s):
538d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
539d03f2ce1SSushil Singh
540d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
541d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
542d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
543d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
544d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
545e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
546d03f2ce1SSushil Singh
547e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
548e33c6e6aSSushil Singh
549e33c6e6aSSushil Singh
550977f8f58SSushil SinghCreate Data To Acquire List Of Lock
55116b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
552977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
553977f8f58SSushil Singh
554977f8f58SSushil Singh    # Description of argument(s):
555977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
556977f8f58SSushil Singh
557977f8f58SSushil Singh    ${temp_list}=  Create List
558977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
559977f8f58SSushil Singh
560977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
561977f8f58SSushil Singh      ${resp}=  RW General Dictionary
562977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
563977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
564977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
565977f8f58SSushil Singh    END
566977f8f58SSushil Singh
567977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
568977f8f58SSushil Singh
569977f8f58SSushil Singh    [Return]  ${lock_request_dict}
570977f8f58SSushil Singh
571977f8f58SSushil Singh
572e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
57316b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
574e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
575e33c6e6aSSushil Singh
576e33c6e6aSSushil Singh    # Description of argument(s):
577e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
578e33c6e6aSSushil Singh
579e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
580e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
581e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
582e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
583e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
584e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
585e33c6e6aSSushil Singh
586e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
587d03f2ce1SSushil Singh
588d03f2ce1SSushil Singh
589d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
59016b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
591d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
592d03f2ce1SSushil Singh
593d03f2ce1SSushil Singh    # Description of argument(s):
594d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
595d03f2ce1SSushil Singh
596d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
597d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
598d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
599d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
600d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
601e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
602d03f2ce1SSushil Singh
603e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
604d03f2ce1SSushil Singh
605d03f2ce1SSushil Singh
606d03f2ce1SSushil SinghGet Locks List On Resource
607bc331e22SVijay    [Documentation]  Get locks list.
608d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
609bc331e22SVijay
610bc331e22SVijay    # Description of argument(s):
611d03f2ce1SSushil Singh    # session_info       Session information in dict.
612d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
613bc331e22SVijay
614d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
615566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
616566daaf3SGeorge Keishing    ...  data=${data}
617bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
618bc331e22SVijay
619bc331e22SVijay    [Return]  ${locks["Records"]}
620bc331e22SVijay
621bc331e22SVijay
622d03f2ce1SSushil SinghVerify Lock On Resource
623d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
624d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
625bc331e22SVijay
626bc331e22SVijay    # Description of argument(s):
627d03f2ce1SSushil Singh    # session_info      Session information in dict.
628d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
629bc331e22SVijay
630d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
631d03f2ce1SSushil Singh    Rprint Vars  sessions
632d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
633d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
634d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
635d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
636afdd2a1dSVijay
637d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
638d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
639d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
640d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
641bc331e22SVijay    END
642bc331e22SVijay
643bc331e22SVijay
644d03f2ce1SSushil SinghAcquire Lock On Resource
645d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
646d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
647bc331e22SVijay
648bc331e22SVijay    # Description of argument(s):
649d03f2ce1SSushil Singh    # client_id    This client id can contain string value
650d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
651d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
652d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
653d03f2ce1SSushil Singh    #               (e.g. True or False).
654bc331e22SVijay
6558a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
656d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6578a3efe7cSSushil Singh
658d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
659d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
660d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6618a3efe7cSSushil Singh
662d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
663566daaf3SGeorge Keishing
664e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
665bc331e22SVijay
666d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6678a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
668e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
6698a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6708a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
671bc331e22SVijay
672d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
673d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
674bc331e22SVijay
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}
678bc331e22SVijay
679bc331e22SVijay
680d03f2ce1SSushil SinghForm Data To Release Lock
681d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
682d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
683355daac7SVijay
684355daac7SVijay    # Description of argument(s):
685d03f2ce1SSushil Singh    # trans_id_list
686355daac7SVijay
687d03f2ce1SSushil Singh    @{tran_ids}=  Create List
688355daac7SVijay
689d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
690d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
691d03f2ce1SSushil Singh    END
692d03f2ce1SSushil Singh
693d03f2ce1SSushil Singh    [Return]  ${tran_ids}
694d03f2ce1SSushil Singh
695d03f2ce1SSushil Singh
696d03f2ce1SSushil SinghRelease Locks On Resource
697d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
6988a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
6998a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
700d03f2ce1SSushil Singh
701d03f2ce1SSushil Singh    # Description of argument(s):
702d03f2ce1SSushil Singh    # session_info        Session information in dict.
703d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
704d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
705d03f2ce1SSushil Singh    # status_code         HTTP status code.
706d03f2ce1SSushil Singh
707d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
708d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
709d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
710d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
711d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
712d03f2ce1SSushil Singh
713d03f2ce1SSushil Singh
714df390b61SSushil SinghRelease locks And Delete Session
715df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
716df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
717df390b61SSushil Singh
718df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
719df390b61SSushil Singh
720df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
721df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
722df390b61SSushil Singh
723df390b61SSushil Singh    Redfish Delete Session  ${session_info}
724df390b61SSushil Singh
725df390b61SSushil Singh
726d03f2ce1SSushil SinghAcquire Lock On Another Lock
727d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
728d03f2ce1SSushil Singh    [Arguments]  ${client_id}
729d03f2ce1SSushil Singh
730d03f2ce1SSushil Singh    # Description of argument(s):
731d03f2ce1SSushil Singh    # client_id    This client id can contain string value
732d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
733d03f2ce1SSushil Singh
734d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
735d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
736d03f2ce1SSushil Singh
737d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
738d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
739d03f2ce1SSushil Singh
740d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
741d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
742d03f2ce1SSushil Singh
743d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
744d03f2ce1SSushil Singh
745df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
746d03f2ce1SSushil Singh
747d03f2ce1SSushil Singh
748977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
749977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
750e3f2e3baSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${status_code}
751e3f2e3baSSushil Singh
752e3f2e3baSSushil Singh    # Description of argument(s):
753e3f2e3baSSushil Singh    # client_id     This client id can contain string value
754e3f2e3baSSushil Singh    #               (e.g. 12345, "HMCID").
755e3f2e3baSSushil Singh    # lock_type     Read lock or Write lock.
756e3f2e3baSSushil Singh    # status_code   HTTP status code
757e3f2e3baSSushil Singh
758e3f2e3baSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
759e3f2e3baSSushil Singh
760e3f2e3baSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
761e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${status_code}
762e3f2e3baSSushil Singh    Redfish Delete Session  ${session_info}
763e3f2e3baSSushil Singh
764e3f2e3baSSushil Singh
765e3f2e3baSSushil SinghVerify Acquire Read In Single Request
766e3f2e3baSSushil Singh    [Documentation]  Verify acquire read in single request.
767977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
768977f8f58SSushil Singh
769977f8f58SSushil Singh    # Description of argument(s):
770977f8f58SSushil Singh    # client_id    This client id can contain string value
771977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
772977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
773977f8f58SSushil Singh
774e3f2e3baSSushil Singh    ${trans_id_list}=  Create List
775977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
776977f8f58SSushil Singh
777977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
778e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}
779e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
780e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
781e3f2e3baSSushil Singh
782e3f2e3baSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
783e3f2e3baSSushil Singh    Remove From List  ${trans_id_list}  1
784e3f2e3baSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
785e3f2e3baSSushil Singh
786977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
787977f8f58SSushil Singh
788977f8f58SSushil Singh
789d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
790d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
791d03f2ce1SSushil Singh    [Arguments]  ${client_id}
792d03f2ce1SSushil Singh
793d03f2ce1SSushil Singh    # Description of argument(s):
794d03f2ce1SSushil Singh    # client_id    This client id can contain string value
795d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
796d03f2ce1SSushil Singh
797d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
798d03f2ce1SSushil Singh
799d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
800d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
801d03f2ce1SSushil Singh
802d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
803d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
804d03f2ce1SSushil Singh
805d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
806f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
807d03f2ce1SSushil Singh
808f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
809d03f2ce1SSushil Singh
810d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
811d03f2ce1SSushil Singh
812d03f2ce1SSushil Singh
813d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
814d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
815d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
816d03f2ce1SSushil Singh
817d03f2ce1SSushil Singh    # Description of argument(s):
818d03f2ce1SSushil Singh    # client_id    This client id can contain string value
819d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
820d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
821d03f2ce1SSushil Singh
822d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
823d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
824d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
825d03f2ce1SSushil Singh
826d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
827d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
828d03f2ce1SSushil Singh
829d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
830d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
831d03f2ce1SSushil Singh
832df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
833d03f2ce1SSushil Singh
834d03f2ce1SSushil Singh
835e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
836e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
837e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
838e33c6e6aSSushil Singh
839e33c6e6aSSushil Singh    # Description of argument(s):
840e33c6e6aSSushil Singh    # client_id    This client id can contain string value
841e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
842e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
843e33c6e6aSSushil Singh
844e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
845f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
846ac229c79SSushil Singh
847e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
848ac229c79SSushil Singh    Redfish BMC Reset Operation
849e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
850ac229c79SSushil Singh    Is BMC Standby
851e33c6e6aSSushil Singh
852e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
853e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
854e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
855e33c6e6aSSushil Singh
856df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
857df390b61SSushil Singh
858df390b61SSushil Singh
859df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
860df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
861df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
862df390b61SSushil Singh
863df390b61SSushil Singh    # Description of argument(s):
864df390b61SSushil Singh    # client_id    This client id can contain string value
865df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
866df390b61SSushil Singh    # lock_type    Read lock or Write lock.
867df390b61SSushil Singh
868df390b61SSushil Singh    ${trans_id_list}=  Create List
869df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
870df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
871df390b61SSushil Singh
872df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
873df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
874df390b61SSushil Singh
875df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
876df390b61SSushil Singh
877df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
878df390b61SSushil Singh
879df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
880e33c6e6aSSushil Singh
881e33c6e6aSSushil Singh
8828d420bf6SSushil SinghPost Reboot Acquire Lock
8838d420bf6SSushil Singh    [Documentation]  Post reboot acquire lock and verify the transaction id is 1.
8848d420bf6SSushil Singh    [Arguments]  ${session_info}  ${lock_type}
8858d420bf6SSushil Singh
8868d420bf6SSushil Singh    # Description of argument(s):
8878d420bf6SSushil Singh    # session_info     Session information.
8888d420bf6SSushil Singh    # lock_type        Read lock or Write lock.
8898d420bf6SSushil Singh
8908d420bf6SSushil Singh    ${trans_id_list}=  Create List
8918d420bf6SSushil Singh    ${trans_id_list_var}=  Create List
8928d420bf6SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
8938d420bf6SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
8948d420bf6SSushil Singh    Append To List  ${trans_id_list_var}  ${default_trans_id}
8958d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
8968d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list_var}
8978d420bf6SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
8988d420bf6SSushil Singh    ${trans_id_emptylist}=  Create List
8998d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9008d420bf6SSushil Singh
9018d420bf6SSushil Singh
902d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
903d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
9048d420bf6SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
905d03f2ce1SSushil Singh
906d03f2ce1SSushil Singh    # Description of argument(s):
907d03f2ce1SSushil Singh    # client_id    This client id can contain string value
908d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
909d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
9108d420bf6SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
9118d420bf6SSushil Singh    #               (e.g. True or False).
912d03f2ce1SSushil Singh
913d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
914d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
915d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
916d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
917d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
918d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
919d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
920d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
921d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9228d420bf6SSushil Singh      Redfish Delete Session  ${session_info}
923d03f2ce1SSushil Singh    END
924d03f2ce1SSushil Singh
9258d420bf6SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9268d420bf6SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
9278d420bf6SSushil Singh
9288d420bf6SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
9298d420bf6SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
9308d420bf6SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
9318d420bf6SSushil Singh    ...  Is BMC Standby  AND
9328d420bf6SSushil Singh    ...  Post Reboot Acquire Lock  ${session_info}  ${lock_type}
933d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
934d03f2ce1SSushil Singh
935d03f2ce1SSushil Singh
936d03f2ce1SSushil SinghAcquire And Release Multiple Locks
937d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
938d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
939d03f2ce1SSushil Singh
940d03f2ce1SSushil Singh    # Description of argument(s):
941d03f2ce1SSushil Singh    # client_id          This client id can contain string value
942d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
943d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
944d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
945d03f2ce1SSushil Singh
946d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
947d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
948d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
949d03f2ce1SSushil Singh
950d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
951d03f2ce1SSushil Singh
952d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
953d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
954d03f2ce1SSushil Singh
955d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
956d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
957d03f2ce1SSushil Singh
958d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
959d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
960d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
961d03f2ce1SSushil Singh
962d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
963d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
964d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
965d03f2ce1SSushil Singh
966d03f2ce1SSushil Singh
96794116c61Ssusilsi7Verify Release Lock When Session Deleted
96894116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
96994116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
97094116c61Ssusilsi7
97194116c61Ssusilsi7    # Description of argument(s):
97294116c61Ssusilsi7    # client_ids    This client id can contain string value
97394116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
97494116c61Ssusilsi7    # lock_type     Read lock or Write lock.
97594116c61Ssusilsi7
97694116c61Ssusilsi7    ${trans_id_list}=  Create List
97794116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
97894116c61Ssusilsi7
97994116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
98094116c61Ssusilsi7
98194116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
98294116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
98394116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
98494116c61Ssusilsi7
98594116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
98694116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
98794116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
98894116c61Ssusilsi7
98994116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
99094116c61Ssusilsi7
99194116c61Ssusilsi7
99294116c61Ssusilsi7
99359011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
99416b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
99559011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
99659011d08SSushil Singh
99759011d08SSushil Singh    # Description of argument(s):
99859011d08SSushil Singh    # client_id          This client id can contain string value
99959011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
100059011d08SSushil Singh    # lock_type          Read lock or Write lock.
100159011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
100259011d08SSushil Singh
100359011d08SSushil Singh    ${trans_id_list}=  Create List
100459011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
100559011d08SSushil Singh
100659011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
100759011d08SSushil Singh
100859011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
100959011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
101059011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
101159011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
101259011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
101359011d08SSushil Singh
101459011d08SSushil Singh    Release Locks On Resource
101559011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
101659011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
101759011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
101859011d08SSushil Singh
101959011d08SSushil Singh    ${trans_id_emptylist}=  Create List
102059011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
102159011d08SSushil Singh    Redfish Delete Session  ${session_info}
102259011d08SSushil Singh
102359011d08SSushil Singh
10241b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
10251b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
1026d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
1027d03f2ce1SSushil Singh
1028d03f2ce1SSushil Singh    # Description of argument(s):
1029d03f2ce1SSushil Singh    # client_id          This client id can contain string value
1030d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
1031d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
1032d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
1033d03f2ce1SSushil Singh
1034d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
1035d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
1036d03f2ce1SSushil Singh
1037d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1038d03f2ce1SSushil Singh
1039d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1040d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1041d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1042d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1043d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1044d03f2ce1SSushil Singh
1045d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1046d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1047d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1048d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1049d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1050d03f2ce1SSushil Singh
1051d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
1052d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1053d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1054d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1055d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1056d03f2ce1SSushil Singh
1057d03f2ce1SSushil Singh    Release Locks On Resource
1058d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
1059d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
1060d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
1061d03f2ce1SSushil Singh
1062d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
1063d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1064d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1065d03f2ce1SSushil Singh
1066d03f2ce1SSushil Singh
10678bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
10689614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
10698bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10708bee358fSSushil Singh
10718bee358fSSushil Singh    # Description of argument(s):
10728bee358fSSushil Singh    # client_id          This client id can contain string value
10738bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
10748bee358fSSushil Singh    # lock_type          Read lock or Write lock.
10758bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
10768bee358fSSushil Singh
10778bee358fSSushil Singh    ${trans_id_list}=  Create List
10788bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
10798bee358fSSushil Singh
10808bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10818bee358fSSushil Singh
10828bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10838bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10848bee358fSSushil Singh
10858bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
10868bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
10878bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
10888bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
10898bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10908bee358fSSushil Singh
10918bee358fSSushil Singh    Release Locks On Resource
10928bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10938bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10948bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10958bee358fSSushil Singh
10968bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
10978bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10988bee358fSSushil Singh    Redfish Delete Session  ${session_info}
10998bee358fSSushil Singh
11008bee358fSSushil Singh
11011d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
11029614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
11031d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
11041d7b996cSsusilsi7
11051d7b996cSsusilsi7    # Description of argument(s):
11061d7b996cSsusilsi7    # client_id          This client id can contain string value
11071d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
11081d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
11091d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
11101d7b996cSsusilsi7
11111d7b996cSsusilsi7    ${trans_id_list}=  Create List
11121d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
11131d7b996cSsusilsi7
11141d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11151d7b996cSsusilsi7
11161d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
11171d7b996cSsusilsi7
11181d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
11191d7b996cSsusilsi7
11201d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
11211d7b996cSsusilsi7
11221d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
11231d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
11241d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
11251d7b996cSsusilsi7
11261d7b996cSsusilsi7    Release Locks On Resource
11271d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
11281d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
11291d7b996cSsusilsi7
11301d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
11311d7b996cSsusilsi7
11321d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
11331d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11341d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
11351d7b996cSsusilsi7
11361d7b996cSsusilsi7
1137d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1138d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1139d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1140d03f2ce1SSushil Singh
1141d03f2ce1SSushil Singh    # Description of argument(s):
1142d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1143d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1144d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1145d03f2ce1SSushil Singh
1146d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1147d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1148d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1149d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1150d03f2ce1SSushil Singh
1151d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1152d03f2ce1SSushil Singh
1153d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1154d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1155d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1156d03f2ce1SSushil Singh
1157d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1158d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1159d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1160d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1161d03f2ce1SSushil Singh
1162d03f2ce1SSushil Singh    Release Locks On Resource
1163e3f2e3baSSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_BAD_REQUEST}
1164d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1165d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1166d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1167d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1168d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1169d03f2ce1SSushil Singh
1170d03f2ce1SSushil Singh
1171e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1172e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1173e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1174e33c6e6aSSushil Singh
1175e33c6e6aSSushil Singh    # Description of argument(s):
1176e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1177e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1178e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1179e33c6e6aSSushil Singh
1180e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1181e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1182e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1183e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1184e33c6e6aSSushil Singh
1185e33c6e6aSSushil Singh
1186d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
118716b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1188d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1189d03f2ce1SSushil Singh
1190d03f2ce1SSushil Singh    # Description of argument(s):
1191d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1192d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1193d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1194d03f2ce1SSushil Singh    # message      Return message from URI.
1195d03f2ce1SSushil Singh
1196d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11978a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
11988a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1199d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1200bace3005SSushil Singh
1201bace3005SSushil Singh
1202bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1203bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1204bace3005SSushil Singh    [Arguments]  ${client_id}
1205bace3005SSushil Singh
1206bace3005SSushil Singh    # Description of argument(s):
1207bace3005SSushil Singh    # client_id    This client id can contain string value
1208bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1209bace3005SSushil Singh
1210bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1211bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1212bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1213bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1214728ef9c9SSushil Singh
1215728ef9c9SSushil Singh
1216728ef9c9SSushil SinghCreate List Of Session ID
1217728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1218728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1219728ef9c9SSushil Singh
1220728ef9c9SSushil Singh    # Description of argument(s):
1221728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1222728ef9c9SSushil Singh
1223728ef9c9SSushil Singh    @{session_id_list}=  Create List
1224728ef9c9SSushil Singh
1225728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1226728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1227728ef9c9SSushil Singh    END
1228728ef9c9SSushil Singh
1229728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1230728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1231728ef9c9SSushil Singh
1232728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1233728ef9c9SSushil Singh
1234728ef9c9SSushil Singh    [Return]  ${session_id_list}
1235728ef9c9SSushil Singh
1236728ef9c9SSushil Singh
1237728ef9c9SSushil SinghGet Locks List On Resource With Session List
1238728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1239728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1240728ef9c9SSushil Singh
1241728ef9c9SSushil Singh    # Description of argument(s):
1242728ef9c9SSushil Singh    # session_id_list    Session ids list.
1243728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1244728ef9c9SSushil Singh
1245728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1246*fbd67007SGeorge Keishing    ...  data={"SessionIDs":${session_id_list}}  expected_status=any
124794116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1248728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1249728ef9c9SSushil Singh
1250728ef9c9SSushil Singh    [Return]  ${locks}
1251728ef9c9SSushil Singh
1252728ef9c9SSushil Singh
1253728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1254728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1255728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1256728ef9c9SSushil Singh
1257728ef9c9SSushil Singh    # Description of argument(s):
1258728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1259728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1260728ef9c9SSushil Singh
1261728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1262728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1263728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1264728ef9c9SSushil Singh
12658a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
12668a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1267728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1268728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1269728ef9c9SSushil Singh    END
1270728ef9c9SSushil Singh
1271728ef9c9SSushil Singh
1272728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1273728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1274728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1275728ef9c9SSushil Singh
1276728ef9c9SSushil Singh    # Description of argument(s):
1277728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1278728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1279728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1280728ef9c9SSushil Singh
1281728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1282728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1283728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1284728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1285728ef9c9SSushil Singh
1286728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1287728ef9c9SSushil Singh    ${lock_list}=  Create List
1288728ef9c9SSushil Singh
1289728ef9c9SSushil Singh    ${client_id1}=  Create List
1290728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1291728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1292728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1293728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1294728ef9c9SSushil Singh
1295728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1296728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1297728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1298728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1299728ef9c9SSushil Singh
1300728ef9c9SSushil Singh
1301728ef9c9SSushil Singh    ${client_id2}=  Create List
1302728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1303728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1304728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1305728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1306728ef9c9SSushil Singh
1307728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1308728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1309728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1310728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1311728ef9c9SSushil Singh
1312728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1313728ef9c9SSushil Singh
1314728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1315728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1316728ef9c9SSushil Singh
1317728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1318728ef9c9SSushil Singh
1319728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1320728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1321728ef9c9SSushil Singh
1322728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1323728ef9c9SSushil Singh
1324728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1325728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1326728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1327728ef9c9SSushil Singh
1328728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1329f9a536caSSushil Singh
1330f9a536caSSushil Singh
1331f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1332f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1333f9a536caSSushil Singh    [Arguments]  ${client_id}
1334f9a536caSSushil Singh
1335f9a536caSSushil Singh    # Description of argument(s):
1336f9a536caSSushil Singh    # client_id    This client id can contain string value
1337f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1338f9a536caSSushil Singh
1339f9a536caSSushil Singh    ${session_dict_list}=  Create List
1340f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1341f9a536caSSushil Singh
1342f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1343f9a536caSSushil Singh
1344f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1345f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1346f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1347f9a536caSSushil Singh
1348f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1349f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1350f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1351f9a536caSSushil Singh
1352f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1353f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1354f9a536caSSushil Singh
1355f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1356f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1357f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1358f9a536caSSushil Singh
1359f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1360f9a536caSSushil Singh
1361f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
136211949a2cSSushil Singh
136311949a2cSSushil Singh
136411949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
136511949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
136611949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
136711949a2cSSushil Singh
136811949a2cSSushil Singh    # Description of argument(s):
136911949a2cSSushil Singh    # client_ids    This client id can contain string value
137011949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
137111949a2cSSushil Singh    # lock_type     Read lock or Write lock.
137211949a2cSSushil Singh
137311949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
137411949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
137511949a2cSSushil Singh    ${trans_id_list1}=  Create List
137611949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
137711949a2cSSushil Singh
137811949a2cSSushil Singh    ${session_dict_list}=  Create List
137911949a2cSSushil Singh    ${lock_list}=  Create List
138011949a2cSSushil Singh
138111949a2cSSushil Singh    ${client_id1}=  Create List
138211949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
138311949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
138411949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
138511949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
138611949a2cSSushil Singh
138711949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
138811949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
138911949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
139011949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
139111949a2cSSushil Singh
139211949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
139311949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
139411949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
139511949a2cSSushil Singh
139611949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
139711949a2cSSushil Singh
139811949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
139911949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
140011949a2cSSushil Singh
140111949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
140211949a2cSSushil Singh
140311949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
140411949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
140511949a2cSSushil Singh
140611949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1407