Executing Customized Scripts
Function
This API is used to execute a script.
A maximum of 20 script input parameters, timeout interval, execution user, and resource restriction script input parameters are supported. A maximum of 200 hosts can be delivered at a time. The maximum number of hosts in a batch is 10. The maximum number of batches is 20. The maximum size of logs generated by the script can only be 1 MB.
URI
POST /v1/job/scripts/{script_uuid}
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
script_uuid |
Yes |
String |
Script UUID. |
Request Parameters
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
execute_param |
Yes |
ScriptExecuteParam object |
Script execution parameters |
execute_batches |
Yes |
Array of ExecuteInstancesBatchInfo objects |
Target instance batch information |
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
resourceful |
Yes |
Boolean |
Whether resources are limited. The value true indicates that resources are not limited, and the value false indicates that resources are limited. |
timeout |
Yes |
Integer |
Timeout interval, in seconds. The value range is to be determined. The value is greater than 5 and less than 1800. Minimum value: 5 Maximum value: 1800 |
success_rate |
Yes |
Double |
Success rate. The value can contain one decimal place. Minimum value: 1 Maximum value: 100 |
execute_user |
Yes |
String |
User who executes the script. The script must be executed by user root. Minimum length: 1 character Maximum length: 32 characters |
script_params |
No |
Array of ScriptExecuteInputParam objects |
Script input parameter list |
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
param_name |
Yes |
String |
Name of a script input parameter. The parameter name must be unique in the same script. Minimum length: 1 character Maximum length: 64 characters |
param_value |
Yes |
String |
Value of the script input parameter. Minimum length: 0 character Maximum length: 1,024 characters The value can be:
|
param_order |
Yes |
Integer |
Parameter sequence. The value starts from 1 and must be consecutive. Minimum value: 1 Maximum value: 20 |
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
batch_index |
Yes |
Integer |
Batch index. The value starts from 1. Minimum value: 1 Maximum value: 20 |
target_instances |
Yes |
Array of ExecuteResourceInstance objects |
Target node list Array length: 1 to 10 characters |
rotation_strategy |
Yes |
String |
Suspension and resumption policy The value can be:
|
Parameter |
Mandatory or Not |
Type |
Description |
---|---|---|---|
resource_id |
Yes |
String |
ECS ID Minimum length: 1 character Maximum length: 64 characters |
agent_sn |
Yes |
String |
UniAgent_sn Minimum length: 1 character Maximum length: 32 characters |
project_id |
Yes |
String |
Project ID Minimum length: 1 character Maximum length: 32 characters |
region_id |
Yes |
String |
Region to which the server belongs Minimum length: 1 character Maximum length: 32 characters |
Response Parameters
Status code: 204
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code Minimum length: 8 characters Maximum length: 36 characters |
error_msg |
String |
Error description Minimum length: 2 characters Maximum length: 512 characters |
Request Example
https://coc.myhuawei.com/v1/job/scripts/{script_uuid} { "execute_param" : { "timeout" : 300, "execute_user" : "root", "success_rate" : "100.0", "script_params" : [ { "param_name" : "a", "param_value" : "key1", "param_order" : 1 } ] }, "execute_batches" : [ { "batch_index" : 1, "rotation_strategy" : "CONTINUE", "target_instances" : [ { "resource_id" : "resource_id", "agent_sn" : "agent_sn", "agent_status" : "ONLINE", "region_id" : "cn-north-7", "project_id" : "project_id" } ] } ] }
Response Example
Status code: 200
execute_uuid
{ "data" : "SCT2023083109562601af694bf" }
Status code: 204
{ "error_code" : "COC.00040701", "error_msg" : "error_msg" }
Status Code
Status Code |
Description |
---|---|
200 |
execute_uuid |
204 |
Error information is included. |
Error code
See Error code.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot