xref: /openbmc/openbmc-test-automation/ipmi/test_ipmi_network_configuration.robot (revision 2104d5f9bca1ab3b460f5255f6093d7b25a13c1a)
1 *** Settings ***
2 
3 Documentation          Module to test IPMI network functionality.
4 Resource               ../lib/ipmi_client.robot
5 Resource               ../lib/openbmc_ffdc.robot
6 Resource               ../lib/bmc_network_utils.robot
7 Resource               ../lib/boot_utils.robot
8 Library                ../lib/ipmi_utils.py
9 Library                ../lib/gen_robot_valid.py
10 Library                ../lib/var_funcs.py
11 Library                ../lib/bmc_network_utils.py
12 
13 Suite Setup            Suite Setup Execution
14 Suite Teardown         Redfish.Logout
15 Test Setup             Printn
16 Test Teardown          Test Teardown Execution
17 
18 Force Tags             IPMI_Network_Config
19 
20 
21 *** Variables ***
22 ${vlan_id_for_ipmi}     ${10}
23 @{vlan_ids}             ${20}  ${30}
24 ${interface}            eth0
25 ${ip}                   10.0.0.1
26 ${initial_lan_config}   &{EMPTY}
27 ${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
28 ${netmask}              ${24}
29 ${gateway}              0.0.0.0
30 ${vlan_id_for_rest}     ${30}
31 
32 
33 *** Test Cases ***
34 
35 Verify IPMI Inband Network Configuration
36     [Documentation]  Verify BMC network configuration via inband IPMI.
37     [Tags]  Verify_IPMI_Inband_Network_Configuration
38     [Teardown]  Run Keywords  Restore Configuration  AND  FFDC On Test Case Fail
39 
40     Redfish Power On
41 
42     Set IPMI Inband Network Configuration  ${STATIC_IP}  ${NETMASK}  ${GATEWAY}
43     Sleep  10
44 
45     ${lan_print_output}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
46     Valid Value  lan_print_output['IP Address']  ["${STATIC_IP}"]
47     Valid Value  lan_print_output['Subnet Mask']  ["${NETMASK}"]
48     Valid Value  lan_print_output['Default Gateway IP']  ["${GATEWAY}"]
49 
50 
51 Disable VLAN Via IPMI When Multiple VLAN Exist On BMC
52     [Documentation]  Disable  VLAN Via IPMI When Multiple VLAN Exist On BMC.
53     [Tags]   Disable_VLAN_Via_IPMI_When_Multiple_VLAN_Exist_On_BMC
54 
55     FOR  ${vlan_id}  IN  @{vlan_ids}
56       Create VLAN  ${vlan_id}
57     END
58 
59     Create VLAN Via IPMI  off
60 
61     ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
62     Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
63 
64 
65 Configure IP On VLAN Via IPMI
66     [Documentation]   Configure IP On VLAN Via IPMI.
67     [Tags]  Configure_IP_On_VLAN_Via_IPMI
68 
69     Create VLAN Via IPMI  ${vlan_id_for_ipmi}
70 
71     Run Inband IPMI Standard Command
72     ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
73 
74     ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
75     Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
76     Valid Value  lan_config['IP Address']  ["${ip}"]
77 
78 
79 Create VLAN Via IPMI When LAN And VLAN Exist On BMC
80     [Documentation]  Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
81     [Tags]   Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
82     [Setup]  Create VLAN  ${vlan_id_for_rest}
83 
84     Create VLAN Via IPMI  ${vlan_id_for_ipmi}
85 
86     ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
87     Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
88 
89 
90 Create VLAN Via IPMI And Verify
91     [Documentation]  Create and verify VLAN via IPMI.
92     [Tags]  Create_VLAN_Via_IPMI_And_Verify
93 
94     Create VLAN Via IPMI  ${vlan_id_for_ipmi}
95 
96     ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
97     Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
98     Valid Value  lan_config['IP Address']  ['${ip_address}']
99     Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
100 
101 Test Disabling Of VLAN Via IPMI
102     [Documentation]  Disable VLAN and verify via IPMI.
103     [Tags]  Test_Disabling_Of_VLAN_Via_IPMI
104 
105     Create VLAN Via IPMI  ${vlan_id_for_ipmi}
106     Create VLAN Via IPMI  off
107 
108     ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
109     Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
110 
111 
112 Create VLAN When LAN And VLAN Exist With IP Address Configured
113    [Documentation]  Create VLAN when LAN and VLAN exist with IP address configured.
114    [Tags]  Create_VLAN_When_LAN_And_VLAN_Exist_With_IP_Address_Configured
115    [Setup]  Run Keywords  Create VLAN  ${vlan_id_for_rest}  AND  Configure Network Settings On VLAN
116    ...  ${vlan_id_for_rest}  ${ip}  ${netmask}  ${gateway}
117 
118    Create VLAN Via IPMI   ${vlan_id_for_ipmi}
119 
120    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
121    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
122    Valid Value  lan_config['IP Address']  ['${ip}']
123 
124 
125 Create Multiple VLANs Via IPMI And Verify
126     [Documentation]  Create multiple VLANs through IPMI.
127     [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
128 
129     FOR  ${vlan_id}  IN  @{vlan_ids}
130 
131       Create VLAN Via IPMI  ${vlan_id}
132 
133       ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
134 
135       # Validate VLAN creation.
136       Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
137 
138       # Validate existing IP address.
139       Valid Value  lan_config['IP Address']  ['${ip_address}']
140 
141       # Validate existing subnet mask.
142       Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
143     END
144 
145 
146 *** Keywords ***
147 
148 Create VLAN Via IPMI
149     [Documentation]  Create VLAN via inband IPMI command.
150     [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
151 
152     # Description of argument(s):
153     # vlan_id  The VLAN ID (e.g. '10').
154 
155     Run Inband IPMI Standard Command
156     ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
157 
158 
159 Set IPMI Inband Network Configuration
160     [Documentation]  Run sequence of standard IPMI command in-band and set
161     ...              the IP configuration.
162     [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
163 
164     # Description of argument(s):
165     # ip       The IP address to be set using ipmitool-inband.
166     # netmask  The Netmask to be set using ipmitool-inband.
167     # gateway  The Gateway address to be set using ipmitool-inband.
168 
169     Run Inband IPMI Standard Command
170     ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
171     Run Inband IPMI Standard Command
172     ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
173     Run Inband IPMI Standard Command
174     ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
175     Run Inband IPMI Standard Command
176     ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
177 
178 
179 Restore Configuration
180     [Documentation]  Restore the configuration to its pre-test state.
181 
182     ${length}=  Get Length  ${initial_lan_config}
183     Return From Keyword If  ${length} == ${0}
184 
185     Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
186     ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
187 
188 
189 Suite Setup Execution
190     [Documentation]  Suite Setup Execution.
191 
192     Redfish.Login
193 
194     ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
195     Set Suite Variable  ${initial_lan_config}
196 
197     Run Inband IPMI Standard Command
198     ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
199 
200     ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
201     Set Suite Variable  ${ip_address}
202 
203     @{network_configurations}=  Get Network Configuration
204     FOR  ${network_configuration}  IN  @{network_configurations}
205        Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
206        ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
207        ...  Exit For Loop
208     END
209 
210 Test Teardown Execution
211    [Documentation]  Test Teardown Execution.
212 
213    FFDC On Test Case Fail
214    Create VLAN Via IPMI  off
215    Restore Configuration
216