Huawei Cloud SFS File System List
Overview
Query the SFS (Scalable File Service) file-system list of a tenant region
through KooCLI hcloud SFSTurbo ListShares (read-only), with a fallback to the
official huaweicloudsdksfsturbo v1 SDK (SFSTurboClient.list_shares, GET
/v1/{project_id}/sfs-turbo/shares/detail). The skill is aimed at storage
resource inventory, daily operations patrol, and as a pre-query step for other
SFS skills that need a file-system ID.
Architecture:
agent → python3 scripts/list_sfs.py → hcloud SFSTurbo ListShares --cli-region=<region>
→ Huawei Cloud SFS OpenAPI (regional endpoint) → parsed JSON → table / --json / --names-only
(hcloud binary missing) → fallback: huaweicloudsdksfsturbo v1 SFSTurboClient.list_shares
Key properties:
- Read-only by design — the only API ever invoked is
ListShares(GET). A write-intent guard scans the user arguments and validates the operation name; mutating intents (create / delete / expand / shrink / resize / mount / unmount / attach / detach / restore / reboot ...) are rejected with an explicit message before any command runs. - CLI first, SDK fallback — KooCLI is the primary execution path; when the
hcloud binary is absent, the script falls back to the official
huaweicloudsdksfsturbov1 SDK (list_shares). Credentials are always read by the CLI profile / SDK environment — never handled by the script. - Full-field table output — the default table renders the union of all
fields returned by ListShares, with
availability_zonesurfaced explicitly and nestedmetadataJSON-encoded. - Client-side filtering — SFS
ListSharesaccepts onlylimit/offset, so--name/--id/--status/--share-proto/--azare applied locally after the paged query completes. - Offline-testable — every code path (paging, filtering, error classification, guard, SDK fallback) is covered by unit tests that mock the hcloud subprocess.
Scope: this skill lists file systems. It does not list objects inside a file system, does not report quota/usage, and does not list the SFS 3.0 「通用文件系统」 (
ListFileSystems) product — those require a separate skill/Issue.
Out of scope: every mutating SFS action (create / delete / expand / shrink / rename / ACL / permission rules / backend binding). Those require a dedicated write-capable skill and explicit user confirmation.
Prerequisites
- KooCLI (
hcloud) installed — see references/cli-installation-guide.md. Alternative:pip install huaweicloudsdkcore huaweicloudsdksfsturboto enable the SDK fallback path. - Active credential profile — configure credentials out-of-band
(
hcloud configurein your terminal, or credential environment variables). Never paste AK/SK into chat; the script never reads, echoes, or stores secrets itself — authentication is delegated entirely to the hcloud profile / SDK environment. - IAM permission — read-only permission for listing SFS file systems; least-privilege policy in references/iam-policies.md.
- Python 3.8+ (standard library only — argparse / json / subprocess / re).
- Outbound HTTPS access to
sfs-turbo.<region>.myhuaweicloud.com.
Workflow
- Confirm the target region (default
cn-north-4); every SFS call is region-scoped. - Confirm hcloud readiness (optional, read-only):
hcloud configure list. - Run the list script with the desired output mode and filters.
- Read the result — table for humans,
--jsonfor downstream tooling,--names-onlyfor a compact inventory. - Handle the empty / error cases per the Error Handling table below.
Core Commands
# Full-field table (default)
python3 scripts/list_sfs.py --region cn-north-4
# Raw JSON of every returned field
python3 scripts/list_sfs.py --json
# Compact file-system name + ID inventory
python3 scripts/list_sfs.py --names-only
# Just the number of matching file systems
python3 scripts/list_sfs.py --count-only
# Filter by name / id (client-side, case-insensitive substring)
python3 scripts/list_sfs.py --name sfs-prod
python3 scripts/list_sfs.py --id 8be2f1a3
# Filter by status / protocol (client-side, exact)
python3 scripts/list_sfs.py --status available
python3 scripts/list_sfs.py --share-proto NFS
# Filter by availability zone (client-side, case-insensitive substring)
python3 scripts/list_sfs.py --az cn-north-4a
# Combine filters + custom page size
python3 scripts/list_sfs.py --region cn-south-1 --share-proto NFS --az cn-south-1a --names-only --page-size 100
Equivalent direct KooCLI command (the script wraps exactly this call, with paging):
hcloud SFSTurbo ListShares --cli-region=cn-north-4 --limit=200 --offset=0
Parameter Confirmation
| Parameter | Required | Description | Example |
|---|---|---|---|
--region / -r |
No | Huawei Cloud region (default cn-north-4) |
cn-south-1 |
--json |
No | Output the raw file-system array as JSON | — |
--names-only |
No | Output a compact name + ID inventory | — |
--count-only |
No | Output only the number of matching file systems | — |
--name |
No | Filter by file-system name (client-side substring) | sfs-prod |
--id |
No | Filter by file-system ID (client-side substring) | 8be2f1a3 |
--status |
No | Filter by status (client-side exact) | available |
--share-proto |
No | Filter by protocol (client-side exact) | NFS, CIFS |
--az |
No | Filter by availability zone (client-side substring) | cn-north-4a |
--page-size |
No | Page size for ListShares (default 200, max 200; values outside [1, 200] are clamped) |
100 |
--operation |
No | hcloud SFSTurbo operation name; only ListShares is allowed |
ListShares |
Output-mode precedence: --count-only → --names-only → --json → table (default).
Write-Intent Guard
- The script scans flag names plus the
--operationvalue for mutating vocabulary (create,delete,update,expand,shrink,resize,mount,unmount,attach,detach,restore,reboot, and SFS operation names such asCreateShare,DeleteShare,ExpandShare). - The values of the read-only filter flags (
--name,--id,--status,--share-proto,--az,--region,--page-size,--limit,--offset) are not scanned: they are query data and may legitimately contain write-looking words (e.g. a file system nameddelete-test). - Any hit raises
GuardError, prints[错误] 检测到写操作意图 ... 已被守卫拦截, and exits with code 1 before a single hcloud command is executed. The guard runs on the raw argv before argparse, so a mutating flag such as--create-shareis reported as a guard violation rather than an "unrecognized argument" error. - Only
hcloud SFSTurbo ListShares(GET) — or the SDKlist_sharescall in the fallback path — is ever constructed bybuild_command(); there is no code path that can issue a mutating SFS API call.
KooCLI Command Format Standard
hcloud <Service> <Operation> --cli-region=<region> [--key=value ...]
- Service name — exact KooCLI title-case service name:
SFSTurbo(KooCLI's file-storage service;SFSis not a registered KooCLI service). - Operation name — PascalCase:
ListShares. - Region parameter —
--cli-region=<value>, e.g.--cli-region=cn-north-4(required for every concrete SFS call). - Simple parameter —
--key=value, e.g.--limit=200,--offset=20. - REST path (official SDK
_http_info) —GET /v1/{project_id}/sfs-turbo/shares/detail(huaweicloudsdksfsturbov1_list_shares_http_info); project_id is resolved by KooCLI from the credential profile.
Error Handling
| Scenario | Behavior |
|---|---|
| Empty file-system list | Exit 0, prints 当前区域(<x>)无 SFS 文件系统 (+ active filters) |
| 403 / insufficient IAM permission | Exit 1, 无权限访问 SFS,请检查 IAM 权限 hint |
| Missing / invalid AK-SK | Exit 1, explicit hint to configure hcloud credentials out-of-band (never in chat) |
| hcloud not installed | Exit 1 after SDK fallback also unavailable, hint to install KooCLI or pip install huaweicloudsdkcore huaweicloudsdksfsturbo |
| Network / API failure | Exit 1 with the hcloud stderr excerpt |
KooCLI usage error ([USE_ERROR] ..., even with exit code 0) |
Exit 1, explicit hcloud 参数错误 hint pointing to hcloud SFSTurbo ListShares --help |
| Write intent detected | Exit 1, GuardError message, no command executed |
Exit codes: 0 success / empty region; 1 config, auth, guard, or API error.
Edge Cases
| Scenario | Handling |
|---|---|
creating / error file systems |
Reported with their state, not treated as failure |
--name / --id / --az filter |
Applied client-side (case-insensitive substring) after the full paged query — the SFS request itself has no such parameters |
| Large file-system count | Automatic offset paging (count aware, full-page fallback, max 100 pages) |
--page-size above the API cap |
Clamped to 200 (SFS Turbo ListShares rejects limit > 200); below 1 clamped to 1 |
| Extra response fields | Table columns are built from the union of returned fields — new fields appear automatically |
| Field missing on a file system | Rendered as - in the table |
Nested metadata |
JSON-encoded in the table cell |
| Non-JSON hcloud output | ApiError with the raw excerpt (first 200 chars) |
| hcloud absent, SDK installed | Transparent fallback to huaweicloudsdksfsturbo list_shares, same output modes |
| User asks to create/delete/expand/mount | Out of scope — blocked by the write-intent guard; a write-capable skill with explicit user confirmation is required |
Testing
Offline unit tests with a mocked hcloud subprocess (no credentials, no network):
python3 -m unittest discover -s tests -v
Coverage: write-intent guard (read passes / create / delete / expand / shrink /
resize / mount / unmount / attach / detach / restore / reboot / operation
whitelist / filter values not blocked / --offset not blocked), command
construction (limit + offset, no write flags), JSON extraction (plain / wrapped
/ list / invalid), file-system extraction (shares / file_systems / bare
list), failure classification (missing AK/SK, 403, generic, [USE_ERROR] with
rc=0), paging (count-aware multi-page), SDK fallback (success and unavailable,
request construction, ShareInfo attribute remapping), client-side filtering
(name / id / status / protocol / az / descriptions), rendering (table with the
preferred columns / names / summary lines / fallbacks), and all main() output
modes (table / json / names / count-only) including empty, filter, and error
paths.
Reference Documents
| Document | Content |
|---|---|
| references/iam-policies.md | Least-privilege read-only IAM policy |
| references/cli-installation-guide.md | KooCLI installation and credential configuration |
| references/verification-method.md | How the skill and its tests were verified |
| references/dataflow-diagram.md | Mermaid data flow diagram |
| references/acceptance-criteria.md | Acceptance criteria checklist |
