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