Created New script for IPMI Set/Get SEL Time

Pre-requisite Condition : Client Machine and BMC should be in Same TimeZone (example : UST).
Mismatch of Timezones result in miscalculation of SEL Time due to different Timezone in Client Machine.

IPMI Raw command variables are defined under ../data/ipmi_raw_cmd_table.py
Python basic functionalities are defined under lib/ipmi_client.robot, lib/ipmi_utils.py and lib/utils.py files.

Test the Set/Get SEL Time functionality and compare the result against BMC Native command (date).

Set the Time Sync Mode from NTP to Manual to Set SEL Time.
Time Sync Mode change performed via REDFISH URI.
Performs the change in Time Sync Mode with Test Setup and Teardown Execution with default NETWORK_TIMEOUT provided under ../lib/resource.robot

NETWORK_RESTART_TIME added for Set SEL Time and Add SEL Entry as the corresponding command takes approx 5 seconds for the operation to reflect.

Current SEL time identified via BMC Native command (date) and perform SEL Time operations.

Script Verifies SEL Time for various scenarios such as,
    - Get current time from BMC and add future year and compare against BMC native command (date),
    - Gets BMC Current Time and Adds 15 minutes and compare against BMC native command (date),
    - Gets BMC Current Time and subtracts 1 day and compare against BMC native command (date),
    - Add SEL Entry for all the above scenarios and compare against BMC native command (date).

Tested: Run robot ipmi/test_ipmi_sel_time.robot

Signed-off-by: chithrag <chithrag@ami.com>
Change-Id: Ied129b96e38351d59780326c71f875dc50ce33f5
diff --git a/data/ipmi_raw_cmd_table.py b/data/ipmi_raw_cmd_table.py
index 764eb22..fcc97ef 100644
--- a/data/ipmi_raw_cmd_table.py
+++ b/data/ipmi_raw_cmd_table.py
@@ -80,7 +80,28 @@
             "0x0a 0x42",
             "27 00",
             "27 is Reservation ID, LSB, 00 Reservation ID, MSB ",
-        ]
+        ],
+        'Get_SEL_Time':
+        [
+            # raw command
+            '0x0a 0x48',
+        ],
+        'Set_SEL_Time':
+        [
+            # raw command, expected output(s), comment
+            '0x0a 0x49',
+            'rsp=0xd5',
+            'not supported in present state',
+            'rsp=0xc7',
+            'Request data length invalid',
+
+        ],
+        'Create_SEL':
+        [
+            # raw command
+            "0x0a 0x44 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x04",
+            "0x00 0xa0 0x04 0x07",
+        ],
     },
     'Self_Test_Results':
     {
diff --git a/ipmi/test_ipmi_sel_time.robot b/ipmi/test_ipmi_sel_time.robot
new file mode 100644
index 0000000..e8e695e
--- /dev/null
+++ b/ipmi/test_ipmi_sel_time.robot
@@ -0,0 +1,613 @@
+*** Settings ***
+
+Documentation    Module to test IPMI SEL Time functionality.
+...              Pre-requisite Condition : Client Machine and BMC should be in Same TimeZone (example : UST)
+...
+...              IPMI Raw command variables are defined under ../data/ipmi_raw_command_table.py
+...              Python basic functionalities are defined under ../lib/functions.py imported under ../lib/resource.robot
+...
+...              Test the Set/Get SEL Time functionality and compare the result against BMC Native command (date).
+...
+...              Set the Time Sync Mode from NTP to Manual to Set SEL Time.
+...              Time Sync Mode change performed via REDFISH URI.
+...              Performs the change in Time Sync Mode with Test Setup and Teardown Execution with default NETWORK_TIMEOUT provided under ../lib/resource.robot.
+...
+...              NETWORK_RESTART_TIME added for Set SEL Time and Add SEL Entry as the corresponding command takes approx 5 seconds for the operation to reflect.
+...
+...              Current SEL time identified via BMC Native command (date) and perform SEL Time operations.
+...
+...              Script Verifies SEL Time for various scenarios such as,
+...              Get current time from BMC and add future year and compare against BMC native command (date),
+...              Gets BMC Current Time and Adds 15 minutes and compare against BMC native command (date),
+...              Gets BMC Current Time and subtracts 1 day and compare against BMC native command (date),
+...              Add SEL Entry for all the above scenarios and compare against BMC native command (date).
+
+Library          DateTime
+Library          Collections
+Library          String
+Library          ../lib/ipmi_utils.py
+Resource         ../lib/ipmi_client.robot
+Resource         ../lib/openbmc_ffdc.robot
+Variables        ../data/ipmi_raw_cmd_table.py
+
+Test Setup       Test Setup Execution
+Test Teardown    Test Teardown Execution
+
+*** Variables ***
+
+${NETWORK_RESTART_TIME}   5s
+
+
+*** Test Cases ***
+
+Verify Default Get SEL Time
+    [Documentation]  Verify IPMI Get SEL Time.
+    [Tags]  Verify_Default_Get_SEL_Time
+    [Setup]  Printn
+    [Teardown]  FFDC On Test Case Fail
+
+    # Gets the current SEL time via Get SEL Time Command.
+    ${resp}=  Get SEL Time Command
+    Should Not Be Empty  ${resp}
+
+
+Set SEL Time On NTP Mode
+    [Documentation]   IPMI Set SEL Time without NTP
+    [Tags]  Verify_SEL_Set_Time_On_NTP_Mode
+    [Setup]  Printn
+    [Teardown]  printn
+
+    # Get current time from BMC and add future year (here, 5years).
+    ${sel_date}=  Get Specific Sel Date  5
+
+    # Gives Hexa decimal raw command data request with the prefix of 0x.
+    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
+
+    ${Set_sel_time}=  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][2]}*
+    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
+    Should Contain  ${Set_sel_time}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][1]}
+
+
+Verify SEL Set Time For Specific Time
+    [Documentation]  Verify IPMI Set SEL Time.
+    [Tags]  Verify_SEL_Set_Time_For_Specific_Time
+
+    # Get current time from BMC and add future year (here, 5years).
+    ${sel_date}=  Get Specific Sel Date  5
+
+    # Gives Hexa decimal raw command data request with the prefix of 0x.
+    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
+
+    # Set SEL Entry command.
+    Set SEL Time Entry Via Raw Command  ${sel_date_raw}
+
+    # Get SEL Time command.
+    ${get_sel_time}=  Check Current Date Time Via IPMI
+
+    # Identify Time difference and find the difference is less than 6 seconds.
+    # Command execution may happen at the end of millisecond so considered 6 seconds as difference.
+    ${time_difference}=  Get Time Difference  ${get_sel_time}  ${sel_date}
+    Should Be True  0<=${time_difference}<=5
+    ...  msg=Set SEL Time Not Working
+
+    # Get BMC time (native) and compare with set sel time given.
+    ${bmc_time}=  Get Current Date from BMC
+
+    ${difference}=  Get Time Difference  ${bmc_time}  ${sel_date}
+    Should Be True  0<=${difference}<=6
+
+
+Verify Set SEL Time With Future Date And Time
+    [Documentation]  Verify IPMI Get SEL Time by adding 15 minutes from current time.
+    [Tags]  Verify_Set_SEL_Time_With_Future_Date_And_Time
+
+    # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time.
+    ${sel_time}  ${set_sel_time}=  Identify SEL Time Future DateTime   06:15:00
+
+    # Set SEL Time via IPMI command.
+    Set SEL Time Via IPMI  ${sel_time}
+
+    # Get SEL Time Command.
+    ${get_sel_time}=  Check Current Date Time Via IPMI
+
+    # Difference of time between set sel time and get time.
+    ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
+    Should Be True  0<=${difference}<=2
+
+    # Difference of time between BMC Date and Get SEL Time.
+    ${bmc_time}=  Get Current Date from BMC
+    ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
+    Should Be True  0<=${difference}<=2
+
+
+Verify Set SEL Time With Past Date And Time
+    [Documentation]  Verify IPMI Get SEL Time for yime delay of 1 day from current dat and time.
+    [Tags]  Verify_Set_SEL_Time_With_Past_Date_And_Time
+
+    # Gets BMC current time and subtracts 1 day and sets the SEL Time.
+    ${sel_time}  ${set_sel_time}=  Identify SEL Time DateTime Delay  1d
+
+    ${status}=  Run Keyword And Return Status  Should Not Contain  ${sel_time}  1969
+    ...  msg=Date cannot be less than 1970.
+
+    IF  '${status}' == '${TRUE}'
+        # Set SEL Time via IPMI command.
+        Set SEL Time Via IPMI  ${sel_time}
+        # Get SEL Time Command.
+        ${get_sel_time}=  Check Current Date Time Via IPMI
+        # Difference of time between set sel time and get time.
+        ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
+        Should Be True  0<=${difference}<=2
+        # Difference of time between BMC Date and Get SEL Time.
+        ${bmc_time}=  Get Current Date from BMC
+        ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
+        Should Be True  0<=${difference}<=2
+    ELSE
+        FAIL  SEL Time cannot set Date less than 1970
+    END
+
+
+Verify SEL Set Time For Invalid Data Request
+    [Documentation]  Verify IPMI Get SEL Time for invalid data request
+    [Tags]  Verify_SEL_Set_Time_For_Invalid_Data_Request
+    [Setup]  Printn
+    [Teardown]  FFDC On Test Case Fail
+
+    # Gets BMC current date via date command.
+    ${current_date}=  Get Current Date from BMC
+
+    # Gives hexa decimal Raw command data request with the prefix of 0x.
+    ${sel_date_raw}=  Converting Date to HexaDecimal  ${current_date}
+
+    # Set Invalid SEL Time with one extra request byte.
+    ${Set_seltime_invalid}=  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}*
+    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw} 0x00
+    Should Contain  ${Set_seltime_invalid}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]}
+
+
+Verify SEL Set Time For Incomplete Data Request
+    [Documentation]  Verify IPMI Get SEL Time for invalid data with one byte less request data.
+    [Tags]  Verify_SEL_Set_Time_For_Incomplete_Data_Request
+    [Setup]  Printn
+    [Teardown]  FFDC On Test Case Fail
+
+    # Gets BMC current date via date command.
+    ${current_date}=  Get Current Date from BMC
+
+    # Gives hexa decimal raw command data request with the prefix of 0x.
+    ${sel_date_raw}=  Converting Date to HexaDecimal  ${current_date}
+
+    # For data request less than expected byes, remove last byte.
+    ${sel_date_raw}=  Split String  ${sel_date_raw}
+    Remove From List  ${sel_date_raw}  -1
+    ${sel_date_raw}=  Evaluate  " ".join(${sel_date_raw})
+
+    # Set incomplete SEL Time with one less request byte.
+    ${Set_seltime_incomplete}=  Run Keyword and Expect Error  *${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][4]}*
+    ...  Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
+    Should Contain  ${Set_seltime_incomplete}  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][3]}
+
+
+Verify SEL Time In SEL Entry
+    [Documentation]  Verify Configured SEL Time reflects in newly added SEL Entry.
+    [Tags]  Verify_SEL_Time_In_SEL_Entry
+
+    Clear The SEL
+
+   # change to manual, get current time and add future year (here, 5years).
+    ${sel_date}=  Get Specific Sel Date  5
+
+    # Gives hexa decimal raw command data request with the prefix of 0x.
+    ${sel_date_raw}=  Converting Date to HexaDecimal  ${sel_date}
+
+    # Set SEL Entry Command.
+    Set SEL Time Entry Via Raw Command  ${sel_date_raw}
+
+    # Get SEL Time Command.
+    ${get_sel_time}=  Check Current Date Time Via IPMI
+
+    # Identify Time difference and find the difference is less than 6 seconds.
+    # Command execution may happen at the end of millisecond so considered 6 seconds as difference.
+    ${time_difference}=  Get Time Difference  ${get_sel_time}  ${sel_date}
+    Should Be True  0<=${time_difference}<=5
+    ...  msg=Set SEL Time Not Working
+
+    # Get BMC time (native) and compare with set sel time given.
+    ${bmc_time}=  Get Current Date from BMC
+
+    ${difference}=  Get Time Difference  ${bmc_time}  ${sel_date}
+    Should Be True  0<=${difference}<=6
+
+    # Get any Sensor available from Sensor list.
+    ${sensor_name}=  Fetch Any Sensor From Sensor List
+
+    # Get Sensor ID from SDR Get "sensor".
+    ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
+    ${name_sensor}  ${sensor_number}=  Get Data And Byte From SDR Sensor  ${sensor_data1}
+
+    # Get Sensor Type from SDR Get "sensor".
+    ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
+    ${sensor_type}  ${sensor_type_id}=  Get Data And Byte From SDR Sensor  ${sensor_data2}
+
+    # Add SEL Entry.
+    ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
+
+    # Finds the last added sel entry.
+    ${resp}=  Verify Last SEL Added  ${sensor_type}  ${sensor_name}
+
+    # Fetches the date of the last added SEL Entry.
+    ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
+
+    # Identify and find the time difference is less than 60 seconds.
+    # Finding the sensor details and execution may take up to a minute.
+    # Compare  date and time of Set SEL with sel entry.
+    ${d}=  Get Time Difference  ${sel_entry_date}  ${sel_date}
+    Should Be True  0<=${d}<=60
+
+
+Verify SEL Time In SEL Entry For Future Date and Time
+    [Documentation]  Verify configured SEL Time (Future Date & Time) in added SEL Entry.
+    [Tags]  Verify_SEL_Time_In_SEL_Entry_For_Future_Date_and_Time
+
+    Clear The SEL
+
+    # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time.
+    ${sel_time}  ${set_sel_time}=  Identify SEL Time Future DateTime   06:15:00
+
+    # Set SEL Time via IPMI command.
+    Set SEL Time Via IPMI  ${sel_time}
+
+    # Get SEL Time Command.
+    ${get_sel_time}=  Check Current Date Time Via IPMI
+
+    # Difference of time between set sel time and get time.
+    ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
+    Should Be True  0<=${difference}<=2
+
+    # Difference of time between BMC Date and Get SEL Time.
+    ${bmc_time}=  Get Current Date from BMC
+    ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
+    Should Be True  0<=${difference}<=2
+
+    # Get any Sensor available from Sensor list.
+    ${sensor_name}=  Fetch Any Sensor From Sensor List
+
+    # Get Sensor ID from SDR Get "sensor".
+    ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
+    ${name_sensor}  ${sensor_number}=  Get Data And Byte From SDR Sensor  ${sensor_data1}
+
+    # Get Sensor Type from SDR Get "sensor".
+    ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
+    ${sensor_type}  ${sensor_type_id}=  Get Data And Byte From SDR Sensor  ${sensor_data2}
+
+    # Add SEL Entry.
+    ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
+
+    # Finds the last added sel entry.
+    ${resp}=  Verify Last SEL Added  ${sensor_type}  ${sensor_name}
+
+    # Fetches the date of the last added SEL Entry.
+    ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
+
+    # Identify and find the time difference is less than 60 seconds.
+    # Finding the sensor details and execution may take up to a minute.
+    # Compare  date and time of Set SEL with sel entry.
+    ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
+    Should Be True  0<=${d}<=60
+
+
+Verify SEL Time In SEL Entry For Past Date And Time
+    [Documentation]  Verify configured SEL Time (Past Date & Time) in added SEL Entry.
+    [Tags]  Verify_SEL_Time_In_SEL_Entry_For_Past_Date_And_Tine
+
+    Clear The SEL
+
+    # Gets BMC Current Time and subtracts 1 day and sets the SEL Time.
+    ${sel_time}  ${set_sel_time}=  Identify SEL Time DateTime Delay  1d
+
+    ${status}=  Run Keyword And Return Status  Should Not Contain  ${sel_time}  1969
+    ...  msg=Date cannot be less than 1970
+
+    IF  '${status}' == '${TRUE}'
+        # Set SEL Time via IPMI command.
+        Set SEL Time Via IPMI  ${sel_time}
+        # Get SEL Time Command.
+        ${get_sel_time}=  Check Current Date Time Via IPMI
+        # Difference of time between set sel time and get time.
+        ${difference}=  Get Time Difference  ${get_sel_time}  ${set_sel_time}
+        Should Be True  0<=${difference}<=2
+        # Difference of time between BMC Date and Get SEL Time.
+        ${bmc_time}=  Get Current Date from BMC
+        ${difference}=  Get Time Difference  ${get_sel_time}  ${bmc_time}
+        Should Be True  0<=${difference}<=2
+
+        # Get any Sensor available from Sensor list.
+        ${sensor_name}=  Fetch Any Sensor From Sensor List
+        # Get Sensor ID from SDR Get "sensor".
+        ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
+        ${name_sensor}  ${sensor_number}=  Get Data And Byte From SDR Sensor  ${sensor_data1}
+
+        # Get Sensor Type from SDR Get "sensor".
+        ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
+        ${sensor_type}  ${sensor_type_id}=  Get Data And Byte From SDR Sensor  ${sensor_data2}
+
+        # Add SEL Entry.
+        ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
+
+        # Finds the last added sel entry.
+        ${resp}=  Verify Last SEL Added  ${sensor_type}  ${sensor_name}
+
+        # Fetches the date of the last added SEL Entry.
+        ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
+
+        # Identify and find the time difference is less than 60 seconds.
+        # Finding the sensor details and execution may take up to a minute.
+        # Compare  date and time of Set SEL with sel entry.
+        ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
+        Should Be True  0<=${d}<=60
+    ELSE
+        FAIL  SEL Time cannot set Date less than 1970.
+    END
+
+
+Verify Multiple Set SEL Time With Multiple Add SEL Entry
+    [Documentation]  Verify SEL time in multiple addition Of SEL entry.
+    [Tags]  Verify_Multiple_Set_SEL_Time_With_Multiple_Add_SEL_Entry
+
+    # Gets BMC Current Time and Adds 15 minutes and sets the SEL Time.
+    ${sel_time}  ${set_sel_time}=  Identify SEL Time Future DateTime   06:15:00
+
+    FOR  ${i}  IN RANGE  1  6
+
+      # Set SEL Time via IPMI command.
+      Set SEL Time Via IPMI  ${sel_time}
+
+      # Clear the SEL.
+      Clear The SEL
+
+      # Get any Sensor available from Sensor list.
+      ${sensor_name}=  Fetch Any Sensor From Sensor List
+
+      # Get Sensor ID from SDR Get "sensor" and Identify Sensor ID.
+      ${sensor_data1}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor ID
+      ${name_sensor}  ${sensor_number}=  Get Data And Byte From SDR Sensor  ${sensor_data1}
+
+      # Get Sensor Type from SDR Get "sensor" and identify Sensor Type.
+      ${sensor_data2}=  Fetch Sensor Details From SDR  ${sensor_name}  Sensor Type (Threshold)
+      ${sensor_type}  ${sensor_type_id}=  Get Data And Byte From SDR Sensor  ${sensor_data2}
+
+      # Add SEL Entry.
+      ${sel_create_resp}=  Create SEL  ${sensor_type_id}  ${sensor_number}
+
+      # Finds the last added sel entry.
+      ${resp}=  Verify Last SEL Added  ${sensor_type}  ${sensor_name}
+
+      # Fetches the date of the last added SEL Entry.
+      ${sel_entry_date}=  Fetch Added SEL Date  ${resp}
+
+      # Identify and find the time difference is less than 60 seconds.
+      # Finding the sensor details and execution may take up to a minute.
+      # Compare  date and time of Set SEL with sel entry.
+      ${d}=  Get Time Difference  ${sel_entry_date}  ${set_sel_time}
+      Should Be True  ${d}<=60
+
+    END
+
+
+*** Keywords ***
+
+Time Sync Mode Change Through Redfish
+    [Documentation]  Export IP, token and change the time sync to manual.
+    [Arguments]   ${value}
+
+    # Description of argument(s):
+    #    ${value}    can be either ${FALSE} or ${TRUE}
+
+    # May be changed to WebView.
+
+    # Changing Time Sync Mode to Manual.
+    Change Time Sync Mode Via Redfish  ${value}
+
+
+Change Time Sync Mode Via Redfish
+    [Documentation]  To change the time sync mode via Redfish.
+    [Arguments]   ${value}
+
+    # Description of argument(s):
+    #    ${value}    can be either ${FALSE} or ${TRUE}
+
+    # Creates request body for Redfish url.
+    ${mode}=  Create Dictionary  ProtocolEnabled=${value}
+    ${data}=  Create Dictionary  NTP=${mode}
+
+    # Patches the obtained body to the given url.
+    Redfish.patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
+    ...   valid_status_codes=[${HTTP_NO_CONTENT}]
+
+    Sleep  ${NETWORK_RESTART_TIME}
+
+
+Get SEL Time Command
+    [Documentation]  Get SEL Time command.
+
+    # The response will be 8 byte timestamp in hexadecimal.
+    # example: If current date and time is "Wed May  4 18:55:00 UTC 2022",
+    # then, ${get_sel_time} will be "07 cc 72 62".
+    ${get_sel_time}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['SEL_entry']['Get_SEL_Time'][0]}
+
+    [Return]    ${get_sel_time}
+
+
+Set SEL Time Entry Via Raw Command
+    [Documentation]  Set SEL Time command.
+    [Arguments]  ${sel_date_raw}
+
+    # Description of argument(s):
+    #    ${sel_date_raw}     Time to set in hexadecimal bytes.
+    #    Example:
+    #       If date is 1st January 2022 12:30:00 PM,
+    #       the hexadecimal timestamp is, 61D04948.
+    #    then the request bytes are,
+    #    ${sel_date_raw}     0x48 0x49 0xd0 0x61
+
+    Run IPMI Command  ${IPMI_RAW_CMD['SEL_entry']['Set_SEL_Time'][0]} ${sel_date_raw}
+    Sleep  ${NETWORK_RESTART_TIME}
+
+
+Clear The SEL
+    [Documentation]  Clear SEL Command.
+
+    # Clear the SEL.
+    ${out}=  Run IPMI Standard Command  sel clear
+    Should Contain  ${out}  Clearing SEL
+    Sleep  2s
+
+
+Verify Last SEL Added
+    [Documentation]  Verify last SEL added.
+    [Arguments]  ${sensor_type}  ${sensor_name}
+
+    # Description of argument(s):
+    #    ${sensor_type}         Type of the sensor (say Fan, Temp, etc.,).
+    #    ${sensor_name}         Name of the sensor.
+
+    ${resp}=  Run IPMI Standard Command  sel elist last 1
+    Run Keywords  Should Contain  ${resp}  ${sensor_type} ${sensor_name}  AND
+    ...  Should Contain  ${resp}  Asserted  msg=Add SEL Entry failed.
+    Should Not Contain  ${resp}  reset/cleared
+
+    [Return]  ${resp}
+
+
+Check Current Date Time Via IPMI
+    [Documentation]  Verify Current Date and Time Via IPMI user command.
+
+    ${resp}=  Run IPMI Standard Command  sel time get
+    [Return]  ${resp}
+
+
+Get Specific Sel Date
+    [Documentation]  Gets initial time and adds year to the current date and returns future date.
+    [Arguments]  ${year}
+
+    # Description of argument(s):
+    #    ${year}             Can be any number of years (say 5 year).
+
+    ${current_date}=  Get Current Date from BMC
+
+    # Converting given years to days by multiplying with 365days and adding the days to current date.
+    ${days}=  Evaluate  365*${year}+1
+    ${date} =  Add Time To Date  ${current_date}  ${days}d  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
+
+    [Return]   ${date}
+
+
+Converting Date to HexaDecimal
+    [Documentation]  Converting the date into hexa decimal values.
+    [Arguments]  ${date}
+
+    # Description of argument(s):
+    #    ${date}             Can be any date in format %m/%d/%Y %H:%M:%S.
+
+    ${epoch_date}=  Convert Date  ${date}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
+    ${date}=  Convert To Hex  ${epoch_date}  lowercase=yes
+
+    # function calls from utils.py.
+    # Length of the date byte should be 8 so that each bytes are separated.
+    ${date}=  Zfill Data  ${date}  8
+    # To split every two characters to form one byte each.
+    ${date}=  Split String With Index  ${date}  2
+    # Prefix every list index value with 0x.
+    ${date}=  Prefix Bytes  ${date}
+
+    # Reverse the bytes and join the list to form request Time stamp data.
+    Reverse List  ${date}
+    ${date}=  Evaluate  " ".join(${date})
+
+    [Return]  ${date}
+
+
+Get Time Difference
+    [Documentation]  Converting the date into hexa decimal values.
+    [Arguments]  ${date1}  ${date2}
+
+    # Description of argument(s):
+    #    ${date1}             Can be any date in format %m/%d/%Y %H:%M:%S.
+    #    ${date2}             Can be any date in format %m/%d/%Y %H:%M:%S.
+
+    ${epoch_date1}=  Convert Date  ${date1}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
+    ${epoch_date2}=  Convert Date  ${date2}  epoch  exclude_millis=yes  date_format=%m/%d/%Y %H:%M:%S
+
+    ${diff}=  Evaluate  int(${epoch_date1}) - int(${epoch_date2})
+
+    [Return]  ${diff}
+
+
+Identify SEL Time Future DateTime
+    [Documentation]  Identify SEL Time Future DateTime.
+    [Arguments]  ${time}
+
+    # Description of argument(s):
+    #    ${time}             Can be any number of hours or minutes in format %H:%M:%S.
+
+    # Gets BMC current date via date command.
+    ${current_date}=  Get Current Date from BMC
+
+    ${datetime} =  Add Time To Date  ${current_date}  ${time}  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
+
+    #Set SEL Time.
+    ${quoted_date}=  Fetch Date  ${datetime}
+
+    [Return]  ${quoted_date}  ${datetime}
+
+
+Identify SEL Time DateTime Delay
+    [Documentation]  Identify SEL Time DateTime Delay by subtracting given date.
+    [Arguments]  ${days}
+
+    # Description of argument(s):
+    #    ${days}             Can be any days (say 3d).
+
+    # Gets BMC current date via date command.
+    ${current_date}=  Get Current Date from BMC
+
+    ${datetime} =  Subtract Time From Date  ${current_date}  ${days}  result_format=%m/%d/%Y %H:%M:%S  date_format=%m/%d/%Y %H:%M:%S
+
+    # Format the sel time.
+    # function call from lib/utils.py.
+    ${quoted_date}=  Fetch Date  ${datetime}
+
+    [Return]  ${quoted_date}  ${datetime}
+
+
+Set SEL Time Via IPMI
+    [Documentation]  Set SEL Time for given date using IPMI.
+    [Arguments]  ${date_time}
+
+    # Description of argument(s):
+    #    ${date_time}       Can be any date in format %m/%d/%Y %H:%M:%S.
+
+    ${resp}=  Run IPMI Standard Command  sel time set "${date_time}"
+    Should Not Contain  ${resp}  Unspecified error
+
+
+Test Setup Execution
+    [Documentation]  Test Setup Execution.
+
+    Redfish.Login
+    # Change timesync mode to manual with timeout as per resource.robot.
+    Time Sync Mode Change Through Redfish   ${FALSE}
+    Sleep  ${NETWORK_TIMEOUT}
+
+
+Test Teardown Execution
+    [Documentation]  For execution of Test teardown.
+
+    Clear The SEL
+
+    # Change TimeSync mode to NTP with Timeout as per default resource.robot.
+    Time Sync Mode Change Through Redfish  ${TRUE}
+    Sleep  ${NETWORK_TIMEOUT}
+    Redfish.Logout
+    FFDC On Test Case Fail
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 282a3bb..1a1a458 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -434,3 +434,104 @@
         Run IPMI Standard Command   user set name ${user_record['user_id']} ""
         Sleep  5s
     END
+
+
+Create SEL
+    [Documentation]  Create a SEL.
+    [Arguments]  ${sensor_type}  ${sensor_number}
+
+    # Create a SEL.
+    # Example:
+    # a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 |  | Asserted
+
+    # Description of argument(s):
+    #    ${sensor_type}            Type of the sensor used in hexadecimal (can be fan, temp etc.,),
+    #                              obtained from Sensor Type field in - ipmitool sdr get "sensor_name".
+    #                              Example: Sensor Type (Threshold) : Fan (0x04), here 0xHH is sensor type.
+
+    #    ${sensor_number}          Sensor number of the sensor in hexadecimal.
+    #                              obtained from Sensor ID field in - ipmitool sdr get "sensor_name".
+    #                              Example: Sensor ID : SENSOR_1 (0xHH), here 0xHH is sensor number.
+
+    ${resp}=  Run IPMI Command
+    ...  ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][0]} 0x${sensor_type} 0x${sensor_number} ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][1]}
+
+    [Return]  ${resp}
+
+
+Fetch Any Sensor From Sensor List
+    [Documentation]  Find any sensor name randomly from Sensor list.
+
+    ${resp}=  Run IPMI Standard Command  sensor
+
+    # Find total number of sensor.
+    ${data}=  Split To Lines  ${resp}
+    ${length}=  Get Length  ${data}
+
+    # Identify any one sensor.
+    ${sensor_index}=  Evaluate  random.randint(1, ${length})  modules=random
+    ${sensor_data}=  Set Variable  ${data[${sensor_index}-1]}
+    ${sensor}=  Split String  ${sensor_data}  |
+
+    # Retrieve Sensor Name and return.
+    ${sensor_name}=  Set Variable  ${sensor[0]}
+    ${sensor_name}=  Remove Whitespace  ${sensor_name}
+
+    [Return]  ${sensor_name}
+
+
+Fetch Sensor Details From SDR
+    [Documentation]  Identify the sensors from sdr get and fetch sensor details required.
+    [Arguments]  ${sensor_name}  ${setting}
+
+    # Description of argument(s):
+    #    ${sensor_number}        Sensor number of the sensor in hexadecimal.
+    #                            obtained sensor name from - 'ipmitool sensor' command.
+    #                            Example: a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 |  | Asserted
+    #                            here, a is the sensor name.
+
+    #    ${setting}              Field to fetch data. Example : Sensor ID, Sensor Type (Threshold), etc,.
+
+    ${resp}=  Run IPMI Standard Command  sdr get "${sensor_name}"
+
+    ${setting_line}=  Get Lines Containing String  ${resp}  ${setting}
+    ...  case-insensitive
+    ${setting_status}=  Fetch From Right  ${setting_line}  :${SPACE}
+
+    [Return]  ${setting_status}
+
+
+Get Data And Byte From SDR Sensor
+    [Documentation]  Fetch the Field Data and hexadecimal values from given details.
+    [Arguments]  ${sensor_detail}
+
+    # Description of argument(s):
+    #    ${sensor_detail}      Requested field and the value from the sdr get ipmi command.
+    #                          Example : if Sensor ID is the requesting setting, then,
+    #                          ${sensor_detail} will be "Sensor ID : SENSOR_1 (0xHH)"
+
+    ${sensor_detail}=  Split String  ${sensor_detail}  (0x
+    ${field_data}=  Set Variable  ${sensor_detail[0]}
+    ${field_data}=  Remove Whitespace  ${field_data}
+    ${sensor_hex}=  Replace String  ${sensor_detail[1]}  )  ${EMPTY}
+    ${sensor_hex}=  Zfill Data  ${sensor_hex}  2
+
+    [Return]  ${field_data}  ${sensor_hex}
+
+
+Get Current Date from BMC
+    [Documentation]  Runs the date command from BMC and returns current date and time
+
+    # Get Current Date from BMC
+    ${date}  ${stderr}  ${rc}=  BMC Execute Command   date
+
+    # Split the string and remove first and 2nd last value from the list and join to form %d %b %H:%M:%S %Y date format
+    ${date}=  Split String  ${date}
+    Remove From List  ${date}  0
+    Remove From List  ${date}  -2
+    ${date}=  Evaluate  " ".join(${date})
+
+    # Convert the date format to %m/%d/%Y %H:%M:%S
+    ${date}=  Convert Date  ${date}  date_format=%b %d %H:%M:%S %Y  result_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
+
+    [Return]   ${date}
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index a23e9e5..af5ee6d 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -715,3 +715,47 @@
     result = vf.key_value_outbuf_to_dict(ret_values, process_indent=1)
 
     return result
+
+
+def fetch_date(date):
+    r"""
+    Removes prefix 0 in a date in given date
+
+    Example : 08/12/2021 then returns 8/12/2021
+    """
+
+    date = date.lstrip("0")
+    return date
+
+
+def fetch_added_sel_date(entry):
+    r"""
+    Split sel entry string with with | and join only the date with space
+
+    Example : If entry given is, "a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 |  | Asserted"
+    Then the result will be "02/14/2020 01:16:58"
+    """
+
+    temp = entry.split(" | ")
+    date = temp[1] + " " + temp[2]
+    print(date)
+    return date
+
+
+def prefix_bytes(listx):
+    r"""
+    prefixes byte strings in list
+
+    Example:
+    ${listx} = ['01', '02', '03']
+    ${listx}=  Prefix Bytes  ${listx}
+    then,
+    ${listx}= ['0x01', '0x02', '0x03']
+
+    """
+
+    listy = []
+    for item in listx:
+        item = "0x" + item
+        listy.append(item)
+    return listy
diff --git a/lib/utils.py b/lib/utils.py
index 20dbef1..40bcf83 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -411,3 +411,44 @@
 
     stdout, stderr, rc = bsu.bmc_execute_command(option_string, **bsu_options)
     return stdout
+
+
+def split_string_with_index(stri, n):
+    r"""
+    To split every n characters and forms an element for every nth index
+
+    Example : Given ${stri} = "abcdef", then the function call,
+    ${data}=  Split List With Index  ${stri}  2
+    then, result will be data = ['ab', 'cd', 'ef']
+    """
+
+    n = int(n)
+    data = [stri[index: index + n] for index in range(0, len(stri), n)]
+    return data
+
+
+def remove_whitespace(instring):
+    r"""
+    Removes the white spaces around the string
+
+    Example: instring = "  xxx  ", then returns instring = "xxx"
+    """
+
+    return instring.strip()
+
+
+def zfill_data(data, num):
+    r"""
+    zfill() method adds zeros (0) at the beginning of the string, until it reaches the specified length.
+
+    Usage : ${anystr}=  Zfill Data  ${data}  num
+
+    Example : Binary of one Byte has 8 bits - xxxx xxxx
+
+    Consider ${binary} has only 3 bits after converting from Hexadecimal/decimal to Binary
+    Say ${binary} = 110 then,
+    ${binary}=  Zfill Data  ${binary}  8
+    Now ${binary} will be 0000 0110
+    """
+
+    return data.zfill(int(num))