Install
openclaw skills install huawei-cloud-flexus-l-server-scripts-excuteBased on Huawei Cloud COC (Cloud Operations Center) APIs for script management and remote execution. Supports creating custom scripts (Shell, Python, Bat) and batch execution on target host instances via UniAgent. Applicable to cloud operations automation and batch script deployment scenarios. Trigger keywords: L-instance, COC script, script management, script execution, cloud operations, custom script, batch execution; COC, script management, script execution, cloud operations (中文触发词:L实例执行脚本).
openclaw skills install huawei-cloud-flexus-l-server-scripts-excute⚠️ Security Execution Rules (Highest Priority):
This skill is built on Huawei Cloud COC (Cloud Operations Center) service, involving the following cloud services and components:
User/Agent │──────▶│ COC API │──────▶│ UniAgent │──────▶│ Flexus L Instance│
(Skill caller) (Cloud Ops Center) (Proxy program) (Target Host)
Component Description:
Routing Keywords: COC script, script management, script execution, cloud operations, custom script, batch execution; COC, script management, script execution, cloud operations.
All scripts and environment check scripts are inside the skill package. You must use skill action=exec to execute them; do not run them directly in the shell.
COC SDK Version Requirement: huaweicloudsdkcoc >= 3.1.0
Verification Commands:
# Check current SDK version
python -c "import huaweicloudsdkcoc; print(huaweicloudsdkcoc.__version__)"
# Verify COC client availability
python -c "from huaweicloudsdkcoc.v1 import CocClient; print('COC SDK version verification passed')"
Supported Authentication Methods:
Credential Acquisition Methods:
This skill supports obtaining Huawei Cloud credentials through the following methods (in order of priority from high to low):
Environment Variables (highest priority)
HW_ACCESS_KEY: Huawei Cloud Access Key AKHW_SECRET_KEY: Huawei Cloud Access Key SKHW_SECURITY_TOKEN: Security token for temporary credentialsCommand Line Parameters (used when environment variables are not provided)
--ak: Huawei Cloud Access Key AK--sk: Huawei Cloud Access Key SK--security-token: Security token for temporary credentials (required when using temporary AK/SK)Interactive Input (when neither of the above methods are provided)
python {baseDir}/scripts/caller.py create --name "test_script" --type SHELL --content "echo hello" --description "Test script"
2. **Command Line Parameters**:
```bash
# Using permanent AK/SK
python {baseDir}/scripts/caller.py create --ak "your_access_key" --sk "your_secret_key" --region "cn-north-4" --name "test_script" --type SHELL --content "echo hello" --description "Test script"
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py create --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --region "cn-north-4" --name "test_script" --type SHELL --content "echo hello" --description "Test script"
python {baseDir}/scripts/caller.py create
# Will prompt for AK/SK/region
Authentication Parameter Description:
| Parameter | Description | Required | Default | Example |
|---|---|---|---|---|
| --ak | Huawei Cloud Access Key AK (can be temporary AK) | Yes* | Prompted | --ak AXXX... |
| --sk | Huawei Cloud Access Key SK (can be temporary SK) | Yes* | Prompted | --sk SXXX... |
| --security-token | Security token for temporary credentials (required when using temporary AK/SK) | No | Prompted | --security-token XXXX... |
| --region | COC Service Region | No | cn-north-4 | --region cn-north-4 |
Note: Parameters marked with * can be provided via environment variables (HW_ACCESS_KEY, HW_SECRET_KEY, HW_SECURITY_TOKEN, HW_REGION). If environment variables are set, they take priority over command line parameters.
Authentication Priority:
HW_ACCESS_KEY, HW_SECRET_KEY, HW_SECURITY_TOKEN, HW_REGIONSecurity Rules:
This skill requires the following IAM permissions. For detailed information, refer to IAM Policies Documentation:
| Permission Category | Permission Name | Description |
|---|---|---|
| Script Management | coc:script:create | Create script |
| Script Management | coc:script:list | List scripts |
| Script Management | coc:script:get | Get script details |
| Script Management | coc:script:update | Update script |
| Script Management | coc:script:delete | Delete script |
| Execution Management | coc:execution:create | Create execution task |
| Execution Management | coc:execution:list | List execution tasks |
| Execution Management | coc:execution:get | Get execution details |
| Instance Management | coc:instance:list | List target instances |
Insufficient Permission Error Handling:
# Typical error message
error: AccessDenied
message: You do not have permission to perform this action.
Troubleshooting Steps:
Resolution:
Verification:
# Re-execute to verify permissions
python {baseDir}/scripts/caller.py list
Create Script:
# Using permanent AK/SK
python {baseDir}/scripts/caller.py create --ak "your_ak" --sk "your_sk" --name "backup_script" --type SHELL --content "echo 'Backup completed'" --description "Data backup script"
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py create --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --name "backup_script" --type SHELL --content "echo 'Backup completed'" --description "Data backup script"
View Script Details:
# Using permanent AK/SK
python {baseDir}/scripts/caller.py show --ak "your_ak" --sk "your_sk" --script-uuid "SC202xxxxxxxx13701c4a8a62"
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py show --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --script-uuid "SC202xxxxxxxx13701c4a8a62"
List Scripts:
# Using permanent AK/SK
python {baseDir}/scripts/caller.py list --ak "your_ak" --sk "your_sk" --page 1 --size 10
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py list --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --page 1 --size 10
Execute Script:
# Using permanent AK/SK
python {baseDir}/scripts/caller.py execute --ak "your_ak" --sk "your_sk" --script-uuid "SC202xxxxxxxx13701c4a8a62" --execute-user root --timeout 300
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py execute --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --script-uuid "SC202xxxxxxxx13701c4a8a62" --execute-user root --timeout 300
Interactive Execution: python {baseDir}/scripts/caller.py execute --ak "your_ak" --sk "your_sk"
Query Execution Result:
# Using permanent AK/SK
python {baseDir}/scripts/caller.py query --ak "your_ak" --sk "your_sk" --execute-uuid "SCT202xxxxxxxx01af694bf"
# Using temporary AK/SK with security-token
python {baseDir}/scripts/caller.py query --ak "temporary_ak" --sk "temporary_sk" --security-token "your_security_token" --execute-uuid "SCT202xxxxxxxx01af694bf"
| Parameter | Description | Required | Default | Example |
|---|---|---|---|---|
| --ak | Huawei Cloud Access Key AK (can be temporary AK) | Yes* | Prompted | --ak AXXX... |
| --sk | Huawei Cloud Access Key SK (can be temporary SK) | Yes* | Prompted | --sk SXXX... |
| --security-token | Security token for temporary credentials (required when using temporary AK/SK) | No | Prompted | --security-token XXXX... |
| --region | COC Service Region | No | cn-north-4 | --region cn-north-4 |
Note: Parameters marked with * can be provided via environment variables:
HW_ACCESS_KEY - Huawei Cloud Access KeyHW_SECRET_KEY - Huawei Cloud Secret KeyHW_SECURITY_TOKEN - Temporary security token (optional)HW_REGION - COC Service RegionIf environment variables are set, they take priority over command line parameters.
| Parameter | Description | Required | Default |
|---|---|---|---|
| --name | Script name | Yes | - |
| --type | Script type (SHELL/PYTHON/BAT) | Yes | - |
| --content | Script content | Yes | - |
| --description | Script description | Yes | - |
| --risk-level | Risk level (LOW/MEDIUM/HIGH) | No | LOW |
| --version | Script version | No | 1.0.0 |
| Parameter | Description | Required | Default |
|---|---|---|---|
| --script-uuid | Script UUID | No | Most recent script |
| --execute-user | Execute user | No | root |
| --timeout | Timeout in seconds (5-1800) | No | 300 |
| --success-rate | Success rate (0.01-100) | No | 1 |
| --rotation-strategy | Rotation strategy (CONTINUE/PAUSE) | No | CONTINUE |
| Parameter | Description | Required | Default |
|---|---|---|---|
| --script-uuid | Script UUID | Yes | - |
| Parameter | Description | Required | Default |
|---|---|---|---|
| --page | Page number | No | 1 |
| --size | Page size | No | 10 |
| Parameter | Description | Required | Default |
|---|---|---|---|
| --execute-uuid | Execution task UUID | Yes | - |
Before creating or executing scripts for the first time, ensure the Huawei Cloud COC SDK dependencies are installed. Run from the skill directory (skills/coc):
pip install -r {baseDir}/requirements.txt
Installation Notes:
scripts directory for script creation and executionpip install -r {baseDir}/requirements.txt -i https://pypi.org/project/huaweicloudsdkcoc/
or
pip install -r {baseDir}/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
Installation Verification:
python -c "from huaweicloudsdkcoc.v1 import CocClient; print('SDK installed successfully!')"
# Set environment variables first
export HW_ACCESS_KEY="your_ak"
export HW_SECRET_KEY="your_sk"
export HW_SECURITY_TOKEN="your_token" # Optional
# Execute command (will automatically use environment variables)
python {baseDir}/scripts/caller.py create --name "test_script" --type SHELL --content "echo hello" --description "Test script"
Or using command line parameters:
python {baseDir}/scripts/caller.py create --ak "your_ak" --sk "your_sk" --name "test_script" --type SHELL --content "echo hello" --description "Test script"
python {baseDir}/scripts/caller.py execute --ak "your_ak" --sk "your_sk" --script-uuid "SC202xxxxxxxx13701c4a8a62" --execute-user root --timeout 300 --success-rate 100
Tip: Refer to the "Parameter Reference" section for complete parameter documentation.
When executing scripts, the following information will be requested interactively (L-instance only):
Required Parameters:
Optional Parameters (press Enter to use default values):
Found 25 scripts (Page 1, 10 per page):
--------------------------------------------------------------------------------
No. Script UUID Name Type Risk Level
--------------------------------------------------------------------------------
1 SC202xxxxxxxx13701c4a8a62 backup_script SHELL LOW
2 SC202xxxxxxxx10302201d5b9e78 deploy_script SHELL HIGH
3 SC202xxxxxxxx13701c4a8a62 monitor_script PYTHON MEDIUM
--------------------------------------------------------------------------------
Create Script Success Response:
{
"ok": true,
"text": "Script created successfully: SC202xxxxxxxx13701c4a8a62",
"result": {
"data": "SC202xxxxxxxx13701c4a8a62"
},
"error": null
}
Execute Script Success Response:
{
"ok": true,
"text": "Script execution started: SCT202xxxxxxxx01af694bf",
"result": {
"data": "SCT202xxxxxxxx01af694bf"
},
"error": null
}
Query Execution Result Response:
{
"data": {
"batch_index": 1,
"total_instances": 1,
"execute_instances": [
{
"id": 40304358,
"cmd_uuid": "2exxxxxxxxxxxxxx6b5",
"job_sign": null,
"target_instance": {
"resource_id": "6axxxxxxxxxxxxxxx9e",
"agent_sn": "e5xxxxxxxxxxxxxxxxxx77",
"agent_status": null,
"agent_version": "1.1.8",
"region_id": "cn-north-4",
"project_id": null,
"properties": {
"host_name": "dify-test-001",
"fixed_ip": null,
"floating_ip": null,
"region_id": "cn-north-4",
"zone_id": null,
"application": null,
"group": null,
"project_id": null
},
"custom_attributes": null,
"provider": "hcss",
"type": "l-instance"
},
"gmt_created": 1779934038727,
"gmt_finished": 1779934107670,
"execute_costs": 68943,
"status": "ABNORMAL",
"message": "Reading package lists...\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\n\nBuilding dependency tree...\nReading state information...\nexpect is already the newest version (5.45.4-2build1).\n\n[SYSTEM INFO] script job execute timeout."
}
]
}
}
Status Description:
FINISHED - Execution successfulABNORMAL - Execution failedPROCESSING/READY - In progresspython -c "from huaweicloudsdkcoc.v1 import CocClient; print('SDK installed successfully!')"
python {baseDir}/scripts/caller.py create --ak "your_ak" --sk "your_sk" --name "test_script" --type SHELL --content "echo hello" --description "Test script" --non-interactive
# Expected output: Script UUID returned
python {baseDir}/scripts/caller.py execute --ak "your_ak" --sk "your_sk" --script-uuid "SC202xxxxxxxx13701c4a8a62" --execute-user root --timeout 300 --non-interactive
# Expected output: Execution task ID returned
python {baseDir}/scripts/smoke_test.py
# This will test the configuration and optional API connectivity
COC involves two different region concepts:
1. COC Service Region (API endpoint region):
2. Target Instance Region (where the L-instance is located):
Important: COC service region and target instance region can be different.
Authentication Failed (403):
error: Authentication failed
API Quota Exceeded (429):
error: API quota exceeded
Parameter Error (400):
error: Invalid parameter