1*364e93d6SGeorge Keishing*** Settings ***
2*364e93d6SGeorge Keishing
3*364e93d6SGeorge KeishingDocumentation          Module to test IPMI network functionality.
4*364e93d6SGeorge KeishingResource               ../lib/ipmi_client.robot
5*364e93d6SGeorge KeishingResource               ../lib/openbmc_ffdc.robot
6*364e93d6SGeorge KeishingResource               ../lib/bmc_network_utils.robot
7*364e93d6SGeorge KeishingLibrary                ../lib/ipmi_utils.py
8*364e93d6SGeorge KeishingLibrary                ../lib/gen_robot_valid.py
9*364e93d6SGeorge KeishingLibrary                ../lib/var_funcs.py
10*364e93d6SGeorge KeishingLibrary                ../lib/bmc_network_utils.py
11*364e93d6SGeorge Keishing
12*364e93d6SGeorge KeishingSuite Setup            Suite Setup Execution
13*364e93d6SGeorge KeishingTest Setup             Printn
14*364e93d6SGeorge KeishingTest Teardown          FFDC On Test Case Fail
15*364e93d6SGeorge Keishing
16*364e93d6SGeorge KeishingForce Tags             IPMI_Network_Config
17*364e93d6SGeorge Keishing
18*364e93d6SGeorge Keishing
19*364e93d6SGeorge Keishing*** Variables ***
20*364e93d6SGeorge Keishing${vlan_id}              ${10}
21*364e93d6SGeorge Keishing@{vlan_ids}             ${20}  ${30}
22*364e93d6SGeorge Keishing${interface}            eth0
23*364e93d6SGeorge Keishing${ip}                   10.0.0.1
24*364e93d6SGeorge Keishing${initial_lan_config}   &{EMPTY}
25*364e93d6SGeorge Keishing${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
26*364e93d6SGeorge Keishing
27*364e93d6SGeorge Keishing*** Test Cases ***
28*364e93d6SGeorge Keishing
29*364e93d6SGeorge KeishingVerify IPMI Inband Network Configuration
30*364e93d6SGeorge Keishing    [Documentation]  Verify BMC network configuration via inband IPMI.
31*364e93d6SGeorge Keishing    [Tags]  Verify_IPMI_Inband_Network_Configuration
32*364e93d6SGeorge Keishing    [Teardown]  Run Keywords  Restore Configuration  AND  FFDC On Test Case Fail
33*364e93d6SGeorge Keishing
34*364e93d6SGeorge Keishing    Redfish Power On
35*364e93d6SGeorge Keishing
36*364e93d6SGeorge Keishing    Set IPMI Inband Network Configuration  10.10.10.10  255.255.255.0  10.10.10.10
37*364e93d6SGeorge Keishing    Sleep  10
38*364e93d6SGeorge Keishing
39*364e93d6SGeorge Keishing    ${lan_print_output}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
40*364e93d6SGeorge Keishing    Valid Value  lan_print_output['IP Address']  ["10.10.10.10"]
41*364e93d6SGeorge Keishing    Valid Value  lan_print_output['Subnet Mask']  ["255.255.255.0"]
42*364e93d6SGeorge Keishing    Valid Value  lan_print_output['Default Gateway IP']  ["10.10.10.10"]
43*364e93d6SGeorge Keishing
44*364e93d6SGeorge Keishing
45*364e93d6SGeorge KeishingDisable VLAN Via IPMI When Multiple VLAN Exist On BMC
46*364e93d6SGeorge Keishing    [Documentation]  Disable  VLAN Via IPMI When Multiple VLAN Exist On BMC.
47*364e93d6SGeorge Keishing    [Tags]   Disable_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
48*364e93d6SGeorge Keishing    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
49*364e93d6SGeorge Keishing    ...  Create VLAN Via IPMI  off  AND  Restore Configuration
50*364e93d6SGeorge Keishing
51*364e93d6SGeorge Keishing    FOR  ${id}  IN  @{vlan_ids}
52*364e93d6SGeorge Keishing      @{data_vlan_id}=  Create List  ${interface}  ${id}
53*364e93d6SGeorge Keishing      ${data}=  Create Dictionary   data=@{data_vlan_id}
54*364e93d6SGeorge Keishing      ${resp}=  OpenBMC Post Request  ${vlan_resource}  data=${data}
55*364e93d6SGeorge Keishing    END
56*364e93d6SGeorge Keishing
57*364e93d6SGeorge Keishing    Create VLAN Via IPMI  off
58*364e93d6SGeorge Keishing
59*364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
60*364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
61*364e93d6SGeorge Keishing
62*364e93d6SGeorge Keishing
63*364e93d6SGeorge KeishingConfigure IP On VLAN Via IPMI
64*364e93d6SGeorge Keishing    [Documentation]   Configure IP On VLAN Via IPMI.
65*364e93d6SGeorge Keishing    [Tags]  Configure_IP_On_VLAN_Via_IPMI
66*364e93d6SGeorge Keishing    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
67*364e93d6SGeorge Keishing    ...  Create VLAN Via IPMI  off  AND  Restore Configuration
68*364e93d6SGeorge Keishing
69*364e93d6SGeorge Keishing    Create VLAN Via IPMI  ${vlan_id}
70*364e93d6SGeorge Keishing
71*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
72*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
73*364e93d6SGeorge Keishing
74*364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
75*364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
76*364e93d6SGeorge Keishing    Valid Value  lan_config['IP Address']  ["${ip}"]
77*364e93d6SGeorge Keishing
78*364e93d6SGeorge Keishing
79*364e93d6SGeorge KeishingCreate VLAN Via IPMI When LAN And VLAN Exist On BMC
80*364e93d6SGeorge Keishing    [Documentation]  Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
81*364e93d6SGeorge Keishing    [Tags]   Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
82*364e93d6SGeorge Keishing    [Teardown]  Run Keywords  FFDC On Test Case Fail  AND
83*364e93d6SGeorge Keishing    ...  Create VLAN Via IPMI  off  AND  Restore Configuration
84*364e93d6SGeorge Keishing
85*364e93d6SGeorge Keishing    @{data_vlan_id}=  Create List  ${interface}  ${vlan_id}
86*364e93d6SGeorge Keishing    ${data}=  Create Dictionary   data=@{data_vlan_id}
87*364e93d6SGeorge Keishing    ${resp}=  OpenBMC Post Request  ${vlan_resource}  data=${data}
88*364e93d6SGeorge Keishing
89*364e93d6SGeorge Keishing    Create VLAN Via IPMI  ${vlan_id}
90*364e93d6SGeorge Keishing
91*364e93d6SGeorge Keishing    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
92*364e93d6SGeorge Keishing    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
93*364e93d6SGeorge Keishing
94*364e93d6SGeorge Keishing
95*364e93d6SGeorge Keishing*** Keywords ***
96*364e93d6SGeorge Keishing
97*364e93d6SGeorge KeishingCreate VLAN Via IPMI
98*364e93d6SGeorge Keishing    [Documentation]  Create VLAN via inband IPMI command.
99*364e93d6SGeorge Keishing    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
100*364e93d6SGeorge Keishing
101*364e93d6SGeorge Keishing    # Description of argument(s):
102*364e93d6SGeorge Keishing    # vlan_id  The VLAN ID (e.g. '10').
103*364e93d6SGeorge Keishing
104*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
105*364e93d6SGeorge Keishing    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
106*364e93d6SGeorge Keishing
107*364e93d6SGeorge Keishing
108*364e93d6SGeorge KeishingSet IPMI Inband Network Configuration
109*364e93d6SGeorge Keishing    [Documentation]  Run sequence of standard IPMI command in-band and set
110*364e93d6SGeorge Keishing    ...              the IP configuration.
111*364e93d6SGeorge Keishing    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
112*364e93d6SGeorge Keishing
113*364e93d6SGeorge Keishing    # Description of argument(s):
114*364e93d6SGeorge Keishing    # ip       The IP address to be set using ipmitool-inband.
115*364e93d6SGeorge Keishing    # netmask  The Netmask to be set using ipmitool-inband.
116*364e93d6SGeorge Keishing    # gateway  The Gateway address to be set using ipmitool-inband.
117*364e93d6SGeorge Keishing
118*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
119*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
120*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
121*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
122*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
123*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
124*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
125*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
126*364e93d6SGeorge Keishing
127*364e93d6SGeorge Keishing
128*364e93d6SGeorge KeishingRestore Configuration
129*364e93d6SGeorge Keishing    [Documentation]  Restore the configuration to its pre-test state
130*364e93d6SGeorge Keishing    ${length}=  Get Length  ${initial_lan_config}
131*364e93d6SGeorge Keishing    Return From Keyword If  ${length} == ${0}
132*364e93d6SGeorge Keishing
133*364e93d6SGeorge Keishing    Set IPMI Inband Network Configuration  ${network_configurations[0]['Address']}
134*364e93d6SGeorge Keishing    ...  ${network_configurations[0]['SubnetMask']}
135*364e93d6SGeorge Keishing    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
136*364e93d6SGeorge Keishing
137*364e93d6SGeorge Keishing
138*364e93d6SGeorge KeishingSuite Setup Execution
139*364e93d6SGeorge Keishing    [Documentation]  Suite Setup Execution.
140*364e93d6SGeorge Keishing
141*364e93d6SGeorge Keishing    Redfish.Login
142*364e93d6SGeorge Keishing
143*364e93d6SGeorge Keishing    Run Inband IPMI Standard Command
144*364e93d6SGeorge Keishing    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
145*364e93d6SGeorge Keishing
146*364e93d6SGeorge Keishing    @{network_configurations}=  Get Network Configuration
147*364e93d6SGeorge Keishing    Set Suite Variable  @{network_configurations}
148*364e93d6SGeorge Keishing
149*364e93d6SGeorge Keishing    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
150*364e93d6SGeorge Keishing    Set Suite Variable  ${initial_lan_config}
151