xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 5d05994be83faca347457a7d93301f5c364105ff)
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
11bc331e22SVijay
1240ef0eb7SSushil SinghSuite Setup              Run Keyword And Ignore Error  Delete All Redfish Sessions
13df390b61SSushil SinghSuite Teardown           Run Keyword And Ignore Error  Delete All Redfish Sessions
14d03f2ce1SSushil SinghTest Setup               Printn
15d03f2ce1SSushil SinghTest Teardown            FFDC On Test Case Fail
16bc331e22SVijay
17bc331e22SVijay*** Variables ***
18bc331e22SVijay
19d03f2ce1SSushil Singh${BAD_REQUEST}           Bad Request
208d420bf6SSushil Singh&{default_trans_id}      TransactionID=${1}
21bc331e22SVijay
22bc331e22SVijay*** Test Cases ***
23bc331e22SVijay
24d03f2ce1SSushil SinghAcquire Read Write Lock
25bc331e22SVijay    [Documentation]  Acquire and release different read locks.
26d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
27d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
28bc331e22SVijay
29d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
30d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
31d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
32d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
33d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
35d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
36bc331e22SVijay
37bc331e22SVijay
38d8bf1424SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
39d8bf1424SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
40d8bf1424SSushil Singh    ...  maintained.
41d8bf1424SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
42d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
43bc331e22SVijay
44d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
45d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
46d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
47d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
49d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
50d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
51bc331e22SVijay
52bc331e22SVijay
538d420bf6SSushil SinghCheck After Reboot Transaction ID Set To Default
548d420bf6SSushil Singh    [Documentation]  After reboot, the transaction id starts with default i.e. 1,
557fd1ac06SGeorge Keishing    ...  if any lock is acquired.
568d420bf6SSushil Singh    [Tags]  Check_After_Reboot_Transaction_ID_Set_To_Default
578d420bf6SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
588d420bf6SSushil Singh
598d420bf6SSushil Singh    # client_id    lock_type     reboot_flag
608d420bf6SSushil Singh    HMCID-01       ReadCase1     True
618d420bf6SSushil Singh    HMCID-01       WriteCase1    True
628d420bf6SSushil Singh
638d420bf6SSushil Singh
64d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
65d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
66d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
67d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
68bc331e22SVijay
69d03f2ce1SSushil Singh    # client_id
70d03f2ce1SSushil Singh    HMCID-01
71bc331e22SVijay
72bc331e22SVijay
73d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
74d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
75d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
76d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
7785610eeeSVijay
78d03f2ce1SSushil Singh    # client_id    lock_type
79*5d05994bSSushil Singh    HMCID-01       ReadCase7,WriteCase6
80*5d05994bSSushil Singh    HMCID-01       WriteCase6,WriteCase6
81*5d05994bSSushil Singh    HMCID-01       WriteCase6,ReadCase7
82566daaf3SGeorge Keishing
83566daaf3SGeorge Keishing
84e33c6e6aSSushil SinghAcquire Lock After Reboot
85e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
86e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
87e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
88e33c6e6aSSushil Singh
89e33c6e6aSSushil Singh    # client_id    lock_type
90e33c6e6aSSushil Singh    HMCID-01       ReadCase1
91e33c6e6aSSushil Singh    HMCID-01       ReadCase2
92e33c6e6aSSushil Singh    HMCID-01       ReadCase3
93e33c6e6aSSushil Singh    HMCID-01       WriteCase1
94e33c6e6aSSushil Singh    HMCID-01       WriteCase2
95e33c6e6aSSushil Singh    HMCID-01       WriteCase3
96e33c6e6aSSushil Singh
97e33c6e6aSSushil Singh
98d03f2ce1SSushil SinghAcquire And Release Lock In Loop
99d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
100d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
101d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
102566daaf3SGeorge Keishing
103d03f2ce1SSushil Singh    # client_id    lock_type
104d03f2ce1SSushil Singh    HMCID-01       ReadCase1
105d03f2ce1SSushil Singh    HMCID-01       ReadCase2
106d03f2ce1SSushil Singh    HMCID-01       ReadCase3
107d03f2ce1SSushil Singh    HMCID-01       WriteCase1
108d03f2ce1SSushil Singh    HMCID-01       WriteCase2
109d03f2ce1SSushil Singh    HMCID-01       WriteCase3
11085610eeeSVijay
11185610eeeSVijay
112977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
113977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
114977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
115977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
116977f8f58SSushil Singh
117977f8f58SSushil Singh    # client_id    lock_type
118977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
119977f8f58SSushil Singh    HMCID-01       WriteCase1,ReadCase1
120977f8f58SSushil Singh
121977f8f58SSushil Singh
122df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
123df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
124df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
125df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
126df390b61SSushil Singh
127df390b61SSushil Singh    # client_id    lock_type
128df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
129df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
130df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
131df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
132df390b61SSushil Singh
133df390b61SSushil Singh
134d03f2ce1SSushil SinghVerify Release Of Valid Locks
135d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
136d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
137d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
138afdd2a1dSVijay
139d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
140d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
141d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
142afdd2a1dSVijay
143afdd2a1dSVijay
14494116c61Ssusilsi7Release Lock When Session Deleted
14594116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
14694116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
14794116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
14894116c61Ssusilsi7
14994116c61Ssusilsi7    # client_id    lock_type
15094116c61Ssusilsi7    HMCID-01       ReadCase1
15194116c61Ssusilsi7    HMCID-01       WriteCase1
15294116c61Ssusilsi7
15394116c61Ssusilsi7
15459011d08SSushil SinghFail To Release Lock With Invalid TransactionID
15559011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
15659011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
15759011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
15859011d08SSushil Singh
15959011d08SSushil Singh    # client_id    lock_type     release_lock_type
16059011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
16143b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
16259011d08SSushil Singh
16359011d08SSushil Singh
1641b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
165d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1661b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1671b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
168afdd2a1dSVijay
169d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
170d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
171d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
172d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
173afdd2a1dSVijay
174afdd2a1dSVijay
1758bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1769614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1778bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1788bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1798bee358fSSushil Singh
1808bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1818bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1828bee358fSSushil Singh
1838bee358fSSushil Singh
1841d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1851d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1861d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1871d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1881d7b996cSsusilsi7
1891d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
1901d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
1911d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
1921d7b996cSsusilsi7
1931d7b996cSsusilsi7
194d03f2ce1SSushil SinghFail To Release Lock For Another Session
195d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
196d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
197d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
198afdd2a1dSVijay
199d03f2ce1SSushil Singh    # client_id          lock_type
200d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
201afdd2a1dSVijay
202afdd2a1dSVijay
203e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
204e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
205e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
206e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
207e33c6e6aSSushil Singh
208e33c6e6aSSushil Singh    # client_id    lock_type
209e33c6e6aSSushil Singh    HMCID-01       ReadCase1
210e33c6e6aSSushil Singh    HMCID-01       ReadCase2
211e33c6e6aSSushil Singh    HMCID-01       ReadCase3
212e33c6e6aSSushil Singh    HMCID-01       WriteCase1
213e33c6e6aSSushil Singh    HMCID-01       WriteCase2
214e33c6e6aSSushil Singh    HMCID-01       WriteCase3
215e33c6e6aSSushil Singh
216e33c6e6aSSushil Singh
217d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
218d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
219d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
220d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
221afdd2a1dSVijay
222d03f2ce1SSushil Singh    # client_id    lock_type      message
223d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
224d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
225d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
226d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
227d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
228d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
229d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
230d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
231d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
232d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
233afdd2a1dSVijay
234afdd2a1dSVijay
235d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
236d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
237d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
238d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
239afdd2a1dSVijay
240d03f2ce1SSushil Singh    # client_id    lock_type       message
241d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
242d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
243d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
244d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
245d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
246d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
247d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
248d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
249d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
250d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
251d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
252d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
253afdd2a1dSVijay
254afdd2a1dSVijay
255d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
256d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
257d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
258d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
259d03f2ce1SSushil Singh
260d03f2ce1SSushil Singh    # client_id    lock_type       message
261d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
262d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
263d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
264d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
265d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
266d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
267afdd2a1dSVijay
268bace3005SSushil Singh
2693b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2703b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2713b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2723b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2733b3a7ecaSSushil Singh
2743b3a7ecaSSushil Singh    # client_id    lock_type       message
2753b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2763b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2773b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2783b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2793b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2803b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2813b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2823b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2833b3a7ecaSSushil Singh
2843b3a7ecaSSushil Singh
285bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
286bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
287bace3005SSushil Singh    ...              empty lock records.
288bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
289bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
290bace3005SSushil Singh
291bace3005SSushil Singh    # client_id
292bace3005SSushil Singh    HMCID-01
293bace3005SSushil Singh
294728ef9c9SSushil Singh
295f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
296f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
297f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
298f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
299f9a536caSSushil Singh
300f9a536caSSushil Singh    # client_id
301f9a536caSSushil Singh    HMCID-01
302f9a536caSSushil Singh
303f9a536caSSushil Singh
304728ef9c9SSushil SinghGet Lock Records For Multiple Session
305728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
306728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
307728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
308728ef9c9SSushil Singh
309728ef9c9SSushil Singh    # client_ids         lock_type
310728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
311728ef9c9SSushil Singh
312728ef9c9SSushil Singh
313f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
314f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
315f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
316f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
317f9a536caSSushil Singh
318f9a536caSSushil Singh    # client_id
319f9a536caSSushil Singh    HMCID-01
320f9a536caSSushil Singh
32111949a2cSSushil Singh
32211949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
32311949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
32411949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
32511949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
32611949a2cSSushil Singh
32711949a2cSSushil Singh    # client_id          lock_type
32811949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
32911949a2cSSushil Singh
330bc331e22SVijay*** Keywords ***
331bc331e22SVijay
332d03f2ce1SSushil SinghCreate Redfish Session With ClientID
333d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
334d03f2ce1SSushil Singh    [Arguments]  ${client_id}
33585610eeeSVijay
33685610eeeSVijay    # Description of argument(s):
337d03f2ce1SSushil Singh    # client_id    This client id can contain string value
338d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
33985610eeeSVijay
340d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
341d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
34285610eeeSVijay
343d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
344d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
34585610eeeSVijay
346d03f2ce1SSushil Singh    [Return]  ${session_info}
34785610eeeSVijay
34885610eeeSVijay
349d03f2ce1SSushil SinghRW General Dictionary
35016b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
351d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
352bc331e22SVijay
353bc331e22SVijay    # Description of argument(s):
354d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
355d03f2ce1SSushil Singh    # res_id       Resource id.
356bc331e22SVijay
357d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
358566daaf3SGeorge Keishing
359d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
360d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
361d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
362d03f2ce1SSushil Singh    END
363bc331e22SVijay
364d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
365d03f2ce1SSushil Singh
366d03f2ce1SSushil Singh    [Return]  ${request_dict}
367bc331e22SVijay
368bc331e22SVijay
369d03f2ce1SSushil SinghReturn Description Of Response
370d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
371bc331e22SVijay    [Arguments]  ${resp_text}
372bc331e22SVijay
373bc331e22SVijay    # Description of argument(s):
374d03f2ce1SSushil Singh    # resp_text    REST response body.
375bc331e22SVijay
376d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
377d03f2ce1SSushil Singh    # {
378d03f2ce1SSushil Singh    #    "Description": "File Created"
379d03f2ce1SSushil Singh    # }
380bc331e22SVijay
381d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
382d03f2ce1SSushil Singh
383d03f2ce1SSushil Singh    [Return]  ${message}
384bc331e22SVijay
385bc331e22SVijay
386a7d71f02SSushil SinghVerify Redfish Session Deleted
387a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
388a7d71f02SSushil Singh    [Arguments]  ${session_info}
389a7d71f02SSushil Singh
390a7d71f02SSushil Singh    # Description of argument(s):
391a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
392a7d71f02SSushil Singh
393a7d71f02SSushil Singh    # ${session_info} = {
394a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
395a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
396a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
397a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
398a7d71f02SSushil Singh    # }
399a7d71f02SSushil Singh
400a7d71f02SSushil Singh    # SessionIDs   : Session IDs
401a7d71f02SSushil Singh    # ClientID     : Client ID
402a7d71f02SSushil Singh    # SessionToken : Session token
403a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
404a7d71f02SSushil Singh
405a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
406a7d71f02SSushil Singh
407a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
4088a3efe7cSSushil Singh      Should Not Be Equal As Strings
4098a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
410a7d71f02SSushil Singh    END
411a7d71f02SSushil Singh
412a7d71f02SSushil Singh
413a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
414a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
415a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
416a7d71f02SSushil Singh
417a7d71f02SSushil Singh    # Description of argument(s):
418a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
419a7d71f02SSushil Singh
420a7d71f02SSushil Singh    # ${session_info_list} = [{
421a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
422a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
423a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
424a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
425a7d71f02SSushil Singh    # }]
426a7d71f02SSushil Singh
427a7d71f02SSushil Singh    # SessionIDs   : Session IDs
428a7d71f02SSushil Singh    # ClientID     : Client ID
429a7d71f02SSushil Singh    # SessionToken : Session token
430a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
431a7d71f02SSushil Singh
432a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
433a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
434a7d71f02SSushil Singh    END
435a7d71f02SSushil Singh
436a7d71f02SSushil Singh
437d03f2ce1SSushil SinghRedfish Post Acquire Lock
438d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
439d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
440bc331e22SVijay
441bc331e22SVijay    # Description of argument(s):
442d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
443d03f2ce1SSushil Singh    # status_code    HTTP status code.
444bc331e22SVijay
445e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
4468a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4478a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
448d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
449df390b61SSushil Singh
450df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
451df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
452df390b61SSushil Singh    ...  ELSE
453df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
454bc331e22SVijay
455d03f2ce1SSushil Singh    [Return]  ${resp}
456bc331e22SVijay
457bc331e22SVijay
458977f8f58SSushil SinghRedfish Post Acquire List Lock
459977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
460977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
461977f8f58SSushil Singh
462977f8f58SSushil Singh    # Description of argument(s):
463977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
464977f8f58SSushil Singh    # status_code    HTTP status code.
465977f8f58SSushil Singh
466977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
4678a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4688a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
469977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
470977f8f58SSushil Singh
471977f8f58SSushil Singh    [Return]  ${resp}
472977f8f58SSushil Singh
473977f8f58SSushil Singh
474d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
475d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
476d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
477bc331e22SVijay
478bc331e22SVijay    # Description of argument(s):
479d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
480d03f2ce1SSushil Singh    # message        Return message from URI.
481d03f2ce1SSushil Singh    # status_code    HTTP status code.
482bc331e22SVijay
483e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
4848a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4858a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
486d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4873b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4883b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
489d03f2ce1SSushil Singh
490d03f2ce1SSushil Singh    [Return]  ${resp}
491bc331e22SVijay
492bc331e22SVijay
493e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
494e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
495e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
496e33c6e6aSSushil Singh
497e33c6e6aSSushil Singh    # Description of argument(s):
498e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
499e33c6e6aSSushil Singh    # status_code    HTTP status code.
500e33c6e6aSSushil Singh
5018a3efe7cSSushil Singh    ${lock_dict_param}=
5028a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
5038a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5048a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
505e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
506e33c6e6aSSushil Singh
507e33c6e6aSSushil Singh    [Return]  ${resp}
508e33c6e6aSSushil Singh
509e33c6e6aSSushil Singh
510d03f2ce1SSushil SinghForm Data To Acquire Lock
51116b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
512d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
513d03f2ce1SSushil Singh
514d03f2ce1SSushil Singh    # Description of argument(s):
515d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
516d03f2ce1SSushil Singh
517d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
518d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
519d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
520d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
521d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
522e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
523d03f2ce1SSushil Singh
524e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
525e33c6e6aSSushil Singh
526e33c6e6aSSushil Singh
527977f8f58SSushil SinghCreate Data To Acquire List Of Lock
52816b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
529977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
530977f8f58SSushil Singh
531977f8f58SSushil Singh    # Description of argument(s):
532977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
533977f8f58SSushil Singh
534977f8f58SSushil Singh    ${temp_list}=  Create List
535977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
536977f8f58SSushil Singh
537977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
538977f8f58SSushil Singh      ${resp}=  RW General Dictionary
539977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
540977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
541977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
542977f8f58SSushil Singh    END
543977f8f58SSushil Singh
544977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
545977f8f58SSushil Singh
546977f8f58SSushil Singh    [Return]  ${lock_request_dict}
547977f8f58SSushil Singh
548977f8f58SSushil Singh
549e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
55016b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
551e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
552e33c6e6aSSushil Singh
553e33c6e6aSSushil Singh    # Description of argument(s):
554e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
555e33c6e6aSSushil Singh
556e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
557e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
558e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
559e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
560e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
561e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
562e33c6e6aSSushil Singh
563e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
564d03f2ce1SSushil Singh
565d03f2ce1SSushil Singh
566d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
56716b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
568d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
569d03f2ce1SSushil Singh
570d03f2ce1SSushil Singh    # Description of argument(s):
571d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
572d03f2ce1SSushil Singh
573d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
574d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
575d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
576d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
577d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
578e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
579d03f2ce1SSushil Singh
580e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
581d03f2ce1SSushil Singh
582d03f2ce1SSushil Singh
583d03f2ce1SSushil SinghGet Locks List On Resource
584bc331e22SVijay    [Documentation]  Get locks list.
585d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
586bc331e22SVijay
587bc331e22SVijay    # Description of argument(s):
588d03f2ce1SSushil Singh    # session_info       Session information in dict.
589d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
590bc331e22SVijay
591d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
592566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
593566daaf3SGeorge Keishing    ...  data=${data}
594bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
595bc331e22SVijay
596bc331e22SVijay    [Return]  ${locks["Records"]}
597bc331e22SVijay
598bc331e22SVijay
599d03f2ce1SSushil SinghVerify Lock On Resource
600d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
601d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
602bc331e22SVijay
603bc331e22SVijay    # Description of argument(s):
604d03f2ce1SSushil Singh    # session_info      Session information in dict.
605d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
606bc331e22SVijay
607d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
608d03f2ce1SSushil Singh    Rprint Vars  sessions
609d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
610d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
611d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
612d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
613afdd2a1dSVijay
614d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
615d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
616d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
617d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
618bc331e22SVijay    END
619bc331e22SVijay
620bc331e22SVijay
621d03f2ce1SSushil SinghAcquire Lock On Resource
622d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
623d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
624bc331e22SVijay
625bc331e22SVijay    # Description of argument(s):
626d03f2ce1SSushil Singh    # client_id    This client id can contain string value
627d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
628d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
629d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
630d03f2ce1SSushil Singh    #               (e.g. True or False).
631bc331e22SVijay
6328a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
633d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6348a3efe7cSSushil Singh
635d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
636d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
637d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6388a3efe7cSSushil Singh
639d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
640566daaf3SGeorge Keishing
641e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
642bc331e22SVijay
643d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6448a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
645e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
6468a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6478a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
648bc331e22SVijay
649d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
650d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
651bc331e22SVijay
652d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
653d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
654d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
655bc331e22SVijay
656bc331e22SVijay
657d03f2ce1SSushil SinghForm Data To Release Lock
658d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
659d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
660355daac7SVijay
661355daac7SVijay    # Description of argument(s):
662d03f2ce1SSushil Singh    # trans_id_list
663355daac7SVijay
664d03f2ce1SSushil Singh    @{tran_ids}=  Create List
665355daac7SVijay
666d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
667d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
668d03f2ce1SSushil Singh    END
669d03f2ce1SSushil Singh
670d03f2ce1SSushil Singh    [Return]  ${tran_ids}
671d03f2ce1SSushil Singh
672d03f2ce1SSushil Singh
673d03f2ce1SSushil SinghRelease Locks On Resource
674d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
6758a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
6768a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
677d03f2ce1SSushil Singh
678d03f2ce1SSushil Singh    # Description of argument(s):
679d03f2ce1SSushil Singh    # session_info        Session information in dict.
680d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
681d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
682d03f2ce1SSushil Singh    # status_code         HTTP status code.
683d03f2ce1SSushil Singh
684d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
685d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
686d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
687d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
688d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
689d03f2ce1SSushil Singh
690d03f2ce1SSushil Singh
691df390b61SSushil SinghRelease locks And Delete Session
692df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
693df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
694df390b61SSushil Singh
695df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
696df390b61SSushil Singh
697df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
698df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
699df390b61SSushil Singh
700df390b61SSushil Singh    Redfish Delete Session  ${session_info}
701df390b61SSushil Singh
702df390b61SSushil Singh
703d03f2ce1SSushil SinghAcquire Lock On Another Lock
704d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
705d03f2ce1SSushil Singh    [Arguments]  ${client_id}
706d03f2ce1SSushil Singh
707d03f2ce1SSushil Singh    # Description of argument(s):
708d03f2ce1SSushil Singh    # client_id    This client id can contain string value
709d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
710d03f2ce1SSushil Singh
711d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
712d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
713d03f2ce1SSushil Singh
714d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
715d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
716d03f2ce1SSushil Singh
717d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
718d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
719d03f2ce1SSushil Singh
720d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
721d03f2ce1SSushil Singh
722df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
723d03f2ce1SSushil Singh
724d03f2ce1SSushil Singh
725977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
726977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
727977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
728977f8f58SSushil Singh
729977f8f58SSushil Singh    # Description of argument(s):
730977f8f58SSushil Singh    # client_id    This client id can contain string value
731977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
732977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
733977f8f58SSushil Singh
734977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
735977f8f58SSushil Singh
736977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
737977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
738977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
739977f8f58SSushil Singh
740977f8f58SSushil Singh
741d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
742d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
743d03f2ce1SSushil Singh    [Arguments]  ${client_id}
744d03f2ce1SSushil Singh
745d03f2ce1SSushil Singh    # Description of argument(s):
746d03f2ce1SSushil Singh    # client_id    This client id can contain string value
747d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
748d03f2ce1SSushil Singh
749d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
750d03f2ce1SSushil Singh
751d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
752d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
753d03f2ce1SSushil Singh
754d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
755d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
756d03f2ce1SSushil Singh
757d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
758f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
759d03f2ce1SSushil Singh
760f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
761d03f2ce1SSushil Singh
762d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
763d03f2ce1SSushil Singh
764d03f2ce1SSushil Singh
765d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
766d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
767d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
768d03f2ce1SSushil Singh
769d03f2ce1SSushil Singh    # Description of argument(s):
770d03f2ce1SSushil Singh    # client_id    This client id can contain string value
771d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
772d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
773d03f2ce1SSushil Singh
774d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
775d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
776d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
777d03f2ce1SSushil Singh
778d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
779d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
780d03f2ce1SSushil Singh
781d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
782d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
783d03f2ce1SSushil Singh
784df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
785d03f2ce1SSushil Singh
786d03f2ce1SSushil Singh
787e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
788e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
789e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
790e33c6e6aSSushil Singh
791e33c6e6aSSushil Singh    # Description of argument(s):
792e33c6e6aSSushil Singh    # client_id    This client id can contain string value
793e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
794e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
795e33c6e6aSSushil Singh
796e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
797f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
798ac229c79SSushil Singh
799e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
800ac229c79SSushil Singh    Redfish BMC Reset Operation
801e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
802ac229c79SSushil Singh    Is BMC Standby
803e33c6e6aSSushil Singh
804e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
805e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
806e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
807e33c6e6aSSushil Singh
808df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
809df390b61SSushil Singh
810df390b61SSushil Singh
811df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
812df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
813df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
814df390b61SSushil Singh
815df390b61SSushil Singh    # Description of argument(s):
816df390b61SSushil Singh    # client_id    This client id can contain string value
817df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
818df390b61SSushil Singh    # lock_type    Read lock or Write lock.
819df390b61SSushil Singh
820df390b61SSushil Singh    ${trans_id_list}=  Create List
821df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
822df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
823df390b61SSushil Singh
824df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
825df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
826df390b61SSushil Singh
827df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
828df390b61SSushil Singh
829df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
830df390b61SSushil Singh
831df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
832e33c6e6aSSushil Singh
833e33c6e6aSSushil Singh
8348d420bf6SSushil SinghPost Reboot Acquire Lock
8358d420bf6SSushil Singh    [Documentation]  Post reboot acquire lock and verify the transaction id is 1.
8368d420bf6SSushil Singh    [Arguments]  ${session_info}  ${lock_type}
8378d420bf6SSushil Singh
8388d420bf6SSushil Singh    # Description of argument(s):
8398d420bf6SSushil Singh    # session_info     Session information.
8408d420bf6SSushil Singh    # lock_type        Read lock or Write lock.
8418d420bf6SSushil Singh
8428d420bf6SSushil Singh    ${trans_id_list}=  Create List
8438d420bf6SSushil Singh    ${trans_id_list_var}=  Create List
8448d420bf6SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
8458d420bf6SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
8468d420bf6SSushil Singh    Append To List  ${trans_id_list_var}  ${default_trans_id}
8478d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
8488d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list_var}
8498d420bf6SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
8508d420bf6SSushil Singh    ${trans_id_emptylist}=  Create List
8518d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
8528d420bf6SSushil Singh
8538d420bf6SSushil Singh
854d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
855d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
8568d420bf6SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
857d03f2ce1SSushil Singh
858d03f2ce1SSushil Singh    # Description of argument(s):
859d03f2ce1SSushil Singh    # client_id    This client id can contain string value
860d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
861d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
8628d420bf6SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
8638d420bf6SSushil Singh    #               (e.g. True or False).
864d03f2ce1SSushil Singh
865d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
866d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
867d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
868d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
869d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
870d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
871d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
872d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
873d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
8748d420bf6SSushil Singh      Redfish Delete Session  ${session_info}
875d03f2ce1SSushil Singh    END
876d03f2ce1SSushil Singh
8778d420bf6SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
8788d420bf6SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
8798d420bf6SSushil Singh
8808d420bf6SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
8818d420bf6SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
8828d420bf6SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
8838d420bf6SSushil Singh    ...  Is BMC Standby  AND
8848d420bf6SSushil Singh    ...  Post Reboot Acquire Lock  ${session_info}  ${lock_type}
885d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
886d03f2ce1SSushil Singh
887d03f2ce1SSushil Singh
888d03f2ce1SSushil SinghAcquire And Release Multiple Locks
889d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
890d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
891d03f2ce1SSushil Singh
892d03f2ce1SSushil Singh    # Description of argument(s):
893d03f2ce1SSushil Singh    # client_id          This client id can contain string value
894d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
895d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
896d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
897d03f2ce1SSushil Singh
898d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
899d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
900d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
901d03f2ce1SSushil Singh
902d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
903d03f2ce1SSushil Singh
904d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
905d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
906d03f2ce1SSushil Singh
907d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
908d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
909d03f2ce1SSushil Singh
910d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
911d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
912d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
913d03f2ce1SSushil Singh
914d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
915d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
916d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
917d03f2ce1SSushil Singh
918d03f2ce1SSushil Singh
91994116c61Ssusilsi7Verify Release Lock When Session Deleted
92094116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
92194116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
92294116c61Ssusilsi7
92394116c61Ssusilsi7    # Description of argument(s):
92494116c61Ssusilsi7    # client_ids    This client id can contain string value
92594116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
92694116c61Ssusilsi7    # lock_type     Read lock or Write lock.
92794116c61Ssusilsi7
92894116c61Ssusilsi7    ${trans_id_list}=  Create List
92994116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
93094116c61Ssusilsi7
93194116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
93294116c61Ssusilsi7
93394116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
93494116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
93594116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
93694116c61Ssusilsi7
93794116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
93894116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
93994116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
94094116c61Ssusilsi7
94194116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
94294116c61Ssusilsi7
94394116c61Ssusilsi7
94494116c61Ssusilsi7
94559011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
94616b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
94759011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
94859011d08SSushil Singh
94959011d08SSushil Singh    # Description of argument(s):
95059011d08SSushil Singh    # client_id          This client id can contain string value
95159011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
95259011d08SSushil Singh    # lock_type          Read lock or Write lock.
95359011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
95459011d08SSushil Singh
95559011d08SSushil Singh    ${trans_id_list}=  Create List
95659011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
95759011d08SSushil Singh
95859011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
95959011d08SSushil Singh
96059011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
96159011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
96259011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
96359011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
96459011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
96559011d08SSushil Singh
96659011d08SSushil Singh    Release Locks On Resource
96759011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
96859011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
96959011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
97059011d08SSushil Singh
97159011d08SSushil Singh    ${trans_id_emptylist}=  Create List
97259011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
97359011d08SSushil Singh    Redfish Delete Session  ${session_info}
97459011d08SSushil Singh
97559011d08SSushil Singh
9761b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
9771b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
978d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
979d03f2ce1SSushil Singh
980d03f2ce1SSushil Singh    # Description of argument(s):
981d03f2ce1SSushil Singh    # client_id          This client id can contain string value
982d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
983d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
984d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
985d03f2ce1SSushil Singh
986d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
987d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
988d03f2ce1SSushil Singh
989d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
990d03f2ce1SSushil Singh
991d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
992d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
993d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
994d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
995d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
996d03f2ce1SSushil Singh
997d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
998d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
999d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1000d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1001d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1002d03f2ce1SSushil Singh
1003d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
1004d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1005d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1006d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1007d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1008d03f2ce1SSushil Singh
1009d03f2ce1SSushil Singh    Release Locks On Resource
1010d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
1011d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
1012d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
1013d03f2ce1SSushil Singh
1014d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
1015d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1016d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1017d03f2ce1SSushil Singh
1018d03f2ce1SSushil Singh
10198bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
10209614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
10218bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10228bee358fSSushil Singh
10238bee358fSSushil Singh    # Description of argument(s):
10248bee358fSSushil Singh    # client_id          This client id can contain string value
10258bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
10268bee358fSSushil Singh    # lock_type          Read lock or Write lock.
10278bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
10288bee358fSSushil Singh
10298bee358fSSushil Singh    ${trans_id_list}=  Create List
10308bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
10318bee358fSSushil Singh
10328bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10338bee358fSSushil Singh
10348bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10358bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10368bee358fSSushil Singh
10378bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
10388bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
10398bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
10408bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
10418bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10428bee358fSSushil Singh
10438bee358fSSushil Singh    Release Locks On Resource
10448bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10458bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10468bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10478bee358fSSushil Singh
10488bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
10498bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10508bee358fSSushil Singh    Redfish Delete Session  ${session_info}
10518bee358fSSushil Singh
10528bee358fSSushil Singh
10531d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
10549614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
10551d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10561d7b996cSsusilsi7
10571d7b996cSsusilsi7    # Description of argument(s):
10581d7b996cSsusilsi7    # client_id          This client id can contain string value
10591d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
10601d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
10611d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
10621d7b996cSsusilsi7
10631d7b996cSsusilsi7    ${trans_id_list}=  Create List
10641d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
10651d7b996cSsusilsi7
10661d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10671d7b996cSsusilsi7
10681d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10691d7b996cSsusilsi7
10701d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
10711d7b996cSsusilsi7
10721d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
10731d7b996cSsusilsi7
10741d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
10751d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
10761d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
10771d7b996cSsusilsi7
10781d7b996cSsusilsi7    Release Locks On Resource
10791d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
10801d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10811d7b996cSsusilsi7
10821d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
10831d7b996cSsusilsi7
10841d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
10851d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10861d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
10871d7b996cSsusilsi7
10881d7b996cSsusilsi7
1089d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1090d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1091d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1092d03f2ce1SSushil Singh
1093d03f2ce1SSushil Singh    # Description of argument(s):
1094d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1095d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1096d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1097d03f2ce1SSushil Singh
1098d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1099d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1100d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1101d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1102d03f2ce1SSushil Singh
1103d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1104d03f2ce1SSushil Singh
1105d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1106d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1107d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1108d03f2ce1SSushil Singh
1109d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1110d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1111d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1112d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1113d03f2ce1SSushil Singh
1114d03f2ce1SSushil Singh    Release Locks On Resource
1115d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
1116d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1117d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1118d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1119d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1120d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1121d03f2ce1SSushil Singh
1122d03f2ce1SSushil Singh
1123e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1124e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1125e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1126e33c6e6aSSushil Singh
1127e33c6e6aSSushil Singh    # Description of argument(s):
1128e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1129e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1130e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1131e33c6e6aSSushil Singh
1132e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1133e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1134e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1135e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1136e33c6e6aSSushil Singh
1137e33c6e6aSSushil Singh
1138d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
113916b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1140d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1141d03f2ce1SSushil Singh
1142d03f2ce1SSushil Singh    # Description of argument(s):
1143d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1144d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1145d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1146d03f2ce1SSushil Singh    # message      Return message from URI.
1147d03f2ce1SSushil Singh
1148d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11498a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
11508a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1151d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1152bace3005SSushil Singh
1153bace3005SSushil Singh
1154bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1155bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1156bace3005SSushil Singh    [Arguments]  ${client_id}
1157bace3005SSushil Singh
1158bace3005SSushil Singh    # Description of argument(s):
1159bace3005SSushil Singh    # client_id    This client id can contain string value
1160bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1161bace3005SSushil Singh
1162bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1163bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1164bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1165bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1166728ef9c9SSushil Singh
1167728ef9c9SSushil Singh
1168728ef9c9SSushil SinghCreate List Of Session ID
1169728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1170728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1171728ef9c9SSushil Singh
1172728ef9c9SSushil Singh    # Description of argument(s):
1173728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1174728ef9c9SSushil Singh
1175728ef9c9SSushil Singh    @{session_id_list}=  Create List
1176728ef9c9SSushil Singh
1177728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1178728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1179728ef9c9SSushil Singh    END
1180728ef9c9SSushil Singh
1181728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1182728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1183728ef9c9SSushil Singh
1184728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1185728ef9c9SSushil Singh
1186728ef9c9SSushil Singh    [Return]  ${session_id_list}
1187728ef9c9SSushil Singh
1188728ef9c9SSushil Singh
1189728ef9c9SSushil SinghGet Locks List On Resource With Session List
1190728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1191728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1192728ef9c9SSushil Singh
1193728ef9c9SSushil Singh    # Description of argument(s):
1194728ef9c9SSushil Singh    # session_id_list    Session ids list.
1195728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1196728ef9c9SSushil Singh
1197728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1198728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
119994116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1200728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1201728ef9c9SSushil Singh
1202728ef9c9SSushil Singh    [Return]  ${locks}
1203728ef9c9SSushil Singh
1204728ef9c9SSushil Singh
1205728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1206728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1207728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1208728ef9c9SSushil Singh
1209728ef9c9SSushil Singh    # Description of argument(s):
1210728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1211728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1212728ef9c9SSushil Singh
1213728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1214728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1215728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1216728ef9c9SSushil Singh
12178a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
12188a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1219728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1220728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1221728ef9c9SSushil Singh    END
1222728ef9c9SSushil Singh
1223728ef9c9SSushil Singh
1224728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1225728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1226728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1227728ef9c9SSushil Singh
1228728ef9c9SSushil Singh    # Description of argument(s):
1229728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1230728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1231728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1232728ef9c9SSushil Singh
1233728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1234728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1235728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1236728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1237728ef9c9SSushil Singh
1238728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1239728ef9c9SSushil Singh    ${lock_list}=  Create List
1240728ef9c9SSushil Singh
1241728ef9c9SSushil Singh    ${client_id1}=  Create List
1242728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1243728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1244728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1245728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1246728ef9c9SSushil Singh
1247728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1248728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1249728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1250728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1251728ef9c9SSushil Singh
1252728ef9c9SSushil Singh
1253728ef9c9SSushil Singh    ${client_id2}=  Create List
1254728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1255728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1256728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1257728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1258728ef9c9SSushil Singh
1259728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1260728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1261728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1262728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1263728ef9c9SSushil Singh
1264728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1265728ef9c9SSushil Singh
1266728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1267728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1268728ef9c9SSushil Singh
1269728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1270728ef9c9SSushil Singh
1271728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1272728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1273728ef9c9SSushil Singh
1274728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1275728ef9c9SSushil Singh
1276728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1277728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1278728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1279728ef9c9SSushil Singh
1280728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1281f9a536caSSushil Singh
1282f9a536caSSushil Singh
1283f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1284f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1285f9a536caSSushil Singh    [Arguments]  ${client_id}
1286f9a536caSSushil Singh
1287f9a536caSSushil Singh    # Description of argument(s):
1288f9a536caSSushil Singh    # client_id    This client id can contain string value
1289f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1290f9a536caSSushil Singh
1291f9a536caSSushil Singh    ${session_dict_list}=  Create List
1292f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1293f9a536caSSushil Singh
1294f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1295f9a536caSSushil Singh
1296f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1297f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1298f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1299f9a536caSSushil Singh
1300f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1301f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1302f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1303f9a536caSSushil Singh
1304f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1305f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1306f9a536caSSushil Singh
1307f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1308f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1309f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1310f9a536caSSushil Singh
1311f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1312f9a536caSSushil Singh
1313f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
131411949a2cSSushil Singh
131511949a2cSSushil Singh
131611949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
131711949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
131811949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
131911949a2cSSushil Singh
132011949a2cSSushil Singh    # Description of argument(s):
132111949a2cSSushil Singh    # client_ids    This client id can contain string value
132211949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
132311949a2cSSushil Singh    # lock_type     Read lock or Write lock.
132411949a2cSSushil Singh
132511949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
132611949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
132711949a2cSSushil Singh    ${trans_id_list1}=  Create List
132811949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
132911949a2cSSushil Singh
133011949a2cSSushil Singh    ${session_dict_list}=  Create List
133111949a2cSSushil Singh    ${lock_list}=  Create List
133211949a2cSSushil Singh
133311949a2cSSushil Singh    ${client_id1}=  Create List
133411949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
133511949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
133611949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
133711949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
133811949a2cSSushil Singh
133911949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
134011949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
134111949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
134211949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
134311949a2cSSushil Singh
134411949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
134511949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
134611949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
134711949a2cSSushil Singh
134811949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
134911949a2cSSushil Singh
135011949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
135111949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
135211949a2cSSushil Singh
135311949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
135411949a2cSSushil Singh
135511949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
135611949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
135711949a2cSSushil Singh
135811949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1359