1391000c1SPrashanth Katti*** Settings ***
2391000c1SPrashanth KattiDocumentation  This testing requires special setup where SNMP trapd is
3391000c1SPrashanth Katti...            configured and installed. For download, installation and
4391000c1SPrashanth Katti...            configuration refer http://www.net-snmp.org/.
5391000c1SPrashanth Katti
6391000c1SPrashanth Katti
7391000c1SPrashanth KattiResource      ../../lib/snmp/resource.robot
8391000c1SPrashanth KattiResource      ../../lib/snmp/redfish_snmp_utils.robot
9391000c1SPrashanth KattiResource      ../../lib/bmc_redfish_resource.robot
10391000c1SPrashanth KattiResource      ../../lib/openbmc_ffdc.robot
11391000c1SPrashanth KattiResource      ../../lib/logging_utils.robot
12391000c1SPrashanth Katti
13391000c1SPrashanth Katti
14391000c1SPrashanth KattiTest Teardown     FFDC On Test Case Fail
15391000c1SPrashanth KattiSuite Setup       Suite Setup Execution
1681302e45SGeorge KeishingSuite Teardown    Suite Teardown Execution
17391000c1SPrashanth Katti
18*6fb70d98SMatt FischerTest Tags        BMC_SNMP_Trap
19391000c1SPrashanth Katti
20391000c1SPrashanth Katti*** Test Cases ***
21391000c1SPrashanth Katti
22391000c1SPrashanth KattiConfigure SNMP Manager On BMC And Verify
23391000c1SPrashanth Katti    [Documentation]  Configure SNMP manager on BMC via Redfish and verify.
24391000c1SPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_And_Verify
25dd99a919SPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
26391000c1SPrashanth Katti
27391000c1SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}  ${HTTP_CREATED}
28391000c1SPrashanth Katti
29391000c1SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
30391000c1SPrashanth Katti
31391000c1SPrashanth Katti
325236ec54SGeorge KeishingConfigure SNMP Manager On BMC With Non Default Port And Verify
33c744f04eSPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC And Verify.
34c744f04eSPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_With_Non_Default_Port_And_Verify
35c744f04eSPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
36c744f04eSPrashanth Katti
37c744f04eSPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}  ${HTTP_CREATED}
38c744f04eSPrashanth Katti
39c744f04eSPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
40c744f04eSPrashanth Katti
41c744f04eSPrashanth Katti
42c744f04eSPrashanth KattiConfigure SNMP Manager On BMC With Out Of Range Port And Verify
43c744f04eSPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC with out-of range port and verify.
44c744f04eSPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_With_Out_Of_Range_Port_And_Verify
45c744f04eSPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${out_of_range_port}
46c744f04eSPrashanth Katti
47c744f04eSPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${out_of_range_port}  ${HTTP_BAD_REQUEST}
48c744f04eSPrashanth Katti
49c744f04eSPrashanth Katti    ${status}=  Run Keyword And Return Status
50c744f04eSPrashanth Katti    ...  Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${out_of_range_port}
51c744f04eSPrashanth Katti
52c744f04eSPrashanth Katti    Should Be Equal As Strings  ${status}  False
53c744f04eSPrashanth Katti    ...  msg=BMC is allowing to configure out of range port.
54c744f04eSPrashanth Katti
55c744f04eSPrashanth Katti
56c744f04eSPrashanth KattiGenerate Error On BMC And Verify SNMP Trap
57c744f04eSPrashanth Katti    [Documentation]  Generate error on BMC and verify trap and its fields.
58c744f04eSPrashanth Katti    [Tags]  Generate_Error_On_BMC_And_Verify_SNMP_Trap
59c744f04eSPrashanth Katti    [Template]  Create Error On BMC And Verify Trap
60c744f04eSPrashanth Katti
61c744f04eSPrashanth Katti    # event_log                 expected_error
62c744f04eSPrashanth Katti
63c744f04eSPrashanth Katti    # Generate internal failure error.
64c744f04eSPrashanth Katti    ${CMD_INTERNAL_FAILURE}     ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
65c744f04eSPrashanth Katti
66c744f04eSPrashanth Katti    # Generate timeout error.
67c744f04eSPrashanth Katti    ${CMD_FRU_CALLOUT}          ${SNMP_TRAP_BMC_CALLOUT_ERROR}
68c744f04eSPrashanth Katti
69c744f04eSPrashanth Katti    # Generate informational error.
70c744f04eSPrashanth Katti    ${CMD_INFORMATIONAL_ERROR}  ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
71c744f04eSPrashanth Katti
72c744f04eSPrashanth Katti
73b1a9c6b7SPrashanth KattiConfigure SNMP Manager On BMC With Alpha Port And Verify
74b1a9c6b7SPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC with alpha port and verify.
75b1a9c6b7SPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_With_Alpha_Port_And_Verify
76b1a9c6b7SPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${alpha_port}
77b1a9c6b7SPrashanth Katti
78b1a9c6b7SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${alpha_port}  ${HTTP_BAD_REQUEST}
79b1a9c6b7SPrashanth Katti
80b1a9c6b7SPrashanth Katti    ${status}=  Run Keyword And Return Status
81b1a9c6b7SPrashanth Katti    ...  Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${alpha_port}
82b1a9c6b7SPrashanth Katti
83b1a9c6b7SPrashanth Katti    Should Be Equal As Strings  ${status}  False
84b1a9c6b7SPrashanth Katti    ...  msg=BMC is allowing to configure invalid port.
85b1a9c6b7SPrashanth Katti
86b1a9c6b7SPrashanth Katti
87b1a9c6b7SPrashanth KattiConfigure SNMP Manager On BMC With Empty Port And Verify
88b1a9c6b7SPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC with empty port and verify
89b1a9c6b7SPrashanth Katti    ...  SNMP manager gets configured with default port.
90b1a9c6b7SPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_With_Empty_Port_And_Verify
91b1a9c6b7SPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
92b1a9c6b7SPrashanth Katti
93b1a9c6b7SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${empty_port}
94b1a9c6b7SPrashanth Katti
95b1a9c6b7SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
96b1a9c6b7SPrashanth Katti
97b1a9c6b7SPrashanth Katti
98b1a9c6b7SPrashanth KattiConfigure Multiple SNMP Managers And Verify
99b1a9c6b7SPrashanth Katti    [Documentation]  Configure multiple SNMP managers and verify.
100b1a9c6b7SPrashanth Katti    [Tags]  Configure_Multiple_SNMP_Managers_And_Verify
101b1a9c6b7SPrashanth Katti    [Teardown]  Run Keywords
102b1a9c6b7SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
103b1a9c6b7SPrashanth Katti    ...  AND
104b1a9c6b7SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
105b1a9c6b7SPrashanth Katti
106b1a9c6b7SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
107b1a9c6b7SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
108b1a9c6b7SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
109b1a9c6b7SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
110b1a9c6b7SPrashanth Katti
111b1a9c6b7SPrashanth Katti
112a2e8b0d6SGeorge KeishingGenerate Error On BMC And Verify SNMP Trap Is Sent To Non Default Port
113b1a9c6b7SPrashanth Katti    [Documentation]  Generate error on BMC and verify trap and its fields.
114a2e8b0d6SGeorge Keishing    [Tags]  Generate_Error_On_BMC_And_Verify_SNMP_Trap_Is_Sent_To_Non_Default_Port
115a2e8b0d6SGeorge Keishing    [Template]  Create Error On BMC And Verify Trap On Non Default Port
116b1a9c6b7SPrashanth Katti
117b1a9c6b7SPrashanth Katti    # event_log                 expected_error
118b1a9c6b7SPrashanth Katti
119b1a9c6b7SPrashanth Katti    # Generate internal failure error.
120b1a9c6b7SPrashanth Katti    ${CMD_INTERNAL_FAILURE}     ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
121b1a9c6b7SPrashanth Katti
122b1a9c6b7SPrashanth Katti    # Generate timeout error.
123b1a9c6b7SPrashanth Katti    ${CMD_FRU_CALLOUT}          ${SNMP_TRAP_BMC_CALLOUT_ERROR}
124b1a9c6b7SPrashanth Katti
125b1a9c6b7SPrashanth Katti    # Generate informational error.
126b1a9c6b7SPrashanth Katti    ${CMD_INFORMATIONAL_ERROR}  ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
127b1a9c6b7SPrashanth Katti
128b1a9c6b7SPrashanth Katti
1297f319268SPrashanth KattiVerify SNMP SysUpTime
1307f319268SPrashanth Katti    [Documentation]  Verify SNMP SysUpTime.
1317f319268SPrashanth Katti    [Tags]  Verify_SNMP_SysUpTime
1327f319268SPrashanth Katti
1337f319268SPrashanth Katti    Generate Error And Verify System Up Time
1347f319268SPrashanth Katti
1357f319268SPrashanth Katti
1367f319268SPrashanth KattiVerify SNMP SysUpTime On BMC Reboot
1377f319268SPrashanth Katti    [Documentation]  Verify SNMP SysUpTime on BMC reboot.
1387f319268SPrashanth Katti    [Tags]  Verify_SNMP_SysUpTime_On_BMC_Reboot
1397f319268SPrashanth Katti
1407f319268SPrashanth Katti    # Reboot BMC to reset system uptime.
1417f319268SPrashanth Katti    OBMC Reboot (off)
1427f319268SPrashanth Katti
1437f319268SPrashanth Katti    ${uptime}=  Generate Error And Verify System Up Time
1447f319268SPrashanth Katti
1457f319268SPrashanth Katti    # Check if uptime is reset after reboot.
1467f319268SPrashanth Katti    Should Be True  ${uptime} <= 1  msg=SNMP SysUpTime is not reset on reboot
1477f319268SPrashanth Katti
1487f319268SPrashanth Katti
1495236ec54SGeorge KeishingConfigure Multiple SNMP Managers With Non Default Port And Verify
1507f319268SPrashanth Katti    [Documentation]  Configure multiple SNMP Managers with non-default port And Verify.
1517f319268SPrashanth Katti    [Tags]  Configure_Multiple_SNMP_Managers_With_Non_Default_Port_And_Verify
1527f319268SPrashanth Katti    [Teardown]  Run Keywords
1537f319268SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
1547f319268SPrashanth Katti    ...  AND
1557f319268SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1567f319268SPrashanth Katti
1577f319268SPrashanth Katti    # Configure multiple SNMP managers with non-default port.
1587f319268SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
1597f319268SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1607f319268SPrashanth Katti
1617f319268SPrashanth Katti    # Verify if SNMP managers are configured.
1627f319268SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${NON_DEFAULT_PORT1}
1637f319268SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1647f319268SPrashanth Katti
1657f319268SPrashanth Katti
1667f319268SPrashanth KattiConfigure Multiple SNMP Managers With Different Ports And Verify
1677f319268SPrashanth Katti    [Documentation]  Configure multiple SNMP Managers with different ports And Verify.
1687f319268SPrashanth Katti    [Tags]  Configure_Multiple_SNMP_Managers_With_Different_Ports_And_Verify
1697f319268SPrashanth Katti    [Teardown]  Run Keywords
1707f319268SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
1717f319268SPrashanth Katti    ...  AND
1727f319268SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1737f319268SPrashanth Katti    ...  AND
1747f319268SPrashanth Katti    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR3_IP}  ${NON_DEFAULT_PORT2}
1757f319268SPrashanth Katti
176269e52e3SGeorge Keishing    # Configure multiple SNMP managers with different ports.
1777f319268SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
1787f319268SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1797f319268SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR3_IP}  ${NON_DEFAULT_PORT2}
1807f319268SPrashanth Katti
1817f319268SPrashanth Katti    # Verify if SNMP managers are configured.
1827f319268SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
1837f319268SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR2_IP}  ${NON_DEFAULT_PORT1}
1847f319268SPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR3_IP}  ${NON_DEFAULT_PORT2}
1857f319268SPrashanth Katti
1867f319268SPrashanth Katti
1876ea399beSPrashanth KattiConfigure SNMP Manager With Out Of Range IP On BMC And Verify
1886ea399beSPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC with out-of range IP and expect an error.
1896ea399beSPrashanth Katti    [Tags]  Configure_SNMP_Manager_With_Out_Of_Range_IP_On_BMC_And_Verify
1906ea399beSPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${out_of_range_ip}  ${SNMP_DEFAULT_PORT}
1916ea399beSPrashanth Katti
1926ea399beSPrashanth Katti    Configure SNMP Manager Via Redfish  ${out_of_range_ip}  ${SNMP_DEFAULT_PORT}  ${HTTP_BAD_REQUEST}
1936ea399beSPrashanth Katti
1946ea399beSPrashanth Katti    ${status}=  Run Keyword And Return Status
1956ea399beSPrashanth Katti    ...  Verify SNMP Manager Configured On BMC  ${out_of_range_ip}  ${SNMP_DEFAULT_PORT}
1966ea399beSPrashanth Katti
1976ea399beSPrashanth Katti    Should Be Equal As Strings  ${status}  False
1986ea399beSPrashanth Katti    ...  msg=BMC is allowing to configure out of range IP.
1996ea399beSPrashanth Katti
2006ea399beSPrashanth Katti
2016ea399beSPrashanth KattiVerify Persistency Of SNMP Manager And Trap On BMC Reboot
2026ea399beSPrashanth Katti    [Documentation]  Verify persistency of SNMP manager configuration on BMC
2036ea399beSPrashanth Katti    ...  and BMC is able to send trap after reboot.
2046ea399beSPrashanth Katti    [Tags]  Verify_Persistency_Of_SNMP_Manager_And_Trap_On_BMC_Reboot
2056ea399beSPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
2066ea399beSPrashanth Katti
2076ea399beSPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}  ${HTTP_CREATED}
2086ea399beSPrashanth Katti
2096ea399beSPrashanth Katti    # Reboot BMC and check persistency SNMP manager.
2106ea399beSPrashanth Katti    OBMC Reboot (off)
2116ea399beSPrashanth Katti
2126ea399beSPrashanth Katti    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
2136ea399beSPrashanth Katti
2146ea399beSPrashanth Katti    # Check if trap is generated and sent to SNMP manager after reboot.
2156ea399beSPrashanth Katti    Generate Error On BMC And Verify Trap
2166ea399beSPrashanth Katti    ...  ${CMD_INTERNAL_FAILURE}  ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
2176ea399beSPrashanth Katti
2186ea399beSPrashanth Katti
2192320c0d5SPrashanth KattiConfigure SNMP Manager With Less Octet IP And Verify
2202320c0d5SPrashanth Katti    [Documentation]  Configure SNMP manager on BMC with less octet IP and expect an error.
2212320c0d5SPrashanth Katti    [Tags]  Configure_SNMP_Manager_With_Less_Octet_IP_And_Verify
2222320c0d5SPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${less_octet_ip}  ${SNMP_DEFAULT_PORT}
2232320c0d5SPrashanth Katti
2242320c0d5SPrashanth Katti    Configure SNMP Manager Via Redfish  ${less_octet_ip}  ${SNMP_DEFAULT_PORT}  ${HTTP_BAD_REQUEST}
2252320c0d5SPrashanth Katti
2262320c0d5SPrashanth Katti    ${status}=  Run Keyword And Return Status
2272320c0d5SPrashanth Katti    ...  Verify SNMP Manager Configured On BMC  ${less_octet_ip}  ${SNMP_DEFAULT_PORT}
2282320c0d5SPrashanth Katti
2292320c0d5SPrashanth Katti    Should Be Equal As Strings  ${status}  False
2302320c0d5SPrashanth Katti    ...  msg=BMC is allowing to configure less octet IP.
2312320c0d5SPrashanth Katti
2322320c0d5SPrashanth Katti
2332320c0d5SPrashanth KattiConfigure SNMP Manager On BMC With Negative Port And Verify
2342320c0d5SPrashanth Katti    [Documentation]  Configure SNMP Manager On BMC with negative port and verify.
2352320c0d5SPrashanth Katti    [Tags]  Configure_SNMP_Manager_On_BMC_With_Negative_Port_And_Verify
2362320c0d5SPrashanth Katti
2372320c0d5SPrashanth Katti    [Teardown]  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${negative_port}
2382320c0d5SPrashanth Katti
2392320c0d5SPrashanth Katti    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${negative_port}  ${HTTP_BAD_REQUEST}
2402320c0d5SPrashanth Katti
2412320c0d5SPrashanth Katti    ${status}=  Run Keyword And Return Status
2422320c0d5SPrashanth Katti    ...  Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${negative_port}
2432320c0d5SPrashanth Katti
2442320c0d5SPrashanth Katti    Should Be Equal As Strings  ${status}  False
2452320c0d5SPrashanth Katti    ...  msg=BMC is allowing to configure negative port.
2462320c0d5SPrashanth Katti
2472320c0d5SPrashanth Katti
248ad10253fSmeghagnConfigure Multiple SNMP Managers On BMC And Verify Persistency On BMC Reboot
249ad10253fSmeghagn    [Documentation]  Configure multiple SNMP Managers on BMC and verify persistency on BMC reboot.
250ad10253fSmeghagn    [Tags]  Configure_Multiple_SNMP_Managers_On_BMC_And_Verify_Persistency_On_BMC_Reboot
251ad10253fSmeghagn    [Teardown]  Run Keywords
252ad10253fSmeghagn    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
253ad10253fSmeghagn    ...  AND
254ad10253fSmeghagn    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
255ad10253fSmeghagn
256ad10253fSmeghagn    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
257ad10253fSmeghagn    Configure SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
258ad10253fSmeghagn
259ad10253fSmeghagn    # Reboot BMC and check persistency SNMP manager.
260ad10253fSmeghagn    OBMC Reboot (off)
261ad10253fSmeghagn
262ad10253fSmeghagn    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
263ad10253fSmeghagn    Verify SNMP Manager Configured On BMC  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
264ad10253fSmeghagn
265ad10253fSmeghagn
266ad10253fSmeghagnConfigure Multiple SNMP Managers On BMC And Check Trap On BMC Reboot
267ad10253fSmeghagn    [Documentation]  Configure multiple SNMP Managers on BMC and check trap on BMC reboot.
268ad10253fSmeghagn    [Tags]  Configure_Multiple_SNMP_Managers_On_BMC_And_Check_Trap_On_BMC_Reboot
269ad10253fSmeghagn    [Teardown]  Run Keywords
270ad10253fSmeghagn    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
271ad10253fSmeghagn    ...  AND
272ad10253fSmeghagn    ...  Delete SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
273ad10253fSmeghagn
274ad10253fSmeghagn    Configure SNMP Manager Via Redfish  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
275ad10253fSmeghagn    Configure SNMP Manager Via Redfish  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
276ad10253fSmeghagn
277ad10253fSmeghagn    # Reboot BMC and check persistency SNMP manager.
278ad10253fSmeghagn    OBMC Reboot (off)
279ad10253fSmeghagn
280ad10253fSmeghagn    Verify SNMP Manager Configured On BMC  ${SNMP_MGR1_IP}  ${SNMP_DEFAULT_PORT}
281ad10253fSmeghagn    Verify SNMP Manager Configured On BMC  ${SNMP_MGR2_IP}  ${SNMP_DEFAULT_PORT}
282ad10253fSmeghagn
283ad10253fSmeghagn    # Check if trap is generated and sent to SNMP managers after reboot.
284ad10253fSmeghagn    Generate Error On BMC And Verify Trap
285ad10253fSmeghagn    ...  ${CMD_INTERNAL_FAILURE}  ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
286ad10253fSmeghagn
287ad10253fSmeghagn
288391000c1SPrashanth Katti*** Keywords ***
289391000c1SPrashanth Katti
290391000c1SPrashanth KattiSuite Setup Execution
291391000c1SPrashanth Katti    [Documentation]  Do suite setup execution.
292391000c1SPrashanth Katti
293391000c1SPrashanth Katti    Redfish.Login
294391000c1SPrashanth Katti
295391000c1SPrashanth Katti    # Check for SNMP configurations.
296391000c1SPrashanth Katti    Valid Value  SNMP_MGR1_IP
297391000c1SPrashanth Katti    Valid Value  SNMP_DEFAULT_PORT
2987f319268SPrashanth Katti
2997f319268SPrashanth Katti
30081302e45SGeorge KeishingSuite Teardown Execution
30181302e45SGeorge Keishing    [Documentation]  Do suite Teardown execution.
30281302e45SGeorge Keishing
30381302e45SGeorge Keishing    Run Keyword And Ignore Error  Redfish Purge Event Log
30481302e45SGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
30581302e45SGeorge Keishing
30681302e45SGeorge Keishing
3077f319268SPrashanth KattiGenerate Error And Verify System Up Time
3087f319268SPrashanth Katti    [Documentation]  Generate error and verify system up time.
3097f319268SPrashanth Katti
3107f319268SPrashanth Katti    # Get system uptime on BMC.
3117f319268SPrashanth Katti    # Example output of uptime:
3127f319268SPrashanth Katti    # (8055.79 15032.86)
3137f319268SPrashanth Katti
3147f319268SPrashanth Katti    ${cmd_output}   ${stderr}  ${rc}=  BMC Execute Command  cat /proc/uptime
3157f319268SPrashanth Katti    @{times}=  Split String  ${cmd_output}
3167f319268SPrashanth Katti
3177f319268SPrashanth Katti    ${bmc_uptime_in_minutes}=  Evaluate  int(${times}[0])/60
3187f319268SPrashanth Katti
3197f319268SPrashanth Katti    ${trap}=  Create Error On BMC And Verify Trap
3207f319268SPrashanth Katti
3217f319268SPrashanth Katti    # Extract System up time from SNMP trap.
3227f319268SPrashanth Katti    # Example - SNMP trap:
3237f319268SPrashanth Katti    # DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (252367) 0:42:03.67
3247f319268SPrashanth Katti    # SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1
3257f319268SPrashanth Katti    # SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: 54
3267f319268SPrashanth Katti    # SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque: UInt64: 4622921648578756984
3277f319268SPrashanth Katti    # SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: 3
3287f319268SPrashanth Katti    # SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING:
3297f319268SPrashanth Katti
3307f319268SPrashanth Katti    @{words}=  Split String  ${trap}[0]  =
3317f319268SPrashanth Katti
3327f319268SPrashanth Katti    ${timeticks}=  Fetch From Right  ${words}[1]  (
3337f319268SPrashanth Katti    ${snmp_sysuptime}=  Fetch From Left  ${timeticks}  )
3347f319268SPrashanth Katti
3357f319268SPrashanth Katti    # SNMP SysUptime will be in milli seconds.
3367f319268SPrashanth Katti    # Convert into minutes.
3377f319268SPrashanth Katti    ${sysuptime_in_minutes}=  Evaluate  int(${snmp_sysuptime})/6000
3387f319268SPrashanth Katti
3397f319268SPrashanth Katti    Should Be Equal As Integers  ${bmc_uptime_in_minutes}  ${sysuptime_in_minutes}
3407f319268SPrashanth Katti
341409df05dSGeorge Keishing    RETURN  ${sysuptime_in_minutes}
342