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 11Test Tags BMC_DHCP_Conf 12 13*** Variables *** 14 15&{DHCP_ENABLE_DICT} DHCPEnabled=${True} 16&{DHCP_DISABLE_DICT} DHCPEnabled=${False} 17 18&{DNS_ENABLE_DICT} UseDNSServers=${True} 19&{DNS_DISABLE_DICT} UseDNSServers=${False} 20 21&{NTP_ENABLE_DICT} UseNTPServers=${True} 22&{NTP_DISABLE_DICT} UseNTPServers=${False} 23 24&{DOMAIN_NAME_ENABLE_DICT} UseDomainName=${True} 25&{DOMAIN_NAME_DISABLE_DICT} UseDomainName=${False} 26 27&{ENABLE_MULTIPLE_PROPRETIES} UseDomainName=${True} 28... UseNTPServers=${True} 29... UseDNSServers=${True} 30 31&{DISABLE_MULTIPLE_PROPERTIES} UseDomainName=${False} 32... UseNTPServers=${False} 33... UseDNSServers=${False} 34 35*** Test Cases *** 36 37Set Network Property via Redfish And Verify 38 [Documentation] Set network property via Redfish and verify. 39 [Tags] Set_Network_Property_via_Redfish_And_Verify 40 [Template] Apply Ethernet Config 41 42 # property 43 ${DHCP_ENABLE_DICT} 44 ${DHCP_DISABLE_DICT} 45 ${DNS_ENABLE_DICT} 46 $NTP_ENABLE_DICT{DNS_DISABLE_DICT} 47 ${DOMAIN_NAME_ENABLE_DICT} 48 ${DOMAIN_NAME_DISABLE_DICT} 49 ${NTP_ENABLE_DICT} 50 ${NTP_DISABLE_DICT} 51 ${ENABLE_MULTIPLE_PROPRETIES} 52 ${DISABLE_MULTIPLE_PROPERTIES} 53 54*** Keywords *** 55 56Suite Setup Execution 57 [Documentation] Suite Setup Execution. 58 59 Ping Host ${OPENBMC_HOST} 60 Ping Host ${OPENBMC_HOST_ETH1} 61 Redfish.Login 62 63 ${network_configurations}= 64 ... Get Network Configuration Using Channel Number ${2} 65 FOR ${network_configuration} IN @{network_configurations} 66 IF '${network_configuration['Address']}' == '${OPENBMC_HOST_ETH1}' 67 Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} 68 Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} 69 BREAK 70 END 71 END 72 73 ${network_configurations}= 74 ... Get Network Configuration Using Channel Number ${1} 75 FOR ${network_configuration} IN @{network_configurations} 76 IF '${network_configuration['Address']}' == '${OPENBMC_HOST}' 77 Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']} 78 Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']} 79 BREAK 80 END 81 END 82 83Get Network Configuration Using Channel Number 84 [Documentation] Get ethernet interface. 85 [Arguments] ${channel_number} 86 87 # Description of argument(s): 88 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for 89 # eth1 (e.g. "1"). 90 91 ${active_channel_config}= Get Active Channel Config 92 ${ethernet_interface}= 93 ... Set Variable ${active_channel_config['${channel_number}']['name']} 94 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 95 96 @{network_configurations}= 97 ... Get From Dictionary ${resp.dict} IPv4StaticAddresses 98 RETURN @{network_configurations} 99 100Apply Ethernet Config 101 [Documentation] Set the given Ethernet config property. 102 [Arguments] ${property} 103 104 # Description of argument(s): 105 # property Ethernet property to be set.. 106 107 ${active_channel_config}= Get Active Channel Config 108 Redfish.Patch 109 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/ 110 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 111 112 ${resp}= Redfish.Get 113 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']} 114 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]} 115 116Restore Configuration 117 [Documentation] Restore the configuration to Both Static Network 118 119 IF '${CHANNEL_NUMBER}' == '1' 120 Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway} 121 ELSE IF '${CHANNEL_NUMBER}' == '2' 122 Add IP Address 123 ... ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway} 124 END 125 126Verify Ethernet Config Property 127 [Documentation] verify ethernet config properties. 128 [Arguments] ${property} ${response_data} 129 130 # Description of argument(s): 131 # ${property} DHCP Properties in dictionary. 132 # Example: 133 # property value 134 # DHCPEnabled :False 135 # UseDomainName :True 136 # UseNTPServers :True 137 # UseDNSServers :True 138 # ${response_data} DHCP Response data in dictionary. 139 # Example: 140 # property value 141 # DHCPEnabled :False 142 # UseDomainName :True 143 # UseNTPServers :True 144 # UseDNSServers :True 145 146 ${key_map}= Get Dictionary Items ${property} 147 FOR ${key} ${value} IN @{key_map} 148 Should Be Equal As Strings ${response_data['${key}']} ${value} 149 END 150 151