Anves Kumar rayankula | 5a57faf | 2020-05-19 05:47:44 -0500 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation DHCP Network to test suite functionality. |
| 3 | |
| 4 | Resource ../lib/openbmc_ffdc.robot |
| 5 | Resource ../lib/bmc_network_utils.robot |
| 6 | Library ../lib/ipmi_utils.py |
| 7 | Library ../lib/bmc_network_utils.py |
| 8 | |
| 9 | Suite Setup Suite Setup Execution |
| 10 | Suite Teardown Redfish.Logout |
| 11 | |
| 12 | *** Test Cases *** |
| 13 | |
| 14 | Enable DHCP Via Redfish And Verify |
| 15 | [Documentation] Enable DHCP via Redfish and verify. |
| 16 | [Tags] Enable_DHCP_Via_Redfish_And_Verify |
| 17 | [Teardown] Run Keywords Restore Configuration |
| 18 | ... AND FFDC On Test Case Fail |
| 19 | |
| 20 | ${active_channel_config}= Get Active Channel Config |
| 21 | Redfish.Patch |
| 22 | ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/ |
| 23 | ... body={"DHCPv4":{"DHCPEnabled":${True}}} |
| 24 | |
| 25 | ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI} |
| 26 | Should Be Equal As Strings ${resp.dict["DHCPv4"]["DHCPEnabled"]} ${True} |
| 27 | |
| 28 | |
| 29 | *** Keywords *** |
| 30 | |
| 31 | Suite Setup Execution |
| 32 | [Documentation] Suite Setup Execution. |
| 33 | |
| 34 | Redfish.Login |
| 35 | |
| 36 | # This keyword should login to host OS. |
| 37 | Run Inband IPMI Standard Command |
| 38 | ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${1} |
| 39 | |
| 40 | ${host_name} ${ip_address}= Get Host Name IP host=${OPENBMC_HOST} |
| 41 | |
| 42 | Set Suite Variable ${ip_address} |
| 43 | |
| 44 | @{network_configurations}= Get Network Configuration |
| 45 | FOR ${network_configuration} IN @{network_configurations} |
| 46 | Run Keyword If '${network_configuration['Address']}' == '${ip_address}' |
| 47 | ... Set Suite Variable ${subnet_mask} ${network_configuration['SubnetMask']} |
| 48 | END |
| 49 | |
| 50 | ${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband |
| 51 | Set Suite Variable ${initial_lan_config} |
| 52 | |
| 53 | |
| 54 | Set IPMI Inband Network Configuration |
| 55 | [Documentation] Run sequence of standard in-band IPMI command and set |
| 56 | ... the IP configuration. |
| 57 | [Arguments] ${ip} ${netmask} ${gateway} |
| 58 | |
| 59 | # Description of argument(s): |
| 60 | # ip The IP address to be set using ipmitool-inband. |
| 61 | # netmask The Netmask to be set using ipmitool-inband. |
| 62 | # gateway The Gateway address to be set using ipmitool-inband. |
| 63 | # login Indicates that this keyword should login to host OS. |
| 64 | |
| 65 | Run Inband IPMI Standard Command |
| 66 | ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0} |
| 67 | Run Inband IPMI Standard Command |
| 68 | ... lan set ${CHANNEL_NUMBER} netmask ${netmask} login_host=${0} |
| 69 | Run Inband IPMI Standard Command |
| 70 | ... lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway} login_host=${0} |
| 71 | |
| 72 | |
| 73 | Restore Configuration |
| 74 | [Documentation] Restore the configuration to its pre-test state. |
| 75 | |
| 76 | ${length}= Get Length ${initial_lan_config} |
| 77 | Return From Keyword If ${length} == ${0} |
| 78 | |
| 79 | Set IPMI Inband Network Configuration ${ip_address} ${subnet_mask} |
| 80 | ... ${initial_lan_config['Default Gateway IP']} |
| 81 | |