Memory

huawei-cloud-obs-total-size

Try it

Queries the total storage size of Huawei Cloud OBS (Object Storage Service) buckets and returns ONLY the size value — a single number, in bytes by default. Supports querying the total size of one bucket or the combined total across all buckets under the account. Uses the KooCLI obsutil-backed `hcloud OBS ls ... -du -bf=raw` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know the total size of an OBS bucket or the overall OBS storage usage, e.g. for capacity review, cost estimation or storage planning. Triggers include: OBS total size, OBS bucket size, total storage usage, bucket capacity, OBS大小, OBS总大小, OBS容量, 桶大小, 查询OBS大小, 存储占用, OBS存储量.

What it does

Queries the total storage size of Huawei Cloud OBS (Object Storage Service) buckets and returns ONLY the size value — a single number, in bytes by default. Supports querying the total size of one bucket or the combined total across all buckets under the account. Uses the KooCLI obsutil-backed `hcloud OBS ls ... -du -bf=raw` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know the total size of an OBS bucket or the overall OBS storage usage, e.g. for capacity review, cost estimation or storage planning. Triggers include: OBS total size, OBS bucket size, total storage usage, bucket capacity, OBS大小, OBS总大小, OBS容量, 桶大小, 查询OBS大小, 存储占用, OBS存储量.

The skill document

Huawei Cloud OBS Total Size Skill

Overview

This skill queries the total size of Huawei Cloud OBS buckets and returns only the size value (a single number). It is a read-only statistics skill: it never creates, modifies, or deletes buckets, directories, or objects.

Architecture:

Agent → hcloud CLI (KooCLI OBS / obsutil, primary) → Huawei Cloud OBS API
       ↘ huaweicloudsdkobs Python SDK (fallback)            ↗

Two query scopes:

ScopeDescriptionExample
Single bucketTotal size of one bucket only--bucket my-bucket5002295
All buckets (default)Combined total size across all buckets under the account--all9533151096

Applicable Scenarios:

  • Capacity review: "how much storage does this bucket / my OBS account use?"
  • Cost estimation: estimate OBS storage billing based on total bytes
  • Storage planning: compare usage before migration or quota changes
  • Compliance auditing: track total storage growth

Prerequisites

  1. hcloud CLI (KooCLI) installed and authenticated — See references/cli-installation-guide.md
  2. obsutil installed — required by the hcloud OBS ls command (bundled with KooCLI or standalone)
  3. OBS credentials configured for obsutilhcloud OBS ls reads AK/SK/endpoint from the obsutil config file (.obsutilconfig in the user home directory), which is separate from the KooCLI account credentials
  4. Python 3.8+ with huaweicloudsdkobs package (SDK fallback) — pip install huaweicloudsdkobs
  5. IAM permissionsobs:bucket:ListBucket, obs:object:List, obs:bucket:ListAllMyBuckets — See references/iam-policies.md

跨区域桶(Multi-region)--all 会从 hcloud OBS ls 的输出解析每个桶所属区域,并按桶所属区域 动态绑定 endpoint(CLI 用 -e=obs..myhuaweicloud.com,SDK 用桶的 location 构造客户端), 因此账号下存在多区域桶时仍可正确汇总。单个桶查询失败(桶不存在 / 无权限)会跳过并给出告警, 不会中断整次求和。

OBS credentials are separate. Before running, check whether obsutil credentials are configured:

hcloud OBS ls -s -limit=1

If the output is Please set ak, sk and endpoint in the configuration file! or an InvalidAccessKeyId error, obsutil credentials are not configured. Ask the user to configure them in their own terminal (never ask the user to paste AK/SK into the conversation). Provide the following example command:

hcloud obs config -i= -k= -e=obs..myhuaweicloud.com

Example (cn-north-4): hcloud obs config -i= -k= -e=obs.cn-north-4.myhuaweicloud.com

Workflow

  1. Confirm the scope — ask the user which OBS bucket to measure, or whether they want the total across all buckets
  2. Verify prerequisiteshcloud version, hcloud OBS ls -s -limit=1 to confirm obsutil credentials
  3. Run the query — use the script scripts/query_obs_total_size.py (primary) with the appropriate flags
  4. Return the size — the script prints a single number; relay that number to the user

Core Commands

Total Size of a Single Bucket (Primary)

Returns the total size of one bucket, in bytes:

python3 scripts/query_obs_total_size.py --bucket 

Total Size Across All Buckets

Returns the combined total size of all buckets under the account, in bytes. Buckets in regions other than the configured endpoint are queried with their own regional endpoint automatically; a single inaccessible bucket is skipped with a warning instead of aborting the whole sum:

python3 scripts/query_obs_total_size.py --all

--all is the default when --bucket is not given:

python3 scripts/query_obs_total_size.py

Different Output Units

# MB
python3 scripts/query_obs_total_size.py --all --unit mb

# Human readable (e.g. 8.88GB)
python3 scripts/query_obs_total_size.py --all --human

Force SDK Executor

If the CLI/obsutil path is unavailable, force the Python SDK:

python3 scripts/query_obs_total_size.py --all --executor sdk

Direct CLI Command (for reference)

The underlying obsutil command the script uses for a single bucket is hcloud OBS ls obs:/// -du -bf=raw, which prints [DU] Total bucket size: N. Prefer the script commands above; use the raw obsutil command only for manual inspection.

Parameter Confirmation

ParameterRequiredDescriptionExample
--bucketNo*OBS bucket name to measuremy-bucket
--allNo*Total size across all buckets (default)--all
--unitNoOutput unit: bytes, kb, mb, gb--unit mb
--humanNoHuman readable size (e.g. 4.77MB)--human
--regionNoHuawei Cloud region (SDK fallback only)cn-north-4
--executorNoauto (default), cli, or sdk--executor sdk

* Either --bucket or --all must be chosen; --all is the default when neither is given.

Reference Documents

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

KooCLI Command Format Standard

The hcloud OBS module is backed by obsutil. The -du flag queries the size of a storage space and -bf=raw prints bytes exactly:

FeatureDescriptionExample
Service nameOBS (obsutil-backed)hcloud OBS ls
Operation nameLowercase obsutil commandls
Query size-du flag obtains the size of the specified storage spacehcloud OBS ls obs://bucket/ -du
Byte format-bf=raw prints sizes in exact byteshcloud OBS ls obs://bucket/ -du -bf=raw
Credentialsobsutil config file (.obsutilconfig)-i=AK -k=SK -e=endpoint

Related skills

Query Huawei Cloud OBS (Object Storage Service) statistics: list buckets with capacity and object counts, query extranet/intranet download traffic with month...

by huaweicloud-skills-team1 installs

Counts the total number of files (objects) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting all files in a whole bucket or all files under a given prefix (folder). Zero-byte folder-marker keys (ending with '/') are excluded — only real files/objects are counted. Uses the KooCLI obsutil-backed `hcloud OBS ls ... -limit=0` command (primary, parses the "File number" line) or the huaweicloudsdkobs Python SDK (fallback, paginated ListObjects). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many files or objects an OBS bucket (or a folder inside it) contains, e.g. for inventory, capacity review, migration planning or compliance checks. Triggers include: "count OBS files", "OBS file count", "number of files in bucket", "how many objects in bucket", "OBS object count", "OBS文件数量", "查询OBS文件总数", "OBS文件总数", "桶里有多少个文件", "统计文件数量", "对象数量", "查询对象总数".

1 installs

Counts the number of directories (folders) inside a Huawei Cloud OBS (Object Storage Service) bucket and returns ONLY the numeric count. Supports counting the immediate subdirectories under the bucket (or a given prefix) as well as all nested directories recursively. Uses the KooCLI obsutil-backed `hcloud OBS ls -d` command (primary) or the huaweicloudsdkobs Python SDK (fallback). Read-only — never creates, modifies or deletes any resource. Use this skill whenever the user wants to know how many directories/folders an OBS bucket contains, e.g. for inventory, capacity review or structure checks. Triggers include: "count OBS directories", "OBS directory count", "number of directories in bucket", "OBS folder count", "how many folders in bucket", "OBS目录数量", "查询OBS目录数量", "OBS目录数", "桶目录数量", "目录数量", "文件夹数量", "统计目录", "目录统计".

Lists the Huawei Cloud OBS (Object Storage Service) buckets of the current tenant and returns the FOLDER names inside a bucket — both the top-level folders of a bucket and the sub-folders under a given prefix. Uses the KooCLI obsutil-backed command `hcloud OBS ls` (primary, parses the "Folder list" section of obsutil output) or the huaweicloudsdkobs Python SDK (fallback, ListObjects with delimiter=/). Read-only — never creates, modifies or deletes any bucket, folder or object. Use this skill whenever the user wants to see which OBS buckets exist or which folders a bucket (or a folder inside it) contains, e.g. for daily inspection, inventory, data organization review or troubleshooting. Triggers include: "list OBS buckets", "OBS bucket list", "list folders in bucket", "OBS folder names", "查询OBS列表", "OBS桶列表", "OBS文件夹名称", "桶里有哪些文件夹", "查询obs列表", "返回obs列表中文件夹名称", "OBS目录列表".

Skill specialized for creating buckets on Huawei Cloud OBS. Use this skill when users need to create OBS buckets, set bucket properties, configure access per...

by huaweicloud-skills-team1 installs

Queries Huawei Cloud storage resources (EVS/OBS/SFS/CBR). Covers cloud disks (volumes/snapshots/types/quotas/recycle bin), OBS buckets (ACL/metadata/notifica...

by huaweicloud-skills-team1 installs