跳转到主要内容
资源中心/资源编排/资源编排相关接口
POSTCloudFormation Operations起始版本 2.5.0同步需要认证

创建资源栈

创建资源栈

调试可用性

在线调试

使用当前认证信息和示例参数提交 Mock 请求。

请求参数

请求体字段

  • paramsObject必填

    请求体参数结构

    • nameString必填

      资源名称

    • descriptionString

      资源的详细描述

    • typeString

      堆栈版本,默认为zstack

    • rollbackBoolean

      堆栈创建失败是否回滚,默认回滚

    • templateContentString

      堆栈内容,json字符串Note: 与参数templateUuid二选一

    • templateUuidString

      模板UUIDNote: 与参数templateContent二选一

    • parametersString必填

      参数列表,json字符串

    • resourceUuidString

      资源的唯一UUID

  • systemTagsList

    系统标签

  • userTagsList

    用户标签

响应状态

200 OK

该 API 成功时返回以下响应结构。

  • errorErrorCode必填

    错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error

    • codeString必填

      错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001

    • descriptionString必填

      错误的概要描述

    • detailsString必填

      错误的详细信息

    • elaborationString必填

      保留字段,默认为null

    • opaqueLinkedHashMap必填

      保留字段,默认为null

    • causeErrorCode必填

      根错误,引发当前错误的源错误,若无原错误,该字段为null

  • inventoryResourceStackInventory必填

    详情参考inventory

    • uuidString必填

      资源的UUID,唯一标示该资源

    • nameString必填

      资源名称

    • descriptionString必填

      资源的详细描述

    • versionString必填

      堆栈版本

    • typeString必填

      堆栈类型,默认为zstack

    • templateContentString必填

      资堆栈内容,json字符串

    • paramContentString必填

      堆栈对应的参数列表,json字符串

    • statusString必填

      堆栈状态

    • reasonString必填

      堆栈创建失败的原因

    • enableRollbackboolean必填

      堆栈创建失败时是否回滚

    • createDateTimestamp必填

      创建时间

    • lastOpDateTimestamp必填

      最后一次修改时间

请求地址

POST/zstack/v1/cloudformation/stack

/zstack/v1/cloudformation/stack

操作 ID

CreateResourceStack

永久链接

请求示例

curl -X POST 'http://{host}/zstack/v1/cloudformation/stack' -H 'Authorization: OAuth {sessionUuid}' -H 'Content-Type: application/json;charset=UTF-8' -d '{"params":{"name":"<name>","description":"<description>","type":"<type>","rollback":true,"templateContent":"<templateContent>","templateUuid":"<templateUuid>","parameters":"<parameters>","resourceUuid":"<resourceUuid>"},"systemTags":["<systemTags>"],"userTags":["<userTags>"]}'

响应示例

200
{ "inventory": { "uuid": "d6ad19356c623599a29140e063c18d74", "name": "test", "description": "description", "version": "2018-06-18", "type": "zstack", "templateContent": "{ \"ZStackTemplateFormatVersion\" : \"2018-06-18\", \"Description\": \"Example for create a group vm instance in zstack.\", \"Parameters\" : { \"imageUuid\": { \"Type\" : \"String\", \"Description\": \"Image Uuid, represents the image resource to startup one vm instance\" }, \"instanceOfferingUuid\": { \"Type\": \"String\", \"Description\": \"The instance offering uuid\" }, \"l3NetworkUuid\": { \"Type\": \"String\", \"Description\": \"The l3 network uuid\" }, \"DiskOfferingUuid\": { \"Type\": \"String\", \"Description\": \"DiskOffering for empty disk\" }, \"PrimaryStorageUuid\": { \"Type\": \"String\", \"Description\": \"primarystorage for initial disk\" }, \"HostUuid\": { \"Type\": \"String\", \"Description\": \"host for initial disk\" } }, \"Resources\" : { \"WebServer1\": { \"Type\": \"ZStack::Resource::VmInstance\", \"Properties\": { \"name\" : \"vm\", \"imageUuid\" : {\"Ref\": \"imageUuid\"}, \"instanceOfferingUuid\": {\"Ref\": \"instanceOfferingUuid\"}, \"l3NetworkUuids\": [{\"Ref\": \"l3NetworkUuid\"}] }, \"DeletionPolicy\": \"Retain\" }, \"WebServer2\": { \"Type\": \"ZStack::Resource::VmInstance\", \"Properties\": { \"name\" : \"vm-2\", \"imageUuid\" : {\"Ref\": \"imageUuid\"}, \"instanceOfferingUuid\": {\"Ref\": \"instanceOfferingUuid\"}, \"l3NetworkUuids\": [{\"Ref\": \"l3NetworkUuid\"}] }, \"DependsOn\": [{\"Ref\": \"WebServer1\"}] }, \"EmptyVolume\": { \"Type\": \"ZStack::Resource::DataVolume\", \"Properties\": { \"name\" : \"empty-volume\", \"diskOfferingUuid\": {\"Ref\": \"DiskOfferingUuid\"}, \"primaryStorageUuid\": {\"Ref\": \"PrimaryStorageUuid\"}, \"systemTags\": [{\"Fn::Join\": [\"::\", [\"localStorage\", \"hostUuid\", {\"Ref\": \"HostUuid\"}]]}] }, \"DependsOn\": [{\"Ref\": \"WebServer2\"}] }, \"AttachDataVolumeToVm\": { \"Type\": \"ZStack::Action::AttachDataVolumeToVm\", \"Properties\": { \"vmInstanceUuid\": {\"Fn::GetAtt\" : [\"WebServer1\", \"uuid\"]}, \"volumeUuid\": {\"Fn::GetAtt\" : [\"EmptyVolume\", \"uuid\"]} } } }, \"Outputs\": { \"VmInstance\": { \"Description\" : \"print vm instance\", \"Value\" : {\"Ref\": \"WebServer1\"} } }}", "paramContent": "{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}", "status": "Created", "enableRollback": true } }

变更历史

此 API 暂无变更历史记录。

查看全部变更历史