1f58cce03SPrashanth Katti*** Settings ***
2f58cce03SPrashanth KattiDocumentation  Network interface configuration and verification
3f58cce03SPrashanth Katti               ...  tests.
4f58cce03SPrashanth Katti
5f58cce03SPrashanth KattiResource       ../../lib/bmc_redfish_resource.robot
6f58cce03SPrashanth KattiResource       ../../lib/bmc_network_utils.robot
7f58cce03SPrashanth KattiResource       ../../lib/openbmc_ffdc.robot
8747ce9d0SPrashanth KattiLibrary        ../../lib/bmc_network_utils.py
9de3bf7b5SVijayLibrary        Collections
10f58cce03SPrashanth Katti
11f58cce03SPrashanth KattiTest Setup     Test Setup Execution
12f58cce03SPrashanth KattiTest Teardown  Test Teardown Execution
13f58cce03SPrashanth Katti
14f34fafabSPrashanth KattiForce Tags     Network_Conf_Test
15f34fafabSPrashanth Katti
1623efc6e3SPrashanth Katti*** Variables ***
1723efc6e3SPrashanth Katti${test_hostname}           openbmc
18de3bf7b5SVijay${test_ipv4_addr}          10.7.7.7
19de3bf7b5SVijay${test_ipv4_invalid_addr}  0.0.1.a
20de3bf7b5SVijay${test_subnet_mask}        255.255.0.0
21de3bf7b5SVijay${test_gateway}            10.7.7.1
22b36a7521SPrashanth Katti${broadcast_ip}            10.7.7.255
23b36a7521SPrashanth Katti${loopback_ip}             127.0.0.2
24b36a7521SPrashanth Katti${multicast_ip}            224.6.6.6
25b36a7521SPrashanth Katti${out_of_range_ip}         10.7.7.256
2623efc6e3SPrashanth Katti
27040c8c12SPrashanth Katti# Valid netmask is 4 bytes long and has continuos block of 1s.
28040c8c12SPrashanth Katti# Maximum valid value in each octet is 255 and least value is 0.
29040c8c12SPrashanth Katti# 253 is not valid, as binary value is 11111101.
30040c8c12SPrashanth Katti${invalid_netmask}         255.255.253.0
31040c8c12SPrashanth Katti${alpha_netmask}           ff.ff.ff.ff
32040c8c12SPrashanth Katti# Maximum value of octet in netmask is 255.
33040c8c12SPrashanth Katti${out_of_range_netmask}    255.256.255.0
34040c8c12SPrashanth Katti${more_byte_netmask}       255.255.255.0.0
35040c8c12SPrashanth Katti${less_byte_netmask}       255.255.255
36c6ad647fSPrashanth Katti${threshold_netmask}       255.255.255.255
37c6ad647fSPrashanth Katti${lowest_netmask}          128.0.0.0
38c6ad647fSPrashanth Katti
39c6ad647fSPrashanth Katti# There will be 4 octets in IP address (e.g. xx.xx.xx.xx)
40c6ad647fSPrashanth Katti# but trying to configure xx.xx.xx
41c6ad647fSPrashanth Katti${less_octet_ip}           10.3.36
42c6ad647fSPrashanth Katti
43c6ad647fSPrashanth Katti# For the address 10.6.6.6, the 10.6.6.0 portion describes the
44c6ad647fSPrashanth Katti# network ID and the 6 describe the host.
45c6ad647fSPrashanth Katti
46c6ad647fSPrashanth Katti${network_id}              10.7.7.0
47c6ad647fSPrashanth Katti${hex_ip}                  0xa.0xb.0xc.0xd
48c6ad647fSPrashanth Katti${negative_ip}             10.-7.-7.7
49c6ad647fSPrashanth Katti${hex_ip}                  0xa.0xb.0xc.0xd
507098c976SPrashanth Katti@{static_name_servers}     10.5.5.5
513c7b6439SPrashanth Katti@{null_value}              null
52afe16b72SPrashanth Katti@{empty_dictionary}        {}
53afe16b72SPrashanth Katti@{string_value}            aa.bb.cc.dd
54afe16b72SPrashanth Katti
55f58cce03SPrashanth Katti*** Test Cases ***
56f58cce03SPrashanth Katti
57f58cce03SPrashanth KattiGet IP Address And Verify
58f58cce03SPrashanth Katti    [Documentation]  Get IP Address And Verify.
59f58cce03SPrashanth Katti    [Tags]  Get_IP_Address_And_Verify
60f58cce03SPrashanth Katti
61f58cce03SPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
62747ce9d0SPrashanth Katti    \  Verify IP On BMC  ${network_configuration['Address']}
63747ce9d0SPrashanth Katti
64f58cce03SPrashanth KattiGet Netmask And Verify
65f58cce03SPrashanth Katti    [Documentation]  Get Netmask And Verify.
66f58cce03SPrashanth Katti    [Tags]  Get_Netmask_And_Verify
67f58cce03SPrashanth Katti
68f58cce03SPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
69747ce9d0SPrashanth Katti    \  Verify Netmask On BMC  ${network_configuration['SubnetMask']}
70747ce9d0SPrashanth Katti
712ec9d8b6SPrashanth KattiGet Gateway And Verify
722ec9d8b6SPrashanth Katti    [Documentation]  Get gateway and verify it's existence on the BMC.
732ec9d8b6SPrashanth Katti    [Tags]  Get_Gateway_And_Verify
742ec9d8b6SPrashanth Katti
752ec9d8b6SPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
762ec9d8b6SPrashanth Katti    \  Verify Gateway On BMC  ${network_configuration['Gateway']}
772ec9d8b6SPrashanth Katti
782ec9d8b6SPrashanth KattiGet MAC Address And Verify
792ec9d8b6SPrashanth Katti    [Documentation]  Get MAC address and verify it's existence on the BMC.
802ec9d8b6SPrashanth Katti    [Tags]  Get_MAC_Address_And_Verify
812ec9d8b6SPrashanth Katti
8297c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH0_URI}
832ec9d8b6SPrashanth Katti    ${macaddr}=  Get From Dictionary  ${resp.dict}  MACAddress
842ec9d8b6SPrashanth Katti    Validate MAC On BMC  ${macaddr}
85f58cce03SPrashanth Katti
862c5c3bbdSPrashanth KattiVerify All Configured IP And Netmask
872c5c3bbdSPrashanth Katti    [Documentation]  Verify all configured IP and netmask on BMC.
882c5c3bbdSPrashanth Katti    [Tags]  Verify_All_Configured_IP_And_Netmask
892c5c3bbdSPrashanth Katti
902c5c3bbdSPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
912c5c3bbdSPrashanth Katti    \  Verify IP And Netmask On BMC  ${network_configuration['Address']}
922c5c3bbdSPrashanth Katti    ...  ${network_configuration['SubnetMask']}
932c5c3bbdSPrashanth Katti
9423efc6e3SPrashanth KattiGet Hostname And Verify
9523efc6e3SPrashanth Katti    [Documentation]  Get hostname via Redfish and verify.
9623efc6e3SPrashanth Katti    [Tags]  Get_Hostname_And_Verify
9723efc6e3SPrashanth Katti
9823efc6e3SPrashanth Katti    ${hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
9923efc6e3SPrashanth Katti
10023efc6e3SPrashanth Katti    Validate Hostname On BMC  ${hostname}
10123efc6e3SPrashanth Katti
10223efc6e3SPrashanth KattiConfigure Hostname And Verify
10323efc6e3SPrashanth Katti    [Documentation]  Configure hostname via Redfish and verify.
10423efc6e3SPrashanth Katti    [Tags]  Configure_Hostname_And_Verify
10523efc6e3SPrashanth Katti
106adf0b4e7SPrashanth Katti    ${hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
10723efc6e3SPrashanth Katti
108adf0b4e7SPrashanth Katti    Configure Hostname  ${test_hostname}
10923efc6e3SPrashanth Katti    Validate Hostname On BMC  ${test_hostname}
11023efc6e3SPrashanth Katti
111adf0b4e7SPrashanth Katti    # Revert back to initial hostname.
112adf0b4e7SPrashanth Katti    Configure Hostname  ${hostname}
113adf0b4e7SPrashanth Katti    Validate Hostname On BMC  ${hostname}
114adf0b4e7SPrashanth Katti
115de3bf7b5SVijayAdd Valid IPv4 Address And Verify
116de3bf7b5SVijay    [Documentation]  Add IPv4 Address via Redfish and verify.
117de3bf7b5SVijay    [Tags]  Add_Valid_IPv4_Addres_And_Verify
118de3bf7b5SVijay
119de3bf7b5SVijay     Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
120de3bf7b5SVijay     Delete IP Address  ${test_ipv4_addr}
121de3bf7b5SVijay
122de3bf7b5SVijayAdd Invalid IPv4 Address And Verify
123de3bf7b5SVijay    [Documentation]  Add Invalid IPv4 Address via Redfish and verify.
124de3bf7b5SVijay    [Tags]  Add_Invalid_IPv4_Addres_And_Verify
125de3bf7b5SVijay
126de3bf7b5SVijay    Add IP Address  ${test_ipv4_invalid_addr}  ${test_subnet_mask}
127de3bf7b5SVijay    ...  ${test_gateway}  valid_status_codes=${HTTP_BAD_REQUEST}
128de3bf7b5SVijay
129b36a7521SPrashanth KattiConfigure Out Of Range IP
130b36a7521SPrashanth Katti    [Documentation]  Configure out-of-range IP address.
131b36a7521SPrashanth Katti    [Tags]  Configure_Out_Of_Range_IP
132b36a7521SPrashanth Katti    [Template]  Add IP Address
133b36a7521SPrashanth Katti
134b36a7521SPrashanth Katti    # ip                subnet_mask          gateway          valid_status_codes
135b36a7521SPrashanth Katti    ${out_of_range_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
136b36a7521SPrashanth Katti
137b36a7521SPrashanth KattiConfigure Broadcast IP
138b36a7521SPrashanth Katti    [Documentation]  Configure broadcast IP address.
139b36a7521SPrashanth Katti    [Tags]  Configure_Broadcast_IP
140b36a7521SPrashanth Katti    [Template]  Add IP Address
141c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${broadcast_ip}
142b36a7521SPrashanth Katti
143b36a7521SPrashanth Katti    # ip             subnet_mask          gateway          valid_status_codes
144b36a7521SPrashanth Katti    ${broadcast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
145b36a7521SPrashanth Katti
146b36a7521SPrashanth KattiConfigure Multicast IP
147b36a7521SPrashanth Katti    [Documentation]  Configure multicast IP address.
148b36a7521SPrashanth Katti    [Tags]  Configure_Multicast_IP
149b36a7521SPrashanth Katti    [Template]  Add IP Address
150c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${multicast_ip}
151b36a7521SPrashanth Katti
152b36a7521SPrashanth Katti    # ip             subnet_mask          gateway          valid_status_codes
153b36a7521SPrashanth Katti    ${multicast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
154b36a7521SPrashanth Katti
155b36a7521SPrashanth KattiConfigure Loopback IP
156b36a7521SPrashanth Katti    [Documentation]  Configure loopback IP address.
157b36a7521SPrashanth Katti    [Tags]  Configure_Loopback_IP
158b36a7521SPrashanth Katti    [Template]  Add IP Address
159c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${loopback_ip}
160b36a7521SPrashanth Katti
161b36a7521SPrashanth Katti    # ip            subnet_mask          gateway          valid_status_codes
162b36a7521SPrashanth Katti    ${loopback_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
163b36a7521SPrashanth Katti
164b36a7521SPrashanth KattiAdd Valid IPv4 Address And Check Persistency
165b36a7521SPrashanth Katti    [Documentation]  Add IPv4 address and check peristency.
166b36a7521SPrashanth Katti    [Tags]  Add_Valid_IPv4_Addres_And_Check_Persistency
167b36a7521SPrashanth Katti
168b36a7521SPrashanth Katti    Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
169b36a7521SPrashanth Katti
170b36a7521SPrashanth Katti    # Reboot BMC and verify persistency.
171b36a7521SPrashanth Katti    OBMC Reboot (off)
1725c498748SGeorge Keishing    Redfish.Login
173b36a7521SPrashanth Katti    Verify IP On BMC  ${test_ipv4_addr}
174b36a7521SPrashanth Katti    Delete IP Address  ${test_ipv4_addr}
175de3bf7b5SVijay
1766cedca29SPrashanth KattiAdd Fourth Octet Threshold IP And Verify
1776cedca29SPrashanth Katti    [Documentation]  Add fourth octet threshold IP and verify.
1786cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Threshold_IP_And_Verify
1796cedca29SPrashanth Katti
1806cedca29SPrashanth Katti     Add IP Address  10.7.7.254  ${test_subnet_mask}  ${test_gateway}
1816cedca29SPrashanth Katti     Delete IP Address  10.7.7.254
1826cedca29SPrashanth Katti
1836cedca29SPrashanth KattiAdd Fourth Octet Lowest IP And Verify
1846cedca29SPrashanth Katti    [Documentation]  Add fourth octet lowest IP and verify.
1856cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Lowest_IP_And_Verify
1866cedca29SPrashanth Katti
1876cedca29SPrashanth Katti     Add IP Address  10.7.7.1  ${test_subnet_mask}  ${test_gateway}
1886cedca29SPrashanth Katti     Delete IP Address  10.7.7.1
1896cedca29SPrashanth Katti
1906cedca29SPrashanth KattiAdd Third Octet Threshold IP And Verify
1916cedca29SPrashanth Katti    [Documentation]  Add third octet threshold IP and verify.
1926cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Threshold_IP_And_Verify
1936cedca29SPrashanth Katti
1946cedca29SPrashanth Katti     Add IP Address  10.7.255.7  ${test_subnet_mask}  ${test_gateway}
1956cedca29SPrashanth Katti     Delete IP Address  10.7.255.7
1966cedca29SPrashanth Katti
1976cedca29SPrashanth KattiAdd Third Octet Lowest IP And Verify
1986cedca29SPrashanth Katti    [Documentation]  Add third octet lowest IP and verify.
1996cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Lowest_IP_And_Verify
2006cedca29SPrashanth Katti
2016cedca29SPrashanth Katti     Add IP Address  10.7.0.7  ${test_subnet_mask}  ${test_gateway}
2026cedca29SPrashanth Katti     Delete IP Address  10.7.0.7
2036cedca29SPrashanth Katti
2046cedca29SPrashanth KattiAdd Second Octet Threshold IP And Verify
2056cedca29SPrashanth Katti    [Documentation]  Add second octet threshold IP and verify.
2066cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Threshold_IP_And_Verify
2076cedca29SPrashanth Katti
2086cedca29SPrashanth Katti     Add IP Address  10.255.7.7  ${test_subnet_mask}  ${test_gateway}
2096cedca29SPrashanth Katti     Delete IP Address  10.255.7.7
2106cedca29SPrashanth Katti
2116cedca29SPrashanth KattiAdd Second Octet Lowest IP And Verify
2126cedca29SPrashanth Katti    [Documentation]  Add second octet lowest IP and verify.
2136cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Lowest_IP_And_Verify
2146cedca29SPrashanth Katti
2156cedca29SPrashanth Katti     Add IP Address  10.0.7.7  ${test_subnet_mask}  ${test_gateway}
2166cedca29SPrashanth Katti     Delete IP Address  10.0.7.7
2176cedca29SPrashanth Katti
2186cedca29SPrashanth KattiAdd First Octet Threshold IP And Verify
2196cedca29SPrashanth Katti    [Documentation]  Add first octet threshold IP and verify.
2206cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Threshold_IP_And_Verify
2216cedca29SPrashanth Katti
2226cedca29SPrashanth Katti     Add IP Address  223.7.7.7  ${test_subnet_mask}  ${test_gateway}
2236cedca29SPrashanth Katti     Delete IP Address  223.7.7.7
2246cedca29SPrashanth Katti
2256cedca29SPrashanth KattiAdd First Octet Lowest IP And Verify
2266cedca29SPrashanth Katti    [Documentation]  Add first octet lowest IP and verify.
2276cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Lowest_IP_And_Verify
2286cedca29SPrashanth Katti
2296cedca29SPrashanth Katti     Add IP Address  1.7.7.7  ${test_subnet_mask}  ${test_gateway}
2306cedca29SPrashanth Katti     Delete IP Address  1.7.7.7
2316cedca29SPrashanth Katti
232040c8c12SPrashanth KattiConfigure Invalid Netmask
233040c8c12SPrashanth Katti    [Documentation]  Verify error while setting invalid netmask.
234040c8c12SPrashanth Katti    [Tags]  Configure_Invalid_Netmask
235040c8c12SPrashanth Katti    [Template]  Add IP Address
236040c8c12SPrashanth Katti
237040c8c12SPrashanth Katti    # ip               subnet_mask         gateway          valid_status_codes
238040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${invalid_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
239040c8c12SPrashanth Katti
240040c8c12SPrashanth KattiConfigure Out Of Range Netmask
241040c8c12SPrashanth Katti    [Documentation]  Verify error while setting out of range netmask.
242040c8c12SPrashanth Katti    [Tags]  Configure_Out_Of_Range_Netmask
243040c8c12SPrashanth Katti    [Template]  Add IP Address
244040c8c12SPrashanth Katti
245040c8c12SPrashanth Katti    # ip               subnet_mask              gateway          valid_status_codes
246040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${out_of_range_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
247040c8c12SPrashanth Katti
248040c8c12SPrashanth KattiConfigure Alpha Netmask
249040c8c12SPrashanth Katti    [Documentation]  Verify error while setting alpha netmask.
250040c8c12SPrashanth Katti    [Tags]  Configure_Alpha_Netmask
251040c8c12SPrashanth Katti    [Template]  Add IP Address
252040c8c12SPrashanth Katti
253040c8c12SPrashanth Katti    # ip               subnet_mask       gateway          valid_status_codes
254040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${alpha_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
255040c8c12SPrashanth Katti
256040c8c12SPrashanth KattiConfigure More Byte Netmask
257040c8c12SPrashanth Katti    [Documentation]  Verify error while setting more byte netmask.
258040c8c12SPrashanth Katti    [Tags]  Configure_More_Byte_Netmask
259040c8c12SPrashanth Katti    [Template]  Add IP Address
260040c8c12SPrashanth Katti
261040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
262040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${more_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
263040c8c12SPrashanth Katti
264040c8c12SPrashanth KattiConfigure Less Byte Netmask
265040c8c12SPrashanth Katti    [Documentation]  Verify error while setting less byte netmask.
266040c8c12SPrashanth Katti    [Tags]  Configure_Less_Byte_Netmask
267040c8c12SPrashanth Katti    [Template]  Add IP Address
268040c8c12SPrashanth Katti
269040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
270040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${less_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
271040c8c12SPrashanth Katti
272c6ad647fSPrashanth KattiConfigure Threshold Netmask And Verify
273c6ad647fSPrashanth Katti    [Documentation]  Configure threshold netmask and verify.
274c6ad647fSPrashanth Katti    [Tags]  Configure_Threshold_Netmask_And_verify
275c6ad647fSPrashanth Katti
276c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${threshold_netmask}  ${test_gateway}
277c6ad647fSPrashanth Katti     Delete IP Address  ${test_ipv4_addr}
278c6ad647fSPrashanth Katti
279c6ad647fSPrashanth KattiConfigure Lowest Netmask And Verify
280c6ad647fSPrashanth Katti    [Documentation]  Configure lowest netmask and verify.
281c6ad647fSPrashanth Katti    [Tags]  Configure_Lowest_Netmask_And_verify
282c6ad647fSPrashanth Katti
283c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${lowest_netmask}  ${test_gateway}
284c6ad647fSPrashanth Katti     Delete IP Address  ${test_ipv4_addr}
285c6ad647fSPrashanth Katti
286c6ad647fSPrashanth KattiConfigure Network ID
287c6ad647fSPrashanth Katti    [Documentation]  Verify error while configuring network ID.
288c6ad647fSPrashanth Katti    [Tags]  Configure_Network_ID
289c6ad647fSPrashanth Katti    [Template]  Add IP Address
290c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${network_id}
291c6ad647fSPrashanth Katti
292c6ad647fSPrashanth Katti    # ip           subnet_mask          gateway          valid_status_codes
293c6ad647fSPrashanth Katti    ${network_id}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
294c6ad647fSPrashanth Katti
295c6ad647fSPrashanth KattiConfigure Less Octet IP
296c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring less octet IP address.
297c6ad647fSPrashanth Katti    [Tags]  Configure_Less_Octet_IP
298c6ad647fSPrashanth Katti    [Template]  Add IP Address
299c6ad647fSPrashanth Katti
300c6ad647fSPrashanth Katti    # ip              subnet_mask          gateway          valid_status_codes
301c6ad647fSPrashanth Katti    ${less_octet_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
302c6ad647fSPrashanth Katti
303c6ad647fSPrashanth KattiConfigure Empty IP
304c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring empty IP address.
305c6ad647fSPrashanth Katti    [Tags]  Configure_Empty_IP
306c6ad647fSPrashanth Katti    [Template]  Add IP Address
307c6ad647fSPrashanth Katti
308c6ad647fSPrashanth Katti    # ip      subnet_mask          gateway          valid_status_codes
309c6ad647fSPrashanth Katti    ${EMPTY}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
310c6ad647fSPrashanth Katti
311c6ad647fSPrashanth KattiConfigure Special Char IP
312c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing special chars.
313c6ad647fSPrashanth Katti    [Tags]  Configure_Special_Char_IP
314c6ad647fSPrashanth Katti    [Template]  Add IP Address
315c6ad647fSPrashanth Katti
316c6ad647fSPrashanth Katti    # ip          subnet_mask          gateway          valid_status_codes
317c6ad647fSPrashanth Katti    @@@.%%.44.11  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
318c6ad647fSPrashanth Katti
319c6ad647fSPrashanth KattiConfigure Hexadecimal IP
320c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing hex value.
321c6ad647fSPrashanth Katti    [Tags]  Configure_Hexadecimal_IP
322c6ad647fSPrashanth Katti    [Template]  Add IP Address
323c6ad647fSPrashanth Katti
324c6ad647fSPrashanth Katti    # ip       subnet_mask          gateway          valid_status_codes
325c6ad647fSPrashanth Katti    ${hex_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
326c6ad647fSPrashanth Katti
327c6ad647fSPrashanth KattiConfigure Negative Octet IP
328c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing negative octet.
329c6ad647fSPrashanth Katti    [Tags]  Configure_Negative_Octet_IP
330c6ad647fSPrashanth Katti    [Template]  Add IP Address
331c6ad647fSPrashanth Katti
332c6ad647fSPrashanth Katti    # ip            subnet_mask          gateway          valid_status_codes
333c6ad647fSPrashanth Katti    ${negative_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
334c6ad647fSPrashanth Katti
3355cad5a07SPrashanth KattiConfigure Incomplete IP For Gateway
3365cad5a07SPrashanth Katti    [Documentation]  Configure incomplete IP for gateway and expect an error.
3375cad5a07SPrashanth Katti    [Tags]  Configure_Incomplete_IP_For_Gateway
3385cad5a07SPrashanth Katti    [Template]  Add IP Address
3395cad5a07SPrashanth Katti
3405cad5a07SPrashanth Katti    # ip               subnet_mask          gateway           valid_status_codes
3415cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${less_octet_ip}  ${HTTP_BAD_REQUEST}
3425cad5a07SPrashanth Katti
3435cad5a07SPrashanth KattiConfigure Special Char IP For Gateway
3445cad5a07SPrashanth Katti    [Documentation]  Configure special char IP for gateway and expect an error.
3455cad5a07SPrashanth Katti    [Tags]  Configure_Special_Char_IP_For_Gateway
3465cad5a07SPrashanth Katti    [Template]  Add IP Address
3475cad5a07SPrashanth Katti
3485cad5a07SPrashanth Katti    # ip               subnet_mask          gateway       valid_status_codes
3495cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  @@@.%%.44.11  ${HTTP_BAD_REQUEST}
3505cad5a07SPrashanth Katti
3515cad5a07SPrashanth KattiConfigure Hexadecimal IP For Gateway
3525cad5a07SPrashanth Katti    [Documentation]  Configure hexadecimal IP for gateway and expect an error.
3535cad5a07SPrashanth Katti    [Tags]  Configure_Hexadecimal_IP_For_Gateway
3545cad5a07SPrashanth Katti    [Template]  Add IP Address
3555cad5a07SPrashanth Katti
3565cad5a07SPrashanth Katti    # ip               subnet_mask          gateway    valid_status_codes
3575cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${hex_ip}  ${HTTP_BAD_REQUEST}
3585cad5a07SPrashanth Katti
3597098c976SPrashanth KattiGet DNS Server And Verify
3607098c976SPrashanth Katti    [Documentation]  Get DNS server via Redfish and verify.
3617098c976SPrashanth Katti    [Tags]  Get_DNS_Server_And_Verify
3627098c976SPrashanth Katti
3637098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3647098c976SPrashanth Katti
3657098c976SPrashanth KattiConfigure DNS Server And Verify
3667098c976SPrashanth Katti    [Documentation]  Configure DNS server and verify.
3677098c976SPrashanth Katti    [Tags]  Configure_DNS_Server_And_Verify
368c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
3697098c976SPrashanth Katti    [Teardown]  Run Keywords
3707098c976SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
3717098c976SPrashanth Katti
3727098c976SPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
3737098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3747098c976SPrashanth Katti
375c85957cdSPrashanth KattiDelete DNS Server And Verify
376c85957cdSPrashanth Katti    [Documentation]  Delete DNS server and verify.
377c85957cdSPrashanth Katti    [Tags]  Delete_DNS_Server_And_Verify
378c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
379c85957cdSPrashanth Katti    [Teardown]  Run Keywords
380c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
381c85957cdSPrashanth Katti
382c85957cdSPrashanth Katti    Delete Static Name Servers
383c85957cdSPrashanth Katti    Verify CLI and Redfish Nameservers
384c85957cdSPrashanth Katti
385c85957cdSPrashanth KattiConfigure DNS Server And Check Persistency
386c85957cdSPrashanth Katti    [Documentation]  Configure DNS server and check persistency on reboot.
387c85957cdSPrashanth Katti    [Tags]  Configure_DNS_Server_And_Check_Persistency
388c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
389c85957cdSPrashanth Katti    [Teardown]  Run Keywords
390c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
391c85957cdSPrashanth Katti
392c85957cdSPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
393c85957cdSPrashanth Katti    # Reboot BMC and verify persistency.
394c85957cdSPrashanth Katti    OBMC Reboot (off)
395c85957cdSPrashanth Katti    Verify CLI and Redfish Nameservers
396c85957cdSPrashanth Katti
3973063ffefSPrashanth KattiConfigure Loopback IP For Gateway
3983063ffefSPrashanth Katti    [Documentation]  Configure loopback IP for gateway and expect an error.
3993063ffefSPrashanth Katti    [Tags]  Configure_Loopback_IP_For_Gateway
4003063ffefSPrashanth Katti    [Template]  Add IP Address
4013063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4023063ffefSPrashanth Katti
4033063ffefSPrashanth Katti    # ip               subnet_mask          gateway         valid_status_codes
4043063ffefSPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${loopback_ip}  ${HTTP_BAD_REQUEST}
4053063ffefSPrashanth Katti
4063063ffefSPrashanth KattiConfigure Network ID For Gateway
4073063ffefSPrashanth Katti    [Documentation]  Configure network ID for gateway and expect an error.
4083063ffefSPrashanth Katti    [Tags]  Configure_Network_ID_For_Gateway
4093063ffefSPrashanth Katti    [Template]  Add IP Address
4103063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4113063ffefSPrashanth Katti
4123063ffefSPrashanth Katti    # ip               subnet_mask          gateway        valid_status_codes
4133063ffefSPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${network_id}  ${HTTP_BAD_REQUEST}
4143063ffefSPrashanth Katti
4153063ffefSPrashanth KattiConfigure Multicast IP For Gateway
4163063ffefSPrashanth Katti    [Documentation]  Configure multicast IP for gateway and expect an error.
4173063ffefSPrashanth Katti    [Tags]  Configure_Multicast_IP_For_Gateway
4183063ffefSPrashanth Katti    [Template]  Add IP Address
4193063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4203063ffefSPrashanth Katti
4213063ffefSPrashanth Katti    # ip               subnet_mask          gateway           valid_status_codes
4223063ffefSPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${multicaste_ip}  ${HTTP_BAD_REQUEST}
4233063ffefSPrashanth Katti
4243063ffefSPrashanth KattiConfigure Broadcast IP For Gateway
4253063ffefSPrashanth Katti    [Documentation]  Configure broadcast IP for gateway and expect an error.
4263063ffefSPrashanth Katti    [Tags]  Configure_Broadcast_IP_For_Gateway
4273063ffefSPrashanth Katti    [Template]  Add IP Address
4283063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4293063ffefSPrashanth Katti
4303063ffefSPrashanth Katti    # ip               subnet_mask          gateway          valid_status_codes
4313063ffefSPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${broadcast_ip}  ${HTTP_BAD_REQUEST}
432c85957cdSPrashanth Katti
4333c7b6439SPrashanth KattiConfigure Null Value For DNS Server
4343c7b6439SPrashanth Katti    [Documentation]  Configure null value for DNS server and expect an error.
4353c7b6439SPrashanth Katti    [Tags]  Configure_Null_Value_For_DNS_Server
4363c7b6439SPrashanth Katti    [Setup]  DNS Test Setup Execution
4373c7b6439SPrashanth Katti    [Teardown]  Run Keywords
4383c7b6439SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
4393c7b6439SPrashanth Katti
4403c7b6439SPrashanth Katti    Configure Static Name Servers  ${null_value}  ${HTTP_BAD_REQUEST}
4413c7b6439SPrashanth Katti
442afe16b72SPrashanth KattiConfigure Empty Value For DNS Server
443afe16b72SPrashanth Katti    [Documentation]  Configure empty value for DNS server and expect an error.
444afe16b72SPrashanth Katti    [Tags]  Configure_Empty_Value_For_DNS_Server
445afe16b72SPrashanth Katti    [Setup]  DNS Test Setup Execution
446afe16b72SPrashanth Katti    [Teardown]  Run Keywords
447afe16b72SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
448afe16b72SPrashanth Katti
449afe16b72SPrashanth Katti    Configure Static Name Servers  ${empty_dictionary}  ${HTTP_BAD_REQUEST}
450afe16b72SPrashanth Katti
451afe16b72SPrashanth KattiConfigure String Value For DNS Server
452afe16b72SPrashanth Katti    [Documentation]  Configure string value for DNS server and expect an error.
453afe16b72SPrashanth Katti    [Tags]  Configure_String_Value_For_DNS_Server
454afe16b72SPrashanth Katti    [Setup]  DNS Test Setup Execution
455afe16b72SPrashanth Katti    [Teardown]  Run Keywords
456afe16b72SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
457afe16b72SPrashanth Katti
458afe16b72SPrashanth Katti    Configure Static Name Servers  ${string_value}  ${HTTP_BAD_REQUEST}
459afe16b72SPrashanth Katti
460f58cce03SPrashanth Katti*** Keywords ***
461f58cce03SPrashanth Katti
462f58cce03SPrashanth KattiTest Setup Execution
463f58cce03SPrashanth Katti    [Documentation]  Test setup execution.
464f58cce03SPrashanth Katti
46597c93945SGeorge Keishing    Redfish.Login
466f58cce03SPrashanth Katti
467f58cce03SPrashanth Katti    @{network_configurations}=  Get Network Configuration
468f58cce03SPrashanth Katti    Set Test Variable  @{network_configurations}
469f58cce03SPrashanth Katti
470f58cce03SPrashanth Katti    # Get BMC IP address and prefix length.
471f58cce03SPrashanth Katti    ${ip_data}=  Get BMC IP Info
472f58cce03SPrashanth Katti    Set Test Variable  ${ip_data}
473f58cce03SPrashanth Katti
474747ce9d0SPrashanth Katti
475f58cce03SPrashanth KattiGet Network Configuration
476f58cce03SPrashanth Katti    [Documentation]  Get network configuration.
477f58cce03SPrashanth Katti
478f58cce03SPrashanth Katti    # Sample output:
479f58cce03SPrashanth Katti    #{
480f58cce03SPrashanth Katti    #  "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
481f58cce03SPrashanth Katti    #  "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
482f58cce03SPrashanth Katti    #  "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
483f58cce03SPrashanth Katti    #  "Description": "Management Network Interface",
484f58cce03SPrashanth Katti    #  "IPv4Addresses": [
485f58cce03SPrashanth Katti    #    {
486f58cce03SPrashanth Katti    #      "Address": "169.254.xx.xx",
487f58cce03SPrashanth Katti    #      "AddressOrigin": "IPv4LinkLocal",
488f58cce03SPrashanth Katti    #      "Gateway": "0.0.0.0",
489f58cce03SPrashanth Katti    #      "SubnetMask": "255.255.0.0"
490f58cce03SPrashanth Katti    #    },
491f58cce03SPrashanth Katti    #    {
492f58cce03SPrashanth Katti    #      "Address": "xx.xx.xx.xx",
493f58cce03SPrashanth Katti    #      "AddressOrigin": "Static",
494f58cce03SPrashanth Katti    #      "Gateway": "xx.xx.xx.1",
495f58cce03SPrashanth Katti    #      "SubnetMask": "xx.xx.xx.xx"
496f58cce03SPrashanth Katti    #    }
497f58cce03SPrashanth Katti    #  ],
498f58cce03SPrashanth Katti    #  "Id": "eth0",
499f58cce03SPrashanth Katti    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
500f58cce03SPrashanth Katti    #  "Name": "Manager Ethernet Interface",
501f58cce03SPrashanth Katti    #  "SpeedMbps": 0,
502f58cce03SPrashanth Katti    #  "VLAN": {
503f58cce03SPrashanth Katti    #    "VLANEnable": false,
504f58cce03SPrashanth Katti    #    "VLANId": 0
505f58cce03SPrashanth Katti    #  }
506f58cce03SPrashanth Katti
50797c93945SGeorge Keishing    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH0_URI}
508ff54bff4SPrashanth Katti    @{network_configurations}=  Get From Dictionary  ${resp.dict}  IPv4StaticAddresses
509f58cce03SPrashanth Katti    [Return]  @{network_configurations}
510f58cce03SPrashanth Katti
5115d46755bSGeorge Keishing
512de3bf7b5SVijayAdd IP Address
513de3bf7b5SVijay    [Documentation]  Add IP Address To BMC.
514de3bf7b5SVijay    [Arguments]  ${ip}  ${subnet_mask}  ${gateway}
515de3bf7b5SVijay    ...  ${valid_status_codes}=${HTTP_OK}
516de3bf7b5SVijay
517de3bf7b5SVijay    # Description of argument(s):
518de3bf7b5SVijay    # ip                  IP address to be added (e.g. "10.7.7.7").
519de3bf7b5SVijay    # subnet_mask         Subnet mask for the IP to be added
520de3bf7b5SVijay    #                     (e.g. "255.255.0.0").
521de3bf7b5SVijay    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
522de3bf7b5SVijay    # valid_status_codes  Expected return code from patch operation
523de3bf7b5SVijay    #                     (e.g. "200").  See prolog of rest_request
524de3bf7b5SVijay    #                     method in redfish_plut.py for details.
525de3bf7b5SVijay
526de3bf7b5SVijay    ${empty_dict}=  Create Dictionary
527de3bf7b5SVijay    ${ip_data}=  Create Dictionary  Address=${ip}
528ff54bff4SPrashanth Katti    ...  SubnetMask=${subnet_mask}  Gateway=${gateway}
529de3bf7b5SVijay
530de3bf7b5SVijay    ${patch_list}=  Create List
531de3bf7b5SVijay    ${network_configurations}=  Get Network Configuration
532de3bf7b5SVijay    ${num_entries}=  Get Length  ${network_configurations}
533de3bf7b5SVijay
534de3bf7b5SVijay    : FOR  ${INDEX}  IN RANGE  0  ${num_entries}
535de3bf7b5SVijay    \  Append To List  ${patch_list}  ${empty_dict}
536de3bf7b5SVijay
53798ffa86fSGeorge Keishing    # We need not check for existence of IP on BMC while adding.
538de3bf7b5SVijay    Append To List  ${patch_list}  ${ip_data}
539ff54bff4SPrashanth Katti    ${data}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
540de3bf7b5SVijay
541de3bf7b5SVijay    Redfish.patch  ${REDFISH_NW_ETH0_URI}  body=&{data}
542de3bf7b5SVijay    ...  valid_status_codes=[${valid_status_codes}]
543de3bf7b5SVijay
544de3bf7b5SVijay    Return From Keyword If  '${valid_status_codes}' != '${HTTP_OK}'
545de3bf7b5SVijay
546de3bf7b5SVijay    # Note: Network restart takes around 15-18s after patch request processing.
547de3bf7b5SVijay    Sleep  ${NETWORK_TIMEOUT}s
548de3bf7b5SVijay    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
549de3bf7b5SVijay
550de3bf7b5SVijay    Verify IP On BMC  ${ip}
551de3bf7b5SVijay    Validate Network Config On BMC
552de3bf7b5SVijay
553de3bf7b5SVijay
554de3bf7b5SVijayDelete IP Address
555de3bf7b5SVijay    [Documentation]  Delete IP Address Of BMC.
556de3bf7b5SVijay    [Arguments]  ${ip}  ${valid_status_codes}=${HTTP_OK}
557de3bf7b5SVijay
558de3bf7b5SVijay    # Description of argument(s):
559de3bf7b5SVijay    # ip                  IP address to be deleted (e.g. "10.7.7.7").
560de3bf7b5SVijay    # valid_status_codes  Expected return code from patch operation
561de3bf7b5SVijay    #                     (e.g. "200").  See prolog of rest_request
562de3bf7b5SVijay    #                     method in redfish_plut.py for details.
563de3bf7b5SVijay
564de3bf7b5SVijay    ${empty_dict}=  Create Dictionary
565de3bf7b5SVijay    ${patch_list}=  Create List
566de3bf7b5SVijay
567de3bf7b5SVijay    @{network_configurations}=  Get Network Configuration
568de3bf7b5SVijay    : FOR  ${network_configuration}  IN  @{network_configurations}
569de3bf7b5SVijay    \  Run Keyword If  '${network_configuration['Address']}' == '${ip}'
570de3bf7b5SVijay       ...  Append To List  ${patch_list}  ${null}
571de3bf7b5SVijay       ...  ELSE  Append To List  ${patch_list}  ${empty_dict}
572de3bf7b5SVijay
573de3bf7b5SVijay    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
574de3bf7b5SVijay    ...  ${patch_list}  ${null}  msg=${ip} does not exist on BMC
575de3bf7b5SVijay    Pass Execution If  ${ip_found} == ${False}  ${ip} does not exist on BMC
576de3bf7b5SVijay
577de3bf7b5SVijay    # Run patch command only if given IP is found on BMC
578ff54bff4SPrashanth Katti    ${data}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
579de3bf7b5SVijay
580de3bf7b5SVijay    Redfish.patch  ${REDFISH_NW_ETH0_URI}  body=&{data}
581de3bf7b5SVijay    ...  valid_status_codes=[${valid_status_codes}]
582de3bf7b5SVijay
583de3bf7b5SVijay    # Note: Network restart takes around 15-18s after patch request processing
584de3bf7b5SVijay    Sleep  ${NETWORK_TIMEOUT}s
585de3bf7b5SVijay    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
586de3bf7b5SVijay
587de3bf7b5SVijay    ${delete_status}=  Run Keyword And Return Status  Verify IP On BMC  ${ip}
588de3bf7b5SVijay    Run Keyword If  '${valid_status_codes}' == '${HTTP_OK}'
589de3bf7b5SVijay    ...  Should Be True  ${delete_status} == ${False}
590de3bf7b5SVijay    ...  ELSE  Should Be True  ${delete_status} == ${True}
591de3bf7b5SVijay
592de3bf7b5SVijay    Validate Network Config On BMC
593de3bf7b5SVijay
594de3bf7b5SVijay
595de3bf7b5SVijayValidate Network Config On BMC
596de3bf7b5SVijay    [Documentation]  Check that network info obtained via redfish matches info
597de3bf7b5SVijay    ...              obtained via CLI.
598de3bf7b5SVijay
599de3bf7b5SVijay    @{network_configurations}=  Get Network Configuration
600de3bf7b5SVijay    ${ip_data}=  Get BMC IP Info
601de3bf7b5SVijay    : FOR  ${network_configuration}  IN  @{network_configurations}
602de3bf7b5SVijay    \  Should Contain Match  ${ip_data}  ${network_configuration['Address']}/*
603de3bf7b5SVijay    ...  msg=IP address does not exist.
604de3bf7b5SVijay
6055d46755bSGeorge Keishing
606747ce9d0SPrashanth KattiVerify Netmask On BMC
607747ce9d0SPrashanth Katti    [Documentation]  Verify netmask on BMC.
608f58cce03SPrashanth Katti    [Arguments]  ${netmask}
609f58cce03SPrashanth Katti
610f58cce03SPrashanth Katti    # Description of the argument(s):
611f58cce03SPrashanth Katti    # netmask  netmask value to be verified.
612f58cce03SPrashanth Katti
613747ce9d0SPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
614747ce9d0SPrashanth Katti
615747ce9d0SPrashanth Katti    Should Contain Match  ${ip_data}  */${prefix_length}
616747ce9d0SPrashanth Katti    ...  msg=Prefix length does not exist.
617f58cce03SPrashanth Katti
6182c5c3bbdSPrashanth KattiVerify IP And Netmask On BMC
6192c5c3bbdSPrashanth Katti    [Documentation]  Verify IP and netmask on BMC.
6202c5c3bbdSPrashanth Katti    [Arguments]  ${ip}  ${netmask}
6212c5c3bbdSPrashanth Katti
6222c5c3bbdSPrashanth Katti    # Description of the argument(s):
6232c5c3bbdSPrashanth Katti    # ip       IP address to be verified.
6242c5c3bbdSPrashanth Katti    # netmask  netmask value to be verified.
6252c5c3bbdSPrashanth Katti
6262c5c3bbdSPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
6272c5c3bbdSPrashanth Katti    @{ip_data}=  Get BMC IP Info
6282c5c3bbdSPrashanth Katti
6292c5c3bbdSPrashanth Katti    ${ip_with_netmask}=  Catenate  ${ip}/${prefix_length}
6302c5c3bbdSPrashanth Katti    Should Contain  ${ip_data}  ${ip_with_netmask}
6312c5c3bbdSPrashanth Katti    ...  msg=IP and netmask pair does not exist.
6322c5c3bbdSPrashanth Katti
63323efc6e3SPrashanth KattiValidate Hostname On BMC
63423efc6e3SPrashanth Katti    [Documentation]  Verify that the hostname read via Redfish is the same as the
63523efc6e3SPrashanth Katti    ...  hostname configured on system.
63623efc6e3SPrashanth Katti    [Arguments]  ${hostname}
63723efc6e3SPrashanth Katti
63823efc6e3SPrashanth Katti    # Description of argument(s):
63923efc6e3SPrashanth Katti    # hostname  A hostname value which is to be compared to the hostname
64023efc6e3SPrashanth Katti    #           configured on system.
64123efc6e3SPrashanth Katti
64223efc6e3SPrashanth Katti    ${sys_hostname}=  Get BMC Hostname
643466d8346SPrashanth Katti    Should Be Equal  ${sys_hostname}  ${hostname}
64423efc6e3SPrashanth Katti    ...  ignore_case=True  msg=Hostname does not exist.
64523efc6e3SPrashanth Katti
646f58cce03SPrashanth KattiTest Teardown Execution
647f58cce03SPrashanth Katti    [Documentation]  Test teardown execution.
648f58cce03SPrashanth Katti
649f58cce03SPrashanth Katti    FFDC On Test Case Fail
65097c93945SGeorge Keishing    Redfish.Logout
651a8442516SPrashanth Katti
652a8442516SPrashanth KattiClear IP Settings On Fail
653a8442516SPrashanth Katti    [Documentation]  Clear IP settings on fail.
654a8442516SPrashanth Katti    [Arguments]  ${ip}
655a8442516SPrashanth Katti
656a8442516SPrashanth Katti    # Description of argument(s):
657a8442516SPrashanth Katti    # ip  IP address to be deleted.
658a8442516SPrashanth Katti
659a8442516SPrashanth Katti    Run Keyword If  '${TEST STATUS}' == 'FAIL'
660a8442516SPrashanth Katti    ...  Delete IP Address  ${ip}
661a8442516SPrashanth Katti
662a8442516SPrashanth Katti    Test Teardown Execution
663adf0b4e7SPrashanth Katti
6647098c976SPrashanth KattiVerify CLI and Redfish Nameservers
6657098c976SPrashanth Katti    [Documentation]  Verify that nameservers obtained via Redfish do not
6667098c976SPrashanth Katti    ...  match those found in /etc/resolv.conf.
6677098c976SPrashanth Katti
6687098c976SPrashanth Katti    ${redfish_nameservers}=  Redfish.Get Attribute  ${REDFISH_NW_ETH0_URI}  StaticNameServers
6697098c976SPrashanth Katti    ${resolve_conf_nameservers}=  CLI Get Nameservers
67039c00518SMichael Walsh    Rqprint Vars  redfish_nameservers  resolve_conf_nameservers
6717098c976SPrashanth Katti
6727098c976SPrashanth Katti    # Check that the 2 lists are equivalent.
6737098c976SPrashanth Katti    ${match}=  Evaluate  set($redfish_nameservers) == set($resolve_conf_nameservers)
6747098c976SPrashanth Katti    Should Be True  ${match}
6757098c976SPrashanth Katti    ...  The nameservers obtained via Redfish do not match those found in /etc/resolv.conf.
6767098c976SPrashanth Katti
6777098c976SPrashanth Katti
6787098c976SPrashanth KattiConfigure Static Name Servers
6797098c976SPrashanth Katti    [Documentation]  Configure DNS server on BMC.
680c85957cdSPrashanth Katti    [Arguments]  ${static_name_servers}=${original_nameservers}
6813c7b6439SPrashanth Katti     ...  ${valid_status_codes}=${HTTP_OK}
6827098c976SPrashanth Katti
6839cb2e596SGeorge Keishing    # Description of the argument(s):
6847098c976SPrashanth Katti    # static_name_servers  A list of static name server IPs to be
6857098c976SPrashanth Katti    #                      configured on the BMC.
6867098c976SPrashanth Katti
6879d995fc8SPrashanth Katti    # Currently BMC is sending 500 response code instead of 400 for invalid scenarios.
6887098c976SPrashanth Katti    Redfish.Patch  ${REDFISH_NW_ETH0_URI}  body={'StaticNameServers': ${static_name_servers}}
6899d995fc8SPrashanth Katti    ...  valid_status_codes=[${valid_status_codes}, ${HTTP_INTERNAL_SERVER_ERROR}]
690c85957cdSPrashanth Katti
691*f247be30SPrashanth Katti    # Patch operation takes 1 to 3 seconds to set new value.
692*f247be30SPrashanth Katti    Sleep  3s
693*f247be30SPrashanth Katti
6947f9e60f0SPrashanth Katti    # Check if newly added DNS server is configured on BMC.
6957f9e60f0SPrashanth Katti    ${cli_nameservers}=  CLI Get Nameservers
6963c7b6439SPrashanth Katti    ${cmd_status}=  Run Keyword And Return Status
6973c7b6439SPrashanth Katti    ...  List Should Contain Sub List  ${cli_nameservers}  ${static_name_servers}
6983c7b6439SPrashanth Katti
6993c7b6439SPrashanth Katti    Run Keyword If  '${valid_status_codes}' == '${HTTP_OK}'
7003c7b6439SPrashanth Katti    ...  Should Be True  ${cmd_status} == ${True}
7013c7b6439SPrashanth Katti    ...  ELSE  Should Be True  ${cmd_status} == ${False}
7027f9e60f0SPrashanth Katti
703c85957cdSPrashanth KattiDelete Static Name Servers
704c85957cdSPrashanth Katti    [Documentation]  Delete static name servers.
705c85957cdSPrashanth Katti
706c85957cdSPrashanth Katti    Configure Static Name Servers  @{EMPTY}
707c85957cdSPrashanth Katti
708c85957cdSPrashanth Katti    # Check if all name servers deleted on BMC.
709c85957cdSPrashanth Katti    ${nameservers}=  CLI Get Nameservers
710c85957cdSPrashanth Katti    Should Be Empty  ${nameservers}
711c85957cdSPrashanth Katti
712c85957cdSPrashanth KattiDNS Test Setup Execution
713c85957cdSPrashanth Katti    [Documentation]  Do DNS test setup execution.
714c85957cdSPrashanth Katti
715c85957cdSPrashanth Katti    Redfish.Login
716c85957cdSPrashanth Katti
717c85957cdSPrashanth Katti    ${original_nameservers}=  Redfish.Get Attribute  ${REDFISH_NW_ETH0_URI}  StaticNameServers
718c85957cdSPrashanth Katti    Rprint Vars  original_nameservers
719c85957cdSPrashanth Katti    # Set suite variables to trigger restoration during teardown.
720c85957cdSPrashanth Katti    Set Suite Variable  ${original_nameservers}
721