1*** Settings *** 2Documentation DHCP Network to test suite functionality. 3 4Resource ../lib/openbmc_ffdc.robot 5Resource ../lib/bmc_network_utils.robot 6Library ../lib/bmc_network_utils.py 7 8Suite Setup Suite Setup Execution 9Suite Teardown Run Keywords Restore Configuration AND Redfish.Logout 10 11*** Variables *** 12 13&{dhcp_enable_dict} DHCPEnabled=${True} 14&{dhcp_disable_dict} DHCPEnabled=${False} 15 16&{dns_enable_dict} UseDNSServers=${True} 17&{dns_disable_dict} UseDNSServers=${False} 18 19&{ntp_enable_dict} UseNTPServers=${True} 20&{ntp_disable_dict} UseNTPServers=${False} 21 22&{domain_name_enable_dict} UseDomainName=${True} 23&{domain_name_disable_dict} UseDomainName=${False} 24 25&{enable_multiple_properties} UseDomainName=${True} 26... UseNTPServers=${True} 27... UseDNSServers=${True} 28 29&{disable_multiple_properties} UseDomainName=${False} 30... UseNTPServers=${False} 31... UseDNSServers=${False} 32 33*** Test Cases *** 34 35Set Network Property via Redfish And Verify 36 [Documentation] Set network property via Redfish and verify. 37 [Tags] Set_Network_Property_via_Redfish_And_Verify 38 [Template] Apply Ethernet Config 39 40 # property 41 ${dhcp_enable_dict} 42 ${dhcp_disable_dict} 43 ${dns_enable_dict} 44 ${dns_disable_dict} 45 ${domain_name_enable_dict} 46 ${domain_name_disable_dict} 47 ${ntp_enable_dict} 48 ${ntp_disable_dict} 49 ${enable_multiple_properties} 50 ${disable_multiple_properties} 51 52 53*** Keywords *** 54 55Suite Setup Execution 56 [Documentation] Suite Setup Execution. 57 58 Ping Host ${OPENBMC_HOST} 59 Ping Host ${OPENBMC_HOST_1} 60 Redfish.Login 61 62 ${network_configurations}= Get Network Configuration Using Channel Number ${2} 63 FOR ${network_configuration} IN @{network_configurations} 64 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}' 65 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} 66 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} 67 ... AND Exit For Loop 68 END 69 70 ${network_configurations}= Get Network Configuration Using Channel Number ${1} 71 FOR ${network_configuration} IN @{network_configurations} 72 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}' 73 ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']} 74 ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']} 75 ... AND Exit For Loop 76 END 77 78Get Network Configuration Using Channel Number 79 [Documentation] Get ethernet interface. 80 [Arguments] ${channel_number} 81 82 # Description of argument(s): 83 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1"). 84 85 ${active_channel_config}= Get Active Channel Config 86 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']} 87 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 88 89 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses 90 [Return] @{network_configurations} 91 92Apply Ethernet Config 93 [Documentation] Set the given Ethernet config property. 94 [Arguments] ${property} 95 96 # Description of argument(s): 97 # property Ethernet property to be set.. 98 99 ${active_channel_config}= Get Active Channel Config 100 Redfish.Patch 101 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/ 102 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 103 104 ${resp}= Redfish.Get 105 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 106 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]} 107 108Restore Configuration 109 [Documentation] Restore the configuration to Both Static Network 110 111 Run Keyword If '${CHANNEL_NUMBER}' == '1' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway} 112 ... ELSE IF '${CHANNEL_NUMBER}' == '2' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway} 113 114Verify Ethernet Config Property 115 [Documentation] verify ethernet config properties. 116 [Arguments] ${property} ${response_data} 117 118 # Description of argument(s): 119 # ${property} DHCP Properties in dictionary. 120 # Example: 121 # property value 122 # DHCPEnabled :False 123 # UseDomainName :True 124 # UseNTPServers :True 125 # UseDNSServers :True 126 # ${response_data} DHCP Response data in dictionary. 127 # Example: 128 # property value 129 # DHCPEnabled :False 130 # UseDomainName :True 131 # UseNTPServers :True 132 # UseDNSServers :True 133 134 ${key_map}= Get Dictionary Items ${property} 135 FOR ${key} ${value} IN @{key_map} 136 Should Be Equal As Strings ${response_data['${key}']} ${value} 137 END 138 139