xref: /openbmc/openbmc-test-automation/lib/serial_connection/serial_console_client.robot (revision a4e62f3ff3a51b543ccbb2e2be50769082bd4ddd)
1217402feSSteven Sombar*** Settings ***
2217402feSSteven SombarDocumentation     Module for capturing BMC serial output
3217402feSSteven Sombar
4217402feSSteven SombarLibrary           Telnet  newline=LF
5217402feSSteven SombarLibrary           OperatingSystem
6217402feSSteven SombarLibrary           Collections
7217402feSSteven SombarLibrary           String
8217402feSSteven Sombar
9217402feSSteven Sombar
10217402feSSteven Sombar*** Keywords ***
11217402feSSteven Sombar
12217402feSSteven SombarOpen Telnet Connection To BMC Serial Console
13217402feSSteven Sombar    [Documentation]   Open telnet connection session to BMC serial console
14217402feSSteven Sombar    ...               The login prompt expected, for example, for Witherspoon
15217402feSSteven Sombar    ...               is "Witherspoon login:".
16217402feSSteven Sombar    [Arguments]   ${i_host}=${OPENBMC_SERIAL_HOST}
17217402feSSteven Sombar    ...           ${i_port}=${OPENBMC_SERIAL_PORT}
18217402feSSteven Sombar    ...           ${i_model}=${OPENBMC_MODEL}
19217402feSSteven Sombar
20217402feSSteven Sombar    # Description of argument(s):
21217402feSSteven Sombar    # i_host    The host name or IP of the serial console.
22217402feSSteven Sombar    # i_port    The port of the serial console.
23217402feSSteven Sombar    # i_model   The path to the system data, i.e. "./data/Witherspoon.py".
24217402feSSteven Sombar
25*a4e62f3fSTony Lee    ${prompt_string}=  Convert To Lowercase  ${i_model} login:
26217402feSSteven Sombar    Telnet.Open Connection
27217402feSSteven Sombar    ...  ${i_host}  port=${i_port}  prompt=#
28217402feSSteven Sombar    Telnet.Set Timeout  30 seconds
29217402feSSteven Sombar    Telnet.Set Newline  \n
30217402feSSteven Sombar    Telnet.Set Newline  CRLF
31217402feSSteven Sombar    Telnet.Write  \n
32217402feSSteven Sombar    Telnet.Write  exit
33217402feSSteven Sombar    Telnet.Write  \n
34217402feSSteven Sombar    Telnet.Read Until Regexp  (Password:|logout)
35217402feSSteven Sombar    Telnet.Write  \n
36217402feSSteven Sombar    Telnet.Read Until  ${prompt_string}
37217402feSSteven Sombar    Telnet.Write  ${OPENBMC_USERNAME}
38217402feSSteven Sombar    Telnet.Write  \n
39217402feSSteven Sombar    Telnet.Read Until  Password:
40217402feSSteven Sombar    Telnet.Write  ${OPENBMC_PASSWORD}
41217402feSSteven Sombar    Telnet.Write  \n
42217402feSSteven Sombar    Telnet.Read Until Prompt
43217402feSSteven Sombar    Telnet.Set Timeout  30 minute 30 seconds
44217402feSSteven Sombar
45217402feSSteven Sombar
46217402feSSteven SombarRead And Log BMC Serial Console Output
47217402feSSteven Sombar    [Documentation]    Reads everything that is currently available
48217402feSSteven Sombar    ...                in the output.
49217402feSSteven Sombar
50217402feSSteven Sombar    ${bmc_serial_log}=   Telnet.Read
51217402feSSteven Sombar    Log   ${bmc_serial_log}
52217402feSSteven Sombar
53217402feSSteven Sombar
54217402feSSteven SombarExecute Command On Serial Console
55217402feSSteven Sombar    [Documentation]  Execute a command on the BMC serial console.
56217402feSSteven Sombar    [Arguments]  ${command_string}
57217402feSSteven Sombar
58217402feSSteven Sombar    # Description of argument(s):
59217402feSSteven Sombar    # command   The command to execute on the BMC.
60217402feSSteven Sombar
61217402feSSteven Sombar    Open Telnet Connection To BMC Serial Console
62217402feSSteven Sombar    Telnet.Write  \n
63217402feSSteven Sombar    Telnet.Write  \n
64217402feSSteven Sombar    Telnet.Execute Command  ${command_string}
65217402feSSteven Sombar    Read And Log BMC Serial Console Output
66217402feSSteven Sombar    Close Serial Console Connection
67217402feSSteven Sombar
68217402feSSteven Sombar
69217402feSSteven SombarClose Serial Console Connection
70217402feSSteven Sombar    [Documentation]  Log out of the BMC and close telnet.
71217402feSSteven Sombar
72217402feSSteven Sombar    Telnet.Write  \n
73217402feSSteven Sombar    Telnet.Write  exit
74217402feSSteven Sombar    Telnet.Close Connection
75