平台服务相关接口

上传平台服务安装包(UploadPlatformServicePackage)

上传平台服务安装包。当前安装包形态为 qcow2,接口会将 qcow2 按镜像导入到镜像服务器,并保存平台服务安装包记录供后续部署使用。

API请求

URLs
PUT zstack/v1/platform-services/packages/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "uploadPlatformServicePackage": {
    "name": "zlr-package",
    "serviceType": "ZLR",
    "artifactType": "Qcow2",
    "url": "file:///data/zlr-zrm-1.0.0.qcow2",
    "backupStorageUuid": "ff081de062bd338eb907962028e64d00"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"uploadPlatformServicePackage":{"name":"zlr-package","serviceType":"ZLR","artifactType":"Qcow2","url":"file:///data/zlr-zrm-1.0.0.qcow2","backupStorageUuid":"ff081de062bd338eb907962028e64d00"}}' http://localhost:8080/zstack/v1/platform-services/packages/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
name String body(包含在uploadPlatformServicePackage结构中) 资源名称 5.1.0
description (可选) String body(包含在uploadPlatformServicePackage结构中) 资源的详细描述 5.1.0
serviceType String body(包含在uploadPlatformServicePackage结构中) 平台服务类型
  • ZCenter
  • ZLR
5.1.0
artifactType (可选) String body(包含在uploadPlatformServicePackage结构中) 安装包形态;当前仅支持 Qcow2
  • Qcow2
5.1.0
version (可选) String body(包含在uploadPlatformServicePackage结构中) 安装包版本号;为空时不记录版本 5.1.0
url String body(包含在uploadPlatformServicePackage结构中) 安装包 URL。支持镜像导入流程可访问的 URL,例如 file://、http(s):// 地址;本地文件上传使用 upload://<fileName> 5.1.0
backupStorageUuid (可选) String body(包含在uploadPlatformServicePackage结构中) 镜像存储UUID 5.1.0
longJobName (可选) String body(包含在uploadPlatformServicePackage结构中) 长任务名称;为空时使用默认任务名称 5.1.0
longJobDescription (可选) String body(包含在uploadPlatformServicePackage结构中) 长任务描述 5.1.0
resourceUuid (可选) String body(包含在uploadPlatformServicePackage结构中) 资源UUID 5.1.0
tagUuids (可选) List body(包含在uploadPlatformServicePackage结构中) 标签UUID列表 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "80387501189d4d6795ab710e32e8d835",
    "name": "zlr-package",
    "serviceType": "ZLR",
    "artifactType": "Qcow2",
    "imageUuid": "5719e30fc3474c3996318b9e6f36cd80",
    "status": "Uploaded",
    "operationState": "Succeeded",
    "progress": 100,
    "uploadFileUrl": "http://127.0.0.1:8001/imagestore/file/direct/upload",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2:20:57 PM"
  }
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventory PlatformServicePackageInventory 详情参考inventory 5.1.0
longJobInventory LongJobInventory 详情参考longJobInventory 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
artifactType String 安装包形态;当前为 Qcow2 5.1.0
imageUuid String 镜像UUID 5.1.0
status String 安装包状态,例如 Uploading、Uploaded、Failed 5.1.0
version String 安装包版本号 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#longJobInventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 2.2.4
name String 资源名称 2.2.4
description String 资源的详细描述 2.2.4
apiId String 用于关联TaskProgress的APIID 2.2.4
jobName String 任务名称 2.2.4
jobData String 任务数据 2.2.4
jobResult String 任务结果 2.2.4
targetResourceUuid String 目标资源UUID 2.2.4
managementNodeUuid String 管理节点UUID 2.2.4
createDate Timestamp 创建时间 2.2.4
lastOpDate Timestamp 最后一次修改时间 2.2.4
state LongJobState 详情参考state 2.2.4
#state
名字 类型 描述 起始版本
name String 资源名称 2.2.4
ordinal int 2.2.4
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
UploadPlatformServicePackageAction action = new UploadPlatformServicePackageAction();
action.name = "zlr-package";
action.serviceType = "ZLR";
action.artifactType = "Qcow2";
action.url = "file:///data/zlr-zrm-1.0.0.qcow2";
action.backupStorageUuid = "ff081de062bd338eb907962028e64d00";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UploadPlatformServicePackageAction.Result res = action.call();
Python SDK
action = UploadPlatformServicePackageAction()
action.name = "zlr-package"
action.serviceType = "ZLR"
action.artifactType = "Qcow2"
action.url = "file:///data/zlr-zrm-1.0.0.qcow2"
action.backupStorageUuid = "ff081de062bd338eb907962028e64d00"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

查询平台服务安装包(QueryPlatformServicePackage)

查询平台服务安装包记录。安装包记录保存服务类型、安装包形态、关联镜像、上传状态和上传阶段进度。

API请求

URLs
GET zstack/v1/platform-services/packages
GET zstack/v1/platform-services/packages/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/platform-services/packages?q=uuid=ff062ec74ff33684b183abeeb7031e00
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/platform-services/packages/373d7c072ed732b091d951fed4c2afeb

可查询字段

运行CLI命令行工具,输入QueryPlatformServicePackage并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "3b1c86aeeab24b1e954feb200b99c375",
      "name": "zlr-package",
      "serviceType": "ZLR",
      "artifactType": "Qcow2",
      "imageUuid": "712e59d33eec4d20a1f319da2ebd38d2",
      "status": "Uploaded",
      "operationState": "Succeeded",
      "progress": 100,
      "uploadFileUrl": "http://127.0.0.1:8001/imagestore/file/direct/upload",
      "createDate": "Nov 14, 2017 2:20:57 PM",
      "lastOpDate": "Nov 14, 2017 2:20:57 PM"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventories List 详情参考inventories 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
artifactType String 安装包形态;当前为 Qcow2 5.1.0
imageUuid String 镜像UUID 5.1.0
status String 安装包状态,例如 Uploading、Uploaded、Failed 5.1.0
version String 安装包版本号 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
QueryPlatformServicePackageAction action = new QueryPlatformServicePackageAction();
action.conditions = asList("uuid=ff062ec74ff33684b183abeeb7031e00");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryPlatformServicePackageAction.Result res = action.call();
Python SDK
action = QueryPlatformServicePackageAction()
action.conditions = ["uuid=ff062ec74ff33684b183abeeb7031e00"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

部署平台服务(DeployPlatformService)

基于已上传的平台服务安装包创建服务虚机并触发后台部署。接口会记录部署阶段,前端刷新页面后可通过获取平台服务实例接口继续展示当前进度。后台部署失败时会尝试自动销毁服务虚机;若清理失败,实例会保留服务虚机UUID,可通过卸载平台服务接口继续清理。

API请求

URLs
PUT zstack/v1/platform-services/packages/{packageUuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "deployPlatformService": {
    "name": "zlr",
    "cpuNum": 2,
    "memorySize": 4294967296,
    "l3NetworkUuids": [
      "ff0defdc65883886b5a760acc322c300"
    ],
    "staticIp": "192.168.0.10",
    "netmask": "255.255.255.0",
    "gateway": "192.168.0.1",
    "language": "zh_CN",
    "mnUsername": "admin"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"deployPlatformService":{"name":"zlr","cpuNum":2,"memorySize":4294967296,"l3NetworkUuids":["ff0defdc65883886b5a760acc322c300"],"staticIp":"192.168.0.10","netmask":"255.255.255.0","gateway":"192.168.0.1","language":"zh_CN","mnUsername":"admin"}}' http://localhost:8080/zstack/v1/platform-services/packages/ff062ec74ff33684b183abeeb7031e00/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
packageUuid String url 平台服务安装包UUID 5.1.0
name (可选) String body(包含在deployPlatformService结构中) 资源名称 5.1.0
description (可选) String body(包含在deployPlatformService结构中) 资源的详细描述 5.1.0
cpuNum Integer body(包含在deployPlatformService结构中) 服务虚机CPU数量 5.1.0
memorySize Long body(包含在deployPlatformService结构中) 服务虚机内存大小,单位为字节 5.1.0
l3NetworkUuids List body(包含在deployPlatformService结构中) 服务虚机接入的分布式端口组UUID列表;当前部署流程按单网卡场景处理 5.1.0
staticIp (可选) String body(包含在deployPlatformService结构中) 服务虚机使用的固定IPv4地址,仅支持单个分布式端口组部署;地址需属于所选分布式端口组地址池且未被占用 5.1.0
netmask (可选) String body(包含在deployPlatformService结构中) 固定IPv4地址对应的子网掩码;为空时尝试从所选分布式端口组推断 5.1.0
gateway (可选) String body(包含在deployPlatformService结构中) 固定IPv4地址对应的网关;为空时尝试从所选分布式端口组推断 5.1.0
clusterUuid (可选) String body(包含在deployPlatformService结构中) 集群UUID 5.1.0
hostUuid (可选) String body(包含在deployPlatformService结构中) 主机UUID 5.1.0
primaryStorageUuidForRootVolume (可选) String body(包含在deployPlatformService结构中) 根硬盘使用的数据存储UUID;为空时使用系统调度结果 5.1.0
allocatorStrategy (可选) String body(包含在deployPlatformService结构中) 虚拟机分配策略;为空时使用系统默认分配策略 5.1.0
language (可选) String body(包含在deployPlatformService结构中) ZCenter部署语言,可选值为zh_CN和en_US;为空时默认使用zh_CN,en_US会作为-I en_US参数传给ZCenter安装器 5.1.0
mnUsername (可选) String body(包含在deployPlatformService结构中) 推送给ZLR的管理节点登录用户名;为空时默认使用admin 5.1.0
mnPassword (可选) String body(包含在deployPlatformService结构中) 兼容保留字段;ZLR部署时后端会按mnUsername从账号数据库读取管理节点登录密码 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "fb2a0d1272394227b101a5d72bc7b134",
    "name": "zlr",
    "serviceType": "ZLR",
    "packageUuid": "0e61188c58014bd28ad1382959fcbdd7",
    "vmInstanceUuid": "f97d64a8e797432d9f954f1de641f618",
    "state": "Deployed",
    "healthStatus": "Healthy",
    "version": "1.0.0",
    "operationState": "Succeeded",
    "progress": 100,
    "lastHealthCheckTime": "Nov 14, 2017 2:20:57 PM",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2:20:57 PM"
  }
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventory PlatformServiceInstanceInventory 详情参考inventory 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
packageUuid String 部署该实例使用的平台服务安装包UUID 5.1.0
vmInstanceUuid String 虚拟机UUID 5.1.0
state String 平台服务实例状态,例如 Deployed、Undeployed 5.1.0
healthStatus String 平台服务健康状态,例如 Healthy、Unhealthy、Unknown 5.1.0
version String 平台服务运行版本;部署或健康检查成功后从服务虚机获取 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
lastHealthCheckTime Timestamp 最近一次健康检查时间 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
DeployPlatformServiceAction action = new DeployPlatformServiceAction();
action.packageUuid = "ff062ec74ff33684b183abeeb7031e00";
action.name = "zlr";
action.cpuNum = 2;
action.memorySize = 4294967296;
action.l3NetworkUuids = asList("ff0defdc65883886b5a760acc322c300");
action.staticIp = "192.168.0.10";
action.netmask = "255.255.255.0";
action.gateway = "192.168.0.1";
action.language = "zh_CN";
action.mnUsername = "admin";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeployPlatformServiceAction.Result res = action.call();
Python SDK
action = DeployPlatformServiceAction()
action.packageUuid = "ff062ec74ff33684b183abeeb7031e00"
action.name = "zlr"
action.cpuNum = 2
action.memorySize = 4294967296
action.l3NetworkUuids = [ff0defdc65883886b5a760acc322c300]
action.staticIp = "192.168.0.10"
action.netmask = "255.255.255.0"
action.gateway = "192.168.0.1"
action.language = "zh_CN"
action.mnUsername = "admin"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

获取平台服务实例(GetPlatformServiceInstances)

获取平台服务实例列表,用于页面刷新后恢复部署进度、查看健康状态以及定位关联服务虚机。

API请求

URLs
GET zstack/v1/platform-services/instances
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/platform-services/instances?serviceType=ZLR
参数列表
名字 类型 位置 描述 可选值 起始版本
serviceType (可选) String query 平台服务类型;为空时返回所有平台服务实例
  • ZCenter
  • ZLR
5.1.0
systemTags (可选) List query 系统标签 5.1.0
userTags (可选) List query 用户标签 5.1.0

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "2ea3e337833942678c063a8fdc85de6d",
      "name": "zlr",
      "serviceType": "ZLR",
      "packageUuid": "a28a14344a604c39b337800bf6e86e1c",
      "vmInstanceUuid": "aae71df9e224410fbf43aada6f21c961",
      "state": "Deployed",
      "healthStatus": "Healthy",
      "version": "1.0.0",
      "operationState": "Succeeded",
      "progress": 100,
      "lastHealthCheckTime": "Nov 14, 2017 2:20:57 PM",
      "createDate": "Nov 14, 2017 2:20:57 PM",
      "lastOpDate": "Nov 14, 2017 2:20:57 PM"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventories List 详情参考inventories 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
packageUuid String 部署该实例使用的平台服务安装包UUID 5.1.0
vmInstanceUuid String 虚拟机UUID 5.1.0
state String 平台服务实例状态,例如 Deployed、Undeployed 5.1.0
healthStatus String 平台服务健康状态,例如 Healthy、Unhealthy、Unknown 5.1.0
version String 平台服务运行版本;部署或健康检查成功后从服务虚机获取 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
lastHealthCheckTime Timestamp 最近一次健康检查时间 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
GetPlatformServiceInstancesAction action = new GetPlatformServiceInstancesAction();
action.serviceType = "ZLR";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetPlatformServiceInstancesAction.Result res = action.call();
Python SDK
action = GetPlatformServiceInstancesAction()
action.serviceType = "ZLR"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

获取平台服务虚拟机(GetPlatformServiceVmInstances)

获取指定平台服务实例关联的服务虚机。平台服务虚机会从普通虚拟机查询结果中隐藏,前端需要通过该接口查看。

API请求

URLs
GET zstack/v1/platform-services/instances/{uuid}/vm-instances
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/platform-services/instances/ff0e6f5e01e23b1fbd616d28a9280400/vm-instances?
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 平台服务实例UUID 5.1.0
systemTags (可选) List query 系统标签 5.1.0
userTags (可选) List query 用户标签 5.1.0

API返回

返回示例
{
  "inventories": [
    {}
  ]
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventories List 详情参考inventories 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 0.6
name String 资源名称 0.6
description String 资源的详细描述 0.6
zoneUuid String 数据中心 UUID 0.6
clusterUuid String 集群 UUID 0.6
imageUuid String 镜像 UUID 0.6
hostUuid String 主机 UUID 0.6
lastHostUuid String 上一次启动的主机 UUID 0.6
instanceOfferingUuid String 计算规格 UUID, 已废弃 0.6
rootVolumeUuid String 根硬盘 UUID 0.6
platform String 虚拟机的平台, 是 Windows / Linux 还是其它 0.6
architecture String 虚拟机架构, 是 x86_64 / aarch64 还是其它 0.6
defaultL3NetworkUuid String 默认使用的分布式端口组 UUID 0.6
type String 虚拟机类型, 是用户使用虚拟机还是平台特殊用途的虚拟机 0.6
hypervisorType String 虚拟机虚拟化类型, 一般为 KVM 0.6
memorySize Long 内存大小 0.6
cpuNum Integer CPU 数量 0.6
cpuSpeed Long CPU 速度 0.6
allocatorStrategy String 虚拟机分配策略 0.6
createDate Timestamp 创建时间 0.6
lastOpDate Timestamp 最后一次修改时间 0.6
state String 虚拟机是否启用的状态 0.6
guestOsType String 虚拟机宿主操作系统类型 3.11.2
vmNics List 详情参考vmNics 0.6
allVolumes List 详情参考allVolumes 0.6
vmCdRoms List 详情参考vmCdRoms 0.6
#vmNics
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.17.13
vmInstanceUuid String 虚拟机UUID 3.17.13
l3NetworkUuid String 分布式端口组UUID 3.17.13
ip String 3.17.13
mac String 3.17.13
hypervisorType String 3.17.13
netmask String 3.17.13
gateway String 3.17.13
metaData String 3.17.13
ipVersion Integer 3.17.13
driverType String 3.17.13
internalName String 3.17.13
deviceId Integer 3.17.13
type String 3.17.13
state String 网卡状态 3.17.13
createDate Timestamp 创建时间 3.17.13
lastOpDate Timestamp 最后一次修改时间 3.17.13
usedIps List 详情参考usedIps 3.17.13
#usedIps
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 4.10.0
ipRangeUuid String IP段UUID 4.10.0
l3NetworkUuid String 分布式端口组UUID 4.10.0
ipVersion Integer IP协议号 4.10.0
ip String IP地址 4.10.0
netmask String 子网掩码 4.10.0
gateway String 网关地址 4.10.0
usedFor String 分配原因 4.10.0
ipInLong long Long存储的IP地址,仅ipv4有效 4.10.0
vmNicUuid String 虚拟机网卡UUID 4.10.0
createDate Timestamp 创建时间 4.10.0
lastOpDate Timestamp 最后一次修改时间 4.10.0
#allVolumes
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.17.13
name String 资源名称 3.17.13
description String 资源的详细描述 3.17.13
primaryStorageUuid String 数据存储UUID 3.17.13
vmInstanceUuid String 虚拟机UUID 3.17.13
diskOfferingUuid String 硬盘规格UUID 3.17.13
rootImageUuid String 3.17.13
installPath String 3.17.13
type String 3.17.13
format String 3.17.13
size Long 3.17.13
actualSize Long 3.17.13
deviceId Integer 3.17.13
state String 3.17.13
status String 3.17.13
createDate Timestamp 创建时间 3.17.13
lastOpDate Timestamp 最后一次修改时间 3.17.13
isShareable Boolean 3.17.13
volumeQos String 3.17.13
lastDetachDate Timestamp 3.17.13
lastVmInstanceUuid String 3.17.13
encrypted Boolean 5.1.0
#vmCdRoms
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 3.17.13
vmInstanceUuid String 虚拟机UUID 3.17.13
deviceId Integer 3.17.13
isoUuid String 3.17.13
isoInstallPath String 3.17.13
name String 资源名称 3.17.13
description String 资源的详细描述 3.17.13
createDate Timestamp 创建时间 3.17.13
lastOpDate Timestamp 最后一次修改时间 3.17.13
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
GetPlatformServiceVmInstancesAction action = new GetPlatformServiceVmInstancesAction();
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetPlatformServiceVmInstancesAction.Result res = action.call();
Python SDK
action = GetPlatformServiceVmInstancesAction()
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

检查平台服务健康状态(CheckPlatformServiceHealth)

对已部署的平台服务实例执行一次健康检查。ZCenter 通过服务虚机内的 cmp-ctl inspection 判断健康状态,ZLR 通过 zlr/zrm systemd 服务状态判断健康状态。

API请求

URLs
PUT zstack/v1/platform-services/instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "checkPlatformServiceHealth": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"checkPlatformServiceHealth":{}}' http://localhost:8080/zstack/v1/platform-services/instances/ff0e6f5e01e23b1fbd616d28a9280400/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 平台服务实例UUID 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "a20c329f4373444b81801bae4da83550",
    "name": "zlr",
    "serviceType": "ZLR",
    "packageUuid": "f81e3a5c1d5240658564b6c25a7d6e8b",
    "vmInstanceUuid": "e884993195df45d4a8514296098ccc7f",
    "state": "Deployed",
    "healthStatus": "Healthy",
    "version": "1.0.0",
    "operationState": "Succeeded",
    "progress": 100,
    "lastHealthCheckTime": "Nov 14, 2017 2:20:57 PM",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2:20:57 PM"
  }
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventory PlatformServiceInstanceInventory 详情参考inventory 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
packageUuid String 部署该实例使用的平台服务安装包UUID 5.1.0
vmInstanceUuid String 虚拟机UUID 5.1.0
state String 平台服务实例状态,例如 Deployed、Undeployed 5.1.0
healthStatus String 平台服务健康状态,例如 Healthy、Unhealthy、Unknown 5.1.0
version String 平台服务运行版本;部署或健康检查成功后从服务虚机获取 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
lastHealthCheckTime Timestamp 最近一次健康检查时间 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
CheckPlatformServiceHealthAction action = new CheckPlatformServiceHealthAction();
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckPlatformServiceHealthAction.Result res = action.call();
Python SDK
action = CheckPlatformServiceHealthAction()
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

卸载平台服务(UndeployPlatformService)

卸载平台服务实例,并删除其关联的服务虚机资源。安装包记录和关联镜像不会随实例卸载一起删除。

API请求

URLs
PUT zstack/v1/platform-services/instances/{uuid}/actions
Headers
Authorization: OAuth the-session-uuid
Body
{
  "undeployPlatformService": {},
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"undeployPlatformService":{}}' http://localhost:8080/zstack/v1/platform-services/instances/ff0e6f5e01e23b1fbd616d28a9280400/actions
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 平台服务实例UUID 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "9492259135a04927b5bf93de67695ef8",
    "name": "zlr",
    "serviceType": "ZLR",
    "packageUuid": "4a4622a797f04fe79e73c7274d45e0c1",
    "vmInstanceUuid": "16d489e3993545848c95cb9770301943",
    "state": "Deployed",
    "healthStatus": "Healthy",
    "version": "1.0.0",
    "operationState": "Succeeded",
    "progress": 100,
    "lastHealthCheckTime": "Nov 14, 2017 2:20:57 PM",
    "createDate": "Nov 14, 2017 2:20:57 PM",
    "lastOpDate": "Nov 14, 2017 2:20:57 PM"
  }
}
名字 类型 描述 起始版本
success boolean 是否成功 5.1.0
inventory PlatformServiceInstanceInventory 详情参考inventory 5.1.0
error ErrorCode 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
name String 资源名称 5.1.0
description String 资源的详细描述 5.1.0
serviceType String 平台服务类型,例如 ZCenter 或 ZLR 5.1.0
packageUuid String 部署该实例使用的平台服务安装包UUID 5.1.0
vmInstanceUuid String 虚拟机UUID 5.1.0
state String 平台服务实例状态,例如 Deployed、Undeployed 5.1.0
healthStatus String 平台服务健康状态,例如 Healthy、Unhealthy、Unknown 5.1.0
version String 平台服务运行版本;部署或健康检查成功后从服务虚机获取 5.1.0
operationState String 当前活跃操作状态;由 TaskProgress 聚合生成,例如 Running、Succeeded、Failed 5.1.0
currentStage String 当前活跃操作阶段;由 TaskProgress 聚合生成 5.1.0
currentStageIndex Integer 当前活跃操作阶段序号;由 TaskProgress 聚合生成 5.1.0
totalStages Integer 当前活跃操作总阶段数;由 TaskProgress 聚合生成 5.1.0
progress Integer 当前活跃操作进度,取值范围 0 到 100;由 TaskProgress 聚合生成 5.1.0
currentStep String 当前活跃操作步骤说明;由 TaskProgress 聚合生成 5.1.0
lastError String 最近一次失败原因;操作成功时为空 5.1.0
lastHealthCheckTime Timestamp 最近一次健康检查时间 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
UndeployPlatformServiceAction action = new UndeployPlatformServiceAction();
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UndeployPlatformServiceAction.Result res = action.call();
Python SDK
action = UndeployPlatformServiceAction()
action.uuid = "ff0e6f5e01e23b1fbd616d28a9280400"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

删除平台服务安装包(DeletePlatformServicePackage)

删除平台服务安装包记录,并清理其关联的镜像资源。若该安装包仍被平台服务实例使用,接口会拒绝删除。

API请求

URLs
DELETE zstack/v1/platform-services/packages/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X DELETE http://localhost:8080/zstack/v1/platform-services/packages/ff062ec74ff33684b183abeeb7031e00?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 平台服务安装包UUID 5.1.0
deleteMode (可选) String query 删除模式,支持 Permissive / Enforcing,默认为 Permissive 5.1.0
systemTags (可选) List query 系统标签 5.1.0
userTags (可选) List query 用户标签 5.1.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:

{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeletePlatformServicePackageAction action = new DeletePlatformServicePackageAction();
action.uuid = "ff062ec74ff33684b183abeeb7031e00";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeletePlatformServicePackageAction.Result res = action.call();
Python SDK
action = DeletePlatformServicePackageAction()
action.uuid = "ff062ec74ff33684b183abeeb7031e00"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

外部服务配置相关接口

新建外部服务配置(AddExternalServiceConfiguration)

新建外部服务配置

API请求

URLs
POST zstack/v1/external/service/configurations
Headers
Authorization: OAuth the-session-uuid
Body
{
  "params": {
    "externalServiceType": "Prometheus2",
    "configuration": "{}",
    "description": "description"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X POST -d '{"params":{"externalServiceType":"Prometheus2","configuration":"{}","description":"description"}}' http://localhost:8080/zstack/v1/external/service/configurations
参数列表
名字 类型 位置 描述 可选值 起始版本
externalServiceType String body(包含在params结构中) 外部服务类型, 例如 Prometheus2 5.1.0
configuration String body(包含在params结构中) 外部服务配置, 使用 json 格式。若配置中包含 remote_write.basic_auth.password 等凭据,系统会按原文保存;查询外部服务配置时 password 会脱敏为 ****** 返回。新增配置时不得提交脱敏值 ******,需提交真实密码 5.1.0
description (可选) String body(包含在params结构中) 资源的详细描述 5.1.0
resourceUuid (可选) String body(包含在params结构中) 资源UUID 5.1.0
tagUuids (可选) List body(包含在params结构中) 标签UUID列表 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "66004d1914e733fd8236e0916f43d860",
    "serviceType": "Prometheus2",
    "configuration": "{}"
  }
}
名字 类型 描述 起始版本
success boolean 操作是否成功 5.1.0
inventory ExternalServiceConfigurationInventory 详情参考inventory 5.1.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
serviceType String 外部服务类型, 如 Prometheus2, FluentBitServer 5.1.0
configuration String 外部服务配置, 使用 json 格式。若已保存配置包含 remote_write.basic_auth.password 等凭据,查询结果中的 password 会脱敏为 ****** 返回;如需通过 Update 回写该脱敏值,系统会保留对应 remote_write 已保存的旧密码 5.1.0
description String 资源的详细描述 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
AddExternalServiceConfigurationAction action = new AddExternalServiceConfigurationAction();
action.externalServiceType = "Prometheus2";
action.configuration = "{}";
action.description = "description";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddExternalServiceConfigurationAction.Result res = action.call();
Python SDK
action = AddExternalServiceConfigurationAction()
action.externalServiceType = "Prometheus2"
action.configuration = "{}"
action.description = "description"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

删除外部服务配置(DeleteExternalServiceConfiguration)

删除外部服务配置

API请求

URLs
DELETE zstack/v1/external/service/configurations/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X DELETE http://localhost:8080/zstack/v1/external/service/configurations/aa1a4fca6262310aa6b780018ba346df?deleteMode=Permissive
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 5.1.0
deleteMode (可选) String query 删除模式(Permissive / Enforcing,Permissive) 5.1.0
systemTags (可选) List query 系统标签 5.1.0
userTags (可选) List query 用户标签 5.1.0

API返回

该API成功时返回一个空的JSON结构{},出错时返回的JSON结构包含一个error字段,例如:

{
	"error": {
		"code": "SYS.1001",
		"description": "A message or a operation timeout",
		"details": "Create VM on KVM timeout after 300s"
	}
}

SDK示例

Java SDK
DeleteExternalServiceConfigurationAction action = new DeleteExternalServiceConfigurationAction();
action.uuid = "aa1a4fca6262310aa6b780018ba346df";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteExternalServiceConfigurationAction.Result res = action.call();
Python SDK
action = DeleteExternalServiceConfigurationAction()
action.uuid = "aa1a4fca6262310aa6b780018ba346df"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

查询外部服务配置(QueryExternalServiceConfiguration)

查询外部服务配置

API请求

URLs
GET zstack/v1/external/service/configurations
GET zstack/v1/external/service/configurations/{uuid}
Headers
Authorization: OAuth the-session-uuid
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/external/service/configurations?q=uuid=efca0d027c943d91bbf524e297a17029
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X GET http://localhost:8080/zstack/v1/external/service/configurations/c8effcfb93a43e138e12b67881cb487f

可查询字段

运行CLI命令行工具,输入QueryExternalServiceConfiguration并按Tab键查看所有可查询字段以及可跨表查询的资源名。

API返回

返回示例
{
  "inventories": [
    {
      "uuid": "249687cb3ea3309f9f0eafde752ea08b",
      "serviceType": "Prometheus2",
      "configuration": "{}"
    }
  ]
}
名字 类型 描述 起始版本
success boolean 5.1.0
inventories List 详情参考inventories 5.1.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 5.1.0
#inventories
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
serviceType String 外部服务类型, 如 Prometheus2, FluentBitServer 5.1.0
configuration String 外部服务配置, 使用 json 格式。若已保存配置包含 remote_write.basic_auth.password 等凭据,查询结果中的 password 会脱敏为 ****** 返回;如需通过 Update 回写该脱敏值,系统会保留对应 remote_write 已保存的旧密码 5.1.0
description String 资源的详细描述 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
QueryExternalServiceConfigurationAction action = new QueryExternalServiceConfigurationAction();
action.conditions = asList("uuid=a975960c59c83af38c48aad79b966b4e");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryExternalServiceConfigurationAction.Result res = action.call();
Python SDK
action = QueryExternalServiceConfigurationAction()
action.conditions = ["uuid=10ffe79c134332b585c2af7eb5a22847"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()

更新外部服务配置(UpdateExternalServiceConfiguration)

更新外部服务配置

API请求

URLs
PUT zstack/v1/external/service/configurations/{uuid}
Headers
Authorization: OAuth the-session-uuid
Body
{
  "updateExternalServiceConfiguration": {
    "description": "description",
    "configuration": "{}"
  },
  "systemTags": [],
  "userTags": []
}
Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" -H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" -X PUT -d '{"updateExternalServiceConfiguration":{"description":"description","configuration":"{}"}}' http://localhost:8080/zstack/v1/external/service/configurations/9a3118bffd913ea68caa76b9a668837d
参数列表
名字 类型 位置 描述 可选值 起始版本
uuid String url 资源的UUID,唯一标示该资源 5.1.0
description (可选) String body(包含在updateExternalServiceConfiguration结构中) 资源的详细描述 5.1.0
configuration (可选) String body(包含在updateExternalServiceConfiguration结构中) 外部服务配置内容。若 remote_write.basic_auth.password 使用查询结果中的脱敏值 ******,系统会保留该 remote_write 对应位置已保存的旧密码;如需修改密码,请提交真实密码 5.1.0
systemTags (可选) List body 系统标签 5.1.0
userTags (可选) List body 用户标签 5.1.0

API返回

返回示例
{
  "inventory": {
    "uuid": "da66ea66a447381db5295a14a5c62b2b"
  }
}
名字 类型 描述 起始版本
success boolean 5.1.0
inventory ExternalServiceConfigurationInventory 详情参考inventory 5.1.0
error ErrorCode 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error 5.1.0
#inventory
名字 类型 描述 起始版本
uuid String 资源的UUID,唯一标示该资源 5.1.0
serviceType String 外部服务类型, 如 Prometheus2, FluentBitServer 5.1.0
configuration String 外部服务配置, 使用 json 格式。若已保存配置包含 remote_write.basic_auth.password 等凭据,查询结果中的 password 会脱敏为 ****** 返回;如需通过 Update 回写该脱敏值,系统会保留对应 remote_write 已保存的旧密码 5.1.0
description String 资源的详细描述 5.1.0
createDate Timestamp 创建时间 5.1.0
lastOpDate Timestamp 最后一次修改时间 5.1.0
#error
名字 类型 描述 起始版本
code String 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 0.6
description String 错误的概要描述 0.6
details String 错误的详细信息 0.6
elaboration String 保留字段,默认为null 0.6
opaque LinkedHashMap 保留字段,默认为null 0.6
cause ErrorCode 根错误,引发当前错误的源错误,若无原错误,该字段为null 0.6

SDK示例

Java SDK
UpdateExternalServiceConfigurationAction action = new UpdateExternalServiceConfigurationAction();
action.uuid = "9a3118bffd913ea68caa76b9a668837d";
action.description = "description";
action.configuration = "{}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateExternalServiceConfigurationAction.Result res = action.call();
Python SDK
action = UpdateExternalServiceConfigurationAction()
action.uuid = "9a3118bffd913ea68caa76b9a668837d"
action.description = "description"
action.configuration = "{}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
res = action.call()
开发手册 | ZStack ZSphere · ZVF | ZStack 资源中心