blob: d91c6114581177d3112bc75b5d78788786d58773 [file] [log] [blame]
Prashanth Kattif58cce02019-02-06 03:05:14 -06001*** Settings ***
2Documentation Network interface configuration and verification
3 ... tests.
4
George Keishing5d467552019-02-08 23:30:48 -06005Resource ../../lib/bmc_redfish_resource.robot
6Resource ../../lib/bmc_network_utils.robot
7Resource ../../lib/openbmc_ffdc.robot
Prashanth Katti747ce9d2019-02-07 07:23:48 -06008Library ../../lib/bmc_network_utils.py
Prashanth Kattif58cce02019-02-06 03:05:14 -06009
10Test Setup Test Setup Execution
11Test Teardown Test Teardown Execution
12
Prashanth Katti23efc6e2019-03-13 06:07:15 -050013*** Variables ***
14${test_hostname} openbmc
15
Prashanth Kattif58cce02019-02-06 03:05:14 -060016*** Test Cases ***
17
18Get IP Address And Verify
19 [Documentation] Get IP Address And Verify.
George Keishing5d467552019-02-08 23:30:48 -060020 [Tags] Get_IP_Address_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060021
22 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060023 \ Verify IP On BMC ${network_configuration['Address']}
24
Prashanth Kattif58cce02019-02-06 03:05:14 -060025Get Netmask And Verify
26 [Documentation] Get Netmask And Verify.
George Keishing5d467552019-02-08 23:30:48 -060027 [Tags] Get_Netmask_And_Verify
Prashanth Kattif58cce02019-02-06 03:05:14 -060028
29 : FOR ${network_configuration} IN @{network_configurations}
Prashanth Katti747ce9d2019-02-07 07:23:48 -060030 \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
31
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060032Get Gateway And Verify
33 [Documentation] Get gateway and verify it's existence on the BMC.
34 [Tags] Get_Gateway_And_Verify
35
36 : FOR ${network_configuration} IN @{network_configurations}
37 \ Verify Gateway On BMC ${network_configuration['Gateway']}
38
39Get MAC Address And Verify
40 [Documentation] Get MAC address and verify it's existence on the BMC.
41 [Tags] Get_MAC_Address_And_Verify
42
George Keishing97c93942019-03-04 12:45:07 -060043 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -060044 ${macaddr}= Get From Dictionary ${resp.dict} MACAddress
45 Validate MAC On BMC ${macaddr}
Prashanth Kattif58cce02019-02-06 03:05:14 -060046
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -060047Verify All Configured IP And Netmask
48 [Documentation] Verify all configured IP and netmask on BMC.
49 [Tags] Verify_All_Configured_IP_And_Netmask
50
51 : FOR ${network_configuration} IN @{network_configurations}
52 \ Verify IP And Netmask On BMC ${network_configuration['Address']}
53 ... ${network_configuration['SubnetMask']}
54
Prashanth Katti23efc6e2019-03-13 06:07:15 -050055Get Hostname And Verify
56 [Documentation] Get hostname via Redfish and verify.
57 [Tags] Get_Hostname_And_Verify
58
59 ${hostname}= Redfish_Utils.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
60
61 Validate Hostname On BMC ${hostname}
62
63Configure Hostname And Verify
64 [Documentation] Configure hostname via Redfish and verify.
65 [Tags] Configure_Hostname_And_Verify
66
67 Configure Hostname ${test_hostname}
68
69 Validate Hostname On BMC ${test_hostname}
70
Prashanth Kattif58cce02019-02-06 03:05:14 -060071*** Keywords ***
72
73Test Setup Execution
74 [Documentation] Test setup execution.
75
George Keishing97c93942019-03-04 12:45:07 -060076 Redfish.Login
Prashanth Kattif58cce02019-02-06 03:05:14 -060077
78 @{network_configurations}= Get Network Configuration
79 Set Test Variable @{network_configurations}
80
81 # Get BMC IP address and prefix length.
82 ${ip_data}= Get BMC IP Info
83 Set Test Variable ${ip_data}
84
Prashanth Katti747ce9d2019-02-07 07:23:48 -060085
Prashanth Kattif58cce02019-02-06 03:05:14 -060086Get Network Configuration
87 [Documentation] Get network configuration.
88
89 # Sample output:
90 #{
91 # "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
92 # "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
93 # "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
94 # "Description": "Management Network Interface",
95 # "IPv4Addresses": [
96 # {
97 # "Address": "169.254.xx.xx",
98 # "AddressOrigin": "IPv4LinkLocal",
99 # "Gateway": "0.0.0.0",
100 # "SubnetMask": "255.255.0.0"
101 # },
102 # {
103 # "Address": "xx.xx.xx.xx",
104 # "AddressOrigin": "Static",
105 # "Gateway": "xx.xx.xx.1",
106 # "SubnetMask": "xx.xx.xx.xx"
107 # }
108 # ],
109 # "Id": "eth0",
110 # "MACAddress": "xx:xx:xx:xx:xx:xx",
111 # "Name": "Manager Ethernet Interface",
112 # "SpeedMbps": 0,
113 # "VLAN": {
114 # "VLANEnable": false,
115 # "VLANId": 0
116 # }
117
George Keishing97c93942019-03-04 12:45:07 -0600118 ${resp}= Redfish.Get ${REDFISH_NW_ETH0_URI}
Prashanth Kattif58cce02019-02-06 03:05:14 -0600119 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4Addresses
120 [Return] @{network_configurations}
121
George Keishing5d467552019-02-08 23:30:48 -0600122
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600123Verify IP On BMC
124 [Documentation] Verify IP on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600125 [Arguments] ${ip}
126
127 # Description of the argument(s):
128 # ip IP address to be verified.
129
130 # Get IP address details on BMC using IP command.
131 @{ip_data}= Get BMC IP Info
132 Should Contain Match ${ip_data} ${ip}/*
133 ... msg=IP address does not exist.
134
George Keishing5d467552019-02-08 23:30:48 -0600135
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600136Verify Netmask On BMC
137 [Documentation] Verify netmask on BMC.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600138 [Arguments] ${netmask}
139
140 # Description of the argument(s):
141 # netmask netmask value to be verified.
142
Prashanth Katti747ce9d2019-02-07 07:23:48 -0600143 ${prefix_length}= Netmask Prefix Length ${netmask}
144
145 Should Contain Match ${ip_data} */${prefix_length}
146 ... msg=Prefix length does not exist.
Prashanth Kattif58cce02019-02-06 03:05:14 -0600147
Prashanth Katti2ec9d8b2019-02-12 05:20:19 -0600148Verify Gateway On BMC
149 [Documentation] Verify gateway on BMC.
150 [Arguments] ${gateway_ip}=0.0.0.0
151
152 # Description of argument(s):
153 # gateway_ip Gateway IP address.
154
155 ${route_info}= Get BMC Route Info
156
157 # If gateway IP is empty or 0.0.0.0 it will not have route entry.
158
159 Run Keyword If '${gateway_ip}' == '0.0.0.0'
160 ... Pass Execution Gateway IP is "0.0.0.0".
161 ... ELSE
162 ... Should Contain ${route_info} ${gateway_ip}
163 ... msg=Gateway IP address not matching.
George Keishing5d467552019-02-08 23:30:48 -0600164
Prashanth Katti2c5c3bb2019-02-14 04:23:07 -0600165Verify IP And Netmask On BMC
166 [Documentation] Verify IP and netmask on BMC.
167 [Arguments] ${ip} ${netmask}
168
169 # Description of the argument(s):
170 # ip IP address to be verified.
171 # netmask netmask value to be verified.
172
173 ${prefix_length}= Netmask Prefix Length ${netmask}
174 @{ip_data}= Get BMC IP Info
175
176 ${ip_with_netmask}= Catenate ${ip}/${prefix_length}
177 Should Contain ${ip_data} ${ip_with_netmask}
178 ... msg=IP and netmask pair does not exist.
179
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500180Configure Hostname
181 [Documentation] Configure hostname on BMC via Redfish.
182 [Arguments] ${hostname}
183
184 # Description of argument(s):
185 # hostname A hostname value which is to be configured on BMC.
186
187 ${data}= Create Dictionary HostName=${hostname}
188 Redfish.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data}
189
190Validate Hostname On BMC
191 [Documentation] Verify that the hostname read via Redfish is the same as the
192 ... hostname configured on system.
193 [Arguments] ${hostname}
194
195 # Description of argument(s):
196 # hostname A hostname value which is to be compared to the hostname
197 # configured on system.
198
199 ${sys_hostname}= Get BMC Hostname
Prashanth Katti466d8342019-03-21 08:58:50 -0500200 Should Be Equal ${sys_hostname} ${hostname}
Prashanth Katti23efc6e2019-03-13 06:07:15 -0500201 ... ignore_case=True msg=Hostname does not exist.
202
Prashanth Kattif58cce02019-02-06 03:05:14 -0600203Test Teardown Execution
204 [Documentation] Test teardown execution.
205
206 FFDC On Test Case Fail
George Keishing97c93942019-03-04 12:45:07 -0600207 Redfish.Logout