1*** Settings ***
2Documentation  BMC OEM serial update utilities keywords.
3
4Resource    code_update_utils.robot
5Resource    oem/ibm/serial_console_client.robot
6
7*** Keywords ***
8
9Reset Network Interface During Code Update
10    [Documentation]  Disable and re-enable the network while doing code update.
11    [Arguments]  ${image_file_path}  ${reboot}
12
13    # Resetting the network will be done via the serial console.
14    #
15    # Description of argument(s):
16    # image_file_path   Path to the image file to update to.
17    # reboot            If set to true, will reboot the BMC after the code
18    #                   update is finished.
19
20    ${version_id}=  Upload And Activate Image  ${image_file_path}  wait=${0}
21    Reset Network Interface
22
23    # Verify code update was successful and 'Activation' state is 'Active'.
24    Wait For Activation State Change  ${version_id}  ${ACTIVATING}
25    ${software_state}=  Read Properties  ${SOFTWARE_VERSION_URI}${version_id}
26    Should Be Equal As Strings  &{software_state}[Activation]  ${ACTIVE}
27
28    Run Keyword If  '${reboot}'  OBMC Reboot (off)  stack_mode=normal
29
30
31Reset Network Interface
32    [Documentation]  Turn the ethernet network interface off and then on again
33    ...              through the serial console.
34
35    Import Resource  ${CURDIR}/oem/ibm/serial_console_client.robot
36    Set Library Search Order  SSHLibrary  Telnet
37    Execute Command On Serial Console  ifconfig eth0 down
38    Sleep  30s
39    Execute Command On Serial Console  ifconfig eth0 up
40