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.
123*0c8100ffSGeorge Keishing    [Tags]  Add_Valid_IPv4_Address_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.
131*0c8100ffSGeorge Keishing    [Tags]  Add_Invalid_IPv4_Address_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.
173*0c8100ffSGeorge Keishing    [Tags]  Add_Valid_IPv4_Address_And_Check_Persistency
174b36a7521SPrashanth Katti
175b36a7521SPrashanth Katti    Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
176b36a7521SPrashanth Katti
177b36a7521SPrashanth Katti    # Reboot BMC and verify persistency.
178b36a7521SPrashanth Katti    OBMC Reboot (off)
1795c498748SGeorge Keishing    Redfish.Login
180b36a7521SPrashanth Katti    Verify IP On BMC  ${test_ipv4_addr}
181f179f267SAnves Kumar rayankula    Delete IP Address  ${test_ipv4_addr}
182de3bf7b5SVijay
1836cedca29SPrashanth KattiAdd Fourth Octet Threshold IP And Verify
1846cedca29SPrashanth Katti    [Documentation]  Add fourth octet threshold IP and verify.
1856cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Threshold_IP_And_Verify
1869c7238daSAnvesh Kumar    [Teardown]  Run Keywords
1879c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.7.254  AND  Test Teardown Execution
1886cedca29SPrashanth Katti
1896cedca29SPrashanth Katti     Add IP Address  10.7.7.254  ${test_subnet_mask}  ${test_gateway}
1906cedca29SPrashanth Katti
1916cedca29SPrashanth KattiAdd Fourth Octet Lowest IP And Verify
1926cedca29SPrashanth Katti    [Documentation]  Add fourth octet lowest IP and verify.
1936cedca29SPrashanth Katti    [Tags]  Add_Fourth_Octet_Lowest_IP_And_Verify
1949c7238daSAnvesh Kumar    [Teardown]  Run Keywords
1959c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.7.1  AND  Test Teardown Execution
1966cedca29SPrashanth Katti
1976cedca29SPrashanth Katti     Add IP Address  10.7.7.1  ${test_subnet_mask}  ${test_gateway}
1986cedca29SPrashanth Katti
1996cedca29SPrashanth KattiAdd Third Octet Threshold IP And Verify
2006cedca29SPrashanth Katti    [Documentation]  Add third octet threshold IP and verify.
2016cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Threshold_IP_And_Verify
2029c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2039c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.255.7  AND  Test Teardown Execution
2046cedca29SPrashanth Katti
2056cedca29SPrashanth Katti     Add IP Address  10.7.255.7  ${test_subnet_mask}  ${test_gateway}
2066cedca29SPrashanth Katti
2076cedca29SPrashanth KattiAdd Third Octet Lowest IP And Verify
2086cedca29SPrashanth Katti    [Documentation]  Add third octet lowest IP and verify.
2096cedca29SPrashanth Katti    [Tags]  Add_Third_Octet_Lowest_IP_And_Verify
2109c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2119c7238daSAnvesh Kumar    ...  Delete IP Address  10.7.0.7  AND  Test Teardown Execution
2126cedca29SPrashanth Katti
2136cedca29SPrashanth Katti     Add IP Address  10.7.0.7  ${test_subnet_mask}  ${test_gateway}
2146cedca29SPrashanth Katti
2156cedca29SPrashanth KattiAdd Second Octet Threshold IP And Verify
2166cedca29SPrashanth Katti    [Documentation]  Add second octet threshold IP and verify.
2176cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Threshold_IP_And_Verify
2189c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2199c7238daSAnvesh Kumar    ...  Delete IP Address  10.255.7.7  AND  Test Teardown Execution
2206cedca29SPrashanth Katti
2216cedca29SPrashanth Katti     Add IP Address  10.255.7.7  ${test_subnet_mask}  ${test_gateway}
2226cedca29SPrashanth Katti
2236cedca29SPrashanth KattiAdd Second Octet Lowest IP And Verify
2246cedca29SPrashanth Katti    [Documentation]  Add second octet lowest IP and verify.
2256cedca29SPrashanth Katti    [Tags]  Add_Second_Octet_Lowest_IP_And_Verify
2269c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2279c7238daSAnvesh Kumar    ...  Delete IP Address  10.0.7.7  AND  Test Teardown Execution
2286cedca29SPrashanth Katti
2296cedca29SPrashanth Katti     Add IP Address  10.0.7.7  ${test_subnet_mask}  ${test_gateway}
2306cedca29SPrashanth Katti
2316cedca29SPrashanth KattiAdd First Octet Threshold IP And Verify
2326cedca29SPrashanth Katti    [Documentation]  Add first octet threshold IP and verify.
2336cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Threshold_IP_And_Verify
2349c7238daSAnvesh Kumar    [Teardown]  Run Keywords
235f757b107SAnves Kumar rayankula    ...  Delete IP Address  223.7.7.7  AND  Test Teardown Execution
2366cedca29SPrashanth Katti
2376cedca29SPrashanth Katti     Add IP Address  223.7.7.7  ${test_subnet_mask}  ${test_gateway}
2386cedca29SPrashanth Katti
2396cedca29SPrashanth KattiAdd First Octet Lowest IP And Verify
2406cedca29SPrashanth Katti    [Documentation]  Add first octet lowest IP and verify.
2416cedca29SPrashanth Katti    [Tags]  Add_First_Octet_Lowest_IP_And_Verify
2429c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2439c7238daSAnvesh Kumar    ...  Delete IP Address  1.7.7.7  AND  Test Teardown Execution
2446cedca29SPrashanth Katti
2456cedca29SPrashanth Katti     Add IP Address  1.7.7.7  ${test_subnet_mask}  ${test_gateway}
2466cedca29SPrashanth Katti
247040c8c12SPrashanth KattiConfigure Invalid Netmask
248040c8c12SPrashanth Katti    [Documentation]  Verify error while setting invalid netmask.
249040c8c12SPrashanth Katti    [Tags]  Configure_Invalid_Netmask
250040c8c12SPrashanth Katti    [Template]  Add IP Address
251040c8c12SPrashanth Katti
252040c8c12SPrashanth Katti    # ip               subnet_mask         gateway          valid_status_codes
253040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${invalid_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
254040c8c12SPrashanth Katti
255040c8c12SPrashanth KattiConfigure Out Of Range Netmask
256040c8c12SPrashanth Katti    [Documentation]  Verify error while setting out of range netmask.
257040c8c12SPrashanth Katti    [Tags]  Configure_Out_Of_Range_Netmask
258040c8c12SPrashanth Katti    [Template]  Add IP Address
259040c8c12SPrashanth Katti
260040c8c12SPrashanth Katti    # ip               subnet_mask              gateway          valid_status_codes
261040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${out_of_range_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
262040c8c12SPrashanth Katti
263040c8c12SPrashanth KattiConfigure Alpha Netmask
264040c8c12SPrashanth Katti    [Documentation]  Verify error while setting alpha netmask.
265040c8c12SPrashanth Katti    [Tags]  Configure_Alpha_Netmask
266040c8c12SPrashanth Katti    [Template]  Add IP Address
267040c8c12SPrashanth Katti
268040c8c12SPrashanth Katti    # ip               subnet_mask       gateway          valid_status_codes
269040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${alpha_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
270040c8c12SPrashanth Katti
271040c8c12SPrashanth KattiConfigure More Byte Netmask
272040c8c12SPrashanth Katti    [Documentation]  Verify error while setting more byte netmask.
273040c8c12SPrashanth Katti    [Tags]  Configure_More_Byte_Netmask
274040c8c12SPrashanth Katti    [Template]  Add IP Address
275040c8c12SPrashanth Katti
276040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
277040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${more_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
278040c8c12SPrashanth Katti
279040c8c12SPrashanth KattiConfigure Less Byte Netmask
280040c8c12SPrashanth Katti    [Documentation]  Verify error while setting less byte netmask.
281040c8c12SPrashanth Katti    [Tags]  Configure_Less_Byte_Netmask
282040c8c12SPrashanth Katti    [Template]  Add IP Address
283040c8c12SPrashanth Katti
284040c8c12SPrashanth Katti    # ip               subnet_mask           gateway          valid_status_codes
285040c8c12SPrashanth Katti    ${test_ipv4_addr}  ${less_byte_netmask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
286040c8c12SPrashanth Katti
287c6ad647fSPrashanth KattiConfigure Threshold Netmask And Verify
288c6ad647fSPrashanth Katti    [Documentation]  Configure threshold netmask and verify.
289c6ad647fSPrashanth Katti    [Tags]  Configure_Threshold_Netmask_And_verify
2909c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2919c7238daSAnvesh Kumar    ...   Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
292c6ad647fSPrashanth Katti
293c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${threshold_netmask}  ${test_gateway}
294c6ad647fSPrashanth Katti
295c6ad647fSPrashanth KattiConfigure Lowest Netmask And Verify
296c6ad647fSPrashanth Katti    [Documentation]  Configure lowest netmask and verify.
297c6ad647fSPrashanth Katti    [Tags]  Configure_Lowest_Netmask_And_verify
2989c7238daSAnvesh Kumar    [Teardown]  Run Keywords
2999c7238daSAnvesh Kumar    ...   Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
300c6ad647fSPrashanth Katti
301c6ad647fSPrashanth Katti     Add IP Address  ${test_ipv4_addr}  ${lowest_netmask}  ${test_gateway}
302c6ad647fSPrashanth Katti
303c6ad647fSPrashanth KattiConfigure Network ID
304c6ad647fSPrashanth Katti    [Documentation]  Verify error while configuring network ID.
305c6ad647fSPrashanth Katti    [Tags]  Configure_Network_ID
306c6ad647fSPrashanth Katti    [Template]  Add IP Address
307c6ad647fSPrashanth Katti    [Teardown]  Clear IP Settings On Fail  ${network_id}
308c6ad647fSPrashanth Katti
309c6ad647fSPrashanth Katti    # ip           subnet_mask          gateway          valid_status_codes
310c6ad647fSPrashanth Katti    ${network_id}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
311c6ad647fSPrashanth Katti
312c6ad647fSPrashanth KattiConfigure Less Octet IP
313c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring less octet IP address.
314c6ad647fSPrashanth Katti    [Tags]  Configure_Less_Octet_IP
315c6ad647fSPrashanth Katti    [Template]  Add IP Address
316c6ad647fSPrashanth Katti
317c6ad647fSPrashanth Katti    # ip              subnet_mask          gateway          valid_status_codes
318c6ad647fSPrashanth Katti    ${less_octet_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
319c6ad647fSPrashanth Katti
320c6ad647fSPrashanth KattiConfigure Empty IP
321c6ad647fSPrashanth Katti    [Documentation]  Verify error while Configuring empty IP address.
322c6ad647fSPrashanth Katti    [Tags]  Configure_Empty_IP
323c6ad647fSPrashanth Katti    [Template]  Add IP Address
324c6ad647fSPrashanth Katti
325c6ad647fSPrashanth Katti    # ip      subnet_mask          gateway          valid_status_codes
326c6ad647fSPrashanth Katti    ${EMPTY}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
327c6ad647fSPrashanth Katti
328c6ad647fSPrashanth KattiConfigure Special Char IP
329c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing special chars.
330c6ad647fSPrashanth Katti    [Tags]  Configure_Special_Char_IP
331c6ad647fSPrashanth Katti    [Template]  Add IP Address
332c6ad647fSPrashanth Katti
333c6ad647fSPrashanth Katti    # ip          subnet_mask          gateway          valid_status_codes
334c6ad647fSPrashanth Katti    @@@.%%.44.11  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
335c6ad647fSPrashanth Katti
336c6ad647fSPrashanth KattiConfigure Hexadecimal IP
337c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing hex value.
338c6ad647fSPrashanth Katti    [Tags]  Configure_Hexadecimal_IP
339c6ad647fSPrashanth Katti    [Template]  Add IP Address
340c6ad647fSPrashanth Katti
341c6ad647fSPrashanth Katti    # ip       subnet_mask          gateway          valid_status_codes
342c6ad647fSPrashanth Katti    ${hex_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
343c6ad647fSPrashanth Katti
344c6ad647fSPrashanth KattiConfigure Negative Octet IP
345c6ad647fSPrashanth Katti    [Documentation]  Configure invalid IP address containing negative octet.
346c6ad647fSPrashanth Katti    [Tags]  Configure_Negative_Octet_IP
347c6ad647fSPrashanth Katti    [Template]  Add IP Address
348c6ad647fSPrashanth Katti
349c6ad647fSPrashanth Katti    # ip            subnet_mask          gateway          valid_status_codes
350c6ad647fSPrashanth Katti    ${negative_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
351c6ad647fSPrashanth Katti
3525cad5a07SPrashanth KattiConfigure Incomplete IP For Gateway
3535cad5a07SPrashanth Katti    [Documentation]  Configure incomplete IP for gateway and expect an error.
3545cad5a07SPrashanth Katti    [Tags]  Configure_Incomplete_IP_For_Gateway
3555cad5a07SPrashanth Katti    [Template]  Add IP Address
3565cad5a07SPrashanth Katti
3575cad5a07SPrashanth Katti    # ip               subnet_mask          gateway           valid_status_codes
3585cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${less_octet_ip}  ${HTTP_BAD_REQUEST}
3595cad5a07SPrashanth Katti
3605cad5a07SPrashanth KattiConfigure Special Char IP For Gateway
3615cad5a07SPrashanth Katti    [Documentation]  Configure special char IP for gateway and expect an error.
3625cad5a07SPrashanth Katti    [Tags]  Configure_Special_Char_IP_For_Gateway
3635cad5a07SPrashanth Katti    [Template]  Add IP Address
3645cad5a07SPrashanth Katti
3655cad5a07SPrashanth Katti    # ip               subnet_mask          gateway       valid_status_codes
3665cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  @@@.%%.44.11  ${HTTP_BAD_REQUEST}
3675cad5a07SPrashanth Katti
3685cad5a07SPrashanth KattiConfigure Hexadecimal IP For Gateway
3695cad5a07SPrashanth Katti    [Documentation]  Configure hexadecimal IP for gateway and expect an error.
3705cad5a07SPrashanth Katti    [Tags]  Configure_Hexadecimal_IP_For_Gateway
3715cad5a07SPrashanth Katti    [Template]  Add IP Address
3725cad5a07SPrashanth Katti
3735cad5a07SPrashanth Katti    # ip               subnet_mask          gateway    valid_status_codes
3745cad5a07SPrashanth Katti    ${test_ipv4_addr}  ${test_subnet_mask}  ${hex_ip}  ${HTTP_BAD_REQUEST}
3755cad5a07SPrashanth Katti
3767098c976SPrashanth KattiGet DNS Server And Verify
3777098c976SPrashanth Katti    [Documentation]  Get DNS server via Redfish and verify.
3787098c976SPrashanth Katti    [Tags]  Get_DNS_Server_And_Verify
3797098c976SPrashanth Katti
3807098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3817098c976SPrashanth Katti
3827098c976SPrashanth KattiConfigure DNS Server And Verify
3837098c976SPrashanth Katti    [Documentation]  Configure DNS server and verify.
3847098c976SPrashanth Katti    [Tags]  Configure_DNS_Server_And_Verify
385c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
3867098c976SPrashanth Katti    [Teardown]  Run Keywords
3877098c976SPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
3887098c976SPrashanth Katti
3897098c976SPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
3907098c976SPrashanth Katti    Verify CLI and Redfish Nameservers
3917098c976SPrashanth Katti
392c85957cdSPrashanth KattiDelete DNS Server And Verify
393c85957cdSPrashanth Katti    [Documentation]  Delete DNS server and verify.
394c85957cdSPrashanth Katti    [Tags]  Delete_DNS_Server_And_Verify
395c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
396c85957cdSPrashanth Katti    [Teardown]  Run Keywords
397c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
398c85957cdSPrashanth Katti
399c85957cdSPrashanth Katti    Delete Static Name Servers
400c85957cdSPrashanth Katti    Verify CLI and Redfish Nameservers
401c85957cdSPrashanth Katti
402c85957cdSPrashanth KattiConfigure DNS Server And Check Persistency
403c85957cdSPrashanth Katti    [Documentation]  Configure DNS server and check persistency on reboot.
404c85957cdSPrashanth Katti    [Tags]  Configure_DNS_Server_And_Check_Persistency
405c85957cdSPrashanth Katti    [Setup]  DNS Test Setup Execution
406c85957cdSPrashanth Katti    [Teardown]  Run Keywords
407c85957cdSPrashanth Katti    ...  Configure Static Name Servers  AND  Test Teardown Execution
408c85957cdSPrashanth Katti
409c85957cdSPrashanth Katti    Configure Static Name Servers  ${static_name_servers}
410c85957cdSPrashanth Katti    # Reboot BMC and verify persistency.
411c85957cdSPrashanth Katti    OBMC Reboot (off)
4128c628b70SAnves Kumar rayankula    Redfish.Login
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.
480*0c8100ffSGeorge Keishing    [Tags]  Modify_IPv4_Address_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
516d4cdd8c0SAnves Kumar rayankulaConfigure And Verify Multiple Static IPv4 Addresses
517d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and verify.
518d4cdd8c0SAnves Kumar rayankula    [Tags]  Configure_And_Verify_Multiple_Static_IPv4_Addresses
519d4cdd8c0SAnves Kumar rayankula    [Teardown]  Run Keywords  Delete Multiple Static IPv4 Addresses  ${test_ipv4_addresses}
520d4cdd8c0SAnves Kumar rayankula    ...  AND  Test Teardown Execution
521d4cdd8c0SAnves Kumar rayankula
522d4cdd8c0SAnves Kumar rayankula    ${test_ipv4_addresses}=  Create List  ${test_ipv4_addr}  ${test_ipv4_addr2}
523d4cdd8c0SAnves Kumar rayankula    Configure Multiple Static IPv4 Addresses   ${test_ipv4_addresses}  ${test_subnet_mask}  ${test_gateway}
524d4cdd8c0SAnves Kumar rayankula
525d4cdd8c0SAnves Kumar rayankula
526d4cdd8c0SAnves Kumar rayankulaConfigure Multiple Static IPv4 Addresses And Check Persistency
527d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and check persistency.
528d4cdd8c0SAnves Kumar rayankula    [Tags]  Configure_Multiple_Static_IPv4_Addresses_And_Check_Persistency
529d4cdd8c0SAnves Kumar rayankula    [Teardown]  Run Keywords  Delete Multiple Static IPv4 Addresses  ${test_ipv4_addresses}
530d4cdd8c0SAnves Kumar rayankula    ...  AND  Test Teardown Execution
531d4cdd8c0SAnves Kumar rayankula
532d4cdd8c0SAnves Kumar rayankula    ${test_ipv4_addresses}=  Create List  ${test_ipv4_addr}  ${test_ipv4_addr2}
533d4cdd8c0SAnves Kumar rayankula    Configure Multiple Static IPv4 Addresses  ${test_ipv4_addresses}  ${test_subnet_mask}  ${test_gateway}
534d4cdd8c0SAnves Kumar rayankula
535d4cdd8c0SAnves Kumar rayankula    # Reboot BMC and verify persistency.
536d4cdd8c0SAnves Kumar rayankula    OBMC Reboot (off)
5378c628b70SAnves Kumar rayankula    Redfish.Login
538d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN  @{test_ipv4_addresses}
539d4cdd8c0SAnves Kumar rayankula      Verify IP And Netmask On BMC  ${ip}  ${test_subnet_mask}
540d4cdd8c0SAnves Kumar rayankula    END
541d4cdd8c0SAnves Kumar rayankula
542d4cdd8c0SAnves Kumar rayankula
54343e93e14SAnves Kumar rayankulaConfigure And Verify Multiple IPv4 Addresses
54443e93e14SAnves Kumar rayankula    [Documentation]  Configure multiple IPv4 addresses and verify.
545*0c8100ffSGeorge Keishing    [Tags]  Configure_And_Verify_Multiple_IPv4_Addresses
54643e93e14SAnves Kumar rayankula    [Teardown]  Run Keywords
54743e93e14SAnves Kumar rayankula    ...  Delete IP Address  ${test_ipv4_addr}  AND  Delete IP Address  ${test_ipv4_addr2}
54843e93e14SAnves Kumar rayankula    ...  AND  Test Teardown Execution
54943e93e14SAnves Kumar rayankula
55043e93e14SAnves Kumar rayankula    ${ip1}=  Create dictionary  Address=${test_ipv4_addr}
55143e93e14SAnves Kumar rayankula    ...  SubnetMask=255.255.0.0  Gateway=${test_gateway}
55243e93e14SAnves Kumar rayankula    ${ip2}=  Create dictionary  Address=${test_ipv4_addr2}
55343e93e14SAnves Kumar rayankula    ...  SubnetMask=255.255.252.0  Gateway=${test_gateway}
55443e93e14SAnves Kumar rayankula
55543e93e14SAnves Kumar rayankula    ${empty_dict}=  Create Dictionary
55643e93e14SAnves Kumar rayankula    ${patch_list}=  Create List
55743e93e14SAnves Kumar rayankula    ${network_configurations}=  Get Network Configuration
55843e93e14SAnves Kumar rayankula    ${num_entries}=  Get Length  ${network_configurations}
55943e93e14SAnves Kumar rayankula
56043e93e14SAnves Kumar rayankula    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
56143e93e14SAnves Kumar rayankula      Append To List  ${patch_list}  ${empty_dict}
56243e93e14SAnves Kumar rayankula    END
56343e93e14SAnves Kumar rayankula
56443e93e14SAnves Kumar rayankula    # We need not check for existence of IP on BMC while adding.
56543e93e14SAnves Kumar rayankula    Append To List  ${patch_list}  ${ip1}  ${ip2}
56643e93e14SAnves Kumar rayankula    ${payload}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
56743e93e14SAnves Kumar rayankula    ${active_channel_config}=  Get Active Channel Config
56843e93e14SAnves Kumar rayankula    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
56943e93e14SAnves Kumar rayankula    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  body=&{payload}
57053b8030fSAnves Kumar rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
57143e93e14SAnves Kumar rayankula
57243e93e14SAnves Kumar rayankula    # Note: Network restart takes around 15-18s after patch request processing.
57343e93e14SAnves Kumar rayankula    Sleep  ${NETWORK_TIMEOUT}s
57443e93e14SAnves Kumar rayankula    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
57543e93e14SAnves Kumar rayankula    Verify IP On BMC  ${test_ipv4_addr}
57643e93e14SAnves Kumar rayankula    Verify IP On BMC  ${test_ipv4_addr2}
57743e93e14SAnves Kumar rayankula
57843e93e14SAnves Kumar rayankula
579eefdb564SAnves Kumar rayankulaConfig Multiple DNS Servers And Check Persistency
580eefdb564SAnves Kumar rayankula    [Documentation]  Config multiple DNS and check persistency.
581eefdb564SAnves Kumar rayankula    [Tags]  Config_Multiple_DNS_Servers_And_Check_Persistency
582eefdb564SAnves Kumar rayankula    [Setup]  DNS Test Setup Execution
583eefdb564SAnves Kumar rayankula    [Teardown]  Run Keywords
584eefdb564SAnves Kumar rayankula    ...  Configure Static Name Servers  AND  Test Teardown Execution
585eefdb564SAnves Kumar rayankula
586eefdb564SAnves Kumar rayankula    @{list_name_servers}=  Create List  10.5.5.10  10.20.5.10  10.5.6.7
587eefdb564SAnves Kumar rayankula    Configure Static Name Servers  ${list_name_servers}
588eefdb564SAnves Kumar rayankula
589eefdb564SAnves Kumar rayankula    # Reboot BMC and verify persistency.
590eefdb564SAnves Kumar rayankula    OBMC Reboot (off)
591eefdb564SAnves Kumar rayankula    Redfish.Login
592eefdb564SAnves Kumar rayankula    Verify CLI and Redfish Nameservers
593eefdb564SAnves Kumar rayankula
5942f137ebeSAnves Kumar rayankula
5952f137ebeSAnves Kumar rayankulaConfigure Static IP Without Using Gateway And Verify
5962f137ebeSAnves Kumar rayankula    [Documentation]  Configure static IP without using gateway and verify error.
5972f137ebeSAnves Kumar rayankula    [Tags]  Configure_Static_IP_Without_Using_Gateway_And_Verify
5982f137ebeSAnves Kumar rayankula
5992f137ebeSAnves Kumar rayankula    ${ip}=  Create dictionary  Address=${test_ipv4_addr}
6002f137ebeSAnves Kumar rayankula    ...  SubnetMask=${test_subnet_mask}
6012f137ebeSAnves Kumar rayankula    ${empty_dict}=  Create Dictionary
6022f137ebeSAnves Kumar rayankula    ${patch_list}=  Create List
6032f137ebeSAnves Kumar rayankula    ${network_configurations}=  Get Network Configuration
6042f137ebeSAnves Kumar rayankula
6052f137ebeSAnves Kumar rayankula    ${num_entries}=  Get Length  ${network_configurations}
6062f137ebeSAnves Kumar rayankula    FOR  ${INDEX}  IN RANGE  0  ${num_entries}
6072f137ebeSAnves Kumar rayankula      Append To List  ${patch_list}  ${empty_dict}
6082f137ebeSAnves Kumar rayankula    END
6092f137ebeSAnves Kumar rayankula
6102f137ebeSAnves Kumar rayankula    # We need not check for existence of IP on BMC while adding.
6112f137ebeSAnves Kumar rayankula    Append To List  ${patch_list}  ${ip}
6122f137ebeSAnves Kumar rayankula    ${payload}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
6132f137ebeSAnves Kumar rayankula    ${active_channel_config}=  Get Active Channel Config
6142f137ebeSAnves Kumar rayankula    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
6152f137ebeSAnves Kumar rayankula    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
6162f137ebeSAnves Kumar rayankula    ...  body=&{payload}  valid_status_codes=[${HTTP_BAD_REQUEST}]
6172f137ebeSAnves Kumar rayankula
618ac0a7bafSAnves Kumar rayankula
619ac0a7bafSAnves Kumar rayankulaTest Network Response On Specified Host State
620ac0a7bafSAnves Kumar rayankula    [Documentation]  Verifying the BMC network response when host is on and off.
621ac0a7bafSAnves Kumar rayankula    [Tags]  Test_Network_Response_On_Specified_Host_State
622ac0a7bafSAnves Kumar rayankula    [Template]  Verify Network Response On Specified Host State
623ac0a7bafSAnves Kumar rayankula
624ac0a7bafSAnves Kumar rayankula    # host_state
625ac0a7bafSAnves Kumar rayankula    on
626ac0a7bafSAnves Kumar rayankula    off
627ac0a7bafSAnves Kumar rayankula
628f58cce03SPrashanth Katti*** Keywords ***
629f58cce03SPrashanth Katti
630f58cce03SPrashanth KattiTest Setup Execution
631f58cce03SPrashanth Katti    [Documentation]  Test setup execution.
632f58cce03SPrashanth Katti
63397c93945SGeorge Keishing    Redfish.Login
634f58cce03SPrashanth Katti
635f58cce03SPrashanth Katti    @{network_configurations}=  Get Network Configuration
636f58cce03SPrashanth Katti    Set Test Variable  @{network_configurations}
637f58cce03SPrashanth Katti
638f58cce03SPrashanth Katti    # Get BMC IP address and prefix length.
639f58cce03SPrashanth Katti    ${ip_data}=  Get BMC IP Info
640f58cce03SPrashanth Katti    Set Test Variable  ${ip_data}
641f58cce03SPrashanth Katti
642747ce9d0SPrashanth Katti
643747ce9d0SPrashanth KattiVerify Netmask On BMC
644747ce9d0SPrashanth Katti    [Documentation]  Verify netmask on BMC.
645f58cce03SPrashanth Katti    [Arguments]  ${netmask}
646f58cce03SPrashanth Katti
647f58cce03SPrashanth Katti    # Description of the argument(s):
648f58cce03SPrashanth Katti    # netmask  netmask value to be verified.
649f58cce03SPrashanth Katti
650747ce9d0SPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
651747ce9d0SPrashanth Katti
652747ce9d0SPrashanth Katti    Should Contain Match  ${ip_data}  */${prefix_length}
653747ce9d0SPrashanth Katti    ...  msg=Prefix length does not exist.
654f58cce03SPrashanth Katti
6552c5c3bbdSPrashanth KattiVerify IP And Netmask On BMC
6562c5c3bbdSPrashanth Katti    [Documentation]  Verify IP and netmask on BMC.
6572c5c3bbdSPrashanth Katti    [Arguments]  ${ip}  ${netmask}
6582c5c3bbdSPrashanth Katti
6592c5c3bbdSPrashanth Katti    # Description of the argument(s):
6602c5c3bbdSPrashanth Katti    # ip       IP address to be verified.
6612c5c3bbdSPrashanth Katti    # netmask  netmask value to be verified.
6622c5c3bbdSPrashanth Katti
6632c5c3bbdSPrashanth Katti    ${prefix_length}=  Netmask Prefix Length  ${netmask}
6642c5c3bbdSPrashanth Katti    @{ip_data}=  Get BMC IP Info
6652c5c3bbdSPrashanth Katti
6662c5c3bbdSPrashanth Katti    ${ip_with_netmask}=  Catenate  ${ip}/${prefix_length}
6672c5c3bbdSPrashanth Katti    Should Contain  ${ip_data}  ${ip_with_netmask}
6682c5c3bbdSPrashanth Katti    ...  msg=IP and netmask pair does not exist.
6692c5c3bbdSPrashanth Katti
670f58cce03SPrashanth KattiTest Teardown Execution
671f58cce03SPrashanth Katti    [Documentation]  Test teardown execution.
672f58cce03SPrashanth Katti
673f58cce03SPrashanth Katti    FFDC On Test Case Fail
67497c93945SGeorge Keishing    Redfish.Logout
675a8442516SPrashanth Katti
676a8442516SPrashanth KattiClear IP Settings On Fail
677a8442516SPrashanth Katti    [Documentation]  Clear IP settings on fail.
678a8442516SPrashanth Katti    [Arguments]  ${ip}
679a8442516SPrashanth Katti
680a8442516SPrashanth Katti    # Description of argument(s):
681a8442516SPrashanth Katti    # ip  IP address to be deleted.
682a8442516SPrashanth Katti
683a8442516SPrashanth Katti    Run Keyword If  '${TEST STATUS}' == 'FAIL'
684a8442516SPrashanth Katti    ...  Delete IP Address  ${ip}
685a8442516SPrashanth Katti
686a8442516SPrashanth Katti    Test Teardown Execution
687adf0b4e7SPrashanth Katti
6887098c976SPrashanth KattiVerify CLI and Redfish Nameservers
6897098c976SPrashanth Katti    [Documentation]  Verify that nameservers obtained via Redfish do not
6907098c976SPrashanth Katti    ...  match those found in /etc/resolv.conf.
6917098c976SPrashanth Katti
692412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
693412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
694412c6680STony Lee
69591548eaeSAnves Kumar rayankula    ${redfish_nameservers}=  Redfish.Get Attribute
69691548eaeSAnves Kumar rayankula    ...  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  StaticNameServers
6977098c976SPrashanth Katti    ${resolve_conf_nameservers}=  CLI Get Nameservers
69839c00518SMichael Walsh    Rqprint Vars  redfish_nameservers  resolve_conf_nameservers
6997098c976SPrashanth Katti
700d77ea988SSweta Potthuri    List Should Contain Sub List  ${resolve_conf_nameservers}  ${redfish_nameservers}
701d77ea988SSweta Potthuri    ...  msg=The nameservers obtained via Redfish do not match those found in /etc/resolv.conf.
7027098c976SPrashanth Katti
7037098c976SPrashanth KattiConfigure Static Name Servers
7047098c976SPrashanth Katti    [Documentation]  Configure DNS server on BMC.
705c85957cdSPrashanth Katti    [Arguments]  ${static_name_servers}=${original_nameservers}
7063c7b6439SPrashanth Katti     ...  ${valid_status_codes}=${HTTP_OK}
7077098c976SPrashanth Katti
7089cb2e596SGeorge Keishing    # Description of the argument(s):
7097098c976SPrashanth Katti    # static_name_servers  A list of static name server IPs to be
7107098c976SPrashanth Katti    #                      configured on the BMC.
7117098c976SPrashanth Katti
712412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
713412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
714412c6680STony Lee
7156b9fcd1aSAnves Kumar rayankula    ${type} =  Evaluate  type($static_name_servers).__name__
7166b9fcd1aSAnves Kumar rayankula    ${static_name_servers}=  Set Variable If  '${type}'=='str'
7176b9fcd1aSAnves Kumar rayankula    ...  '${static_name_servers}'  ${static_name_servers}
7186b9fcd1aSAnves Kumar rayankula
7199d995fc8SPrashanth Katti    # Currently BMC is sending 500 response code instead of 400 for invalid scenarios.
72091548eaeSAnves Kumar rayankula    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
72191548eaeSAnves Kumar rayankula    ...  body={'StaticNameServers': ${static_name_servers}}
7229d995fc8SPrashanth Katti    ...  valid_status_codes=[${valid_status_codes}, ${HTTP_INTERNAL_SERVER_ERROR}]
723c85957cdSPrashanth Katti
724f247be30SPrashanth Katti    # Patch operation takes 1 to 3 seconds to set new value.
725f247be30SPrashanth Katti    Sleep  3s
726f247be30SPrashanth Katti
7277f9e60f0SPrashanth Katti    # Check if newly added DNS server is configured on BMC.
7287f9e60f0SPrashanth Katti    ${cli_nameservers}=  CLI Get Nameservers
7293c7b6439SPrashanth Katti    ${cmd_status}=  Run Keyword And Return Status
7303c7b6439SPrashanth Katti    ...  List Should Contain Sub List  ${cli_nameservers}  ${static_name_servers}
7313c7b6439SPrashanth Katti
7323c7b6439SPrashanth Katti    Run Keyword If  '${valid_status_codes}' == '${HTTP_OK}'
7333c7b6439SPrashanth Katti    ...  Should Be True  ${cmd_status} == ${True}
7343c7b6439SPrashanth Katti    ...  ELSE  Should Be True  ${cmd_status} == ${False}
7357f9e60f0SPrashanth Katti
736c85957cdSPrashanth KattiDelete Static Name Servers
737c85957cdSPrashanth Katti    [Documentation]  Delete static name servers.
738c85957cdSPrashanth Katti
739045814b3SAnves Kumar rayankula    Configure Static Name Servers  static_name_servers=@{EMPTY}
740c85957cdSPrashanth Katti
741c85957cdSPrashanth Katti    # Check if all name servers deleted on BMC.
742c85957cdSPrashanth Katti    ${nameservers}=  CLI Get Nameservers
743c85957cdSPrashanth Katti    Should Be Empty  ${nameservers}
744c85957cdSPrashanth Katti
745c85957cdSPrashanth KattiDNS Test Setup Execution
746c85957cdSPrashanth Katti    [Documentation]  Do DNS test setup execution.
747c85957cdSPrashanth Katti
748c85957cdSPrashanth Katti    Redfish.Login
749c85957cdSPrashanth Katti
750412c6680STony Lee    ${active_channel_config}=  Get Active Channel Config
751412c6680STony Lee    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
752412c6680STony Lee
75391548eaeSAnves Kumar rayankula    ${original_nameservers}=  Redfish.Get Attribute
75491548eaeSAnves Kumar rayankula    ...  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  StaticNameServers
755412c6680STony Lee
756c85957cdSPrashanth Katti    Rprint Vars  original_nameservers
757c85957cdSPrashanth Katti    # Set suite variables to trigger restoration during teardown.
758c85957cdSPrashanth Katti    Set Suite Variable  ${original_nameservers}
759b478d90eSPrashanth Katti
760b478d90eSPrashanth KattiSuite Setup Execution
761b478d90eSPrashanth Katti    [Documentation]  Do suite setup execution.
762b478d90eSPrashanth Katti
763b478d90eSPrashanth Katti    ${test_gateway}=  Get BMC Default Gateway
764b478d90eSPrashanth Katti    Set Suite Variable  ${test_gateway}
765568df5f1SPrashanth Katti
766568df5f1SPrashanth KattiUpdate IP Address
767568df5f1SPrashanth Katti    [Documentation]  Update IP address of BMC.
76853b8030fSAnves Kumar rayankula    [Arguments]  ${ip}  ${new_ip}  ${netmask}  ${gw_ip}
76953b8030fSAnves Kumar rayankula    ...  ${valid_status_codes}=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
770568df5f1SPrashanth Katti
771568df5f1SPrashanth Katti    # Description of argument(s):
772568df5f1SPrashanth Katti    # ip                  IP address to be replaced (e.g. "10.7.7.7").
773568df5f1SPrashanth Katti    # new_ip              New IP address to be configured.
774568df5f1SPrashanth Katti    # netmask             Netmask value.
775568df5f1SPrashanth Katti    # gw_ip               Gateway IP address.
776568df5f1SPrashanth Katti    # valid_status_codes  Expected return code from patch operation
777568df5f1SPrashanth Katti    #                     (e.g. "200").  See prolog of rest_request
778568df5f1SPrashanth Katti    #                     method in redfish_plus.py for details.
779568df5f1SPrashanth Katti
780568df5f1SPrashanth Katti    ${empty_dict}=  Create Dictionary
781568df5f1SPrashanth Katti    ${patch_list}=  Create List
782568df5f1SPrashanth Katti    ${ip_data}=  Create Dictionary  Address=${new_ip}  SubnetMask=${netmask}  Gateway=${gw_ip}
783568df5f1SPrashanth Katti
784568df5f1SPrashanth Katti    # Find the position of IP address to be modified.
785568df5f1SPrashanth Katti    @{network_configurations}=  Get Network Configuration
786568df5f1SPrashanth Katti    FOR  ${network_configuration}  IN  @{network_configurations}
787568df5f1SPrashanth Katti      Run Keyword If  '${network_configuration['Address']}' == '${ip}'
788568df5f1SPrashanth Katti      ...  Append To List  ${patch_list}  ${ip_data}
789568df5f1SPrashanth Katti      ...  ELSE  Append To List  ${patch_list}  ${empty_dict}
790568df5f1SPrashanth Katti    END
791568df5f1SPrashanth Katti
792568df5f1SPrashanth Katti    ${ip_found}=  Run Keyword And Return Status  List Should Contain Value
793568df5f1SPrashanth Katti    ...  ${patch_list}  ${ip_data}  msg=${ip} does not exist on BMC
794568df5f1SPrashanth Katti    Pass Execution If  ${ip_found} == ${False}  ${ip} does not exist on BMC
795568df5f1SPrashanth Katti
796568df5f1SPrashanth Katti    # Run patch command only if given IP is found on BMC
797568df5f1SPrashanth Katti    ${data}=  Create Dictionary  IPv4StaticAddresses=${patch_list}
798568df5f1SPrashanth Katti
799abf68545SAnves Kumar rayankula    ${active_channel_config}=  Get Active Channel Config
800abf68545SAnves Kumar rayankula    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
801abf68545SAnves Kumar rayankula
802abf68545SAnves Kumar rayankula    Redfish.patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
803abf68545SAnves Kumar rayankula    ...  body=&{data}  valid_status_codes=${valid_status_codes}
804568df5f1SPrashanth Katti
805568df5f1SPrashanth Katti    # Note: Network restart takes around 15-18s after patch request processing.
806568df5f1SPrashanth Katti    Sleep  ${NETWORK_TIMEOUT}s
807568df5f1SPrashanth Katti    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
808568df5f1SPrashanth Katti
809568df5f1SPrashanth Katti    Verify IP On BMC  ${new_ip}
810568df5f1SPrashanth Katti    Validate Network Config On BMC
811d4cdd8c0SAnves Kumar rayankula
812d4cdd8c0SAnves Kumar rayankulaConfigure Multiple Static IPv4 Addresses
813d4cdd8c0SAnves Kumar rayankula    [Documentation]  Configure multiple static ipv4 address via Redfish and verify.
814d4cdd8c0SAnves Kumar rayankula    [Arguments]  ${ip_addreses}  ${subnet_mask}  ${gateway}
815d4cdd8c0SAnves Kumar rayankula
816d4cdd8c0SAnves Kumar rayankula    # Description of argument(s):
817d4cdd8c0SAnves Kumar rayankula    # ip_addreses         A list of IP addresses to be added (e.g.["10.7.7.7"]).
818d4cdd8c0SAnves Kumar rayankula    # subnet_mask         Subnet mask for the IP to be added (e.g. "255.255.0.0").
819d4cdd8c0SAnves Kumar rayankula    # gateway             Gateway for the IP to be added (e.g. "10.7.7.1").
820d4cdd8c0SAnves Kumar rayankula
821d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN   @{ip_addreses}
822d4cdd8c0SAnves Kumar rayankula       Add IP Address  ${ip}  ${subnet_mask}  ${gateway}
823d4cdd8c0SAnves Kumar rayankula    END
824d4cdd8c0SAnves Kumar rayankula    Validate Network Config On BMC
825d4cdd8c0SAnves Kumar rayankula
826d4cdd8c0SAnves Kumar rayankula
827d4cdd8c0SAnves Kumar rayankulaDelete Multiple Static IPv4 Addresses
828d4cdd8c0SAnves Kumar rayankula    [Documentation]  Delete multiple static ipv4 address via Redfish.
829d4cdd8c0SAnves Kumar rayankula    [Arguments]  ${ip_addreses}
830d4cdd8c0SAnves Kumar rayankula
831d4cdd8c0SAnves Kumar rayankula    # Description of argument(s):
832d4cdd8c0SAnves Kumar rayankula    # ip_addreses         A list of IP addresses to be deleted (e.g.["10.7.7.7"]).
833d4cdd8c0SAnves Kumar rayankula
834d4cdd8c0SAnves Kumar rayankula    FOR  ${ip}  IN   @{ip_addreses}
835d4cdd8c0SAnves Kumar rayankula       Delete IP Address  ${ip}
836d4cdd8c0SAnves Kumar rayankula    END
837d4cdd8c0SAnves Kumar rayankula    Validate Network Config On BMC
838ac0a7bafSAnves Kumar rayankula
839ac0a7bafSAnves Kumar rayankulaVerify Network Response On Specified Host State
840ac0a7bafSAnves Kumar rayankula    [Documentation]  Verifying the BMC network response when host is on and off.
841ac0a7bafSAnves Kumar rayankula    [Arguments]  ${host_state}
842ac0a7bafSAnves Kumar rayankula
843ac0a7bafSAnves Kumar rayankula    # Description of argument(s):
844ac0a7bafSAnves Kumar rayankula    # host_state   if host_state is on then host is booted to operating system.
845ac0a7bafSAnves Kumar rayankula    #              if host_state is off then host is power off.
846ac0a7bafSAnves Kumar rayankula    #              (eg. on, off).
847ac0a7bafSAnves Kumar rayankula
848ac0a7bafSAnves Kumar rayankula    ${active_channel_config}=  Get Active Channel Config
849ac0a7bafSAnves Kumar rayankula    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
850ac0a7bafSAnves Kumar rayankula
851ac0a7bafSAnves Kumar rayankula    Run Keyword If  '${host_state}' == 'on'
852ac0a7bafSAnves Kumar rayankula    ...    Redfish Power On  stack_mode=skip
853ac0a7bafSAnves Kumar rayankula    ...  ELSE
854ac0a7bafSAnves Kumar rayankula    ...    Redfish Power off  stack_mode=skip
855ac0a7bafSAnves Kumar rayankula
856ac0a7bafSAnves Kumar rayankula    Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
857ac0a7bafSAnves Kumar rayankula    Ping Host  ${OPENBMC_HOST}
858ac0a7bafSAnves Kumar rayankula
859