1*** Settings ***
2Documentation   Factory reset BMC and set the network config back.
3
4# robot -v OPENBMC_HOST:xx.xx.xx.233 -v SUBNET_MASK:22 -v BMC_GW:xx.xx.xx.1
5# -v OPENBMC_SERIAL_HOST:xx.xx.xx.152 -v OPENBMC_SERIAL_PORT:2002
6# -v OPENBMC_MODEL:witherspoon factory_reset.robot
7
8Resource     ../lib/resource.robot
9Resource     ../lib/serial_connection/serial_console_client.robot
10Library      ../lib/bmc_ssh_utils.py
11
12Test Setup   Test Setup Execution
13
14*** Variables ***
15
16${CMD_STATIC_IPV4_PREFIX}    busctl call  xyz.openbmc_project.Network
17...  /xyz/openbmc_project/network/eth0 xyz.openbmc_project.Network.IP.Create IP
18...  ssys "xyz.openbmc_project.Network.IP.Protocol.IPv4"
19
20${CMD_STATIS_GW_PREFIX}      busctl set-property xyz.openbmc_project.Network
21...  /xyz/openbmc_project/network/config
22...  xyz.openbmc_project.Network.SystemConfiguration DefaultGateway s
23
24
25*** Test Cases ***
26
27Factory Reset BMC
28    [Documentation]  Factory reset BMC and verify BMC comes back online.
29
30    BMC Execute Command  /usr/bin/hostnamectl set-hostname ${OPENBMC_MODEL}
31    BMC Execute Command  /sbin/fw_setenv rwreset true
32    Execute Command On Serial Console  reboot -f
33
34    Sleep  4min
35
36    ${cmd_ip}=  Catenate  ${CMD_STATIC_IPV4_PREFIX} ${OPENBMC_HOST}
37    ...  ${SUBNET_MASK} ${BMC_GW}
38    Execute Command On Serial Console  ${cmd_ip}
39
40    ${cmd_gw}=  Catenate  ${CMD_STATIS_GW_PREFIX}  ${BMC_GW}
41    Execute Command On Serial Console  ${cmd_gw}
42
43
44*** Keywords ***
45
46Test Setup Execution
47    [Documentation]  Check if parameters are provided.
48    Should Not Be Empty   ${OPENBMC_SERIAL_HOST}
49    Should Not Be Empty   ${OPENBMC_SERIAL_PORT}
50    Should Not Be Empty   ${OPENBMC_MODEL}
51    Should Not Be Empty   ${SUBNET_MASK}
52    Should Not Be Empty   ${BMC_GW}
53