Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Network interface configuration and verification |
| 3 | ... tests. |
| 4 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 5 | Resource ../../lib/bmc_redfish_resource.robot |
| 6 | Resource ../../lib/bmc_network_utils.robot |
| 7 | Resource ../../lib/openbmc_ffdc.robot |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 8 | Library ../../lib/bmc_network_utils.py |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 9 | |
| 10 | Test Setup Test Setup Execution |
| 11 | Test Teardown Test Teardown Execution |
| 12 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 13 | *** Variables *** |
| 14 | ${test_hostname} openbmc |
| 15 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 16 | *** Test Cases *** |
| 17 | |
| 18 | Get IP Address And Verify |
| 19 | [Documentation] Get IP Address And Verify. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 20 | [Tags] Get_IP_Address_And_Verify |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 21 | |
| 22 | : FOR ${network_configuration} IN @{network_configurations} |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 23 | \ Verify IP On BMC ${network_configuration['Address']} |
| 24 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 25 | Get Netmask And Verify |
| 26 | [Documentation] Get Netmask And Verify. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 27 | [Tags] Get_Netmask_And_Verify |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 28 | |
| 29 | : FOR ${network_configuration} IN @{network_configurations} |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 30 | \ Verify Netmask On BMC ${network_configuration['SubnetMask']} |
| 31 | |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 32 | Get Gateway And Verify |
| 33 | [Documentation] Get gateway and verify it's existence on the BMC. |
| 34 | [Tags] Get_Gateway_And_Verify |
| 35 | |
| 36 | : FOR ${network_configuration} IN @{network_configurations} |
| 37 | \ Verify Gateway On BMC ${network_configuration['Gateway']} |
| 38 | |
| 39 | Get MAC Address And Verify |
| 40 | [Documentation] Get MAC address and verify it's existence on the BMC. |
| 41 | [Tags] Get_MAC_Address_And_Verify |
| 42 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 43 | ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 44 | ${macaddr}= Get From Dictionary ${resp.dict} MACAddress |
| 45 | Validate MAC On BMC ${macaddr} |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 46 | |
Prashanth Katti | 2c5c3bb | 2019-02-14 04:23:07 -0600 | [diff] [blame] | 47 | Verify All Configured IP And Netmask |
| 48 | [Documentation] Verify all configured IP and netmask on BMC. |
| 49 | [Tags] Verify_All_Configured_IP_And_Netmask |
| 50 | |
| 51 | : FOR ${network_configuration} IN @{network_configurations} |
| 52 | \ Verify IP And Netmask On BMC ${network_configuration['Address']} |
| 53 | ... ${network_configuration['SubnetMask']} |
| 54 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 55 | Get Hostname And Verify |
| 56 | [Documentation] Get hostname via Redfish and verify. |
| 57 | [Tags] Get_Hostname_And_Verify |
| 58 | |
| 59 | ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName |
| 60 | |
| 61 | Validate Hostname On BMC ${hostname} |
| 62 | |
| 63 | Configure Hostname And Verify |
| 64 | [Documentation] Configure hostname via Redfish and verify. |
| 65 | [Tags] Configure_Hostname_And_Verify |
| 66 | |
| 67 | Configure Hostname ${test_hostname} |
| 68 | |
| 69 | Validate Hostname On BMC ${test_hostname} |
| 70 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 71 | *** Keywords *** |
| 72 | |
| 73 | Test Setup Execution |
| 74 | [Documentation] Test setup execution. |
| 75 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 76 | Redfish.Login |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 77 | |
| 78 | @{network_configurations}= Get Network Configuration |
| 79 | Set Test Variable @{network_configurations} |
| 80 | |
| 81 | # Get BMC IP address and prefix length. |
| 82 | ${ip_data}= Get BMC IP Info |
| 83 | Set Test Variable ${ip_data} |
| 84 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 85 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 86 | Get Network Configuration |
| 87 | [Documentation] Get network configuration. |
| 88 | |
| 89 | # Sample output: |
| 90 | #{ |
| 91 | # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface", |
| 92 | # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0", |
| 93 | # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface", |
| 94 | # "Description": "Management Network Interface", |
| 95 | # "IPv4Addresses": [ |
| 96 | # { |
| 97 | # "Address": "169.254.xx.xx", |
| 98 | # "AddressOrigin": "IPv4LinkLocal", |
| 99 | # "Gateway": "0.0.0.0", |
| 100 | # "SubnetMask": "255.255.0.0" |
| 101 | # }, |
| 102 | # { |
| 103 | # "Address": "xx.xx.xx.xx", |
| 104 | # "AddressOrigin": "Static", |
| 105 | # "Gateway": "xx.xx.xx.1", |
| 106 | # "SubnetMask": "xx.xx.xx.xx" |
| 107 | # } |
| 108 | # ], |
| 109 | # "Id": "eth0", |
| 110 | # "MACAddress": "xx:xx:xx:xx:xx:xx", |
| 111 | # "Name": "Manager Ethernet Interface", |
| 112 | # "SpeedMbps": 0, |
| 113 | # "VLAN": { |
| 114 | # "VLANEnable": false, |
| 115 | # "VLANId": 0 |
| 116 | # } |
| 117 | |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 118 | ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 119 | @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses |
| 120 | [Return] @{network_configurations} |
| 121 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 122 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 123 | Verify IP On BMC |
| 124 | [Documentation] Verify IP on BMC. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 125 | [Arguments] ${ip} |
| 126 | |
| 127 | # Description of the argument(s): |
| 128 | # ip IP address to be verified. |
| 129 | |
| 130 | # Get IP address details on BMC using IP command. |
| 131 | @{ip_data}= Get BMC IP Info |
| 132 | Should Contain Match ${ip_data} ${ip}/* |
| 133 | ... msg=IP address does not exist. |
| 134 | |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 135 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 136 | Verify Netmask On BMC |
| 137 | [Documentation] Verify netmask on BMC. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 138 | [Arguments] ${netmask} |
| 139 | |
| 140 | # Description of the argument(s): |
| 141 | # netmask netmask value to be verified. |
| 142 | |
Prashanth Katti | 747ce9d | 2019-02-07 07:23:48 -0600 | [diff] [blame] | 143 | ${prefix_length}= Netmask Prefix Length ${netmask} |
| 144 | |
| 145 | Should Contain Match ${ip_data} */${prefix_length} |
| 146 | ... msg=Prefix length does not exist. |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 147 | |
Prashanth Katti | 2ec9d8b | 2019-02-12 05:20:19 -0600 | [diff] [blame] | 148 | Verify Gateway On BMC |
| 149 | [Documentation] Verify gateway on BMC. |
| 150 | [Arguments] ${gateway_ip}=0.0.0.0 |
| 151 | |
| 152 | # Description of argument(s): |
| 153 | # gateway_ip Gateway IP address. |
| 154 | |
| 155 | ${route_info}= Get BMC Route Info |
| 156 | |
| 157 | # If gateway IP is empty or 0.0.0.0 it will not have route entry. |
| 158 | |
| 159 | Run Keyword If '${gateway_ip}' == '0.0.0.0' |
| 160 | ... Pass Execution Gateway IP is "0.0.0.0". |
| 161 | ... ELSE |
| 162 | ... Should Contain ${route_info} ${gateway_ip} |
| 163 | ... msg=Gateway IP address not matching. |
George Keishing | 5d46755 | 2019-02-08 23:30:48 -0600 | [diff] [blame] | 164 | |
Prashanth Katti | 2c5c3bb | 2019-02-14 04:23:07 -0600 | [diff] [blame] | 165 | Verify IP And Netmask On BMC |
| 166 | [Documentation] Verify IP and netmask on BMC. |
| 167 | [Arguments] ${ip} ${netmask} |
| 168 | |
| 169 | # Description of the argument(s): |
| 170 | # ip IP address to be verified. |
| 171 | # netmask netmask value to be verified. |
| 172 | |
| 173 | ${prefix_length}= Netmask Prefix Length ${netmask} |
| 174 | @{ip_data}= Get BMC IP Info |
| 175 | |
| 176 | ${ip_with_netmask}= Catenate ${ip}/${prefix_length} |
| 177 | Should Contain ${ip_data} ${ip_with_netmask} |
| 178 | ... msg=IP and netmask pair does not exist. |
| 179 | |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 180 | Configure Hostname |
| 181 | [Documentation] Configure hostname on BMC via Redfish. |
| 182 | [Arguments] ${hostname} |
| 183 | |
| 184 | # Description of argument(s): |
| 185 | # hostname A hostname value which is to be configured on BMC. |
| 186 | |
| 187 | ${data}= Create Dictionary HostName=${hostname} |
| 188 | Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 189 | |
| 190 | Validate Hostname On BMC |
| 191 | [Documentation] Verify that the hostname read via Redfish is the same as the |
| 192 | ... hostname configured on system. |
| 193 | [Arguments] ${hostname} |
| 194 | |
| 195 | # Description of argument(s): |
| 196 | # hostname A hostname value which is to be compared to the hostname |
| 197 | # configured on system. |
| 198 | |
| 199 | ${sys_hostname}= Get BMC Hostname |
Prashanth Katti | 466d834 | 2019-03-21 08:58:50 -0500 | [diff] [blame] | 200 | Should Be Equal ${sys_hostname} ${hostname} |
Prashanth Katti | 23efc6e | 2019-03-13 06:07:15 -0500 | [diff] [blame] | 201 | ... ignore_case=True msg=Hostname does not exist. |
| 202 | |
Prashanth Katti | f58cce0 | 2019-02-06 03:05:14 -0600 | [diff] [blame] | 203 | Test Teardown Execution |
| 204 | [Documentation] Test teardown execution. |
| 205 | |
| 206 | FFDC On Test Case Fail |
George Keishing | 97c9394 | 2019-03-04 12:45:07 -0600 | [diff] [blame] | 207 | Redfish.Logout |