Cluster Operations
CreateCluster
API Request
URLs
POST zstack/v1/clustersHeaders
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": {
"zoneUuid": "d5629a75f0a24280ac669d93d38a7dcd",
"name": "cluster1",
"description": "test",
"hypervisorType": "KVM"
},
"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":{"zoneUuid":"e1fb7d87073b397c857eaeeb16243103","name":"cluster1","description":"test","hypervisorType":"KVM"}}' \
http://localhost:8080/zstack/v1/clustersRequest Parameters
| Name | Type | Location | Description | Valid Value | Starting Version |
|---|---|---|---|---|---|
| zoneUuid | String | body (contained in the params structure) | The zone UUID. | 0.6 | |
| name | String | body (contained in the params structure) | The resource name. | 0.6 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 0.6 | |
| hypervisorType | String | body (contained in the params structure) | The hypervisor type. |
|
4.0.0 |
| type | String | body (contained in the params structure) | Optional. The reserved field for internal use. | zstack | 0.6 |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID.
|
0.6 | |
| architecture | String | body (contained in the params structure) | Optional. |
|
4.0.0 |
| tagUuids | List | body (contained in the params structure) | Optional. | 4.0.0 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"name": "cluster1",
"uuid": "dc7442bb39674d779d688369329ba845",
"description": "test",
"state": "Enabled",
"hypervisorType": "KVM",
"createDate": "Jun 7, 2017 9:20:31 PM",
"lastOpDate": "Jun 7, 2017 9:20:31 PM",
"zoneUuid": "342b68c14869412984d6327a58b18f9b",
"type": "zstack"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventory | ClusterInventory | See inventory. | 0.6 |
#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 |
|---|---|---|---|
| name | String | The resource name. | 0.6 |
| uuid | String | The resource UUID. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| state | String | The cluster state. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| type | String | The reserved field. | 0.6 |
SDK Sample
Java
SDK
CreateClusterAction action = new CreateClusterAction();
action.zoneUuid = "70fd596da027478eb22ac9357aed23f4";
action.name = "cluster1";
action.description = "test";
action.hypervisorType = "KVM";
action.sessionId = "894477861bcc45488978b584908e4ee3";
CreateClusterAction.Result res = action.call();Python
SDK
CreateClusterAction action = CreateClusterAction()
action.zoneUuid = "cfe698802c87486986878daa2da7e02f"
action.name = "cluster1"
action.description = "test"
action.hypervisorType = "KVM"
action.sessionId = "0664130c5d36414bbb3a7a59ef87ea5a"
CreateClusterAction.Result res = action.call()DeleteCluster
API Request
URLs
DELETE zstack/v1/clusters/{uuid}?deleteMode={deleteMode}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth d55b1a48ad2348ceb3bea95b407a8bde" \
-X DELETE http://localhost:8080/zstack/v1/clusters/a5bb7e5ca83f41748538d953709ba3c3?deleteMode=PermissiveRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| deleteMode | String | body | Optional. The delete mode. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
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
DeleteClusterAction action = new DeleteClusterAction();
action.uuid = "51b6e91ce692487ea582418f52835061";
action.deleteMode = "Permissive";
action.sessionId = "41695ae924854a3abfc1e681e092f744";
DeleteClusterAction.Result res = action.call();Python
SDK
DeleteClusterAction action = DeleteClusterAction()
action.uuid = "2e9d94bbe3d240d3a660e86a7cd6aff8"
action.deleteMode = "Permissive"
action.sessionId = "386fba061d404eeb830a772e31fd4faf"
DeleteClusterAction.Result res = action.call()QueryCluster
API Request
URLs
GET zstack/v1/clusters
GET zstack/v1/clusters/{uuid}Headers
Authorization: OAuth the-session-uuidCurl
Sample
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 815c808ecfb5461b953544d4bcefea31" \
-X GET http://localhost:8080/zstack/v1/clusters?q=hypervisorType=KVMcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth 663eef55906d4b6e9750f9b4ed65f5f9" \
-X GET http://localhost:8080/zstack/v1/clusters/a8d5ea1ceda34616a26bec2fce3b4d8aQueryable Fields
You can check all queryable fields and resource names that can be queried across
tables by using zstack-cli, entering
QueryCluster, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"name": "cluster1",
"uuid": "41f3a4eb130347a2af6d7f2e0d21fab0",
"description": "test",
"state": "Enabled",
"hypervisorType": "KVM",
"createDate": "Jun 7, 2017 9:20:13 PM",
"lastOpDate": "Jun 7, 2017 9:20:13 PM",
"zoneUuid": "aad01c8b25774796b2e341ec51a7c9c1",
"type": "zstack"
}
]
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventories | List | See inventories. | 0.6 |
#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 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 0.6 |
| uuid | String | The resource UUID. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| state | String | The cluster state. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| type | String | The reserved field. | 0.6 |
SDK Sample
Java
SDK
QueryClusterAction action = new QueryClusterAction();
action.conditions = asList("hypervisorType=KVM");
action.sessionId = "3e214b652cc947ea9e1aa256d05752ea";
QueryClusterAction.Result res = action.call();Python
SDK
QueryClusterAction action = QueryClusterAction()
action.conditions = ["hypervisorType=KVM"]
action.sessionId = "ad8f3cd4b5bc4da0a3a91dc8bcbdd18c"
QueryClusterAction.Result res = action.call()UpdateCluster
API Request
URLs
PUT zstack/v1/clusters/{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.
{
"updateCluster": {
"name": "cluster1",
"description": "test"
},
"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 '{"updateCluster":{"name":"cluster1","description":"test"}}' \
http://localhost:8080/zstack/v1/clusters/851a3783e1503de2a1b9222014c843c4/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| name | String | body (contained in the updateCluster structure) | Optional. The resource name. | 0.6 | |
| description | String | body (contained in the updateCluster structure) | Optional. The detailed description of the resource. | 0.6 | |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"name": "cluster1",
"uuid": "9dd0fbecb0e04260ad161c66d1da9f96",
"description": "test",
"state": "Enabled",
"hypervisorType": "KVM",
"createDate": "Jun 7, 2017 9:20:29 PM",
"lastOpDate": "Jun 7, 2017 9:20:29 PM",
"zoneUuid": "25b7ddce968f4cbbb58aa5a205e116ee",
"type": "zstack"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventory | ClusterInventory | See inventory. | 0.6 |
#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 |
|---|---|---|---|
| name | String | The resource name. | 0.6 |
| uuid | String | The resource UUID. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| state | String | The cluster state. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| type | String | The reserved field. | 0.6 |
SDK Sample
Java
SDK
UpdateClusterAction action = new UpdateClusterAction();
action.uuid = "ce185b26a4f14153941a868435d94498";
action.name = "cluster1";
action.description = "test";
action.sessionId = "5abfadbc97d64b4687ba6281de117d2d";
UpdateClusterAction.Result res = action.call();Python
SDK
UpdateClusterAction action = UpdateClusterAction()
action.uuid = "a643ba1b98524c60acced530ce2ded1b"
action.name = "cluster1"
action.description = "test"
action.sessionId = "cc779e5d5344493d9bd1cb1ced887321"
UpdateClusterAction.Result res = action.call()ChangeClusterState
API Request
URLs
PUT zstack/v1/clusters/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuid
Body
Note: In
the preceding sample, both systemTags and userTags are optional.
These two fields can be included in the body structure.
{
"changeClusterState": {
"stateEvent": "disable"
},
"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 '{"changeClusterState":{"stateEvent":"disable"}}' \
http://localhost:8080/zstack/v1/clusters/652ee5e996203bfbb5eb75e750720093/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 0.6 | |
| stateEvent | String | body (contained in the changeClusterState structure) | The state event. |
|
0.6 |
| systemTags | List | body | Optional. The system tags. | 0.6 | |
| userTags | List | body | Optional. The user tags. | 0.6 |
API Response
Sample
Response
{
"inventory": {
"name": "cluster1",
"uuid": "2cebd4274c7c4550add1ee3620b52a81",
"description": "test",
"state": "Enabled",
"hypervisorType": "KVM",
"createDate": "Jun 7, 2017 9:20:25 PM",
"lastOpDate": "Jun 7, 2017 9:20:25 PM",
"zoneUuid": "90eb72b73e144650990db2aa1ddee7c1",
"type": "zstack"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 0.6 |
| inventory | ClusterInventory | See inventory. | 0.6 |
#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 |
|---|---|---|---|
| name | String | The resource name. | 0.6 |
| uuid | String | The resource UUID. | 0.6 |
| description | String | The detailed description of the resource. | 0.6 |
| state | String | The cluster state. | 0.6 |
| hypervisorType | String | The hypervisor type. | 0.6 |
| createDate | Timestamp | The creation date. | 0.6 |
| lastOpDate | Timestamp | The last operation date. | 0.6 |
| zoneUuid | String | The zone UUID. | 0.6 |
| type | String | The reserved field. | 0.6 |
SDK Sample
Java
SDK
ChangeClusterStateAction action = new ChangeClusterStateAction();
action.uuid = "b97eb5ab5e264edbad128090b0ac28c2";
action.stateEvent = "disable";
action.sessionId = "79368b716c6a4d5db37fc7c601bf14cc";
ChangeClusterStateAction.Result res = action.call();Python
SDK
ChangeClusterStateAction action = ChangeClusterStateAction()
action.uuid = "24f520e8991d464eaf2ed9b1e55996a3"
action.stateEvent = "disable"
action.sessionId = "11db5049d24342e7af8b1a3992484184"
ChangeClusterStateAction.Result res = action.call()UpdateClusterOS
API Request
URLs
PUT zstack/v1/clusters/{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.
{
"updateClusterOS": {
"excludePackages": [
"kernel",
"systemd*"
],
"updatePackages": [
"zstack-release"
],
"releaseVersion": "c74",
"force": false
},
"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 '{"updateClusterOS":{"excludePackages":["kernel","systemd*"],"updatePackages":["zstack-release"],"releaseVersion":"c74","force":false}}' http://localhost:8080/zstack/v1/clusters/31c4951f39ae38969802e833448369ae/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| excludePackages | List | body (contained in the updateClusterOS structure) | Optional. The packages not to be upgraded. | 3.7.0 | |
| updatePackages | List | body (contained in the updateClusterOS structure) | Optional. The packages to be upgraded. | 3.7.0 | |
| releaseVersion | String | body (contained in the updateClusterOS structure) | Optional. The release version of the operating system. | 3.7.0 | |
| resourceUuid | String | body (contained in the updateClusterOS structure) | Optional. The resource UUID. | 3.7.0 | |
| tagUuids | List | body (contained in the updateClusterOS structure) | Optional. The tag UUID list. | 3.7.0 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 | |
| force | boolean | body (contained in the updateClusterOS structure) | Optional. Whether update cluster OS forcefully or not. | 5.2.0 |
API Response
Sample
Response
{
"inventory": {
"uuid": "932696598b64375ea4ae6226cc0c1407"
}
}| 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.3 |
| inventory | LongJobInventory | See inventory. | 2.2 |
#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 detailed 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.2.4 |
| name | String | The resource name. | 2.2.4 |
| description | String | The detailed description of the resource. | 2.2.4 |
| apiId | String | The API ID used to associate with the task progress. | 2.2.4 |
| jobName | String | The job name. | 2.2.4 |
| jobData | String | The job data. | 2.2.4 |
| jobResult | String | The job result. | 2.2.4 |
| targetResourceUuid | String | The target resource UUID. | 2.2.4 |
| managementNodeUuid | String | The management node UUID. | 2.2.4 |
| createDate | Timestamp | The creation date. | 2.2.4 |
| lastOpDate | Timestamp | The last operation date. | 2.2.4 |
| executeTime | Long | 3.7.0 | |
| state | LongJobState | See state. | 2.2.4 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.24 |
| ordinal | int | 2.2.4 |
SDK Sample
Java
SDK
UpdateClusterOSAction action = new UpdateClusterOSAction();
action.uuid = "31c4951f39ae38969802e833448369ae";
action.excludePackages = asList("kernel","systemd*");
action.updatePackages = asList("zstack-release");
action.releaseVersion = "c74";
action.force = false;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateClusterOSAction.Result res = action.call();
Python
SDK
UpdateClusterOSAction action = UpdateClusterOSAction()
action.uuid = "31c4951f39ae38969802e833448369ae"
action.excludePackages = [kernel, systemd*]
action.updatePackages = [zstack-release]
action.releaseVersion = "c74"
action.force = false
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateClusterOSAction.Result res = action.call()
