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
7Resource               ../lib/boot_utils.robot
8Library                ../lib/ipmi_utils.py
9Library                ../lib/gen_robot_valid.py
10Library                ../lib/var_funcs.py
11Library                ../lib/bmc_network_utils.py
12
13Suite Setup            Suite Setup Execution
14Suite Teardown         Redfish.Logout
15Test Setup             Printn
16Test Teardown          Test Teardown Execution
17
18Force Tags             Ipmi_Network_Configuration
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
35Verify 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
51Disable 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
65Configure 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
79Create 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
90Create 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
101Test 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
112Create 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}  interface=${interface}
116   ...  AND  Configure Network Settings On VLAN  ${vlan_id_for_rest}  ${ip}
117   ...  ${netmask}  ${gateway}  interface=${interface}
118
119   Create VLAN Via IPMI   ${vlan_id_for_ipmi}
120
121   ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
122   Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
123   Valid Value  lan_config['IP Address']  ['${ip}']
124
125
126Create Multiple VLANs Via IPMI And Verify
127    [Documentation]  Create multiple VLANs through IPMI.
128    [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
129
130    FOR  ${vlan_id}  IN  @{vlan_ids}
131
132      Create VLAN Via IPMI  ${vlan_id}
133
134      ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
135
136      # Validate VLAN creation.
137      Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
138
139      # Validate existing IP address.
140      Valid Value  lan_config['IP Address']  ['${ip_address}']
141
142      # Validate existing subnet mask.
143      Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
144    END
145
146
147*** Keywords ***
148
149Create VLAN Via IPMI
150    [Documentation]  Create VLAN via inband IPMI command.
151    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
152
153    # Description of argument(s):
154    # vlan_id  The VLAN ID (e.g. '10').
155
156    Run Inband IPMI Standard Command
157    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
158
159
160Set IPMI Inband Network Configuration
161    [Documentation]  Run sequence of standard IPMI command in-band and set
162    ...              the IP configuration.
163    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
164
165    # Description of argument(s):
166    # ip       The IP address to be set using ipmitool-inband.
167    # netmask  The Netmask to be set using ipmitool-inband.
168    # gateway  The Gateway address to be set using ipmitool-inband.
169
170    Run Inband IPMI Standard Command
171    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
172    Run Inband IPMI Standard Command
173    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
174    Run Inband IPMI Standard Command
175    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
176    Run Inband IPMI Standard Command
177    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
178
179
180Restore Configuration
181    [Documentation]  Restore the configuration to its pre-test state.
182
183    ${length}=  Get Length  ${initial_lan_config}
184    Return From Keyword If  ${length} == ${0}
185
186    Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
187    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
188
189
190Suite Setup Execution
191    [Documentation]  Suite Setup Execution.
192
193    Redfish.Login
194
195    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
196    Set Suite Variable  ${initial_lan_config}
197
198    Run Inband IPMI Standard Command
199    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
200
201    ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
202    Set Suite Variable  ${ip_address}
203
204    @{network_configurations}=  Get Network Configuration
205    FOR  ${network_configuration}  IN  @{network_configurations}
206       Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
207       ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
208       ...  Exit For Loop
209    END
210
211Test Teardown Execution
212   [Documentation]  Test Teardown Execution.
213
214   FFDC On Test Case Fail
215   Create VLAN Via IPMI  off
216   Restore Configuration
217