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
7364e93d6SGeorge KeishingLibrary                ../lib/ipmi_utils.py
8364e93d6SGeorge KeishingLibrary                ../lib/gen_robot_valid.py
9364e93d6SGeorge KeishingLibrary                ../lib/var_funcs.py
10364e93d6SGeorge KeishingLibrary                ../lib/bmc_network_utils.py
11364e93d6SGeorge Keishing
12364e93d6SGeorge KeishingSuite Setup            Suite Setup Execution
13e354c1c0SAnvesh Kumar RayankulaSuite Teardown         Redfish.Logout
14364e93d6SGeorge KeishingTest Setup             Printn
15e354c1c0SAnvesh Kumar RayankulaTest Teardown          Test Teardown Execution
16364e93d6SGeorge Keishing
17364e93d6SGeorge KeishingForce Tags             IPMI_Network_Config
18364e93d6SGeorge Keishing
19364e93d6SGeorge Keishing
20364e93d6SGeorge Keishing*** Variables ***
21e354c1c0SAnvesh Kumar Rayankula${vlan_id_for_ipmi}     ${10}
22364e93d6SGeorge Keishing@{vlan_ids}             ${20}  ${30}
23364e93d6SGeorge Keishing${interface}            eth0
24364e93d6SGeorge Keishing${ip}                   10.0.0.1
25364e93d6SGeorge Keishing${initial_lan_config}   &{EMPTY}
26364e93d6SGeorge Keishing${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
27e354c1c0SAnvesh Kumar Rayankula${netmask}              ${24}
28e354c1c0SAnvesh Kumar Rayankula${gateway}              0.0.0.0
29e354c1c0SAnvesh Kumar Rayankula${vlan_id_for_rest}     ${30}
30e354c1c0SAnvesh Kumar Rayankula
31364e93d6SGeorge Keishing
32364e93d6SGeorge Keishing*** Test Cases ***
33364e93d6SGeorge Keishing
34364e93d6SGeorge KeishingVerify IPMI Inband Network Configuration
35364e93d6SGeorge Keishing    [Documentation]  Verify BMC network configuration via inband IPMI.
36364e93d6SGeorge Keishing    [Tags]  Verify_IPMI_Inband_Network_Configuration
37364e93d6SGeorge Keishing    [Teardown]  Run Keywords  Restore Configuration  AND  FFDC On Test Case Fail
38364e93d6SGeorge Keishing
39364e93d6SGeorge Keishing    Redfish Power On
40364e93d6SGeorge Keishing
41364e93d6SGeorge Keishing    Set IPMI Inband Network Configuration  10.10.10.10  255.255.255.0  10.10.10.10
42364e93d6SGeorge Keishing    Sleep  10
43364e93d6SGeorge Keishing
44364e93d6SGeorge Keishing    ${lan_print_output}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
45364e93d6SGeorge Keishing    Valid Value  lan_print_output['IP Address']  ["10.10.10.10"]
46364e93d6SGeorge Keishing    Valid Value  lan_print_output['Subnet Mask']  ["255.255.255.0"]
47364e93d6SGeorge Keishing    Valid Value  lan_print_output['Default Gateway IP']  ["10.10.10.10"]
48364e93d6SGeorge Keishing
49364e93d6SGeorge Keishing
50364e93d6SGeorge KeishingDisable VLAN Via IPMI When Multiple VLAN Exist On BMC
51364e93d6SGeorge Keishing    [Documentation]  Disable  VLAN Via IPMI When Multiple VLAN Exist On BMC.
52364e93d6SGeorge Keishing    [Tags]   Disable_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
53364e93d6SGeorge Keishing
54364e93d6SGeorge Keishing    FOR  ${id}  IN  @{vlan_ids}
55e354c1c0SAnvesh Kumar Rayankula      Create VLAN  ${vlan_id_for_rest}
56364e93d6SGeorge Keishing    END
57364e93d6SGeorge Keishing
58364e93d6SGeorge Keishing    Create VLAN Via IPMI  off
59364e93d6SGeorge Keishing
60364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
61364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
62364e93d6SGeorge Keishing
63364e93d6SGeorge Keishing
64364e93d6SGeorge KeishingConfigure IP On VLAN Via IPMI
65364e93d6SGeorge Keishing    [Documentation]   Configure IP On VLAN Via IPMI.
66364e93d6SGeorge Keishing    [Tags]  Configure_IP_On_VLAN_Via_IPMI
67364e93d6SGeorge Keishing
68e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
69364e93d6SGeorge Keishing
70364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
71364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
72364e93d6SGeorge Keishing
73364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
74e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
75364e93d6SGeorge Keishing    Valid Value  lan_config['IP Address']  ["${ip}"]
76364e93d6SGeorge Keishing
77364e93d6SGeorge Keishing
78364e93d6SGeorge KeishingCreate VLAN Via IPMI When LAN And VLAN Exist On BMC
79364e93d6SGeorge Keishing    [Documentation]  Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
80364e93d6SGeorge Keishing    [Tags]   Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
81e354c1c0SAnvesh Kumar Rayankula    [Setup]  Create VLAN  ${vlan_id_for_rest}
82364e93d6SGeorge Keishing
83e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
84364e93d6SGeorge Keishing
85364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
86e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
87364e93d6SGeorge Keishing
88364e93d6SGeorge Keishing
89e354c1c0SAnvesh Kumar RayankulaCreate VLAN Via IPMI And Verify
9074ed739fSAnvesh Kumar Rayankula    [Documentation]  Create and verify VLAN via IPMI.
9174ed739fSAnvesh Kumar Rayankula    [Tags]  Create_VLAN_Via_IPMI_And_Verify
9274ed739fSAnvesh Kumar Rayankula
93e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
9474ed739fSAnvesh Kumar Rayankula
9574ed739fSAnvesh Kumar Rayankula    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
96e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
97*8e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['IP Address']  ['${ip_address}']
98*8e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
9974ed739fSAnvesh Kumar Rayankula
100e354c1c0SAnvesh Kumar RayankulaTest Disabling Of VLAN Via IPMI
10174ed739fSAnvesh Kumar Rayankula    [Documentation]  Disable VLAN and verify via IPMI.
102e354c1c0SAnvesh Kumar Rayankula    [Tags]  Test_Disabling_Of_VLAN_Via_IPMI
10374ed739fSAnvesh Kumar Rayankula
104e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
10574ed739fSAnvesh Kumar Rayankula    Create VLAN Via IPMI  off
10674ed739fSAnvesh Kumar Rayankula
107e354c1c0SAnvesh Kumar Rayankula    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
10874ed739fSAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
10974ed739fSAnvesh Kumar Rayankula
11074ed739fSAnvesh Kumar Rayankula
111e354c1c0SAnvesh Kumar RayankulaCreate VLAN When LAN And VLAN Exist With IP Address Configured
112e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Create VLAN when LAN and VLAN exist with IP address configured.
113e354c1c0SAnvesh Kumar Rayankula   [Tags]  Create_VLAN_When_LAN_And_VLAN_Exist_With_IP_Address_Configured
114e354c1c0SAnvesh Kumar Rayankula   [Setup]  Run Keywords  Create VLAN  ${vlan_id_for_rest}  AND  Configure Network Settings On VLAN
115e354c1c0SAnvesh Kumar Rayankula   ...  ${vlan_id_for_rest}  ${ip}  ${netmask}  ${gateway}
116e354c1c0SAnvesh Kumar Rayankula
117e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI   ${vlan_id_for_ipmi}
118e354c1c0SAnvesh Kumar Rayankula
119e354c1c0SAnvesh Kumar Rayankula   ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
120e354c1c0SAnvesh Kumar Rayankula   Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
121e354c1c0SAnvesh Kumar Rayankula   Valid Value  lan_config['IP Address']  ['${ip}']
122e354c1c0SAnvesh Kumar Rayankula
123*8e25b8f0SAnvesh Kumar Rayankula
124*8e25b8f0SAnvesh Kumar RayankulaCreate Multiple VLANs Via IPMI And Verify
125*8e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Create multiple VLANs through IPMI.
126*8e25b8f0SAnvesh Kumar Rayankula    [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
127*8e25b8f0SAnvesh Kumar Rayankula
128*8e25b8f0SAnvesh Kumar Rayankula    FOR  ${vlan_id}  IN  @{vlan_ids}
129*8e25b8f0SAnvesh Kumar Rayankula
130*8e25b8f0SAnvesh Kumar Rayankula      Create VLAN Via IPMI  ${vlan_id}
131*8e25b8f0SAnvesh Kumar Rayankula
132*8e25b8f0SAnvesh Kumar Rayankula      ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
133*8e25b8f0SAnvesh Kumar Rayankula
134*8e25b8f0SAnvesh Kumar Rayankula      # Validate VLAN creation.
135*8e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
136*8e25b8f0SAnvesh Kumar Rayankula
137*8e25b8f0SAnvesh Kumar Rayankula      # Validate existing IP address.
138*8e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['IP Address']  ['${ip_address}']
139*8e25b8f0SAnvesh Kumar Rayankula
140*8e25b8f0SAnvesh Kumar Rayankula      # Validate existing subnet mask.
141*8e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
142*8e25b8f0SAnvesh Kumar Rayankula    END
143*8e25b8f0SAnvesh Kumar Rayankula
144*8e25b8f0SAnvesh Kumar Rayankula
145364e93d6SGeorge Keishing*** Keywords ***
146364e93d6SGeorge Keishing
147364e93d6SGeorge KeishingCreate VLAN Via IPMI
148364e93d6SGeorge Keishing    [Documentation]  Create VLAN via inband IPMI command.
149364e93d6SGeorge Keishing    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
150364e93d6SGeorge Keishing
151364e93d6SGeorge Keishing    # Description of argument(s):
152364e93d6SGeorge Keishing    # vlan_id  The VLAN ID (e.g. '10').
153364e93d6SGeorge Keishing
154364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
155364e93d6SGeorge Keishing    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
156364e93d6SGeorge Keishing
157364e93d6SGeorge Keishing
158364e93d6SGeorge KeishingSet IPMI Inband Network Configuration
159364e93d6SGeorge Keishing    [Documentation]  Run sequence of standard IPMI command in-band and set
160364e93d6SGeorge Keishing    ...              the IP configuration.
161364e93d6SGeorge Keishing    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
162364e93d6SGeorge Keishing
163364e93d6SGeorge Keishing    # Description of argument(s):
164364e93d6SGeorge Keishing    # ip       The IP address to be set using ipmitool-inband.
165364e93d6SGeorge Keishing    # netmask  The Netmask to be set using ipmitool-inband.
166364e93d6SGeorge Keishing    # gateway  The Gateway address to be set using ipmitool-inband.
167364e93d6SGeorge Keishing
168364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
169364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
170364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
171364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
172364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
173364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
174364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
175364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
176364e93d6SGeorge Keishing
177364e93d6SGeorge Keishing
178364e93d6SGeorge KeishingRestore Configuration
179*8e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Restore the configuration to its pre-test state.
180*8e25b8f0SAnvesh Kumar Rayankula
181364e93d6SGeorge Keishing    ${length}=  Get Length  ${initial_lan_config}
182364e93d6SGeorge Keishing    Return From Keyword If  ${length} == ${0}
183364e93d6SGeorge Keishing
184*8e25b8f0SAnvesh Kumar Rayankula    Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
185364e93d6SGeorge Keishing    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
186364e93d6SGeorge Keishing
187364e93d6SGeorge Keishing
188364e93d6SGeorge KeishingSuite Setup Execution
189364e93d6SGeorge Keishing    [Documentation]  Suite Setup Execution.
190364e93d6SGeorge Keishing
191364e93d6SGeorge Keishing    Redfish.Login
192364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
193364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
194364e93d6SGeorge Keishing
195*8e25b8f0SAnvesh Kumar Rayankula    ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
196*8e25b8f0SAnvesh Kumar Rayankula    Set Suite Variable  ${ip_address}
197*8e25b8f0SAnvesh Kumar Rayankula
198364e93d6SGeorge Keishing    @{network_configurations}=  Get Network Configuration
199*8e25b8f0SAnvesh Kumar Rayankula    FOR  ${network_configuration}  IN  @{network_configurations}
200*8e25b8f0SAnvesh Kumar Rayankula       Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
201*8e25b8f0SAnvesh Kumar Rayankula       ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
202*8e25b8f0SAnvesh Kumar Rayankula       ...  Exit For Loop
203*8e25b8f0SAnvesh Kumar Rayankula    END
204e354c1c0SAnvesh Kumar Rayankula
205e354c1c0SAnvesh Kumar RayankulaTest Teardown Execution
206e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Test Teardown Execution.
207e354c1c0SAnvesh Kumar Rayankula
208e354c1c0SAnvesh Kumar Rayankula   FFDC On Test Case Fail
209e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI  off
210e354c1c0SAnvesh Kumar Rayankula   Restore Configuration
211