blob: 8a850ec5b5e34d79a0eede479e7fb3f0f232dee6 [file] [log] [blame]
Sweta Potthuriab871742023-02-20 11:08:42 -06001*** Settings ***
2Documentation Test BMC DHCP multiple network interface functionalities.
3
4Resource ../../lib/resource.robot
5Resource ../../lib/common_utils.robot
6Resource ../../lib/connection_client.robot
7Resource ../../lib/bmc_network_utils.robot
8Resource ../../lib/openbmc_ffdc.robot
9
10Suite Setup Suite Setup Execution
11Test Teardown FFDC On Test Case Fail
12Suite Teardown Redfish.Logout
13
14*** Variables ***
15
16&{DHCP_ENABLED} DHCPEnabled=${True}
17&{DHCP_DISABLED} DHCPEnabled=${False}
18&{ENABLE_DHCP} DHCPv4=${DHCP_ENABLED}
19&{DISABLE_DHCP} DHCPv4=${DHCP_DISABLED}
20${ethernet_interface} eth1
21
Sweta Potthuridda695e2023-04-26 02:10:38 -050022&{dns_enable_dict} UseDNSServers=${True}
23&{dns_disable_dict} UseDNSServers=${False}
24&{ntp_enable_dict} UseNTPServers=${True}
25&{ntp_disable_dict} UseNTPServers=${False}
26&{domain_name_enable_dict} UseDomainName=${True}
27&{domain_name_disable_dict} UseDomainName=${False}
28&{enable_multiple_properties} UseDomainName=${True}
29... UseNTPServers=${True}
30... UseDNSServers=${True}
31&{disable_multiple_properties} UseDomainName=${False}
32... UseNTPServers=${False}
33... UseDNSServers=${False}
34
Sweta Potthuri51ce1212023-10-11 02:18:12 -050035Force Tags Multiple_Interfaces_DHCP
36
Sweta Potthuriab871742023-02-20 11:08:42 -060037*** Test Cases ***
38
39Disable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053040 [Documentation] Disable DHCP on eth1 using Redfish and verify
41 ... if system is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060042 [Tags] Disable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
43 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
44
45 Set DHCPEnabled To Enable Or Disable False eth1
46 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
47
48Enable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053049 [Documentation] Enable DHCP on eth1 using Redfish and verify if system
50 ... is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060051 [Tags] Enable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
52 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
53
54 Set DHCPEnabled To Enable Or Disable True eth1
55 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
56
Sweta Potthuridda695e2023-04-26 02:10:38 -050057Set Network Property via Redfish And Verify
58 [Documentation] Set network property via Redfish and verify.
59 [Tags] Set_Network_Property_via_Redfish_And_Verify
60 [Teardown] Restore Configuration
61 [Template] Apply DHCP Config
62
63 # property
64 ${dns_enable_dict}
65 ${dns_disable_dict}
66 ${domain_name_enable_dict}
67 ${domain_name_disable_dict}
68 ${ntp_enable_dict}
69 ${ntp_disable_dict}
70 ${enable_multiple_properties}
71 ${disable_multiple_properties}
72
Sweta Potthuri51ce1212023-10-11 02:18:12 -050073Enable DHCP On Eth1 And Check No Impact On Eth0
74 [Documentation] Enable DHCP On Eth1 And Check No Impact On Eth0.
75 [Tags] Enable_DHCP_On_Eth1_And_Check_No_Impact_On_Eth0
76 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
77
78 # Getting the eth0 details before enabling DHCP.
79 ${ip_data_before}= Get BMC IP Info
80
81 # Enable DHCP.
82 Set DHCPEnabled To Enable Or Disable True eth1
83
84 # Check the value of DHCPEnabled on eth0 is not impacted.
85 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status
86 Should Be Equal ${DHCPEnabled} ${False}
87
88 # Getting eth0 details after enabling DHCP.
89 ${ip_data_after}= Get BMC IP Info
90
91 # Before and after IP details must match.
92 Should Be Equal ${ip_data_before} ${ip_data_after}
93
Sweta Potthuriab871742023-02-20 11:08:42 -060094*** Keywords ***
95
Sweta Potthuri51ce1212023-10-11 02:18:12 -050096Get IPv4 DHCP Enabled Status
97 [Documentation] Return IPv4 DHCP enabled status from redfish URI.
98
99 ${active_channel_config}= Get Active Channel Config
100 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
101 ${resp}= Redfish.Get Attribute ${REDFISH_NW_ETH_IFACE}${ethernet_interface} DHCPv4
102 Return From Keyword ${resp['DHCPEnabled']}
103
Sweta Potthuriab871742023-02-20 11:08:42 -0600104Set DHCPEnabled To Enable Or Disable
105 [Documentation] Enable or Disable DHCP on the interface.
George Keishing618aff72023-03-09 09:55:19 +0530106 [Arguments] ${dhcp_enabled}=${False} ${interface}=${ethernet_interface}
107 ... ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuriab871742023-02-20 11:08:42 -0600108
109 # Description of argument(s):
110 # dhcp_enabled False for disabling DHCP and True for Enabling DHCP.
111 # interface eth0 or eth1. Default is eth1.
George Keishing618aff72023-03-09 09:55:19 +0530112 # valid_status_code Expected valid status code from Patch request.
113 # Default is HTTP_OK.
Sweta Potthuriab871742023-02-20 11:08:42 -0600114
115 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
116 ${resp}= Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +0000117 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${interface}
Sweta Potthuriab871742023-02-20 11:08:42 -0600118 ... body=${data} valid_status_codes=${valid_status_code}
119
Sweta Potthuridda695e2023-04-26 02:10:38 -0500120Apply DHCP Config
121 [Documentation] Apply DHCP Config
122 [Arguments] ${property}
123
124 # Description of Argument(s):
125 # property DHCP property values.
126
127 ${active_channel_config}= Get Active Channel Config
128 Redfish.Patch
ganesanb26e59572023-06-09 07:55:47 +0000129 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/
Sweta Potthuridda695e2023-04-26 02:10:38 -0500130 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
131
132 ${resp}= Redfish.Get
ganesanb26e59572023-06-09 07:55:47 +0000133 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500134 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
135
136
137Verify Ethernet Config Property
138 [Documentation] verify ethernet config properties.
139 [Arguments] ${property} ${response_data}
140
141 # Description of argument(s):
142 # ${property} DHCP Properties in dictionary.
143 # Example:
144 # property value
145 # DHCPEnabled :False
146 # UseDomainName :True
147 # UseNTPServers :True
148 # UseDNSServers :True
149 # ${response_data} DHCP Response data in dictionary.
150 # Example:
151 # property value
152 # DHCPEnabled :False
153 # UseDomainName :True
154 # UseNTPServers :True
155 # UseDNSServers :True
156
157 ${key_map}= Get Dictionary Items ${property}
158 FOR ${key} ${value} IN @{key_map}
159 Should Be Equal As Strings ${response_data['${key}']} ${value}
160 END
161
162Restore Configuration
163 [Documentation] Restore the configuration to Both Static Network
164
165 Run Keyword If '${CHANNEL_NUMBER}' == '1' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
166 ... ELSE IF '${CHANNEL_NUMBER}' == '2' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
167
168Get Network Configuration Using Channel Number
169 [Documentation] Get ethernet interface.
170 [Arguments] ${channel_number}
171
172 # Description of argument(s):
173 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
174
175 ${active_channel_config}= Get Active Channel Config
176 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
177 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
178
179 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
180 [Return] @{network_configurations}
181
Sweta Potthuriab871742023-02-20 11:08:42 -0600182Suite Setup Execution
183 [Documentation] Do suite setup task.
184
185 Ping Host ${OPENBMC_HOST}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500186 Ping Host ${OPENBMC_HOST_1}
Sweta Potthuriab871742023-02-20 11:08:42 -0600187 Redfish.Login
Sweta Potthuridda695e2023-04-26 02:10:38 -0500188
189 # Get the configuration of eth1
190 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
191 FOR ${network_configuration} IN @{network_configurations}
192 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
193 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
194 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
195 ... AND Exit For Loop
196 END
197
198 # Get the configuration of eth0
199 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
200 FOR ${network_configuration} IN @{network_configurations}
201 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}'
202 ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
203 ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
204 ... AND Exit For Loop
205 END
206