blob: cb56c3df7905ad335494037cd6c9cb56f49c7b45 [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.
35 [Teardown] Close All Connections
36
37 # Check if we can open SSH connection and login.
38 Open Connection And Login
39
40 # Check if we can run command successfully on SSH session.
41 BMC Execute Command /sbin/ip addr
42
43
44Verify SSH Protocol State
45 [Documentation] verify SSH protocol state.
46 [Arguments] ${state}=${True}
47
48 # Description of argument(s}:
49 # state Enable or disable SSH, e.g. (true, false)
50
51 # Sample output:
52 # {
ganesanb4d430282023-04-27 14:33:23 +000053 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol",
Prashanth Kattif59a73e2021-09-22 03:03:58 -050054 # "@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol",
55 # "Description": "Manager Network Service",
56 # "FQDN": "bmc",
57 # "HTTP": {
58 # "Port": 0,
59 # "ProtocolEnabled": false
60 # },
61 # "HTTPS": {
62 # "Certificates": {
ganesanb4d430282023-04-27 14:33:23 +000063 # "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol/HTTPS/Certificates"
Prashanth Kattif59a73e2021-09-22 03:03:58 -050064 # },
65 # "Port": xxx,
66 # "ProtocolEnabled": true
67 # },
68 # "HostName": "xxxxbmc",
69 # "IPMI": {
70 # "Port": xxx,
71 # "ProtocolEnabled": true
72 # },
73 # "Id": "NetworkProtocol",
74 # "NTP": {
75 # "NTPServers": [
76 # "xx.xx.xx.xx",
77 # "xx.xx.xx.xx",
78 # "xx.xx.xx.xx"
79 # ],
80 # "ProtocolEnabled": true
81 # },
82 # "Name": "Manager Network Protocol",
83 # "SSH": {
84 # "Port": xx,
85 # "ProtocolEnabled": true
86 # },
87 # "Status": {
88 # "Health": "OK",
89 # "HealthRollup": "OK",
90 # "State": "Enabled"
91 # }
92
93 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
94 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state}
95 ... msg=Protocol states are not matching.
96
97
98Enable IPMI Protocol
99 [Documentation] Enable or disable IPMI protocol.
100 [Arguments] ${enable_value}=${True}
101
102 # Description of argument(s}:
103 # enable_value Enable or disable IPMI, e.g. (true, false).
104
105 ${ipmi_state}= Create Dictionary ProtocolEnabled=${enable_value}
106 ${data}= Create Dictionary IPMI=${ipmi_state}
107
108 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
109 ... valid_status_codes=[${HTTP_NO_CONTENT}]
110
111 # Wait for timeout for new values to take effect.
112 Sleep ${NETWORK_TIMEOUT}s
113
114
115Verify IPMI Works
116 [Documentation] Run IPMI command and return status.
117 [Arguments] ${sub_cmd} ${host}=${OPENBMC_HOST}
118
119 # Description of argument(s):
120 # host BMC host name or IP address.
121 # sub_cmd The IPMI command string to be executed.
122
123 ${rc}= Run And Return Rc ${cmd_prefix} -H ${host} ${sub_cmd}
124 Should Be Equal As Strings ${rc} 0
125 ... msg=IPMI is not enabled and commands are failing.
126
127
128Verify IPMI Protocol State
129 [Documentation] Verify IPMI protocol state.
130 [Arguments] ${state}=${True}
131
132 # Description of argument(s}:
133 # state Enable or disable IPMI, e.g. (true, false)
134
135 ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI}
136 Should Be Equal As Strings ${resp.dict['IPMI']['ProtocolEnabled']} ${state}
137 ... msg=Protocol states are not matching.