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
60Configure VMI First Interface In Static And Second In Dynamic And Verify
61    [Documentation]  Configure VMI first interface in static mode and second interface in dynamic mode
62    ...  and verify first gets static ip details and second gets dynamic ip details.
63    [Tags]  Configure_VMI_First_Interface_In_Static_And_Second_In_Dynamic_And_Verify
64    [Teardown]   Run keywords  Delete VMI IPv4 Address  AND
65    ...  Set VMI IPv4 Origin  ${False}  ${HTTP_ACCEPTED}  ${interface_list}[1]
66    ...  AND  Test Teardown
67
68    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
69    ...  ${test_netmask_1}
70    Set VMI IPv4 Origin  ${True}  ${HTTP_ACCEPTED}  ${interface_list}[1]
71    ${default}=  Set Variable  0.0.0.0
72    Verify VMI Network Interface Details  ${test_ipv4_1}  Static  ${test_gateway_1}  ${test_netmask_1}
73    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}  ${interface_list}[1]
74
75Configure VMI First Interface In Dynamic And Second In Static And Verify
76    [Documentation]  Configure VMI first interface in dynamic mode and second interface in static mode
77    ...  and verify first gets dynamic ip details and second gets static ip details.
78    [Tags]  Configure_VMI_First_Interface_In_Dynamic_And_Second_In_Static_And_Verify
79    [Teardown]   Run keywords  Set VMI IPv4 Origin  ${False}  AND
80    ...  Delete VMI IPv4 Address  IPv4StaticAddresses  ${HTTP_ACCEPTED}  ${interface_list}[1]
81    ...  AND  Test Teardown
82
83    Set VMI IPv4 Origin  ${True}
84    ${default}=  Set Variable  0.0.0.0
85    Set Static IPv4 Address To VMI And Verify  ${test_ipv4_1}  ${test_gateway_1}
86    ...  ${test_netmask_1}  ${HTTP_ACCEPTED}  ${interface_list}[1]
87    Verify VMI Network Interface Details  ${default}  DHCP  ${default}  ${default}
88
89*** Keywords ***
90
91Suite Setup Execution
92    [Documentation]  Do suite setup execution task.
93
94    Redfish.Login
95    Redfish Power On  stack_mode=skip  quiet=1
96    Get Original Vmi Details
97
98
99Test Teardown Execution
100    [Documentation]  Do test teardown execution task.
101
102    FOR  ${interface}  IN   @{interface_list}
103        Delete VMI IPv4 Address  IPv4StaticAddresses  ${HTTP_ACCEPTED}  ${interface}
104    END
105
106    FFDC On Test Case Fail
107
108
109Get Original Vmi Details
110    [Documentation]  Get original details of VMI.
111
112    @{interface_list}=  Get VMI Interfaces
113    Set Suite Variable  @{interface_list}
114
115    FOR  ${interface}  IN   @{interface_list}
116        ${resp}=  Redfish.Get
117        ...  /redfish/v1/Systems/hypervisor/EthernetInterfaces/${interface}
118        ${ip_resp}=  Evaluate  json.loads(r'''${resp.text}''')  json
119        ${length}=  Get Length  ${ip_resp["IPv4StaticAddresses"]}
120        ${vmi_network_conf}=  Catenate  SEPARATOR=_   vmi_network_conf  ${interface}
121        ${vmi_network_conf_value}=  Run Keyword If  ${length} != ${0}
122        ...  Get VMI Network Interface Details  ${interface}
123        Set Suite Variable  ${${vmi_network_conf}}  ${vmi_network_conf_value}
124    END
125
126
127Suite Teardown Execution
128    [Documentation]  Do suite teardown execution task
129    ...  Set original vmi details and verify.
130
131    FOR  ${interface}  IN   @{interface_list}
132        Run Keyword If  ${vmi_network_conf_${interface}} != ${None}
133        ...  Set Static IPv4 Address To VMI And Verify
134        ...  ${vmi_network_conf_${interface}}[IPv4_Address]
135        ...  ${vmi_network_conf_${interface}}[IPv4_Gateway]
136        ...  ${vmi_network_conf_${interface}}[IPv4_SubnetMask]
137        ...  ${HTTP_ACCEPTED}  ${interface}
138    END
139
140    Redfish.Logout
141
142