blob: eea89e4e5a25d1cd3463e592524ee5ad9929672d [file] [log] [blame]
Prashanth Kattif59a73e2021-09-22 03:03:58 -05001*** Settings ***
2
3Documentation Protocol settings utilities keywords.
4
5Resource ../lib/resource.robot
6Resource ../lib/utils.robot
7
8
Megha G N903ebe92023-09-07 00:47:07 -05009*** Variables ***
10
11${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD}
12
13
Prashanth Kattif59a73e2021-09-22 03:03:58 -050014*** Keywords ***
15
16Enable SSH Protocol
17 [Documentation] Enable or disable SSH protocol.
18 [Arguments] ${enable_value}=${True}
19
20 # Description of argument(s}:
21 # enable_value Enable or disable SSH, e.g. (true, false).
22
23 ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value}
24 ${data}= Create Dictionary SSH=${ssh_state}
25
26 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
27 ... valid_status_codes=[${HTTP_NO_CONTENT}]
28
29 # Wait for timeout for new values to take effect.
30 Sleep ${NETWORK_TIMEOUT}s
31
32
33Verify SSH Login And Commands Work
34 [Documentation] Verify if SSH connection works and able to run command on SSH session.
Sweta Potthuri79ba8a22024-09-25 04:09:45 -050035 [Arguments] ${host}=${OPENBMC_HOST}
Prashanth Kattif59a73e2021-09-22 03:03:58 -050036 [Teardown] Close All Connections
37
Sweta Potthuri79ba8a22024-09-25 04:09:45 -050038 # Description of argument(s}:
39 # host OPENBMC_HOST, OPENBMC_HOST_1, Use eth0 as the default interface
Prashanth Kattif59a73e2021-09-22 03:03:58 -050040
Sweta Potthuri79ba8a22024-09-25 04:09:45 -050041 # Check if we can open SSH connection and login.
42 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${host}
Prashanth Kattif59a73e2021-09-22 03:03:58 -050043 # Check if we can run command successfully on SSH session.
44 BMC Execute Command /sbin/ip addr
45
46
47Verify SSH Protocol State
48 [Documentation] verify SSH protocol state.
49 [Arguments] ${state}=${True}
50
51 # Description of argument(s}:
52 # state Enable or disable SSH, e.g. (true, false)
53
54 # Sample output:
55 # {
ganesanb4d430282023-04-27 14:33:23 +000056 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol",
Prashanth Kattif59a73e2021-09-22 03:03:58 -050057 # "@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol",
58 # "Description": "Manager Network Service",
59 # "FQDN": "bmc",
60 # "HTTP": {
61 # "Port": 0,
62 # "ProtocolEnabled": false
63 # },
64 # "HTTPS": {
65 # "Certificates": {
ganesanb4d430282023-04-27 14:33:23 +000066 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol/HTTPS/Certificates"
Prashanth Kattif59a73e2021-09-22 03:03:58 -050067 # },
68 # "Port": xxx,
69 # "ProtocolEnabled": true
70 # },
71 # "HostName": "xxxxbmc",
72 # "IPMI": {
73 # "Port": xxx,
74 # "ProtocolEnabled": true
75 # },
76 # "Id": "NetworkProtocol",
77 # "NTP": {
78 # "NTPServers": [
79 # "xx.xx.xx.xx",
80 # "xx.xx.xx.xx",
81 # "xx.xx.xx.xx"
82 # ],
83 # "ProtocolEnabled": true
84 # },
85 # "Name": "Manager Network Protocol",
86 # "SSH": {
87 # "Port": xx,
88 # "ProtocolEnabled": true
89 # },
90 # "Status": {
91 # "Health": "OK",
92 # "HealthRollup": "OK",
93 # "State": "Enabled"
94 # }
95
96 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
97 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state}
98 ... msg=Protocol states are not matching.
99
100
101Enable IPMI Protocol
102 [Documentation] Enable or disable IPMI protocol.
103 [Arguments] ${enable_value}=${True}
104
105 # Description of argument(s}:
106 # enable_value Enable or disable IPMI, e.g. (true, false).
107
108 ${ipmi_state}= Create Dictionary ProtocolEnabled=${enable_value}
109 ${data}= Create Dictionary IPMI=${ipmi_state}
110
111 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
112 ... valid_status_codes=[${HTTP_NO_CONTENT}]
113
114 # Wait for timeout for new values to take effect.
115 Sleep ${NETWORK_TIMEOUT}s
116
117
Nandakumar Babu7ad35ec2025-12-03 16:17:42 +0530118Enable NTP Protocol
119 [Documentation] Enable or disable NTP protocol.
120 [Arguments] ${enable_value}=${True}
121
122 # Description of argument(s}:
123 # enable_value Enable or disable NTP, e.g. (true, false).
124
125 ${ntp_state}= Create Dictionary ProtocolEnabled=${enable_value}
126 ${data}= Create Dictionary NTP=${ntp_state}
127
128 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
129 ... valid_status_codes=[${HTTP_NO_CONTENT}]
130
131 # Wait for timeout for new values to take effect.
132 Sleep ${NETWORK_TIMEOUT}s
133
134
Prashanth Kattif59a73e2021-09-22 03:03:58 -0500135Verify IPMI Works
136 [Documentation] Run IPMI command and return status.
137 [Arguments] ${sub_cmd} ${host}=${OPENBMC_HOST}
138
139 # Description of argument(s):
140 # host BMC host name or IP address.
141 # sub_cmd The IPMI command string to be executed.
142
143 ${rc}= Run And Return Rc ${cmd_prefix} -H ${host} ${sub_cmd}
144 Should Be Equal As Strings ${rc} 0
145 ... msg=IPMI is not enabled and commands are failing.
146
147
148Verify IPMI Protocol State
149 [Documentation] Verify IPMI protocol state.
150 [Arguments] ${state}=${True}
151
152 # Description of argument(s}:
153 # state Enable or disable IPMI, e.g. (true, false)
154
155 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
156 Should Be Equal As Strings ${resp.dict['IPMI']['ProtocolEnabled']} ${state}
157 ... msg=Protocol states are not matching.
Nandakumar Babu7ad35ec2025-12-03 16:17:42 +0530158
159
160Verify NTP Protocol State
161 [Documentation] verify NTP protocol state.
162 [Arguments] ${state}=${True}
163
164 # Description of argument(s}:
165 # state Enable or disable NTP, e.g. (true, false)
166
167 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
168 Should Be Equal As Strings ${resp.dict['NTP']['ProtocolEnabled']} ${state}
169 ... msg=Protocol states are not matching.