1*f58cce03SPrashanth Katti*** Settings ***
2*f58cce03SPrashanth KattiDocumentation  Network interface configuration and verification
3*f58cce03SPrashanth Katti               ...  tests.
4*f58cce03SPrashanth Katti
5*f58cce03SPrashanth KattiResource  ../../lib/bmc_redfish_resource.robot
6*f58cce03SPrashanth KattiResource  ../../lib/bmc_network_utils.robot
7*f58cce03SPrashanth KattiResource  ../../lib/openbmc_ffdc.robot
8*f58cce03SPrashanth Katti
9*f58cce03SPrashanth KattiTest Setup     Test Setup Execution
10*f58cce03SPrashanth KattiTest Teardown  Test Teardown Execution
11*f58cce03SPrashanth Katti
12*f58cce03SPrashanth Katti*** Test Cases ***
13*f58cce03SPrashanth Katti
14*f58cce03SPrashanth KattiGet IP Address And Verify
15*f58cce03SPrashanth Katti    [Documentation]  Get IP Address And Verify.
16*f58cce03SPrashanth Katti    [Tags]           Get_IP_Address_And_Verify
17*f58cce03SPrashanth Katti
18*f58cce03SPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
19*f58cce03SPrashanth Katti    \  Validate IP On BMC  ${network_configuration['Address']}
20*f58cce03SPrashanth Katti
21*f58cce03SPrashanth KattiGet Netmask And Verify
22*f58cce03SPrashanth Katti    [Documentation]  Get Netmask And Verify.
23*f58cce03SPrashanth Katti    [Tags]           Get_Netmask_And_Verify
24*f58cce03SPrashanth Katti
25*f58cce03SPrashanth Katti    : FOR  ${network_configuration}  IN  @{network_configurations}
26*f58cce03SPrashanth Katti    \  Validate Netmask On BMC  ${network_configuration['SubnetMask']}
27*f58cce03SPrashanth Katti
28*f58cce03SPrashanth Katti*** Keywords ***
29*f58cce03SPrashanth Katti
30*f58cce03SPrashanth KattiTest Setup Execution
31*f58cce03SPrashanth Katti    [Documentation]  Test setup execution.
32*f58cce03SPrashanth Katti
33*f58cce03SPrashanth Katti    redfish.Login
34*f58cce03SPrashanth Katti
35*f58cce03SPrashanth Katti    @{network_configurations}=  Get Network Configuration
36*f58cce03SPrashanth Katti    Set Test Variable  @{network_configurations}
37*f58cce03SPrashanth Katti
38*f58cce03SPrashanth Katti    # Get BMC IP address and prefix length.
39*f58cce03SPrashanth Katti    ${ip_data}=  Get BMC IP Info
40*f58cce03SPrashanth Katti    Set Test Variable  ${ip_data}
41*f58cce03SPrashanth Katti
42*f58cce03SPrashanth KattiGet Network Configuration
43*f58cce03SPrashanth Katti    [Documentation]  Get network configuration.
44*f58cce03SPrashanth Katti
45*f58cce03SPrashanth Katti    # Sample output:
46*f58cce03SPrashanth Katti    #{
47*f58cce03SPrashanth Katti    #  "@odata.context": "/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
48*f58cce03SPrashanth Katti    #  "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
49*f58cce03SPrashanth Katti    #  "@odata.type": "#EthernetInterface.v1_2_0.EthernetInterface",
50*f58cce03SPrashanth Katti    #  "Description": "Management Network Interface",
51*f58cce03SPrashanth Katti    #  "IPv4Addresses": [
52*f58cce03SPrashanth Katti    #    {
53*f58cce03SPrashanth Katti    #      "Address": "169.254.xx.xx",
54*f58cce03SPrashanth Katti    #      "AddressOrigin": "IPv4LinkLocal",
55*f58cce03SPrashanth Katti    #      "Gateway": "0.0.0.0",
56*f58cce03SPrashanth Katti    #      "SubnetMask": "255.255.0.0"
57*f58cce03SPrashanth Katti    #    },
58*f58cce03SPrashanth Katti    #    {
59*f58cce03SPrashanth Katti    #      "Address": "xx.xx.xx.xx",
60*f58cce03SPrashanth Katti    #      "AddressOrigin": "Static",
61*f58cce03SPrashanth Katti    #      "Gateway": "xx.xx.xx.1",
62*f58cce03SPrashanth Katti    #      "SubnetMask": "xx.xx.xx.xx"
63*f58cce03SPrashanth Katti    #    }
64*f58cce03SPrashanth Katti    #  ],
65*f58cce03SPrashanth Katti    #  "Id": "eth0",
66*f58cce03SPrashanth Katti    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
67*f58cce03SPrashanth Katti    #  "Name": "Manager Ethernet Interface",
68*f58cce03SPrashanth Katti    #  "SpeedMbps": 0,
69*f58cce03SPrashanth Katti    #  "VLAN": {
70*f58cce03SPrashanth Katti    #    "VLANEnable": false,
71*f58cce03SPrashanth Katti    #    "VLANId": 0
72*f58cce03SPrashanth Katti    #  }
73*f58cce03SPrashanth Katti
74*f58cce03SPrashanth Katti    ${resp}=  redfish.Get  ${REDFISH_NW_ETH0_URI}
75*f58cce03SPrashanth Katti    @{network_configurations}=  Get From Dictionary  ${resp.dict}  IPv4Addresses
76*f58cce03SPrashanth Katti    [Return]  @{network_configurations}
77*f58cce03SPrashanth Katti
78*f58cce03SPrashanth KattiValidate IP On BMC
79*f58cce03SPrashanth Katti    [Documentation]  Validate IP on BMC.
80*f58cce03SPrashanth Katti    [Arguments]  ${ip}
81*f58cce03SPrashanth Katti
82*f58cce03SPrashanth Katti    # Description of the argument(s):
83*f58cce03SPrashanth Katti    # ip  IP address to be verified.
84*f58cce03SPrashanth Katti
85*f58cce03SPrashanth Katti    # Get IP address details on BMC using IP command.
86*f58cce03SPrashanth Katti    @{ip_data}=  Get BMC IP Info
87*f58cce03SPrashanth Katti    Should Contain Match  ${ip_data}  ${ip}/*
88*f58cce03SPrashanth Katti    ...  msg=IP address does not exist.
89*f58cce03SPrashanth Katti
90*f58cce03SPrashanth KattiValidate Netmask On BMC
91*f58cce03SPrashanth Katti    [Documentation]  Validate netmask on BMC.
92*f58cce03SPrashanth Katti    [Arguments]  ${netmask}
93*f58cce03SPrashanth Katti
94*f58cce03SPrashanth Katti    # Description of the argument(s):
95*f58cce03SPrashanth Katti    # netmask  netmask value to be verified.
96*f58cce03SPrashanth Katti
97*f58cce03SPrashanth Katti    # TBD- openbmc/openbmc-test-automation#1541
98*f58cce03SPrashanth Katti
99*f58cce03SPrashanth KattiTest Teardown Execution
100*f58cce03SPrashanth Katti    [Documentation]  Test teardown execution.
101*f58cce03SPrashanth Katti
102*f58cce03SPrashanth Katti    FFDC On Test Case Fail
103*f58cce03SPrashanth Katti    redfish.Logout
104