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    Run Keyword And Ignore Error  Suite Teardown Execution
13
14Force Tags        Vmi_Multiple_Interfaces
15
16*** Variables ***
17
18${test_ipv4_1}              10.6.6.6
19${test_gateway_1}           10.6.6.1
20${test_netmask_1}           255.255.252.0
21
22${test_ipv4_2}              10.5.20.5
23${test_gateway_2}           10.5.20.1
24${test_netmask_2}           255.255.255.0
25${test_ipv4_3}              10.6.4.6
26
27*** Test Cases ***
28
29Configure VMI Both Interfaces In Same Subnet And Verify
30    [Documentation]  Configure VMI both interfaces in same subnet and verify.
31    [Tags]  Configure_VMI_Both_Interfaces_In_Same_Subnet_And_Verify
32    [Teardown]  Test Teardown Execution
33
34    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
35    ...  ${test_netmask_1}
36    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_3}  ${test_gateway_1}
37    ...  ${test_netmask_1}  ${HTTP_ACCEPTED}  ${interface_list}[1]
38
39Configure VMI Both Interfaces In Different Subnet And Verify
40    [Documentation]  Configure VMI both interfaces in different subnet and verify.
41    [Tags]  Configure_VMI_Both_Interfaces_In_Different_Subnet_And_Verify
42    [Teardown]  Test Teardown Execution
43
44    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
45    ...  ${test_netmask_1}
46    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_2}  ${test_gateway_2}
47    ...  ${test_netmask_2}  ${HTTP_ACCEPTED}  ${interface_list}[1]
48
49Configure VMI Both Interfaces In Dynamic And Verify
50    [Documentation]  Configure VMI both interfaces in dynamic And Verify.
51    [Tags]  Configure_VMI_Both_Interfaces_In_Dynamic_And_Verify
52    [Teardown]   Run keywords  Set VMI IPv4 Origin  ${False}
53    ...  AND  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}  ${interface_list}[1]
54    ...  AND  Test Teardown
55
56    Set VMI IPv4 Origin  ${True}
57    ${default}=  Set Variable  0.0.0.0
58    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}  ${interface_list}[1]
59    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
60    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}  ${interface_list}[1]
61
62Configure VMI First Interface In Static And Second In Dynamic And Verify
63    [Documentation]  Configure VMI first interface in static mode and second interface in dynamic mode
64    ...  and verify first gets static ip details and second gets dynamic ip details.
65    [Tags]  Configure_VMI_First_Interface_In_Static_And_Second_In_Dynamic_And_Verify
66    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND
67    ...  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}  ${interface_list}[1]
68    ...  AND  Test Teardown
69
70    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
71    ...  ${test_netmask_1}
72    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}  ${interface_list}[1]
73    ${default}=  Set Variable  0.0.0.0
74    Verify VMI Network Interface Details  ${test_ipv4_1}  Static  ${test_gateway_1}  ${test_netmask_1}
75    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}  ${interface_list}[1]
76
77Configure VMI First Interface In Dynamic And Second In Static And Verify
78    [Documentation]  Configure VMI first interface in dynamic mode and second interface in static mode
79    ...  and verify first gets dynamic ip details and second gets static ip details.
80    [Tags]  Configure_VMI_First_Interface_In_Dynamic_And_Second_In_Static_And_Verify
81    [Teardown]   Run keywords  Set VMI IPv4 Origin  ${False}  AND
82    ...  Delete VMI IPv4 Address  IPv4StaticAddresses  ${HTTP_ACCEPTED}  ${interface_list}[1]
83    ...  AND  Test Teardown
84
85    Set VMI IPv4 Origin  ${True}
86    ${default}=  Set Variable  0.0.0.0
87    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
88    ...  ${test_netmask_1}  ${HTTP_ACCEPTED}  ${interface_list}[1]
89    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
90
91*** Keywords ***
92
93Suite Setup Execution
94    [Documentation]  Do suite setup execution task.
95
96    Redfish.Login
97    Redfish Power On  stack_mode=skip  quiet=1
98    Get Original Vmi Details
99
100
101Test Teardown Execution
102    [Documentation]  Do test teardown execution task.
103
104    FOR  ${interface}  IN   @{interface_list}
105        Delete VMI IPv4 Address  IPv4StaticAddresses  ${HTTP_ACCEPTED}  ${interface}
106    END
107
108    FFDC On Test Case Fail
109
110
111Get Original Vmi Details
112    [Documentation]  Get original details of VMI.
113
114    @{interface_list}=  Get VMI Interfaces
115    Set Suite Variable  @{interface_list}
116
117    FOR  ${interface}  IN   @{interface_list}
118        ${resp}=  Redfish.Get
119        ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
120        ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
121        ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
122        ${vmi_network_conf}=  Catenate  SEPARATOR=_   vmi_network_conf  ${interface}
123        ${vmi_network_conf_value}=  Run Keyword If  ${length} != ${0}
124        ...  Get VMI Network Interface Details  ${interface}
125        Set Suite Variable  ${${vmi_network_conf}}  ${vmi_network_conf_value}
126    END
127
128
129Suite Teardown Execution
130    [Documentation]  Do suite teardown execution task
131    ...  Set original vmi details and verify.
132
133    FOR  ${interface}  IN   @{interface_list}
134        Run Keyword If  ${vmi_network_conf_${interface}} != ${None}
135        ...  Set Static IPv4 Address To VMI And Verify
136        ...  ${vmi_network_conf_${interface}}[IPv4_Address]
137        ...  ${vmi_network_conf_${interface}}[IPv4_Gateway]
138        ...  ${vmi_network_conf_${interface}}[IPv4_SubnetMask]
139        ...  ${HTTP_ACCEPTED}  ${interface}
140    END
141
142    Redfish.Logout
143
144