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  ${id}  IN  @{vlan_ids}
55      Create VLAN  ${vlan_id_for_rest}
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']  ['${network_configurations[0]['Address']}']
98    Valid Value  lan_config['Subnet Mask']  ['${network_configurations[0]['SubnetMask']}']
99
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}  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*** Keywords ***
125
126Create VLAN Via IPMI
127    [Documentation]  Create VLAN via inband IPMI command.
128    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
129
130    # Description of argument(s):
131    # vlan_id  The VLAN ID (e.g. '10').
132
133    Run Inband IPMI Standard Command
134    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
135
136
137Set IPMI Inband Network Configuration
138    [Documentation]  Run sequence of standard IPMI command in-band and set
139    ...              the IP configuration.
140    [Arguments]  ${ip}  ${netmask}  ${gateway}  ${login}=${1}
141
142    # Description of argument(s):
143    # ip       The IP address to be set using ipmitool-inband.
144    # netmask  The Netmask to be set using ipmitool-inband.
145    # gateway  The Gateway address to be set using ipmitool-inband.
146
147    Run Inband IPMI Standard Command
148    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${login}
149    Run Inband IPMI Standard Command
150    ...  lan set ${CHANNEL_NUMBER} ipaddr ${ip}  login_host=${0}
151    Run Inband IPMI Standard Command
152    ...  lan set ${CHANNEL_NUMBER} netmask ${netmask}  login_host=${0}
153    Run Inband IPMI Standard Command
154    ...  lan set ${CHANNEL_NUMBER} defgw ipaddr ${gateway}  login_host=${0}
155
156
157Restore Configuration
158    [Documentation]  Restore the configuration to its pre-test state
159    ${length}=  Get Length  ${initial_lan_config}
160    Return From Keyword If  ${length} == ${0}
161
162    Set IPMI Inband Network Configuration  ${network_configurations[0]['Address']}
163    ...  ${network_configurations[0]['SubnetMask']}
164    ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
165
166
167Suite Setup Execution
168    [Documentation]  Suite Setup Execution.
169
170    Redfish.Login
171
172    Run Inband IPMI Standard Command
173    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
174
175    @{network_configurations}=  Get Network Configuration
176    Set Suite Variable  @{network_configurations}
177
178    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
179    Set Suite Variable  ${initial_lan_config}
180
181
182Test Teardown Execution
183   [Documentation]  Test Teardown Execution.
184
185   FFDC On Test Case Fail
186   Create VLAN Via IPMI  off
187   Restore Configuration
188
189