首批通过分布式安全可靠测评,为关键业务系统打造
查询主机列表
更新时间:2023-08-10 11:45:58
功能说明
查询主机信息列表。
调用说明
接口约束
调用者需要具备 HOST_VIEWER 权限。
请求路径
GET /api/v2/compute/hosts
请求参数
| 参数 | 类型 | 必选 | 示例值 | 描述 |
|---|---|---|---|---|
| status | StringArray | 否 | ONLINE,NEW | 主机状态,有如下状态: * NEW:新添加主机,未安装 OCP Agent 及初始化 * AVAILABLE:主机在线并且空闲 * ONLINE:主机在线并且已部署了服务 * OFFLINE:主机离线 * DELETING:主机删除中 |
| keyword | String | 否 | cluster1 | 主机检索关键字,支持模糊匹配,可以匹配如下几种信息: * hostname:主机名 * innerIpAddress:主机 IP * service:主机上部署的服务信息 |
| includedServiceType | StringArray | 否 | OB_CLUSTER,OB_PROXY | 主机列表需要包含的服务类型,有如下几种服务类型: * OB_CLUSTER:OceanBase 集群 * OB_PROXY:OceanBase proxy * OCP_AGENT:OCP Agent * BACKUP_AGENT:备份 Agent * RESTORE_AGENT:恢复 Agent * BACKUP_RESTORE_AGENT:备份恢复 Agent * OMS:OMS 服务 |
| excludedServiceType | StringArray | 否 | OB_CLUSTER,OB_PROXY | 主机列表不能包含的服务类型,有如下几种服务类型: * OB_CLUSTER:OceanBase 集群 * OB_PROXY:OceanBase proxy * OCP_AGENT:OCP Agent * BACKUP_AGENT:备份 Agent * RESTORE_AGENT:恢复 Agent * BACKUP_RESTORE_AGENT:备份恢复 Agent * OMS:OMS 服务 |
| page | Integer | 否 | 1 | 分页页码,从 1 开始 |
| size | Integer | 否 | 10 | 请求数据的分页大小。 默认值:10 最大值:2000 |
| sort | String | 否 | id,asc | 请求数据的排序规则 |
返回结果
| 参数 | 类型 | 说明 |
|---|---|---|
| data | Object | 请求的数据 |
| ├─ contents | Array | Host 的数组,详细数据结构见下表 |
| ├─ page | Object | 分页信息 |
| successful | Boolean | 请求是否成功 |
| timestamp | Datetime | 服务端完成请求的时间戳 |
| duration | Integer | 服务端处理请求的时间(毫秒) |
| status | Integer | 符合 HTTP Status 规范的编码 |
| traceId | String | 请求的 Trace ID,用于排查问题 |
| server | String | 响应请求的应用服务的地址 |
page 参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| totalElements | Integer | 总记录数 |
| totalPage | Integer | 总页数 |
| number | Integer | 当前页码 |
| size | Integer | 当前页大小 |
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 | 主机类型,有如下两种: * DEDICATED_PHYSICAL_MACHINE:物理机 * DEDICATED_CONTAINER:容器 |
| publishPorts | String | 端口映射 |
| services | ObjectArray | ServiceSummary 数组,部署服务汇总信息 |
| status | String | 主机状态,有如下状态: * NEW:新添加主机,未安装 OCP Agent 及初始化 * AVAILABLE:主机在线并且空闲 * ONLINE:主机在线并且已部署了服务 * OFFLINE:主机离线 * DELETING:主机删除中 |
| 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 状态信息,有如下状态: * AVAILABLE:可用 * RESTARTING:重启中 * STOPPING:停止中 * REINTSTALLING:重装中 * OFFLINE:离线中 * DELETED:已删除 |
| createTime | String | 主机创建时间 |
| updateTime | String | 主机修改时间 |
ServiceSummary 的数据结构
| 参数 | 类型 | 说明 |
|---|---|---|
| name | String | 服务名称 |
| version | String | 服务版本 |
| type | String | 服务类型,有如下几种服务类型: * OB_CLUSTER:OceanBase 集群 * OB_PROXY:OceanBase proxy * OCP_AGENT:OCP Agent * BACKUP_AGENT:备份 Agent * RESTORE_AGENT:恢复 Agent * BACKUP_RESTORE_AGENT:备份恢复 Agent * OMS:OMS 服务 |
| softwarePackageId | Long | 软件包 ID |
示例
请求示例
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"
}