Coding

huawei-cloud-cli-guidance

Try it

Provides guidance for Huawei Cloud KooCLI command-line tool operations. Covers KooCLI installation, IAM authentication configuration, access credential confi...

What it does

Provides guidance for Huawei Cloud KooCLI command-line tool operations. Covers KooCLI installation, IAM authentication configuration, access credential configuration, command construction, common error troubleshooting. Use this skill when users ask about any cloud-related services or wants to operate Huawei Cloud services from the terminal. Triggers: Huawei Cloud, huaweiyun, "华为云","华为cli", "命令行", KooCLI, hcloud, huaweiyunCLI, Huawei Cloud command line, OBS, ECS, VPC, "云", yun, huaweiyun tool, huawei tool, "华为云工具", "云工具", "工具"

The skill document

huawei cloud cli guidance

Overview

Huawei Cloud KooCLI command-line tool guidance skill, providing comprehensive KooCLI usage guide. This skill covers core functionalities including KooCLI installation, authentication configuration, command construction, common error troubleshooting, helping users efficiently manage Huawei Cloud resources.

Attention

  1. Any issues encountered during the use of koocli must be addressed by prioritizing the guidance steps provided in this skill. [MUST][IMPORTANT]
  2. It is essential to read this document in its entirety and make full use of its guidance during the process.[MUST][IMPORTANT]

Prerequisites

  • KooCLI Version: 7.2.2 or higher
  • Huawei Cloud Account: Valid Huawei Cloud account with corresponding access permissions
  • Authentication Credentials: Access Key (AK) and Secret Key (SK) or IAM user credentials
  • Network Connection: Accessible Huawei Cloud service endpoints
  • Operating System: Linux, macOS, or Windows (WSL supported)

KooCLI Command Format Standard

Huawei Cloud KooCLI adopts a unified command format:

hcloud   [parameters] [options]

Command Structure

  • hcloud: Command-line tool name
  • ``: Cloud service name (e.g., ECS, VPC, OBS, etc.)
  • ``: API operation name (e.g., ListInstances, CreateVpc, etc.)
  • [parameters]: Operation parameters (e.g., instance_id, vpc_name, etc.)
  • [options]: Global options (e.g., --cli-region, --cli-output, etc.)

Parameter Format Rules

  1. Required parameters: Directly specified in the command, e.g., --instance_id i-12345678
  2. Optional parameters: Represented with square brackets, e.g., [--description "instance description"]
  3. Authentication parameters: Use --cli- prefix, e.g., --cli-profile, --cli-region
  4. Output parameters: Use --cli-output to specify output format (json/table/tsv)
  5. Query parameters: Use --cli-query to perform JMESPath query filtering

Scenario Routing

Installation Scenario

  1. User asks about KooCLI installation → Jump to "1. Install KooCLI"
  2. User needs to verify installation → Check version command hcloud version

Authentication Scenario

  1. User needs to configure authentication → Jump to "2. Configure koocli"
  2. User asks about different authentication modes → Choose Profile mode, explicit parameter mode, etc. based on requirements

Command Execution Scenario

  1. User needs to execute specific operations → Guide to use hcloud --help to query available operations
  2. User encounters errors → Jump to "8. Common issues" for troubleshooting

Output Formatting Scenario

  1. User needs specific format output → Use --cli-output=json/table/tsv
  2. User needs to filter results → Use --cli-query for JMESPath querying

Core Commands

refer to '../references/core-commands.md'

Architecture:

Cloud Service OpenAPI
    |
    | ECS API / VPC API / RDS API / OBS API / IAM API ...
    v
Service Metadata JSON API Definition
    |
    | Description:
    | - Service name
    | - API version
    | - Request method GET / POST / PUT / DELETE...
    | - URI path
    | - Request parameters
    | - Response structure
    | - Authentication method
    | - Region and Endpoint
    v
KooCLI Core
    |
    | Read metadata
    | Generate commands
    | Validate parameters
    | Assemble HTTP requests
    | Signature authentication
    | Call OpenAPI
    v
Dynamically Generated Commands
    |
    | hcloud   [parameters]
    v
Unified Execution Engine
    |
    | Execute requests
    | Return results
    v
Huawei Cloud Resource Operation Results

Understand the logic and process of KooCLI managing Huawei Cloud resources. Every time Huawei Cloud service is called or problems are encountered during the process, you must refer to and understand the architecture again, clarifying current steps and subsequent steps. [Required]

Applicable Scenarios

  1. Install koocli
  2. Configure IAM, AK, SK, region, profile
  3. Manage Huawei Cloud resources

1. Install KooCLI

  1. Check local version
hcloud version

Expected output: Current KooCLI version: 7.2.2 or higher.

  1. One-click installation (skip this step if local version check passes)
# Universal for all platforms
curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && bash ./hcloud_install.sh

# Non-interactive installation
curl -sSL https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/hcloud_install.sh -o ./hcloud_install.sh && bash ./hcloud_install.sh -y

After installation completes, check if local installation was successful.

Important: No additional operations allowed!!! Any file content changes must obtain user permission.

If more detailed installation guidance is needed, refer to ./references/installation-guide.md

2. Configure koocli

Credential Configuration

After koocli download is complete, ask the user which way they want to use koocli [Required]

1. koocli provides a configuration-free usage method, only requiring passing current user authentication-related parameters directly in commands.

2. If the user chooses non-interactive method to add configuration items, execute hcloud configure init, guide the user to input each parameter value.

When using koocli to manage Huawei Cloud resources requires other permissions, refer to '../references/iam-policies.md'

3. ecsAgency

When the user has successfully established a delegation to Elastic Cloud Server (ECS), when using KooCLI within the ECS server, you can specify "--cli-mode=ecsAgency" in commands. KooCLI will automatically obtain temporary AK/SK and SecurityToken for authentication based on ECS delegation.

4. AssumeRole

When the delegator user creates a delegation and hands over resources to another account for management, the delegatee can add "--cli-agency-domain-id"/"--cli-agency-domain-name", "--cli-agency-name" and "--cli-source-profile" options to commands, using the configuration-free method to AssumeRole and call cloud service APIs, managing and using the delegator's resources:

hcloud VPC ListAddressGroup/v3 --cli-region="cn-north-4" --project_id="2cc60****************caefa5019ef" --cli-agency-domain-id=13534326******************5cf67b --cli-agency-name=****** --cli-source-profile=test
{
  "request_id": "29ec21****************6d6b4cdd82",
  "address_groups": [],
  "page_info": {
  "current_count": 0
   }
}

5. SSO Login

KooCLI's SSO login command stores user authentication information in configuration files by completing SSO login, avoiding frequent input of these fixed information during operation execution. SSO login can be performed with the following command: hcloud configure sso

# SSO profile name (configuration item name to save after SSO login, required), SSO start URL (user portal URL, required), SSO region (region where IAM Identity Center is opened, required), Region (default or commonly used region, optional)
hcloud configure sso
? Input SSO profile name [required]:  sso
? Input SSO start URL [required]:  https://idcenter.huaweicloud.com/d-3********6/portal
? Input SSO region [required]:  cn-north-4
? Input Region:  cn-north-4
Browser page has been opened, waiting for you to complete SSO login...
? Choose account name: ACCOUNT_01
? Choose permission set name: PERMISSION_01
SSO login successful

6. Authentication Modes

KooCLI configuration item authentication mode values are AKSK, ecsAgency, SSO, AssumeRole. AKSK is recommended. When the configuration item being used has multiple authentication mode-related parameters configured simultaneously, use the "--cli-mode" option to specify the configuration item's authentication mode:

When setting configuration items, you need to specify the configuration item name with "--cli-profile", and also add corresponding authentication parameters based on the authentication mode "--cli-mode":

If the configuration item's authentication mode is "AKSK", then the values of "--cli-access-key" and "--cli-secret-key" in the configuration command cannot be empty;
If the configuration item's authentication mode is "ecsAgency", then specify "--cli-mode=ecsAgency" in the configuration command;
If the configuration item's authentication mode is "SSO", then the values of "--cli-sso-start-url" and "--cli-sso-region" in the configuration command cannot be empty;
If the configuration item's authentication mode is "AssumeRole", then the values of "--cli-agency-domain-id"/"--cli-agency-domain-name", "--cli-agency-name", "--cli-source-profile" in the configuration command cannot be empty.

7. Authentication Mode Selection

Use and only use one authentication method:

ModeApplicable ScenarioStart CommandCleanup
Profile ModeAgent sessions, multiple callshcloud configure init --cli-profile agent-profileTemporary profiles need cleanup
Explicit Parameter ModeOne-time commands, CI/CDPass authentication parameters in each commandNo local configuration
Existing Profile ModeUser already configured--cli-profile Do not modify configuration

Profile Mode Configuration

# Create dedicated profile
hcloud configure init --cli-profile agent-profile

# View configuration
hcloud configure list

# Execute commands using profile
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=json

Explicit Parameter Mode

# Using permanent AK/SK
hcloud   \
  --cli-access-key  \
  --cli-secret-key  \
  --cli-region cn-north-4

# Using temporary credentials
hcloud   \
  --cli-access-key  \
  --cli-secret-key  \
  --cli-security-token  \
  --cli-region cn-north-4

Multi-Environment Management

Create independent profiles for different environments:

  • dev: Development environment
  • test: Test environment
  • prod: Production environment

Explicitly specify when calling:

hcloud   \
  --cli-profile dev \
  --cli-region cn-north-4

3. Consult --help before constructing any command

Help output is the authoritative source. [Important]

Execute help output as follows:

  1. Use hcloud --help command to query the list of cloud services supported by KooCLI. After obtaining accurate cloud service names, proceed to next step.
  2. Use hcloud --help command to query the service's operation list. Find out what operations the service has, obtain the operation the user needs, then continue.
  3. Use hcloud --help to query the help information for the specific cloud service operation.
  4. After executing the API call command, print the output result to the user

4. Ensure service availability

When users ask about or want to execute corresponding service management, you should also execute the previous step's help query to ensure the service exists and is available.

5. OBS usage commands

In KooCLI, some functionality of the obsutil tool for managing OBS data via command line has been integrated. Specific functions and commands strictly refer to and execute according to the help output steps mentioned above.
If the operation is not found, you need to prompt the user to install obsutil to obtain complete functionality and explain the reason.

*** OBS Command Explanation: ***

OBS-related commands in KooCLI may exist in two forms:
1. OpenAPI style:
   hcloud OBS 
2. OBS integrated commands / obsutil style:
   hcloud obs 
The two have different parameter systems, must check help separately before execution:
hcloud OBS --help
hcloud OBS  --help
hcloud obs help
hcloud obs help 

6. Filter and format output

KooCLI supports three output formats: json, table, tsv. Default output is in json format.
You can use the "--cli-output" parameter to specify any of the aforementioned output formats, and you can also use the "--cli-query" option with JMESPath expression to perform JMESPath query on json results, filtering out information the user needs.

ParameterParameter Purpose
cli-outputcli-o response data output format, can be one of: json, table, tsv
cli-querycli-query JMESPath path for filtering response data
cli-output-numcli-output-num whether to print line numbers in table output. Values: true or false

Output Format Control

# JSON format (recommended for Agent)
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=json

# Table format (suitable for manual viewing)
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=table

# Text format
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=text

JMESPath Filtering

Use --cli-query to extract specific fields:

# Extract specific fields
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=json \
  --cli-query "items[].{ID:id,Name:name,Status:status}"

# Filter specific status
hcloud   \
  --cli-profile agent-profile \
  --cli-region cn-north-4 \
  --cli-output=json \
  --cli-query "items[?status=='ACTIVE'].{ID:id,Name:name,Status:status}"

Note: JMESPath query fields must be written according to actual JSON return structure, cannot assume all list interfaces return items.

7. Debugging

When troubleshooting KooCLI command failures, first add --cli-debug=true after the specific execution command to view underlying requests, responses, endpoints, parameter parsing, and authentication-related information.

8. Common issues

KooCLI divides errors encountered during command calls into five types, declaring their specific type at the beginning of error prompt messages. The positioning methods for various errors are as follows:

  1. [NETWORK_ERROR]: Usually HTTP request exceptions, please check network connection;
  2. [CLI_ERROR]: Usually errors caused by KooCLI's own exceptions during command processing, please contact KooCLI oncall for assistance;
  3. [USE_ERROR]: Usually errors caused by incorrect parameters in commands, please make corresponding modifications according to error prompts;
  4. [OPENAPI_ERROR]: Usually errors occurring when calling cloud service APIs, please contact relevant cloud service oncall for assistance;
  5. [APIE_ERROR]: Usually errors occurring when calling API Explorer to obtain metadata, please contact API Explorer cloud service oncall for assistance.

When encountering errors, query help based on error type and interact with users step by step to resolve.

9. Security

Credential Security

  1. Never expose AK/SK values in conversations or commands (echo $ACCESS_KEY_ID is prohibited)
  2. Never let users directly input AK/SK in conversations
  3. Never use hcloud configure set to pass plaintext credentials
  4. Only use hcloud configure list to check credential status
  5. Cloud environments recommend using IAM users rather than main accounts
  6. Enable MFA (Multi-Factor Authentication) for sensitive operations

Operation Security

  1. Must obtain user confirmation before modification operations (security group rules, restart, deletion, etc.)
  2. Prefer read-only APIs, avoid modifying resource status
  3. Production environment operations require risk warnings
  4. Sensitive information must never appear in report output (AK/SK, passwords, etc.)

Configuration Security

  • Use independent profiles for different environments
  • Regularly rotate credentials
  • Use principle of least privilege
  • Clean up temporary profiles
  • Encrypt sensitive configuration information

Parameter Verification

Global Parameters

ParameterDescriptionExample
--cli-profileConfiguration file name--cli-profile dev
--cli-regionRegion--cli-region cn-north-4
--cli-outputOutput format--cli-output=json
--cli-queryJMESPath query--cli-query "items[].{ID:id,Name:name}"
--cli-debugDebug mode--cli-debug=true

Authentication Parameters

Authentication ModeRequired ParametersOptional Parameters
AKSK--cli-access-key, --cli-secret-key--cli-security-token
Profile--cli-profile--cli-mode, --cli-region
ECS Agency--cli-mode=ecsAgency--cli-region
SSO--cli-sso-start-url, --cli-sso-region--cli-profile, --cli-region
AssumeRole--cli-agency-domain-id, --cli-agency-name, --cli-source-profile--cli-region

Service-Specific Parameters

Use hcloud --help to view parameter list for specific operations.

Output Format

KooCLI supports three output formats:

JSON Format (Default)

hcloud ECS ListInstances/v3 --cli-region=cn-north-4 --cli-output=json

Applicable Scenarios: Automated scripts, API integration, data extraction

Table Format

hcloud ECS ListInstances/v3 --cli-region=cn-north-4 --cli-output=table

Applicable Scenarios: Manual viewing, quick browsing

TSV Format

hcloud ECS ListInstances/v3 --cli-region=cn-north-4 --cli-output=tsv

Applicable Scenarios: Import to spreadsheets, data processing

JMESPath Query

hcloud ECS ListInstances/v3 --cli-region=cn-north-4 --cli-output=json --cli-query "servers[?status=='ACTIVE'].{ID:id,Name:name,Status:status}"

Verification Methods

Installation Verification

  1. Version check: hcloud version should return 7.2.2 or higher
  2. Help verification: hcloud --help should display available service list

Authentication Verification

  1. Profile verification: hcloud configure list displays configured profile
  2. Permission verification: hcloud IAM ListUsers/v3 --cli-profile tests IAM permissions

Command Verification

  1. Help verification: Execute hcloud --help for each service to confirm available operations
  2. Parameter verification: Use --cli-debug=true to view parameter parsing results
  3. Response verification: Check HTTP status codes and error messages returned by commands

Environment Verification

  1. Network connectivity: curl -s https://ecs.cn-north-4.myhuaweicloud.com tests service endpoint
  2. Certificate verification: Ensure system clock synchronization, certificates are valid

Best Practices

Authentication Management

  1. Use Profile mode for long-term session management
  2. Create independent Profiles for different environments (dev/test/prod)
  3. Regularly rotate AK/SK, avoid using the same credentials long-term
  4. Use IAM users instead of main account for daily operations

Command Construction

  1. First query help: hcloud --helphcloud --help
  2. Use --cli-debug=true for initial command debugging
  3. Gradually add parameters, avoid constructing complex commands at once
  4. Use --cli-query to filter and format output

Error Handling

  1. Read error type prefixes: [NETWORK_ERROR], [CLI_ERROR], [USE_ERROR], [OPENAPI_ERROR], [APIE_ERROR]
  2. Check network connectivity: for [NETWORK_ERROR]
  3. Verify parameter format: for [USE_ERROR]
  4. Check API documentation: for [OPENAPI_ERROR]

Performance Optimization

  1. Use --cli-output=json for automated processing
  2. Properly use --cli-query to reduce data transfer
  3. Use scripts instead of interactive commands for batch operations
  4. Cache frequently used configurations to avoid repetitive input

Notes

Usage Limitations

  1. Version compatibility: Ensure KooCLI version is compatible with service API versions
  2. Regional restrictions: Some services are only available in specific regions
  3. API quotas: Pay attention to API call frequency limits
  4. Network requirements: Some operations require specific network environments

Common Pitfalls

  1. Parameter order: Some services are sensitive to parameter order
  2. JSON format: Complex parameters require correct JSON format
  3. Region settings: Forgetting to set --cli-region results in operations in default region
  4. Output parsing: Table format output may be truncated due to terminal width

Troubleshooting

  1. Enable debugging: --cli-debug=true displays detailed request information
  2. Check logs: View log files in ~/.hcloud/logs/
  3. Version check: Ensure KooCLI version is up to date
  4. Network diagnostics: Use curl to test service endpoint reachability

Reference Documents

  • ./references/installation-guide.md — Installation guide
  • ./references/cli-troubleshooting.md — Error troubleshooting
  • ./references/common-workflows.md — Common workflows
  • ./references/parameter-format.md — Parameter format rules
  • ./references/service-catalog.md — Service catalog
  • ./references/iam-policies.md — IAM policies
  • ./references/acceptance-criteria.md — Acceptance criteria
  • ./references/core-commands.md — Core commands

Related skills

Query the total number of Huawei Cloud services available through KooCLI offline metadata. Returns the count of all supported cloud services from the cached service catalog. Triggers include: "how many Huawei Cloud services", "count Huawei Cloud services", "华为云服务总数", "华为云有多少个服务", "查询华为云服务数量".

1 installs

Queries Huawei Cloud Cloud Connect (CC) resources via hcloud CLI. Covers cloud connection instances (single + list), bandwidth packages (single + list), inter-region bandwidths (single + list), network instances (single + list), cloud connection routes (single + list), and cross-account authorisations (granted + received). No write operations. Use this skill when the user needs to inspect cross-cloud connectivity topology, check bandwidth package status, review inter-region bandwidth allocation, query network instances attached to a cloud connection, troubleshoot routing in Cloud Connect, or audit cross-account authorisation relationships (who authorised whom). Triggers: 云连接, CC, Cloud Connect, 带宽包, bandwidth package, 域间带宽, inter-region bandwidth, 网络实例, network instance, 路由查询, cloud connection route, 跨云网络, cross-cloud connectivity, 授权, authorisation, 被授权, permission, 跨账号, cross-account.

Generate Huawei Cloud Terraform configurations and execute deployment with user-guided approval. Use this skill when users want to create Huawei Cloud infras...

1 installs

Generate Huawei Cloud pre-order price estimates, safely provision allowlisted resources via hcloud, and guide unsubscribe requests to the console only. Use this skill whenever the user mentions 华为云/Huawei Cloud/hcloud with 报价/询价/价格/quote/pricing/budget, 开通/购买/创建/provision/create, or 退订/unsubscribe. Create requires runtime help, --dryrun, fee review, and confirmation. Never run or emit unsubscribe CLI/API. Refuse other clouds, credentials, payment/renewal/delete, and non-allowlisted writes.

4 installs

Queries Huawei Cloud billing and fee details only when Terraform needs a billing or pricing inquiry. Covers balances, bills, coupons, cash coupons, stored-value cards, orders, refunds, costs, free resources, resource usage, enterprise accounts, and on-demand/period/ELB/NAT/DCS pricing. No write operations. Use this skill only when Terraform requires billing details, invoice/bill summaries, coupon or balance status, refund/order billing status, or pricing inquiry. Triggers: Terraform 账单查询, Terraform 费用查询, Terraform 价格询价, Terraform 询价, Terraform billing query, Terraform pricing inquiry, Terraform price quote, Terraform bill summary.

by huaweiclouddev-dev

Queries Huawei Cloud ECS (Elastic Cloud Server) resources in read-only mode. Covers ECS instances, flavors, keypairs, quotas, server groups, block devices, NICs, VNC console, launch templates, recycle bin, scheduled events, and tags. No write operations. Use this skill when the user needs to query ECS instance details, list flavors, check server status, view block devices, or inspect ECS resource attributes. Triggers include: 查询ECS, ECS实例查询, 云服务器查询, 弹性云服务器, ECS规格, ECS配额, 云服务器列表, ECS详情, query ECS, list ECS servers, show server details, ECS flavors, ECS quotas, ECS keypairs, server groups, block devices, ECS inventory, cloud server list, ecs list, ecs query, ecs show.

More from huaweicloud-skills-team

Browse all skills

Manage Huawei Ascend NPUs with natural language commands that translate to npu-smi, locally or over SSH.

by huaweicloud-skills-team7 installs

Deploy and test LLM, VL, Embedding, and Rerank models on Huawei Cloud Ascend 910B DevServer with single- or dual-node topologies.

by huaweicloud-skills-team7 installs

Read-only queries against Huawei Cloud resources for inventory, verification, and parameter discovery.

by huaweicloud-skills-team6 installs

Query Huawei Cloud IAM resources (users, groups, policies, agencies, AK/SK, MFA, security settings) read-only via local Python SDK.

by huaweicloud-skills-team6 installs