Documents

huawei-cloud-dcs-count

Try it

Count the number of Huawei Cloud DCS (Distributed Cache Service) instances — managed Redis and Memcached — in a region and output the count. Returns the authoritative instance_num from the ListInstances API, so the reported number is always exact regardless of page size. Supports counting all instances, counting Redis-only (or Memcached-only) instances via the per-engine breakdown, filtering by status (RUNNING, FROZEN, etc.), and a per-status count breakdown via ListNumberOfInstancesInDifferentStatus. Read-only — never creates, modifies or deletes any resource. Use for Redis/DCS instance inventory, daily inspection, or cost review. Triggers include: count Redis, Redis count, DCS instance count, how many Redis instances, number of Redis instances, Redis数量, DCS实例数量, Redis实例数量, 查询Redis数量, 查询redis数量, 缓存实例数量, DCS数量, 统计Redis实例数, redis实例个数.

What it does

Count the number of Huawei Cloud DCS (Distributed Cache Service) instances — managed Redis and Memcached — in a region and output the count. Returns the authoritative instance_num from the ListInstances API, so the reported number is always exact regardless of page size. Supports counting all instances, counting Redis-only (or Memcached-only) instances via the per-engine breakdown, filtering by status (RUNNING, FROZEN, etc.), and a per-status count breakdown via ListNumberOfInstancesInDifferentStatus. Read-only — never creates, modifies or deletes any resource. Use for Redis/DCS instance inventory, daily inspection, or cost review. Triggers include: count Redis, Redis count, DCS instance count, how many Redis instances, number of Redis instances, Redis数量, DCS实例数量, Redis实例数量, 查询Redis数量, 查询redis数量, 缓存实例数量, DCS数量, 统计Redis实例数, redis实例个数.

The skill document

Huawei Cloud DCS Count Skill

Overview

This skill counts Huawei Cloud DCS (Distributed Cache Service) instances — the managed Redis / Memcached service — in a region and outputs the number. It supports four counting modes:

  • Total count — number of all DCS instances in a region.
  • Redis / Memcached count — number of instances for a specific engine, derived from the per-engine breakdown of ListNumberOfInstancesInDifferentStatus.
  • Filtered count — number of instances matching a status (e.g. RUNNING).
  • Per-status breakdown — counts of instances grouped by lifecycle status (running, creating, frozen, error, etc.) via ListNumberOfInstancesInDifferentStatus.

The total count is taken from the authoritative instance_num field returned by the list API, so the result is exact regardless of page size — no pagination sum is needed for the count itself.

Architecture:

Agent → hcloud CLI (primary) → Huawei Cloud DCS API
       ↘ Python SDK (fallback) ↗

Applicable Scenarios:

  • Daily inspection: how many Redis/DCS instances exist in a region
  • Cache instance inventory and cost review
  • Redis-only inventory when the project also uses Memcached
  • Capacity planning and pre-migration verification
  • Quick health check of how many instances are running vs. non-running

Prerequisites

  1. hcloud CLI installed and authenticated — See references/cli-installation-guide.md
  2. Python 3.8+ with the huaweicloudsdkdcs package (SDK fallback)
  3. Huawei Cloud AK/SK configured via environment variables or the hcloud CLI profile
  4. IAM permissions — read-only access to DCS instances — See references/iam-policies.md

Workflow

  1. Identify query scope — Decide which region to query and which counting mode to use (total, engine-specific, status-filtered, or per-status breakdown)
  2. Select execution mode — Use the hcloud CLI by default; fall back to the Python SDK if the CLI is unavailable
  3. Execute the query — Run the count commands and capture instance_num from each response
  4. Present results — Output the DCS instance count to the user

Core Commands

Count All DCS Instances

PurposeCommand
Count all DCS (Redis/Memcached) instanceshcloud DCS ListInstances --cli-region={region} --limit={limit}

Count-Only Lookup (jq)

To return just the numeric count:

hcloud DCS ListInstances --cli-region={region} --limit={limit} | jq -r '.instance_num'

Count Redis-Only Instances

The ListNumberOfInstancesInDifferentStatus API returns per-engine status statistics. Sum the redis.* status counters for the total Redis count:

hcloud DCS ListNumberOfInstancesInDifferentStatus --cli-region={region} | jq '[.redis | to_entries[].value | tonumber] | add'

For just the number of running Redis instances:

hcloud DCS ListNumberOfInstancesInDifferentStatus --cli-region={region} | jq -r '.redis.running_count'

Filtered Count by Status

PurposeCommand
Count instances in a given statushcloud DCS ListInstances --cli-region={region} --status={status} --limit={limit}

To return just the numeric count for a status:

hcloud DCS ListInstances --cli-region={region} --status=RUNNING --limit={limit} | jq -r '.instance_num'

Valid {status} values include: RUNNING, CREATING, FROZEN, ERROR, RESTARTING, EXTENDING, CLOSING, CLOSED, FLUSHING, UPGRADING, RESTORING, MIGRATING.

Per-Status Count Breakdown

PurposeCommand
Count instances grouped by lifecycle statushcloud DCS ListNumberOfInstancesInDifferentStatus --cli-region={region}

To extract the number of running Redis instances:

hcloud DCS ListNumberOfInstancesInDifferentStatus --cli-region={region} | jq -r '.redis.running_count'

SDK Fallback Examples

When the CLI is unavailable, use the Python SDK:

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdcs.v2.region.dcs_region import DcsRegion
from huaweicloudsdkdcs.v2 import DcsClient, ListInstancesRequest

credentials = BasicCredentials().with_ak(os.getenv("HUAWEI_ACCESS_KEY")) \
                                .with_sk(os.getenv("HUAWEI_SECRET_KEY"))

client = DcsClient.new_builder() \
    .with_credentials(credentials) \
    .with_region(DcsRegion.value_of("{region}")) \
    .build()

response = client.list_instances(ListInstancesRequest(limit={limit}))
print(response.instance_num)

Per-engine count via SDK:

from huaweicloudsdkdcs.v2 import ListNumberOfInstancesInDifferentStatusRequest

resp = client.list_number_of_instances_in_different_status(
    ListNumberOfInstancesInDifferentStatusRequest())
redis_total = sum(int(v) for k, v in resp.redis.to_dict().items() if isinstance(v, int))
print(resp.redis.running_count)

A ready-to-run helper script is provided in scripts/count_dcs_instances.py.

Parameter Confirmation

ParameterRequiredDescriptionExample
{region}YesHuawei Cloud regioncn-north-4
{limit}NoMax records per page (1-1000, default 10); does not affect instance_num100
{status}NoInstance status filter (see valid values above)RUNNING
{engine}NoEngine filter for SDK helper (redis or memcached)redis

Reference Documents

  • CLI Installation Guide
  • IAM Policies
  • Verification Method
  • Data Flow Diagram
  • Acceptance Criteria

KooCLI Command Format Standard

hcloud   --cli-region= [--key=value ...]
FeatureDescriptionExample
Service nameDCShcloud DCS ListInstances --cli-region={region}
Operation namePascalCaseListInstances, ListNumberOfInstancesInDifferentStatus
Region parameter--cli-region=--cli-region=cn-north-4
Simple parameter--key=value--limit=100

Related skills

Query Huawei Cloud DCS (Distributed Cache Service) instances, configurations, backups, slow logs, big key/hot key scan tasks, migration tasks, ACL accounts, IP whitelists, tags, quotas, and instance statistics. Provides read-only inspection capabilities for daily operations, performance troubleshooting, and compliance auditing. Triggers include: DCS query, list DCS instances, check Redis instance status, view cache configuration, backup records, slow logs, big key analysis, hot key analysis, migration task, ACL account, IP whitelist, instance quota, list DCS, query DCS, show DCS, DCS instance, Redis instance, 分布式缓存, DCS查询, DCS实例查询, 缓存实例.

Query Huawei Cloud DCS (Distributed Cache Service) instance names and list all managed Redis/Memcached instances across a region. Provides read-only name lookup, name filtering, status-based filtering, and instance ID lookup for inventory reporting and daily inspection. Triggers include: DCS list, list DCS instances, query DCS names, DCS instance name, find DCS instance, DCS name lookup, DCS instance list, Redis instance names, cache instance names, DCS inventory, 查询DCS名称, DCS实例名称, 缓存实例名称, DCS列表, DCS实例列表, 查询缓存实例名称.

Count the number of Huawei Cloud GaussDB instances in a region and output the count. Covers both GaussDB for openGauss and GaussDB (MySQL-compatible) instances. Returns the authoritative total_count from the list API, so the reported number is always correct. Read-only — never creates, modifies or deletes any resource. Use for GaussDB database inventory, daily inspection, or cost review. Triggers include: count GaussDB, GaussDB count, GaussDB instance count, how many GaussDB instances, GaussDB数量, GaussDB实例数量, 查询GaussDB数量, GaussDB总数, 统计GaussDB实例数.

1 installs

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

Read-only query of Huawei Cloud ECS, BMS, IMS, and AS resources via local Python scripts.

by huaweicloud-skills-team2 installs

Query the list of Huawei Cloud RDS (Relational Database Service, 云数据库) instances under the current tenant / project and return the RDS instance NAMES. By default the skill prints only the instance names (one per line); with extra flags it also returns id, status, engine type, flavor, private IPs and created time. Supports filtering by instance name, id, type (Single/Ha/Replica), datastore engine (MySQL/PostgreSQL/SQLServer/MariaDB) and VPC, plus pagination via limit/offset. Uses the KooCLI command `hcloud RDS ListInstances --cli-region={region}` (primary) or the huaweicloudsdkrds Python SDK (fallback). Read-only — never creates, modifies, deletes, restarts or stops any RDS instance. Use this skill whenever the user wants to list/inspect the RDS instances of the tenant or query the RDS instance name list, e.g. for database inventory, daily inspection, or cost review. Triggers include: "list RDS", "RDS list", "query RDS names", "RDS实例列表", "查询RDS", "RDS实例名称", "rds list", "how many RDS", "