blob: d6be5a9a54a49b69e98442164d34380b8407c895 [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
118Verify IPMI Works
119 [Documentation] Run IPMI command and return status.
120 [Arguments] ${sub_cmd} ${host}=${OPENBMC_HOST}
121
122 # Description of argument(s):
123 # host BMC host name or IP address.
124 # sub_cmd The IPMI command string to be executed.
125
126 ${rc}= Run And Return Rc ${cmd_prefix} -H ${host} ${sub_cmd}
127 Should Be Equal As Strings ${rc} 0
128 ... msg=IPMI is not enabled and commands are failing.
129
130
131Verify IPMI Protocol State
132 [Documentation] Verify IPMI protocol state.
133 [Arguments] ${state}=${True}
134
135 # Description of argument(s}:
136 # state Enable or disable IPMI, e.g. (true, false)
137
138 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
139 Should Be Equal As Strings ${resp.dict['IPMI']['ProtocolEnabled']} ${state}
140 ... msg=Protocol states are not matching.