1*** Settings ***
2
3Documentation    Module to test IPMI SEL Time functionality.
4...              Pre-requisite Condition : Client Machine and BMC should be in
5...              Same TimeZone (example : UST)
6...
7...              IPMI Raw command variables are defined under
8...              ../data/ipmi_raw_command_table.py
9...
10...              Test the Set/Get SEL Time functionality and compare the result against
11...              BMC Native command (date).
12...
13...              Set the Time Sync Mode from NTP to Manual to Set SEL Time.
14...              Time Sync Mode change performed via REDFISH URI.
15...              Performs the change in Time Sync Mode with Test Setup and Teardown Execution
16...              with default NETWORK_TIMEOUT provided under ../lib/resource.robot.
17...
18...              NETWORK_RESTART_TIME added for Set SEL Time and Add SEL Entry as the corresponding
19...              command takes approx 5 seconds for the operation to reflect.
20...
21...              Current SEL time identified via BMC Native command (date) and perform SEL Time operations.
22...
23...              Script Verifies SEL Time for various scenarios such as,
24...              Get current time from BMC and add future year and compare against BMC native command (date),
25...              Gets BMC Current Time and Adds 15 minutes and compare against BMC native command (date),
26...              Gets BMC Current Time and subtracts 1 day and compare against BMC native command (date),
27...              Add SEL Entry for all the above scenarios and compare against BMC native command (date).
28
29Resource         ../lib/ipmi_client.robot
30Resource         ../lib/openbmc_ffdc.robot
31Library          DateTime
32Library          Collections
33Library          String
34Library          ../lib/ipmi_utils.py
35Variables        ../data/ipmi_raw_cmd_table.py
36
37Test Setup       Test Setup Execution
38Test Teardown    Test Teardown Execution
39
40Force Tags       IPMI_SEL_Time
41
42*** Variables ***
43
44${NETWORK_RESTART_TIME}   5s
45@{time_difference_list}  +8760:153:25  -87600:453:120  +175200:40:15  -43800:10:05  +20:35:12  -8760:00:00
46
47# Based on 13th byte of add SEL entry command as per IPMI spec
48# event_dir and event_type variable value needs to be given.
49${sel_no_entry_msg}  SEL has no entries
50${event_type}        Lower Non-critical going low
51${event_dir}         Asserted
52# number_of_times_sel_entry_added this variable is used in Verify Multiple Set SEL Time With Multiple Add SEL Entry
53# test case. Need to give how many sel should be added with multiple date and time.
54${number_of_times_sel_entry_added}    6
55
56*** Test Cases ***
57
58Verify Default Get SEL Time
59    [Documentation]  Verify IPMI Get SEL Time.
60    [Tags]  Verify_Default_Get_SEL_Time
61    [Setup]  Printn
62    [Teardown]  FFDC On Test Case Fail
63
64    # Gets the current SEL time via Get SEL Time Command.
65    ${resp}=  Get SEL Time Command
66    Should Not Be Empty  ${resp}
67
68
69Verify Set SEL Time On NTP Mode
70    [Documentation]   IPMI Set SEL Time without NTP
71    [Tags]  Verify_Set_SEL_Time_On_NTP_Mode
72    [Setup]  Printn
73    [Teardown]  printn
74
75    # Get current time from BMC and add future year (here, 5years).
76    ${sel_date}=  Get Specific Sel Date  5
77
78    # Gives Hexa decimal raw command data request with the prefix of 0x.
79    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
80
81    ${Set_sel_time}=  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][2]}*
82    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
83    Should Contain  ${Set_sel_time}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][1]}
84
85
86Verify SEL Set Time For Specific Time
87    [Documentation]  Verify IPMI Set SEL Time.
88    [Tags]  Verify_SEL_Set_Time_For_Specific_Time
89
90    # Get current time from BMC and add future year (here, 5years).
91    ${sel_date}=  Get Specific Sel Date  5
92
93    # Gives Hexa decimal raw command data request with the prefix of 0x.
94    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
95
96    # Set SEL Entry command.
97    Set SEL Time Entry Via Raw Command  ${sel_date_raw}
98
99    # Get SEL Time command.
100    ${get_sel_time}=  Check Current Date Time Via IPMI
101
102    # Identify Time difference and find the difference is less than 6 seconds.
103    # Command execution may happen at the end of millisecond so considered 6 seconds as difference.
104    ${time_difference}=  Get Time Difference  ${get_sel_time}  ${sel_date}
105    Should Be True  0<=${time_difference}<=5
106    ...  msg=Set SEL Time Not Working
107
108    # Get BMC time (native) and compare with set sel time given.
109    ${bmc_time}=  Get Current Date from BMC
110
111    ${difference}=  Get Time Difference  ${bmc_time}  ${sel_date}
112    Should Be True  0<=${difference}<=6
113
114
115Verify Set SEL Time With Future Date And Time
116    [Documentation]  Verify IPMI Get SEL Time by adding 15 minutes from current time.
117    [Tags]  Verify_Set_SEL_Time_With_Future_Date_And_Time
118
119    # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time.
120    ${sel_time}  ${set_sel_time}=  Identify SEL Time  +06:15:00
121
122    # Set SEL Time via IPMI command.
123    Set SEL Time Via IPMI  ${sel_time}
124
125    # Get SEL Time Command.
126    ${get_sel_time}=  Check Current Date Time Via IPMI
127
128    # Difference of time between set sel time and get time.
129    ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
130    Should Be True  0<=${difference}<=2
131
132    # Difference of time between BMC Date and Get SEL Time.
133    ${bmc_time}=  Get Current Date from BMC
134    ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
135    Should Be True  0<=${difference}<=2
136
137
138Verify Set SEL Time With Past Date And Time
139    [Documentation]  Verify IPMI Get SEL Time for yime delay of 1 day from current dat and time.
140    [Tags]  Verify_Set_SEL_Time_With_Past_Date_And_Time
141
142    # Gets BMC current time and subtracts 1 day and sets the SEL Time.
143    ${sel_time}  ${set_sel_time}=  Identify SEL Time  -24:00:00
144
145    ${status}=  Run Keyword And Return Status  Should Not Contain  ${sel_time}  1969
146    ...  msg=Date cannot be less than 1970.
147
148    IF  '${status}' == '${TRUE}'
149        # Set SEL Time via IPMI command.
150        Set SEL Time Via IPMI  ${sel_time}
151        # Get SEL Time Command.
152        ${get_sel_time}=  Check Current Date Time Via IPMI
153        # Difference of time between set sel time and get time.
154        ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
155        Should Be True  0<=${difference}<=2
156        # Difference of time between BMC Date and Get SEL Time.
157        ${bmc_time}=  Get Current Date from BMC
158        ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
159        Should Be True  0<=${difference}<=2
160    ELSE
161        FAIL  SEL Time cannot set Date less than 1970
162    END
163
164
165Verify SEL Set Time For Invalid Data Request
166    [Documentation]  Verify IPMI Get SEL Time for invalid data request
167    [Tags]  Verify_SEL_Set_Time_For_Invalid_Data_Request
168    [Setup]  Printn
169    [Teardown]  FFDC On Test Case Fail
170
171    # Gets BMC current date via date command.
172    ${current_date}=  Get Current Date from BMC
173
174    # Gives hexa decimal Raw command data request with the prefix of 0x.
175    ${sel_date_raw}=  Converting Date to HexaDecimal  ${current_date}
176
177    # Set Invalid SEL Time with one extra request byte.
178    ${Set_seltime_invalid}=  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}*
179    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} 0x00
180    Should Contain  ${Set_seltime_invalid}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]}
181
182
183Verify SEL Set Time For Incomplete Data Request
184    [Documentation]  Verify IPMI Get SEL Time for invalid data with one byte less request data.
185    [Tags]  Verify_SEL_Set_Time_For_Incomplete_Data_Request
186    [Setup]  Printn
187    [Teardown]  FFDC On Test Case Fail
188
189    # Gets BMC current date via date command.
190    ${current_date}=  Get Current Date from BMC
191
192    # Gives hexa decimal raw command data request with the prefix of 0x.
193    ${sel_date_raw}=  Converting Date to HexaDecimal  ${current_date}
194
195    # For data request less than expected byes, remove last byte.
196    ${sel_date_raw}=  Split String  ${sel_date_raw}
197    Remove From List  ${sel_date_raw}  -1
198    ${sel_date_raw}=  Evaluate  " ".join(${sel_date_raw})
199
200    # Set incomplete SEL Time with one less request byte.
201    ${Set_seltime_incomplete}=
202    ...  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}*
203    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
204    Should Contain  ${Set_seltime_incomplete}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]}
205
206
207Verify SEL Time In SEL Entry
208    [Documentation]  Verify Configured SEL Time reflects in newly added SEL Entry.
209    [Tags]  Verify_SEL_Time_In_SEL_Entry
210
211    Clear The SEL
212
213   # change to manual, get current time and add future year (here, 5years).
214    ${sel_date}=  Get Specific Sel Date  5
215
216    # Gives hexa decimal raw command data request with the prefix of 0x.
217    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
218
219    # Set SEL Entry Command.
220    Set SEL Time Entry Via Raw Command  ${sel_date_raw}
221
222    # Get SEL Time Command.
223    ${get_sel_time}=  Check Current Date Time Via IPMI
224
225    # Identify Time difference and find the difference is less than 6 seconds.
226    # Command execution may happen at the end of millisecond so considered 6 seconds as difference.
227    ${time_difference}=  Get Time Difference  ${get_sel_time}  ${sel_date}
228    Should Be True  0<=${time_difference}<=5
229    ...  msg=Set SEL Time Not Working
230
231    # Get BMC time (native) and compare with set sel time given.
232    ${bmc_time}=  Get Current Date from BMC
233
234    ${difference}=  Get Time Difference  ${bmc_time}  ${sel_date}
235    Should Be True  0<=${difference}<=6
236
237    # Get any Sensor available from Sensor list.
238    ${sensor_name}=  Fetch One Threshold Sensor From Sensor List
239
240    # Get Sensor ID from SDR Get "sensor".
241    ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
242    ${sensor_number}=  Get Bytes From SDR Sensor  ${sensor_data1}
243
244    # Get Sensor Type from SDR Get "sensor".
245    ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
246    ${sensor_type_id}=  Get Bytes From SDR Sensor  ${sensor_data2}
247
248    # Add SEL Entry.
249    ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
250
251    # Finds the last added sel entry.
252    ${resp}=  Verify SEL Added  ${sensor_name}
253
254    # Fetches the date of the last added SEL Entry.
255    ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
256
257    # Identify and find the time difference is less than 60 seconds.
258    # Finding the sensor details and execution may take up to a minute.
259    # Compare  date and time of Set SEL with sel entry.
260    ${d}=  Get Time Difference  ${sel_entry_date}  ${sel_date}
261    Should Be True  0<=${d}<=60
262
263
264Verify SEL Time In SEL Entry For Future Date and Time
265    [Documentation]  Verify configured SEL Time (Future Date & Time) in added SEL Entry.
266    [Tags]  Verify_SEL_Time_In_SEL_Entry_For_Future_Date_and_Time
267
268    Clear The SEL
269
270    # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time.
271    ${sel_time}  ${set_sel_time}=  Identify SEL Time  +06:15:00
272
273    # Set SEL Time via IPMI command.
274    Set SEL Time Via IPMI  ${sel_time}
275
276    # Get SEL Time Command.
277    ${get_sel_time}=  Check Current Date Time Via IPMI
278
279    # Difference of time between set sel time and get time.
280    ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
281    Should Be True  0<=${difference}<=2
282
283    # Difference of time between BMC Date and Get SEL Time.
284    ${bmc_time}=  Get Current Date from BMC
285    ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
286    Should Be True  0<=${difference}<=2
287
288    # Get any Sensor available from Sensor list.
289    ${sensor_name}=  Fetch One Threshold Sensor From Sensor List
290
291    # Get Sensor ID from SDR Get "sensor".
292    ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
293    ${sensor_number}=  Get Bytes From SDR Sensor  ${sensor_data1}
294
295    # Get Sensor Type from SDR Get "sensor".
296    ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
297    ${sensor_type_id}=  Get Bytes From SDR Sensor  ${sensor_data2}
298
299    # Add SEL Entry.
300    ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
301
302    # Finds the last added sel entry.
303    ${resp}=  Verify SEL Added  ${sensor_name}
304
305    # Fetches the date of the last added SEL Entry.
306    ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
307
308    # Identify and find the time difference is less than 60 seconds.
309    # Finding the sensor details and execution may take up to a minute.
310    # Compare  date and time of Set SEL with sel entry.
311    ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
312    Should Be True  0<=${d}<=60
313
314
315Verify SEL Time In SEL Entry For Past Date And Time
316    [Documentation]  Verify configured SEL Time (Past Date & Time) in added SEL Entry.
317    [Tags]  Verify_SEL_Time_In_SEL_Entry_For_Past_Date_And_Time
318
319    Clear The SEL
320
321    # Gets BMC Current Time and subtracts 1 day and sets the SEL Time.
322    ${sel_time}  ${set_sel_time}=  Identify SEL Time  -24:00:00
323
324    ${status}=  Run Keyword And Return Status  Should Not Contain  ${sel_time}  1969
325    ...  msg=Date cannot be less than 1970
326
327    IF  '${status}' == '${TRUE}'
328        # Set SEL Time via IPMI command.
329        Set SEL Time Via IPMI  ${sel_time}
330        # Get SEL Time Command.
331        ${get_sel_time}=  Check Current Date Time Via IPMI
332        # Difference of time between set sel time and get time.
333        ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
334        Should Be True  0<=${difference}<=2
335        # Difference of time between BMC Date and Get SEL Time.
336        ${bmc_time}=  Get Current Date from BMC
337        ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
338        Should Be True  0<=${difference}<=2
339
340        # Get any Sensor available from Sensor list.
341        ${sensor_name}=  Fetch One Threshold Sensor From Sensor List
342        # Get Sensor ID from SDR Get "sensor".
343        ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
344        ${sensor_number}=  Get Bytes From SDR Sensor  ${sensor_data1}
345
346        # Get Sensor Type from SDR Get "sensor".
347        ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
348        ${sensor_type_id}=  Get Bytes From SDR Sensor  ${sensor_data2}
349
350        # Add SEL Entry.
351        ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
352
353        # Finds the last added sel entry.
354        ${resp}=  Verify SEL Added  ${sensor_name}
355
356        # Fetches the date of the last added SEL Entry.
357        ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
358
359        # Identify and find the time difference is less than 60 seconds.
360        # Finding the sensor details and execution may take up to a minute.
361        # Compare  date and time of Set SEL with sel entry.
362        ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
363        Should Be True  0<=${d}<=60
364    ELSE
365        FAIL  SEL Time cannot set Date less than 1970.
366    END
367
368
369Verify Multiple Set SEL Time With Multiple Add SEL Entry
370    [Documentation]  Verify SEL time in multiple addition Of SEL entry.
371    [Tags]  Verify_Multiple_Set_SEL_Time_With_Multiple_Add_SEL_Entry
372
373    FOR  ${i}  IN RANGE  ${number_of_times_sel_entry_added}
374
375      ${sel_time}  ${set_sel_time}=  Identify SEL Time  ${time_difference_list[${i}]}
376
377      # Set SEL Time via IPMI command.
378      Set SEL Time Via IPMI  ${sel_time}
379
380      # Clear the SEL.
381      Clear The SEL
382
383      # Get any Sensor available from Sensor list.
384      ${sensor_name}=  Fetch One Threshold Sensor From Sensor List
385
386      # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID.
387      ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
388      ${sensor_number}=  Get Bytes From SDR Sensor  ${sensor_data1}
389
390      # Get Sensor Type from SDR Get "sensor" and identify Sensor Type.
391      ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
392      ${sensor_type_id}=  Get Bytes From SDR Sensor  ${sensor_data2}
393
394      # Add SEL Entry.
395      ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
396
397      # Finds the last added sel entry.
398      ${resp}=  Verify SEL Added  ${sensor_name}
399
400      # Fetches the date of the last added SEL Entry.
401      ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
402
403      # Identify and find the time difference is less than 60 seconds.
404      # Finding the sensor details and execution may take up to a minute.
405      # Compare  date and time of Set SEL with sel entry.
406      ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
407      Should Be True  ${d}<=60
408
409    END
410
411
412*** Keywords ***
413
414Time Sync Mode Change Through Redfish
415    [Documentation]  Export IP, token and change the time sync to manual.
416    [Arguments]   ${value}
417
418    # Description of argument(s):
419    # ${value}    Can be either ${FALSE} or ${TRUE}.
420
421    # May be changed to WebView.
422
423    # Changing Time Sync Mode to Manual.
424    Change Time Sync Mode Via Redfish  ${value}
425
426
427Change Time Sync Mode Via Redfish
428    [Documentation]  To change the time sync mode via Redfish.
429    [Arguments]   ${value}
430
431    # Description of argument(s):
432    # ${value}    Can be either ${FALSE} or ${TRUE}
433
434    # Creates request body for Redfish url.
435    ${mode}=  Create Dictionary  ProtocolEnabled=${value}
436    ${data}=  Create Dictionary  NTP=${mode}
437
438    # Patches the obtained body to the given url.
439    Redfish.patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
440    ...   valid_status_codes=[${HTTP_NO_CONTENT}]
441
442    Sleep  ${NETWORK_RESTART_TIME}
443
444
445Get SEL Time Command
446    [Documentation]  Get SEL Time command.
447
448    # The response will be 8 byte timestamp in hexadecimal.
449    # example: If current date and time is "Wed May  4 18:55:00 UTC 2022",
450    # then, ${get_sel_time} will be "07 cc 72 62".
451    ${get_sel_time}=  Run IPMI Command
452    ...  ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Time'][0]}
453
454    RETURN    ${get_sel_time}
455
456
457Set SEL Time Entry Via Raw Command
458    [Documentation]  Set SEL Time command.
459    [Arguments]  ${sel_date_raw}
460
461    # Description of argument(s):
462    # ${sel_date_raw}     Time to set in hexadecimal bytes.
463    # Example:
464    #    If date is 1st January 2022 12:30:00 PM,
465    #    the hexadecimal timestamp is, 61D04948.
466    #    then the request bytes are,
467    #    ${sel_date_raw}     0x48 0x49 0xd0 0x61
468
469    Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
470    Sleep  ${NETWORK_RESTART_TIME}
471
472
473Clear The SEL
474    [Documentation]  Clear SEL Command.
475
476    # Clear the SEL.
477    ${out}=  Run IPMI Standard Command  sel clear
478    Should Contain  ${out}  Clearing SEL
479    Sleep  2s
480
481
482Verify SEL Added
483    [Documentation]  Verify Added SEL.
484    [Arguments]  ${sensor_name}
485
486    # Description of argument(s):
487    # sensor_name         Name of the sensor.
488
489    ${resp}=  Run IPMI Standard Command  sel elist
490    Should Not Contain  ${resp}  ${sel_no_entry_msg}
491    ${get_sel_entry}=  Get Lines Containing String  ${resp}  ${sensor_name}
492    ${sel_entry}=  Get Lines Containing String  ${get_sel_entry}  ${event_type}
493    Should Contain  ${sel_entry}  ${event_dir}  msg=Add SEL Entry failed.
494
495    RETURN  ${sel_entry}
496
497
498Check Current Date Time Via IPMI
499    [Documentation]  Verify Current Date and Time Via IPMI user command.
500
501    ${resp}=  Run IPMI Standard Command  sel time get
502    RETURN  ${resp}
503
504
505Get Specific Sel Date
506    [Documentation]  Gets initial time and adds year to the current date and returns future date.
507    [Arguments]  ${year}
508
509    # Description of argument(s):
510    # ${year}             Can be any number of years (say 5 year).
511
512    ${current_date}=  Get Current Date from BMC
513
514    # Converting given years to days by multiplying with 365days and adding the days to current date.
515    ${days}=  Evaluate  365*${year}+1
516    ${date}=  Add Time To Date
517    ...  ${current_date}  ${days}d  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
518
519    RETURN   ${date}
520
521
522Converting Date to HexaDecimal
523    [Documentation]  Converting the date into hexa decimal values.
524    [Arguments]  ${date}
525
526    # Description of argument(s):
527    # ${date}             Can be any date in format %m/%d/%Y %H:%M:%S.
528
529    ${epoch_date}=  Convert Date  ${date}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
530    ${date}=  Convert To Hex  ${epoch_date}  lowercase=yes
531
532    # function calls from utils.py.
533    # Length of the date byte should be 8 so that each bytes are separated.
534    ${date}=  Zfill Data  ${date}  8
535    # To split every two characters to form one byte each.
536    ${date}=  Split String With Index  ${date}  2
537    # Prefix every list index value with 0x.
538    ${date}=  Prefix Bytes  ${date}
539
540    # Reverse the bytes and join the list to form request Time stamp data.
541    Reverse List  ${date}
542    ${date}=  Evaluate  " ".join(${date})
543
544    RETURN  ${date}
545
546
547Get Time Difference
548    [Documentation]  Converting the date into hexa decimal values.
549    [Arguments]  ${date1}  ${date2}
550
551    # Description of argument(s):
552    # ${date1}             Can be any date in format %m/%d/%Y %H:%M:%S.
553    # ${date2}             Can be any date in format %m/%d/%Y %H:%M:%S.
554
555    ${epoch_date1}=  Convert Date  ${date1}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
556    ${epoch_date2}=  Convert Date  ${date2}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
557
558    ${diff}=  Evaluate  int(${epoch_date1}) - int(${epoch_date2})
559
560    RETURN  ${diff}
561
562
563Identify SEL Time
564    [Documentation]  Modify SEL Time From BMC For Set Sel Time Command.
565    [Arguments]  ${time}
566
567    # Description of argument(s):
568    # time             Can be any number of hours or minutes in format %H:%M:%S.
569
570    # Gets BMC current date via date command.
571    ${current_date}=  Get Current Date from BMC
572
573    ${modifying_date_status}=  Run Keyword And Return Status  Should Contain  ${time}  +
574
575    ${date_time}=  Set Variable IF
576    ...  ${modifying_date_status} == True  ${time.split("+")[-1]}
577    ...  ${modifying_date_status} == False  ${time.split("-")[-1]}
578
579    ${datetime} =  Run Keyword IF  ${modifying_date_status} == True
580    ...    Add Time To Date
581    ...    ${current_date}  ${date_time}  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
582    ...  ELSE IF  ${modifying_date_status} == False
583    ...    Subtract Time From Date
584    ...    ${current_date}  ${date_time}  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
585
586    #Set SEL Time.
587    ${quoted_date}=  Fetch Date  ${datetime}
588
589    RETURN  ${quoted_date}  ${datetime}
590
591
592Set SEL Time Via IPMI
593    [Documentation]  Set SEL Time for given date using IPMI.
594    [Arguments]  ${date_time}
595
596    # Description of argument(s):
597    # ${date_time}       Can be any date in format %m/%d/%Y %H:%M:%S.
598
599    ${resp}=  Run IPMI Standard Command  sel time set "${date_time}"
600    Should Not Contain  ${resp}  Unspecified error
601
602
603Test Setup Execution
604    [Documentation]  Test Setup Execution.
605
606    Redfish.Login
607    # Change timesync mode to manual with timeout as per resource.robot.
608    Time Sync Mode Change Through Redfish   ${FALSE}
609    Sleep  ${NETWORK_TIMEOUT}
610
611
612Test Teardown Execution
613    [Documentation]  For execution of Test teardown.
614
615    Clear The SEL
616
617    # Change TimeSync mode to NTP with Timeout as per default resource.robot.
618    Time Sync Mode Change Through Redfish  ${TRUE}
619    Sleep  ${NETWORK_TIMEOUT}
620    Redfish.Logout
621    FFDC On Test Case Fail
622