首批通过分布式安全可靠测评,为关键业务系统打造
查询主机列表
更新时间:2026-04-14 11:55:54
功能说明
查询主机信息列表。
调用说明
接口约束
调用者需要具备 HOST_VIEWER 权限。
请求路径
GET /api/v2/compute/hosts
请求参数
body:
| 参数 | 类型 | 必选 | 示例值 | 描述 |
|---|---|---|---|---|
| status | StringArray | 否 | ONLINE,NEW | 主机状态,取值范围: |
| keyword | String | 否 | cluster1 | 主机检索关键字,支持模糊匹配,可以匹配如下几种信息: |
| includedServiceType | StringArray | 否 | OB_CLUSTER,OB_PROXY | 主机列表需要包含的服务类型,取值范围: |
| excludedServiceType | StringArray | 否 | OB_CLUSTER,OB_PROXY | 主机列表不能包含的服务类型,取值范围: |
| page | Integer | 否 | 1 | 分页页码,从 1 开始。 |
| size | Integer | 否 | 10 | 请求数据的分页大小。默认值:10,最大值:2000。 |
| sort | String | 否 | id,asc | 请求数据的排序规则。 |
返回结果
基础数据结构
| 参数 | 类型 | 说明 |
|---|---|---|
| data | Object | 请求的数据。 |
| ├─ contents | Array | Host 的数组,详情参见 Host 数据结构。 |
| ├─ page | Object | 分页信息,详情参见 page 数据结构。 |
| successful | Boolean | 请求是否成功。 |
| timestamp | Datetime | 服务端完成请求的时间戳。 |
| duration | Integer | 服务端处理请求的时间(毫秒)。 |
| status | Integer | 符合 HTTP Status 规范的编码。。 |
| traceId | String | 请求的 Trace ID,用于排查问题 |
| server | String | 响应请求的应用服务的地址。 |
Host 数据结构
| 参数 | 类型 | 说明 |
|---|---|---|
| id | Long | 主机 ID。 |
| name | String | 主机名。 |
| alias | String | 主机别名。 |
| description | String | 主机描述信息。 |
| operatingSystem | String | 操作系统。 |
| operatingSystemRelease | String | 操作系统发行版名字。 |
| architecture | String | 硬件架构。 |
| serialNumber | String | 序列号。 |
| innerIpAddress | String | 主机 IP 地址。 |
| sshPort | Integer | SSH 端口。 |
| kind | String | 主机类型,取值范围: |
| publishPorts | String | 端口映射。 |
| services | ObjectArray | ServiceSummary 数组,部署服务汇总信息,详情参见 ServiceSummary 数据结构。 |
| status | String | 主机状态,取值范围: |
| idcId | Long | 机房 ID。 |
| idcName | String | 机房名称。 |
| idcDescription | String | 机房描述信息。 |
| typeId | Long | 机型 ID。 |
| typeName | String | 机型名称。 |
| typeDescription | String | 机型描述信息。 |
| regionId | Long | 区域 ID。 |
| regionName | String | 区域名称。 |
| regionDescription | String | 区域描述信息。 |
| hostAgentId | Long | OCP Agent ID 信息。 |
| hostAgentVersion | String | OCP Agent 版本信息。 |
| hostAgentStatus | String | OCP Agent 状态信息,取值范围: |
| createTime | String | 主机创建时间。 |
| updateTime | String | 主机修改时间。 |
ServiceSummary 数据结构
| 参数 | 类型 | 说明 |
|---|---|---|
| name | String | 服务名称。 |
| version | String | 服务版本。 |
| type | String | 服务类型,取值范围: |
| softwarePackageId | Long | 软件包 ID。 |
page 数据结构
| 参数 | 类型 | 说明 |
|---|---|---|
| totalElements | Integer | 总记录数。 |
| totalPages | Integer | 总页数。 |
| number | Integer | 当前页码。 |
| size | Integer | 当前页大小。 |
示例
请求示例
GET /api/v2/compute/hosts?page=1&size=10
返回示例
{
"data": {
"contents": [
{
"alias": null,
"architecture": "x86_64",
"createTime": "2021-08-10T11:56:16+08:00",
"description": null,
"hostAgentId": 6000001,
"hostAgentStatus": "AVAILABLE",
"hostAgentVersion": "3.1.2-20210812221645",
"id": 3000002,
"idcDescription": null,
"idcId": 1,
"idcName": "bejing1",
"innerIpAddress": "xx.xx.xx.xx",
"kind": "DEDICATED_PHYSICAL_MACHINE",
"name": "OceanBase152105.et15sqa",
"operatingSystem": "4.9.168-018.ali3000.alios7.x86_64",
"operatingSystemRelease": "alios7",
"publishPorts": null,
"regionDescription": null,
"regionId": 1,
"regionName": "beijing",
"serialNumber": null,
"services": [
{
"name": "cluster01:1",
"softwarePackageId": null,
"type": "OB_CLUSTER",
"version": "2.2.76"
}
],
"sshPort": 22,
"status": "ONLINE",
"typeDescription": null,
"typeId": 1,
"typeName": "beijing",
"updateTime": "2021-08-25T15:09:53+08:00"
}
],
"page": {
"number": 1,
"size": 10,
"totalElements": 1,
"totalPages": 1
}
},
"duration": 31,
"server": "a83ad33525",
"status": 200,
"successful": true,
"timestamp": "2021-08-25T17:19:47.311+08:00",
"traceId": "7afbe6e4d7ad403b"
}