blob: 3943236f153e4d8477b51127e4f5d9e36a7356a7 [file] [log] [blame]
George Keishingbbfc3942018-09-19 10:15:48 -05001*** Settings ***
2Documentation Remote syslog utilities keywords.
3
4Resource ../lib/resource.txt
5Resource ../lib/rest_client.robot
6Resource ../lib/utils.robot
7
8*** Keywords ***
9
10Configure Remote Log Server With Parameters
11 [Documentation] Configure the remote logging server on BMC.
12 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
13 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
14
15 # Description of argument(s):
16 # remote_host The host name or IP address of the remote logging server
17 # (e.g. "xx.xx.xx.xx").
18 # remote_port Remote ryslog server port number (e.g. "514").
19
20 # Example:
21 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
22 # Response code:200, Content:{
23 # "data": {
24 # "Address": "xx.xx.xx.xx",
25 # "Port": 514
26 # },
27 # "message": "200 OK",
28 # "status": "ok"
29 # }
30
31 ${host_dict}= Create Dictionary data=${remote_host}
32 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
33 ... verify=${TRUE} expected_value=${remote_host}
34
35 # TODO: From Dev to do bump up restart service time and bulk address and
36 # port update API.
37 # Reference: https://github.com/ibm-openbmc/dev/issues/59
George Keishing5e5f1782018-09-28 11:05:59 -050038 Sleep 20s
George Keishingbbfc3942018-09-19 10:15:48 -050039
40 ${remote_port}= Convert To Integer ${remote_port}
41 ${port_dict}= Create Dictionary data=${remote_port}
42 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
43 ... verify=${TRUE} expected_value=${remote_port}
44
45 # TODO: From Dev to do bump up restart service time and bulk address and
46 # port update API.
47 # Reference: https://github.com/ibm-openbmc/dev/issues/59
George Keishing5e5f1782018-09-28 11:05:59 -050048 Sleep 20s
George Keishingbbfc3942018-09-19 10:15:48 -050049
50
51Configure Remote Log Server
52 [Documentation] Configure the remote logging server on BMC.
53 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
54 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
55
56 # Description of argument(s):
57 # remote_host The host name or IP address of the remote logging server
58 # (e.g. "xx.xx.xx.xx").
59 # remote_port Remote ryslog server port number (e.g. "514").
60
61 @{remote_parm_list}= Create List ${remote_host} ${remote_port}
62
63 ${data}= Create Dictionary data=@{remote_parm_list}
64
65 ${resp}= OpenBMC Post Request
66 ... ${REMOTE_LOGGING_CONFIG_URI}/action/remote data=${data}
67
68 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
69
70
71Verify Rsyslog Config On BMC
72 [Documentation] Check if the rsyslog configuration on BMC is correct.
73 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
74 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
75
76 # Description of argument(s):
77 # remote_host The host name or IP address of the remote logging server
78 # (e.g. "xx.xx.xx.xx").
79 # remote_port Remote ryslog server port number (e.g. "514").
80
81 # Example:
82 # Configured:
George Keishing96904c42018-09-20 09:25:30 -050083 # *.* @@xx.xx.xx.xx:514root@bmchostname
George Keishingbbfc3942018-09-19 10:15:48 -050084 # By default:
85 # #*.* @@remote-host:port
86
87 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
88 ... cat /etc/rsyslog.d/server.conf
89
90 ${config}= Catenate @@${remote_host}:${remote_port}
91
92 Should Contain ${ryslog_conf} ${config}
93 ... msg=${remote_host} and ${remote_port} are not configured.
94
95
96Remote Logging Server Execute Command
97 [Documentation] Login to remote logging server.
98 [Arguments] ${command}
99 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
100 ... ${username}=${REMOTE_USERNAME}
101 ... ${password}=${REMOTE_PASSWORD}
102
103 # Description of argument(s):
104 # command Command line string.
105 # remote_host The host name or IP address of the remote logging server
106 # (e.g. "xx.xx.xx.xx").
107 # username Remote rsyslog server user name.
108 # password Remote rsyslog server password.
109
110 ${remote_dict}= Create Dictionary host=${remote_host}
111 Open Connection And Log In ${username} ${password}
112 ... &{remote_dict}
113 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
114 Should Be Empty ${stderr}
115 [Return] ${stdout}
116
117
118Get Remote Log Server Configured
119 [Documentation] Check that remote logging server is not configured.
120
121 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
122 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
123
124 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
125 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
126 Should Not Be Equal ${port} ${port_number}