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
1264a7bb01SishwaryamathimVariables              ../data/ipmi_raw_cmd_table.py
13364e93d6SGeorge Keishing
14364e93d6SGeorge KeishingSuite Setup            Suite Setup Execution
15e354c1c0SAnvesh Kumar RayankulaSuite Teardown         Redfish.Logout
16364e93d6SGeorge KeishingTest Setup             Printn
17e354c1c0SAnvesh Kumar RayankulaTest Teardown          Test Teardown Execution
18364e93d6SGeorge Keishing
19*6fb70d98SMatt FischerTest Tags             IPMI_Network_Configuration
20364e93d6SGeorge Keishing
21364e93d6SGeorge Keishing*** Variables ***
2287dc442cSGeorge Keishing
23e354c1c0SAnvesh Kumar Rayankula${vlan_id_for_ipmi}     ${10}
24364e93d6SGeorge Keishing@{vlan_ids}             ${20}  ${30}
25364e93d6SGeorge Keishing${interface}            eth0
26364e93d6SGeorge Keishing${initial_lan_config}   &{EMPTY}
27364e93d6SGeorge Keishing${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
2864a7bb01Sishwaryamathim${subnet_mask}          ${24}
2964a7bb01Sishwaryamathim${gateway_ip}           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
3864a7bb01Sishwaryamathim    [Teardown]  Run Keywords  Restore Configuration  AND  set_base_url    https://${OPENBMC_HOST}:${HTTPS_PORT}
3964a7bb01Sishwaryamathim    ...  AND  FFDC On Test Case Fail  AND
4064a7bb01Sishwaryamathim    ...  Redfish.Login  AND  Run IPMI Command  ${IPMI_RAW_CMD['Device ID']['Get'][0]}
41364e93d6SGeorge Keishing
42364e93d6SGeorge Keishing    Redfish Power On
43364e93d6SGeorge Keishing
44374a5380STony Lee    Set IPMI Inband Network Configuration  ${STATIC_IP}  ${NETMASK}  ${GATEWAY}
45364e93d6SGeorge Keishing    Sleep  10
46364e93d6SGeorge Keishing
47364e93d6SGeorge Keishing    ${lan_print_output}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
48374a5380STony Lee    Valid Value  lan_print_output['IP Address']  ["${STATIC_IP}"]
49374a5380STony Lee    Valid Value  lan_print_output['Subnet Mask']  ["${NETMASK}"]
50374a5380STony Lee    Valid Value  lan_print_output['Default Gateway IP']  ["${GATEWAY}"]
51364e93d6SGeorge Keishing
5264a7bb01Sishwaryamathim    # To verify changed static ip is communicable through external IPMI cmd.
5364a7bb01Sishwaryamathim    Run External IPMI Raw Command  ${IPMI_RAW_CMD['Device ID']['Get'][0]}  H=${STATIC_IP}
5464a7bb01Sishwaryamathim
5564a7bb01Sishwaryamathim    set_base_url    https://${STATIC_IP}:${HTTPS_PORT}
5664a7bb01Sishwaryamathim    Redfish.Login
5764a7bb01Sishwaryamathim
5864a7bb01Sishwaryamathim
5964a7bb01Sishwaryamathim    ${ipv4_addresses}=  Redfish.Get Attribute
6064a7bb01Sishwaryamathim    ...  ${REDFISH_NW_ETH_IFACE}${interface}  IPv4Addresses
6164a7bb01Sishwaryamathim
6264a7bb01Sishwaryamathim    FOR  ${ipv4_address}  IN  @{ipv4_addresses}
6364a7bb01Sishwaryamathim        ${ip_address}=  Set Variable if  '${ipv4_address['Address']}' == '${STATIC_IP}'
6464a7bb01Sishwaryamathim                        ...  ${ipv4_address}
6564a7bb01Sishwaryamathim        Exit For Loop If  ${ip_address} != None
6664a7bb01Sishwaryamathim    END
6764a7bb01Sishwaryamathim
6864a7bb01Sishwaryamathim    Should Be Equal  ${ip_address['AddressOrigin']}  Static
6964a7bb01Sishwaryamathim    Should Be Equal  ${ip_address['SubnetMask']}  ${NETMASK}
7064a7bb01Sishwaryamathim    Should Be Equal  ${ip_address['Gateway']}  ${GATEWAY}
7164a7bb01Sishwaryamathim
7264a7bb01Sishwaryamathim    Redfish.Logout
7364a7bb01Sishwaryamathim
74364e93d6SGeorge Keishing
75364e93d6SGeorge KeishingDisable VLAN Via IPMI When Multiple VLAN Exist On BMC
76364e93d6SGeorge Keishing    [Documentation]  Disable  VLAN Via IPMI When Multiple VLAN Exist On BMC.
77b98036a9SGeorge Keishing    [Tags]   Disable_VLAN_Via_IPMI_When_Multiple_VLAN_Exist_On_BMC
78364e93d6SGeorge Keishing
791ee53321SAnves Kumar rayankula    FOR  ${vlan_id}  IN  @{vlan_ids}
801ee53321SAnves Kumar rayankula      Create VLAN  ${vlan_id}
81364e93d6SGeorge Keishing    END
82364e93d6SGeorge Keishing
83364e93d6SGeorge Keishing    Create VLAN Via IPMI  off
84364e93d6SGeorge Keishing
85364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
86364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
87364e93d6SGeorge Keishing
88364e93d6SGeorge Keishing
89364e93d6SGeorge KeishingConfigure IP On VLAN Via IPMI
90364e93d6SGeorge Keishing    [Documentation]   Configure IP On VLAN Via IPMI.
91364e93d6SGeorge Keishing    [Tags]  Configure_IP_On_VLAN_Via_IPMI
92364e93d6SGeorge Keishing
93e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
94364e93d6SGeorge Keishing
95364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
9664a7bb01Sishwaryamathim    ...  lan set ${CHANNEL_NUMBER} ipaddr ${STATIC_IP}  login_host=${0}
97364e93d6SGeorge Keishing
98364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
99e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
10064a7bb01Sishwaryamathim    Valid Value  lan_config['IP Address']  ["${STATIC_IP}"]
101364e93d6SGeorge Keishing
102364e93d6SGeorge Keishing
103364e93d6SGeorge KeishingCreate VLAN Via IPMI When LAN And VLAN Exist On BMC
104364e93d6SGeorge Keishing    [Documentation]  Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
105364e93d6SGeorge Keishing    [Tags]   Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
106e354c1c0SAnvesh Kumar Rayankula    [Setup]  Create VLAN  ${vlan_id_for_rest}
107364e93d6SGeorge Keishing
108e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
109364e93d6SGeorge Keishing
110364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
111e354c1c0SAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
112364e93d6SGeorge Keishing
113364e93d6SGeorge Keishing
114e354c1c0SAnvesh Kumar RayankulaCreate VLAN Via IPMI And Verify
11574ed739fSAnvesh Kumar Rayankula    [Documentation]  Create and verify VLAN via IPMI.
11674ed739fSAnvesh Kumar Rayankula    [Tags]  Create_VLAN_Via_IPMI_And_Verify
11774ed739fSAnvesh Kumar Rayankula
118e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
11974ed739fSAnvesh Kumar Rayankula
12074ed739fSAnvesh 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}']
1228e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['IP Address']  ['${ip_address}']
1238e25b8f0SAnvesh Kumar Rayankula    Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
12474ed739fSAnvesh Kumar Rayankula
125e354c1c0SAnvesh Kumar RayankulaTest Disabling Of VLAN Via IPMI
12674ed739fSAnvesh Kumar Rayankula    [Documentation]  Disable VLAN and verify via IPMI.
127e354c1c0SAnvesh Kumar Rayankula    [Tags]  Test_Disabling_Of_VLAN_Via_IPMI
12874ed739fSAnvesh Kumar Rayankula
129e354c1c0SAnvesh Kumar Rayankula    Create VLAN Via IPMI  ${vlan_id_for_ipmi}
13074ed739fSAnvesh Kumar Rayankula    Create VLAN Via IPMI  off
13174ed739fSAnvesh Kumar Rayankula
132e354c1c0SAnvesh Kumar Rayankula    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
13374ed739fSAnvesh Kumar Rayankula    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
13474ed739fSAnvesh Kumar Rayankula
13574ed739fSAnvesh Kumar Rayankula
136e354c1c0SAnvesh Kumar RayankulaCreate VLAN When LAN And VLAN Exist With IP Address Configured
137e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Create VLAN when LAN and VLAN exist with IP address configured.
138e354c1c0SAnvesh Kumar Rayankula   [Tags]  Create_VLAN_When_LAN_And_VLAN_Exist_With_IP_Address_Configured
139c658f1dbSBrian Ma   [Setup]  Run Keywords  Create VLAN  ${vlan_id_for_rest}  interface=${interface}
14064a7bb01Sishwaryamathim   ...  AND  Configure Network Settings On VLAN  ${vlan_id_for_rest}  ${STATIC_IP}
141c658f1dbSBrian Ma   ...  ${netmask}  ${gateway}  interface=${interface}
142e354c1c0SAnvesh Kumar Rayankula
143e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI   ${vlan_id_for_ipmi}
144e354c1c0SAnvesh Kumar Rayankula
145e354c1c0SAnvesh Kumar Rayankula   ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
146e354c1c0SAnvesh Kumar Rayankula   Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
14764a7bb01Sishwaryamathim   Valid Value  lan_config['IP Address']  ['${STATIC_IP}']
148e354c1c0SAnvesh Kumar Rayankula
1498e25b8f0SAnvesh Kumar Rayankula
1508e25b8f0SAnvesh Kumar RayankulaCreate Multiple VLANs Via IPMI And Verify
1518e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Create multiple VLANs through IPMI.
1528e25b8f0SAnvesh Kumar Rayankula    [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
1538e25b8f0SAnvesh Kumar Rayankula
1548e25b8f0SAnvesh Kumar Rayankula    FOR  ${vlan_id}  IN  @{vlan_ids}
1558e25b8f0SAnvesh Kumar Rayankula
1568e25b8f0SAnvesh Kumar Rayankula      Create VLAN Via IPMI  ${vlan_id}
1578e25b8f0SAnvesh Kumar Rayankula
1588e25b8f0SAnvesh Kumar Rayankula      ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
1598e25b8f0SAnvesh Kumar Rayankula
1608e25b8f0SAnvesh Kumar Rayankula      # Validate VLAN creation.
1618e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
1628e25b8f0SAnvesh Kumar Rayankula
1638e25b8f0SAnvesh Kumar Rayankula      # Validate existing IP address.
1648e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['IP Address']  ['${ip_address}']
1658e25b8f0SAnvesh Kumar Rayankula
1668e25b8f0SAnvesh Kumar Rayankula      # Validate existing subnet mask.
1678e25b8f0SAnvesh Kumar Rayankula      Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
1688e25b8f0SAnvesh Kumar Rayankula    END
1698e25b8f0SAnvesh Kumar Rayankula
1708e25b8f0SAnvesh Kumar Rayankula
171364e93d6SGeorge Keishing*** Keywords ***
172364e93d6SGeorge Keishing
173364e93d6SGeorge KeishingCreate VLAN Via IPMI
174364e93d6SGeorge Keishing    [Documentation]  Create VLAN via inband IPMI command.
175364e93d6SGeorge Keishing    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
176364e93d6SGeorge Keishing
177364e93d6SGeorge Keishing    # Description of argument(s):
178364e93d6SGeorge Keishing    # vlan_id  The VLAN ID (e.g. '10').
179364e93d6SGeorge Keishing
180364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
181364e93d6SGeorge Keishing    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
182364e93d6SGeorge Keishing
183364e93d6SGeorge Keishing
184364e93d6SGeorge KeishingSet IPMI Inband Network Configuration
185364e93d6SGeorge Keishing    [Documentation]  Run sequence of standard IPMI command in-band and set
186364e93d6SGeorge Keishing    ...              the IP configuration.
187364e93d6SGeorge Keishing    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
188364e93d6SGeorge Keishing
189364e93d6SGeorge Keishing    # Description of argument(s):
190364e93d6SGeorge Keishing    # ip       The IP address to be set using ipmitool-inband.
191364e93d6SGeorge Keishing    # netmask  The Netmask to be set using ipmitool-inband.
192364e93d6SGeorge Keishing    # gateway  The Gateway address to be set using ipmitool-inband.
193364e93d6SGeorge Keishing
194364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
195364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
196364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
197364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
198364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
199364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
200364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
201364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
202364e93d6SGeorge Keishing
203364e93d6SGeorge Keishing
204364e93d6SGeorge KeishingRestore Configuration
2058e25b8f0SAnvesh Kumar Rayankula    [Documentation]  Restore the configuration to its pre-test state.
2068e25b8f0SAnvesh Kumar Rayankula
207364e93d6SGeorge Keishing    ${length}=  Get Length  ${initial_lan_config}
208364e93d6SGeorge Keishing    Return From Keyword If  ${length} == ${0}
209364e93d6SGeorge Keishing
2108e25b8f0SAnvesh Kumar Rayankula    Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
211364e93d6SGeorge Keishing    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
212364e93d6SGeorge Keishing
213364e93d6SGeorge Keishing
214364e93d6SGeorge KeishingSuite Setup Execution
215364e93d6SGeorge Keishing    [Documentation]  Suite Setup Execution.
216364e93d6SGeorge Keishing
217364e93d6SGeorge Keishing    Redfish.Login
2181ee53321SAnves Kumar rayankula
2191ee53321SAnves Kumar rayankula    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
2201ee53321SAnves Kumar rayankula    Set Suite Variable  ${initial_lan_config}
2211ee53321SAnves Kumar rayankula
222364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
223364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
224364e93d6SGeorge Keishing
2258e25b8f0SAnvesh Kumar Rayankula    ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
2268e25b8f0SAnvesh Kumar Rayankula    Set Suite Variable  ${ip_address}
2278e25b8f0SAnvesh Kumar Rayankula
228364e93d6SGeorge Keishing    @{network_configurations}=  Get Network Configuration
2298e25b8f0SAnvesh Kumar Rayankula    FOR  ${network_configuration}  IN  @{network_configurations}
2308e25b8f0SAnvesh Kumar Rayankula       Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
2318e25b8f0SAnvesh Kumar Rayankula       ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
2328e25b8f0SAnvesh Kumar Rayankula       ...  Exit For Loop
2338e25b8f0SAnvesh Kumar Rayankula    END
234e354c1c0SAnvesh Kumar Rayankula
235e354c1c0SAnvesh Kumar RayankulaTest Teardown Execution
236e354c1c0SAnvesh Kumar Rayankula   [Documentation]  Test Teardown Execution.
237e354c1c0SAnvesh Kumar Rayankula
238e354c1c0SAnvesh Kumar Rayankula   FFDC On Test Case Fail
239e354c1c0SAnvesh Kumar Rayankula   Create VLAN Via IPMI  off
240e354c1c0SAnvesh Kumar Rayankula   Restore Configuration
241