|
Post by cccc1680tw on Feb 24, 2023 8:13:07 GMT
I built an openbmc system using QEMU and used the curl command to make sure that redfishAPI is working properly
Currently I want to use Redfish Event Listener to listen to redfish activities on openbmc, but I don't know how to set the correct config.ini
The ip of my openbmc is 127.0.0.1:2443
I use the qemu command below
sudo ./qemu-system-arm -m 1024 -M romulus-bmc -nographic -drive \
file=../openbmc/dev-2.14.0/tmp/deploy/images/romulus/obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd -net nic -net user,hostfwd=: 127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu Below is the config.ini of my Redfish Event Listener
[Information]
Updated = April 24, 2017
Description = Redfish Event Listener Tool
[System Information]
ListenerIP = 0.0.0.0
ListenerPort = 443
UseSSL=on
[Certificate Details]
certfile = cert.pem
keyfile = server.key
[Subscription Details]
Destination = https://127.0.0.1/
EventTypes = [
"Alert",
"ResourceRemoved",
"ResourceAdded",
"ResourceUpdated",
"StatusChange"]
Context = Public
Format = Event
Expand = false
ResourceTypes = ["Chassis"]
Registries =
[ServerInformation]
ServerIPs = ["https://127.0.0.1:2443"]
UserNames = ["root"]
Passwords = ["0penBmc"]
LoginType = ["Session"]
But I can't always receive the service from EventService/Subscriptions
Attempt 1 of /redfish/v1/EventService/Subscriptions
Response Time for POST to /redfish/v1/EventService/Subscriptions: 0.02355643900227733 seconds.
Unable to subscribe for events with https://127.0.0.1:2443
Traceback (most recent call last):
File "RedfishEventListener_v1.py", line 263, in <module>
response = redfish_utilities.create_event_subscription(my_ctx, config['destination'],
File "/home/charlie/.local/lib/python3.8/site-packages/redfish_utilities/event_service.py", line 212, in create_event_subscription
verify_response( response )
File "/home/charlie/.local/lib/python3.8/site-packages/redfish_utilities/messages.py", line 70, in verify_response
raise RedfishOperationFailedError( "Operation failed: HTTP {}\n{}". format( response. status, exception_string ) )
redfish_utilities.messages.RedfishOperationFailedError: Operation failed: HTTP 400
A general error has occurred. See Resolution for information on how to resolve the error.
The property EventTypes is not in the list of valid properties for the resource.
The property IncludeOriginOfCondition is not in the list of valid properties for the resource.
none
Continuing with Listener.
Listening on 0.0.0.0:443 via HTTPS
Press Ctrl-C to close program
Traceback (most recent call last):
File "RedfishEventListener_v1.py", line 311, in <module>
socket_server = socket.create_server(my_host, family=family)
File "/usr/lib/python3.8/socket.py", line 886, in create_server
raise error(err.errno, msg) from None
PermissionError: [Errno 13] Permission denied (while attempting to bind on address ('0.0.0.0', 443))
|
|
|
Post by mraineri on Feb 24, 2023 14:00:10 GMT
From the error message, it states "The property EventTypes is not in the list of valid properties for the resource." and "The property IncludeOriginOfCondition is not in the list of valid properties for the resource." You'll need to remove the "EventTypes" and "Expand" entries in your config file. By specifying those options, the tool will attempt to specify "EventTypes" and "IncludeOriginOfCondition" in the subscription request. The README file specifies some of these details in the "Configuration" section under "Subscription Details"; most of the parameters are optional, so if you don't need a particular option, then you should remove it from your configuration.
|
|
|
Post by mraineri on Feb 24, 2023 14:27:10 GMT
|
|
|
Post by cccc1680tw on Mar 2, 2023 8:01:53 GMT
Thank you for your assistance! According to the settings you uploaded the latest version, I can run the Redfish Event Listener at present. But I'm not sure how to query the records of Redfihs events, will this service generate any log files? In addition, I am still not sure whether the Destination in SubscriptionDetails is set correctly, but I am sure that when running the Redfish Event Listener, there is a new Subscription in /redfish/v1/EventService/Subscriptions/ in the server. The following records of my operation config.ini settings [Information]
Updated = February 24, 2023
Description = Redfish Event Listener Tool Simple Config
[SystemInformation]
ListenerIP = 0.0.0.0
ListenerPort = 443
UseSSL = on
[CertificateDetails]
certfile = cert.pem
keyfile = server.key
[SubscriptionDetails]
Destination = https://127.0.0.1:2443/
Context = Public
[ServerInformation]
ServerIPs = ["https://127.0.0.1:2443"]
UserNames = ["root"]
Passwords = ["0penBmc"]
LoginType = ["Session"] Status of EventService/Subscriptions when the Redfish Event Listener is not yet running curl -k -H "X-Auth-Token: $token" https://127.0.0.1:2443/edfish/v1/EventService/Subscriptions {
"@odata.id": "/redfish/v1/EventService/Subscriptions",
"@odata.type": "#EventDestinationCollection.EventDestinationCollection",
"Members": [],
"Members@odata.count": 0,
"Name": "Event Destination Collections" Result of successfully running Redfish Event Listener sudo python RedfishEventListener_v1.py
sudo: unable to resolve host openbmc
Redfish Event Listener v1.1.3
ServerIP:: https://127.0.0.1:2443
UserName:: root
Attempt 1 of /redfish/v1/
Response Time for GET to /redfish/v1/: 0.05054431099961221 seconds.
Attempt 1 of /redfish/v1/SessionService/Sessions
Response Time for POST to /redfish/v1/SessionService/Sessions: 0.15434713300055591 seconds.
Login returned code 201: {
"@odata.id": "/redfish/v1/SessionService/Sessions/BTwuTNkpFg",
"@odata.type": "#Session.v1_5_0.Session",
"ClientOriginIPAddress": "10.0.2.2",
"Description": "Manager User Session",
"Id": "BTwuTNkpFg",
"Name": "User Session",
"UserName": "root"
}
Attempt 1 of /redfish/v1/
Response Time for GET to /redfish/v1/: 0.0228347140000551 seconds.
Attempt 1 of /redfish/v1/EventService
Response Time for GET to /redfish/v1/EventService: 0.019904726999811828 seconds.
Attempt 1 of /redfish/v1/EventService/Subscriptions
Response Time for POST to /redfish/v1/EventService/Subscriptions: 0.02195434699933685 seconds.
Subscription is successful for https://127.0.0.1:2443, /redfish/v1/EventService/Subscriptions/1302488251
Continuing with Listener.
Listening on 0.0.0.0:443 via HTTPS
Press Ctrl-C to close program Status of EventService/Subscriptions when successfully running Redfish Event Listener curl -k -H "X-Auth-Token: $token" https://127.0.0.1:2443/edfish/v1/EventService/Subscriptions
{
"@odata.id": "/redfish/v1/EventService/Subscriptions",
"@odata.type": "#EventDestinationCollection.EventDestinationCollection",
"Members": [
{
"@odata.id": "/redfish/v1/EventService/Subscriptions/1302488251"
}
],
"Members@odata.count": 1,
"Name": "Event Destination Collections"
curl -k -H "X-Auth-Token: $token" https://127.0.0.1:2443/edfish/v1/EventService/Subscriptions/1302488251
{
"@odata.id": "/redfish/v1/EventService/Subscriptions/1302488251",
"@odata.type": "#EventDestination.v1_7_0.EventDestination",
"Context": "Public",
"DeliveryRetryPolicy": "TerminateAfterRetries",
"Destination": "https://127.0.0.1:2443/",
"EventFormatType": "Event",
"HttpHeaders": [],
"Id": "1302488251",
"MessageIds": [],
"MetricReportDefinitions": [],
"Name": "Event Destination 1302488251",
"Protocol": "Redfish",
"RegistryPrefixes": [],
"ResourceTypes": [],
"SubscriptionType": "RedfishEvent" Finally, the setting of EventService on openbmc curl -k -H "X-Auth-Token: $token" https://127.0.0.1:2443/edfish/v1/EventService
{
"@odata.id": "/redfish/v1/EventService",
"@odata.type": "#EventService.v1_5_0.EventService",
"Actions": {
"#EventService.SubmitTestEvent": {
"target": "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent"
}
},
"DeliveryRetryAttempts": 3,
"DeliveryRetryIntervalSeconds": 30,
"EventFormatTypes": [
"Event",
"MetricReport"
],
"Id": "EventService",
"Name": "Event Service",
"RegistryPrefixes": [
"Base",
"OpenBMC",
"TaskEvent"
],
"ResourceTypes": [
"Task"
],
"SSEFilterPropertiesSupported": {
"EventFormatType": true,
"MessageId": true,
"MetricReportDefinition": true,
"OriginResource": false,
"RegistryPrefix": true,
"ResourceType": false
},
"ServiceEnabled": true,
"Status": {
"State": "Enabled"
},
"Subscriptions": {
"@odata.id": "/redfish/v1/EventService/Subscriptions"
}
|
|
|
Post by mraineri on Mar 2, 2023 13:09:59 GMT
You don't query for events; the service will send events to you based on its event notification policies. When the listener receives an event, it will display the event to the screen, and create/append a txt logfile of events from that service.
From your output, the "Destination" needs to be corrected. This will contain the listener's info; I see you're using the service's port in the configuration. So, since the listener is using the default port for HTTPS, you can just use "https://127.0.0.1/" as the Destination. Everything else looks good to me though.
If you want to test the subscription, you could use the "SubmitTestEvent" action on the event service. This curl command should generate a test event, which should in turn be sent to the listener.
curl -k -u root:0penBmc -X POST https://127.0.0.1:2443/redfish/v1/EventService/Actions/EventService.SubmitTestEvent -d '{"MessageId": "TestEvent.1.0.Test"}' I've noticed some services might require more than "MessageId" in the action's request; if the above operation fails, we can look at this further and modify your request.
|
|
|
Post by cccc1680tw on Mar 3, 2023 8:48:13 GMT
Thank you for your detailed help and advice.
I currently added some settings you marked in Redfish Event Listener in config.ini.
[Information]
Updated = February 24, 2023
Description = Redfish Event Listener Tool Simple Config
[SystemInformation]
ListenerIP = 0.0.0.0
ListenerPort = 443
UseSSL = on
[CertificateDetails]
certfile = cert.pem
keyfile = server.key
[SubscriptionDetails]
Destination = https://127.0.0.1/
Context = Public
Format = Event
ResourceTypes = ["Task"]
Registries = [
"Base",
"OpenBMC",
"TaskEvent"]
[ServerInformation]
ServerIPs = ["https://127.0.0.1:2443"]
UserNames = ["root"]
Passwords = ["0penBmc"]
LoginType = ["Session"]
It is also currently working.
But using the test command you suggested, but still don't see any response.
Could it be the reason that the MessageId in the newly generated subscription is a null value?
Sorry, I'm a new Redfish developer, please forgive me.
|
|
|
Post by mraineri on Mar 3, 2023 13:05:23 GMT
If you tried using the "SubmitTestEvent" action after updating your config file, the configuration you've specified won't align with the test event. When you add details like "Registries" and "ResourceTypes", you'll constrain the types of events you receive. So, in the case of the test event from the previous post, it specifies a message ID of "TestEvent.1.0.Test"; this would equate to a "registry" of TestEvent, which is not in your configuration list.
At least for testing purposes, it would be good to remove "ResourceTypes" and "Registries" from your configuration for the time being so we can ensure the service sends the test event to you correctly. Once we can confirm that, then you can start adding more configurations to your file to fine-tune the events you'd like to receive.
|
|