1364e93d6SGeorge Keishing*** Settings ***
2364e93d6SGeorge Keishing
3364e93d6SGeorge KeishingDocumentation          Module to test IPMI network functionality.
4364e93d6SGeorge KeishingResource               ../lib/ipmi_client.robot
5364e93d6SGeorge KeishingResource               ../lib/openbmc_ffdc.robot
6364e93d6SGeorge KeishingResource               ../lib/bmc_network_utils.robot
76f395fd4SGeorge KeishingResource               ../lib/boot_utils.robot
8364e93d6SGeorge KeishingLibrary                ../lib/ipmi_utils.py
9364e93d6SGeorge KeishingLibrary                ../lib/gen_robot_valid.py
10364e93d6SGeorge KeishingLibrary                ../lib/var_funcs.py
11364e93d6SGeorge KeishingLibrary                ../lib/bmc_network_utils.py
12364e93d6SGeorge Keishing
13364e93d6SGeorge KeishingSuite Setup            Suite Setup Execution
14e354c1c0SAnvesh Kumar RayankulaSuite Teardown         Redfish.Logout
15364e93d6SGeorge KeishingTest Setup             Printn
16e354c1c0SAnvesh Kumar RayankulaTest Teardown          Test Teardown Execution
17364e93d6SGeorge Keishing
18364e93d6SGeorge KeishingForce Tags             IPMI_Network_Config
19364e93d6SGeorge Keishing
20364e93d6SGeorge Keishing
21364e93d6SGeorge Keishing*** Variables ***
22e354c1c0SAnvesh Kumar Rayankula${vlan_id_for_ipmi}     ${10}
23364e93d6SGeorge Keishing@{vlan_ids}             ${20}  ${30}
24364e93d6SGeorge Keishing${interface}            eth0
25364e93d6SGeorge Keishing${ip}                   10.0.0.1
26364e93d6SGeorge Keishing${initial_lan_config}   &{EMPTY}
27364e93d6SGeorge Keishing${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
28e354c1c0SAnvesh Kumar Rayankula${netmask}              ${24}
29e354c1c0SAnvesh Kumar Rayankula${gateway}              0.0.0.0
30e354c1c0SAnvesh Kumar Rayankula${vlan_id_for_rest}     ${30}
31e354c1c0SAnvesh Kumar Rayankula
32364e93d6SGeorge Keishing
33364e93d6SGeorge Keishing*** Test Cases ***
34364e93d6SGeorge Keishing
35364e93d6SGeorge KeishingVerify IPMI Inband Network Configuration
36364e93d6SGeorge Keishing    [Documentation]  Verify BMC network configuration via inband IPMI.
37364e93d6SGeorge Keishing    [Tags]  Verify_IPMI_Inband_Network_Configuration
38364e93d6SGeorge Keishing    [Teardown]  Run Keywords  Restore Configuration  AND  FFDC On Test Case Fail
39364e93d6SGeorge Keishing
40364e93d6SGeorge Keishing    Redfish Power On
41364e93d6SGeorge Keishing
42374a5380STony Lee    Set IPMI Inband Network Configuration  ${STATIC_IP}  ${NETMASK}  ${GATEWAY}
43364e93d6SGeorge Keishing    Sleep  10
44364e93d6SGeorge Keishing
45364e93d6SGeorge Keishing    ${lan_print_output}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
46374a5380STony Lee    Valid Value  lan_print_output['IP Address']  ["${STATIC_IP}"]
47374a5380STony Lee    Valid Value  lan_print_output['Subnet Mask']  ["${NETMASK}"]
48374a5380STony Lee    Valid Value  lan_print_output['Default Gateway IP']  ["${GATEWAY}"]
49364e93d6SGeorge Keishing
50364e93d6SGeorge Keishing
51364e93d6SGeorge KeishingDisable VLAN Via IPMI When Multiple VLAN Exist On BMC
52364e93d6SGeorge Keishing    [Documentation]  Disable  VLAN Via IPMI When Multiple VLAN Exist On BMC.
53*b98036a9SGeorge Keishing    [Tags]   Disable_VLAN_Via_IPMI_When_Multiple_VLAN_Exist_On_BMC
54364e93d6SGeorge Keishing
551ee53321SAnves Kumar rayankula    FOR  ${vlan_id}  IN  @{vlan_ids}
561ee53321SAnves Kumar rayankula      Create VLAN  ${vlan_id}
57364e93d6SGeorge Keishing    END
58364e93d6SGeorge Keishing
59364e93d6SGeorge Keishing    Create VLAN Via IPMI  off
60364e93d6SGeorge Keishing
61364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
62364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
63364e93d6SGeorge Keishing
64364e93d6SGeorge Keishing
65364e93d6SGeorge KeishingConfigure IP On VLAN Via IPMI
66364e93d6SGeorge Keishing    [Documentation]   Configure IP On VLAN Via IPMI.
67364e93d6SGeorge Keishing    [Tags]  Configure_IP_On_VLAN_Via_IPMI
68364e93d6SGeorge Keishing
69e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
70364e93d6SGeorge Keishing
71364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
72364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
73364e93d6SGeorge Keishing
74364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
75e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
76364e93d6SGeorge Keishing    Valid Value  lan_config['IP Address']  ["${ip}"]
77364e93d6SGeorge Keishing
78364e93d6SGeorge Keishing
79364e93d6SGeorge KeishingCreate VLAN Via IPMI When LAN And VLAN Exist On BMC
80364e93d6SGeorge Keishing    [Documentation]  Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
81364e93d6SGeorge Keishing    [Tags]   Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
82e354c1c0SAnvesh Kumar Rayankula    [Setup]  Create VLAN  ${vlan_id_for_rest}
83364e93d6SGeorge Keishing
84e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
85364e93d6SGeorge Keishing
86364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
87e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
88364e93d6SGeorge Keishing
89364e93d6SGeorge Keishing
90e354c1c0SAnvesh Kumar RayankulaCreate VLAN Via IPMI And Verify
9174ed739fSAnvesh Kumar Rayankula    [Documentation]  Create and verify VLAN via IPMI.
9274ed739fSAnvesh Kumar Rayankula    [Tags]  Create_VLAN_Via_IPMI_And_Verify
9374ed739fSAnvesh Kumar Rayankula
94e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
9574ed739fSAnvesh Kumar Rayankula
9674ed739fSAnvesh Kumar Rayankula    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
97e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
988e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['IP Address']  ['${ip_address}']
998e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
10074ed739fSAnvesh Kumar Rayankula
101e354c1c0SAnvesh Kumar RayankulaTest Disabling Of VLAN Via IPMI
10274ed739fSAnvesh Kumar Rayankula    [Documentation]  Disable VLAN and verify via IPMI.
103e354c1c0SAnvesh Kumar Rayankula    [Tags]  Test_Disabling_Of_VLAN_Via_IPMI
10474ed739fSAnvesh Kumar Rayankula
105e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
10674ed739fSAnvesh Kumar Rayankula    Create VLAN Via IPMI  off
10774ed739fSAnvesh Kumar Rayankula
108e354c1c0SAnvesh Kumar Rayankula    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
10974ed739fSAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
11074ed739fSAnvesh Kumar Rayankula
11174ed739fSAnvesh Kumar Rayankula
112e354c1c0SAnvesh Kumar RayankulaCreate VLAN When LAN And VLAN Exist With IP Address Configured
113e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Create VLAN when LAN and VLAN exist with IP address configured.
114e354c1c0SAnvesh Kumar Rayankula   [Tags]  Create_VLAN_When_LAN_And_VLAN_Exist_With_IP_Address_Configured
115e354c1c0SAnvesh Kumar Rayankula   [Setup]  Run Keywords  Create VLAN  ${vlan_id_for_rest}  AND  Configure Network Settings On VLAN
116e354c1c0SAnvesh Kumar Rayankula   ...  ${vlan_id_for_rest}  ${ip}  ${netmask}  ${gateway}
117e354c1c0SAnvesh Kumar Rayankula
118e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI   ${vlan_id_for_ipmi}
119e354c1c0SAnvesh Kumar Rayankula
120e354c1c0SAnvesh Kumar Rayankula   ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
121e354c1c0SAnvesh Kumar Rayankula   Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
122e354c1c0SAnvesh Kumar Rayankula   Valid Value  lan_config['IP Address']  ['${ip}']
123e354c1c0SAnvesh Kumar Rayankula
1248e25b8f0SAnvesh Kumar Rayankula
1258e25b8f0SAnvesh Kumar RayankulaCreate Multiple VLANs Via IPMI And Verify
1268e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Create multiple VLANs through IPMI.
1278e25b8f0SAnvesh Kumar Rayankula    [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
1288e25b8f0SAnvesh Kumar Rayankula
1298e25b8f0SAnvesh Kumar Rayankula    FOR  ${vlan_id}  IN  @{vlan_ids}
1308e25b8f0SAnvesh Kumar Rayankula
1318e25b8f0SAnvesh Kumar Rayankula      Create VLAN Via IPMI  ${vlan_id}
1328e25b8f0SAnvesh Kumar Rayankula
1338e25b8f0SAnvesh Kumar Rayankula      ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
1348e25b8f0SAnvesh Kumar Rayankula
1358e25b8f0SAnvesh Kumar Rayankula      # Validate VLAN creation.
1368e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
1378e25b8f0SAnvesh Kumar Rayankula
1388e25b8f0SAnvesh Kumar Rayankula      # Validate existing IP address.
1398e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['IP Address']  ['${ip_address}']
1408e25b8f0SAnvesh Kumar Rayankula
1418e25b8f0SAnvesh Kumar Rayankula      # Validate existing subnet mask.
1428e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
1438e25b8f0SAnvesh Kumar Rayankula    END
1448e25b8f0SAnvesh Kumar Rayankula
1458e25b8f0SAnvesh Kumar Rayankula
146364e93d6SGeorge Keishing*** Keywords ***
147364e93d6SGeorge Keishing
148364e93d6SGeorge KeishingCreate VLAN Via IPMI
149364e93d6SGeorge Keishing    [Documentation]  Create VLAN via inband IPMI command.
150364e93d6SGeorge Keishing    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
151364e93d6SGeorge Keishing
152364e93d6SGeorge Keishing    # Description of argument(s):
153364e93d6SGeorge Keishing    # vlan_id  The VLAN ID (e.g. '10').
154364e93d6SGeorge Keishing
155364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
156364e93d6SGeorge Keishing    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
157364e93d6SGeorge Keishing
158364e93d6SGeorge Keishing
159364e93d6SGeorge KeishingSet IPMI Inband Network Configuration
160364e93d6SGeorge Keishing    [Documentation]  Run sequence of standard IPMI command in-band and set
161364e93d6SGeorge Keishing    ...              the IP configuration.
162364e93d6SGeorge Keishing    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
163364e93d6SGeorge Keishing
164364e93d6SGeorge Keishing    # Description of argument(s):
165364e93d6SGeorge Keishing    # ip       The IP address to be set using ipmitool-inband.
166364e93d6SGeorge Keishing    # netmask  The Netmask to be set using ipmitool-inband.
167364e93d6SGeorge Keishing    # gateway  The Gateway address to be set using ipmitool-inband.
168364e93d6SGeorge Keishing
169364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
170364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
171364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
172364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
173364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
174364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
175364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
176364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
177364e93d6SGeorge Keishing
178364e93d6SGeorge Keishing
179364e93d6SGeorge KeishingRestore Configuration
1808e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Restore the configuration to its pre-test state.
1818e25b8f0SAnvesh Kumar Rayankula
182364e93d6SGeorge Keishing    ${length}=  Get Length  ${initial_lan_config}
183364e93d6SGeorge Keishing    Return From Keyword If  ${length} == ${0}
184364e93d6SGeorge Keishing
1858e25b8f0SAnvesh Kumar Rayankula    Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
186364e93d6SGeorge Keishing    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
187364e93d6SGeorge Keishing
188364e93d6SGeorge Keishing
189364e93d6SGeorge KeishingSuite Setup Execution
190364e93d6SGeorge Keishing    [Documentation]  Suite Setup Execution.
191364e93d6SGeorge Keishing
192364e93d6SGeorge Keishing    Redfish.Login
1931ee53321SAnves Kumar rayankula
1941ee53321SAnves Kumar rayankula    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
1951ee53321SAnves Kumar rayankula    Set Suite Variable  ${initial_lan_config}
1961ee53321SAnves Kumar rayankula
197364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
198364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
199364e93d6SGeorge Keishing
2008e25b8f0SAnvesh Kumar Rayankula    ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
2018e25b8f0SAnvesh Kumar Rayankula    Set Suite Variable  ${ip_address}
2028e25b8f0SAnvesh Kumar Rayankula
203364e93d6SGeorge Keishing    @{network_configurations}=  Get Network Configuration
2048e25b8f0SAnvesh Kumar Rayankula    FOR  ${network_configuration}  IN  @{network_configurations}
2058e25b8f0SAnvesh Kumar Rayankula       Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
2068e25b8f0SAnvesh Kumar Rayankula       ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
2078e25b8f0SAnvesh Kumar Rayankula       ...  Exit For Loop
2088e25b8f0SAnvesh Kumar Rayankula    END
209e354c1c0SAnvesh Kumar Rayankula
210e354c1c0SAnvesh Kumar RayankulaTest Teardown Execution
211e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Test Teardown Execution.
212e354c1c0SAnvesh Kumar Rayankula
213e354c1c0SAnvesh Kumar Rayankula   FFDC On Test Case Fail
214e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI  off
215e354c1c0SAnvesh Kumar Rayankula   Restore Configuration
216