×

使用以下精密时间协议 (PTP) 快速事件 REST API v1 端点,将cloud-event-consumer应用程序订阅到由应用程序 Pod 中的cloud-event-proxy容器在https://127.0.0.1:8089/api/ocloudNotifications/v1/发布的 PTP 事件。

PTP 事件 REST API v1 和事件使用者应用程序 Sidecar 是已弃用的功能。已弃用的功能仍然包含在 OpenShift Container Platform 中,并且继续受支持;但是,它将在该产品的未来版本中删除,不建议用于新部署。

有关 OpenShift Container Platform 中已弃用或删除的主要功能的最新列表,请参阅 OpenShift Container Platform 发行说明中的“已弃用和删除的功能”部分。

提供以下 API 端点

PTP 事件 REST API v1 端点

api/ocloudNotifications/v1/subscriptions

HTTP 方法

GET api/ocloudNotifications/v1/subscriptions

描述

返回订阅列表。如果存在订阅,则返回200 OK状态码以及订阅列表。

示例 API 响应
[
 {
  "id": "75b1ad8f-c807-4c23-acf5-56f4b7ee3826",
  "endpointUri": "https://127.0.0.1:9089/event",
  "uriLocation": "https://127.0.0.1:8089/api/ocloudNotifications/v1/subscriptions/75b1ad8f-c807-4c23-acf5-56f4b7ee3826",
  "resource": "/cluster/node/compute-1.example.com/ptp"
 }
]

HTTP 方法

POST api/ocloudNotifications/v1/subscriptions

描述

通过传递相应的有效负载为所需事件创建新的订阅。如果成功创建订阅,或者订阅已经存在,则返回201 Created状态码。您可以订阅以下 PTP 事件

  • lock-state 事件

  • os-clock-sync-state 事件

  • clock-class 事件

  • gnss-sync-status 事件

  • sync-state 事件

表 1. 查询参数
参数 类型

订阅

数据

示例 PTP 事件订阅有效负载
{
  "uriLocation": "https://127.0.0.1:8089/api/ocloudNotifications/v1/subscriptions",
  "resource": "/cluster/node/compute-1.example.com/ptp"
}
示例 PTP lock-state 事件订阅有效负载
{
"endpointUri": "https://127.0.0.1:8989/event",
"resource": "/cluster/node/{node_name}/sync/ptp-status/lock-state"
}
示例 PTP os-clock-sync-state 事件订阅有效负载
{
"endpointUri": "https://127.0.0.1:8989/event",
"resource": "/cluster/node/{node_name}/sync/sync-status/os-clock-sync-state"
}
示例 PTP clock-class 事件订阅有效负载
{
"endpointUri": "https://127.0.0.1:8989/event",
"resource": "/cluster/node/{node_name}/sync/ptp-status/clock-class"
}
示例 PTP gnss-sync-status 事件订阅有效负载
{
"endpointUri": "https://127.0.0.1:8989/event",
"resource": "/cluster/node/{node_name}/sync/gnss-status/gnss-sync-status"
}
示例 sync-state 订阅有效负载
{
"endpointUri": "https://127.0.0.1:8989/event",
"resource": "/cluster/node/{node_name}/sync/sync-status/sync-state"
}

HTTP 方法

DELETE api/ocloudNotifications/v1/subscriptions

描述

删除所有订阅。

示例 API 响应
{
"status": "deleted all subscriptions"
}

api/ocloudNotifications/v1/subscriptions/{subscription_id}

HTTP 方法

GET api/ocloudNotifications/v1/subscriptions/{subscription_id}

描述

返回 ID 为subscription_id的订阅的详细信息。

表 2. 全局路径参数
参数 类型

subscription_id

字符串

示例 API 响应
{
  "id":"48210fb3-45be-4ce0-aa9b-41a0e58730ab",
  "endpointUri": "https://127.0.0.1:9089/event",
  "uriLocation":"https://127.0.0.1:8089/api/ocloudNotifications/v1/subscriptions/48210fb3-45be-4ce0-aa9b-41a0e58730ab",
  "resource":"/cluster/node/compute-1.example.com/ptp"
}

HTTP 方法

DELETE api/ocloudNotifications/v1/subscriptions/{subscription_id}

描述

删除 ID 为subscription_id的订阅。

表 3. 全局路径参数
参数 类型

subscription_id

字符串

示例 API 响应
{
"status": "OK"
}

api/ocloudNotifications/v1/health

HTTP 方法

GET api/ocloudNotifications/v1/health/

描述

返回ocloudNotifications REST API 的健康状态。

示例 API 响应
OK

api/ocloudNotifications/v1/publishers

api/ocloudNotifications/v1/publishers 端点仅可在 PTP Operator 管理的 pod 中的 cloud-event-proxy 容器中访问。应用程序 pod 中的消费者应用程序无法访问它。

HTTP 方法

GET api/ocloudNotifications/v1/publishers

描述

返回集群节点的发行者详细信息列表。系统在相关设备状态发生变化时生成通知。

您可以将设备同步状态订阅结合使用,以提供系统整体同步健康状况的详细视图。

示例 API 响应
[
  {
    "id": "0fa415ae-a3cf-4299-876a-589438bacf75",
    "endpointUri": "https://127.0.0.1:9085/api/ocloudNotifications/v1/dummy",
    "uriLocation": "https://127.0.0.1:9085/api/ocloudNotifications/v1/publishers/0fa415ae-a3cf-4299-876a-589438bacf75",
    "resource": "/cluster/node/compute-1.example.com/sync/sync-status/os-clock-sync-state"
  },
  {
    "id": "28cd82df-8436-4f50-bbd9-7a9742828a71",
    "endpointUri": "https://127.0.0.1:9085/api/ocloudNotifications/v1/dummy",
    "uriLocation": "https://127.0.0.1:9085/api/ocloudNotifications/v1/publishers/28cd82df-8436-4f50-bbd9-7a9742828a71",
    "resource": "/cluster/node/compute-1.example.com/sync/ptp-status/clock-class"
  },
  {
    "id": "44aa480d-7347-48b0-a5b0-e0af01fa9677",
    "endpointUri": "https://127.0.0.1:9085/api/ocloudNotifications/v1/dummy",
    "uriLocation": "https://127.0.0.1:9085/api/ocloudNotifications/v1/publishers/44aa480d-7347-48b0-a5b0-e0af01fa9677",
    "resource": "/cluster/node/compute-1.example.com/sync/ptp-status/lock-state"
  },
  {
    "id": "778da345d-4567-67b0-a43f0-rty885a456",
    "endpointUri": "https://127.0.0.1:9085/api/ocloudNotifications/v1/dummy",
    "uriLocation": "https://127.0.0.1:9085/api/ocloudNotifications/v1/publishers/778da345d-4567-67b0-a43f0-rty885a456",
    "resource": "/cluster/node/compute-1.example.com/sync/gnss-status/gnss-sync-status"
  }
]

api/ocloudNotifications/v1/{resource_address}/CurrentState

HTTP 方法

GET api/ocloudNotifications/v1/cluster/node/{node_name}/sync/ptp-status/lock-state/CurrentState

GET api/ocloudNotifications/v1/cluster/node/{node_name}/sync/sync-status/os-clock-sync-state/CurrentState

GET api/ocloudNotifications/v1/cluster/node/{node_name}/sync/ptp-status/clock-class/CurrentState

GET api/ocloudNotifications/v1/cluster/node/{node_name}/sync/sync-status/sync-state/CurrentState

GET api/ocloudNotifications/v1/cluster/node/{node_name}/sync/gnss-status/gnss-sync-state/CurrentState

描述

返回集群节点的os-clock-sync-stateclock-classlock-stategnss-sync-statussync-state 事件的当前状态。

  • os-clock-sync-state 通知描述主机操作系统时钟同步状态。可以处于LOCKEDFREERUN 状态。

  • clock-class 通知描述 PTP 时钟类的当前状态。

  • lock-state 通知描述 PTP 设备锁定状态的当前状态。可以处于LOCKEDHOLDOVERFREERUN 状态。

  • sync-state 通知描述ptp-status/lock-statesync-status/os-clock-sync-state 端点中同步程度最低者的当前状态。

  • gnss-sync-status 通知描述 GNSS 时钟同步状态。

表 4. 全局路径参数
参数 类型

resource_address

字符串

lock-state API 响应示例
{
  "id": "c1ac3aa5-1195-4786-84f8-da0ea4462921",
  "type": "event.sync.ptp-status.ptp-state-change",
  "source": "/cluster/node/compute-1.example.com/sync/ptp-status/lock-state",
  "dataContentType": "application/json",
  "time": "2023-01-10T02:41:57.094981478Z",
  "data": {
    "version": "1.0",
    "values": [
      {
        "resource": "/cluster/node/compute-1.example.com/ens5fx/master",
        "dataType": "notification",
        "valueType": "enumeration",
        "value": "LOCKED"
      },
      {
        "resource": "/cluster/node/compute-1.example.com/ens5fx/master",
        "dataType": "metric",
        "valueType": "decimal64.3",
        "value": "29"
      }
    ]
  }
}
os-clock-sync-state API 响应示例
{
  "specversion": "0.3",
  "id": "4f51fe99-feaa-4e66-9112-66c5c9b9afcb",
  "source": "/cluster/node/compute-1.example.com/sync/sync-status/os-clock-sync-state",
  "type": "event.sync.sync-status.os-clock-sync-state-change",
  "subject": "/cluster/node/compute-1.example.com/sync/sync-status/os-clock-sync-state",
  "datacontenttype": "application/json",
  "time": "2022-11-29T17:44:22.202Z",
  "data": {
    "version": "1.0",
    "values": [
      {
        "resource": "/cluster/node/compute-1.example.com/CLOCK_REALTIME",
        "dataType": "notification",
        "valueType": "enumeration",
        "value": "LOCKED"
      },
      {
        "resource": "/cluster/node/compute-1.example.com/CLOCK_REALTIME",
        "dataType": "metric",
        "valueType": "decimal64.3",
        "value": "27"
      }
    ]
  }
}
clock-class API 响应示例
{
  "id": "064c9e67-5ad4-4afb-98ff-189c6aa9c205",
  "type": "event.sync.ptp-status.ptp-clock-class-change",
  "source": "/cluster/node/compute-1.example.com/sync/ptp-status/clock-class",
  "dataContentType": "application/json",
  "time": "2023-01-10T02:41:56.785673989Z",
  "data": {
    "version": "1.0",
    "values": [
      {
        "resource": "/cluster/node/compute-1.example.com/ens5fx/master",
        "dataType": "metric",
        "valueType": "decimal64.3",
        "value": "165"
      }
    ]
  }
}
sync-state API 响应示例
{
    "specversion": "0.3",
    "id": "8c9d6ecb-ae9f-4106-82c4-0a778a79838d",
    "source": "/sync/sync-status/sync-state",
    "type": "event.sync.sync-status.synchronization-state-change",
    "subject": "/cluster/node/compute-1.example.com/sync/sync-status/sync-state",
    "datacontenttype": "application/json",
    "time": "2024-08-28T14:50:57.327585316Z",
    "data":
    {
        "version": "1.0",
        "values": [
        {
            "ResourceAddress": "/cluster/node/compute-1.example.com/sync/sync-status/sync-state",
            "data_type": "notification",
            "value_type": "enumeration",
            "value": "LOCKED"
        }]
    }
}
gnss-sync-status API 响应示例
{
  "id": "435e1f2a-6854-4555-8520-767325c087d7",
  "type": "event.sync.gnss-status.gnss-state-change",
  "source": "/cluster/node/compute-1.example.com/sync/gnss-status/gnss-sync-status",
  "dataContentType": "application/json",
  "time": "2023-09-27T19:35:33.42347206Z",
  "data": {
    "version": "1.0",
    "values": [
      {
        "resource": "/cluster/node/compute-1.example.com/ens2fx/master",
        "dataType": "notification",
        "valueType": "enumeration",
        "value": "LOCKED"
      },
      {
        "resource": "/cluster/node/compute-1.example.com/ens2fx/master",
        "dataType": "metric",
        "valueType": "decimal64.3",
        "value": "5"
      }
    ]
  }
}