Prashanth Katti | f59a73e | 2021-09-22 03:03:58 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Protocol settings utilities keywords. |
| 4 | |
| 5 | Resource ../lib/resource.robot |
| 6 | Resource ../lib/utils.robot |
| 7 | |
| 8 | |
| 9 | *** Keywords *** |
| 10 | |
| 11 | Enable SSH Protocol |
| 12 | [Documentation] Enable or disable SSH protocol. |
| 13 | [Arguments] ${enable_value}=${True} |
| 14 | |
| 15 | # Description of argument(s}: |
| 16 | # enable_value Enable or disable SSH, e.g. (true, false). |
| 17 | |
| 18 | ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value} |
| 19 | ${data}= Create Dictionary SSH=${ssh_state} |
| 20 | |
| 21 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 22 | ... valid_status_codes=[${HTTP_NO_CONTENT}] |
| 23 | |
| 24 | # Wait for timeout for new values to take effect. |
| 25 | Sleep ${NETWORK_TIMEOUT}s |
| 26 | |
| 27 | |
| 28 | Verify SSH Login And Commands Work |
| 29 | [Documentation] Verify if SSH connection works and able to run command on SSH session. |
| 30 | [Teardown] Close All Connections |
| 31 | |
| 32 | # Check if we can open SSH connection and login. |
| 33 | Open Connection And Login |
| 34 | |
| 35 | # Check if we can run command successfully on SSH session. |
| 36 | BMC Execute Command /sbin/ip addr |
| 37 | |
| 38 | |
| 39 | Verify SSH Protocol State |
| 40 | [Documentation] verify SSH protocol state. |
| 41 | [Arguments] ${state}=${True} |
| 42 | |
| 43 | # Description of argument(s}: |
| 44 | # state Enable or disable SSH, e.g. (true, false) |
| 45 | |
| 46 | # Sample output: |
| 47 | # { |
| 48 | # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol", |
| 49 | # "@odata.type": "#ManagerNetworkProtocol.v1_5_0.ManagerNetworkProtocol", |
| 50 | # "Description": "Manager Network Service", |
| 51 | # "FQDN": "bmc", |
| 52 | # "HTTP": { |
| 53 | # "Port": 0, |
| 54 | # "ProtocolEnabled": false |
| 55 | # }, |
| 56 | # "HTTPS": { |
| 57 | # "Certificates": { |
| 58 | # "@odata.id": "/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates" |
| 59 | # }, |
| 60 | # "Port": xxx, |
| 61 | # "ProtocolEnabled": true |
| 62 | # }, |
| 63 | # "HostName": "xxxxbmc", |
| 64 | # "IPMI": { |
| 65 | # "Port": xxx, |
| 66 | # "ProtocolEnabled": true |
| 67 | # }, |
| 68 | # "Id": "NetworkProtocol", |
| 69 | # "NTP": { |
| 70 | # "NTPServers": [ |
| 71 | # "xx.xx.xx.xx", |
| 72 | # "xx.xx.xx.xx", |
| 73 | # "xx.xx.xx.xx" |
| 74 | # ], |
| 75 | # "ProtocolEnabled": true |
| 76 | # }, |
| 77 | # "Name": "Manager Network Protocol", |
| 78 | # "SSH": { |
| 79 | # "Port": xx, |
| 80 | # "ProtocolEnabled": true |
| 81 | # }, |
| 82 | # "Status": { |
| 83 | # "Health": "OK", |
| 84 | # "HealthRollup": "OK", |
| 85 | # "State": "Enabled" |
| 86 | # } |
| 87 | |
| 88 | ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI} |
| 89 | Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state} |
| 90 | ... msg=Protocol states are not matching. |
| 91 | |
| 92 | |
| 93 | Enable IPMI Protocol |
| 94 | [Documentation] Enable or disable IPMI protocol. |
| 95 | [Arguments] ${enable_value}=${True} |
| 96 | |
| 97 | # Description of argument(s}: |
| 98 | # enable_value Enable or disable IPMI, e.g. (true, false). |
| 99 | |
| 100 | ${ipmi_state}= Create Dictionary ProtocolEnabled=${enable_value} |
| 101 | ${data}= Create Dictionary IPMI=${ipmi_state} |
| 102 | |
| 103 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 104 | ... valid_status_codes=[${HTTP_NO_CONTENT}] |
| 105 | |
| 106 | # Wait for timeout for new values to take effect. |
| 107 | Sleep ${NETWORK_TIMEOUT}s |
| 108 | |
| 109 | |
| 110 | Verify IPMI Works |
| 111 | [Documentation] Run IPMI command and return status. |
| 112 | [Arguments] ${sub_cmd} ${host}=${OPENBMC_HOST} |
| 113 | |
| 114 | # Description of argument(s): |
| 115 | # host BMC host name or IP address. |
| 116 | # sub_cmd The IPMI command string to be executed. |
| 117 | |
| 118 | ${rc}= Run And Return Rc ${cmd_prefix} -H ${host} ${sub_cmd} |
| 119 | Should Be Equal As Strings ${rc} 0 |
| 120 | ... msg=IPMI is not enabled and commands are failing. |
| 121 | |
| 122 | |
| 123 | Verify IPMI Protocol State |
| 124 | [Documentation] Verify IPMI protocol state. |
| 125 | [Arguments] ${state}=${True} |
| 126 | |
| 127 | # Description of argument(s}: |
| 128 | # state Enable or disable IPMI, e.g. (true, false) |
| 129 | |
| 130 | ${resp}= Redfish.Get ${REDFISH_NW_PROTOCOL_URI} |
| 131 | Should Be Equal As Strings ${resp.dict['IPMI']['ProtocolEnabled']} ${state} |
| 132 | ... msg=Protocol states are not matching. |