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