根据名称批量更新模板镜像

更新时间:
2025-01-14

根据名称批量更新模板镜像

此接口用于根据模板名称批量更新模板镜像。批量更新模板镜像需要逐一指定待修改的模板,一个模板中目前仅支持配置一个容器镜像。 更新模板镜像不会更新镜像之前配置的启动参数,需要用户确保更新前后两个镜像启动参数的兼容问题。更新时支持根据参数选择是否在更新后对模板进行部署操作。

接口描述

通信协议:HTTP

URL:PUT /api/v1/provision-template/images

传参方式:body

请求参数

字段名 类型 是否必填 说明
templatesTemplate[ ]需要更新的模板数组
actionenum指定在更新后对所有模板进行的部署行为,如果不指定则仅做更新操作
run: 运行
load: 仅创建

Template

字段名 类型 是否必填 说明
namestring需要更新的模板名称
imageRefstring模板 ID 对应的镜像,格式为 name@tag#os
actionenum指定在更新后对当前模板进行的部署行为,如果不指定则仅做更新操作,优先级大于上层
run: 运行
load: 仅创建

响应参数

响应体 data 字段为数组,其中每一项类型如下:

字段名 类型 说明
id?string模板 ID
namestring模板名称
resultboolean更新结果。false 代表失败,true 代表成功
messagestring如果失败,代表失败的错误信息。如果成功,则为 successful
deployResult?DeployResult部署结果

请求示例

curl --location --request PUT 'http://localhost:3001/api/v1/provision-template/images' \
--header 'Content-Type: application/json' \
--data-raw '{
  "templates": [
    {
      "name": "vsoa_demo_syx-v17-Z2dqADAz",
      "imageRef": "vsoa-demo@v1#sylixos",
      "action": "load"
    },
    {
      "name": "vsoa_demo_syx-v17-q185YLYI",
      "imageRef": "vsoa-demo@v1#sylixos"
    },
    {
      "name": "vsoa_demo_syx-v17-un-exist",
      "imageRef": "vsoa-demo@v1#sylixos"
    }
  ],
  "action": "run"
}'

响应示例


{
  "status": 200,
  "message": "success",
  "data": [
    {
      "id": "c5abbebd9701495aadca32f34f7d7b5f",
      "name": "vsoa_demo_syx-v17-Z2dqADAz",
      "result": true,
      "message": "successful",
      "deployResult": {
        "provisionTmplId": "c5abbebd9701495aadca32f34f7d7b5f",
        "provisionId": "cb561633178946f983dbeb1bd006d593",
        "tasks": [
          {
            "id": "0e4017c868784a6bae2404dcec5e0992",
            "imageId": "c3f747be7ceb4191aa54cd9925bde701",
            "nodeId": "c97b12eee6ea4443a8aae4ec708bc178",
            "nodeName": "192.168.64.56",
            "recordId": "04b3348a261d4f1e8f6829c9dcf0bc21"
          },
          {
            "id": "c5b806c4ecf3465a849b8b5071923770",
            "imageId": "c3f747be7ceb4191aa54cd9925bde701",
            "nodeId": "7861a49e379441bea7f15bd5d240e97e",
            "nodeName": "192.168.64.55",
            "recordId": "04b3348a261d4f1e8f6829c9dcf0bc21"
          }
        ],
        "result": "created",
        "error": null
      }
    },
    {
      "id": "22787e60d39648a1a984761731dffbe3",
      "name": "vsoa_demo_syx-v17-q185YLYI",
      "result": true,
      "message": "successful",
      "deployResult": {
        "provisionTmplId": "22787e60d39648a1a984761731dffbe3",
        "provisionId": "f8a295a7d12d46ddab827f3901d2ad3f",
        "tasks": [
          {
            "id": "17618917099946cdbf4670ab5cab61d4",
            "imageId": "c3f747be7ceb4191aa54cd9925bde701",
            "nodeId": "d3221779d3614eb6aed0df800cea4f80",
            "nodeName": "192.168.64.45",
            "recordId": "797ee31329464d0198a898e5a4a96380"
          },
          {
            "id": "a7470dd7c09e4bc99a3d1b77f1edec33",
            "imageId": "c3f747be7ceb4191aa54cd9925bde701",
            "nodeId": "8201c7b2e48c4f12b2981567e2616500",
            "nodeName": "192.168.64.46",
            "recordId": "797ee31329464d0198a898e5a4a96380"
          }
        ],
        "result": "created",
        "error": null
      }
    },
    {
      "name": "vsoa_demo_syx-v17-un-exist",
      "result": false,
      "message": "not exist with name"
    }
  ],
  "fieldErrors": null
}

错误码

具体请参见 错误码说明

文档内容是否对您有所帮助?
有帮助
没帮助