1*** Settings ***
2Documentation     Module for capturing BMC serial output
3
4Library           Telnet  newline=LF
5Library           OperatingSystem
6Library           Collections
7Library           String
8
9
10*** Keywords ***
11
12Open Telnet Connection To BMC Serial Console
13    [Documentation]   Open telnet connection session to BMC serial console
14    ...               The login prompt expected, for example, for Witherspoon
15    ...               is "Witherspoon login:".
16    [Arguments]   ${i_host}=${OPENBMC_SERIAL_HOST}
17    ...           ${i_port}=${OPENBMC_SERIAL_PORT}
18    ...           ${i_model}=${OPENBMC_MODEL}
19
20    # Description of argument(s):
21    # i_host    The host name or IP of the serial console.
22    # i_port    The port of the serial console.
23    # i_model   The path to the system data, i.e. "./data/Witherspoon.py".
24
25    ${prompt_string}=  Convert To Lowercase  ${OPENBMC_MODEL} login:
26    Telnet.Open Connection
27    ...  ${i_host}  port=${i_port}  prompt=#
28    Telnet.Set Timeout  30 seconds
29    Telnet.Set Newline  \n
30    Telnet.Set Newline  CRLF
31    Telnet.Write  \n
32    Telnet.Write  exit
33    Telnet.Write  \n
34    Telnet.Read Until Regexp  (Password:|logout)
35    Telnet.Write  \n
36    Telnet.Read Until  ${prompt_string}
37    Telnet.Write  ${OPENBMC_USERNAME}
38    Telnet.Write  \n
39    Telnet.Read Until  Password:
40    Telnet.Write  ${OPENBMC_PASSWORD}
41    Telnet.Write  \n
42    Telnet.Read Until Prompt
43    Telnet.Set Timeout  30 minute 30 seconds
44
45
46Read And Log BMC Serial Console Output
47    [Documentation]    Reads everything that is currently available
48    ...                in the output.
49
50    ${bmc_serial_log}=   Telnet.Read
51    Log   ${bmc_serial_log}
52
53
54Execute Command On Serial Console
55    [Documentation]  Execute a command on the BMC serial console.
56    [Arguments]  ${command_string}
57
58    # Description of argument(s):
59    # command   The command to execute on the BMC.
60
61    Open Telnet Connection To BMC Serial Console
62    Telnet.Write  \n
63    Telnet.Write  \n
64    Telnet.Execute Command  ${command_string}
65    Read And Log BMC Serial Console Output
66    Close Serial Console Connection
67
68
69Close Serial Console Connection
70    [Documentation]  Log out of the BMC and close telnet.
71
72    Telnet.Write  \n
73    Telnet.Write  exit
74    Telnet.Close Connection
75