blob: 75559622fbdafd0ee6fd90c965b880de3c657761 [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 Potthuriab871742023-02-20 11:08:42 -060035*** Test Cases ***
36
37Disable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053038 [Documentation] Disable DHCP on eth1 using Redfish and verify
39 ... if system is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060040 [Tags] Disable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
41 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1
42
43 Set DHCPEnabled To Enable Or Disable False eth1
44 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
45
46Enable DHCP On Eth1 And Verify System Is Accessible By Eth0
George Keishing618aff72023-03-09 09:55:19 +053047 [Documentation] Enable DHCP on eth1 using Redfish and verify if system
48 ... is accessible by eth0.
Sweta Potthuriab871742023-02-20 11:08:42 -060049 [Tags] Enable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
50 [Setup] Set DHCPEnabled To Enable Or Disable False eth1
51
52 Set DHCPEnabled To Enable Or Disable True eth1
53 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
54
Sweta Potthuridda695e2023-04-26 02:10:38 -050055Set Network Property via Redfish And Verify
56 [Documentation] Set network property via Redfish and verify.
57 [Tags] Set_Network_Property_via_Redfish_And_Verify
58 [Teardown] Restore Configuration
59 [Template] Apply DHCP Config
60
61 # property
62 ${dns_enable_dict}
63 ${dns_disable_dict}
64 ${domain_name_enable_dict}
65 ${domain_name_disable_dict}
66 ${ntp_enable_dict}
67 ${ntp_disable_dict}
68 ${enable_multiple_properties}
69 ${disable_multiple_properties}
70
Sweta Potthuriab871742023-02-20 11:08:42 -060071*** Keywords ***
72
73Set DHCPEnabled To Enable Or Disable
74 [Documentation] Enable or Disable DHCP on the interface.
George Keishing618aff72023-03-09 09:55:19 +053075 [Arguments] ${dhcp_enabled}=${False} ${interface}=${ethernet_interface}
76 ... ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED}]
Sweta Potthuriab871742023-02-20 11:08:42 -060077
78 # Description of argument(s):
79 # dhcp_enabled False for disabling DHCP and True for Enabling DHCP.
80 # interface eth0 or eth1. Default is eth1.
George Keishing618aff72023-03-09 09:55:19 +053081 # valid_status_code Expected valid status code from Patch request.
82 # Default is HTTP_OK.
Sweta Potthuriab871742023-02-20 11:08:42 -060083
84 ${data}= Set Variable If ${dhcp_enabled} == ${False} ${DISABLE_DHCP} ${ENABLE_DHCP}
85 ${resp}= Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +000086 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${interface}
Sweta Potthuriab871742023-02-20 11:08:42 -060087 ... body=${data} valid_status_codes=${valid_status_code}
88
Sweta Potthuridda695e2023-04-26 02:10:38 -050089Apply DHCP Config
90 [Documentation] Apply DHCP Config
91 [Arguments] ${property}
92
93 # Description of Argument(s):
94 # property DHCP property values.
95
96 ${active_channel_config}= Get Active Channel Config
97 Redfish.Patch
98 ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/
99 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
100
101 ${resp}= Redfish.Get
102 ... /redfish/v1/Managers/bmc/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
103 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
104
105
106Verify Ethernet Config Property
107 [Documentation] verify ethernet config properties.
108 [Arguments] ${property} ${response_data}
109
110 # Description of argument(s):
111 # ${property} DHCP Properties in dictionary.
112 # Example:
113 # property value
114 # DHCPEnabled :False
115 # UseDomainName :True
116 # UseNTPServers :True
117 # UseDNSServers :True
118 # ${response_data} DHCP Response data in dictionary.
119 # Example:
120 # property value
121 # DHCPEnabled :False
122 # UseDomainName :True
123 # UseNTPServers :True
124 # UseDNSServers :True
125
126 ${key_map}= Get Dictionary Items ${property}
127 FOR ${key} ${value} IN @{key_map}
128 Should Be Equal As Strings ${response_data['${key}']} ${value}
129 END
130
131Restore Configuration
132 [Documentation] Restore the configuration to Both Static Network
133
134 Run Keyword If '${CHANNEL_NUMBER}' == '1' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
135 ... ELSE IF '${CHANNEL_NUMBER}' == '2' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
136
137Get Network Configuration Using Channel Number
138 [Documentation] Get ethernet interface.
139 [Arguments] ${channel_number}
140
141 # Description of argument(s):
142 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
143
144 ${active_channel_config}= Get Active Channel Config
145 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
146 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
147
148 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
149 [Return] @{network_configurations}
150
Sweta Potthuriab871742023-02-20 11:08:42 -0600151Suite Setup Execution
152 [Documentation] Do suite setup task.
153
154 Ping Host ${OPENBMC_HOST}
Sweta Potthuridda695e2023-04-26 02:10:38 -0500155 Ping Host ${OPENBMC_HOST_1}
Sweta Potthuriab871742023-02-20 11:08:42 -0600156 Redfish.Login
Sweta Potthuridda695e2023-04-26 02:10:38 -0500157
158 # Get the configuration of eth1
159 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
160 FOR ${network_configuration} IN @{network_configurations}
161 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
162 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
163 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
164 ... AND Exit For Loop
165 END
166
167 # Get the configuration of eth0
168 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
169 FOR ${network_configuration} IN @{network_configurations}
170 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}'
171 ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
172 ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
173 ... AND Exit For Loop
174 END
175