blob: e028b0160890558ee13b3f03c0cc6c61d4ee8cc3 [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
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050011*** 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
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050033*** Test Cases ***
34
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050035Set 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
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050039
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050040 # 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}
Prashanth Kattif312d202020-05-28 10:56:10 -050051
52
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050053*** Keywords ***
54
55Suite Setup Execution
56 [Documentation] Suite Setup Execution.
57
Sweta Potthuridda695e2023-04-26 02:10:38 -050058 Ping Host ${OPENBMC_HOST}
59 Ping Host ${OPENBMC_HOST_1}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050060 Redfish.Login
61
Sweta Potthuridda695e2023-04-26 02:10:38 -050062 ${network_configurations}= Get Network Configuration Using Channel Number ${2}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050063 FOR ${network_configuration} IN @{network_configurations}
Sweta Potthuridda695e2023-04-26 02:10:38 -050064 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
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050068 END
69
Sweta Potthuridda695e2023-04-26 02:10:38 -050070 ${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
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050077
Sweta Potthuridda695e2023-04-26 02:10:38 -050078Get Network Configuration Using Channel Number
79 [Documentation] Get ethernet interface.
80 [Arguments] ${channel_number}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050081
82 # Description of argument(s):
Sweta Potthuridda695e2023-04-26 02:10:38 -050083 # 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 -050084
Sweta Potthuridda695e2023-04-26 02:10:38 -050085 ${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}
Anves Kumar rayankula5a57faf2020-05-19 05:47:44 -050088
Sweta Potthuridda695e2023-04-26 02:10:38 -050089 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
90 [Return] @{network_configurations}
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -050091
92Apply Ethernet Config
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050093 [Documentation] Set the given Ethernet config property.
94 [Arguments] ${property}
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -050095
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050096 # Description of argument(s):
97 # property Ethernet property to be set..
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -050098
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -050099 ${active_channel_config}= Get Active Channel Config
100 Redfish.Patch
ganesanb4d430282023-04-27 14:33:23 +0000101 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}/
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500102 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -0500103
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500104 ${resp}= Redfish.Get
ganesanb4d430282023-04-27 14:33:23 +0000105 ... /redfish/v1/Managers/${MANAGER_ID}/EthernetInterfaces/${active_channel_config['${CHANNEL_NUMBER}']['name']}
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500106 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]}
107
Sweta Potthuridda695e2023-04-26 02:10:38 -0500108Restore Configuration
109 [Documentation] Restore the configuration to Both Static Network
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500110
Sweta Potthuridda695e2023-04-26 02:10:38 -0500111 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
Anves Kumar rayankula7a68d892020-07-10 00:30:13 -0500114Verify 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
Anves Kumar rayankula8115e1e2020-07-03 01:22:09 -0500138