Long Job Operations
SubmitLongJob
API Request
URLs
POST zstack/v1/longjobsHeaders
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": "migrate-volume",
"description": "migrate volume to another Ceph primary storage",
"jobName": "APIPrimaryStorageMigrateVolumeMsg",
"jobData": "{\"volumeUuid\":\"45a53d3d93384433add8ead7616586cf\", \"dstPrimaryStorageUuid\":\"70a0618804864b3dabe8be9824c8028c\"}",
"targetResourceUuid": "45a53d3d93384433add8ead7616586cf"
},
"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":"migrate-volume","description":"migrate volume to another Ceph primary storage","jobName":"APIPrimaryStorageMigrateVolumeMsg","jobData":"{\"volumeUuid\":\"45a53d3d93384433add8ead7616586cf\", \"dstPrimaryStorageUuid\":\"70a0618804864b3dabe8be9824c8028c\"}","targetResourceUuid":"45a53d3d93384433add8ead7616586cf"}}' \
http://localhost:8080/zstack/v1/longjobsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| name | String | body (contained in the params structure) | Optional. The resource name. | 2.3 | |
| description | String | body (contained in the params structure) | Optional. The detailed description of the resource. | 2.3 | |
| jobName | String | body (contained in the params structure) | The job name. | 2.3 | |
| jobData | String | body (contained in the params structure) | The job data. | 2.3 | |
| resourceUuid | String | body (contained in the params structure) | Optional. The resource UUID. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 | |
| targetResourceUuid | String | body (contained in the params structure) | Optional. The UUID of the target resource. | 2.3 |
- ZStack Cloud allows you to mark a longjob that
uploads a specific image by using the systemTags parameter. You can set the
value of the systemTags parameter to uploadImage. The
IMAGE_ID that you specify is generally a MD5 value.
- The format of the option is
uploadImage::{IMAGE_ID}. - For example,
uploadImage::68b329da9893e34099c7d8ad5cb9c940.
- The format of the option is
API Response
Sample
Response
{
"inventory": {
"uuid": "23598186b9ef35aa89fbebf8f04d497a"
}
}| 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.3 |
#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.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| 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.3 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | The resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| apiId | String | The API ID used to associate with the task progress. | 2.3 |
| jobName | String | The job name. | 2.3 |
| jobData | String | The job data. | 2.3 |
| jobResult | String | The job result. | 2.3 |
| targetResourceUuid | String | The target resource UUID. | 2.3 |
| managementNodeUuid | String | The management node UUID. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| state | LongJobState | See state. | 2.3 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | 2.3 |
SDK Sample
Java
SDK
SubmitLongJobAction action = new SubmitLongJobAction();
action.name = "migrate-volume";
action.description = "migrate volume to another Ceph primary storage";
action.jobName = "APIPrimaryStorageMigrateVolumeMsg";
action.jobData = "{"volumeUuid":"45a53d3d93384433add8ead7616586cf", "dstPrimaryStorageUuid":"70a0618804864b3dabe8be9824c8028c"}";
action.targetResourceUuid = "45a53d3d93384433add8ead7616586cf";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SubmitLongJobAction.Result res = action.call();Python
SDK
SubmitLongJobAction action = SubmitLongJobAction()
action.name = "migrate-volume"
action.description = "migrate volume to another Ceph primary storage"
action.jobName = "APIPrimaryStorageMigrateVolumeMsg"
action.jobData = "{"volumeUuid":"45a53d3d93384433add8ead7616586cf", "dstPrimaryStorageUuid":"70a0618804864b3dabe8be9824c8028c"}"
action.targetResourceUuid = "45a53d3d93384433add8ead7616586cf"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SubmitLongJobAction.Result res = action.call()UpdateLongJob
API Request
URLs
PUT zstack/v1/longjobs/{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.
{
"updateLongJob": {
"name": "new-name",
"description": "new-description"
},
"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 '{"updateLongJob":{"name":"new-name","description":"new-description"}}' http://localhost:8080/zstack/v1/longjobs/dee3e1e3706f3e52a2cb9a47850508e7/actionsRequest Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 3.9.0 | |
| name | String | body (contained in the updateLongJob structure) | Optional. The resource name. | 3.9.0 | |
| description | String | body (contained in the updateLongJob structure) | Optional. The detailed description of the resource. | 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
Sample
Response
{
"inventory": {
"uuid": "464cdf695427358696dae171544b67ef",
"name": "new-name",
"description": "new-description"
}
}| Name | Type | Description | Starting Version |
|---|---|---|---|
| error | ErrorCode | The error code. If not null, the operation fails, or vice versa. For more information, see error. | 3.9.0 |
| inventory | LongJobInventory | See inventory. | 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 |
#inventory
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 3.9.0 |
| name | String | The resource name. | 3.9.0 |
| description | String | The detailed description of the resource. | 3.9.0 |
| apiId | String | The API ID used to associate with the task progress. | 3.9.0 |
| jobName | String | The job name. | 3.9.0 |
| jobData | String | The job data. | 3.9.0 |
| jobResult | String | The job result. | 3.9.0 |
| targetResourceUuid | String | The UUID of the target resource. | 3.9.0 |
| managementNodeUuid | String | The UUID of the management node. | 3.9.0 |
| createDate | Timestamp | The creation date. | 3.9.0 |
| lastOpDate | Timestamp | The last operation date. | 3.9.0 |
| state | LongJobState | See state. | 3.9.0 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| Waiting | LongJobState | 3.9.0 | |
| Suspended | LongJobState | 3.9.0 | |
| Running | LongJobState | 3.9.0 | |
| Succeeded | LongJobState | 3.9.0 | |
| Canceling | LongJobState | 3.9.0 | |
| Canceled | LongJobState | 3.9.0 | |
| Failed | LongJobState | 3.9.0 |
SDK Sample
Java
SDK
UpdateLongJobAction action = new UpdateLongJobAction();
action.uuid = "dee3e1e3706f3e52a2cb9a47850508e7";
action.name = "new-name";
action.description = "new-description";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateLongJobAction.Result res = action.call();Python
SDK
UpdateLongJobAction action = UpdateLongJobAction()
action.uuid = "dee3e1e3706f3e52a2cb9a47850508e7"
action.name = "new-name"
action.description = "new-description"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateLongJobAction.Result res = action.call()DeleteLongJob
API Request
URLs
DELETE zstack/v1/longjobs/{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/longjobs/a87ae356c6583cc7b312412337f96609?Request Parameters
| Name | Type | Location | Description | Optional Value | Starting Version |
|---|---|---|---|---|---|
| uuid | String | url | The resource UUID. | 2.3 | |
| systemTags | List | body | Optional. The system tags. | 2.3 | |
| userTags | List | body | Optional. The user tags. | 2.3 |
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
DeleteLongJobAction action = new DeleteLongJobAction();
action.uuid = "a87ae356c6583cc7b312412337f96609";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteLongJobAction.Result res = action.call();Python
SDK
DeleteLongJobAction action = DeleteLongJobAction()
action.uuid = "a87ae356c6583cc7b312412337f96609"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteLongJobAction.Result res = action.call()QueryLongJob
API Request
URLs
GET zstack/v1/longjobs
GET zstack/v1/longjobs/{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/longjobscurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/longjobs/f031e4ea64673a5f96e022f4eb81fc59
Queryable Fields
You can check all queryable fields and resource names that can be queried across tables by using zstack-cli, entering QueryLongJob, and pressing the Tab key.
API Response
Sample
Response
{
"inventories": [
{
"uuid": "e8a3fcaa8c393684b78a6dc1b20db49f"
}
]
}| 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 |
| inventories | List | See inventories. | 2.3 |
#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.3 |
| description | String | The brief description of the error. | 2.3 |
| details | String | The details about the error. | 2.3 |
| elaboration | String | The reserved field. Default value: null. | 2.3 |
| opaque | LinkedHashMap | The reserved field. Default value: null. | 2.3 |
| 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.3 |
#inventories
| Name | Type | Description | Starting Version |
|---|---|---|---|
| uuid | String | The resource UUID. | 2.3 |
| name | String | The resource name. | 2.3 |
| description | String | The detailed description of the resource. | 2.3 |
| apiId | String | The API ID used to associate with the task progress. | 2.3 |
| jobName | String | The job name. | 2.3 |
| jobData | String | The job data. | 2.3 |
| jobResult | String | The job result. | 2.3 |
| targetResourceUuid | String | The target resource UUID. | 2.3 |
| managementNodeUuid | String | The management node UUID. | 2.3 |
| createDate | Timestamp | The creation date. | 2.3 |
| lastOpDate | Timestamp | The last operation date. | 2.3 |
| state | LongJobState | See state. | 2.3 |
#state
| Name | Type | Description | Starting Version |
|---|---|---|---|
| name | String | The resource name. | 2.3 |
| ordinal | int | 2.3 |
SDK Sample
Java
SDK
QueryLongJobAction action = new QueryLongJobAction();
action.conditions = asList();
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryLongJobAction.Result res = action.call();Python
SDK
QueryLongJobAction action = QueryLongJobAction()
action.conditions = []
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryLongJobAction.Result res = action.call()