1*** Settings ***
2Documentation   Test BMC DHCP multiple network interface functionalities.
3
4Resource        ../../lib/resource.robot
5Resource        ../../lib/common_utils.robot
6Resource        ../../lib/connection_client.robot
7Resource        ../../lib/bmc_network_utils.robot
8Resource        ../../lib/openbmc_ffdc.robot
9
10Suite Setup     Suite Setup Execution
11Test Teardown   FFDC On Test Case Fail
12Suite Teardown  Redfish.Logout
13
14*** Variables ***
15
16&{DHCP_ENABLED}           DHCPEnabled=${True}
17&{DHCP_DISABLED}          DHCPEnabled=${False}
18&{ENABLE_DHCP}            DHCPv4=${DHCP_ENABLED}
19&{DISABLE_DHCP}           DHCPv4=${DHCP_DISABLED}
20${ethernet_interface}     eth1
21
22*** Test Cases ***
23
24Disable DHCP On Eth1 And Verify System Is Accessible By Eth0
25    [Documentation]  Disable DHCP on eth1 using Redfish and verify
26    ...              if system is accessible by eth0.
27    [Tags]  Disable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
28    [Teardown]  Set DHCPEnabled To Enable Or Disable  True  eth1
29
30    Set DHCPEnabled To Enable Or Disable  False  eth1
31    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
32
33Enable DHCP On Eth1 And Verify System Is Accessible By Eth0
34    [Documentation]  Enable DHCP on eth1 using Redfish and verify if system
35    ...              is accessible by eth0.
36    [Tags]  Enable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0
37    [Setup]  Set DHCPEnabled To Enable Or Disable  False  eth1
38
39    Set DHCPEnabled To Enable Or Disable  True  eth1
40    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
41
42*** Keywords ***
43
44Set DHCPEnabled To Enable Or Disable
45    [Documentation]  Enable or Disable DHCP on the interface.
46    [Arguments]  ${dhcp_enabled}=${False}  ${interface}=${ethernet_interface}
47    ...          ${valid_status_code}=[${HTTP_OK},${HTTP_ACCEPTED}]
48
49    # Description of argument(s):
50    # dhcp_enabled        False for disabling DHCP and True for Enabling DHCP.
51    # interface           eth0 or eth1. Default is eth1.
52    # valid_status_code   Expected valid status code from Patch request.
53    #                     Default is HTTP_OK.
54
55    ${data}=  Set Variable If  ${dhcp_enabled} == ${False}  ${DISABLE_DHCP}  ${ENABLE_DHCP}
56    ${resp}=  Redfish.Patch
57    ...  /redfish/v1/Managers/bmc/EthernetInterfaces/${interface}
58    ...  body=${data}  valid_status_codes=${valid_status_code}
59
60Suite Setup Execution
61    [Documentation]  Do suite setup task.
62
63    Ping Host  ${OPENBMC_HOST}
64    Redfish.Login
65