1*** Settings ***
2
3Documentation    VMI multiple network interface tests.
4
5# This includes test scenarios where VMI has multiple interfaces.
6# So,assigns and verifies the combination of network mode in interfaces.
7
8Resource         ../../lib/external_intf/vmi_utils.robot
9
10Suite Setup       Suite Setup Execution
11Test Teardown     FFDC On Test Case Fail
12Suite Teardown    Suite Teardown Execution
13
14*** Variables ***
15
16${test_ipv4_1}              10.6.6.6
17${test_gateway_1}           10.6.6.1
18${test_netmask_1}           255.255.252.0
19
20${test_ipv4_2}              10.5.20.5
21${test_gateway_2}           10.5.20.1
22${test_netmask_2}           255.255.255.0
23${test_ipv4_3}              10.6.4.6
24
25*** Test Cases ***
26
27Configure VMI Both Interfaces In Same Subnet And Verify
28    [Documentation]  Configure VMI both interfaces in same subnet and verify.
29    [Tags]  Configure_VMI_Both_Interfaces_In_Same_Subnet_And_Verify
30    [Teardown]  Test Teardown Execution
31
32    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
33    ...  ${test_netmask_1}
34    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_3}  ${test_gateway_1}
35    ...  ${test_netmask_1}  ${HTTP_ACCEPTED}  ${interface_list}[1]
36
37Configure VMI Both Interfaces In Different Subnet And Verify
38    [Documentation]  Configure VMI both interfaces in different subnet and verify.
39    [Tags]  Configure_VMI_Both_Interfaces_In_Different_Subnet_And_Verify
40    [Teardown]  Test Teardown Execution
41
42    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
43    ...  ${test_netmask_1}
44    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_2}  ${test_gateway_2}
45    ...  ${test_netmask_2}  ${HTTP_ACCEPTED}  ${interface_list}[1]
46
47Configure VMI Both Interfaces In Dynamic And Verify
48    [Documentation]  Configure VMI both interfaces in dynamic And Verify.
49    [Tags]  Configure_VMI_Both_Interfaces_In_Dynamic_And_Verify
50    [Teardown]   Run keywords  Set VMI IPv4 Origin  ${False}
51    ...  AND  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}  ${interface_list}[1]
52    ...  AND  Test Teardown
53
54    Set VMI IPv4 Origin  ${True}
55    ${default}=  Set Variable  0.0.0.0
56    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}  ${interface_list}[1]
57    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
58    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}  ${interface_list}[1]
59
60*** Keywords ***
61
62Suite Setup Execution
63    [Documentation]  Do suite setup execution task.
64
65    Redfish.Login
66    Redfish Power On  stack_mode=skip  quiet=1
67    Get Original Vmi Details
68
69
70Test Teardown Execution
71    [Documentation]  Do test teardown execution task.
72
73    FOR  ${interface}  IN   @{interface_list}
74        Delete VMI IPv4 Address  IPv4StaticAddresses  ${HTTP_ACCEPTED}  ${interface}
75    END
76
77    FFDC On Test Case Fail
78
79
80Get Original Vmi Details
81    [Documentation]  Get original details of VMI.
82
83    @{interface_list}=  Get VMI Interfaces
84    Set Suite Variable  @{interface_list}
85
86    FOR  ${interface}  IN   @{interface_list}
87        ${resp}=  Redfish.Get
88        ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
89        ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
90        ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
91        ${vmi_network_conf}=  Catenate  SEPARATOR=_   vmi_network_conf  ${interface}
92        ${vmi_network_conf_value}=  Run Keyword If  ${length} != ${0}
93        ...  Get VMI Network Interface Details  ${interface}
94        Set Suite Variable  ${${vmi_network_conf}}  ${vmi_network_conf_value}
95    END
96
97
98Suite Teardown Execution
99    [Documentation]  Do suite teardown execution task
100    ...  Set original vmi details and verify.
101
102    FOR  ${interface}  IN   @{interface_list}
103        Run Keyword If  ${vmi_network_conf_${interface}} != ${None}
104        ...  Set Static IPv4 Address To VMI And Verify
105        ...  ${vmi_network_conf_${interface}}[IPv4_Address]
106        ...  ${vmi_network_conf_${interface}}[IPv4_Gateway]
107        ...  ${vmi_network_conf_${interface}}[IPv4_SubnetMask]
108        ...  ${HTTP_ACCEPTED}  ${interface}
109    END
110
111    Redfish.Logout
112
113