Install
openclaw skills install @huaweiclouddev/huawei-cloud-eip-cost-optimizerHuawei Cloud EIP (Elastic IP) cost optimization skill using Python SDK v2. Use this skill when the user wants to: (1) list and query EIPs across regions with detailed status, (2) identify idle/unbound EIPs and generate cost optimization reports, (3) set up idle EIP monitoring with webhook/email alerts, (4) generate HTML/JSON cost analysis reports, (5) maintain operation audit logs for compliance. **Read-only analysis only - NO bandwidth adjustment, tag management, or EIP release/deletion**. Trigger: user mentions "EIP cost optimization", "idle EIP analysis", "EIP audit", "cost report", "EIP status query", "EIP list", "EIP monitoring", "EIP alert", "cost analysis", "idle monitoring", "operation audit", "EIP 成本优化", "闲置 EIP 分析", "EIP 审计", "成本报告", "EIP 状态查询", "EIP 查询", "EIP 列表", "EIP 监控", "EIP 告警", "成本分析", "闲置监控", "操作审计"
openclaw skills install @huaweiclouddev/huawei-cloud-eip-cost-optimizerThis skill provides batch management and cost optimization capabilities for Huawei Cloud Elastic Public IPs (EIPs).
Architecture: Python SDK v2 → EIP Service API → VPC/Bandwidth/Tag resources
Related Skills: For broader cost optimization across all resource types (ECS, EVS, OBS, etc.), see the archived huaweicloud-cost-optimizer skill. This skill focuses exclusively on EIP optimization with deeper functionality and 100% Python SDK compliance.
Typical Use Cases:
pip install huaweicloudsdkeip huaweicloudsdkcoreAvailable Python Scripts:
scripts/analyze_idle_eips.py - Analyze idle EIPs and generate optimization reports (read-only, no release capability)scripts/monitor_idle_eips.py - Monitor idle EIPs with webhook/email alerts and cron supportscripts/eip_cost_report.py - Generate EIP cost analysis reports (HTML/JSON formats)scripts/list_eips.py - List all EIPs in a region (supports filtering and multi-region summary)Available Shell Wrappers:
scripts/eip_audit_log.sh - Operation audit logging (standalone, no SDK dependency)Note: All scripts are READ-ONLY. This skill does NOT perform bandwidth adjustment, tag management, or EIP release/deletion.
echo $HUAWEI_CLOUD_AK or echo $HUAWEI_CLOUD_SK to check credentialsHUAWEI_CLOUD_AK, HUAWEI_CLOUD_SK, HUAWEI_CLOUD_REGIONConfiguration Method (Environment Variables Only):
export HUAWEI_CLOUD_AK=<your-ak>
export HUAWEI_CLOUD_SK=<your-sk>
export HUAWEI_CLOUD_REGION=cn-north-4
⚠️ Important Security Notes:
Note: This skill is READ-ONLY for EIP resources. It does NOT perform any write operations (update, delete, tag management).
| API Action | Permission | Purpose |
|---|---|---|
vpc:publicIps:list | List EIPs | Query all EIPs and their status |
vpc:publicIps:get | Get EIP details | View individual EIP information |
See IAM Permission Policies for complete policy JSON.
Permission Failure Handling:
references/iam-policies.mdAll EIP operations use the Python SDK v2 format:
from huaweicloudsdkeip.v2 import EipClient, ListPublicipsRequest, ShowPublicipRequest
from huaweicloudsdkeip.v2.region.eip_region import EipRegion
from huaweicloudsdkcore.auth.credentials import BasicCredentials
# Initialize client
credentials = BasicCredentials(ak, sk)
client = EipClient(credentials, EipRegion.value_of(region))
# List all EIPs
request = ListPublicipsRequest()
request.limit = 100
response = client.list_publicips(request)
# Show EIP details
request = ShowPublicipRequest()
request.publicip_id = "<eip-id>"
response = client.show_publicip(request)
from huaweicloudsdkeip.v2 import UpdatePublicipRequest, UpdatePublicipOption, UpdatePublicipRequestBody
from huaweicloudsdkeip.v2.model.tag import Tag
# Add tags to EIP
option = UpdatePublicipOption()
option.tags = [Tag(key="env", value="prod")]
body = UpdatePublicipRequestBody()
body.publicip = option
request = UpdatePublicipRequest()
request.publicip_id = "<eip-id>"
request.body = body
client.update_publicip(request)
| Rule | Description | Example |
|---|---|---|
| v2 SDK | EIP operations use v2 SDK | huaweicloudsdkeip.v2 |
| Region parameter | Use EipRegion.value_of(region) | EipRegion.value_of('cn-north-4') |
| Credentials | Use BasicCredentials(ak, sk) | Environment variables preferred |
Python SDK Method (Recommended):
# List all EIPs with bandwidth info
python3 scripts/adjust_eip_bandwidth.py --list
# Analyze idle EIPs and generate report (read-only)
python3 scripts/analyze_idle_eips.py
# Adjust bandwidth for all EIPs
python3 scripts/adjust_eip_bandwidth.py --all --bandwidth 5
# Adjust bandwidth for idle EIPs only
python3 scripts/adjust_eip_bandwidth.py --idle-only --bandwidth 1
Required for: eip_audit_log.sh
# Verify jq installation
jq --version # Should return "jq-1.x"
# If jq fails or shows "Not Found", diagnose:
which jq
cat $(which jq) # If this shows text instead of binary, jq is broken
# Fix broken jq (common in WSL):
sudo rm /usr/local/bin/jq # Remove invalid PATH-prioritized jq
which jq # Should now show /usr/bin/jq
Note: jq is only required for Shell wrapper scripts. All Python SDK scripts work without jq.
Python SDK Method (Recommended for batch operations):
# Adjust all EIPs to 5 Mbps
python3 scripts/adjust_eip_bandwidth.py --all --bandwidth 5
# Adjust idle EIPs to 1 Mbps
python3 scripts/adjust_eip_bandwidth.py --idle-only --bandwidth 1
# Adjust specific EIPs
python3 scripts/adjust_eip_bandwidth.py --eip-ids "eip-id1,eip-id2" --bandwidth 10
# View current bandwidth configuration
python3 scripts/adjust_eip_bandwidth.py --list
Python SDK Method:
# Add tags to EIP
python3 scripts/manage_tags.py --action add --tags "env=prod,team=backend" --eip-ids <ID1,ID2>
# Remove tags from EIP
python3 scripts/manage_tags.py --action remove --tags "env" --eip-ids <ID1,ID2>
# List tags for EIP
python3 scripts/list_eips.py --region cn-north-4 # Shows tags in output
Using Python Scripts (Recommended):
# List EIPs in multiple regions (manually specify regions)
python3 scripts/list_eips.py --region cn-north-4
python3 scripts/list_eips.py --region cn-east-3
python3 scripts/list_eips.py --region cn-south-1
# Generate summary report for automation
python3 scripts/list_eips.py --region cn-north-4 --summary
# Output: CSV format (count,idle,bandwidth)
Note: The multi_region_manage.sh wrapper was removed in v3.0.3. Users can achieve the same functionality by running list_eips.py for each region individually, or by scripting multiple calls in their own automation.
Using Audit Script:
# Log an EIP release operation
bash scripts/eip_audit_log.sh --action release --eip-id eip-xxx --operator admin
# Log a bandwidth adjustment
bash scripts/eip_audit_log.sh --action update_bandwidth --eip-id eip-xxx --details '{"old": 5, "new": 10}'
# Query audit logs for last 30 days
bash scripts/eip_audit_log.sh --query --days 30
# Export audit logs to CSV
bash scripts/eip_audit_log.sh --export --format csv
# Export to HTML report
bash scripts/eip_audit_log.sh --export --format html
Audit Log Entry Format (JSONL):
{
"timestamp": "2026-05-25T03:30:00Z",
"operation": "release",
"eip_id": "eip-xxx",
"operator": "admin",
"region": "cn-north-4",
"details": {"reason": "idle_cleanup", "cost_saved": "2.5"}
}
| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
--region | Optional (Python scripts) | Huawei Cloud region ID | HUAWEI_CLOUD_REGION or cn-north-4 |
--eip-ids | Optional (scripts) | Comma-separated EIP IDs | All EIPs |
--bandwidth | Required (adjust script) | Target bandwidth in Mbps | N/A |
--all | Optional | Apply to all EIPs | false |
--idle-only | Optional | Apply to idle EIPs only | false |
--list | Optional | List EIPs with bandwidth info | false |
--summary | Optional (list_eips.py) | Output CSV stats (count,idle,bandwidth) | false |
--idle-days | Optional (scripts) | Idle threshold in days | 7 |
--interactive | Optional (scripts) | Interactive confirmation mode | false |
--confirm | Optional (release script) | Confirm release operation | false |
| Script | Parameter | Description |
|---|---|---|
eip_audit_log.sh | --action ACTION | Log operation (release, create, update) |
eip_audit_log.sh | --eip-id ID | EIP ID for audit log |
eip_audit_log.sh | --query | Query audit logs |
eip_audit_log.sh | --export --format csv | Export audit logs |
{
"publicips": [
{
"id": "eip-xxx1",
"public_ip_address": "123.45.67.89",
"bandwidth": { "size": 5 },
"status": "ACTIVE",
"binding_status": "BOUND",
"associate_instance_type": "ECS",
"create_time": "2026-04-15T10:30:00Z"
}
]
}
========================================
Huawei Cloud EIP List (Region: cn-north-4)
========================================
EIP ID: eip-xxx1, IP: 123.45.67.89, BW: 5 Mbps, Status: BOUND (ECS: ecs-xxx)
EIP ID: eip-xxx2, IP: 98.76.54.32, BW: 10 Mbps, Status: UNBOUND ⚠️
========================================
Total: 2 EIPs, Idle: 1
Generated by scripts/eip_cost_report.py — includes statistics cards, idle EIP table, full EIP list, and optimization recommendations.
Before any skill update or release, run the automated compliance check:
# Run compliance check
python3 scripts/compliance_check.py
# Verbose mode (show all findings)
python3 scripts/compliance_check.py --verbose
Checks performed:
Exit codes:
0 - All checks passed, skill is compliant1 - Compliance issues found, must fix before releasescripts/adjust_eip_bandwidth.py, scripts/analyze_idle_eips.py, and scripts/monitor_idle_eips.pymonitor_idle_eips.py --setup-cron to catch idle EIPs early--interactive flag for release operations in productionscripts/eip_audit_log.sh --action <operation> --eip-id <id>list_eips.py for each region individually, or use --summary flag for programmatic access to EIP statisticslist_eips.py --summary for programmatic access to EIP statistics (returns CSV: count,idle,bandwidth)grep -r "<deleted-script>.sh" scripts/. Test each wrapper before marking compliance complete.jq --version should return "jq-1.x". If it fails or shows "Not Found", check for broken PATH-prioritized installations at /usr/local/bin/jq and remove them.grep -A 20 "Typical Use Cases" SKILL.md | grep -c "^- \"" - should be 9+ for full coverage. Missing use cases indicate undocumented functionality.| Document | Description |
|---|---|
| IAM Permission Policies | Required permissions and policy JSON |
| EIP API Guide | EIP API reference (Python SDK v2) |
| Verification Method | Step-by-step verification |
| Python SDK Usage Guide | Python SDK patterns, common errors, and working examples. See "Issue 4" for critical bandwidth adjustment API pitfalls. |
BatchModifyBandwidth API (NOT UpdatePublicip or UpdateBandwidth).See Common Pitfalls & Solutions for detailed troubleshooting guides.
Quick Reference:
| Pitfall | Symptom | Quick Fix |
|---|---|---|
| jq path issues | eip_audit_log.sh fails | sudo rm /usr/local/bin/jq |
| Wrong bandwidth API | VPC.0301 error | Use BatchModifyBandwidthRequest |
| Missing bandwidth_id | Empty bandwidth ID | Access eip.bandwidth_size directly |
| v3 SDK import error | No EipRegion attribute | Use v2 SDK |
| Timestamp parsing | Unknown idle days | Handle ISO format |