1*** Settings *** 2Documentation DHCP Network to test suite functionality. 3 4Resource ../lib/openbmc_ffdc.robot 5Resource ../lib/bmc_network_utils.robot 6Library ../lib/ipmi_utils.py 7Library ../lib/bmc_network_utils.py 8 9Suite Setup Suite Setup Execution 10Suite Teardown Redfish.Logout 11 12*** Variables *** 13 14&{dhcp_enable_dict} DHCPEnabled=${True} 15&{dhcp_disable_dict} DHCPEnabled=${False} 16 17&{dns_enable_dict} UseDNSServers=${True} 18&{dns_disable_dict} UseDNSServers=${False} 19 20&{ntp_enable_dict} UseNTPServers=${True} 21&{ntp_disable_dict} UseNTPServers=${False} 22 23&{domain_name_enable_dict} UseDomainName=${True} 24&{domain_name_disable_dict} UseDomainName=${False} 25 26&{enable_multiple_properties} UseDomainName=${True} 27... UseNTPServers=${True} 28... UseDNSServers=${True} 29 30&{disable_multiple_properties} UseDomainName=${False} 31... UseNTPServers=${False} 32... UseDNSServers=${False} 33 34*** Test Cases *** 35 36Set Network Property via Redfish And Verify 37 [Documentation] Set network property via Redfish and verify. 38 [Tags] Set_Network_Property_via_Redfish_And_Verify 39 [Template] Apply Ethernet Config 40 41 # property 42 ${dhcp_enable_dict} 43 ${dhcp_disable_dict} 44 ${dns_enable_dict} 45 ${dns_disable_dict} 46 ${domain_name_enable_dict} 47 ${domain_name_disable_dict} 48 ${ntp_enable_dict} 49 ${ntp_disable_dict} 50 ${enable_multiple_properties} 51 ${disable_multiple_properties} 52 53 54*** Keywords *** 55 56Suite Setup Execution 57 [Documentation] Suite Setup Execution. 58 59 Redfish.Login 60 61 # This keyword should login to host OS. 62 Run Inband IPMI Standard Command 63 ... lan set ${CHANNEL_NUMBER} ipsrc static login_host=${1} 64 65 ${host_name} ${ip_address}= Get Host Name IP host=${OPENBMC_HOST} 66 67 Set Suite Variable ${ip_address} 68 69 @{network_configurations}= Get Network Configuration 70 FOR ${network_configuration} IN @{network_configurations} 71 Run Keyword If '${network_configuration['Address']}' == '${ip_address}' 72 ... Set Suite Variable ${subnet_mask} ${network_configuration['SubnetMask']} 73 END 74 75 ${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband 76 Set Suite Variable ${initial_lan_config} 77 78 79Set IPMI Inband Network Configuration 80 [Documentation] Run sequence of standard in-band IPMI command and set 81 ... the IP configuration. 82 [Arguments] ${ip} ${netmask} ${gateway} 83 84 # Description of argument(s): 85 # ip The IP address to be set using ipmitool-inband. 86 # netmask The Netmask to be set using ipmitool-inband. 87 # gateway The Gateway address to be set using ipmitool-inband. 88 # login Indicates that this keyword should login to host OS. 89 90 Run Inband IPMI Standard Command 91 ... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0} 92 Run Inband IPMI Standard Command 93 ... lan set ${CHANNEL_NUMBER} netmask ${netmask} login_host=${0} 94 Run Inband IPMI Standard Command 95 ... lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway} login_host=${0} 96 97 98Restore Configuration 99 [Documentation] Restore the configuration to its pre-test state. 100 101 ${length}= Get Length ${initial_lan_config} 102 Return From Keyword If ${length} == ${0} 103 104 Set IPMI Inband Network Configuration ${ip_address} ${subnet_mask} 105 ... ${initial_lan_config['Default Gateway IP']} 106 107 108Apply Ethernet Config 109 [Documentation] Set the given Ethernet config property. 110 [Arguments] ${property} 111 [Teardown] Run Keywords Restore Configuration AND 112 ... Set Global Variable ${TEST_STATUS} ${KEYWORD STATUS} AND FFDC On Test Case Fail 113 114 # Description of argument(s): 115 # property Ethernet property to be set.. 116 117 ${active_channel_config}= Get Active Channel Config 118 Redfish.Patch 119 ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/ 120 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 121 122 ${resp}= Redfish.Get 123 ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 124 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]} 125 126 127Verify Ethernet Config Property 128 [Documentation] verify ethernet config properties. 129 [Arguments] ${property} ${response_data} 130 131 # Description of argument(s): 132 # ${property} DHCP Properties in dictionary. 133 # Example: 134 # property value 135 # DHCPEnabled :False 136 # UseDomainName :True 137 # UseNTPServers :True 138 # UseDNSServers :True 139 # ${response_data} DHCP Response data in dictionary. 140 # Example: 141 # property value 142 # DHCPEnabled :False 143 # UseDomainName :True 144 # UseNTPServers :True 145 # UseDNSServers :True 146 147 ${key_map}= Get Dictionary Items ${property} 148 FOR ${key} ${value} IN @{key_map} 149 Should Be Equal As Strings ${response_data['${key}']} ${value} 150 END 151 152