跳到主要内容

POST – 创建订阅

创建 Redfish 服务的订阅以将事件发送给订阅者。

请求 URL

POST https://<BMC_IPADDR>/redfish/v1/EventService/Subscriptions

请求正文

字段类型描述

Destination

字符串

此属性应包含要将事件发送到的目标的 URI。

Context

字符串

与事件目标订阅一起存储的由客户端提供的字符串。

Protocol

字符串

“Redfish”

RegistryPrefixes

数组

项:字符串

项数:映射到资源 /redfish/v1/Registries 下的成员

 

RegistryPrefixes[N]

字符串

映射到资源 /redfish/v1/Registries 下的成员

响应正文

用于响应创建的订阅资源,使用 GET 方法引用事件订阅的响应正文。

状态代码

HTTP 状态代码错误消息 ID
201Created
400BadRequest、PropertyValueNotInList
500InternalError

示例

创建 Redfish 协议订阅

以下示例是 POST 正文。
{
"Protocol": "Redfish",
"Context": "Test_Context",
"Destination": "https://192.168.0.2:443",
"RegistryPrefixes": [
"EventRegistry"
]
}

返回以下示例 JSON 响应:

{
"SubscriptionType" : "RedfishEvent",
"HttpHeaders" : [],
"RegistryPrefixes" : [
"EventRegistry"
],
"EventFormatType" : "Event",
"OriginResources@odata.count" : 0,
"OriginResources" : [],
"Id" : "3A048D0E",
"Destination" : "https://192.168.0.2:443",
"Context" : "Test_Context",
"MessageIds" : [],
"SubordinateResources" : null,
"@odata.id" : "/redfish/v1/EventService/Subscriptions/3A048D0E",
"@odata.etag" : "\"1575571584025\"",
"@odata.type" : "#EventDestination.v1_5_0.EventDestination",
"Protocol" : "Redfish",
"Description" : "This resource represents the target of an event subscription, including the types of events subscribed and context to provide to the target in the Event payload.",
"Name" : "Destination",
"ResourceTypes" : []
}

创建 SMTP 协议订阅

以下示例是 POST 正文
{
“Context”: “SMTP user”,
"Destination": "mailto:userid@lenovo.com",
"Protocol": "SMTP"
}

返回以下示例 JSON 响应:
{
"Protocol": "SMTP",
"Description": "This resource represents an event destination for a Redfish implementation.",
"EventFormatType": "Event",
"Id": "REST-SMTP-1",
"Status": {
"State": "Enabled"
},
"Context": "SMTP user",
"@odata.type": "#EventDestination.v1_11_0.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/REST-SMTP-1",
"@odata.etag": "\"363737e9a52729657ae\"",
"Name": "REST-SMTP-1",
"Destination": "mailto:userid@lenovo.com",
"SubscriptionType": "RedfishEvent"
}

创建 SNMPv1 警报订阅

以下示例是 POST 正文
{
"Destination": "snmp://10.10.10.10",
"Protocol": "SNMPv1",
"SNMP": {
"TrapCommunity": "test"
}
}

返回以下示例 JSON 响应:
{
"Protocol": "SNMPv1",
"Id": "REST-SNMPv1-1",
"SNMP": {
"TrapCommunity": "test"
},
"@odata.type": "#EventDestination.v1_8_0.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/REST-SNMPv1-1",
"Destination": "snmp://10.10.10.10",
"Description": "This resource represents an event destination for a Redfish implementation.",
"Context": "",
"Name": "REST-SNMPv1-1",
"Status": {
"State": "Disabled"
},
"@odata.etag": "\"38906ed3cd672966db8\"",
"SubscriptionType": "SNMPTrap",
"EventFormatType": "Event"
}

请注意,如果响应中的“State”为“Disabled”,则需要在 /redfish/v1/Managers/1/NetworkProtocol /Oem/Lenovo/SNMP 中启用 SNMPv1 警报。

创建 SNMPv2c 警报订阅

以下示例是 POST 正文
{
"Protocol": "SNMPv2c",
"Destination": "snmp://10.10.10.11",
"SNMP": {
"TrapCommunity": "TestTrapCommunity"
}
}

返回以下示例 JSON 响应:
{
"SubscriptionType": "SNMPTrap",
"Description": "This resource represents an event destination for a Redfish implementation.",
"Destination": "snmp://10.10.10.11",
"Context": "",
"Status": {
"State": "Enabled"
},
"EventFormatType": "Event",
"Id": "REST-SNMPv2c-1",
"Name": "REST-SNMPv2c-1",
"@odata.type": "#EventDestination.v1_11_2.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/REST-SNMPv2c-1",
"Protocol": "SNMPv2c",
"@odata.etag": "\"3dd4bf8b4ce72a26dff\"",
"@odata.context": "/redfish/v1/$metadata#EventDestination.EventDestination",
"SNMP": {
"TrapCommunity": "TestTrapCommunity"
}
}

请注意,只能创建一个 SNMPv1 和一个 SNMPv2c。

创建 SNMPv3 警报订阅

以下示例是 POST 正文
{
"Destination": "snmp://test@10.10.10.10",
"Protocol": "SNMPv3"
}

返回以下示例 JSON 响应:
{
"Protocol": "SNMPv3",
"Id": "REST-SNMPv3-2",
"SubscriptionType": "SNMPTrap",
"@odata.type": "#EventDestination.v1_8_0.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/REST-SNMPv3-2",
"Destination": "snmp://test@10.10.10.10",
"Description": "This resource represents an event destination for a Redfish implementation.",
"Context": "",
"Name": "test",
"Status": {
"State": "Disabled"
},
"SNMP": {
"TrapCommunity": null
},
"@odata.etag": "\"3b17f6a279c82667a00\"",
"EventFormatType": "Event"
}

请注意,如果响应中的“State”为“Disabled”,则需要在 /redfish/v1/Managers/1/NetworkProtocol /Oem/Lenovo/SNMP 中启用 SNMPv3 警报。请参阅SNMP 管理