blob: 4a996979a46395d23e310da3d40ffeeb4901f8ad [file] [log] [blame]
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -05001*** Settings ***
2Documentation DHCP Network to test suite functionality.
3
4Resource ../lib/openbmc_ffdc.robot
5Resource ../lib/bmc_network_utils.robot
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -05006Library ../lib/bmc_network_utils.py
7
8Suite Setup Suite Setup Execution
Sweta Potthuridda695e2023-04-26 02:10:38 -05009Suite Teardown Run Keywords Restore Configuration AND Redfish.Logout
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050010
Matt Fischer6fb70d92023-10-24 19:06:33 -060011Test Tags BMC_DHCP_Conf
George Keishing87dc4422023-10-20 12:56:30 +053012
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050013*** 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_properties} UseDomainName=${True}
28... UseNTPServers=${True}
29... UseDNSServers=${True}
30
31&{disable_multiple_properties} UseDomainName=${False}
32... UseNTPServers=${False}
33... UseDNSServers=${False}
34
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050035*** Test Cases ***
36
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050037Set 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
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050041
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050042 # property
43 ${dhcp_enable_dict}
44 ${dhcp_disable_dict}
45 ${dns_enable_dict}
46 ${dns_disable_dict}
47 ${domain_name_enable_dict}
48 ${domain_name_disable_dict}
49 ${ntp_enable_dict}
50 ${ntp_disable_dict}
51 ${enable_multiple_properties}
52 ${disable_multiple_properties}
Prashanth Kattif312d202020-05-28 10:56:10 -050053
54
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050055*** Keywords ***
56
57Suite Setup Execution
58 [Documentation] Suite Setup Execution.
59
Sweta Potthuridda695e2023-04-26 02:10:38 -050060 Ping Host ${OPENBMC_HOST}
61 Ping Host ${OPENBMC_HOST_1}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050062 Redfish.Login
63
Sweta Potthuridda695e2023-04-26 02:10:38 -050064 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050065 FOR ${network_configuration} IN @{network_configurations}
Sweta Potthuridda695e2023-04-26 02:10:38 -050066 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
67 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']}
68 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']}
69 ... AND Exit For Loop
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050070 END
71
Sweta Potthuridda695e2023-04-26 02:10:38 -050072 ${network_configurations}= Get Network Configuration Using Channel Number ${1}
73 FOR ${network_configuration} IN @{network_configurations}
74 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST}'
75 ... Run Keywords Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']}
76 ... AND Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']}
77 ... AND Exit For Loop
78 END
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050079
Sweta Potthuridda695e2023-04-26 02:10:38 -050080Get Network Configuration Using Channel Number
81 [Documentation] Get ethernet interface.
82 [Arguments] ${channel_number}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050083
84 # Description of argument(s):
Sweta Potthuridda695e2023-04-26 02:10:38 -050085 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050086
Sweta Potthuridda695e2023-04-26 02:10:38 -050087 ${active_channel_config}= Get Active Channel Config
88 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']}
89 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050090
Sweta Potthuridda695e2023-04-26 02:10:38 -050091 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
George Keishing409df052024-01-17 22:36:14 +053092 RETURN @{network_configurations}
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -050093
94Apply Ethernet Config
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050095 [Documentation] Set the given Ethernet config property.
96 [Arguments] ${property}
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -050097
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050098 # Description of argument(s):
99 # property Ethernet property to be set..
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -0500100
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500101 ${active_channel_config}= Get Active Channel Config
102 Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +0000103 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500104 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -0500105
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500106 ${resp}= Redfish.Get
ganesanb4d430282023-04-27 14:33:23 +0000107 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500108 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
109
Sweta Potthuridda695e2023-04-26 02:10:38 -0500110Restore Configuration
111 [Documentation] Restore the configuration to Both Static Network
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500112
Sweta Potthuridda695e2023-04-26 02:10:38 -0500113 Run Keyword If '${CHANNEL_NUMBER}' == '1' Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway}
114 ... ELSE IF '${CHANNEL_NUMBER}' == '2' Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway}
George Keishing7d92d072023-07-12 08:51:22 -0500115
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500116Verify Ethernet Config Property
117 [Documentation] verify ethernet config properties.
118 [Arguments] ${property} ${response_data}
119
120 # Description of argument(s):
121 # ${property} DHCP Properties in dictionary.
122 # Example:
123 # property value
124 # DHCPEnabled :False
125 # UseDomainName :True
126 # UseNTPServers :True
127 # UseDNSServers :True
128 # ${response_data} DHCP Response data in dictionary.
129 # Example:
130 # property value
131 # DHCPEnabled :False
132 # UseDomainName :True
133 # UseNTPServers :True
134 # UseDNSServers :True
135
136 ${key_map}= Get Dictionary Items ${property}
137 FOR ${key} ${value} IN @{key_map}
138 Should Be Equal As Strings ${response_data['${key}']} ${value}
139 END
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -0500140