blob: 4ed1479369a62ea48b1bcbb993b465f4e1a11cd2 [file] [log] [blame]
George Keishingbbfc3942018-09-19 10:15:48 -05001*** Settings ***
2Documentation Remote syslog utilities keywords.
3
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06004Resource ../lib/resource.robot
George Keishingbbfc3942018-09-19 10:15:48 -05005Resource ../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
George Keishing5e5f1782018-09-28 11:05:59 -050035 Sleep 20s
George Keishingbbfc3942018-09-19 10:15:48 -050036
37 ${remote_port}= Convert To Integer ${remote_port}
38 ${port_dict}= Create Dictionary data=${remote_port}
39 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
40 ... verify=${TRUE} expected_value=${remote_port}
41
George Keishing5e5f1782018-09-28 11:05:59 -050042 Sleep 20s
George Keishingbbfc3942018-09-19 10:15:48 -050043
44
45Configure Remote Log Server
46 [Documentation] Configure the remote logging server on BMC.
47 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
48 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
49
50 # Description of argument(s):
51 # remote_host The host name or IP address of the remote logging server
52 # (e.g. "xx.xx.xx.xx").
53 # remote_port Remote ryslog server port number (e.g. "514").
54
55 @{remote_parm_list}= Create List ${remote_host} ${remote_port}
56
57 ${data}= Create Dictionary data=@{remote_parm_list}
58
59 ${resp}= OpenBMC Post Request
60 ... ${REMOTE_LOGGING_CONFIG_URI}/action/remote data=${data}
61
62 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
63
64
65Verify Rsyslog Config On BMC
66 [Documentation] Check if the rsyslog configuration on BMC is correct.
67 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
68 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
69
70 # Description of argument(s):
71 # remote_host The host name or IP address of the remote logging server
72 # (e.g. "xx.xx.xx.xx").
73 # remote_port Remote ryslog server port number (e.g. "514").
74
75 # Example:
76 # Configured:
George Keishing96904c42018-09-20 09:25:30 -050077 # *.* @@xx.xx.xx.xx:514root@bmchostname
George Keishingbbfc3942018-09-19 10:15:48 -050078 # By default:
79 # #*.* @@remote-host:port
80
81 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
82 ... cat /etc/rsyslog.d/server.conf
83
84 ${config}= Catenate @@${remote_host}:${remote_port}
85
86 Should Contain ${ryslog_conf} ${config}
87 ... msg=${remote_host} and ${remote_port} are not configured.
88
89
90Remote Logging Server Execute Command
91 [Documentation] Login to remote logging server.
92 [Arguments] ${command}
93 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
94 ... ${username}=${REMOTE_USERNAME}
95 ... ${password}=${REMOTE_PASSWORD}
96
97 # Description of argument(s):
98 # command Command line string.
99 # remote_host The host name or IP address of the remote logging server
100 # (e.g. "xx.xx.xx.xx").
101 # username Remote rsyslog server user name.
102 # password Remote rsyslog server password.
103
104 ${remote_dict}= Create Dictionary host=${remote_host}
105 Open Connection And Log In ${username} ${password}
106 ... &{remote_dict}
107 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
108 Should Be Empty ${stderr}
109 [Return] ${stdout}
110
111
112Get Remote Log Server Configured
113 [Documentation] Check that remote logging server is not configured.
114
115 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
116 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
117
118 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
119 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
120 Should Not Be Equal ${port} ${port_number}