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
15
16Suite Setup     Suite Setup Execution
17Test Teardown   FFDC On Test Case Fail
18Suite Teardown  Run Keywords  Redfish1.Logout  AND  Redfish.Logout
19
20*** Test Cases ***
21
22Verify Both Interfaces BMC IP Addresses Accessible Via SSH
23    [Documentation]  Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH.
24    [Tags]  Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH
25
26    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST}
27    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  host=${OPENBMC_HOST_1}
28    Close All Connections
29
30
31Verify Redfish Works On Both Interfaces
32    [Documentation]  Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish.
33    [Tags]  Verify_Redfish_Works_On_Both_Interfaces
34    [Teardown]  Run Keywords
35    ...  Configure Hostname  ${hostname}  AND  Validate Hostname On BMC  ${hostname}
36
37    Redfish1.Login
38    Redfish.Login
39
40    ${hostname}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
41    ${data}=  Create Dictionary  HostName=openbmc
42    Redfish1.patch  ${REDFISH_NW_ETH_IFACE}eth1  body=&{data}
43    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
44
45    Validate Hostname On BMC  openbmc
46
47    ${resp1}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}eth0
48    ${resp2}=  Redfish1.Get  ${REDFISH_NW_ETH_IFACE}eth1
49    Should Be Equal  ${resp1.dict['HostName']}  ${resp2.dict['HostName']}
50
51
52Verify LDAP Login Works When Eth1 IP Is Not Configured
53    [Documentation]  Verify LDAP login works when eth1 IP is erased.
54    [Tags]  Verify_LDAP_Login_Works_When_Eth1_IP_Is_Not_Configured
55    [Setup]  Run Keywords  Set Test Variable  ${CHANNEL_NUMBER}  ${2}
56    ...  AND  Delete IP Address  ${OPENBMC_HOST_1}
57    [Teardown]  Run Keywords  Redfish.Login  AND
58    ...  Add IP Address  ${OPENBMC_HOST_1}  ${eth1_subnet_mask}  ${eth1_gateway}
59
60    Create LDAP Configuration
61    Redfish.Login  ${LDAP_USER}  ${LDAP_USER_PASSWORD}
62    Redfish.Logout
63
64
65*** Keywords ***
66
67Get Network Configuration Using Channel Number
68    [Documentation]  Get ethernet interface.
69    [Arguments]  ${channel_number}
70
71    # Description of argument(s):
72    # channel_number   Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1").
73
74    ${active_channel_config}=  Get Active Channel Config
75    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
76    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
77
78    @{network_configurations}=  Get From Dictionary  ${resp.dict}  IPv4StaticAddresses
79    [Return]  @{network_configurations}
80
81
82Suite Setup Execution
83    [Documentation]  Do suite setup task.
84
85    Valid Value  OPENBMC_HOST_1
86
87    # Check both interfaces are configured and reachable.
88    Ping Host  ${OPENBMC_HOST}
89    Ping Host  ${OPENBMC_HOST_1}
90
91    ${network_configurations}=  Get Network Configuration Using Channel Number  ${2}
92    FOR  ${network_configuration}  IN  @{network_configurations}
93
94      Run Keyword If  '${network_configuration['Address']}' == '${OPENBMC_HOST_1}'
95      ...  Run Keywords  Set Suite Variable  ${eth1_subnet_mask}  ${network_configuration['SubnetMask']}
96      ...  AND  Set Suite Variable  ${eth1_gateway}  ${network_configuration['Gateway']}
97      ...  AND  Exit For Loop
98
99    END
100
101