Prashanth Katti | 391000c | 2021-06-11 04:09:21 -0500 | [diff] [blame] | 1 | Documentation Utility for SNMP configurations via Redfish. |
| 2 | |
| 3 | *** Settings *** |
| 4 | |
| 5 | Resource ../../lib/utils.robot |
| 6 | Resource ../../lib/connection_client.robot |
| 7 | Library ../../lib/gen_misc.py |
| 8 | Library ../../lib/utils.py |
| 9 | |
| 10 | |
| 11 | *** Keywords *** |
| 12 | |
| 13 | Get SNMP Manager List |
| 14 | [Documentation] Get the list of SNMP managers and return IP addresses and ports. |
| 15 | |
| 16 | # Get the list of SNMP manager URIs. |
| 17 | @{snmp_mgr_uris}= Get SNMP Child URIs |
| 18 | |
| 19 | ${snmp_mgr_list}= Create List |
| 20 | |
| 21 | FOR ${snmp_mgr_uri} IN @{snmp_mgr_uris} |
| 22 | # Sample output: |
| 23 | # { |
| 24 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1", |
| 25 | # "@odata.type": "#EventDestination.v1_7_0.EventDestination", |
| 26 | # "Context": "", |
| 27 | # "Destination": "snmp://xx.xx.xx.xx:162", |
| 28 | # "EventFormatType": "Event", |
| 29 | # "Id": "snmp1", |
| 30 | # "Name": "Event Destination snmp1", |
| 31 | # "Protocol": "SNMPv2c", |
| 32 | # "SubscriptionType": "SNMPTrap" |
| 33 | |
| 34 | ${resp}= Redfish.Get ${snmp_mgr_uri} |
| 35 | ${snmp_mgr}= Get From Dictionary ${resp.dict} Destination |
| 36 | Append To List ${snmp_mgr_list} ${snmp_mgr} |
| 37 | END |
| 38 | |
| 39 | [Return] ${snmp_mgr_list} |
| 40 | |
| 41 | |
| 42 | Configure SNMP Manager Via Redfish |
| 43 | [Documentation] Configure SNMP manager on BMC via Redfish. |
| 44 | [Arguments] ${snmp_mgr_ip} ${snmp_port} ${valid_status_codes}=${HTTP_CREATED} |
| 45 | |
| 46 | # Description of argument(s): |
| 47 | # snmp_mgr_ip SNMP manager IP address |
| 48 | # snmp_port SNMP manager port |
| 49 | # valid_status_code expected code |
| 50 | |
| 51 | ${snmp_mgr_data}= Create Dictionary Destination=snmp://${snmp_mgr_ip}:${snmp_port} |
| 52 | ... SubscriptionType=${snmp_function} Protocol=${snmp_version} |
| 53 | |
| 54 | Redfish.Post ${subscription_uri} body=&{snmp_mgr_data} |
| 55 | ... valid_status_codes=[${valid_status_codes}] |
| 56 | |
| 57 | |
| 58 | Verify SNMP Manager Configured On BMC |
| 59 | [Documentation] Verify SNMP manager configured on BMC. |
| 60 | [Arguments] ${snmp_mgr_ip} ${snmp_port} |
| 61 | |
| 62 | # Description of argument(s): |
| 63 | # snmp_mgr_ip SNMP manager IP address |
| 64 | # snmp_port SNMP manager port |
| 65 | |
| 66 | # Get the list of SNMP managers that are configured on BMC. |
| 67 | @{snmp_mgr_list}= Get SNMP Manager List |
| 68 | |
| 69 | ${snmp_ip_port}= Catenate ${snmp_mgr_ip}:${snmp_port} |
| 70 | |
| 71 | List Should Contain Value ${snmp_mgr_list} snmp://${snmp_ip_port} |
| 72 | ... msg=SNMP manager is not configured. |
| 73 | |
| 74 | |
| 75 | Get SNMP Child URIs |
| 76 | [Documentation] Get the list of all SNMP manager URIs. |
| 77 | |
| 78 | # Sample output of SNMP URI: |
| 79 | # { |
| 80 | # "@odata.id": "/redfish/v1/EventService/Subscriptions", |
| 81 | # "@odata.type": "#EventDestinationCollection.EventDestinationCollection", |
| 82 | # "Members": [ |
| 83 | # { |
| 84 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp6" |
| 85 | # }, |
| 86 | # { |
| 87 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp2" |
| 88 | # }, |
| 89 | # { |
| 90 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp9" |
| 91 | # }, |
| 92 | # { |
| 93 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp1" |
| 94 | # }, |
| 95 | # { |
| 96 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp8" |
| 97 | # }, |
| 98 | # { |
| 99 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp4" |
| 100 | # }, |
| 101 | # { |
| 102 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp7" |
| 103 | # }, |
| 104 | # { |
| 105 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp5" |
| 106 | # }, |
| 107 | # { |
| 108 | # "@odata.id": "/redfish/v1/EventService/Subscriptions/snmp3" |
| 109 | # } |
| 110 | # ], |
| 111 | # "Members@odata.count": 9, |
| 112 | # "Name": "Event Destination Collections" |
| 113 | |
| 114 | # Get the list of child URIs. |
| 115 | @{snmp_mgr_uris}= Redfish.Get Members List ${subscription_uri} filter=snmp |
| 116 | |
| 117 | [Return] ${snmp_mgr_uris} |