1*** Settings ***
2Documentation   Test BMC multiple network interface functionalities.
3
4# User input BMC IP for the eth1.
5# Use can input as  -v OPENBMC_HOST_1:xx.xxx.xx from command line.
6Library         ../../lib/bmc_redfish.py  https://${OPENBMC_HOST_1}:${HTTPS_PORT}
7...             ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  WITH NAME  Redfish1
8
9Resource        ../../lib/resource.robot
10Resource        ../../lib/common_utils.robot
11Resource        ../../lib/connection_client.robot
12Resource        ../../lib/bmc_network_utils.robot
13Resource        ../../lib/openbmc_ffdc.robot
14Resource        ../../lib/bmc_ldap_utils.robot
15Resource        ../../lib/snmp/resource.robot
16Resource        ../../lib/snmp/redfish_snmp_utils.robot
17Library         ../../lib/jobs_processing.py
18
19Suite Setup     Suite Setup Execution
20Test Teardown   FFDC On Test Case Fail
21Suite Teardown  Run Keywords  Redfish1.Logout  AND  Redfish.Logout
22
23*** Test Cases ***
24
25Verify Both Interfaces BMC IP Addresses Accessible Via SSH
26    [Documentation]  Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH.
27    [Tags]  Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH
28
29    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST}
30    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST_1}
31    Close All Connections
32
33
34Verify Redfish Works On Both Interfaces
35    [Documentation]  Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish.
36    [Tags]  Verify_Redfish_Works_On_Both_Interfaces
37    [Teardown]  Run Keywords
38    ...  Configure Hostname  ${hostname}  AND  Validate Hostname On BMC  ${hostname}
39
40    Redfish1.Login
41    Redfish.Login
42
43    ${hostname}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
44    ${data}=  Create Dictionary  HostName=openbmc
45    Redfish1.patch  ${REDFISH_NW_ETH_IFACE}eth1  body=&{data}
46    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
47
48    Validate Hostname On BMC  openbmc
49
50    ${resp1}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}eth0
51    ${resp2}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth1
52    Should Be Equal  ${resp1.dict['HostName']}  ${resp2.dict['HostName']}
53
54
55Verify LDAP Login Works When Eth1 IP Is Not Configured
56    [Documentation]  Verify LDAP login works when eth1 IP is erased.
57    [Tags]  Verify_LDAP_Login_Works_When_Eth1_IP_Is_Not_Configured
58    [Setup]  Run Keywords  Set Test Variable  ${CHANNEL_NUMBER}  ${2}
59    ...  AND  Delete IP Address  ${OPENBMC_HOST_1}
60    [Teardown]  Run Keywords  Redfish.Login  AND
61    ...  Add IP Address  ${OPENBMC_HOST_1}  ${eth1_subnet_mask}  ${eth1_gateway}
62
63    Create LDAP Configuration
64    Redfish.Login  ${LDAP_USER}  ${LDAP_USER_PASSWORD}
65    Redfish.Logout
66
67
68Verify SNMP Works When Eth1 IP Is Not Configured
69    [Documentation]  Verify SNMP works when eth1 IP is not configured.
70    [Tags]  Verify_SNMP_Works_When_Eth1_IP_Is_Not_Configured
71    [Setup]  Run Keywords  Set Test Variable  ${CHANNEL_NUMBER}  ${2}
72    ...  AND  Delete IP Address  ${OPENBMC_HOST_1}
73    [Teardown]  Run Keywords  Redfish.Login  AND
74    ...  Add IP Address  ${OPENBMC_HOST_1}  ${eth1_subnet_mask}  ${eth1_gateway}
75
76    Create Error On BMC And Verify Trap
77
78
79Disable And Enable Eth0 Interface
80    [Documentation]  Disable and Enable eth0 ethernet interface via redfish.
81    [Tags]  Disable_And_Enable_Eth0_Interface
82    [Template]  Set BMC Ethernet Interfaces State
83
84    # interface_ip   interface  enabled
85    ${OPENBMC_HOST}   eth0      ${False}
86    ${OPENBMC_HOST}   eth0      ${True}
87
88
89Verify Both Interfaces Access Concurrently Via Redfish
90    [Documentation]  Verify both interfaces access conurrently via redfish.
91    [Tags]  Verify_Both_Interfaces_Access_Concurrently_Via_Redfish
92
93    Redfish.Login
94    Redfish1.Login
95
96    ${dict}=  Execute Process Multi Keyword  ${2}
97    ...  Redfish.Patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}}
98    ...  Redfish1.Patch ${REDFISH_NW_ETH_IFACE}eth1 body={'DHCPv4':{'UseDNSServers':${True}}}
99
100    Dictionary Should Not Contain Value  ${dict}  False
101    ...  msg=One or more operations has failed.
102
103    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}eth0
104    ${resp1}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth1
105
106    Should Be Equal  ${resp.dict["DHCPv4"]['UseDNSServers']}  ${True}
107    Should Be Equal  ${resp1.dict["DHCPv4"]['UseDNSServers']}  ${True}
108
109
110Able To Access Serial Console Via Both Network Interfaces
111    [Documentation]  Able to access serial console via both network interfaces.
112    [Tags]  Able_To_Access_Serial_Console_Via_Both_Network Interfaces
113
114    Open Connection And Log In  host=${OPENBMC_HOST}  port=2200
115    Open Connection And Log In  host=${OPENBMC_HOST_1}  port=2200
116    Close All Connections
117
118
119*** Keywords ***
120
121Get Network Configuration Using Channel Number
122    [Documentation]  Get ethernet interface.
123    [Arguments]  ${channel_number}
124
125    # Description of argument(s):
126    # channel_number   Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
127
128    ${active_channel_config}=  Get Active Channel Config
129    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
130    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
131
132    @{network_configurations}=  Get From Dictionary  ${resp.dict}  IPv4StaticAddresses
133    [Return]  @{network_configurations}
134
135
136Suite Setup Execution
137    [Documentation]  Do suite setup task.
138
139    Valid Value  OPENBMC_HOST_1
140
141    # Check both interfaces are configured and reachable.
142    Ping Host  ${OPENBMC_HOST}
143    Ping Host  ${OPENBMC_HOST_1}
144
145    ${network_configurations}=  Get Network Configuration Using Channel Number  ${2}
146    FOR  ${network_configuration}  IN  @{network_configurations}
147
148      Run Keyword If  '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
149      ...  Run Keywords  Set Suite Variable  ${eth1_subnet_mask}  ${network_configuration['SubnetMask']}
150      ...  AND  Set Suite Variable  ${eth1_gateway}  ${network_configuration['Gateway']}
151      ...  AND  Exit For Loop
152
153    END
154
155
156Set BMC Ethernet Interfaces State
157    [Documentation]  Set BMC ethernet interface state.
158    [Arguments]  ${interface_ip}  ${interface}  ${enabled}
159    [Teardown]  Redfish1.Logout
160
161    # Description of argument(s):
162    # interface_ip    IP address of ethernet interface.
163    # interface       The ethernet interface name (eg. eth0 or eth1).
164    # enabled         Indicates interface should be enabled (eg. True or False).
165
166    Redfish1.Login
167
168    ${data}=  Create Dictionary  InterfaceEnabled=${enabled}
169
170    Redfish1.patch  ${REDFISH_NW_ETH_IFACE}${interface}  body=&{data}
171    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
172
173    Sleep  ${NETWORK_TIMEOUT}s
174    ${interface_status}=   Redfish1.Get Attribute  ${REDFISH_NW_ETH_IFACE}${interface}  InterfaceEnabled
175    Should Be Equal  ${interface_status}  ${enabled}
176
177    ${status}=  Run Keyword And Return Status  Ping Host  ${interface_ip}
178
179    Run Keyword If  ${enabled} == ${True}  Should Be Equal  ${status}  ${True}
180    ...  ELSE  Should Be Equal  ${status}  ${False}
181