1*** Settings *** 2Documentation Network interface configuration and verification 3 ... tests. 4 5Resource ../../lib/bmc_redfish_resource.robot 6Resource ../../lib/bmc_network_utils.robot 7Resource ../../lib/openbmc_ffdc.robot 8Library ../../lib/bmc_network_utils.py 9 10Test Setup Test Setup Execution 11Test Teardown Test Teardown Execution 12 13*** Variables *** 14${test_hostname} openbmc 15 16*** Test Cases *** 17 18Get IP Address And Verify 19 [Documentation] Get IP Address And Verify. 20 [Tags] Get_IP_Address_And_Verify 21 22 : FOR ${network_configuration} IN @{network_configurations} 23 \ Verify IP On BMC ${network_configuration['Address']} 24 25Get Netmask And Verify 26 [Documentation] Get Netmask And Verify. 27 [Tags] Get_Netmask_And_Verify 28 29 : FOR ${network_configuration} IN @{network_configurations} 30 \ Verify Netmask On BMC ${network_configuration['SubnetMask']} 31 32Get 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 39Get 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 43 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} 44 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress 45 Validate MAC On BMC ${macaddr} 46 47Verify 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 55Get 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 63Configure 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 71*** Keywords *** 72 73Test Setup Execution 74 [Documentation] Test setup execution. 75 76 Redfish.Login 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 85 86Get 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 118 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} 119 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses 120 [Return] @{network_configurations} 121 122 123Verify IP On BMC 124 [Documentation] Verify IP on BMC. 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 135 136Verify Netmask On BMC 137 [Documentation] Verify netmask on BMC. 138 [Arguments] ${netmask} 139 140 # Description of the argument(s): 141 # netmask netmask value to be verified. 142 143 ${prefix_length}= Netmask Prefix Length ${netmask} 144 145 Should Contain Match ${ip_data} */${prefix_length} 146 ... msg=Prefix length does not exist. 147 148Verify 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. 164 165Verify 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 180Configure 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 190Validate 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 200 Should Contain ${sys_hostname} ${hostname} 201 ... ignore_case=True msg=Hostname does not exist. 202 203Test Teardown Execution 204 [Documentation] Test teardown execution. 205 206 FFDC On Test Case Fail 207 Redfish.Logout 208