xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 43b0c0634062693573bed59444f91f43a8e2bc7a)
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
20bc331e22SVijay
21bc331e22SVijay*** Test Cases ***
22bc331e22SVijay
23d03f2ce1SSushil SinghAcquire Read Write Lock
24bc331e22SVijay    [Documentation]  Acquire and release different read locks.
25d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
26d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
27bc331e22SVijay
28d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
29d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
30d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
31d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
32d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
33d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
35bc331e22SVijay
36bc331e22SVijay
37d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot
38d03f2ce1SSushil Singh    [Documentation]  Acquire lock and check after reboot it remain same.
39d03f2ce1SSushil Singh    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
40d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
41bc331e22SVijay
42d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
43d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
44d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
45d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
46d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
47d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
49bc331e22SVijay
50bc331e22SVijay
51d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
52d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
53d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
54d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
55bc331e22SVijay
56d03f2ce1SSushil Singh    # client_id
57d03f2ce1SSushil Singh    HMCID-01
58bc331e22SVijay
59bc331e22SVijay
60d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
61d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
62d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
63d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
6485610eeeSVijay
65d03f2ce1SSushil Singh    # client_id    lock_type
66d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
67d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
68d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
69566daaf3SGeorge Keishing
70566daaf3SGeorge Keishing
71e33c6e6aSSushil SinghAcquire Lock After Reboot
72e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
73e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
74e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
75e33c6e6aSSushil Singh
76e33c6e6aSSushil Singh    # client_id    lock_type
77e33c6e6aSSushil Singh    HMCID-01       ReadCase1
78e33c6e6aSSushil Singh    HMCID-01       ReadCase2
79e33c6e6aSSushil Singh    HMCID-01       ReadCase3
80e33c6e6aSSushil Singh    HMCID-01       WriteCase1
81e33c6e6aSSushil Singh    HMCID-01       WriteCase2
82e33c6e6aSSushil Singh    HMCID-01       WriteCase3
83e33c6e6aSSushil Singh
84e33c6e6aSSushil Singh
85d03f2ce1SSushil SinghAcquire And Release Lock In Loop
86d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
87d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
88d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
89566daaf3SGeorge Keishing
90d03f2ce1SSushil Singh    # client_id    lock_type
91d03f2ce1SSushil Singh    HMCID-01       ReadCase1
92d03f2ce1SSushil Singh    HMCID-01       ReadCase2
93d03f2ce1SSushil Singh    HMCID-01       ReadCase3
94d03f2ce1SSushil Singh    HMCID-01       WriteCase1
95d03f2ce1SSushil Singh    HMCID-01       WriteCase2
96d03f2ce1SSushil Singh    HMCID-01       WriteCase3
9785610eeeSVijay
9885610eeeSVijay
99977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
100977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
101977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
102977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
103977f8f58SSushil Singh
104977f8f58SSushil Singh    # client_id    lock_type
105977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
106977f8f58SSushil Singh    HMCID-01       WriteCase1,ReadCase1
107977f8f58SSushil Singh
108977f8f58SSushil Singh
109df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
110df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
111df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
112df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
113df390b61SSushil Singh
114df390b61SSushil Singh    # client_id    lock_type
115df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
116df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
117df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
118df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
119df390b61SSushil Singh
120df390b61SSushil Singh
121d03f2ce1SSushil SinghVerify Release Of Valid Locks
122d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
123d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
124d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
125afdd2a1dSVijay
126d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
127d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
128d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
129afdd2a1dSVijay
130afdd2a1dSVijay
13159011d08SSushil SinghFail To Release Lock With Invalid TransactionID
13259011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
13359011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
13459011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
13559011d08SSushil Singh
13659011d08SSushil Singh    # client_id    lock_type     release_lock_type
13759011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
138*43b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
13959011d08SSushil Singh
14059011d08SSushil Singh
1411b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
142d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1431b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1441b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
145afdd2a1dSVijay
146d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
147d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
148d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
149d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
150afdd2a1dSVijay
151afdd2a1dSVijay
1528bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1538bee358fSSushil Singh    [Documentation]  Release multiple lock with valid and invalid trasaction.
1548bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1558bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1568bee358fSSushil Singh
1578bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1588bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1598bee358fSSushil Singh
1608bee358fSSushil Singh
1611d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1621d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1631d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1641d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1651d7b996cSsusilsi7
1661d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
1671d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
1681d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
1691d7b996cSsusilsi7
1701d7b996cSsusilsi7
171d03f2ce1SSushil SinghFail To Release Lock For Another Session
172d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
173d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
174d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
175afdd2a1dSVijay
176d03f2ce1SSushil Singh    # client_id          lock_type
177d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
178afdd2a1dSVijay
179afdd2a1dSVijay
180e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
181e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
182e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
183e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
184e33c6e6aSSushil Singh
185e33c6e6aSSushil Singh    # client_id    lock_type
186e33c6e6aSSushil Singh    HMCID-01       ReadCase1
187e33c6e6aSSushil Singh    HMCID-01       ReadCase2
188e33c6e6aSSushil Singh    HMCID-01       ReadCase3
189e33c6e6aSSushil Singh    HMCID-01       WriteCase1
190e33c6e6aSSushil Singh    HMCID-01       WriteCase2
191e33c6e6aSSushil Singh    HMCID-01       WriteCase3
192e33c6e6aSSushil Singh
193e33c6e6aSSushil Singh
194d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
195d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
196d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
197d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
198afdd2a1dSVijay
199d03f2ce1SSushil Singh    # client_id    lock_type      message
200d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
201d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
202d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
203d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
204d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
205d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
206d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
207d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
208d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
209d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
210afdd2a1dSVijay
211afdd2a1dSVijay
212d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
213d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
214d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
215d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
216afdd2a1dSVijay
217d03f2ce1SSushil Singh    # client_id    lock_type       message
218d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
219d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
220d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
221d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
222d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
223d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
224d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
225d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
226d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
227d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
228d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
229d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
230afdd2a1dSVijay
231afdd2a1dSVijay
232d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
233d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
234d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
235d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
236d03f2ce1SSushil Singh
237d03f2ce1SSushil Singh    # client_id    lock_type       message
238d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
239d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
240d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
241d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
242d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
243d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
244afdd2a1dSVijay
245bace3005SSushil Singh
2463b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2473b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2483b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2493b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2503b3a7ecaSSushil Singh
2513b3a7ecaSSushil Singh    # client_id    lock_type       message
2523b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2533b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2543b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2553b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2563b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2573b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2583b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2593b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2603b3a7ecaSSushil Singh
2613b3a7ecaSSushil Singh
262bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
263bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
264bace3005SSushil Singh    ...              empty lock records.
265bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
266bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
267bace3005SSushil Singh
268bace3005SSushil Singh    # client_id
269bace3005SSushil Singh    HMCID-01
270bace3005SSushil Singh
271728ef9c9SSushil Singh
272f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
273f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
274f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
275f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
276f9a536caSSushil Singh
277f9a536caSSushil Singh    # client_id
278f9a536caSSushil Singh    HMCID-01
279f9a536caSSushil Singh
280f9a536caSSushil Singh
281728ef9c9SSushil SinghGet Lock Records For Multiple Session
282728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
283728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
284728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
285728ef9c9SSushil Singh
286728ef9c9SSushil Singh    # client_ids         lock_type
287728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
288728ef9c9SSushil Singh
289728ef9c9SSushil Singh
290f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
291f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
292f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
293f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
294f9a536caSSushil Singh
295f9a536caSSushil Singh    # client_id
296f9a536caSSushil Singh    HMCID-01
297f9a536caSSushil Singh
29811949a2cSSushil Singh
29911949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
30011949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
30111949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
30211949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
30311949a2cSSushil Singh
30411949a2cSSushil Singh    # client_id          lock_type
30511949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
30611949a2cSSushil Singh
307bc331e22SVijay*** Keywords ***
308bc331e22SVijay
309d03f2ce1SSushil SinghCreate Redfish Session With ClientID
310d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
311d03f2ce1SSushil Singh    [Arguments]  ${client_id}
31285610eeeSVijay
31385610eeeSVijay    # Description of argument(s):
314d03f2ce1SSushil Singh    # client_id    This client id can contain string value
315d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
31685610eeeSVijay
317d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
318d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
31985610eeeSVijay
320d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
321d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
32285610eeeSVijay
323d03f2ce1SSushil Singh    [Return]  ${session_info}
32485610eeeSVijay
32585610eeeSVijay
326d03f2ce1SSushil SinghRW General Dictionary
32716b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
328d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
329bc331e22SVijay
330bc331e22SVijay    # Description of argument(s):
331d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
332d03f2ce1SSushil Singh    # res_id       Resource id.
333bc331e22SVijay
334d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
335566daaf3SGeorge Keishing
336d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
337d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
338d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
339d03f2ce1SSushil Singh    END
340bc331e22SVijay
341d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
342d03f2ce1SSushil Singh
343d03f2ce1SSushil Singh    [Return]  ${request_dict}
344bc331e22SVijay
345bc331e22SVijay
346d03f2ce1SSushil SinghReturn Description Of Response
347d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
348bc331e22SVijay    [Arguments]  ${resp_text}
349bc331e22SVijay
350bc331e22SVijay    # Description of argument(s):
351d03f2ce1SSushil Singh    # resp_text    REST response body.
352bc331e22SVijay
353d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
354d03f2ce1SSushil Singh    # {
355d03f2ce1SSushil Singh    #    "Description": "File Created"
356d03f2ce1SSushil Singh    # }
357bc331e22SVijay
358d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
359d03f2ce1SSushil Singh
360d03f2ce1SSushil Singh    [Return]  ${message}
361bc331e22SVijay
362bc331e22SVijay
363a7d71f02SSushil SinghVerify Redfish Session Deleted
364a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
365a7d71f02SSushil Singh    [Arguments]  ${session_info}
366a7d71f02SSushil Singh
367a7d71f02SSushil Singh    # Description of argument(s):
368a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
369a7d71f02SSushil Singh
370a7d71f02SSushil Singh    # ${session_info} = {
371a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
372a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
373a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
374a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
375a7d71f02SSushil Singh    # }
376a7d71f02SSushil Singh
377a7d71f02SSushil Singh    # SessionIDs   : Session IDs
378a7d71f02SSushil Singh    # ClientID     : Client ID
379a7d71f02SSushil Singh    # SessionToken : Session token
380a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
381a7d71f02SSushil Singh
382a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
383a7d71f02SSushil Singh
384a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
385a7d71f02SSushil Singh      Should Not Be Equal As Strings  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
386a7d71f02SSushil Singh    END
387a7d71f02SSushil Singh
388a7d71f02SSushil Singh
389a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
390a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
391a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
392a7d71f02SSushil Singh
393a7d71f02SSushil Singh    # Description of argument(s):
394a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
395a7d71f02SSushil Singh
396a7d71f02SSushil Singh    # ${session_info_list} = [{
397a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
398a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
399a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
400a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
401a7d71f02SSushil Singh    # }]
402a7d71f02SSushil Singh
403a7d71f02SSushil Singh    # SessionIDs   : Session IDs
404a7d71f02SSushil Singh    # ClientID     : Client ID
405a7d71f02SSushil Singh    # SessionToken : Session token
406a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
407a7d71f02SSushil Singh
408a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
409a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
410a7d71f02SSushil Singh    END
411a7d71f02SSushil Singh
412a7d71f02SSushil Singh
413d03f2ce1SSushil SinghRedfish Post Acquire Lock
414d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
415d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
416bc331e22SVijay
417bc331e22SVijay    # Description of argument(s):
418d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
419d03f2ce1SSushil Singh    # status_code    HTTP status code.
420bc331e22SVijay
421e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
422e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
423d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
424df390b61SSushil Singh
425df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
426df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
427df390b61SSushil Singh    ...  ELSE
428df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
429bc331e22SVijay
430d03f2ce1SSushil Singh    [Return]  ${resp}
431bc331e22SVijay
432bc331e22SVijay
433977f8f58SSushil SinghRedfish Post Acquire List Lock
434977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
435977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
436977f8f58SSushil Singh
437977f8f58SSushil Singh    # Description of argument(s):
438977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
439977f8f58SSushil Singh    # status_code    HTTP status code.
440977f8f58SSushil Singh
441977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
442977f8f58SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
443977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
444977f8f58SSushil Singh
445977f8f58SSushil Singh    [Return]  ${resp}
446977f8f58SSushil Singh
447977f8f58SSushil Singh
448d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
449d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
450d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
451bc331e22SVijay
452bc331e22SVijay    # Description of argument(s):
453d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
454d03f2ce1SSushil Singh    # message        Return message from URI.
455d03f2ce1SSushil Singh    # status_code    HTTP status code.
456bc331e22SVijay
457e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
458e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
459d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4603b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4613b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
462d03f2ce1SSushil Singh
463d03f2ce1SSushil Singh    [Return]  ${resp}
464bc331e22SVijay
465bc331e22SVijay
466e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
467e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
468e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
469e33c6e6aSSushil Singh
470e33c6e6aSSushil Singh    # Description of argument(s):
471e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
472e33c6e6aSSushil Singh    # status_code    HTTP status code.
473e33c6e6aSSushil Singh
474e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
475e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
476e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
477e33c6e6aSSushil Singh
478e33c6e6aSSushil Singh    [Return]  ${resp}
479e33c6e6aSSushil Singh
480e33c6e6aSSushil Singh
481d03f2ce1SSushil SinghForm Data To Acquire Lock
48216b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
483d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
484d03f2ce1SSushil Singh
485d03f2ce1SSushil Singh    # Description of argument(s):
486d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
487d03f2ce1SSushil Singh
488d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
489d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
490d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
491d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
492d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
493e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
494d03f2ce1SSushil Singh
495e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
496e33c6e6aSSushil Singh
497e33c6e6aSSushil Singh
498977f8f58SSushil SinghCreate Data To Acquire List Of Lock
49916b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
500977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
501977f8f58SSushil Singh
502977f8f58SSushil Singh    # Description of argument(s):
503977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
504977f8f58SSushil Singh
505977f8f58SSushil Singh    ${temp_list}=  Create List
506977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
507977f8f58SSushil Singh
508977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
509977f8f58SSushil Singh      ${resp}=  RW General Dictionary
510977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
511977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
512977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
513977f8f58SSushil Singh    END
514977f8f58SSushil Singh
515977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
516977f8f58SSushil Singh
517977f8f58SSushil Singh    [Return]  ${lock_request_dict}
518977f8f58SSushil Singh
519977f8f58SSushil Singh
520e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
52116b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
522e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
523e33c6e6aSSushil Singh
524e33c6e6aSSushil Singh    # Description of argument(s):
525e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
526e33c6e6aSSushil Singh
527e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
528e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
529e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
530e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
531e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
532e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
533e33c6e6aSSushil Singh
534e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
535d03f2ce1SSushil Singh
536d03f2ce1SSushil Singh
537d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
53816b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
539d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
540d03f2ce1SSushil Singh
541d03f2ce1SSushil Singh    # Description of argument(s):
542d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
543d03f2ce1SSushil Singh
544d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
545d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
546d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
547d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
548d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
549e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
550d03f2ce1SSushil Singh
551e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
552d03f2ce1SSushil Singh
553d03f2ce1SSushil Singh
554d03f2ce1SSushil SinghGet Locks List On Resource
555bc331e22SVijay    [Documentation]  Get locks list.
556d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
557bc331e22SVijay
558bc331e22SVijay    # Description of argument(s):
559d03f2ce1SSushil Singh    # session_info       Session information in dict.
560d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
561bc331e22SVijay
562d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
563566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
564566daaf3SGeorge Keishing    ...  data=${data}
565bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
566bc331e22SVijay
567bc331e22SVijay    [Return]  ${locks["Records"]}
568bc331e22SVijay
569bc331e22SVijay
570d03f2ce1SSushil SinghVerify Lock On Resource
571d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
572d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
573bc331e22SVijay
574bc331e22SVijay    # Description of argument(s):
575d03f2ce1SSushil Singh    # session_info      Session information in dict.
576d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
577bc331e22SVijay
578d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
579d03f2ce1SSushil Singh    Rprint Vars  sessions
580d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
581d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
582d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
583d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
584afdd2a1dSVijay
585d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
586d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
587d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
588d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
589bc331e22SVijay    END
590bc331e22SVijay
591bc331e22SVijay
592d03f2ce1SSushil SinghAcquire Lock On Resource
593d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
594d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
595bc331e22SVijay
596bc331e22SVijay    # Description of argument(s):
597d03f2ce1SSushil Singh    # client_id    This client id can contain string value
598d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
599d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
600d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
601d03f2ce1SSushil Singh    #               (e.g. True or False).
602bc331e22SVijay
603d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
604d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
605d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
606d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
607d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
608566daaf3SGeorge Keishing
609e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
610bc331e22SVijay
611d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
612d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
613d03f2ce1SSushil Singh    ...  Redfish Login  AND
614e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
615d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
616d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
617bc331e22SVijay
618d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
619d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
620bc331e22SVijay
621d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
622d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
623d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
624bc331e22SVijay
625bc331e22SVijay
626d03f2ce1SSushil SinghForm Data To Release Lock
627d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
628d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
629355daac7SVijay
630355daac7SVijay    # Description of argument(s):
631d03f2ce1SSushil Singh    # trans_id_list
632355daac7SVijay
633d03f2ce1SSushil Singh    @{tran_ids}=  Create List
634355daac7SVijay
635d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
636d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
637d03f2ce1SSushil Singh    END
638d03f2ce1SSushil Singh
639d03f2ce1SSushil Singh    [Return]  ${tran_ids}
640d03f2ce1SSushil Singh
641d03f2ce1SSushil Singh
642d03f2ce1SSushil SinghRelease Locks On Resource
643d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
644d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
645d03f2ce1SSushil Singh
646d03f2ce1SSushil Singh    # Description of argument(s):
647d03f2ce1SSushil Singh    # session_info        Session information in dict.
648d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
649d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
650d03f2ce1SSushil Singh    # status_code         HTTP status code.
651d03f2ce1SSushil Singh
652d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
653d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
654d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
655d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
656d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
657d03f2ce1SSushil Singh
658d03f2ce1SSushil Singh
659df390b61SSushil SinghRelease locks And Delete Session
660df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
661df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
662df390b61SSushil Singh
663df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
664df390b61SSushil Singh
665df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
666df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
667df390b61SSushil Singh
668df390b61SSushil Singh    Redfish Delete Session  ${session_info}
669df390b61SSushil Singh
670df390b61SSushil Singh
671d03f2ce1SSushil SinghAcquire Lock On Another Lock
672d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
673d03f2ce1SSushil Singh    [Arguments]  ${client_id}
674d03f2ce1SSushil Singh
675d03f2ce1SSushil Singh    # Description of argument(s):
676d03f2ce1SSushil Singh    # client_id    This client id can contain string value
677d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
678d03f2ce1SSushil Singh
679d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
680d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
681d03f2ce1SSushil Singh
682d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
683d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
684d03f2ce1SSushil Singh
685d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
686d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
687d03f2ce1SSushil Singh
688d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
689d03f2ce1SSushil Singh
690df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
691d03f2ce1SSushil Singh
692d03f2ce1SSushil Singh
693977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
694977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
695977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
696977f8f58SSushil Singh
697977f8f58SSushil Singh    # Description of argument(s):
698977f8f58SSushil Singh    # client_id    This client id can contain string value
699977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
700977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
701977f8f58SSushil Singh
702977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
703977f8f58SSushil Singh
704977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
705977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
706977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
707977f8f58SSushil Singh
708977f8f58SSushil Singh
709d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
710d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
711d03f2ce1SSushil Singh    [Arguments]  ${client_id}
712d03f2ce1SSushil Singh
713d03f2ce1SSushil Singh    # Description of argument(s):
714d03f2ce1SSushil Singh    # client_id    This client id can contain string value
715d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
716d03f2ce1SSushil Singh
717d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
718d03f2ce1SSushil Singh
719d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
720d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
721d03f2ce1SSushil Singh
722d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
723d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
724d03f2ce1SSushil Singh
725d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
726f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
727d03f2ce1SSushil Singh
728f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
729d03f2ce1SSushil Singh
730d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
731d03f2ce1SSushil Singh
732d03f2ce1SSushil Singh
733d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
734d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
735d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
736d03f2ce1SSushil Singh
737d03f2ce1SSushil Singh    # Description of argument(s):
738d03f2ce1SSushil Singh    # client_id    This client id can contain string value
739d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
740d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
741d03f2ce1SSushil Singh
742d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
743d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
744d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
745d03f2ce1SSushil Singh
746d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
747d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
748d03f2ce1SSushil Singh
749d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
750d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
751d03f2ce1SSushil Singh
752df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
753d03f2ce1SSushil Singh
754d03f2ce1SSushil Singh
755e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
756e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
757e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
758e33c6e6aSSushil Singh
759e33c6e6aSSushil Singh    # Description of argument(s):
760e33c6e6aSSushil Singh    # client_id    This client id can contain string value
761e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
762e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
763e33c6e6aSSushil Singh
764e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
765f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
766e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
767e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
768e33c6e6aSSushil Singh    Redfish Login
769e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
770e33c6e6aSSushil Singh
771e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
772e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
773e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
774e33c6e6aSSushil Singh
775df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
776df390b61SSushil Singh
777df390b61SSushil Singh
778df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
779df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
780df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
781df390b61SSushil Singh
782df390b61SSushil Singh    # Description of argument(s):
783df390b61SSushil Singh    # client_id    This client id can contain string value
784df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
785df390b61SSushil Singh    # lock_type    Read lock or Write lock.
786df390b61SSushil Singh
787df390b61SSushil Singh    ${trans_id_list}=  Create List
788df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
789df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
790df390b61SSushil Singh
791df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
792df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
793df390b61SSushil Singh
794df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
795df390b61SSushil Singh
796df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
797df390b61SSushil Singh
798df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
799e33c6e6aSSushil Singh
800e33c6e6aSSushil Singh
801d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
802d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
803d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
804d03f2ce1SSushil Singh
805d03f2ce1SSushil Singh    # Description of argument(s):
806d03f2ce1SSushil Singh    # client_id    This client id can contain string value
807d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
808d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
809d03f2ce1SSushil Singh
810d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
811d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
812d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
813d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
814d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
815d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
816d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
817d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
818d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
819d03f2ce1SSushil Singh    END
820d03f2ce1SSushil Singh
821d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
822d03f2ce1SSushil Singh
823d03f2ce1SSushil Singh
824d03f2ce1SSushil SinghAcquire And Release Multiple Locks
825d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
826d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
827d03f2ce1SSushil Singh
828d03f2ce1SSushil Singh    # Description of argument(s):
829d03f2ce1SSushil Singh    # client_id          This client id can contain string value
830d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
831d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
832d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
833d03f2ce1SSushil Singh
834d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
835d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
836d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
837d03f2ce1SSushil Singh
838d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
839d03f2ce1SSushil Singh
840d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
841d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
842d03f2ce1SSushil Singh
843d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
844d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
845d03f2ce1SSushil Singh
846d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
847d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
848d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
849d03f2ce1SSushil Singh
850d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
851d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
852d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
853d03f2ce1SSushil Singh
854d03f2ce1SSushil Singh
85559011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
85616b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
85759011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
85859011d08SSushil Singh
85959011d08SSushil Singh    # Description of argument(s):
86059011d08SSushil Singh    # client_id          This client id can contain string value
86159011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
86259011d08SSushil Singh    # lock_type          Read lock or Write lock.
86359011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
86459011d08SSushil Singh
86559011d08SSushil Singh    ${trans_id_list}=  Create List
86659011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
86759011d08SSushil Singh
86859011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
86959011d08SSushil Singh
87059011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
87159011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
87259011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
87359011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
87459011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
87559011d08SSushil Singh
87659011d08SSushil Singh    Release Locks On Resource
87759011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
87859011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
87959011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
88059011d08SSushil Singh
88159011d08SSushil Singh    ${trans_id_emptylist}=  Create List
88259011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
88359011d08SSushil Singh    Redfish Delete Session  ${session_info}
88459011d08SSushil Singh
88559011d08SSushil Singh
8861b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
8871b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
888d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
889d03f2ce1SSushil Singh
890d03f2ce1SSushil Singh    # Description of argument(s):
891d03f2ce1SSushil Singh    # client_id          This client id can contain string value
892d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
893d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
894d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
895d03f2ce1SSushil Singh
896d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
897d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
898d03f2ce1SSushil Singh
899d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
900d03f2ce1SSushil Singh
901d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
902d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
903d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
904d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
905d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
906d03f2ce1SSushil Singh
907d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
908d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
909d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
910d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
911d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
912d03f2ce1SSushil Singh
913d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
914d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
915d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
916d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
917d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
918d03f2ce1SSushil Singh
919d03f2ce1SSushil Singh    Release Locks On Resource
920d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
921d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
922d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
923d03f2ce1SSushil Singh
924d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
925d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
926d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
927d03f2ce1SSushil Singh
928d03f2ce1SSushil Singh
9298bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
9308bee358fSSushil Singh    [Documentation]  Verify fail to be release multiple lock with valid and invalid trasaction ID.
9318bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
9328bee358fSSushil Singh
9338bee358fSSushil Singh    # Description of argument(s):
9348bee358fSSushil Singh    # client_id          This client id can contain string value
9358bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
9368bee358fSSushil Singh    # lock_type          Read lock or Write lock.
9378bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
9388bee358fSSushil Singh
9398bee358fSSushil Singh    ${trans_id_list}=  Create List
9408bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
9418bee358fSSushil Singh
9428bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9438bee358fSSushil Singh
9448bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
9458bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9468bee358fSSushil Singh
9478bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
9488bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
9498bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
9508bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
9518bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9528bee358fSSushil Singh
9538bee358fSSushil Singh    Release Locks On Resource
9548bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
9558bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
9568bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
9578bee358fSSushil Singh
9588bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
9598bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9608bee358fSSushil Singh    Redfish Delete Session  ${session_info}
9618bee358fSSushil Singh
9628bee358fSSushil Singh
9631d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
9641d7b996cSsusilsi7    [Documentation]  Verify fail to be release lock with trasaction ID as string data type.
9651d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
9661d7b996cSsusilsi7
9671d7b996cSsusilsi7    # Description of argument(s):
9681d7b996cSsusilsi7    # client_id          This client id can contain string value
9691d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
9701d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
9711d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
9721d7b996cSsusilsi7
9731d7b996cSsusilsi7    ${trans_id_list}=  Create List
9741d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
9751d7b996cSsusilsi7
9761d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9771d7b996cSsusilsi7
9781d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
9791d7b996cSsusilsi7
9801d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
9811d7b996cSsusilsi7
9821d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
9831d7b996cSsusilsi7
9841d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
9851d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
9861d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
9871d7b996cSsusilsi7
9881d7b996cSsusilsi7    Release Locks On Resource
9891d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
9901d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
9911d7b996cSsusilsi7
9921d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
9931d7b996cSsusilsi7
9941d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
9951d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9961d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
9971d7b996cSsusilsi7
9981d7b996cSsusilsi7
999d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1000d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1001d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1002d03f2ce1SSushil Singh
1003d03f2ce1SSushil Singh    # Description of argument(s):
1004d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1005d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1006d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1007d03f2ce1SSushil Singh
1008d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1009d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1010d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1011d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1012d03f2ce1SSushil Singh
1013d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1014d03f2ce1SSushil Singh
1015d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1016d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1017d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1018d03f2ce1SSushil Singh
1019d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1020d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1021d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1022d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1023d03f2ce1SSushil Singh
1024d03f2ce1SSushil Singh    Release Locks On Resource
1025d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
1026d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1027d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1028d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1029d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1030d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1031d03f2ce1SSushil Singh
1032d03f2ce1SSushil Singh
1033e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1034e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1035e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1036e33c6e6aSSushil Singh
1037e33c6e6aSSushil Singh    # Description of argument(s):
1038e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1039e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1040e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1041e33c6e6aSSushil Singh
1042e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1043e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1044e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1045e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1046e33c6e6aSSushil Singh
1047e33c6e6aSSushil Singh
1048d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
104916b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1050d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1051d03f2ce1SSushil Singh
1052d03f2ce1SSushil Singh    # Description of argument(s):
1053d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1054d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1055d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1056d03f2ce1SSushil Singh    # message      Return message from URI.
1057d03f2ce1SSushil Singh
1058d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1059d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1060d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1061bace3005SSushil Singh
1062bace3005SSushil Singh
1063bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1064bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1065bace3005SSushil Singh    [Arguments]  ${client_id}
1066bace3005SSushil Singh
1067bace3005SSushil Singh    # Description of argument(s):
1068bace3005SSushil Singh    # client_id    This client id can contain string value
1069bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1070bace3005SSushil Singh
1071bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1072bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1073bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1074bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1075728ef9c9SSushil Singh
1076728ef9c9SSushil Singh
1077728ef9c9SSushil SinghCreate List Of Session ID
1078728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1079728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1080728ef9c9SSushil Singh
1081728ef9c9SSushil Singh    # Description of argument(s):
1082728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1083728ef9c9SSushil Singh
1084728ef9c9SSushil Singh    @{session_id_list}=  Create List
1085728ef9c9SSushil Singh
1086728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1087728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1088728ef9c9SSushil Singh    END
1089728ef9c9SSushil Singh
1090728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1091728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1092728ef9c9SSushil Singh
1093728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1094728ef9c9SSushil Singh
1095728ef9c9SSushil Singh    [Return]  ${session_id_list}
1096728ef9c9SSushil Singh
1097728ef9c9SSushil Singh
1098728ef9c9SSushil SinghGet Locks List On Resource With Session List
1099728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1100728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1101728ef9c9SSushil Singh
1102728ef9c9SSushil Singh    # Description of argument(s):
1103728ef9c9SSushil Singh    # session_id_list    Session ids list.
1104728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1105728ef9c9SSushil Singh
1106728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1107728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
1108728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1109728ef9c9SSushil Singh
1110728ef9c9SSushil Singh    [Return]  ${locks}
1111728ef9c9SSushil Singh
1112728ef9c9SSushil Singh
1113728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1114728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1115728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1116728ef9c9SSushil Singh
1117728ef9c9SSushil Singh    # Description of argument(s):
1118728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1119728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1120728ef9c9SSushil Singh
1121728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1122728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1123728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1124728ef9c9SSushil Singh
1125728ef9c9SSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1126728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1127728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1128728ef9c9SSushil Singh    END
1129728ef9c9SSushil Singh
1130728ef9c9SSushil Singh
1131728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1132728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1133728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1134728ef9c9SSushil Singh
1135728ef9c9SSushil Singh    # Description of argument(s):
1136728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1137728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1138728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1139728ef9c9SSushil Singh
1140728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1141728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1142728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1143728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1144728ef9c9SSushil Singh
1145728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1146728ef9c9SSushil Singh    ${lock_list}=  Create List
1147728ef9c9SSushil Singh
1148728ef9c9SSushil Singh    ${client_id1}=  Create List
1149728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1150728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1151728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1152728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1153728ef9c9SSushil Singh
1154728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1155728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1156728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1157728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1158728ef9c9SSushil Singh
1159728ef9c9SSushil Singh
1160728ef9c9SSushil Singh    ${client_id2}=  Create List
1161728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1162728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1163728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1164728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1165728ef9c9SSushil Singh
1166728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1167728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1168728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1169728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1170728ef9c9SSushil Singh
1171728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1172728ef9c9SSushil Singh
1173728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1174728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1175728ef9c9SSushil Singh
1176728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1177728ef9c9SSushil Singh
1178728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1179728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1180728ef9c9SSushil Singh
1181728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1182728ef9c9SSushil Singh
1183728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1184728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1185728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1186728ef9c9SSushil Singh
1187728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1188f9a536caSSushil Singh
1189f9a536caSSushil Singh
1190f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1191f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1192f9a536caSSushil Singh    [Arguments]  ${client_id}
1193f9a536caSSushil Singh
1194f9a536caSSushil Singh    # Description of argument(s):
1195f9a536caSSushil Singh    # client_id    This client id can contain string value
1196f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1197f9a536caSSushil Singh
1198f9a536caSSushil Singh    ${session_dict_list}=  Create List
1199f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1200f9a536caSSushil Singh
1201f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1202f9a536caSSushil Singh
1203f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1204f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1205f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1206f9a536caSSushil Singh
1207f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1208f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1209f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1210f9a536caSSushil Singh
1211f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1212f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1213f9a536caSSushil Singh
1214f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1215f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1216f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1217f9a536caSSushil Singh
1218f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1219f9a536caSSushil Singh
1220f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
122111949a2cSSushil Singh
122211949a2cSSushil Singh
122311949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
122411949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
122511949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
122611949a2cSSushil Singh
122711949a2cSSushil Singh    # Description of argument(s):
122811949a2cSSushil Singh    # client_ids    This client id can contain string value
122911949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
123011949a2cSSushil Singh    # lock_type     Read lock or Write lock.
123111949a2cSSushil Singh
123211949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
123311949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
123411949a2cSSushil Singh    ${trans_id_list1}=  Create List
123511949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
123611949a2cSSushil Singh
123711949a2cSSushil Singh    ${session_dict_list}=  Create List
123811949a2cSSushil Singh    ${lock_list}=  Create List
123911949a2cSSushil Singh
124011949a2cSSushil Singh    ${client_id1}=  Create List
124111949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
124211949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
124311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
124411949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
124511949a2cSSushil Singh
124611949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
124711949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
124811949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
124911949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
125011949a2cSSushil Singh
125111949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
125211949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
125311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
125411949a2cSSushil Singh
125511949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
125611949a2cSSushil Singh
125711949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
125811949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
125911949a2cSSushil Singh
126011949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
126111949a2cSSushil Singh
126211949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
126311949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
126411949a2cSSushil Singh
126511949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1266