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