Submit Long Job

POST/zstack/v1/longjobs

Headers

Authorization: OAuth the-session-uuid

Body

{
  "params": {
    "name": "migrate-volume",
    "description": "migrate volume to another Ceph primary storage",
    "jobName": "APIPrimaryStorageMigrateVolumeMsg",
    "jobData": "{\"volumeUuid\":\"45a53d3d93384433add8ead7616586cf\", \"dstPrimaryStorageUuid\":\"70a0618804864b3dabe8be9824c8028c\"}",
    "targetResourceUuid": "45a53d3d93384433add8ead7616586cf"
  },
  "systemTags": [],
  "userTags": []
}

In the above example, the systemTags and userTags fields are optional. They are listed to indicate that these two fields can be included in the body.

Curl Example

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/longjobs

Parameter List

NameTypeLocationDescriptionAllowed ValuesStarting Version
name (Optional)Stringbody (contained in the params structure)Resource name 2.3
description (Optional)Stringbody (contained in the params structure)Detailed description of the resource 2.3
jobNameStringbody (contained in the params structure)Job name 2.3
jobDataStringbody (contained in the params structure)Job data 2.3
resourceUuid (Optional)Stringbody (contained in the params structure)Resource UUID 2.3
systemTags (Optional)ListbodySystem tags 2.3
userTags (Optional)ListbodyUser tags 2.3
targetResourceUuid (Optional)Stringbody (contained in the params structure)  2.3
  • ZSvirt uses an identifier to mark the upload of a specific image for this longjob. The IMAGE_ID is specified by the user, typically as an md5 value. Add the uploadImage option to SystemTags.
  • Option format: uploadImage::{IMAGE_ID}
  • Example: uploadImage::68b329da9893e34099c7d8ad5cb9c940

API Response

Response example

{
  "inventory": {
    "uuid": "23598186b9ef35aa89fbebf8f04d497a"
  }
}
NameTypeDescriptionStarting Version
errorErrorCodeThe error code. If not null, the operation failed. This field is null when the operation succeeds. For details, see error2.3
inventoryLongJobInventoryFor details, see inventory2.3

error

NameTypeDescriptionStarting Version
codeStringThe error code number. A globally unique identifier for the error, such as SYS.1000, HOST.1001.2.3
descriptionStringA brief description of the error2.3
detailsStringThe detailed error information2.3
elaborationStringA reserved field. Default is null.2.3
opaqueLinkedHashMapA reserved field. Default is null.2.3
causeErrorCodeThe root error. The source error that caused the current error. This field is null if there is no root error.2.3

inventory

NameTypeDescriptionStarting Version
uuidStringThe UUID of the resource. Uniquely identifies the resource.2.3
nameStringResource name2.3
descriptionStringDetailed description of the resource2.3
apiIdStringThe API ID used to associate with TaskProgress2.3
jobNameStringJob name2.3
jobDataStringJob data2.3
jobResultStringJob result2.3
targetResourceUuidStringTarget resource UUID2.3
managementNodeUuidStringManagement node UUID2.3
createDateTimestampCreation time2.3
lastOpDateTimestampLast modification time2.3
stateLongJobStateFor details, see state2.3

state

NameTypeDescriptionStarting Version
nameStringResource name2.3
ordinalint 2.3

SDK Examples

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()