跳到主要内容

POST – 创建订阅

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

请求 URL

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

请求正文

字段类型描述

Destination

字符串

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

如果 Protocol 为 Redfish,则此字段为 HTTP/HTTPS URI。

如果 Protocol 为 SNMPv1,则此字段为 RFC1157 定义的 URI。

如果 Protocol 为 SNMPv3,则此字段为 RFC3411 和 RFC3418 定义的 URI。

如果 Protocol 为 SMTP,则此字段为 RFC5321 定义的 SMTP URI。

Context

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

Protocol

字符串支持的协议为“Redfish”、“SMTP”、“SNMPv1”和“SNMPv3”。

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 陷阱。

创建 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 中启用 SNMPv1 陷阱。

创建 SNMPv2c 陷阱订阅

以下示例是 POST 正文:

{
"Destination": "snmp://10.10.10.10",
"Protocol": "SNMPv2c",
"SNMP": {
"TrapCommunity": "test"
}
}

返回以下示例 JSON 响应:

{
"Description": "This resource represents an event destination for a Redfish implementation.",
"Id": "REST-SNMPv2c-2",
"Name": "REST-SNMPv2c-2",
"@odata.type": "#EventDestination.v1_12_0.EventDestination",
"@odata.id": "/redfish/v1/EventService/Subscriptions/REST-SNMPv2c-2",
"@odata.context": "/redfish/v1/$metadata#EventDestination.EventDestination",
"Protocol": "SNMPv2c",
"@odata.etag": "\"3e29269e00cd2a26e2e\"",
"Context": "",
"Destination": "snmp://10.10.10.10",
"EventFormatType": "Event",
"SubscriptionType": "SNMPTrap",
"SNMP": {
"TrapCommunity": "test"
},
"Status": {
"State": "Enabled"
},
"@Message.ExtendedInfo": [
{
"Resolution": "If failed, retry before meeting the requirement of the security mode.",
"Message": "The value \"snmp://10.10.10.10\" for the property Destination is not recommanded by current security mode Standard.",
"@odata.type": "#Message.v1_1_2.Message",
"MessageArgs": [
"\"snmp://10.10.10.10\"",
"Destination",
"Standard"
],
"MessageId": "LenovoExtendedWarning.1.0.NotRecommandedOperation",
"MessageSeverity": "Warning"
}
]
}

对于 SNMPv3,格式应与 RFC4088 一致:“snmp://<user>@<host>”。如果格式不正确,则返回错误 PropertyValueConflict。

创建 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 陷阱。