huaweicloud-devkit 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/LICENSE +201 -0
  3. package/README.md +148 -0
  4. package/bin/setup.cjs +8 -0
  5. package/integrations/opencode/commands/huaweicloud-doctor.md +14 -0
  6. package/integrations/opencode/opencode.json +14 -0
  7. package/integrations/opencode/skills/huaweicloud-core/SKILL.md +30 -0
  8. package/package.json +43 -0
  9. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +44 -0
  10. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +43 -0
  11. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +44 -0
  12. package/plugins/huaweicloud-core/.mcp.json +13 -0
  13. package/plugins/huaweicloud-core/hooks/hooks.json +26 -0
  14. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +88 -0
  15. package/plugins/huaweicloud-core/safety/policy.json +86 -0
  16. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +144 -0
  17. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -0
  18. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -0
  19. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +101 -0
  20. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +73 -0
  21. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +190 -0
  22. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +124 -0
  23. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -0
  24. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -0
  25. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +56 -0
  26. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +97 -0
  27. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +29 -0
  28. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +23 -0
  29. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +131 -0
  30. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +92 -0
  31. package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -0
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +28 -0
  33. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -0
  34. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +132 -0
  35. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +58 -0
  36. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +71 -0
  37. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -0
  38. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -0
  39. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -0
  40. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +65 -0
  41. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -0
  42. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +122 -0
  43. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -0
  44. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -0
  45. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +118 -0
  46. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -0
  47. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +26 -0
  48. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +100 -0
  49. package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -0
  50. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +181 -0
  51. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -0
  52. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +77 -0
  53. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +52 -0
  54. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +59 -0
  55. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -0
  56. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -0
  57. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -0
  58. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -0
  59. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +47 -0
  60. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -0
  61. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +125 -0
  62. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -0
  63. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +94 -0
  64. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -0
  65. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +20 -0
  66. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +28 -0
  67. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +46 -0
  68. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -0
  69. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -0
  70. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -0
  71. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +265 -0
  72. package/plugins/huaweicloud-core/src/mcp-server.mjs +93 -0
  73. package/plugins/huaweicloud-core/src/safety-policy.mjs +289 -0
  74. package/plugins/huaweicloud-core/src/search-market.mjs +169 -0
  75. package/plugins/huaweicloud-core/src/setup-cli.mjs +628 -0
  76. package/plugins/huaweicloud-core/src/tools.mjs +672 -0
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: huawei-ecs
3
+ description: "Use when creating, configuring, managing, or troubleshooting ECS instances on Huawei Cloud. Covers instance creation (hcloud ECS CreateServers), flavor selection, image management, security groups, EIP binding, disk attachment, auto-scaling (AS), and troubleshooting. Triggers on: ECS, instance, flavor, image, security group, EIP, EVS, auto-scaling. NOT for: CCE container workloads (use huawei-cce), BMS bare metal servers."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud ECS
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ Always run `hcloud <Service> <Operation> --help` before constructing commands to discover exact parameter names and requirements.
12
+
13
+ ## Overview
14
+
15
+ Domain expertise for Huawei Cloud Elastic Cloud Server (ECS). Covers instance lifecycle, flavor selection, image management, networking, storage attachment, auto-scaling, and troubleshooting.
16
+
17
+ ## Prerequisites
18
+
19
+ Before creating an ECS instance from scratch, you MUST have:
20
+ - A VPC (see `huawei-vpc`)
21
+ - A subnet with DNS configured (see `huawei-vpc`)
22
+ - A security group with application ports open (see `huawei-vpc`)
23
+
24
+ If these do not exist, load the `huawei-vpc` skill first and create them before returning here.
25
+
26
+ ## Critical Warnings
27
+
28
+ | Trap | Why |
29
+ |------|-----|
30
+ | Flavor not in region | Not all flavors available everywhere. Check with ECS ListFlavors first |
31
+ | Security group denies all | New SGs deny ALL inbound. Must explicitly add rules |
32
+ | EIP bills when idle | Unattached EIP still incurs charges |
33
+ | Stopped instance still bills | Pay-per-use instances bill when stopped (unless shutdown-no-billing flavor) |
34
+ | Disk survives instance delete | Deleting instance does NOT delete system disk by default |
35
+
36
+ ## Flavor Selection Guide
37
+
38
+ Flavor families are **region-dependent**. Always run `hcloud ECS ListFlavors --cli-region=<r>` to discover available flavors before recommending.
39
+
40
+ | Scenario | Family | What to look for |
41
+ |----------|--------|-----------------|
42
+ | Web app / microservices | General-purpose (ac, s, sn, c) | 2-4 vCPU, 4-8 GB RAM |
43
+ | Database / big data | Memory-optimized (m, r) | 4-8 vCPU, 16-64 GB RAM |
44
+ | AI inference | GPU (g, p) | 8+ vCPU, 64+ GB RAM + GPU |
45
+ | HPC | High-IO (h, ir, i) | 8+ vCPU, local SSD |
46
+
47
+ > See `references/flavors.md` for discovery workflow. **Do not hardcode flavor names** — availability changes by region and over time.
48
+
49
+ ## Common Workflows
50
+
51
+ | Task | Command | Steps |
52
+ |------|---------|-------|
53
+ | List flavors | hcloud ECS ListFlavors --cli-region=<region> | references/flavors.md |
54
+ | Create instance | hcloud ECS CreateServers --server.name=<n> --server.flavorRef=<id> --server.imageRef=<id> --server.nics.1.subnet_id=<id> --server.availability_zone=<az> | references/create-instance.md |
55
+ | Find by name | See "How to search for instances" below | |
56
+ | Bind EIP | hcloud EIP AssociatePublicips --publicip_id=<id> --publicip.associate_instance_id=<port-id> --publicip.associate_instance_type=PORT | Get port ID from `hcloud ECS ListServersDetails --server_id=<id>` → `OS-EXT-IPS:port_id` |
57
+ | Security group rule | hcloud VPC CreateSecurityGroupRule --security_group_id=<id> --direction=<direction> --protocol=<protocol> | references/sg.md |
58
+ | Attach disk | hcloud EVS AttachVolume --volume_id=<id> --server_id=<id> | references/evs.md |
59
+ | Delete instance | hcloud ECS DeleteServers --servers.1.id=<id> --delete_publicip=true --delete_volume=true | references/create-instance.md |
60
+
61
+ ## How to Search for Instances
62
+
63
+ `ListServersDetails` supports `--name` for exact match only. For fuzzy search:
64
+
65
+ 1. List all instances: `hcloud ECS ListServersDetails --cli-region=<region> --limit=100`
66
+ 2. Filter client-side by name substring, tag, or status
67
+ 3. Use `--server_tags` filter if instances are tagged: `hcloud ECS ListServersDetails --server_tags.1.key=Project`
68
+
69
+ Abort if the result set is larger than `--limit` and ask the user to narrow the search.
70
+
71
+ ## Deleting Instances
72
+
73
+ - Show the user the exact command and get explicit approval before running
74
+ - By default, `--delete_publicip` and `--delete_volume` are **false** — public IP and system disk survive deletion
75
+ - Set both to `true` to avoid orphaned resources and unexpected billing
76
+ - Data disks ARE deleted by default (unlike system disk)
77
+
78
+ ## Troubleshooting
79
+
80
+ | Error | Root Cause -> Fix |
81
+ |-------|------------------|
82
+ | Cannot SSH | SG missing port 22 or no EIP -> Add ingress rule / Bind EIP |
83
+ | Flavor unavailable | Region limitation -> ListFlavors in target region |
84
+ | Insufficient resources | Stock depleted -> Change flavor or AZ |
85
+ | AuthFailure | Expired AK/SK -> hcloud configure init |
86
+ | APIGW.0802 / region permission | IAM user has no access to this region -> IAM console → User → Permissions → add region, or switch to another region |
87
+
88
+ ## Security Considerations
89
+
90
+ - MUST use security groups, not iptables
91
+ - MUST store SSH keys in DEW, never in user-data
92
+ - SHOULD enable CTS audit logging
93
+ - MUST NOT open 0.0.0.0/0 for SSH
94
+
95
+ ## MCP Tools
96
+
97
+ Prefer these tools over raw hcloud CLI — they enforce safety policies:
98
+
99
+ - huaweicloud_list_operations service=ECS
100
+ - huaweicloud_run_readonly_command for discovery (auto-redacts output)
101
+ - huaweicloud_run_approved_command for writes (requires exact command approval)
102
+ - huaweicloud_check_cli to verify hcloud is available
103
+
104
+ ## Without MCP (Fallback)
105
+
106
+ If MCP tools are NOT available (new install, session not restarted):
107
+ - Raw hcloud commands WILL appear in shell history — passwords and secrets are at risk
108
+ - Always use key_name instead of adminPass
109
+ - Verify safety manually: no secret value reads, no credential file access
110
+ - Restart session as soon as possible to enable safety policies
111
+
112
+ ## Without MCP
113
+
114
+ Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
115
+
116
+ ## Flexus (Lightweight ECS)
117
+
118
+ Flexus is the lightweight ECS family. Two variants:
119
+
120
+ | Variant | API | CLI | Billing |
121
+ |---------|-----|:---:|---------|
122
+ | **Flexus L** | HCSS (hcss:lightInstances) | ❌ No hcloud — Python SDK only | Prepaid only |
123
+ | **Flexus X** | Standard ECS API | ✅ `hcloud ECS` with `x1.*` flavors | On-demand & prepaid |
124
+
125
+ For Flexus X, use standard ECS CreateServers flow with `x1.*` flavors. For Flexus L, manual console provisioning is recommended — no KooCLI path exists.
126
+
127
+ ## References
128
+
129
+ - ECS Docs: https://support.huaweicloud.com/ecs/
130
+ - Flavor specs: references/flavors.md
131
+ - Create instance: references/create-instance.md
@@ -0,0 +1,92 @@
1
+ # Create ECS Instance SOP
2
+
3
+ **Before executing any command: If MCP tools are not available** (new session after install), restart your session or use hcloud CLI directly with caution. Commands using adminPass/password WILL appear in shell history — prefer key_name.
4
+
5
+ ## 1. Discover flavors
6
+ hcloud ECS ListFlavors --cli-region=<region> --cli-output=json
7
+
8
+ ## 2. Find availability zones
9
+ hcloud ECS NovaListAvailabilityZones --cli-region=<region>
10
+
11
+ ## 3. Find image
12
+ hcloud IMS ListImages --cli-region=<region> --__imagetype=gold --__isregistered=true --limit=20
13
+
14
+ Common image IDs (cn-south-1, verify with region):
15
+ | Image | ID |
16
+ |-------|----|
17
+ | Ubuntu 22.04 | Query live via ListImages |
18
+ | CentOS 8.2 64bit | Query live via ListImages |
19
+ | EulerOS 2.9 64bit | Query live via ListImages |
20
+
21
+ Always run ListImages to get the latest image IDs — they change over time.
22
+
23
+ ## 4. Verify or create VPC/subnet
24
+ hcloud VPC ListVpcs --cli-region=<region>
25
+ hcloud VPC ListSubnets --vpc_id=<vpc-id> --cli-region=<region>
26
+ If no VPC/subnet exists: load `huawei-vpc` skill → create VPC → create subnet (with DNS) → create security group → return here.
27
+
28
+ ## 5. Create keypair (recommended over adminPass)
29
+ hcloud ECS NovaCreateKeypair --keypair.name=<name>
30
+ Save the returned private key to a local file. The public key is auto-injected.
31
+
32
+ Password alternative:
33
+ - adminPass: 8-26 chars, must have uppercase + lowercase + digit + special char
34
+ - Passwords appear ONCE in creation output and are not retrievable
35
+ - Passwords are logged in shell history — this is a security risk
36
+
37
+ ## 6. Create instance
38
+ hcloud ECS CreateServers --cli-region=<region> --server.name=<name> --server.flavorRef=<flavor-id> --server.imageRef=<image-id> --server.nics.1.subnet_id=<subnet-id> --server.root_volume.volumetype=<type> --server.root_volume.size=<minsize> --server.vpcid=<vpc-id> --server.availability_zone=<az> --server.key_name=<keypair-name> --server.count=1
39
+
40
+ ### Bootstrap with user_data (cloud-init)
41
+
42
+ Use `--server.user_data` to run a cloud-init script at first boot. The value must be **base64-encoded**:
43
+
44
+ ```bash
45
+ # Encode the script
46
+ user_data=$(cat << 'SCRIPT' | base64
47
+ #!/bin/bash
48
+ # Your bootstrap commands here.
49
+ # Output logs: /var/log/cloud-init-output.log
50
+ SCRIPT
51
+ )
52
+
53
+ hcloud ECS CreateServers ... --server.user_data=$user_data
54
+ ```
55
+
56
+ > **Security**: Never embed secrets (passwords, AK/SK, tokens) in user_data. It is stored unencrypted and readable from within the instance via IMDS. Fetch secrets at boot from DEW/CSMS instead.
57
+
58
+ > **Debugging**: If the script didn't run, check `/var/log/cloud-init-output.log` on the instance.
59
+
60
+ ## 7. EIP (optional)
61
+ hcloud EIP CreatePublicip --publicip.type=<type> --bandwidth.size=<size> --bandwidth.share_type=<share-type> --bandwidth.name=<name>
62
+
63
+ # Get the ECS network port ID
64
+ hcloud ECS ListServersDetails --cli-region=<region> --server_id=<instance-id>
65
+ # → addresses.<vpc-id>[].OS-EXT-IPS:port_id
66
+
67
+ # Bind EIP via port
68
+ hcloud EIP AssociatePublicips --publicip_id=<eip-id> --publicip.associate_instance_id=<port-id> --publicip.associate_instance_type=PORT
69
+
70
+ ## 8. Verify
71
+ hcloud ECS ListServersDetails --cli-region=<region> --server_id=<instance-id>
72
+ Expected: status=ACTIVE
73
+
74
+ ### Verify HTTP accessibility (if EIP bound)
75
+
76
+ ```bash
77
+ # Get the EIP address from instance details
78
+ hcloud ECS ListServersDetails --cli-region=<region> --server_id=<instance-id>
79
+ # → addresses.<vpc-id>[].OS-EXT-IPS:addr
80
+
81
+ curl http://<eip-address>
82
+ # Expected: HTTP 200 (if port 80 open and web server installed)
83
+
84
+ ## 9. Delete instance (with cleanup)
85
+ hcloud ECS DeleteServers --servers.1.id=<instance-id> --delete_publicip=true --delete_volume=true
86
+ Warning: --delete_publicip and --delete_volume default to false. Set to true to avoid orphaned charges.
87
+
88
+ ## Constraints
89
+ - Name: 1-64 chars, letters/digits/hyphens
90
+ - Flavor: must be available in target region — always ListFlavors first
91
+ - Root volume: SSD 40GB min
92
+ - Keypair is safer than adminPass (passwords leak into shell history)
@@ -0,0 +1,31 @@
1
+ # EVS Cloud Disk
2
+
3
+ ## Create Volume
4
+
5
+ ```bash
6
+ hcloud EVS CreateVolume --help
7
+ # Required: --volume.availability_zone, --volume.size, --volume.volume_type
8
+ ```
9
+
10
+ ```bash
11
+ hcloud EVS CreateVolume \
12
+ --volume.availability_zone=<az> \
13
+ --volume.size=<size> \
14
+ --volume.volume_type=<type> \
15
+ --volume.name=<name>
16
+ ```
17
+
18
+ ## Attach to ECS
19
+
20
+ ```bash
21
+ hcloud EVS AttachVolume --volume_id=<vol-id> --server_id=<ecs-id>
22
+ ```
23
+
24
+ ## List / Delete
25
+
26
+ ```bash
27
+ hcloud EVS ListVolumes
28
+ hcloud EVS DeleteVolume --volume_id=<id>
29
+ ```
30
+
31
+ > Deleting an ECS instance does NOT automatically delete attached EVS volumes unless `--delete_volume=true` is set during instance deletion.
@@ -0,0 +1,28 @@
1
+ # ECS Flavor Selection
2
+
3
+ **Always discover flavors dynamically before recommending a specific flavor name.** Flavor availability varies by region and changes over time.
4
+
5
+ ## Step 1: List available flavors
6
+ hcloud ECS ListFlavors --cli-region=<region> --cli-output=json
7
+
8
+ ## Step 2: Filter by scenario
9
+
10
+ | Scenario | Look for | Preference |
11
+ |----------|----------|------------|
12
+ | Web app / microservices | General-purpose families (ac, s, sn) | 2-4 vCPU, 4-8 GB RAM |
13
+ | Database / big data | Memory-optimized families (m, r) | 4-8 vCPU, 16-64 GB RAM |
14
+ | AI inference / training | GPU families (g, p) | 8+ vCPU, 64+ GB RAM |
15
+ | HPC / high throughput | High-IO families (h, ir, i) | 8+ vCPU, local SSD |
16
+
17
+ ## Step 3: Match spec from ListFlavors output
18
+
19
+ Common naming pattern: `<family><gen>.<type>x<ratio>`
20
+ - `ac6.2xlarge.2` = ac6 family, 2xlarge (8 vCPU), ratio 2 (vCPU:RAM = 1:2 → 16 GB)
21
+
22
+ ## Do Not Hardcode
23
+
24
+ Flavor family names are region-dependent. Example discrepancies seen in testing:
25
+ - cn-south-1: ac6/ac7/kc/r-c7e (s6/m6/g6 NOT available)
26
+ - Other regions may have s6/m6/g6 families
27
+
28
+ Always run ListFlavors and pick from actual results.
@@ -0,0 +1,52 @@
1
+ # ECS Troubleshooting
2
+
3
+ 基于真实测试暴露的常见错误和诊断步骤。
4
+
5
+ ## 错误码映射
6
+
7
+ | 错误 | 根因 | 修复 |
8
+ |------|------|------|
9
+ | `Ecs.0005` flavor-image 不匹配 | 镜像虚拟化类型与规格不兼容 | 检查 image `__support_amd`/`__support_xen` 与 flavor `os_extra_specs`。BareMetal 镜像不兼容标准 ECS 规格 |
10
+ | `[USE_ERROR]不正确的参数:imagetype` | 参数名错误 | KooCLI 使用双下划线前缀:`--__imagetype=gold`(不是 `--imagetype`) |
11
+ | `[USE_ERROR]不正确的参数:chargingMode` | 参数路径错误 | 计费模式参数路径:`--server.extendparam.chargingMode=postPaid`。不传默认按需付费 |
12
+ | `[USE_ERROR]不正确的参数:__support_amd` | 参数无效 | `IMS ListImages` 某些版本不支持此过滤。去掉该参数,使用 client-side 过滤 |
13
+ | Cannot SSH | 安全组未开放22端口 或 未绑定EIP | 1) 添加入方向规则 tcp 22。2) `hcloud EIP BindPublicIp` |
14
+ | Flavor unavailable | 区域不支持该规格 | `hcloud ECS ListFlavors --cli-region=<r>` 先查。不硬编码 s6/m6 等规格名 |
15
+ | Insufficient resources | AZ 库存不足 | 换规格、换 AZ、或等待资源释放 |
16
+ | AuthFailure | AK/SK 过期或无效 | `hcloud configure init` 重新配置 |
17
+
18
+ ## 创建失败诊断流程
19
+
20
+ 1. 运行 `hcloud ECS ListFlavors` — 确认规格在目标区域可用
21
+ 2. 运行 `hcloud IMS ListImages --__imagetype=gold --limit=20` — 确认可用的公共镜像
22
+ 3. 交叉检查:flavor `os_extra_specs` 中的虚拟化类型 vs image 的 `__support_*` 属性
23
+ 4. 运行 `hcloud VPC ListVpcs` / `ListSubnets` — 确认 VPC 和子网存在
24
+ 5. 运行 `hcloud ECS NovaListAvailabilityZones` — 确认 AZ 可用
25
+ 6. 创建后:`hcloud ECS ListServersDetails --server_id=<id>` 检查状态
26
+ 7. 状态 `BUILD` → 等待。`ERROR` → 查看 job_id 详情
27
+
28
+ ## 镜像查询正确姿势
29
+
30
+ ```bash
31
+ # 正确:双下划线前缀
32
+ hcloud IMS ListImages --cli-region=<r> --__imagetype=gold --__isregistered=true --limit=20
33
+
34
+ # 按需过滤(如果参数支持)
35
+ # --virtual_env_type=FusionCompute 排除 BareMetal
36
+ # 不支持的参数不要传,用 client-side 过滤
37
+ ```
38
+
39
+ ## 密钥对 vs 密码
40
+
41
+ | 方式 | 安全 | 建议 |
42
+ |------|------|------|
43
+ | `--server.key_name=<name>` | ✅ 高 | **推荐**。先 `hcloud DEW CreateKeypair` 创建密钥对 |
44
+ | `--server.adminPass=<pw>` | ❌ 低 | 密码明文进入 shell 历史。仅测试用 |
45
+
46
+ 密码要求:8-26 字符,含大写 + 小写 + 数字 + 特殊字符。
47
+
48
+ ## 删除注意事项
49
+
50
+ - `--delete_publicip` 默认 false — EIP 不随实例删除,继续计费
51
+ - `--delete_volume` 默认 false — 系统盘不随实例删除
52
+ - 数据盘默认随实例删除(与系统盘行为相反)
@@ -0,0 +1,132 @@
1
+ ---
2
+ name: huawei-functiongraph
3
+ description: "Use when creating, deploying, or managing serverless functions on FunctionGraph. Covers triggers (APIG/OBS/timer/SMN), cold start, reserved concurrency. Triggers: FunctionGraph, serverless, function, Lambda, trigger. NOT for: CCE containers (use huawei-cce)."
4
+ version: 1
5
+ ---
6
+
7
+ # Huawei Cloud FunctionGraph
8
+
9
+ **STOP - Do not answer from general knowledge.** Follow the procedure below.
10
+
11
+ ## Overview
12
+
13
+ Domain expertise for Huawei Cloud FunctionGraph. Covers function lifecycle, code deployment, trigger configuration, and troubleshooting.
14
+
15
+ ## How to Use This Skill
16
+
17
+ 1. This skill tells you the **correct service/operation names** and **non-obvious traps**.
18
+ 2. **Parameters are discovered via `--help`, not hardcoded.** Always run `hcloud FunctionGraph <Operation> --help` before constructing commands.
19
+ 3. Detailed examples are in `references/` — load them only when needed.
20
+
21
+ ## Critical Warnings
22
+
23
+ | Trap | Why |
24
+ |------|-----|
25
+ | Service name is `FunctionGraph` | NOT `FGS`. KooCLI 7.x uses the full service name |
26
+ | CLI requires `project_id` | Get it: `hcloud IAM KeystoneListProjects` or extract from URN `urn:fss:<region>:<project_id>:...` |
27
+ | Cold start 100ms-2s | Reserve concurrency for latency-sensitive workloads |
28
+ | Max execution 900s | Use ECS/CCE for long-running tasks |
29
+ | Env vars plaintext | Use DEW for secrets |
30
+ | **ZIP upload is unreliable** | `CreateFunction --code_type=zip --code_filename=xxx.zip` succeeds even with a nonexistent file — the function is created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size` > placeholder after creation and run `InvokeFunction` to confirm output. |
31
+ | **DeleteFunction strip `:latest`** | Passing `urn:fss:...:function:xxx:latest` causes FSS.0400. Strip `:latest` suffix (DeleteFunction only — UpdateApiV2 needs the full URN). |
32
+ | **DeleteFunctionTrigger does NOT cascade** | Deleting a DEDICATEDGATEWAY trigger leaves the API in APIG. Manually clean up: `hcloud APIG DeleteApiV2 --instance_id=<id> --api_id=<api-id>`. |
33
+
34
+ ## Prerequisites
35
+
36
+ ```bash
37
+ hcloud configure list # confirm a profile exists
38
+ hcloud FunctionGraph --help # confirm service is available
39
+ ```
40
+
41
+ ## IAM Permissions
42
+
43
+ If you see `FSS.0403 Forbidden`, the user needs these permissions:
44
+
45
+ | Operation | Required Permission |
46
+ |-----------|---------------------|
47
+ | Create function | `functiongraph:function:createFunction` |
48
+ | List functions | `functiongraph:function:list` |
49
+ | Delete function | `functiongraph:function:deleteFunction` |
50
+ | Invoke function | `functiongraph:function:invoke` |
51
+ | Create trigger | `functiongraph:trigger:*` |
52
+
53
+ Grant via IAM console (`FunctionGraph FullAccess` role) or ask project admin.
54
+
55
+ ## Operations
56
+
57
+ Always discover parameters with `--help` before executing. These are the correct operation names:
58
+
59
+ | Task | Operation | Gotchas |
60
+ |------|-----------|---------|
61
+ | List functions | `ListFunctions` | |
62
+ | Show function | `ShowFunctionConfig` | |
63
+ | Create function | `CreateFunction` | references/create-function.md |
64
+ | Delete function | `DeleteFunction` | Strip `:latest` from URN |
65
+ | Invoke function | `InvokeFunction` | Requires body param (`--name=<value>` becomes event body). Use `--x_cff_request_version=v0` for raw output, `v1` for APIG-wrapped. |
66
+ | List runtimes | `ListRuntimes` | |
67
+ | Create trigger | `CreateFunctionTrigger` | references/triggers.md |
68
+ | List triggers | `ListFunctionTriggers` | |
69
+ | Delete trigger | `DeleteFunctionTrigger` | |
70
+
71
+ Discover exact parameters:
72
+ ```bash
73
+ hcloud FunctionGraph CreateFunction --help
74
+ hcloud FunctionGraph CreateFunctionTrigger --help
75
+ ```
76
+
77
+ ## Deployment Workflow
78
+
79
+ ```
80
+ Write code → zip → CreateFunction → InvokeFunction → CreateFunctionTrigger
81
+ ```
82
+
83
+ See `references/deploy-workflow.md` for a step-by-step example with code templates.
84
+
85
+ ## Troubleshooting
86
+
87
+ | Error | Root Cause -> Fix |
88
+ |-------|------------------|
89
+ | `不支持的服务名称:FGS` | Use `FunctionGraph`, not `FGS` |
90
+ | `不支持的operation:CreateTrigger` | Use `CreateFunctionTrigger` |
91
+ | `FSS.0403` / Forbidden | Missing IAM permissions — see IAM Permissions above |
92
+ | `缺少必填参数:{*}` on Invoke | Add body param: `--name=<value>` |
93
+ | APIG/EOM trigger error | `trigger_type_code=APIG` deprecated — use `DEDICATEDGATEWAY` |
94
+ | `event_data` parse error | Use dotted format: `--event_data.key=value`, NOT JSON string |
95
+ | FSS.1078 / code upload fails | `--code_filename` is filename-only, no path. `cd` to zip directory first |
96
+ | DeleteFunction with `:latest` | Strip `:latest` version suffix from URN |
97
+ | Code too large | Inline limit 10KB — use `zip`/`obs` code type |
98
+ | Cold start slow | Set reserved instances for critical functions |
99
+ | Auth failure | Run `hcloud configure init` |
100
+
101
+ ## Security Considerations
102
+
103
+ - MUST use DEW for secrets, never hardcode in environment variables
104
+ - MUST use `--app_xrole` (agency) for cross-service access
105
+ - SHOULD enable CTS audit logging for function invocations
106
+ - MUST NOT expose AK/SK in function code
107
+
108
+ ## MCP Tools
109
+
110
+ - `huaweicloud_list_operations` service=FunctionGraph
111
+ - `huaweicloud_run_readonly_command` for discovery
112
+ - `huaweicloud_run_approved_command` for writes
113
+
114
+ ## Without MCP
115
+
116
+ Fall back to hcloud CLI. State: "MCP unavailable, using local hcloud CLI."
117
+
118
+ ## Cross-Skill References
119
+
120
+ - **APIG trigger setup**: See `huawei-apig` for API group creation and publishing
121
+ - **OBS trigger setup**: See `huawei-obs` for bucket and object event configuration
122
+ - **DEW secrets**: See `huawei-dew` for managing function secrets
123
+ - **SMN notifications**: See `huawei-smn-dms` for notification topics
124
+ - **VPC configuration**: See `huawei-vpc` for network settings
125
+
126
+ ## References
127
+
128
+ - FunctionGraph Docs: https://support.huaweicloud.com/functiongraph/
129
+ - Create function: references/create-function.md
130
+ - Triggers: references/triggers.md
131
+ - Deploy workflow: references/deploy-workflow.md
132
+ - APIG event format: references/apig-event-format.md
@@ -0,0 +1,58 @@
1
+ # APIG DEDICATEDGATEWAY Event Format
2
+
3
+ When APIG calls FunctionGraph via DEDICATEDGATEWAY trigger, the event structure is NOT the standard HTTP event. Key differences:
4
+
5
+ ## Event Structure
6
+
7
+ ```json
8
+ {
9
+ "isBase64Encoded": true,
10
+ "body": "<Base64-encoded request body>",
11
+ "httpMethod": "POST",
12
+ "requestContext": {
13
+ "apiId": "xxx",
14
+ "requestId": "xxx",
15
+ "stage": "RELEASE"
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Critical: body is Base64 Encoded
21
+
22
+ `event["body"]` is Base64 encoded. You MUST decode it:
23
+
24
+ **Python handler template:**
25
+ ```python
26
+ import json, base64
27
+
28
+ def handler(event, context):
29
+ body = event.get("body", "")
30
+ if event.get("isBase64Encoded"):
31
+ body = base64.b64decode(body).decode("utf-8")
32
+ data = json.loads(body) if body else {}
33
+ return {
34
+ "statusCode": 200,
35
+ "body": json.dumps({"message": "ok", "received": data}),
36
+ "headers": {"Content-Type": "application/json"}
37
+ }
38
+ ```
39
+
40
+ **Node.js handler template:**
41
+ ```js
42
+ exports.handler = async (event, context) => {
43
+ let body = event.body || "";
44
+ if (event.isBase64Encoded) {
45
+ body = Buffer.from(body, "base64").toString("utf8");
46
+ }
47
+ const data = body ? JSON.parse(body) : {};
48
+ return {
49
+ statusCode: 200,
50
+ body: JSON.stringify({ message: "ok", received: data }),
51
+ headers: { "Content-Type": "application/json" }
52
+ };
53
+ };
54
+ ```
55
+
56
+ ## Missing Fields vs Standard HTTP
57
+
58
+ Fields NOT in DEDICATEDGATEWAY event: `event.path`, `event.headers`, `event.queryStringParameters`. Use `event.httpMethod` for method detection.
@@ -0,0 +1,71 @@
1
+ # FunctionGraph Function Creation Reference
2
+
3
+ ## Runtime Options
4
+
5
+ | Runtime | Handler Format | Example |
6
+ |---------|---------------|---------|
7
+ | Python3.9 | `index.handler` | `def handler(event, context): return {"statusCode": 200}` |
8
+ | Python3.10 | `index.handler` | Same as 3.9 |
9
+ | Node.js 18 | `index.handler` | `exports.handler = async (event, context) => ({statusCode: 200})` |
10
+ | Java 8/11/17 | `com.example.Handler::handleRequest` | Java class method |
11
+ | Go 1.x | `handler` | Go function name |
12
+ | C# (.NET Core) | `CsharpDemo::CsharpDemo.Function::Handler` | Namespace.Class::Method |
13
+
14
+ ## Create Function (inline)
15
+
16
+ ```bash
17
+ hcloud FunctionGraph CreateFunction \
18
+ --func_name=<name> \
19
+ --package=default \
20
+ --runtime=Python3.10 \
21
+ --handler=index.handler \
22
+ --memory_size=128 \
23
+ --timeout=3 \
24
+ --code_type=inline \
25
+ --func_code.file=<base64-encoded-code> \
26
+ --cli-region=<region>
27
+ ```
28
+
29
+ | Param | Required | Range/Default |
30
+ |-------|----------|---------------|
31
+ | `--func_name` | Yes | 1-60 chars |
32
+ | `--runtime` | Yes | See runtime options above |
33
+ | `--handler` | Yes | Per runtime |
34
+ | `--memory_size` | No | 128-4096 MB, default 128 |
35
+ | `--timeout` | No | 1-900s, default 3 |
36
+
37
+ ## ZIP Upload Warning
38
+
39
+ `--code_type=zip --code_filename=xxx.zip` **succeeds even with non-existent file** — function created with empty code. Prefer `code_type=inline` for simple functions. If using zip, verify `code_size > 0` after creation and invoke the function to confirm output.
40
+
41
+ ## Required IAM Permissions
42
+
43
+ - `functiongraph:function:createFunction` — Create
44
+ - `functiongraph:function:list` — List
45
+ - `functiongraph:function:getConfig` — Read config
46
+ - `functiongraph:function:invoke` — Invoke
47
+
48
+ Grant `FunctionGraph FullAccess` role or custom policy.
49
+
50
+ ## Error Codes
51
+
52
+ | Error | Root Cause -> Fix |
53
+ |-------|-------------------|
54
+ | FSS.0400 | `:latest` suffix on URN. Strip it |
55
+ | FSS.1417 | Missing DEDICATEDGATEWAY params |
56
+ | FSS.0403 | Insufficient IAM permission |
57
+ | FSS.1020 | Missing `--app_xrole` when binding VPC. Create IAM agency with `trust_domain_name=functiongraph`. See `huawei-iam` skill → Agencies section |
58
+
59
+ ## VPC + Agency Configuration
60
+
61
+ To access VPC-internal resources from FunctionGraph:
62
+
63
+ ```bash
64
+ # 1. Create agency (see huawei-iam skill)
65
+ hcloud IAM CreateAgency --agency_name=<name> --trust_domain_name=functiongraph
66
+ # 2. Grant role (e.g., VPC Administrator)
67
+ hcloud IAM GrantRoleToAgency --agency_name=<name> --role_id=<role-id>
68
+ # 3. Use in CreateFunction
69
+ hcloud FunctionGraph CreateFunction --func_vpc.vpc_id=<vpc> --func_vpc.subnet_id=<subnet> --app_xrole=<name> ...
70
+ ```
71
+ | QuotaExceeded | Max 10 functions per project per region |