Features
Creates an SOP task definition. When startNow=true, the instance is created and started immediately after the task is saved; otherwise, the task status is NOT_STARTED.
API details
Constraints
You must have the SOP_TASK:UPDATE privilege, as well as the UPDATE privilege on the selected cluster, tenant, arbitration service/service group, or host.
Request path
POST /api/v2/sop/tasks
Request parameters
Parameter |
Location |
Type |
Required |
Example value |
Description |
|---|---|---|---|---|---|
| name | Body | String | Yes | rebuild-standby-tenant-1 |
The globally unique task name. It must be 2 to 32 characters in length. The first character must be a Chinese character, an English letter, a hiragana character, or a katakana character. The last character must be a Chinese character, an English letter, a digit, a hiragana character, or a katakana character. It can contain underscores. |
| sopType | Body | String | Yes | REBUILD_STANDBY_TENANT |
SOP type code. Valid values:REBUILD_STANDBY_TENANT、ARBITRATION_FOR_FAULTY_REPLICA、OBSERVER_DATA_REBUILD. |
| targetParam | Body | Object | Yes | See the following table. | Task-level objective parameters. The fields are as follows:sopTypeDecision. |
| steps | Body | Array | Yes | See example | Step configuration array, which cannot be empty.stepKeyIt must be unique and belong to a template. Fixed enablement steps must be provided, and at least one enablement step must be retained. |
| steps[].stepIndex | Body | Integer | No | 1 |
Step number. If not provided, the default value from the template is used. The numbers must be consecutive and unique.1..N); onlyuserMovable=trueThe steps can be moved within the template scope. |
| steps[].stepKey | Body | String | Yes | CONFIRM_STANDBY_TENANT_INFO |
Step identifier returned by the template. |
| steps[].autoRun | Body | Boolean | No | true |
Whether to automatically execute. If not specified, the default value of the template is used. The default value cannot be changed for steps that are not editable. |
| steps[].enabled | Body | Boolean | No | true |
Whether to enable this step. Only steps that can be disabled in the template are allowed to be disabled here. |
| comments | Body | String | No | Monthly Drill |
Task remarks. Currently, the length limit is not defined on the server side. |
| startNow | Body | Boolean | No | false |
Only fortrueis specified, the instance is started immediately. If this parameter is not specified or its value isfalseNeither is started. |
The targetParam field varies based on the sopType:
SOP Type |
Parameter |
Type |
Required |
Constraints and Meanings |
|---|---|---|---|---|
REBUILD_STANDBY_TENANT |
standbyClusterId |
Long | Yes | The cluster ID of the standby tenant to be rebuilt must be a positive number. |
standbyTenantId |
Long | Yes | The ID of the standby tenant to be rebuilt must be a positive number. | |
logTransportMode |
String | Yes | Log transmission method. Valid values:NETWORKorLOG_BACKUP. |
|
standbyClusterName、standbyTenantName |
String | No | Display name, which may be supplemented by the server. | |
ARBITRATION_FOR_FAULTY_REPLICA |
clusterId |
Long | Yes | Cluster ID, which must be a numeric value. |
arbitrationServiceId |
Long | Condition Required | Arbitration service ID; corresponding to thearbitrationGroupIdChoose one of the two options and provide only one value. |
|
arbitrationGroupId |
Long | Condition Required | Arbitration service group ID; corresponding to thearbitrationServiceIdChoose one and provide only one value. |
|
clusterName |
String | No | The name of the cluster to be displayed. | |
OBSERVER_DATA_REBUILD |
clusterId |
Long | Yes | Cluster ID, which must be a numeric value. |
replacementHostId |
Long | No | Preselected replacement host ID. The value must be a positive number. If not specified, it can be set toADD_OBSERVERSet up the prerequisites. |
|
clusterName |
String | No | The name of the cluster to be displayed. |
The possible values of steps[].stepKey are determined entirely by sopType:
sopType |
steps[].stepKeyValid values |
|---|---|
REBUILD_STANDBY_TENANT |
CONFIRM_STANDBY_TENANT_INFO、BACKUP_PRIMARY_TENANT、DISCONNECT_STANDBY_TENANT、LOCK_STANDBY_TENANT、DELETE_STANDBY_TENANT、CREATE_STANDBY_TENANT、VERIFY_PRIMARY_STANDBY_SYNC |
ARBITRATION_FOR_FAULTY_REPLICA |
CONFIRM_ARBITRATION_TARGET、ADD_ARBITRATION_SERVICE、DELETE_TENANT_REPLICA、DELETE_OBSERVER、ENABLE_TENANT_ARBITRATION、VERIFY_TENANT_ARBITRATION |
OBSERVER_DATA_REBUILD |
CONFIRM_OBSERVER_TARGET、DELETE_TENANT_REPLICA、DELETE_OBSERVER、FORCE_DELETE_HOST、ADD_OBSERVER、ADD_TENANT_REPLICA、VERIFY_REPLICA_REBUILD |
Response parameters
Parameter |
Type |
Description |
|
|---|---|---|---|
| successful | Boolean | Returns 0 on success.true. |
|
| data.id | Long | The ID of the new task. | |
| data.name | String | Saved task name. | |
| data.sopType | String | SOP type code. | |
| data.sopTypeDisplayName | String | The display name of the SOP type in the current locale. | |
| data.targetParam | Object | Saved task-level goal parameters, which can include names resolved by the server, associated objects, or snapshot fields. | |
| data.operationObjects | Object | The parsed display object only returns the currently existing fields. Rebuilding a standby tenant may includeoldStandbyTenant、oldStandbyCluster、primaryTenant、primaryTenantId、primaryCluster、primaryClusterId、primaryOcpClusterId、logTransportMode、backupConfig、newStandbyTenantId、newStandbyClusterId、newStandbyTenant、newStandbyCluster; The arbitration type may includetenantNames、faultyObserverIp、arbitrationServiceId、arbitrationGroupId、resolvedArbitrationServiceId、arbitrationServiceIp、arbitrationServicePort、arbitrationServiceGroupName; OBServer reconstruction may containtenantNames、faultyObserverIp、zoneName、replacementHostId、replacementHostIp. |
|
| data.targetSummary.displayText | String | The target summary that can be directly displayed. | |
| data.targetSummary.kind | String | Target category. Currently:TENANTorCLUSTER. |
|
| data.targetSummary.details[] | Array | Summary details, each item containinglabel(name) andvalue(value). |
|
| data.steps[] | Array | Step configuration saved. | |
| data.steps[].stepIndex | Integer | Step number. | |
| data.steps[].stepKey | String | Unique identifier of the step. | |
| data.steps[].stepName | String | The name displayed for the step in the current locale. | |
| data.steps[].stepKind | String | EXECUTABLEorCONFIRMATION. |
|
| data.steps[].stepDescription | String \ | null | Step description. |
| data.steps[].autoRun | Boolean | Whether to execute automatically. | |
| data.steps[].enabled | Boolean \ | null | Whether to enable;nullindicates that the feature is always enabled. |
| data.steps[].blockNext | Boolean | Whether to block subsequent automatic progress when a failure occurs. | |
| data.steps[].editable | Boolean | Whether to allow modification of the auto-execution switch. | |
| data.steps[].userMovable | Boolean | Whether to allow adjusting the step order. | |
| data.steps[].minStepIndex | Integer \ | null | The minimum step number allowed for moving. |
| data.steps[].maxStepIndex | Integer \ | null | Maximum step number allowed for moving. |
| data.comments | String \ | null | Note saved. |
| data.creator | String | The username of the creator in OCP. | |
| data.createTime | Datetime | The time when the task was created. | |
| data.updateTime | Datetime | Last update time of the task. | |
| data.displayStatus | String | NOT_STARTED、WAITING_CONFIRM、RUNNING、FAILEDorCOMPLETED. If not started immediately, it isNOT_STARTED. |
|
| data.currentExecutionId | Long \ | null | The ID of the instance being executed. This parameter is NULL if the instance has not been started.null. |
| timestamp | Datetime | The time taken by the server to create the response. | |
| duration | Long | The time consumed by the server for processing, in milliseconds. | |
| status | Integer | HTTP status code. In case of success, it is200. |
|
| traceId | String | Request link ID, used for log troubleshooting. |
Error codes
HTTP |
Error Code |
Description |
|---|---|---|
| 400 | SOP10001 |
The task name is invalid. |
| 400 | SOP10002 |
The target parameter field is missing, has an incorrect type, or does not meet the scenario constraints. |
| 400 | SOP10003 |
Empty steps, missing template steps, duplicate steps/steps not in the template, or all steps are disabled. |
| 400 | SOP10004 |
Modify the step that cannot be editedautoRun. |
| 400 | SOP10005 |
Step number is invalid. |
| 400 | SOP10006 |
Not supported for SOP types. |
| 400 | SOP10007 |
The task name already exists. |
Examples
Request example
POST /api/v2/sop/tasks
{
"name": "rebuild-standby-tenant-1",
"sopType": "REBUILD_STANDBY_TENANT",
"targetParam": {
"standbyClusterId": 1,
"standbyTenantId": 2,
"logTransportMode": "NETWORK"
},
"steps": [
{"stepIndex": 1, "stepKey": "CONFIRM_STANDBY_TENANT_INFO", "autoRun": true},
{"stepIndex": 2, "stepKey": "BACKUP_PRIMARY_TENANT", "autoRun": true, "enabled": true},
{"stepIndex": 3, "stepKey": "DISCONNECT_STANDBY_TENANT", "autoRun": true},
{"stepIndex": 4, "stepKey": "LOCK_STANDBY_TENANT", "autoRun": true},
{"stepIndex": 5, "stepKey": "DELETE_STANDBY_TENANT", "autoRun": true},
{"stepIndex": 6, "stepKey": "CREATE_STANDBY_TENANT", "autoRun": false},
{"stepIndex": 7, "stepKey": "VERIFY_PRIMARY_STANDBY_SYNC", "autoRun": true}
],
"comments": "Monthly Drill",
"startNow": false
}
