Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Executing Customized Scripts

Updated on 2024-04-19 GMT+08:00

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}

Table 1 Path parameters

Parameter

Mandatory or Not

Type

Description

script_uuid

Yes

String

Script UUID.

Request Parameters

Table 2 Request body parameter

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

Table 3 ScriptExecuteParam

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

Table 4 ScriptExecuteInputParam

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:

  • ^((?!\.{2
  • })[a-zA-Z0-9_\-\/\.\x20\?:"
  • =+@\\\[\{\]\}])*$

param_order

Yes

Integer

Parameter sequence. The value starts from 1 and must be consecutive.

Minimum value: 1

Maximum value: 20

Table 5 ExecuteInstancesBatchInfo

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:

  • CONTINUE
  • PAUSE
Table 6 ExecuteResourceInstance

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

Table 7 Response body parameters

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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback