CloudFormation Operations
AddStackTemplate
API Request
URLs
POST zstack/v1/cloudformation/templateHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "stack",
"description": "description",
"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"stack","description":"description","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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"}}' \
http://localhost:8080/zstack/v1/cloudformation/templateRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 2.5.0 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 2.5.0 | |
| type | String | body (contained in the params structure) | Optional. The template type. Default type: zstack. |
|
2.5.0 |
| templateContent | String | body (contained in the params structure) | The template content, which is a JSON string. | 2.5.0 | |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"inventory": {
"uuid": "9e3dd776d9ed3c048b74b930aadded5d",
"name": "stack",
"type": "zstack",
"version": "2018-06-18",
"state": true,
"content": "{ \"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventory | StackTemplateInventory | See inventory. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 0.6 |
| description | String | The brief description of the error. | 0.6 |
| details | String | The details about the error. | 0.6 |
| elaboration | String | The reserved field. Default value: null. | 0.6 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 0.6 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 0.6 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| type | String | The template content, which is a JSON string. | 2.5.0 |
| version | String | The template version. | 2.5.0 |
| state | Boolean | Whether the template is available. | 2.5.0 |
| content | String | The template content, which is a JSON string. | 2.5.0 |
| md5sum | String | The MD5 checksum value of the content field. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
AddStackTemplateAction action = new AddStackTemplateAction();
action.name = "stack";
action.description = "description";
action.type = "zstack";
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddStackTemplateAction.Result res = action.call();Python
SDK
AddStackTemplateAction action = AddStackTemplateAction()
action.name = "stack"
action.description = "description"
action.type = "zstack"
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddStackTemplateAction.Result res = action.call()DeleteStackTemplate
API Request
URLs
DELETE zstack/v1/cloudformation/template/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/cloudformation/template/dbeed1e724c13eb49650b3bdf7993d7bRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.5.0 | |
| deleteMode | String | body | Optional. The delete mode. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeleteStackTemplateAction action = new DeleteStackTemplateAction();
action.uuid = "dbeed1e724c13eb49650b3bdf7993d7b";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteStackTemplateAction.Result res = action.call();Python
SDK
DeleteStackTemplateAction action = DeleteStackTemplateAction()
action.uuid = "dbeed1e724c13eb49650b3bdf7993d7b"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteStackTemplateAction.Result res = action.call()QueryStackTemplate
API Request
URLs
GET zstack/v1/cloudformation/template
GET zstack/v1/cloudformation/template/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/template?q=name=testcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/template/285b46cc67623c6d92eebc1ecab8f139Queryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryStackTemplate, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "5c1bb041907e3f29a27c7818e7fd07de",
"name": "test",
"description": "description",
"type": "zstack",
"version": "2018-06-18",
"state": true,
"content": "{ \"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\"} } }}"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventories | List | See inventories. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| type | String | The template type. Default type: zstack. | 2.5.0 |
| version | String | The template version. | 2.5.0 |
| state | Boolean | Whether the template is available. | 2.5.0 |
| content | String | The template content, which is a JSON string. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
QueryStackTemplateAction action = new QueryStackTemplateAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryStackTemplateAction.Result res = action.call();Python
SDK
QueryStackTemplateAction action = QueryStackTemplateAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryStackTemplateAction.Result res = action.call()UpdateStackTemplate
API Request
URLs
PUT zstack/v1/cloudformation/template/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"updateStackTemplate": {
"name": "stack",
"description": "description",
"state": false,
"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateStackTemplate":{"name":"stack","description":"description","state":false,"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"}}' \
http://localhost:8080/zstack/v1/cloudformation/template/86cefd61876833eaa581d942f6d519ba/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The template UUID. | 2.5.0 | |
| name | String | body (contained in the updateStackTemplate structure) | Optional. The resource name. | 2.5.0 | |
| description | String | body (contained in the updateStackTemplate structure) | Optional. The detailed description of the resource. | 2.5.0 | |
| state | Boolean | body (contained in the updateStackTemplate structure) | Optional. Whether the template is available. | 2.5.0 | |
| templateContent | String | body (contained in the updateStackTemplate structure) | Optional. The template content, which is a JSON string. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"inventory": {
"uuid": "600afd0b079b303385e5d04b4d560af1",
"name": "stack",
"type": "zstack",
"version": "2018-06-18",
"state": true,
"content": "{ \"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventory | StackTemplateInventory | See inventory. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| type | String | The template type. Default type: zstack. | 2.5.0 |
| version | String | The template version. | 2.5.0 |
| state | Boolean | Whether the template is available. | 2.5.0 |
| content | String | The template content, which is a JSON string. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
UpdateStackTemplateAction action = new UpdateStackTemplateAction();
action.uuid = "86cefd61876833eaa581d942f6d519ba";
action.name = "stack";
action.description = "description";
action.state = false;
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateStackTemplateAction.Result res = action.call();Python
SDK
UpdateStackTemplateAction action = UpdateStackTemplateAction()
action.uuid = "86cefd61876833eaa581d942f6d519ba"
action.name = "stack"
action.description = "description"
action.state = false
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateStackTemplateAction.Result res = action.call()GetSupportedCloudFormationResources
API Request
URLs
GET zstack/v1/cloudformation/resourcesHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/resources?type=zstackRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| version | String | query | Optional. The template version No. For example, v1. |
|
2.6.0 |
| type | String | query | Optional. The template type. Default type: zstack. |
|
2.6.0 |
| systemTags | List | query | Optional. The system tags. | 2.6.0 | |
| userTags | List | query | Optional. The user tags. | 2.6.0 |
API Response
Sample
Response
{
"resources": [
{
"name": "VmInstance",
"type": "Resource",
"actionName": "CreateVmInstanceAction",
"resources": [
"InstanceOffering",
"Image",
"L3Network",
"DiskOffering",
"Zone",
"Cluster",
"Host",
"PrimaryStorage"
]
},
{
"name": "AttachDataVolumeToVm",
"type": "Action",
"actionName": "AttachDataVolumeToVmAction",
"resources": [
"VmInstance",
"Volume"
]
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.6.0 |
| resources | List | See resources. | 2.6.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.6.0 |
| description | String | The brief description of the error. | 2.6.0 |
| details | String | The details about the error. | 2.6.0 |
| elaboration | String | The reserved field. Default value: null. | 2.6.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.6.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.6.0 |
#resources
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.6.0 |
| type | String | The type, including Action and Resource. | 2.6.0 |
| actionName | String | The action name. | 2.6.0 |
| resources | List | The list of the associated resources. | 2.6.0 |
SDK Sample
Java
SDK
GetSupportedCloudFormationResourcesAction action = new GetSupportedCloudFormationResourcesAction();
action.type = "zstack";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetSupportedCloudFormationResourcesAction.Result res = action.call();Python
SDK
GetSupportedCloudFormationResourcesAction action = GetSupportedCloudFormationResourcesAction()
action.type = "zstack"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetSupportedCloudFormationResourcesAction.Result res = action.call()CreateResourceStack
API Request
URLs
POST zstack/v1/cloudformation/stackHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"name": "stack",
"description": "description",
"type": "zstack",
"rollback": true,
"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}",
"parameters": "{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"name":"stack","description":"description","type":"zstack","rollback":true,"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}","parameters":"{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"}}' \
http://localhost:8080/zstack/v1/cloudformation/stackRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | The resource name. | 2.5.0 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 2.5.0 | |
| type | String | body (contained in the params structure) | Optional. The stack type. Default type: zstack. |
|
2.5.0 |
| rollback | Boolean | body (contained in the params structure) | Optional. Whether to roll back if stack creation fails. By default, rollback is performed on failure. | 2.5.0 | |
| templateContent | String | body (contained in the params structure) | Optional. The stack content, which is a JSON
string. Note: Make sure that at least one of
templateContent and templateUuid is not
null. |
2.5.0 | |
| templateUuid | String | body (contained in the params structure) | Optional. The template UUID. Note: Make sure
that at least one of templateContent and
templateUuid is not null. |
2.5.0 | |
| parameters | String | body (contained in the params structure) | The parameters in the stack. The parameters are JSON strings. | 2.5.0 | |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"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
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventory | ResourceStackInventory | See inventory. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| version | String | The stack version. | 2.5.0 |
| type | String | The stack type. Default type: zstack. | 2.5.0 |
| templateContent | String | The stack content, which is a JSON string. | 2.5.0 |
| paramContent | String | The parameters in the stack. The parameters are JSON strings. | 2.5.0 |
| status | String | The stack status. | 2.5.0 |
| reason | String | The reason for stack creation failure. | 2.5.0 |
| enableRollback | boolean | Whether to roll back if stack creation fails. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
CreateResourceStackAction action = new CreateResourceStackAction();
action.name = "stack";
action.description = "description";
action.type = "zstack";
action.rollback = true;
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}";
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateResourceStackAction.Result res = action.call();Python
SDK
CreateResourceStackAction action = CreateResourceStackAction()
action.name = "stack"
action.description = "description"
action.type = "zstack"
action.rollback = true
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}"
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateResourceStackAction.Result res = action.call()PreviewResourceStack
API Request
URLs
POST zstack/v1/cloudformation/stack/previewHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"type": "zstack",
"uuid": "c0c6caa3886d37709efe2c52aeeefa31",
"parameters": "{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"type":"zstack","uuid":"c0c6caa3886d37709efe2c52aeeefa31","parameters":"{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"}}' http://localhost:8080/zstack/v1/cloudformation/stack/previewRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| type | String | body (contained in the params structure) | Optional. |
|
2.5.0 |
| templateContent | String | body (contained in the params structure) | Optional. The template content. | 2.5.0 | |
| uuid | String | body (contained in the params structure) | Optional. The template UUID. | 2.5.0 | |
| parameters | String | body (contained in the params structure) | Optional. The parameters in the stack. The parameters are JSON strings. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"preview": {
"actions": [
{
"resourceName": "WebServer1",
"actionName": "org.zstack.sdk.CreateVmInstanceAction",
"round": 0.0,
"inDegree": [],
"actions": {
"name": "vm",
"instanceOfferingUuid": "f524c10459ce32f0b70a1c0878769b2d",
"imageUuid": "66296cfc1c6d36fa8405788cb2fb85a0",
"l3NetworkUuids": [
"e99fce59e6463758aef45bdfc5579203"
],
"strategy": "InstantStart",
"timeout": -1.0,
"pollingInterval": -1.0
}
}
],
"conditions": {
"WithDataVolume": false
}
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| preview | PreviewResourceStruct | See preview. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#preview
| Name | Type | Description | Starting Version |
|---|---|---|---|
| conditions | Map | The action results of the conditions. | 3.7.0 |
| actions | List | See actions. | 2.5.0 |
#actions
| Name | Type | Description | Starting Version |
|---|---|---|---|
| resourceName | String | The resource type. | 2.5.0 |
| actionName | String | The action name. | 2.5.0 |
| round | int | The round (), counting from '0'. | 2.5.0 |
| inDegree | Set | The dependency action list. | 2.5.0 |
| actions | Object | The action parameters. | 2.5.0 |
SDK Sample
Java
SDK
PreviewResourceStackAction action = new PreviewResourceStackAction();
action.type = "zstack";
action.uuid = "c0c6caa3886d37709efe2c52aeeefa31";
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
PreviewResourceStackAction.Result res = action.call();Python
SDK
PreviewResourceStackAction action = PreviewResourceStackAction()
action.type = "zstack"
action.uuid = "c0c6caa3886d37709efe2c52aeeefa31"
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
PreviewResourceStackAction.Result res = action.call()DeleteResourceStack
API Request
URLs
DELETE zstack/v1/cloudformation/stack/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/cloudformation/stack/77e576c15ef33cfcac8478e8db28f0faRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.5.0 | |
| deleteMode | String | body | Optional. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeleteResourceStackAction action = new DeleteResourceStackAction();
action.uuid = "77e576c15ef33cfcac8478e8db28f0fa";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteResourceStackAction.Result res = action.call();Python
SDK
DeleteResourceStackAction action = DeleteResourceStackAction()
action.uuid = "77e576c15ef33cfcac8478e8db28f0fa"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteResourceStackAction.Result res = action.call()UpdateResourceStack
API Request
URLs
PUT zstack/v1/cloudformation/stack/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"updateResourceStack": {
"name": "stack",
"description": "description",
"rollback": true,
"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}",
"parameters": "{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateResourceStack":{"name":"stack","description":"description","rollback":true,"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\", \"DefaultValue\" : \"instanceoffering-123\", \"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\"} } }}","parameters":"{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"}}' \
http://localhost:8080/zstack/v1/cloudformation/stack/acbf4bd4eb7838e2a624095d4f02990d/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The stack UUID. | 2.5.0 | |
| name | String | body (contained in the updateResourceStack structure) | Optional. The resource name. | 2.5.0 | |
| description | String | body (contained in the updateResourceStack structure) | Optional. The detailed description of the resource. | 2.5.0 | |
| rollback | Boolean | body (contained in the updateResourceStack structure) | Optional. Whether to roll back if stack creation fails. | 2.5.0 | |
| templateContent | String | body (contained in the updateResourceStack structure) | Optional. The stack content, which is a JSON string. | 2.5.0 | |
| parameters | String | body (contained in the updateResourceStack structure) | Optional. The parameters in the stack. The parameters are JSON strings. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"inventory": {
"uuid": "d72e80d8e9c235d0976e6c5a4e3f9137",
"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
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventory | ResourceStackInventory | See inventory. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| version | String | The stack version. | 2.5.0 |
| type | String | The stack type. Default type: zstack. | 2.5.0 |
| templateContent | String | The stack content, which is a JSON string. | 2.5.0 |
| paramContent | String | The parameters in the stack. The parameters are JSON strings. | 2.5.0 |
| status | String | The stack status. | 2.5.0 |
| reason | String | The reason for stack creation failure. | 2.5.0 |
| enableRollback | boolean | Whether to roll back if stack creation fails. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
UpdateResourceStackAction action = new UpdateResourceStackAction();
action.uuid = "acbf4bd4eb7838e2a624095d4f02990d";
action.name = "stack";
action.description = "description";
action.rollback = true;
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}";
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateResourceStackAction.Result res = action.call();Python
SDK
UpdateResourceStackAction action = UpdateResourceStackAction()
action.uuid = "acbf4bd4eb7838e2a624095d4f02990d"
action.name = "stack"
action.description = "description"
action.rollback = true
action.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", "DefaultValue" : "instanceoffering-123", "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"} } }}"
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateResourceStackAction.Result res = action.call()QueryResourceStack
API Request
URLs
GET zstack/v1/cloudformation/stack
GET zstack/v1/cloudformation/stack/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/stack?q=name=testcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/stack/071098a5d0b931758b2d96f3b947db06Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryResourceStack, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "33c82809544f38e886ea0e9409772057",
"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
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventories | List | See inventories. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| version | String | The stack version. | 2.5.0 |
| type | String | The stack type. Default type: zstack. | 2.5.0 |
| templateContent | String | The stack content, which is a JSON string. | 2.5.0 |
| paramContent | String | The parameters in the stack. The parameters are JSON strings. | 2.5.0 |
| status | String | The stack status. | 2.5.0 |
| reason | String | The reason for stack creation failure. | 2.5.0 |
| enableRollback | boolean | Whether to roll back if stack creation fails. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
QueryResourceStackAction action = new QueryResourceStackAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryResourceStackAction.Result res = action.call();Python
SDK
QueryResourceStackAction action = QueryResourceStackAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryResourceStackAction.Result res = action.call()GetResourceFromResourceStack
API Request
URLs
GET zstack/v1/cloudformation/stack/resourcesHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/stack/resources?uuid=37c961a530033ca1abd0650684c199dbRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | query | The stack UUID. | 2.5.0 | |
| systemTags | List | query | Optional. The system tags. | 2.5.0 | |
| userTags | List | query | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"resources": [
{
"VmInstance": {
"uuid": "70b885e0948b34a5831c75a457322b47",
"name": "Test-VM",
"description": "web server VM",
"zoneUuid": "d35a2b4b992c3293ac1bc10096de6cb2",
"clusterUuid": "8179e9b50398308aa0e2bf4eaf6f9712",
"imageUuid": "b3aedde2f9ba32e7a4442a48860180c3",
"hostUuid": "f2d9365120cf36ef961e8b522e0c319d",
"lastHostUuid": "93b923aa43433196895dada30f9dc458",
"instanceOfferingUuid": "61c0ba5753753a39b6c792ae6ef94915",
"rootVolumeUuid": "7d45c0a312ce37ffacc75005da14dcae",
"platform": "Linux",
"defaultL3NetworkUuid": "e8604346d3d63ed790f0ba8d443af3d9",
"type": "UserVm",
"hypervisorType": "KVM",
"memorySize": 8.589934592E9,
"cpuNum": 1.0,
"allocatorStrategy": "LastHostPreferredAllocatorStrategy",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM",
"state": "Running",
"vmNics": [
{
"uuid": "db23a9ba4d05362da2a58c51a9e50f65",
"vmInstanceUuid": "70b885e0948b34a5831c75a457322b47",
"usedIpUuid": "bf43c6c9ab453ed2be711573a1b959a0",
"l3NetworkUuid": "e8604346d3d63ed790f0ba8d443af3d9",
"ip": "192.168.1.10",
"mac": "00:0c:29:bd:99:fc",
"hypervisorType": "KVM",
"netmask": "255.255.255.0",
"gateway": "192.168.1.1",
"deviceId": 0.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
],
"allVolumes": [
{
"uuid": "7d45c0a312ce37ffacc75005da14dcae",
"name": "Root-Volume-For-VM-70b885e0948b34a5831c75a457322b47",
"primaryStorageUuid": "657bf5b4fe7c31ae9a50dd703dbbf958",
"vmInstanceUuid": "70b885e0948b34a5831c75a457322b47",
"diskOfferingUuid": "1c10223d580b3b889d1e06e6ad94f398",
"rootImageUuid": "b3aedde2f9ba32e7a4442a48860180c3",
"installPath": "/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-7d45c0a312ce37ffacc75005da14dcae/7d45c0a312ce37ffacc75005da14dcae.qcow2",
"type": "Root",
"format": "qcow2",
"size": 1.073741824E11,
"actualSize": 2.147483648E10,
"deviceId": 0.0,
"state": "Enabled",
"status": "Ready",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| resources | List | The resource list in the stack. | 2.5.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
SDK Sample
Java
SDK
GetResourceFromResourceStackAction action = new GetResourceFromResourceStackAction();
action.uuid = "37c961a530033ca1abd0650684c199db";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceFromResourceStackAction.Result res = action.call();Python
SDK
GetResourceFromResourceStackAction action = GetResourceFromResourceStackAction()
action.uuid = "37c961a530033ca1abd0650684c199db"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceFromResourceStackAction.Result res = action.call()QueryEventFromResourceStack
API Request
URLs
GET zstack/v1/cloudformation/event
GET zstack/v1/cloudformation/event/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/event?q=name=testcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/event/e2e62c108bd0316ea404980ad56d4e6bQueryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryEventFromResourceStack, and pressing the Tab
key.
API Response
Sample
Response
{
"inventories": [
{
"id": 1.0,
"description": "description",
"action": "CreateVmInstanceAction",
"content": "{\\n \"l3NetworkUuids\": [\\n \"1245de5c2d28454bb63e60575ec611cb\"\\n ],\\n \"name\": \"vm\",\\n \"description\": \"test\\nenter\",\\n \"systemTags\": [\\n \"userdata::I2Nsb3VkLWNvbmZpZwp1c2VyczoKIC0gbmFtZTogcm9vdAogICBzaGVsbDogL2Jpbi9iYXNoCiAgIGdyb3Vwczogcm9vdAogICBzdWRvOiBbJ0FMTD0oQUxMKSBOT1BBU1NXRDpBTEwnXQogICBzc2gtYXV0aG9yaXplZC1rZXlzOgogICAgICAgLSBzc2gtcnNhIEFBQUFCM056YUMxeWMyRUFBQUFEQVFBQkFBQUJBUURmZ2dMQVRrM0prVW5uazczT1F6b1dOdzN4UFdtb1FNVjV6bUZWekEwYVFyWHZoT00xakk3bXJiLzdKVTJTK0t3Nm1xUFp5QVUvTWg3WEc5Smw4REh3NzJEZWlzOEVWYm8yanA5dkU1dHRmdXY0K3Rvb1o2Sm9STVNDOEdvcGlkd2RZYWw3Y3o2Vk9TYzgyWkFyR3VlVUxzMzFqWEUzclIxNk96V0tTRzFVL1RsbXA5V0Rlamxyd1dZMCtPZzA4WHBORWVjMnFkUnpvV3lHMHJ5WEpDbUQrdmxCSXErWnVMQVRMZWZQUk1uNGZOVlROM1JmZ0Q0aVEvR2Jaa3RJK1BwZ1ppRkdMVW0zVnJwMjNJckVzSTdjUkszV01lZ2RNSlVrQmFzR05STjB1d082OXNvM3lBbi9NZTZ0b1hmd2JOaC9MWEpPRkh2RFo5bmtscWwydnA0MyByb290QDEwLjAuMTIxLjE3NQp3cml0ZV9maWxlczoKIC0gcGF0aDogL3RtcC9aU3RhY2tfY29uZmlnCiAgIGNvbnRlbnQ6IHwKICAgICAgIEhlbGxvLHdvcmxkIQpob3N0bmFtZToga292ZW4tdGVzdApkaXNhYmxlX3Jvb3Q6IGZhbHNlCmNocGFzc3dkOgogIGxpc3Q6IHwKICAgICAgcm9vdDpwYXNzd29yZAogIGV4cGlyZTogRmFsc2UKcnVuY21kOgogLSBjdXJsIGh0dHA6Ly9zb2Z0LnZwc2VyLm5ldC9sbm1wL2xubXAxLjQudGFyLmd6IC1vIGxubXAxLjQudGFyLmd6ICYmIHRhciB6eGYgbG5tcDEuNC50YXIuZ3ogJiYgY2QgbG5tcDEuNCAmJiBlY2hvICIifC4vaW5zdGFsbC5zaCBsbm1w\"\\n ],\\n \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\",\\n \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\"\\n}",
"resourceName": "WebServer1",
"actionStatus": "Start",
"stackUuid": "076e5c4edce23f09af5a842ffdfb0cb6"
},
{
"id": 2.0,
"description": "description",
"action": "CreateVmInstanceAction",
"content": "{\\n \"inventory\": {\\n \"uuid\": \"cebf83ef8ec04f7a9fbc80a54043b749\",\\n \"name\": \"vm\",\\n \"description\": \"test\\nenter\",\\n \"zoneUuid\": \"78c2900f033344a485e953bc02bd0010\",\\n \"clusterUuid\": \"a60243d5048c4a5c8cc6a35c0c1a3c97\",\\n \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\",\\n \"hostUuid\": \"9b57690de23f449e99c8f0da311e568e\",\\n \"lastHostUuid\": \"9b57690de23f449e99c8f0da311e568e\",\\n \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\",\\n \"rootVolumeUuid\": \"17c96f79a28347128f1b147c3ef0d12b\",\\n \"platform\": \"Linux\",\\n \"defaultL3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\",\\n \"type\": \"UserVm\",\\n \"hypervisorType\": \"KVM\",\\n \"memorySize\": 1073741824,\\n \"cpuNum\": 1,\\n \"cpuSpeed\": 0,\\n \"allocatorStrategy\": \"LeastVmPreferredHostAllocatorStrategy\",\\n \"createDate\": \"Jun 21, 2018 11:31:46 AM\",\\n \"lastOpDate\": \"Jun 21, 2018 11:31:47 AM\",\\n \"state\": \"Running\",\\n \"vmNics\": [\\n {\\n \"uuid\": \"a25592b3aced44dc889cede4f8368e52\",\\n \"vmInstanceUuid\": \"cebf83ef8ec04f7a9fbc80a54043b749\",\\n \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\",\\n \"ip\": \"10.75.0.98\",\\n \"mac\": \"fa:91:99:e1:d1:00\",\\n \"netmask\": \"255.0.0.0\",\\n \"gateway\": \"10.0.0.1\",\\n \"deviceId\": 0,\\n \"createDate\": \"Jun 21, 2018 11:31:46 AM\",\\n \"lastOpDate\": \"Jun 21, 2018 11:31:46 AM\"\\n }\\n ],\\n \"allVolumes\": [\\n {\\n \"uuid\": \"17c96f79a28347128f1b147c3ef0d12b\",\\n \"name\": \"ROOT-for-vm\",\\n \"description\": \"Root volume for VM[uuid:cebf83ef8ec04f7a9fbc80a54043b749]\",\\n \"primaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\",\\n \"vmInstanceUuid\": \"cebf83ef8ec04f7a9fbc80a54043b749\",\\n \"rootImageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\",\\n \"installPath\": \"/Cloud_ps/rootVolumes/acct-36c27e8ff05c4780bf6d2fa65700f22e/vol-17c96f79a28347128f1b147c3ef0d12b/17c96f79a28347128f1b147c3ef0d12b.qcow2\",\\n \"type\": \"Root\",\\n \"format\": \"qcow2\",\\n \"size\": 1610612736,\\n \"actualSize\": 1342308352,\\n \"deviceId\": 0,\\n \"state\": \"Enabled\",\\n \"status\": \"Ready\",\\n \"createDate\": \"Jun 21, 2018 11:31:46 AM\",\\n \"lastOpDate\": \"Jun 21, 2018 11:31:46 AM\",\\n \"isShareable\": false\\n }\\n ]\\n }\\n}",
"resourceName": "WebServer1",
"actionStatus": "Finish",
"stackUuid": "076e5c4edce23f09af5a842ffdfb0cb6"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventories | List | See inventories. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| id | long | The event ID. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| action | String | The event name. | 2.5.0 |
| content | String | The event parameter list. | 2.5.0 |
| resourceName | String | The resource name. | 2.5.0 |
| actionStatus | String | The action status. | 2.5.0 |
| stackUuid | String | The stack UUID. | 2.5.0 |
| duration | String | The event duration. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
QueryEventFromResourceStackAction action = new QueryEventFromResourceStackAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryEventFromResourceStackAction.Result res = action.call();Python
SDK
QueryEventFromResourceStackAction action = QueryEventFromResourceStackAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryEventFromResourceStackAction.Result res = action.call()RestartResourceStack
API Request
URLs
PUT zstack/v1/cloudformation/stack/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"restartResourceStack": {},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"restartResourceStack":{}}' http://localhost:8080/zstack/v1/cloudformation/stack/35b245eed7fd317d8c7f2b615d70ded1/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"inventory": {
"uuid": "88cf0d7fd9f8326081cbf268fe07566f",
"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
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| inventory | ResourceStackInventory | See inventory. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.5.0 |
| name | String | The resource name. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| version | String | The stack version. | 2.5.0 |
| type | String | The stack type. Default type: zstack. | 2.5.0 |
| templateContent | String | The stack content, which is a JSON string. | 2.5.0 |
| paramContent | String | The parameters in the stack. The parameters are JSON strings. | 2.5.0 |
| status | String | The stack status. | 2.5.0 |
| reason | String | The reason for stack creation failure. | 2.5.0 |
| enableRollback | Boolean | Whether to roll back if stack creation fails. | 2.5.0 |
| createDate | Timestamp | The creation date. | 2.5.0 |
| lastOpDate | Timestamp | The last operation date. | 2.5.0 |
SDK Sample
Java
SDK
RestartResourceStackAction action = new RestartResourceStackAction();
action.uuid = "35b245eed7fd317d8c7f2b615d70ded1";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RestartResourceStackAction.Result res = action.call();Python
SDK
RestartResourceStackAction action = RestartResourceStackAction()
action.uuid = "35b245eed7fd317d8c7f2b615d70ded1"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RestartResourceStackAction.Result res = action.call()CheckStackTemplateParameters
API Request
URLs
POST zstack/v1/cloudformation/stack/checkHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"type": "zstack",
"uuid": "69c3bbde1b693995a5998361a7f017e7"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"type":"zstack","uuid":"69c3bbde1b693995a5998361a7f017e7"}}' http://localhost:8080/zstack/v1/cloudformation/stack/checkRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| type | String | body (contained in the params structure) | Optional. The template type. Default type: zstack. |
|
2.5.0 |
| templateContent | String | body (contained in the params structure) | Optional. The template content, which is a JSON string. | 2.5.0 | |
| uuid | String | body (contained in the params structure) | The template UUID. | 2.5.0 | |
| systemTags | List | body | Optional. The system tags. | 2.5.0 | |
| userTags | List | body | Optional. The user tags. | 2.5.0 |
API Response
Sample
Response
{
"parametes": [
{
"paramName": "imageUuid",
"type": "String",
"defaultValue": "ff1373b10ee93b15b347f7abfb4bb5b6",
"description": "Image Uuid, represents the image resource to startup one vm instance",
"resourceType": "Image"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 2.5.0 |
| parametes | List | See parametes. | 2.5.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 2.5.0 |
| description | String | The brief description of the error. | 2.5.0 |
| details | String | The details about the error. | 2.5.0 |
| elaboration | String | The reserved field. Default value: null. | 2.5.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.5.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 2.5.0 |
#parametes
| Name | Type | Description | Starting Version |
|---|---|---|---|
| paramName | String | The parameter name. | 2.5.0 |
| type | String | The parameter type. | 2.5.0 |
| defaultValue | String | The default value. | 2.5.0 |
| description | String | The detailed description of the resource. | 2.5.0 |
| noEcho | Boolean | Whether to mask the parameter value to prevent it from being displayed in the console, command line tools, or API. | 2.5.0 |
| label | String | Specifies a name or description for a parameter that the frontend displays. | 2.5.0 |
| constraintDescription | String | Explains a constraint when the constraint is violated. If the verification fails, the corresponding content is returned. | 2.5.0 |
| resourceType | String | The type of a resource referenced by the event returned if the parameter is the ZStack resource. When the resource type cannot be determined, null is returned. | 2.5.0 |
SDK Sample
Java
SDK
CheckStackTemplateParametersAction action = new CheckStackTemplateParametersAction();
action.type = "zstack";
action.uuid = "69c3bbde1b693995a5998361a7f017e7";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CheckStackTemplateParametersAction.Result res = action.call();Python
SDKCheckStackTemplateParametersAction action = CheckStackTemplateParametersAction()
action.type = "zstack"
action.uuid = "69c3bbde1b693995a5998361a7f017e7"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CheckStackTemplateParametersAction.Result res = action.call()DecodeStackTemplate
API Request
URLs
POST zstack/v1/cloudformation/stack/preview/resourceHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"type": "zstack",
"uuid": "7628ef91277e392ca996d6457537bb45",
"parameters": "{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"type":"zstack","uuid":"7628ef91277e392ca996d6457537bb45","parameters":"{ \"imageUuid\": \"8fcfe758a7eb13118d7344a08ff790a5\", \"instanceOfferingUuid\": \"751f662a32184933aff487f5c6e167a6\", \"l3NetworkUuid\": \"1245de5c2d28454bb63e60575ec611cb\", \"DiskOfferingUuid\": \"ad0b4ea4c747401c92a7c990f7375cf1\", \"PrimaryStorageUuid\": \"06c35e7f42264a74abb5b828367169fe\", \"HostUuid\": \"9b57690de23f449e99c8f0da311e568e\"}"}}' http://localhost:8080/zstack/v1/cloudformation/stack/preview/resourceRequest Parameters
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| type | String | body(contained in the params structure) | Optional. The template type. |
|
3.0.0 |
| templateContent | String | body(contained in the params structure) | Optional. The template content. | 3.0.0 | |
| uuid | String | body(contained in the params structure) | Optional. The template UUID. | 3.0.0 | |
| parameters | String | body(contained in the params structure) | Optional. The request parameters in JSON format. | 3.0.0 | |
| systemTags | List | body | Optional. The system tags. | 3.0.0 | |
| userTags | List | body | Optional. The user tags. | 3.0.0 | |
| preparameters | String | body(contained in the params structure) | Optional. The pre-rendered request parameters in JSON format. | 3.9.0 |
API Response
Sample Response
{
"resources": [
{
"resourceName": "WebServer",
"resourceType": "VmInstance",
"deletePolicy": "Retain",
"inDegree": [
"l3",
"instanceOfferingUuid",
"addDns",
"imageUuid"
],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Resource",
"created": false,
"mockFailed": false
},
{
"resourceName": "l3",
"resourceType": "L3Network",
"inDegree": [
"l2NetworkUuid"
],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Resource",
"created": false,
"mockFailed": false
},
{
"resourceName": "addIpRange",
"inDegree": [
"l3"
],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Action",
"created": false,
"mockFailed": false
},
{
"resourceName": "addDns",
"inDegree": [
"l3",
"addIpRange"
],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Action",
"created": false,
"mockFailed": false
},
{
"resourceName": "imageUuid",
"resourceType": "Image",
"inDegree": [],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Resource",
"created": true,
"mockFailed": false
},
{
"resourceName": "instanceOfferingUuid",
"resourceType": "InstanceOffering",
"inDegree": [],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Resource",
"created": true,
"mockFailed": false
},
{
"resourceName": "l2NetworkUuid",
"resourceType": "L2Network",
"inDegree": [],
"properties": {
"uuid": "d55161ef863942d8a53a4f8448074749"
},
"type": "Resource",
"created": true,
"mockFailed": false
}
]
}#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.0.0 |
| description | String | The brief description of the error. | 3.0.0 |
| details | String | The details about the error. | 3.0.0 |
| elaboration | String | The reserved field. Default value: null. | 3.0.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.0.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.0.0 |
#resources
| Name | Type | Description | Starting Version |
|---|---|---|---|
| resourceName | String | The resource name in the stack template. | 3.0.0 |
| resourceType | String | The resource type. | 3.0.0 |
| deletePolicy | String | The deletion policy. | 3.0.0 |
| description | String | The resource description in the stack template. | 3.0.0 |
| inDegree | Set | The dependent resources. | 3.0.0 |
| action | String | The action. | 3.0.0 |
| properties | Map | The properties. | 3.0.0 |
| results | Object | The operation results. An empty string is returned if no operation is performed. | 3.0.0 |
| created | boolean | Indicates whether the resources are created. | 3.0.0 |
| mockFailed | boolean | Indicates whether mock failed. | 3.0.0 |
| type | ResourceType | For more information, see type. | 3.0.0 |
#type
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource type. | 3.0.0 |
| ordinal | int | 3.0.0 |
SDK Sample
Java
SDK
DecodeStackTemplateAction action = new DecodeStackTemplateAction();
action.type = "zstack";
action.uuid = "7628ef91277e392ca996d6457537bb45";
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DecodeStackTemplateAction.Result res = action.call();Python
SDK
DecodeStackTemplateAction action = DecodeStackTemplateAction()
action.type = "zstack"
action.uuid = "7628ef91277e392ca996d6457537bb45"
action.parameters = "{ "imageUuid": "8fcfe758a7eb13118d7344a08ff790a5", "instanceOfferingUuid": "751f662a32184933aff487f5c6e167a6", "l3NetworkUuid": "1245de5c2d28454bb63e60575ec611cb", "DiskOfferingUuid": "ad0b4ea4c747401c92a7c990f7375cf1", "PrimaryStorageUuid": "06c35e7f42264a74abb5b828367169fe", "HostUuid": "9b57690de23f449e99c8f0da311e568e"}"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DecodeStackTemplateAction.Result res = action.call()GetResourceStackFromResource
API Request
URLs
GET zstack/v1/cloudformation/resources/stackHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/resources/stack?resourceUuid=fad8b8f55961311a82b82a61d8b67fc5Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| resourceUuid | String | query | The resource UUID. | 3.9.0 | |
| systemTags | List | query | Optional. The system tags. | 3.9.0 | |
| userTags | List | query | Optional. The user tags. | 3.9.0 |
API Response
Sample
Response
{
"stack": {
"stackUuid": "4700be6752c037b69c74bd06eedf0308"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| stack | Map | The stack. | 3.9.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.9.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.9.0 |
| description | String | The brief description of the error. | 3.9.0 |
| details | String | The details about the error. | 3.9.0 |
| elaboration | String | The reserved field. Default value: null. | 3.9.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.9.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.9.0 |
SDK Sample
Java
SDK
GetResourceStackFromResourceAction action = new GetResourceStackFromResourceAction();
action.resourceUuid = "fad8b8f55961311a82b82a61d8b67fc5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceStackFromResourceAction.Result res = action.call();Python
SDK
GetResourceStackFromResourceAction action = GetResourceStackFromResourceAction()
action.resourceUuid = "fad8b8f55961311a82b82a61d8b67fc5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceStackFromResourceAction.Result res = action.call()GetResourceStackVmStatus
API Request
URLs
GET zstack/v1/cloudformation/stack/monitor/vmstatusHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/cloudformation/stack/monitor/vmstatus?uuid=8f0e4af072913507a434a2c7a8bd1d0aRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | query | The resource UUID. | 3.9.0 | |
| systemTags | List | query | Optional. The system tags. | 3.9.0 | |
| userTags | List | query | Optional. The user tags. | 3.9.0 |
API Response
Sample Response
{
"portStatus": {}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| portStatus | Map | The port monitoring status. Options: open | initialize | close. | 3.9.0 |
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.9.0 |
#error
| Name | Type | Description | Starting Version |
|---|---|---|---|
| code | String | The error code, which is a numbered or alphanumeric code that specifies an error. For example, SYS.1000, HOST.1001. | 3.9.0 |
| description | String | The brief description of the error. | 3.9.0 |
| details | String | The details about the error. | 3.9.0 |
| elaboration | String | The reserved field. Default value: null. | 3.9.0 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 3.9.0 |
| cause | ErrorCode | The root error, which is the associated root cause of the current error. If no root error exists, this parameter is null. | 3.9.0 |
SDK Sample
Java
SDK
GetResourceStackVmStatusAction action = new GetResourceStackVmStatusAction();
action.uuid = "8f0e4af072913507a434a2c7a8bd1d0a";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetResourceStackVmStatusAction.Result res = action.call();Python
SDK
GetResourceStackVmStatusAction action = GetResourceStackVmStatusAction()
action.uuid = "8f0e4af072913507a434a2c7a8bd1d0a"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetResourceStackVmStatusAction.Result res = action.call()AddResourceStackVmPortMonitor
API Request
URLs
POST zstack/v1/cloudformation/stack/monitor/addvmHeaders
Authorization: OAuth the-session-uuidBody
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"params": {
"stackUuid": "26386ffc6d43365d87aef19fdd32c6a1",
"vmInstanceUuid": "29ddc109dd983b7fb74a7988ebbed12d",
"port": 22.0
},
"systemTags": [],
"userTags": []
}
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.Curl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"stackUuid":"26386ffc6d43365d87aef19fdd32c6a1","vmInstanceUuid":"29ddc109dd983b7fb74a7988ebbed12d","port":22.0}}' http://localhost:8080/zstack/v1/cloudformation/stack/monitor/addvmRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| stackUuid | String | body (contained in the params structure) | Optional. The stack UUID. | 3.9.0 | |
| vmInstanceUuid | String | body (contained in the params structure) | The VM instance UUID. | 3.9.0 | |
| port | Integer | body (contained in the params structure) | The port No. | 3.9.0 | |
| systemTags | List | body | Optional. The system tags. | 3.9.0 | |
| userTags | List | body | Optional. The user tags. | 3.9.0 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
AddResourceStackVmPortMonitorAction action = new AddResourceStackVmPortMonitorAction();
action.stackUuid = "26386ffc6d43365d87aef19fdd32c6a1";
action.vmInstanceUuid = "29ddc109dd983b7fb74a7988ebbed12d";
action.port = 22.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddResourceStackVmPortMonitorAction.Result res = action.call();Python
SDK
AddResourceStackVmPortMonitorAction action = AddResourceStackVmPortMonitorAction()
action.stackUuid = "26386ffc6d43365d87aef19fdd32c6a1"
action.vmInstanceUuid = "29ddc109dd983b7fb74a7988ebbed12d"
action.port = 22.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddResourceStackVmPortMonitorAction.Result res = action.call()DeleteResourceStackVmPortMonitor
API Request
URLs
DELETE zstack/v1/cloudformation/stack/monitor/delvmHeaders
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/cloudformation/stack/monitor/delvm?deleteMode=PermissiveRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| stackUuid | String | body | Optional. The stack UUID | 3.9.0 | |
| vmInstanceUuid | String | body | The VM instance UUID. | 3.9.0 | |
| port | Integer | body | Optional. The port No. | 3.9.0 | |
| deleteMode | String | body | Optional. The delete mode. | 3.9.0 | |
| systemTags | List | body | Optional. The system tags. | 3.9.0 | |
| userTags | List | body | Optional. The user tags. | 3.9.0 |
API Response
When the API succeeded, an empty JSON structure {} is returned. When the API
failed, the returned JSON structure includes an error field. For
example,
{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK Sample
Java
SDK
DeleteResourceStackVmPortMonitorAction action = new DeleteResourceStackVmPortMonitorAction();
action.stackUuid = "2683832bb7d53245acd3012da44e7fe6";
action.vmInstanceUuid = "ffa8ab9746de3edcb1bc1245eef8868d";
action.port = 22.0;
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteResourceStackVmPortMonitorAction.Result res = action.call();Python
SDK
DeleteResourceStackVmPortMonitorAction action = DeleteResourceStackVmPortMonitorAction()
action.stackUuid = "2683832bb7d53245acd3012da44e7fe6"
action.vmInstanceUuid = "ffa8ab9746de3edcb1bc1245eef8868d"
action.port = 22.0
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteResourceStackVmPortMonitorAction.Result res = action.call()