1*** Settings ***
2Documentation   This program performs Factory data reset.
3
4Resource        ../lib/ipmi_client.robot
5Resource        ../lib/utils.robot
6Resource        ../lib/connection_client.robot
7Resource        ../lib/oem/ibm/serial_console_client.robot
8Library         OperatingSystem
9
10Suite Setup      Validate Setup
11Suite Teardown   Close All Connections
12
13*** Test Cases ***
14
15Verify Factory Reset
16    [Documentation]  Factory reset the system and verify if BMC is online.
17    [Tags]  Verify_Factory_Reset
18
19    # Factory reset erases user config settings which incldes IP, netmask
20    # gateway and route. Before running this test we are checking all these
21    # settings and checking whether ping works with BMC host.
22    # If factory reset is successful, ping to BMC host should fail as
23    # IP address is erased and comes up with zero_conf.
24
25    Erase All Settings
26    ${status}=  Run Keyword And Return Status  Ping Host  ${OPENBMC_HOST}
27    Should Be Equal  ${status}  False  msg=Factory reset failed.
28
29Revert to Initial Setup And Verify
30    [Documentation]  Revert to old setup.
31    [Tags]  Revert_to_Initial_Setup_And_Verify
32
33    # This test case restores old settings Viz IP address, netmask, gateway
34    # and route. Restoring is done through serial port console.
35    # If reverting to initial setup is successful, ping to BMC
36    # host should pass.
37
38    Configure Initial Settings
39    Ping Host  ${OPENBMC_HOST}
40
41*** Keywords ***
42
43Validate Setup
44    [Documentation]  Validate setup.
45
46    Open Connection And Log In
47
48    # Check whether gateway IP is reachable.
49    Ping Host  ${GW_IP}
50    Should Not Be Empty  ${NET_MASK}  msg=Netmask not provided.
51
52    # Check whether serial console IP is reachable and responding
53    # to telnet command.
54    Open Telnet Connection to BMC Serial Console
55
56Erase All Settings
57    [Documentation]  Factory reset the system.
58
59    Run Dbus IPMI Raw Command  0x32 0xBA 00 00
60    Run Dbus IPMI Raw Command  0x32 0x66
61