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
13b478d90eSPrashanth KattiSuite Setup    Suite Setup Execution
14f58cce03SPrashanth Katti
15f34fafabSPrashanth KattiForce Tags     Network_Conf_Test
16f34fafabSPrashanth Katti
1723efc6e3SPrashanth Katti*** Variables ***
1823efc6e3SPrashanth Katti${test_hostname}           openbmc
19de3bf7b5SVijay${test_ipv4_addr}          10.7.7.7
20de3bf7b5SVijay${test_ipv4_invalid_addr}  0.0.1.a
21de3bf7b5SVijay${test_subnet_mask}        255.255.0.0
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
26568df5f1SPrashanth Katti${test_ipv4_addr2}         10.7.7.8
2723efc6e3SPrashanth Katti
2816b3c7bfSGeorge Keishing# Valid netmask is 4 bytes long and has continuous block of 1s.
29040c8c12SPrashanth Katti# Maximum valid value in each octet is 255 and least value is 0.
30040c8c12SPrashanth Katti# 253 is not valid, as binary value is 11111101.
31040c8c12SPrashanth Katti${invalid_netmask}         255.255.253.0
32040c8c12SPrashanth Katti${alpha_netmask}           ff.ff.ff.ff
33040c8c12SPrashanth Katti# Maximum value of octet in netmask is 255.
34040c8c12SPrashanth Katti${out_of_range_netmask}    255.256.255.0
35040c8c12SPrashanth Katti${more_byte_netmask}       255.255.255.0.0
36040c8c12SPrashanth Katti${less_byte_netmask}       255.255.255
37c6ad647fSPrashanth Katti${threshold_netmask}       255.255.255.255
38c6ad647fSPrashanth Katti${lowest_netmask}          128.0.0.0
39c6ad647fSPrashanth Katti
40c6ad647fSPrashanth Katti# There will be 4 octets in IP address (e.g. xx.xx.xx.xx)
41c6ad647fSPrashanth Katti# but trying to configure xx.xx.xx
42c6ad647fSPrashanth Katti${less_octet_ip}           10.3.36
43c6ad647fSPrashanth Katti
44c6ad647fSPrashanth Katti# For the address 10.6.6.6, the 10.6.6.0 portion describes the
45c6ad647fSPrashanth Katti# network ID and the 6 describe the host.
46c6ad647fSPrashanth Katti
47c6ad647fSPrashanth Katti${network_id}              10.7.7.0
48c6ad647fSPrashanth Katti${hex_ip}                  0xa.0xb.0xc.0xd
49c6ad647fSPrashanth Katti${negative_ip}             10.-7.-7.7
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
6150621144SSushil Singh    FOR  ${network_configuration}  IN  @{network_configurations}
6250621144SSushil Singh      Verify IP On BMC  ${network_configuration['Address']}
6350621144SSushil Singh    END
64747ce9d0SPrashanth Katti
65f58cce03SPrashanth KattiGet Netmask And Verify
66f58cce03SPrashanth Katti    [Documentation]  Get Netmask And Verify.
67f58cce03SPrashanth Katti    [Tags]  Get_Netmask_And_Verify
68f58cce03SPrashanth Katti
6950621144SSushil Singh    FOR  ${network_configuration}  IN  @{network_configurations}
7050621144SSushil Singh      Verify Netmask On BMC  ${network_configuration['SubnetMask']}
7150621144SSushil Singh    END
72747ce9d0SPrashanth Katti
732ec9d8b6SPrashanth KattiGet Gateway And Verify
742ec9d8b6SPrashanth Katti    [Documentation]  Get gateway and verify it's existence on the BMC.
752ec9d8b6SPrashanth Katti    [Tags]  Get_Gateway_And_Verify
762ec9d8b6SPrashanth Katti
7750621144SSushil Singh    FOR  ${network_configuration}  IN  @{network_configurations}
7850621144SSushil Singh      Verify Gateway On BMC  ${network_configuration['Gateway']}
7950621144SSushil Singh    END
802ec9d8b6SPrashanth Katti
812ec9d8b6SPrashanth KattiGet MAC Address And Verify
822ec9d8b6SPrashanth Katti    [Documentation]  Get MAC address and verify it's existence on the BMC.
832ec9d8b6SPrashanth Katti    [Tags]  Get_MAC_Address_And_Verify
842ec9d8b6SPrashanth Katti
85412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
86412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
87412c6680STony Lee
88412c6680STony Lee    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
892ec9d8b6SPrashanth Katti    ${macaddr}=  Get From Dictionary  ${resp.dict}  MACAddress
902ec9d8b6SPrashanth Katti    Validate MAC On BMC  ${macaddr}
91f58cce03SPrashanth Katti
922c5c3bbdSPrashanth KattiVerify All Configured IP And Netmask
932c5c3bbdSPrashanth Katti    [Documentation]  Verify all configured IP and netmask on BMC.
942c5c3bbdSPrashanth Katti    [Tags]  Verify_All_Configured_IP_And_Netmask
952c5c3bbdSPrashanth Katti
9650621144SSushil Singh    FOR  ${network_configuration}  IN  @{network_configurations}
9750621144SSushil Singh      Verify IP And Netmask On BMC  ${network_configuration['Address']}
982c5c3bbdSPrashanth Katti      ...  ${network_configuration['SubnetMask']}
9950621144SSushil Singh    END
1002c5c3bbdSPrashanth Katti
10123efc6e3SPrashanth KattiGet Hostname And Verify
10223efc6e3SPrashanth Katti    [Documentation]  Get hostname via Redfish and verify.
10323efc6e3SPrashanth Katti    [Tags]  Get_Hostname_And_Verify
10423efc6e3SPrashanth Katti
10523efc6e3SPrashanth Katti    ${hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
10623efc6e3SPrashanth Katti
10723efc6e3SPrashanth Katti    Validate Hostname On BMC  ${hostname}
10823efc6e3SPrashanth Katti
10923efc6e3SPrashanth KattiConfigure Hostname And Verify
11023efc6e3SPrashanth Katti    [Documentation]  Configure hostname via Redfish and verify.
11123efc6e3SPrashanth Katti    [Tags]  Configure_Hostname_And_Verify
112578276cbSshrsuman123    [Teardown]  Run Keywords
113578276cbSshrsuman123    ...  Configure Hostname  ${hostname}  AND  Validate Hostname On BMC  ${hostname}
11423efc6e3SPrashanth Katti
115adf0b4e7SPrashanth Katti    ${hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
11623efc6e3SPrashanth Katti
117adf0b4e7SPrashanth Katti    Configure Hostname  ${test_hostname}
11823efc6e3SPrashanth Katti    Validate Hostname On BMC  ${test_hostname}
11923efc6e3SPrashanth Katti
120adf0b4e7SPrashanth Katti
121de3bf7b5SVijayAdd Valid IPv4 Address And Verify
122de3bf7b5SVijay    [Documentation]  Add IPv4 Address via Redfish and verify.
123de3bf7b5SVijay    [Tags]  Add_Valid_IPv4_Addres_And_Verify
1249c7238daSAnvesh Kumar    [Teardown]   Run Keywords
1259c7238daSAnvesh Kumar    ...  Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
126de3bf7b5SVijay
127de3bf7b5SVijay     Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
128de3bf7b5SVijay
129de3bf7b5SVijayAdd Invalid IPv4 Address And Verify
130de3bf7b5SVijay    [Documentation]  Add Invalid IPv4 Address via Redfish and verify.
131de3bf7b5SVijay    [Tags]  Add_Invalid_IPv4_Addres_And_Verify
132de3bf7b5SVijay
133de3bf7b5SVijay    Add IP Address  ${test_ipv4_invalid_addr}  ${test_subnet_mask}
134de3bf7b5SVijay    ...  ${test_gateway}  valid_status_codes=${HTTP_BAD_REQUEST}
135de3bf7b5SVijay
136b36a7521SPrashanth KattiConfigure Out Of Range IP
137b36a7521SPrashanth Katti    [Documentation]  Configure out-of-range IP address.
138b36a7521SPrashanth Katti    [Tags]  Configure_Out_Of_Range_IP
139b36a7521SPrashanth Katti    [Template]  Add IP Address
140b36a7521SPrashanth Katti
141b36a7521SPrashanth Katti    # ip                subnet_mask          gateway          valid_status_codes
142b36a7521SPrashanth Katti    ${out_of_range_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
143b36a7521SPrashanth Katti
144b36a7521SPrashanth KattiConfigure Broadcast IP
145b36a7521SPrashanth Katti    [Documentation]  Configure broadcast IP address.
146b36a7521SPrashanth Katti    [Tags]  Configure_Broadcast_IP
147b36a7521SPrashanth Katti    [Template]  Add IP Address
148c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${broadcast_ip}
149b36a7521SPrashanth Katti
150b36a7521SPrashanth Katti    # ip             subnet_mask          gateway          valid_status_codes
151b36a7521SPrashanth Katti    ${broadcast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
152b36a7521SPrashanth Katti
153b36a7521SPrashanth KattiConfigure Multicast IP
154b36a7521SPrashanth Katti    [Documentation]  Configure multicast IP address.
155b36a7521SPrashanth Katti    [Tags]  Configure_Multicast_IP
156b36a7521SPrashanth Katti    [Template]  Add IP Address
157c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${multicast_ip}
158b36a7521SPrashanth Katti
159b36a7521SPrashanth Katti    # ip             subnet_mask          gateway          valid_status_codes
160b36a7521SPrashanth Katti    ${multicast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
161b36a7521SPrashanth Katti
162b36a7521SPrashanth KattiConfigure Loopback IP
163b36a7521SPrashanth Katti    [Documentation]  Configure loopback IP address.
164b36a7521SPrashanth Katti    [Tags]  Configure_Loopback_IP
165b36a7521SPrashanth Katti    [Template]  Add IP Address
166c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${loopback_ip}
167b36a7521SPrashanth Katti
168b36a7521SPrashanth Katti    # ip            subnet_mask          gateway          valid_status_codes
169b36a7521SPrashanth Katti    ${loopback_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
170b36a7521SPrashanth Katti
171b36a7521SPrashanth KattiAdd Valid IPv4 Address And Check Persistency
172b36a7521SPrashanth Katti    [Documentation]  Add IPv4 address and check peristency.
173b36a7521SPrashanth Katti    [Tags]  Add_Valid_IPv4_Addres_And_Check_Persistency
1749c7238daSAnvesh Kumar    [Teardown]  Run Keywords
1759c7238daSAnvesh Kumar    ...  Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
176b36a7521SPrashanth Katti
177b36a7521SPrashanth Katti    Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
178b36a7521SPrashanth Katti
179b36a7521SPrashanth Katti    # Reboot BMC and verify persistency.
180b36a7521SPrashanth Katti    OBMC Reboot (off)
1815c498748SGeorge Keishing    Redfish.Login
182b36a7521SPrashanth Katti    Verify IP On BMC  ${test_ipv4_addr}
183de3bf7b5SVijay
1846cedca29SPrashanth KattiAdd Fourth Octet Threshold IP And Verify
1856cedca29SPrashanth Katti    [Documentation]  Add fourth octet threshold IP and verify.
1866cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Threshold_IP_And_Verify
1879c7238daSAnvesh Kumar    [Teardown]  Run Keywords
1889c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.7.254  AND  Test Teardown Execution
1896cedca29SPrashanth Katti
1906cedca29SPrashanth Katti     Add IP Address  10.7.7.254  ${test_subnet_mask}  ${test_gateway}
1916cedca29SPrashanth Katti
1926cedca29SPrashanth KattiAdd Fourth Octet Lowest IP And Verify
1936cedca29SPrashanth Katti    [Documentation]  Add fourth octet lowest IP and verify.
1946cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Lowest_IP_And_Verify
1959c7238daSAnvesh Kumar    [Teardown]  Run Keywords
1969c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.7.1  AND  Test Teardown Execution
1976cedca29SPrashanth Katti
1986cedca29SPrashanth Katti     Add IP Address  10.7.7.1  ${test_subnet_mask}  ${test_gateway}
1996cedca29SPrashanth Katti
2006cedca29SPrashanth KattiAdd Third Octet Threshold IP And Verify
2016cedca29SPrashanth Katti    [Documentation]  Add third octet threshold IP and verify.
2026cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Threshold_IP_And_Verify
2039c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2049c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.255.7  AND  Test Teardown Execution
2056cedca29SPrashanth Katti
2066cedca29SPrashanth Katti     Add IP Address  10.7.255.7  ${test_subnet_mask}  ${test_gateway}
2076cedca29SPrashanth Katti
2086cedca29SPrashanth KattiAdd Third Octet Lowest IP And Verify
2096cedca29SPrashanth Katti    [Documentation]  Add third octet lowest IP and verify.
2106cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Lowest_IP_And_Verify
2119c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2129c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.0.7  AND  Test Teardown Execution
2136cedca29SPrashanth Katti
2146cedca29SPrashanth Katti     Add IP Address  10.7.0.7  ${test_subnet_mask}  ${test_gateway}
2156cedca29SPrashanth Katti
2166cedca29SPrashanth KattiAdd Second Octet Threshold IP And Verify
2176cedca29SPrashanth Katti    [Documentation]  Add second octet threshold IP and verify.
2186cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Threshold_IP_And_Verify
2199c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2209c7238daSAnvesh Kumar    ...  Delete IP Address  10.255.7.7  AND  Test Teardown Execution
2216cedca29SPrashanth Katti
2226cedca29SPrashanth Katti     Add IP Address  10.255.7.7  ${test_subnet_mask}  ${test_gateway}
2236cedca29SPrashanth Katti
2246cedca29SPrashanth KattiAdd Second Octet Lowest IP And Verify
2256cedca29SPrashanth Katti    [Documentation]  Add second octet lowest IP and verify.
2266cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Lowest_IP_And_Verify
2279c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2289c7238daSAnvesh Kumar    ...  Delete IP Address  10.0.7.7  AND  Test Teardown Execution
2296cedca29SPrashanth Katti
2306cedca29SPrashanth Katti     Add IP Address  10.0.7.7  ${test_subnet_mask}  ${test_gateway}
2316cedca29SPrashanth Katti
2326cedca29SPrashanth KattiAdd First Octet Threshold IP And Verify
2336cedca29SPrashanth Katti    [Documentation]  Add first octet threshold IP and verify.
2346cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Threshold_IP_And_Verify
2359c7238daSAnvesh Kumar    [Teardown]  Run Keywords
236f757b107SAnves Kumar rayankula    ...  Delete IP Address  223.7.7.7  AND  Test Teardown Execution
2376cedca29SPrashanth Katti
2386cedca29SPrashanth Katti     Add IP Address  223.7.7.7  ${test_subnet_mask}  ${test_gateway}
2396cedca29SPrashanth Katti
2406cedca29SPrashanth KattiAdd First Octet Lowest IP And Verify
2416cedca29SPrashanth Katti    [Documentation]  Add first octet lowest IP and verify.
2426cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Lowest_IP_And_Verify
2439c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2449c7238daSAnvesh Kumar    ...  Delete IP Address  1.7.7.7  AND  Test Teardown Execution
2456cedca29SPrashanth Katti
2466cedca29SPrashanth Katti     Add IP Address  1.7.7.7  ${test_subnet_mask}  ${test_gateway}
2476cedca29SPrashanth Katti
248040c8c12SPrashanth KattiConfigure Invalid Netmask
249040c8c12SPrashanth Katti    [Documentation]  Verify error while setting invalid netmask.
250040c8c12SPrashanth Katti    [Tags]  Configure_Invalid_Netmask
251040c8c12SPrashanth Katti    [Template]  Add IP Address
252040c8c12SPrashanth Katti
253040c8c12SPrashanth Katti    # ip               subnet_mask         gateway          valid_status_codes
254040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${invalid_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
255040c8c12SPrashanth Katti
256040c8c12SPrashanth KattiConfigure Out Of Range Netmask
257040c8c12SPrashanth Katti    [Documentation]  Verify error while setting out of range netmask.
258040c8c12SPrashanth Katti    [Tags]  Configure_Out_Of_Range_Netmask
259040c8c12SPrashanth Katti    [Template]  Add IP Address
260040c8c12SPrashanth Katti
261040c8c12SPrashanth Katti    # ip               subnet_mask              gateway          valid_status_codes
262040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${out_of_range_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
263040c8c12SPrashanth Katti
264040c8c12SPrashanth KattiConfigure Alpha Netmask
265040c8c12SPrashanth Katti    [Documentation]  Verify error while setting alpha netmask.
266040c8c12SPrashanth Katti    [Tags]  Configure_Alpha_Netmask
267040c8c12SPrashanth Katti    [Template]  Add IP Address
268040c8c12SPrashanth Katti
269040c8c12SPrashanth Katti    # ip               subnet_mask       gateway          valid_status_codes
270040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${alpha_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
271040c8c12SPrashanth Katti
272040c8c12SPrashanth KattiConfigure More Byte Netmask
273040c8c12SPrashanth Katti    [Documentation]  Verify error while setting more byte netmask.
274040c8c12SPrashanth Katti    [Tags]  Configure_More_Byte_Netmask
275040c8c12SPrashanth Katti    [Template]  Add IP Address
276040c8c12SPrashanth Katti
277040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
278040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${more_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
279040c8c12SPrashanth Katti
280040c8c12SPrashanth KattiConfigure Less Byte Netmask
281040c8c12SPrashanth Katti    [Documentation]  Verify error while setting less byte netmask.
282040c8c12SPrashanth Katti    [Tags]  Configure_Less_Byte_Netmask
283040c8c12SPrashanth Katti    [Template]  Add IP Address
284040c8c12SPrashanth Katti
285040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
286040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${less_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
287040c8c12SPrashanth Katti
288c6ad647fSPrashanth KattiConfigure Threshold Netmask And Verify
289c6ad647fSPrashanth Katti    [Documentation]  Configure threshold netmask and verify.
290c6ad647fSPrashanth Katti    [Tags]  Configure_Threshold_Netmask_And_verify
2919c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2929c7238daSAnvesh Kumar    ...   Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
293c6ad647fSPrashanth Katti
294c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${threshold_netmask}  ${test_gateway}
295c6ad647fSPrashanth Katti
296c6ad647fSPrashanth KattiConfigure Lowest Netmask And Verify
297c6ad647fSPrashanth Katti    [Documentation]  Configure lowest netmask and verify.
298c6ad647fSPrashanth Katti    [Tags]  Configure_Lowest_Netmask_And_verify
2999c7238daSAnvesh Kumar    [Teardown]  Run Keywords
3009c7238daSAnvesh Kumar    ...   Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
301c6ad647fSPrashanth Katti
302c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${lowest_netmask}  ${test_gateway}
303c6ad647fSPrashanth Katti
304c6ad647fSPrashanth KattiConfigure Network ID
305c6ad647fSPrashanth Katti    [Documentation]  Verify error while configuring network ID.
306c6ad647fSPrashanth Katti    [Tags]  Configure_Network_ID
307c6ad647fSPrashanth Katti    [Template]  Add IP Address
308c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${network_id}
309c6ad647fSPrashanth Katti
310c6ad647fSPrashanth Katti    # ip           subnet_mask          gateway          valid_status_codes
311c6ad647fSPrashanth Katti    ${network_id}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
312c6ad647fSPrashanth Katti
313c6ad647fSPrashanth KattiConfigure Less Octet IP
314c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring less octet IP address.
315c6ad647fSPrashanth Katti    [Tags]  Configure_Less_Octet_IP
316c6ad647fSPrashanth Katti    [Template]  Add IP Address
317c6ad647fSPrashanth Katti
318c6ad647fSPrashanth Katti    # ip              subnet_mask          gateway          valid_status_codes
319c6ad647fSPrashanth Katti    ${less_octet_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
320c6ad647fSPrashanth Katti
321c6ad647fSPrashanth KattiConfigure Empty IP
322c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring empty IP address.
323c6ad647fSPrashanth Katti    [Tags]  Configure_Empty_IP
324c6ad647fSPrashanth Katti    [Template]  Add IP Address
325c6ad647fSPrashanth Katti
326c6ad647fSPrashanth Katti    # ip      subnet_mask          gateway          valid_status_codes
327c6ad647fSPrashanth Katti    ${EMPTY}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
328c6ad647fSPrashanth Katti
329c6ad647fSPrashanth KattiConfigure Special Char IP
330c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing special chars.
331c6ad647fSPrashanth Katti    [Tags]  Configure_Special_Char_IP
332c6ad647fSPrashanth Katti    [Template]  Add IP Address
333c6ad647fSPrashanth Katti
334c6ad647fSPrashanth Katti    # ip          subnet_mask          gateway          valid_status_codes
335c6ad647fSPrashanth Katti    @@@.%%.44.11  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
336c6ad647fSPrashanth Katti
337c6ad647fSPrashanth KattiConfigure Hexadecimal IP
338c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing hex value.
339c6ad647fSPrashanth Katti    [Tags]  Configure_Hexadecimal_IP
340c6ad647fSPrashanth Katti    [Template]  Add IP Address
341c6ad647fSPrashanth Katti
342c6ad647fSPrashanth Katti    # ip       subnet_mask          gateway          valid_status_codes
343c6ad647fSPrashanth Katti    ${hex_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
344c6ad647fSPrashanth Katti
345c6ad647fSPrashanth KattiConfigure Negative Octet IP
346c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing negative octet.
347c6ad647fSPrashanth Katti    [Tags]  Configure_Negative_Octet_IP
348c6ad647fSPrashanth Katti    [Template]  Add IP Address
349c6ad647fSPrashanth Katti
350c6ad647fSPrashanth Katti    # ip            subnet_mask          gateway          valid_status_codes
351c6ad647fSPrashanth Katti    ${negative_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
352c6ad647fSPrashanth Katti
3535cad5a07SPrashanth KattiConfigure Incomplete IP For Gateway
3545cad5a07SPrashanth Katti    [Documentation]  Configure incomplete IP for gateway and expect an error.
3555cad5a07SPrashanth Katti    [Tags]  Configure_Incomplete_IP_For_Gateway
3565cad5a07SPrashanth Katti    [Template]  Add IP Address
3575cad5a07SPrashanth Katti
3585cad5a07SPrashanth Katti    # ip               subnet_mask          gateway           valid_status_codes
3595cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${less_octet_ip}  ${HTTP_BAD_REQUEST}
3605cad5a07SPrashanth Katti
3615cad5a07SPrashanth KattiConfigure Special Char IP For Gateway
3625cad5a07SPrashanth Katti    [Documentation]  Configure special char IP for gateway and expect an error.
3635cad5a07SPrashanth Katti    [Tags]  Configure_Special_Char_IP_For_Gateway
3645cad5a07SPrashanth Katti    [Template]  Add IP Address
3655cad5a07SPrashanth Katti
3665cad5a07SPrashanth Katti    # ip               subnet_mask          gateway       valid_status_codes
3675cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  @@@.%%.44.11  ${HTTP_BAD_REQUEST}
3685cad5a07SPrashanth Katti
3695cad5a07SPrashanth KattiConfigure Hexadecimal IP For Gateway
3705cad5a07SPrashanth Katti    [Documentation]  Configure hexadecimal IP for gateway and expect an error.
3715cad5a07SPrashanth Katti    [Tags]  Configure_Hexadecimal_IP_For_Gateway
3725cad5a07SPrashanth Katti    [Template]  Add IP Address
3735cad5a07SPrashanth Katti
3745cad5a07SPrashanth Katti    # ip               subnet_mask          gateway    valid_status_codes
3755cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${hex_ip}  ${HTTP_BAD_REQUEST}
3765cad5a07SPrashanth Katti
3777098c976SPrashanth KattiGet DNS Server And Verify
3787098c976SPrashanth Katti    [Documentation]  Get DNS server via Redfish and verify.
3797098c976SPrashanth Katti    [Tags]  Get_DNS_Server_And_Verify
3807098c976SPrashanth Katti
3817098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3827098c976SPrashanth Katti
3837098c976SPrashanth KattiConfigure DNS Server And Verify
3847098c976SPrashanth Katti    [Documentation]  Configure DNS server and verify.
3857098c976SPrashanth Katti    [Tags]  Configure_DNS_Server_And_Verify
386c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
3877098c976SPrashanth Katti    [Teardown]  Run Keywords
3887098c976SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
3897098c976SPrashanth Katti
3907098c976SPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
3917098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3927098c976SPrashanth Katti
393c85957cdSPrashanth KattiDelete DNS Server And Verify
394c85957cdSPrashanth Katti    [Documentation]  Delete DNS server and verify.
395c85957cdSPrashanth Katti    [Tags]  Delete_DNS_Server_And_Verify
396c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
397c85957cdSPrashanth Katti    [Teardown]  Run Keywords
398c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
399c85957cdSPrashanth Katti
400c85957cdSPrashanth Katti    Delete Static Name Servers
401c85957cdSPrashanth Katti    Verify CLI and Redfish Nameservers
402c85957cdSPrashanth Katti
403c85957cdSPrashanth KattiConfigure DNS Server And Check Persistency
404c85957cdSPrashanth Katti    [Documentation]  Configure DNS server and check persistency on reboot.
405c85957cdSPrashanth Katti    [Tags]  Configure_DNS_Server_And_Check_Persistency
406c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
407c85957cdSPrashanth Katti    [Teardown]  Run Keywords
408c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
409c85957cdSPrashanth Katti
410c85957cdSPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
411c85957cdSPrashanth Katti    # Reboot BMC and verify persistency.
412c85957cdSPrashanth Katti    OBMC Reboot (off)
413c85957cdSPrashanth Katti    Verify CLI and Redfish Nameservers
414c85957cdSPrashanth Katti
4153063ffefSPrashanth KattiConfigure Loopback IP For Gateway
4163063ffefSPrashanth Katti    [Documentation]  Configure loopback IP for gateway and expect an error.
4173063ffefSPrashanth Katti    [Tags]  Configure_Loopback_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}  ${loopback_ip}  ${HTTP_BAD_REQUEST}
4233063ffefSPrashanth Katti
4243063ffefSPrashanth KattiConfigure Network ID For Gateway
4253063ffefSPrashanth Katti    [Documentation]  Configure network ID for gateway and expect an error.
4263063ffefSPrashanth Katti    [Tags]  Configure_Network_ID_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}  ${network_id}  ${HTTP_BAD_REQUEST}
4323063ffefSPrashanth Katti
4333063ffefSPrashanth KattiConfigure Multicast IP For Gateway
4343063ffefSPrashanth Katti    [Documentation]  Configure multicast IP for gateway and expect an error.
4353063ffefSPrashanth Katti    [Tags]  Configure_Multicast_IP_For_Gateway
4363063ffefSPrashanth Katti    [Template]  Add IP Address
4373063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4383063ffefSPrashanth Katti
4393063ffefSPrashanth Katti    # ip               subnet_mask          gateway           valid_status_codes
440412c6680STony Lee    ${test_ipv4_addr}  ${test_subnet_mask}  ${multicast_ip}  ${HTTP_BAD_REQUEST}
4413063ffefSPrashanth Katti
4423063ffefSPrashanth KattiConfigure Broadcast IP For Gateway
4433063ffefSPrashanth Katti    [Documentation]  Configure broadcast IP for gateway and expect an error.
4443063ffefSPrashanth Katti    [Tags]  Configure_Broadcast_IP_For_Gateway
4453063ffefSPrashanth Katti    [Template]  Add IP Address
4463063ffefSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${test_ipv4_addr}
4473063ffefSPrashanth Katti
4483063ffefSPrashanth Katti    # ip               subnet_mask          gateway          valid_status_codes
4493063ffefSPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${broadcast_ip}  ${HTTP_BAD_REQUEST}
450c85957cdSPrashanth Katti
4513c7b6439SPrashanth KattiConfigure Null Value For DNS Server
4523c7b6439SPrashanth Katti    [Documentation]  Configure null value for DNS server and expect an error.
4533c7b6439SPrashanth Katti    [Tags]  Configure_Null_Value_For_DNS_Server
4543c7b6439SPrashanth Katti    [Setup]  DNS Test Setup Execution
4553c7b6439SPrashanth Katti    [Teardown]  Run Keywords
4563c7b6439SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
4573c7b6439SPrashanth Katti
4583c7b6439SPrashanth Katti    Configure Static Name Servers  ${null_value}  ${HTTP_BAD_REQUEST}
4593c7b6439SPrashanth Katti
460afe16b72SPrashanth KattiConfigure Empty Value For DNS Server
461afe16b72SPrashanth Katti    [Documentation]  Configure empty value for DNS server and expect an error.
462afe16b72SPrashanth Katti    [Tags]  Configure_Empty_Value_For_DNS_Server
463afe16b72SPrashanth Katti    [Setup]  DNS Test Setup Execution
464afe16b72SPrashanth Katti    [Teardown]  Run Keywords
465afe16b72SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
466afe16b72SPrashanth Katti
467afe16b72SPrashanth Katti    Configure Static Name Servers  ${empty_dictionary}  ${HTTP_BAD_REQUEST}
468afe16b72SPrashanth Katti
469afe16b72SPrashanth KattiConfigure String Value For DNS Server
470afe16b72SPrashanth Katti    [Documentation]  Configure string value for DNS server and expect an error.
471afe16b72SPrashanth Katti    [Tags]  Configure_String_Value_For_DNS_Server
472afe16b72SPrashanth Katti    [Setup]  DNS Test Setup Execution
473afe16b72SPrashanth Katti    [Teardown]  Run Keywords
474afe16b72SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
475afe16b72SPrashanth Katti
476afe16b72SPrashanth Katti    Configure Static Name Servers  ${string_value}  ${HTTP_BAD_REQUEST}
477afe16b72SPrashanth Katti
478568df5f1SPrashanth KattiModify IPv4 Address And Verify
479568df5f1SPrashanth Katti    [Documentation]  Modify IP address via Redfish and verify.
480568df5f1SPrashanth Katti    [Tags]  Modify_IPv4_Addres_And_Verify
481568df5f1SPrashanth Katti    [Teardown]  Run Keywords
482045814b3SAnves Kumar rayankula    ...  Delete IP Address  ${test_ipv4_addr2}  AND  Test Teardown Execution
483568df5f1SPrashanth Katti
484568df5f1SPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
485568df5f1SPrashanth Katti
486568df5f1SPrashanth Katti     Update IP Address  ${test_ipv4_addr}  ${test_ipv4_addr2}  ${test_subnet_mask}  ${test_gateway}
487568df5f1SPrashanth Katti
4889c7238daSAnvesh Kumar
4896b9fcd1aSAnves Kumar rayankulaConfigure Invalid Values For DNS Server
4906b9fcd1aSAnves Kumar rayankula    [Documentation]  Configure invalid values for DNS server and expect an error.
4916b9fcd1aSAnves Kumar rayankula    [Tags]  Configure_Invalid_Value_For_DNS_Server
4926b9fcd1aSAnves Kumar rayankula    [Setup]  DNS Test Setup Execution
4936b9fcd1aSAnves Kumar rayankula    [Template]  Configure Static Name Servers
4946b9fcd1aSAnves Kumar rayankula    [Teardown]  Run Keywords
4956b9fcd1aSAnves Kumar rayankula    ...  Configure Static Name Servers  AND  Test Teardown Execution
4966b9fcd1aSAnves Kumar rayankula
4976b9fcd1aSAnves Kumar rayankula     # static_name_servers        valid_status_codes
4986b9fcd1aSAnves Kumar rayankula      0xa.0xb.0xc.0xd             ${HTTP_BAD_REQUEST}
4996b9fcd1aSAnves Kumar rayankula      10.-7.-7.-7                 ${HTTP_BAD_REQUEST}
5006b9fcd1aSAnves Kumar rayankula      10.3.36                     ${HTTP_BAD_REQUEST}
5016b9fcd1aSAnves Kumar rayankula      @@@.%%.44.11                ${HTTP_BAD_REQUEST}
5026b9fcd1aSAnves Kumar rayankula
5036b9fcd1aSAnves Kumar rayankula
5046b9fcd1aSAnves Kumar rayankulaConfig Multiple DNS Servers And Verify
5056b9fcd1aSAnves Kumar rayankula    [Documentation]  Config multiple DNS servers and verify.
5066b9fcd1aSAnves Kumar rayankula    [Tags]  Config_Multiple_DNS_Servers_And_Verify
5076b9fcd1aSAnves Kumar rayankula    [Setup]  DNS Test Setup Execution
5086b9fcd1aSAnves Kumar rayankula    [Teardown]  Run Keywords
5096b9fcd1aSAnves Kumar rayankula    ...  Configure Static Name Servers  AND  Test Teardown Execution
5106b9fcd1aSAnves Kumar rayankula
5116b9fcd1aSAnves Kumar rayankula     @{list_name_servers}=  Create List  10.5.5.10  10.20.5.10  10.5.6.7
5126b9fcd1aSAnves Kumar rayankula     Configure Static Name Servers  ${list_name_servers}
5136b9fcd1aSAnves Kumar rayankula     Verify CLI and Redfish Nameservers
5146b9fcd1aSAnves Kumar rayankula
5156b9fcd1aSAnves Kumar rayankula
516*d4cdd8c0SAnves Kumar rayankulaConfigure And Verify Multiple Static IPv4 Addresses
517*d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and verify.
518*d4cdd8c0SAnves Kumar rayankula    [Tags]  Configure_And_Verify_Multiple_Static_IPv4_Addresses
519*d4cdd8c0SAnves Kumar rayankula    [Teardown]  Run Keywords  Delete Multiple Static IPv4 Addresses  ${test_ipv4_addresses}
520*d4cdd8c0SAnves Kumar rayankula    ...  AND  Test Teardown Execution
521*d4cdd8c0SAnves Kumar rayankula
522*d4cdd8c0SAnves Kumar rayankula    ${test_ipv4_addresses}=  Create List  ${test_ipv4_addr}  ${test_ipv4_addr2}
523*d4cdd8c0SAnves Kumar rayankula    Configure Multiple Static IPv4 Addresses   ${test_ipv4_addresses}  ${test_subnet_mask}  ${test_gateway}
524*d4cdd8c0SAnves Kumar rayankula
525*d4cdd8c0SAnves Kumar rayankula
526*d4cdd8c0SAnves Kumar rayankulaConfigure Multiple Static IPv4 Addresses And Check Persistency
527*d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and check persistency.
528*d4cdd8c0SAnves Kumar rayankula    [Tags]  Configure_Multiple_Static_IPv4_Addresses_And_Check_Persistency
529*d4cdd8c0SAnves Kumar rayankula    [Teardown]  Run Keywords  Delete Multiple Static IPv4 Addresses  ${test_ipv4_addresses}
530*d4cdd8c0SAnves Kumar rayankula    ...  AND  Test Teardown Execution
531*d4cdd8c0SAnves Kumar rayankula
532*d4cdd8c0SAnves Kumar rayankula    ${test_ipv4_addresses}=  Create List  ${test_ipv4_addr}  ${test_ipv4_addr2}
533*d4cdd8c0SAnves Kumar rayankula    Configure Multiple Static IPv4 Addresses  ${test_ipv4_addresses}  ${test_subnet_mask}  ${test_gateway}
534*d4cdd8c0SAnves Kumar rayankula
535*d4cdd8c0SAnves Kumar rayankula    # Reboot BMC and verify persistency.
536*d4cdd8c0SAnves Kumar rayankula    OBMC Reboot (off)
537*d4cdd8c0SAnves Kumar rayankula
538*d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN  @{test_ipv4_addresses}
539*d4cdd8c0SAnves Kumar rayankula      Verify IP And Netmask On BMC  ${ip}  ${test_subnet_mask}
540*d4cdd8c0SAnves Kumar rayankula    END
541*d4cdd8c0SAnves Kumar rayankula
542*d4cdd8c0SAnves Kumar rayankula
543f58cce03SPrashanth Katti*** Keywords ***
544f58cce03SPrashanth Katti
545f58cce03SPrashanth KattiTest Setup Execution
546f58cce03SPrashanth Katti    [Documentation]  Test setup execution.
547f58cce03SPrashanth Katti
54897c93945SGeorge Keishing    Redfish.Login
549f58cce03SPrashanth Katti
550f58cce03SPrashanth Katti    @{network_configurations}=  Get Network Configuration
551f58cce03SPrashanth Katti    Set Test Variable  @{network_configurations}
552f58cce03SPrashanth Katti
553f58cce03SPrashanth Katti    # Get BMC IP address and prefix length.
554f58cce03SPrashanth Katti    ${ip_data}=  Get BMC IP Info
555f58cce03SPrashanth Katti    Set Test Variable  ${ip_data}
556f58cce03SPrashanth Katti
557747ce9d0SPrashanth Katti
558747ce9d0SPrashanth KattiVerify Netmask On BMC
559747ce9d0SPrashanth Katti    [Documentation]  Verify netmask on BMC.
560f58cce03SPrashanth Katti    [Arguments]  ${netmask}
561f58cce03SPrashanth Katti
562f58cce03SPrashanth Katti    # Description of the argument(s):
563f58cce03SPrashanth Katti    # netmask  netmask value to be verified.
564f58cce03SPrashanth Katti
565747ce9d0SPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
566747ce9d0SPrashanth Katti
567747ce9d0SPrashanth Katti    Should Contain Match  ${ip_data}  */${prefix_length}
568747ce9d0SPrashanth Katti    ...  msg=Prefix length does not exist.
569f58cce03SPrashanth Katti
5702c5c3bbdSPrashanth KattiVerify IP And Netmask On BMC
5712c5c3bbdSPrashanth Katti    [Documentation]  Verify IP and netmask on BMC.
5722c5c3bbdSPrashanth Katti    [Arguments]  ${ip}  ${netmask}
5732c5c3bbdSPrashanth Katti
5742c5c3bbdSPrashanth Katti    # Description of the argument(s):
5752c5c3bbdSPrashanth Katti    # ip       IP address to be verified.
5762c5c3bbdSPrashanth Katti    # netmask  netmask value to be verified.
5772c5c3bbdSPrashanth Katti
5782c5c3bbdSPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
5792c5c3bbdSPrashanth Katti    @{ip_data}=  Get BMC IP Info
5802c5c3bbdSPrashanth Katti
5812c5c3bbdSPrashanth Katti    ${ip_with_netmask}=  Catenate  ${ip}/${prefix_length}
5822c5c3bbdSPrashanth Katti    Should Contain  ${ip_data}  ${ip_with_netmask}
5832c5c3bbdSPrashanth Katti    ...  msg=IP and netmask pair does not exist.
5842c5c3bbdSPrashanth Katti
58523efc6e3SPrashanth KattiValidate Hostname On BMC
58623efc6e3SPrashanth Katti    [Documentation]  Verify that the hostname read via Redfish is the same as the
58723efc6e3SPrashanth Katti    ...  hostname configured on system.
58823efc6e3SPrashanth Katti    [Arguments]  ${hostname}
58923efc6e3SPrashanth Katti
59023efc6e3SPrashanth Katti    # Description of argument(s):
59123efc6e3SPrashanth Katti    # hostname  A hostname value which is to be compared to the hostname
59223efc6e3SPrashanth Katti    #           configured on system.
59323efc6e3SPrashanth Katti
59423efc6e3SPrashanth Katti    ${sys_hostname}=  Get BMC Hostname
595466d8346SPrashanth Katti    Should Be Equal  ${sys_hostname}  ${hostname}
59623efc6e3SPrashanth Katti    ...  ignore_case=True  msg=Hostname does not exist.
59723efc6e3SPrashanth Katti
598f58cce03SPrashanth KattiTest Teardown Execution
599f58cce03SPrashanth Katti    [Documentation]  Test teardown execution.
600f58cce03SPrashanth Katti
601f58cce03SPrashanth Katti    FFDC On Test Case Fail
60297c93945SGeorge Keishing    Redfish.Logout
603a8442516SPrashanth Katti
604a8442516SPrashanth KattiClear IP Settings On Fail
605a8442516SPrashanth Katti    [Documentation]  Clear IP settings on fail.
606a8442516SPrashanth Katti    [Arguments]  ${ip}
607a8442516SPrashanth Katti
608a8442516SPrashanth Katti    # Description of argument(s):
609a8442516SPrashanth Katti    # ip  IP address to be deleted.
610a8442516SPrashanth Katti
611a8442516SPrashanth Katti    Run Keyword If  '${TEST STATUS}' == 'FAIL'
612a8442516SPrashanth Katti    ...  Delete IP Address  ${ip}
613a8442516SPrashanth Katti
614a8442516SPrashanth Katti    Test Teardown Execution
615adf0b4e7SPrashanth Katti
6167098c976SPrashanth KattiVerify CLI and Redfish Nameservers
6177098c976SPrashanth Katti    [Documentation]  Verify that nameservers obtained via Redfish do not
6187098c976SPrashanth Katti    ...  match those found in /etc/resolv.conf.
6197098c976SPrashanth Katti
620412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
621412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
622412c6680STony Lee
62391548eaeSAnves Kumar rayankula    ${redfish_nameservers}=  Redfish.Get Attribute
62491548eaeSAnves Kumar rayankula    ...  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  StaticNameServers
6257098c976SPrashanth Katti    ${resolve_conf_nameservers}=  CLI Get Nameservers
62639c00518SMichael Walsh    Rqprint Vars  redfish_nameservers  resolve_conf_nameservers
6277098c976SPrashanth Katti
6287098c976SPrashanth Katti    # Check that the 2 lists are equivalent.
6297098c976SPrashanth Katti    ${match}=  Evaluate  set($redfish_nameservers) == set($resolve_conf_nameservers)
6307098c976SPrashanth Katti    Should Be True  ${match}
6317098c976SPrashanth Katti    ...  The nameservers obtained via Redfish do not match those found in /etc/resolv.conf.
6327098c976SPrashanth Katti
6337098c976SPrashanth Katti
6347098c976SPrashanth KattiConfigure Static Name Servers
6357098c976SPrashanth Katti    [Documentation]  Configure DNS server on BMC.
636c85957cdSPrashanth Katti    [Arguments]  ${static_name_servers}=${original_nameservers}
6373c7b6439SPrashanth Katti     ...  ${valid_status_codes}=${HTTP_OK}
6387098c976SPrashanth Katti
6399cb2e596SGeorge Keishing    # Description of the argument(s):
6407098c976SPrashanth Katti    # static_name_servers  A list of static name server IPs to be
6417098c976SPrashanth Katti    #                      configured on the BMC.
6427098c976SPrashanth Katti
643412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
644412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
645412c6680STony Lee
6466b9fcd1aSAnves Kumar rayankula    ${type} =  Evaluate  type($static_name_servers).__name__
6476b9fcd1aSAnves Kumar rayankula    ${static_name_servers}=  Set Variable If  '${type}'=='str'
6486b9fcd1aSAnves Kumar rayankula    ...  '${static_name_servers}'  ${static_name_servers}
6496b9fcd1aSAnves Kumar rayankula
6509d995fc8SPrashanth Katti    # Currently BMC is sending 500 response code instead of 400 for invalid scenarios.
65191548eaeSAnves Kumar rayankula    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
65291548eaeSAnves Kumar rayankula    ...  body={'StaticNameServers': ${static_name_servers}}
6539d995fc8SPrashanth Katti    ...  valid_status_codes=[${valid_status_codes}, ${HTTP_INTERNAL_SERVER_ERROR}]
654c85957cdSPrashanth Katti
655f247be30SPrashanth Katti    # Patch operation takes 1 to 3 seconds to set new value.
656f247be30SPrashanth Katti    Sleep  3s
657f247be30SPrashanth Katti
6587f9e60f0SPrashanth Katti    # Check if newly added DNS server is configured on BMC.
6597f9e60f0SPrashanth Katti    ${cli_nameservers}=  CLI Get Nameservers
6603c7b6439SPrashanth Katti    ${cmd_status}=  Run Keyword And Return Status
6613c7b6439SPrashanth Katti    ...  List Should Contain Sub List  ${cli_nameservers}  ${static_name_servers}
6623c7b6439SPrashanth Katti
6633c7b6439SPrashanth Katti    Run Keyword If  '${valid_status_codes}' == '${HTTP_OK}'
6643c7b6439SPrashanth Katti    ...  Should Be True  ${cmd_status} == ${True}
6653c7b6439SPrashanth Katti    ...  ELSE  Should Be True  ${cmd_status} == ${False}
6667f9e60f0SPrashanth Katti
667c85957cdSPrashanth KattiDelete Static Name Servers
668c85957cdSPrashanth Katti    [Documentation]  Delete static name servers.
669c85957cdSPrashanth Katti
670045814b3SAnves Kumar rayankula    Configure Static Name Servers  static_name_servers=@{EMPTY}
671c85957cdSPrashanth Katti
672c85957cdSPrashanth Katti    # Check if all name servers deleted on BMC.
673c85957cdSPrashanth Katti    ${nameservers}=  CLI Get Nameservers
674c85957cdSPrashanth Katti    Should Be Empty  ${nameservers}
675c85957cdSPrashanth Katti
676c85957cdSPrashanth KattiDNS Test Setup Execution
677c85957cdSPrashanth Katti    [Documentation]  Do DNS test setup execution.
678c85957cdSPrashanth Katti
679c85957cdSPrashanth Katti    Redfish.Login
680c85957cdSPrashanth Katti
681412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
682412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
683412c6680STony Lee
68491548eaeSAnves Kumar rayankula    ${original_nameservers}=  Redfish.Get Attribute
68591548eaeSAnves Kumar rayankula    ...  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  StaticNameServers
686412c6680STony Lee
687c85957cdSPrashanth Katti    Rprint Vars  original_nameservers
688c85957cdSPrashanth Katti    # Set suite variables to trigger restoration during teardown.
689c85957cdSPrashanth Katti    Set Suite Variable  ${original_nameservers}
690b478d90eSPrashanth Katti
691b478d90eSPrashanth KattiSuite Setup Execution
692b478d90eSPrashanth Katti    [Documentation]  Do suite setup execution.
693b478d90eSPrashanth Katti
694b478d90eSPrashanth Katti    ${test_gateway}=  Get BMC Default Gateway
695b478d90eSPrashanth Katti    Set Suite Variable  ${test_gateway}
696568df5f1SPrashanth Katti
697568df5f1SPrashanth KattiUpdate IP Address
698568df5f1SPrashanth Katti    [Documentation]  Update IP address of BMC.
699568df5f1SPrashanth Katti    [Arguments]  ${ip}  ${new_ip}  ${netmask}  ${gw_ip}  ${valid_status_codes}=${HTTP_OK}
700568df5f1SPrashanth Katti
701568df5f1SPrashanth Katti    # Description of argument(s):
702568df5f1SPrashanth Katti    # ip                  IP address to be replaced (e.g. "10.7.7.7").
703568df5f1SPrashanth Katti    # new_ip              New IP address to be configured.
704568df5f1SPrashanth Katti    # netmask             Netmask value.
705568df5f1SPrashanth Katti    # gw_ip               Gateway IP address.
706568df5f1SPrashanth Katti    # valid_status_codes  Expected return code from patch operation
707568df5f1SPrashanth Katti    #                     (e.g. "200").  See prolog of rest_request
708568df5f1SPrashanth Katti    #                     method in redfish_plus.py for details.
709568df5f1SPrashanth Katti
710568df5f1SPrashanth Katti    ${empty_dict}=  Create Dictionary
711568df5f1SPrashanth Katti    ${patch_list}=  Create List
712568df5f1SPrashanth Katti    ${ip_data}=  Create Dictionary  Address=${new_ip}  SubnetMask=${netmask}  Gateway=${gw_ip}
713568df5f1SPrashanth Katti
714568df5f1SPrashanth Katti    # Find the position of IP address to be modified.
715568df5f1SPrashanth Katti    @{network_configurations}=  Get Network Configuration
716568df5f1SPrashanth Katti    FOR  ${network_configuration}  IN  @{network_configurations}
717568df5f1SPrashanth Katti      Run Keyword If  '${network_configuration['Address']}' == '${ip}'
718568df5f1SPrashanth Katti      ...  Append To List  ${patch_list}  ${ip_data}
719568df5f1SPrashanth Katti      ...  ELSE  Append To List  ${patch_list}  ${empty_dict}
720568df5f1SPrashanth Katti    END
721568df5f1SPrashanth Katti
722568df5f1SPrashanth Katti    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
723568df5f1SPrashanth Katti    ...  ${patch_list}  ${ip_data}  msg=${ip} does not exist on BMC
724568df5f1SPrashanth Katti    Pass Execution If  ${ip_found} == ${False}  ${ip} does not exist on BMC
725568df5f1SPrashanth Katti
726568df5f1SPrashanth Katti    # Run patch command only if given IP is found on BMC
727568df5f1SPrashanth Katti    ${data}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
728568df5f1SPrashanth Katti
729568df5f1SPrashanth Katti    Redfish.patch  ${REDFISH_NW_ETH0_URI}  body=&{data}  valid_status_codes=[${valid_status_codes}]
730568df5f1SPrashanth Katti
731568df5f1SPrashanth Katti    # Note: Network restart takes around 15-18s after patch request processing.
732568df5f1SPrashanth Katti    Sleep  ${NETWORK_TIMEOUT}s
733568df5f1SPrashanth Katti    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
734568df5f1SPrashanth Katti
735568df5f1SPrashanth Katti    Verify IP On BMC  ${new_ip}
736568df5f1SPrashanth Katti    Validate Network Config On BMC
737*d4cdd8c0SAnves Kumar rayankula
738*d4cdd8c0SAnves Kumar rayankulaConfigure Multiple Static IPv4 Addresses
739*d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and verify.
740*d4cdd8c0SAnves Kumar rayankula    [Arguments]  ${ip_addreses}  ${subnet_mask}  ${gateway}
741*d4cdd8c0SAnves Kumar rayankula
742*d4cdd8c0SAnves Kumar rayankula    # Description of argument(s):
743*d4cdd8c0SAnves Kumar rayankula    # ip_addreses         A list of IP addresses to be added (e.g.["10.7.7.7"]).
744*d4cdd8c0SAnves Kumar rayankula    # subnet_mask         Subnet mask for the IP to be added (e.g. "255.255.0.0").
745*d4cdd8c0SAnves Kumar rayankula    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
746*d4cdd8c0SAnves Kumar rayankula
747*d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN   @{ip_addreses}
748*d4cdd8c0SAnves Kumar rayankula       Add IP Address  ${ip}  ${subnet_mask}  ${gateway}
749*d4cdd8c0SAnves Kumar rayankula    END
750*d4cdd8c0SAnves Kumar rayankula    Validate Network Config On BMC
751*d4cdd8c0SAnves Kumar rayankula
752*d4cdd8c0SAnves Kumar rayankula
753*d4cdd8c0SAnves Kumar rayankulaDelete Multiple Static IPv4 Addresses
754*d4cdd8c0SAnves Kumar rayankula    [Documentation]  Delete multiple static ipv4 address via Redfish.
755*d4cdd8c0SAnves Kumar rayankula    [Arguments]  ${ip_addreses}
756*d4cdd8c0SAnves Kumar rayankula
757*d4cdd8c0SAnves Kumar rayankula    # Description of argument(s):
758*d4cdd8c0SAnves Kumar rayankula    # ip_addreses         A list of IP addresses to be deleted (e.g.["10.7.7.7"]).
759*d4cdd8c0SAnves Kumar rayankula
760*d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN   @{ip_addreses}
761*d4cdd8c0SAnves Kumar rayankula       Delete IP Address  ${ip}
762*d4cdd8c0SAnves Kumar rayankula    END
763*d4cdd8c0SAnves Kumar rayankula    Validate Network Config On BMC
764