
Huawei Cloud Network Query
- 110 installs
- 19 repo stars
- Updated July 31, 2026
- huaweicloud/huaweicloud-skills
Query Huawei Cloud network resources such as DNS public zones, name servers, and line lists via bundled Python scripts.
About
Read-only query guide for Huawei Cloud network resources including DNS public zones, zone details, name servers, and line lists via Python scripts. A developer uses it to inspect DNS and network configuration.
- Lists and details public zones with TTL and recordset counts
- Queries zone name servers and line lists
Huawei Cloud Network Query by the numbers
- 110 all-time installs (skills.sh)
- +14 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #552 of 1,042 Cloud & Infrastructure skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/huaweicloud/huaweicloud-skills --skill huawei-cloud-network-queryAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 110 |
|---|---|
| repo stars | ★ 19 |
| Last updated | July 31, 2026 |
| Repository | huaweicloud/huaweicloud-skills ↗ |
What it does
Query Huawei Cloud network resources such as DNS public zones, name servers, and line lists via bundled Python scripts.
Files
DNS Python Script Usage Guide
---
Public Zones
list_public_zones.py — Query Public Zone List
Purpose: Query the public zone list, including ID, name, status, zone type, TTL, recordset count, enterprise project ID, created at. Supports filtering by name, ID, status, tags, enterprise project, etc. Supports fuzzy/exact search and sorting. Usage: python scripts/dns/list_public_zones.py -h
---
show_public_zone.py — Query Public Zone Details
Purpose: Query public zone details, including ID, name, description, email, zone type, TTL, serial, status, recordset count, pool_id, project ID, enterprise project ID, masters, etc. Usage: python scripts/dns/show_public_zone.py -h
---
show_public_zone_name_server.py — Query Public Zone Name Servers
Purpose: Query the name servers of a public zone, including hostname, priority. Usage: python scripts/dns/show_public_zone_name_server.py -h
---
list_public_zone_lines.py — Query Public Zone Line List
Purpose: Query the line list of a public zone, including line ID, name, IP segment, created at, updated at. Usage: python scripts/dns/list_public_zone_lines.py -h
---
Private Zones
list_private_zones.py — Query Private Zone List
Purpose: Query the private zone list, including ID, name, status, zone type, TTL, recordset count, enterprise project ID, created at. Supports filtering by name, ID, status, tags, enterprise project, associated VPC, etc. Supports fuzzy/exact search and sorting. Usage: python scripts/dns/list_private_zones.py -h
---
show_private_zone.py — Query Private Zone Details
Purpose: Query private zone details, including ID, name, description, email, zone type, TTL, serial, status, recordset count, pool_id, project ID, enterprise project ID, proxy_pattern, masters, associated VPC routing information, etc. Usage: python scripts/dns/show_private_zone.py -h
---
show_private_zone_name_server.py — Query Private Zone Name Servers
Purpose: Query the name servers of a private zone, including hostname, priority, address. Usage: python scripts/dns/show_private_zone_name_server.py -h
---
Record Sets
list_record_sets.py — Query Tenant Record Set List
Purpose: Query the tenant record set list, including ID, name, type, status, TTL, zone ID, zone name. Supports filtering by zone type, name, ID, type, status, tags, etc. Supports fuzzy/exact search and sorting. Usage: python scripts/dns/list_record_sets.py -h
---
list_record_sets_by_zone.py — Query Record Set List Under Zone
Purpose: Query the record set list under a specified zone, including ID, name, type, status, TTL, records. Supports filtering by name, ID, type, status, tags, etc. Supports fuzzy/exact search and sorting. Usage: python scripts/dns/list_record_sets_by_zone.py -h
---
list_record_sets_with_line.py — Query Tenant Record Set List (With Line Support)
Purpose: Query the tenant record set list (with line support), including ID, name, type, status, TTL, zone ID, zone name, line, weight. Supports filtering by zone type, zone ID, line ID, name, type, status, tags, health check ID, etc. Usage: python scripts/dns/list_record_sets_with_line.py -h
---
show_record_set.py — Query Record Set Details
Purpose: Query record set details, including ID, name, description, zone ID, zone name, type, TTL, status, default, project ID, bundle, records, etc. Usage: python scripts/dns/show_record_set.py -h
---
show_record_set_by_zone.py — Query Record Set Details Under Zone
Purpose: Query record set details under a specified zone, including ID, name, type, status, TTL, records. Supports filtering by line ID, name, type, status, tags, etc. Usage: python scripts/dns/show_record_set_by_zone.py -h
---
show_record_set_with_line.py — Query Record Set Details (With Line Support)
Purpose: Query record set details (with line support), including ID, name, description, zone ID, zone name, type, TTL, status, default, project ID, line, weight, health check ID, bundle, records, alias_target, etc. Usage: python scripts/dns/show_record_set_with_line.py -h
---
Reverse Resolution (PTR)
list_ptr_records.py — Query PTR Record List
Purpose: Query the reverse resolution record list for elastic public IPs, including ID, IP address, PTR domain, status, TTL. Supports filtering by enterprise project ID, tags, status, etc. Usage: python scripts/dns/list_ptr_records.py -h
---
list_ptrs.py — Query PTR Record List
Purpose: Query the reverse resolution record list for elastic public IPs, including ID, IP address, PTR domain, status, TTL. Supports filtering by enterprise project ID, tags, status, resource type, etc. Usage: python scripts/dns/list_ptrs.py -h
---
show_ptr.py — Query PTR Record Details
Purpose: Query reverse resolution record details for an elastic public IP, including ID, PTR domain, description, TTL, status, enterprise project ID, public IP information (ID, address, type). Usage: python scripts/dns/show_ptr.py -h
---
show_ptr_record_set.py — Query Reverse Resolution Record for Elastic Public IP
Purpose: Query the reverse resolution record for a specified elastic public IP, including ID, PTR domain, description, TTL, IP address, status, action, enterprise project ID. Usage: python scripts/dns/show_ptr_record_set.py -h
---
Line Management
list_line_groups.py — Query Line Group List
Purpose: Query the line group list, including line group ID, name, status, description, created at, updated at. Supports filtering by line group ID, name, etc. Usage: python scripts/dns/list_line_groups.py -h
---
show_line_group.py — Query Line Group Details
Purpose: Query line group details, including line group ID, name, status, description, included line list, created at, updated at. Usage: python scripts/dns/show_line_group.py -h
---
list_custom_line.py — Query Custom Line List
Purpose: Query the custom line list, including line ID, name, status, created at, updated at. Supports filtering by line ID, name, status, IP address, etc. Usage: python scripts/dns/list_custom_line.py -h
---
list_system_lines.py — Query System Line List
Purpose: Query the system line list, including line ID, name, created at, updated at. Supports filtering by language identifier. Usage: python scripts/dns/list_system_lines.py -h
---
Endpoints
list_endpoints.py — Query Endpoint List
Purpose: Query the endpoint list, including ID, name, direction (inbound/outbound), status, created at, updated at. Supports filtering by VPC ID, name, etc. Usage: python scripts/dns/list_endpoints.py -h
---
show_endpoint.py — Query Endpoint Details
Purpose: Query endpoint details, including ID, name, direction, status, created at, updated at, IP address list. Usage: python scripts/dns/show_endpoint.py -h
---
list_endpoint_vpcs.py — Query Endpoint VPC List
Purpose: Query the endpoint VPC list, including VPC ID, VPC name, region. Supports filtering by VPC ID. Usage: python scripts/dns/list_endpoint_vpcs.py -h
---
list_endpoint_ipaddresses.py — Query Endpoint IP Address List
Purpose: Query the IP address list of a specified endpoint, including ID, IP address, status, created at, updated at. Usage: python scripts/dns/list_endpoint_ipaddresses.py -h
---
Resolver Forwarding Rules
list_resolver_rules.py — Query Resolver Rule List
Purpose: Query the resolver forwarding rule list, including ID, name, domain, endpoint ID, status, created at, updated at. Supports filtering by domain, name, endpoint ID, forwarding rule ID, etc. Usage: python scripts/dns/list_resolver_rules.py -h
---
show_resolver_rule.py — Query Resolver Rule Details
Purpose: Query resolver forwarding rule details, including ID, name, domain, endpoint ID, status, created at, updated at, IP address list. Usage: python scripts/dns/show_resolver_rule.py -h
---
Resolver Access Logs
list_resolver_query_log_configs.py — Query Resolver Query Log Config List
Purpose: Query the resolver query log configuration list, including ID, LTS log group ID, LTS log topic ID, associated VPC ID list. Supports filtering by VPC ID. Usage: python scripts/dns/list_resolver_query_log_configs.py -h
---
show_resolver_query_log_config.py — Query Resolver Query Log Config Details
Purpose: Query resolver query log configuration details, including ID, LTS log group ID, LTS log topic ID, associated VPC ID list. Usage: python scripts/dns/show_resolver_query_log_config.py -h
---
Name Servers
list_name_servers.py — Query Name Server List
Purpose: Query the name server list, including zone type, region, name server records (hostname, priority, address). Supports filtering by zone type, region. Usage: python scripts/dns/list_name_servers.py -h
---
show_zone_name_server.py — Query DNS Server Addresses for Public Zone
Purpose: Query DNS server addresses for a public zone, including zone name, whether all Huawei Cloud DNS, whether includes Huawei Cloud DNS, actual DNS server list, expected DNS server list. Usage: python scripts/dns/show_zone_name_server.py -h
---
Tags
list_tags.py — Query All Tag Sets for Specified Instance Type
Purpose: Query all tag sets for a specified instance type, including tag key, values list. resource_type supports: DNS-public_zone, DNS-private_zone, DNS-public_recordset, DNS-private_recordset, DNS-ptr_record. Usage: python scripts/dns/list_tags.py -h
---
show_resource_tag.py — Query Tags for Specified Instance
Purpose: Query tags for a specified instance, including tag key, value. resource_type supports: DNS-public_zone, DNS-private_zone, DNS-public_recordset, DNS-private_recordset, DNS-ptr_record. Usage: python scripts/dns/show_resource_tag.py -h
---
DNSSEC
show_dnssec_config.py — Query DNSSEC Configuration
Purpose: Query DNSSEC configuration, including zone name, key_tag, flag, digest algorithm, digest type, digest, signature, signature type, KSK public key, DS record, status, created at, updated at. Usage: python scripts/dns/show_dnssec_config.py -h
---
Quotas and Diagnostics
show_domain_quota.py — Query Tenant Quota
Purpose: Query tenant quota, including quota item, quota limit, used count, unit. Usage: python scripts/dns/show_domain_quota.py -h
---
show_domain_detection.py — Query Domain Diagnosis for Public Zone
Purpose: Query domain diagnosis for a public zone, including zone name, type, status. Supports filtering by recordset type (MX/CNAME/TXT) and zone name. Usage: python scripts/dns/show_domain_detection.py -h
---
Batch Operations
show_batch_operation_task.py — Query Batch Operation Task
Purpose: Query batch operation task, including task ID, type, status, created at, success count, failure count, failure item list. Usage: python scripts/dns/show_batch_operation_task.py -h
---
show_batch_create_record_sets_task.py — Query Batch Create Record Sets Task
Purpose: Query batch create record sets task, including task ID, status, created at, updated at, total count, success count, failure count, failure item list. Usage: python scripts/dns/show_batch_create_record_sets_task.py -h
---
Domain Authorization and Retrieval
show_authorize_txt_record.py — Query Public Subdomain Authorization
Purpose: Query public subdomain authorization, including ID, zone name, status, subdomain name, created at, updated at, TXT record (host, value). Usage: python scripts/dns/show_authorize_txt_record.py -h
---
show_retrieval.py — Query Public Domain Retrieval
Purpose: Query public domain retrieval, including ID, zone name, status, created at, updated at, TXT record (host, value). Usage: python scripts/dns/show_retrieval.py -h
---
show_retrieval_verification.py — Query Public Domain Retrieval Result
Purpose: Query public domain retrieval result, including task ID, status, updated at. Usage: python scripts/dns/show_retrieval_verification.py -h
---
Email and Website Domains
show_email_record_set.py — Query Email Domain Record Set for Public Zone
Purpose: Query the email domain record set for a public zone, including ID, name, type, status, TTL, records. Usage: python scripts/dns/show_email_record_set.py -h
---
show_website_record_set.py — Query Website Domain Record Set for Public Zone
Purpose: Query the website domain record set for a public zone, including ID, name, type, status, TTL, records. Usage: python scripts/dns/show_website_record_set.py -h
---
DNS Resolution Statistics
list_instances.py — Batch Query DNS Resolution Statistics Resources
Purpose: Batch query DNS resolution statistics resources, including ID, name, status, region, enterprise project ID. Supports filtering by zone ID, zone name, time range. Usage: python scripts/dns/list_instances.py -h
---
API Versions
list_api_versions.py — Query API Version Information List
Purpose: Query the DNS API version information list, including version ID, status. Usage: python scripts/dns/list_api_versions.py -h
---
show_api_info.py — Query API Version Information for Specified Version
Purpose: Query API version information for a specified version, including version ID, status, version, min_version, updated, links. Usage: python scripts/dns/show_api_info.py -h
EIP Python Script Usage Guide
---
List Queries
list_publicips.py — Query Elastic Public IP List
Purpose: Query the elastic public IP list, including ID, public IP address, status, type, alias, bandwidth size. Usage: python scripts/eip/list_publicips.py -h
---
list_bandwidth.py — Query Bandwidth List
Purpose: Query the bandwidth list, including ID, name, size, type, billing mode, publicip_count. Usage: python scripts/eip/list_bandwidth.py -h
---
list_bandwidths_limit.py — Query Tenant Bandwidth Limits
Purpose: Query tenant bandwidth limits, including ID, billing mode, min_size, max_size. Usage: python scripts/eip/list_bandwidths_limit.py -h
---
list_common_pools.py — Query Common Pool List
Purpose: Query the common pool list, including common border group, publicip_pools. Usage: python scripts/eip/list_common_pools.py -h
---
list_publicip_pool.py — Query Public IP Pool List
Purpose: Query the public IP pool list, including ID, name, type, status, size, used, common border group. Usage: python scripts/eip/list_publicip_pool.py -h
---
list_share_bandwidth_types.py — Query Shared Bandwidth Type List
Purpose: Query the shared bandwidth type list, including ID, bandwidth type, name_zh, name_en, common border group. Usage: python scripts/eip/list_share_bandwidth_types.py -h
---
list_project_geip_bindings.py — Query GEIP Binding List
Purpose: Query the tenant list of GEIP and instance binding relationships, including geip_id, geip_ip_address, instance_type, instance_id. Usage: python scripts/eip/list_project_geip_bindings.py -h
---
list_tenant_vpc_igws.py — Query Virtual IGW List
Purpose: Query the virtual IGW list under a tenant, including ID, name, VPC ID, enable_ipv6. Usage: python scripts/eip/list_tenant_vpc_igws.py -h
---
show_publicip.py — Query Elastic Public IP Details
Purpose: Query elastic public IP details. Usage: python scripts/eip/show_publicip.py -h
---
show_publicip_pool.py — Query Public IP Pool Details
Purpose: Query public IP pool details. Usage: python scripts/eip/show_publicip_pool.py -h
---
show_publicip_pool_types.py — Query Public IP Pool Types
Purpose: Query public IP pool types. Usage: python scripts/eip/show_publicip_pool_types.py -h
---
show_internal_vpc_igw.py — Query Virtual IGW Details
Purpose: Query virtual IGW details. Usage: python scripts/eip/show_internal_vpc_igw.py -h
---
count_eip_available_resources.py — Query Available EIP Resource Count
Purpose: Query the number of available elastic public IP resources, including available count. Usage: python scripts/eip/count_eip_available_resources.py -h
---
list_eip_bandwidths.py — Query Bandwidth List (v3 API)
Purpose: Query the bandwidth list (v3 API, returns more detailed bandwidth information), including ID, name, size, type, bandwidth_type, admin_state, publicip_count. Usage: python scripts/eip/list_eip_bandwidths.py -h
ELB Python Script Usage Guide
---
List Query APIs
list_load_balancers.py — Query Load Balancer List
Purpose: Query the ELB load balancer list, including name, ID, vip_address, provisioning_status, operating_status, VPC ID. Usage: python scripts/elb/list_load_balancers.py -h
---
list_listeners.py — Query Listener List
Purpose: Query the ELB listener list, including name, ID, protocol, protocol_port, loadbalancer_id, default_pool_id, admin state. Usage: python scripts/elb/list_listeners.py -h
---
list_pools.py — Query Backend Server Group List
Purpose: Query the ELB backend server group list, including name, ID, protocol, lb_algorithm, healthmonitor_id, VPC ID. Usage: python scripts/elb/list_pools.py -h
---
list_members.py — Query Backend Server List
Purpose: Query the ELB backend server list, including name, ID, address, protocol_port, weight, operating_status, admin state. Usage: python scripts/elb/list_members.py -h
---
list_health_monitors.py — Query Health Check List
Purpose: Query the ELB health check list, including name, ID, type, delay, timeout, max_retries, admin state. Usage: python scripts/elb/list_health_monitors.py -h
---
list_certificates.py — Query Certificate List
Purpose: Query the ELB certificate list, including name, ID, type, domain, expiration time, admin state. Usage: python scripts/elb/list_certificates.py -h
---
list_l7_policies.py — Query L7 Policy List
Purpose: Query the ELB L7 policy list, including name, ID, action, position, priority, listener_id, provisioning_status. Usage: python scripts/elb/list_l7_policies.py -h
---
list_l7_rules.py — Query L7 Rule List
Purpose: Query the ELB L7 rule list, including ID, type, compare_type, value, key, admin state, provisioning_status. Usage: python scripts/elb/list_l7_rules.py -h
---
list_flavors.py — Query Flavor List
Purpose: Query the ELB flavor list, including ID, name, type, shared, flavor_sold_out. Usage: python scripts/elb/list_flavors.py -h
---
list_logtanks.py — Query Cloud Log List
Purpose: Query the ELB cloud log list, including ID, loadbalancer_id, log group ID, log topic ID. Usage: python scripts/elb/list_logtanks.py -h
---
list_security_policies.py — Query Security Policy List
Purpose: Query the ELB security policy list, including ID, name, description, protocols, ciphers. Usage: python scripts/elb/list_security_policies.py -h
---
list_ip_groups.py — Query IP Address Group List
Purpose: Query the ELB IP address group list, including ID, name, description, project ID. Usage: python scripts/elb/list_ip_groups.py -h
---
list_jobs.py — Query Job List
Purpose: Query the ELB job list, including job ID, job type, status, resource ID, begin_time, end time. Usage: python scripts/elb/list_jobs.py -h
---
list_master_slave_pools.py — Query Master-Backup Backend Server Group List
Purpose: Query the ELB master-backup backend server group list, including ID, name, protocol, lb_algorithm, VPC ID, type. Usage: python scripts/elb/list_master_slave_pools.py -h
---
list_all_l7_rules.py — Query All L7 Rule List
Purpose: Query the ELB all L7 rule list, including ID, type, compare_type, value, key, admin state, provisioning_status. Usage: python scripts/elb/list_all_l7_rules.py -h
---
list_all_members.py — Query All Backend Server List
Purpose: Query the ELB all backend server list, including ID, name, address, protocol_port, weight, pool ID, operating_status. Usage: python scripts/elb/list_all_members.py -h
---
list_availability_zones.py — Query Availability Zone List
Purpose: Query the ELB availability zone list, including code, state, protocol, common border group, category. Usage: python scripts/elb/list_availability_zones.py -h
---
list_system_security_policies.py — Query System Security Policy List
Purpose: Query the ELB system security policy list, including name, protocols, ciphers, project ID. Usage: python scripts/elb/list_system_security_policies.py -h
---
list_loadbalancer_tags.py — Query Load Balancer Tags
Purpose: Query the ELB load balancer tag list, including key, values. Usage: python scripts/elb/list_loadbalancer_tags.py -h
---
list_listener_tags.py — Query Listener Tags
Purpose: Query the ELB listener tag list, including key, values. Usage: python scripts/elb/list_listener_tags.py -h
---
list_api_versions.py — Query API Version List
Purpose: Query the ELB API version list, including ID, status. Usage: python scripts/elb/list_api_versions.py -h
---
list_domain_i_ps.py — Query Domain IP List
Purpose: Query the ELB domain IP list, including ID, IP address, type, domain name, enabled. Usage: python scripts/elb/list_domain_i_ps.py -h
---
list_feature_configs.py — Query Feature Configuration List
Purpose: Query the ELB feature configuration list, including ID, feature, type, value, enabled, description. Usage: python scripts/elb/list_feature_configs.py -h
---
list_quota_details.py — Query Quota Detail List
Purpose: Query the ELB quota detail list, including quota_key, quota_limit, used, unit. Usage: python scripts/elb/list_quota_details.py -h
---
list_recycle_bin_load_balancers.py — Query Recycle Bin Load Balancer List
Purpose: Query the ELB recycle bin load balancer list, including ID, name, vip_address, provisioning_status, operating_status, VPC ID. Usage: python scripts/elb/list_recycle_bin_load_balancers.py -h
---
list_loadbalancer_feature.py — Query Load Balancer Feature List
Purpose: Query the ELB load balancer feature list, including feature, type, value. Usage: python scripts/elb/list_loadbalancer_feature.py -h
show_load_balancer.py — Query Load Balancer Details
Purpose: Query ELB load balancer details, including ID, name, description, vip_address, provisioning_status, operating_status, VPC ID, admin state, guaranteed, created at, updated at. Usage: python scripts/elb/show_load_balancer.py -h
---
show_listener.py — Query Listener Details
Purpose: Query ELB listener details, including ID, name, protocol, protocol_port, loadbalancer_id, default_pool_id, admin state, connection_limit, created at, updated at. Usage: python scripts/elb/show_listener.py -h
---
show_pool.py — Query Backend Server Group Details
Purpose: Query ELB backend server group details, including ID, name, protocol, lb_algorithm, healthmonitor_id, VPC ID, admin state, description, type, created at, updated at. Usage: python scripts/elb/show_pool.py -h
---
show_member.py — Query Backend Server Details
Purpose: Query ELB backend server details, including ID, name, address, protocol_port, weight, admin state, operating_status, subnet_cidr_id, IP version. Usage: python scripts/elb/show_member.py -h
---
show_health_monitor.py — Query Health Check Details
Purpose: Query ELB health check details, including ID, name, type, delay, timeout, max_retries, max_retries_down, admin state, monitor_port, domain name, url_path, http_method, expected_codes. Usage: python scripts/elb/show_health_monitor.py -h
---
show_certificate.py — Query Certificate Details
Purpose: Query ELB certificate details, including ID, name, type, domain, description, admin state, expiration time, common_name, fingerprint, source, created at, updated at. Usage: python scripts/elb/show_certificate.py -h
---
show_l7_policy.py — Query L7 Policy Details
Purpose: Query ELB forwarding policy details, including ID, name, action, position, priority, listener_id, redirect_pool_id, redirect_listener_id, redirect_url, provisioning_status, admin state, description. Usage: python scripts/elb/show_l7_policy.py -h
---
show_l7_rule.py — Query L7 Rule Details
Purpose: Query ELB forwarding rule details, including ID, type, compare_type, value, key, admin state, provisioning_status, invert. Usage: python scripts/elb/show_l7_rule.py -h
---
show_flavor.py — Query Flavor Details
Purpose: Query ELB flavor details, including ID, name, type, shared, flavor_sold_out, common border group, category. Usage: python scripts/elb/show_flavor.py -h
---
show_logtank.py — Query Cloud Log Details
Purpose: Query ELB cloud log details, including ID, loadbalancer_id, log group ID, log topic ID, project ID. Usage: python scripts/elb/show_logtank.py -h
---
show_security_policy.py — Query Security Policy Details
Purpose: Query ELB security policy details, including ID, name, description, protocols, ciphers, enterprise project ID, created at, updated at. Usage: python scripts/elb/show_security_policy.py -h
---
show_job.py — Query Job Details
Purpose: Query ELB job details, including job ID, job type, status, resource ID, error code, error message, begin_time, end time. Usage: python scripts/elb/show_job.py -h
---
show_master_slave_pool.py — Query Master-Backup Backend Server Group Details
Purpose: Query ELB master-backup backend server group details, including ID, name, protocol, lb_algorithm, VPC ID, type, description, IP version, enterprise project ID. Usage: python scripts/elb/show_master_slave_pool.py -h
---
show_load_balancer_status.py — Query Load Balancer Status Tree
Purpose: Query the ELB load balancer status tree. Usage: python scripts/elb/show_load_balancer_status.py -h
---
show_load_balancer_topology.py — Query Load Balancer Topology
Purpose: Query the ELB load balancer topology. Usage: python scripts/elb/show_load_balancer_topology.py -h
---
show_load_balancer_ports.py — Query Load Balancer Port List
Purpose: Query the ELB load balancer port list, including port ID, IP address, ipv6_address, type, subnet ID. Usage: python scripts/elb/show_load_balancer_ports.py -h
---
show_member_health_check_job.py — Query Member Health Check Job
Purpose: Query ELB member health check job details, including job ID, status, listener_id, member_id, check_item_total_num, check_item_finished_num, created at, updated at. Usage: python scripts/elb/show_member_health_check_job.py -h
---
show_ip_group.py — Query IP Address Group Details
Purpose: Query ELB IP address group details, including ID, name, description, project ID, enterprise project ID, created at, updated at. Usage: python scripts/elb/show_ip_group.py -h
---
show_ip_group_related_listeners.py — Query IP Address Group Related Listeners
Purpose: Query the list of listeners associated with an ELB IP address group, including ID. Usage: python scripts/elb/show_ip_group_related_listeners.py -h
---
show_listener_tags.py — Query Listener Tags
Purpose: Query the ELB listener tag list, including key, value. Usage: python scripts/elb/show_listener_tags.py -h
---
show_loadbalancer_tags.py — Query Load Balancer Tags
Purpose: Query the ELB load balancer tag list, including key, value. Usage: python scripts/elb/show_loadbalancer_tags.py -h
---
show_quota.py — Query Quota
Purpose: Query ELB quota, including project ID, loadbalancer, listener, pool, member, healthmonitor, l7policy, certificate, ipgroup, security_policy. Usage: python scripts/elb/show_quota.py -h
---
show_recycle_bin.py — Query Recycle Bin Configuration
Purpose: Query ELB recycle bin configuration, including project ID, enable, policy. Usage: python scripts/elb/show_recycle_bin.py -h
---
show_certificate_private_key_echo.py — Query Certificate Private Key Echo Switch
Purpose: Query the ELB certificate private key echo switch. Usage: python scripts/elb/show_certificate_private_key_echo.py -h
count_preoccupy_ip_num.py — Calculate Pre-occupied IP Count
Purpose: Calculate the number of pre-occupied IPs for LB. Usage: python scripts/elb/count_preoccupy_ip_num.py -h
NAT Gateway Python Script Usage Guide
---
Public NAT Gateway
list_nat_gateways.py — Query NAT Gateway List
Purpose: Query the NAT gateway list, including ID, name, status, spec, router_id, internal_network_id, description, enterprise project ID. Usage: python scripts/nat/list_nat_gateways.py -h
---
list_nat_gateway_dnat_rules.py — Query DNAT Rule List
Purpose: Query the NAT gateway DNAT rule list, including ID, status, protocol, floating_ip_address, internal_service_port, private_ip, external_service_port, nat_gateway_id, description. Usage: python scripts/nat/list_nat_gateway_dnat_rules.py -h
---
list_nat_gateway_snat_rules.py — Query SNAT Rule List
Purpose: Query the NAT gateway SNAT rule list, including ID, status, floating_ip_address, CIDR, source_type, nat_gateway_id, network ID, description. Usage: python scripts/nat/list_nat_gateway_snat_rules.py -h
---
list_nat_gateway_specs.py — Query Public NAT Gateway Specification List
Purpose: Query the NAT gateway specification list, including spec. Usage: python scripts/nat/list_nat_gateway_specs.py -h
---
show_nat_gateway.py — Query NAT Gateway Details
Purpose: Query NAT gateway details, including ID, name, description, spec, status, admin state, router_id, internal_network_id, enterprise project ID, created at, dnat_rules_limit, snat_rule_public_ip_limit. Usage: python scripts/nat/show_nat_gateway.py -h
---
show_nat_gateway_dnat_rule.py — Query DNAT Rule Details
Purpose: Query NAT gateway DNAT rule details, including ID, nat_gateway_id, protocol, floating_ip_address, floating_ip_id, external_service_port, internal_service_port, private_ip, port ID, status, admin state, description, created at, global_eip_id, global_eip_address. Usage: python scripts/nat/show_nat_gateway_dnat_rule.py -h
---
show_nat_gateway_snat_rule.py — Query SNAT Rule Details
Purpose: Query NAT gateway SNAT rule details, including ID, nat_gateway_id, CIDR, source_type, floating_ip_id, floating_ip_address, network ID, status, admin state, description, created at, global_eip_id, global_eip_address. Usage: python scripts/nat/show_nat_gateway_snat_rule.py -h
list_private_nats.py — Query Private NAT Gateway List
Purpose: Query the private NAT gateway list, including ID, name, status, spec, description, enterprise project ID. Usage: python scripts/nat/list_private_nats.py -h
---
list_private_dnats.py — Query Private DNAT Rule List
Purpose: Query the private NAT gateway DNAT rule list, including ID, gateway_id, protocol, private IP address, internal_service_port, transit_service_port, transit_ip_id, status, description. Usage: python scripts/nat/list_private_dnats.py -h
---
list_private_snats.py — Query Private SNAT Rule List
Purpose: Query the private NAT gateway SNAT rule list, including ID, gateway_id, CIDR, subnet ID, description, status. Usage: python scripts/nat/list_private_snats.py -h
---
list_specs.py — Query Private NAT Gateway Specification List
Purpose: Query the private NAT gateway specification list, including name, code, rule_max, sess_max, bps_max, pps_max, qps_max. Usage: python scripts/nat/list_specs.py -h
---
show_private_nat.py — Query Private NAT Gateway Details
Purpose: Query private NAT gateway details, including ID, name, description, spec, status, enterprise project ID, created at, updated at, rule_max. Usage: python scripts/nat/show_private_nat.py -h
---
show_private_dnat.py — Query Private DNAT Rule Details
Purpose: Query private NAT gateway DNAT rule details, including ID, gateway_id, transit_ip_id, network_interface_id, type, protocol, private IP address, internal_service_port, transit_service_port, status, description, enterprise project ID, created at, updated at. Usage: python scripts/nat/show_private_dnat.py -h
---
show_private_snat.py — Query Private SNAT Rule Details
Purpose: Query private NAT gateway SNAT rule details, including ID, gateway_id, CIDR, subnet ID, description, status, enterprise project ID, created at, updated at. Usage: python scripts/nat/show_private_snat.py -h
list_transit_ip.py — Query Transit IP List
Purpose: Query the transit IP list, including ID, IP address, network_interface_id, gateway_id, subnet ID, status, enterprise project ID. Usage: python scripts/nat/list_transit_ip.py -h
---
show_transit_ip.py — Query Transit IP Details
Purpose: Query transit IP details, including ID, IP address, network_interface_id, gateway_id, subnet ID, status, enterprise project ID, created at, updated at. Usage: python scripts/nat/show_transit_ip.py -h
list_transit_subnet.py — Query Transit Subnet List
Purpose: Query the transit subnet list, including ID, name, VPC ID, subnet ID, CIDR, type, status, ip_count, description. Usage: python scripts/nat/list_transit_subnet.py -h
---
show_transit_subnet.py — Query Transit Subnet Details
Purpose: Query transit subnet details, including ID, name, description, VPC ID, subnet ID, CIDR, type, status, ip_count, created at, updated at. Usage: python scripts/nat/show_transit_subnet.py -h
---
list_nat_gateway_tag.py — Query Public NAT Gateway Project Tags
Purpose: Query public NAT gateway project tags, including key, values. Usage: python scripts/nat/list_nat_gateway_tag.py -h
---
list_nat_gateway_by_tag.py — Query Public NAT Gateway Instances by Tag
Purpose: Query public NAT gateway instances filtered by tag, including resource_id, resource_name, tags. Usage: python scripts/nat/list_nat_gateway_by_tag.py -h
---
show_nat_gateway_tag.py — Query Tags of a Specific Public NAT Gateway
Purpose: Query tags of a specific public NAT gateway, including key, value. Usage: python scripts/nat/show_nat_gateway_tag.py -h
---
list_private_nat_tags.py — Query Private NAT Gateway Project Tags
Purpose: Query private NAT gateway project tags, including key, values. Usage: python scripts/nat/list_private_nat_tags.py -h
---
list_private_nats_by_tags.py — Query Private NAT Gateway Instances by Tag
Purpose: Query private NAT gateway instances filtered by tag, including resource_id, resource_name, tags. Usage: python scripts/nat/list_private_nats_by_tags.py -h
---
show_private_nat_tags.py — Query Tags of a Specific Private NAT Gateway
Purpose: Query tags of a specific private NAT gateway, including key, value. Usage: python scripts/nat/show_private_nat_tags.py -h
---
list_transit_ip_tags.py — Query Transit IP Project Tags
Purpose: Query transit IP project tags, including key, values. Usage: python scripts/nat/list_transit_ip_tags.py -h
---
list_transit_ips_by_tags.py — Query Transit IP Instances by Tag
Purpose: Query transit IP instances filtered by tag, including resource_id, resource_name, tags. Usage: python scripts/nat/list_transit_ips_by_tags.py -h
---
show_transit_ip_tags.py — Query Tags of a Specific Transit IP
Purpose: Query tags of a specific transit IP, including key, value. Usage: python scripts/nat/show_transit_ip_tags.py -h
---
list_transit_subnet_tags.py — Query Transit Subnet Project Tags
Purpose: Query transit subnet project tags, including key, values. Usage: python scripts/nat/list_transit_subnet_tags.py -h
---
list_transit_subnets_by_tags.py — Query Transit Subnet Instances by Tag
Purpose: Query transit subnet instances filtered by tag, including resource_id, resource_name, tags. Usage: python scripts/nat/list_transit_subnets_by_tags.py -h
---
show_transit_subnet_tags.py — Query Tags of a Specific Transit Subnet
Purpose: Query tags of a specific transit subnet, including key, value. Usage: python scripts/nat/show_transit_subnet_tags.py -h
VPC Python Script Usage Guide
---
v3 List Queries
list_vpcs.py — Query VPC List
Purpose: Query the VPC list, including name, ID, CIDR, status, description. Usage: python scripts/vpc/list_vpcs.py -h
---
list_virsubnets.py — Query Subnet List
Purpose: Query the subnet list, including name, ID, VPC ID, status, CIDR range, availability zone ID, description. Usage: python scripts/vpc/list_virsubnets.py -h
---
list_security_groups.py — Query Security Group List
Purpose: Query the security group list, including name, ID, description. Usage: python scripts/vpc/list_security_groups.py -h
---
list_security_group_rules.py — Query Security Group Rule List
Purpose: Query the security group rule list, including ID, direction, protocol, action, remote IP prefix, remote security group ID, security group ID, priority. Usage: python scripts/vpc/list_security_group_rules.py -h
---
list_ports.py — Query Port List
Purpose: Query the port list, including ID, name, device ID, device owner, MAC address, status, admin state, VPC ID, subnet ID. Usage: python scripts/vpc/list_ports.py -h
---
list_firewall.py — Query Firewall List
Purpose: Query the firewall list, including ID, name, status, admin state, description, enterprise project ID. Usage: python scripts/vpc/list_firewall.py -h
---
list_address_group.py — Query Address Group List
Purpose: Query the address group list, including ID, name, IP version, max capacity, description. Usage: python scripts/vpc/list_address_group.py -h
---
list_sub_network_interfaces.py — Query Sub Network Interface List
Purpose: Query the sub network interface list, including ID, subnet ID, private IP address, MAC address, VPC ID, parent ID. Usage: python scripts/vpc/list_sub_network_interfaces.py -h
---
list_traffic_mirror_filters.py — Query Traffic Mirror Filter List
Purpose: Query the traffic mirror filter list, including ID, name, description, created at, updated at. Usage: python scripts/vpc/list_traffic_mirror_filters.py -h
---
list_traffic_mirror_filter_rules.py — Query Traffic Mirror Filter Rule List
Purpose: Query the traffic mirror filter rule list, including ID, traffic mirror filter ID, direction, protocol, source CIDR, destination CIDR, action, priority. Usage: python scripts/vpc/list_traffic_mirror_filter_rules.py -h
---
list_traffic_mirror_sessions.py — Query Traffic Mirror Session List
Purpose: Query the traffic mirror session list, including ID, name, traffic mirror filter ID, traffic mirror target ID, virtual network ID, priority, enabled. Usage: python scripts/vpc/list_traffic_mirror_sessions.py -h
---
list_virsubnet_cidr_reservations.py — Query Subnet CIDR Reservation List
Purpose: Query the subnet CIDR reservation list, including ID, subnet ID, CIDR, IP version, name, description. Usage: python scripts/vpc/list_virsubnet_cidr_reservations.py -h
list_address_groups_dependency.py — Query Address Group Dependencies
Purpose: Query address group dependencies, including ID, name, IP version, max capacity, description. Usage: python scripts/vpc/list_address_groups_dependency.py -h
show_vpc.py — Query VPC Details
Purpose: Query VPC details, including ID, name, CIDR, status, description, enterprise project ID, created at, updated at. Usage: python scripts/vpc/show_vpc.py -h
---
show_virsubnet.py — Query Subnet Details
Purpose: Query subnet details, including ID, name, VPC ID, status, CIDR range, availability zone ID, description, created at, updated at. Usage: python scripts/vpc/show_virsubnet.py -h
---
show_security_group.py — Query Security Group Details
Purpose: Query security group details, including ID, name, description, enterprise project ID, created at, updated at. Usage: python scripts/vpc/show_security_group.py -h
---
show_security_group_rule.py — Query Security Group Rule Details
Purpose: Query security group rule details, including ID, direction, protocol, action, remote IP prefix, remote security group ID, security group ID, priority, IP protocol type, port range min, port range max. Usage: python scripts/vpc/show_security_group_rule.py -h
---
show_port.py — Query Port Details
Purpose: Query port details, including ID, name, device ID, device owner, MAC address, status, admin state, VPC ID, subnet ID. Usage: python scripts/vpc/show_port.py -h
---
show_firewall.py — Query Firewall Details
Purpose: Query firewall details, including ID, name, status, admin state, description, enterprise project ID, created at, updated at. Usage: python scripts/vpc/show_firewall.py -h
---
show_address_group.py — Query Address Group Details
Purpose: Query address group details, including ID, name, IP version, max capacity, description, created at, updated at. Usage: python scripts/vpc/show_address_group.py -h
---
show_sub_network_interface.py — Query Sub Network Interface Details
Purpose: Query sub network interface details, including ID, subnet ID, private IP address, MAC address, VPC ID, parent ID, description. Usage: python scripts/vpc/show_sub_network_interface.py -h
---
show_virsubnet_cidr_reservation.py — Query Subnet CIDR Reservation Details
Purpose: Query subnet CIDR reservation details, including ID, subnet ID, CIDR, IP version, name, description. Usage: python scripts/vpc/show_virsubnet_cidr_reservation.py -h
---
show_traffic_mirror_filter.py — Query Traffic Mirror Filter Details
Purpose: Query traffic mirror filter details, including ID, name, description, created at, updated at. Usage: python scripts/vpc/show_traffic_mirror_filter.py -h
---
show_traffic_mirror_filter_rule.py — Query Traffic Mirror Filter Rule Details
Purpose: Query traffic mirror filter rule details, including ID, traffic mirror filter ID, direction, protocol, source CIDR, destination CIDR, action, priority. Usage: python scripts/vpc/show_traffic_mirror_filter_rule.py -h
---
show_traffic_mirror_session.py — Query Traffic Mirror Session Details
Purpose: Query traffic mirror session details, including ID, name, traffic mirror filter ID, traffic mirror target ID, virtual network ID, priority, enabled, description. Usage: python scripts/vpc/show_traffic_mirror_session.py -h
---
show_quota.py — Query Quota
Purpose: Query quota, including key, value. Usage: python scripts/vpc/show_quota.py -h
---
show_sub_network_interfaces_quantity.py — Query Sub Network Interface Count
Purpose: Query the count of sub network interfaces. Usage: python scripts/vpc/show_sub_network_interfaces_quantity.py -h
list_subnets.py — Query Subnet List (v2)
Purpose: Query the subnet list (v2), including name, ID, CIDR, gateway IP, VPC ID, status, availability zone. Usage: python scripts/vpc/list_subnets.py -h
---
list_flow_logs.py — Query VPC Flow Log List
Purpose: Query the VPC flow log list, including ID, name, resource type, resource ID, traffic type, log group ID, log topic ID, status. Usage: python scripts/vpc/list_flow_logs.py -h
---
list_route_tables.py — Query Route Table List
Purpose: Query the route table list, including ID, VPC ID, name. Usage: python scripts/vpc/list_route_tables.py -h
---
list_vpc_peerings.py — Query VPC Peering List
Purpose: Query the VPC peering list, including ID, name, status, requester VPC ID, requester tenant ID, accepter VPC ID, accepter tenant ID. Usage: python scripts/vpc/list_vpc_peerings.py -h
---
list_vpc_routes.py — Query VPC Route List
Purpose: Query the VPC route list, including ID, type, destination, VPC ID, next hop. Usage: python scripts/vpc/list_vpc_routes.py -h
---
list_privateips.py — Query Private IP List
Purpose: Query the private IP list, including ID, subnet ID, IP address, status, device owner. Usage: python scripts/vpc/list_privateips.py -h
show_subnet.py — Query Subnet Details (v2)
Purpose: Query subnet details (v2), including ID, name, CIDR, gateway IP, VPC ID, status, availability zone, DHCP enabled, primary DNS, secondary DNS, description. Usage: python scripts/vpc/show_subnet.py -h
---
show_flow_log.py — Query VPC Flow Log Details
Purpose: Query VPC flow log details, including ID, name, resource type, resource ID, traffic type, log group ID, log topic ID, status, description. Usage: python scripts/vpc/show_flow_log.py -h
---
show_route_table.py — Query Route Table Details
Purpose: Query route table details, including ID, name, VPC ID, description. Usage: python scripts/vpc/show_route_table.py -h
---
show_vpc_peering.py — Query VPC Peering Details
Purpose: Query VPC peering details, including ID, name, status. Usage: python scripts/vpc/show_vpc_peering.py -h
---
show_vpc_route.py — Query VPC Route Details
Purpose: Query VPC route details, including ID, type, destination, VPC ID, next hop. Usage: python scripts/vpc/show_vpc_route.py -h
---
show_privateip.py — Query Private IP Details
Purpose: Query private IP details, including ID, subnet ID, IP address, status, device owner. Usage: python scripts/vpc/show_privateip.py -h
---
show_network_ip_availabilities.py — Query Network IP Availability
Purpose: Query the number of available network IPs. Usage: python scripts/vpc/show_network_ip_availabilities.py -h
---
VPN Python Script Usage Guide
---
Availability Zone Queries
list_availability_zones.py — Query VPN Availability Zone List
Purpose: Query the VPN availability zone list, including category, type, availability zone list. Usage: python scripts/vpn/list_availability_zones.py -h
---
list_extended_availability_zones.py — Query Extended Availability Zone List
Purpose: Query the VPN extended availability zone list, including name, common border group, available specifications. Usage: python scripts/vpn/list_extended_availability_zones.py -h
---
list_p2c_vgw_availability_zones.py — Query P2C VPN Gateway Availability Zone List
Purpose: Query the P2C VPN gateway availability zone list. Usage: python scripts/vpn/list_p2c_vgw_availability_zones.py -h
list_cgws.py — Query Peer Gateway List
Purpose: Query the peer gateway list, including ID, name, BGP AS number, identifier type, identifier value, created at. Usage: python scripts/vpn/list_cgws.py -h
---
show_cgw.py — Query Peer Gateway Details
Purpose: Query peer gateway details, including ID, name, BGP AS number, identifier type, identifier value, CA certificate, created at, updated at. Usage: python scripts/vpn/show_cgw.py -h
list_vgws.py — Query VPN Gateway List
Purpose: Query the VPN gateway list, including ID, name, status, association type, VPC ID, specification, connection count, used connection count, enterprise project ID. Usage: python scripts/vpn/list_vgws.py -h
---
show_vgw.py — Query VPN Gateway Details
Purpose: Query VPN gateway details, including ID, name, status, association type, IP version, VPC ID, specification, connection count, used connection count, enterprise project ID, HA mode, created at, updated at. Usage: python scripts/vpn/show_vgw.py -h
---
show_vpn_gateway_certificate.py — Query VPN Gateway Certificate
Purpose: Query VPN gateway certificate details, including ID, name, VPN gateway ID, status, issuer, signature algorithm, certificate serial number, certificate subject, certificate expiration time, created at, updated at. Usage: python scripts/vpn/show_vpn_gateway_certificate.py -h
---
show_vpn_gateway_routing_table.py — Query VPN Gateway Routing Table
Purpose: Query the VPN gateway routing table, including destination, next hop, outgoing interface IP, source, AS path, MED value. Usage: python scripts/vpn/show_vpn_gateway_routing_table.py -h
list_vpn_connections.py — Query VPN Connection List
Purpose: Query the VPN connection list, including ID, name, status, VPN gateway ID, peer gateway ID, connection mode, enterprise project ID. Usage: python scripts/vpn/list_vpn_connections.py -h
---
show_vpn_connection.py — Query VPN Connection Details
Purpose: Query VPN connection details, including ID, name, status, VPN gateway ID, VPN gateway IP, connection mode, peer gateway ID, tunnel local address, tunnel peer address, NQA switch, Hub switch, created at, updated at, enterprise project ID. Usage: python scripts/vpn/show_vpn_connection.py -h
---
show_vpn_connection_log.py — Query VPN Connection Log
Purpose: Query VPN connection log, including time, raw message. Usage: python scripts/vpn/show_vpn_connection_log.py -h
list_connection_monitors.py — Query Connection Monitor List
Purpose: Query the VPN connection monitor list, including ID, status, VPN connection ID, type, source IP, destination IP. Usage: python scripts/vpn/list_connection_monitors.py -h
---
show_connection_monitor.py — Query Connection Monitor Details
Purpose: Query VPN connection monitor details, including ID, status, VPN connection ID, type, source IP, destination IP, protocol type. Usage: python scripts/vpn/show_connection_monitor.py -h
list_vpn_gateway_jobs.py — Query VPN Gateway Job List
Purpose: Query the VPN gateway job list, including ID, resource ID, job type, status, created at. Usage: python scripts/vpn/list_vpn_gateway_jobs.py -h
---
list_p2c_vpn_gateway_jobs.py — Query P2C VPN Gateway Job List
Purpose: Query the P2C VPN gateway job list, including ID, resource ID, job type, status, created at. Usage: python scripts/vpn/list_p2c_vpn_gateway_jobs.py -h
list_p2c_vgws.py — Query P2C VPN Gateway List
Purpose: Query the P2C VPN gateway list, including ID, name, status, VPC ID, specification, max connection count, current connection count, enterprise project ID. Usage: python scripts/vpn/list_p2c_vgws.py -h
---
show_p2c_vgw.py — Query P2C VPN Gateway Details
Purpose: Query P2C VPN gateway details, including ID, name, status, VPC ID, connection subnet, specification, max connection count, current connection count, enterprise project ID, created at, updated at. Usage: python scripts/vpn/show_p2c_vgw.py -h
---
list_p2c_vgw_connections.py — Query P2C VPN Gateway Connection List
Purpose: Query the P2C VPN gateway connection list, including connection ID, client IP, client username, inbound packets, outbound packets. Usage: python scripts/vpn/list_p2c_vgw_connections.py -h
---
show_vpn_connections_log_config.py — Query VPN Connection Log Configuration
Purpose: Query VPN connection log configuration, including log group ID, log stream ID. Usage: python scripts/vpn/show_vpn_connections_log_config.py -h
list_vpn_servers_by_project.py — Query VPN Server List Under Project
Purpose: Query the VPN server list under a project, including ID, P2C VPN gateway ID, client authentication type, tunnel protocol, status. Usage: python scripts/vpn/list_vpn_servers_by_project.py -h
---
list_vpn_servers_by_vgw.py — Query VPN Server List Under Gateway
Purpose: Query the VPN server list under a VPN gateway, including ID, P2C VPN gateway ID, client authentication type, tunnel protocol, status. Usage: python scripts/vpn/list_vpn_servers_by_vgw.py -h
---
show_client_ca.py — Query Client CA Certificate
Purpose: Query client CA certificate details, including ID, name, issuer, subject, serial number, expiration time, signature algorithm, created at, updated at. Usage: python scripts/vpn/show_client_ca.py -h
list_vpn_access_policies.py — Query VPN Access Policy List
Purpose: Query the VPN access policy list, including ID, name, type, user group ID, user group name, description. Usage: python scripts/vpn/list_vpn_access_policies.py -h
---
show_vpn_access_policy.py — Query VPN Access Policy Details
Purpose: Query VPN access policy details, including ID, name, type, user group ID, user group name, description, created at, updated at. Usage: python scripts/vpn/show_vpn_access_policy.py -h
list_vpn_user_groups.py — Query VPN User Group List
Purpose: Query the VPN user group list, including ID, name, description, type, user count. Usage: python scripts/vpn/list_vpn_user_groups.py -h
---
show_vpn_user_group.py — Query VPN User Group Details
Purpose: Query VPN user group details, including ID, name, description, type, user count, created at, updated at. Usage: python scripts/vpn/show_vpn_user_group.py -h
list_vpn_users.py — Query VPN User List
Purpose: Query the VPN user list, including ID, name, description, user group ID, user group name. Usage: python scripts/vpn/list_vpn_users.py -h
---
show_vpn_user.py — Query VPN User Details
Purpose: Query VPN user details, including ID, name, description, user group ID, user group name, created at, updated at. Usage: python scripts/vpn/show_vpn_user.py -h
---
list_vpn_users_in_group.py — Query User List Within User Group
Purpose: Query the VPN user list within a user group, including ID, name, description. Usage: python scripts/vpn/list_vpn_users_in_group.py -h
show_quotas_info.py — Query Quota Information
Purpose: Query VPN quota information, including type, used, quota, unit. Usage: python scripts/vpn/show_quotas_info.py -h
---
list_project_tags.py — Query Project Tags
Purpose: Query VPN project tags, including key, values. Usage: python scripts/vpn/list_project_tags.py -h
---
list_resources_by_tags.py — Query Resource Instance List by Tag
Purpose: Query VPN resource instance list by tag, including resource_id, resource_name, tags. Usage: python scripts/vpn/list_resources_by_tags.py -h
---
show_resource_tags.py — Query Resource Tags
Purpose: Query VPN resource tags, including key, value. Usage: python scripts/vpn/show_resource_tags.py -h
huaweicloudsdkcore>=3.1.0
huaweicloudsdkeip>=3.1.0
huaweicloudsdkelb>=3.1.0
huaweicloudsdkiam>=3.1.0
huaweicloudsdknat>=3.1.0
huaweicloudsdkvpc>=3.1.0
huaweicloudsdkvpn>=3.1.0
huaweicloudsdkdns>=3.1.0<#
华为云资源查询 - 环境检查前置脚本 (Windows PowerShell)
#>
$ErrorActionPreference = "Stop"
Write-Output ""
Write-Output "=================================================="
Write-Output " 华为云资源查询 - 环境检查"
Write-Output "=================================================="
# 步骤 1:检查 Python 是否存在
Write-Output ""
Write-Output "[1/3] 检查 Python 环境"
$pythonPath = $null
foreach ($cmd in @("python3", "python")) {
$candidate = Get-Command $cmd -ErrorAction SilentlyContinue
if ($candidate) {
$testVer = (& $candidate.Path --version 2>&1 | Out-String).Trim()
if ($testVer -match "^Python \d+") {
$pythonPath = $candidate
break
}
}
}
if (-not $pythonPath) {
Write-Output "FAIL: Python 未安装或不可用"
Write-Output "环境未就绪,请先安装 Python 3.6+"
exit 1
}
Write-Output "OK: 找到 Python: $($pythonPath.Path)"
# 步骤 2:检查 Python 版本
Write-Output ""
Write-Output "[2/3] 检查 Python 版本"
$pythonVersion = (& $pythonPath.Path --version 2>&1 | Out-String).Trim()
if (-not $pythonVersion) {
Write-Output "FAIL: 无法获取 Python 版本"
exit 1
}
$versionMatch = [regex]::Match($pythonVersion, 'Python (\d+)\.(\d+)')
if (-not $versionMatch.Success) {
Write-Output "FAIL: 无法解析 Python 版本"
exit 1
}
$major = [int]$versionMatch.Groups[1].Value
$minor = [int]$versionMatch.Groups[2].Value
$versionStr = "$major.$minor"
Write-Output " 当前版本: $versionStr"
if ($major -lt 3 -or ($major -eq 3 -and $minor -lt 6)) {
Write-Output "FAIL: Python $versionStr `< 3.6"
Write-Output "环境未就绪,请升级 Python 到 3.6+"
exit 1
}
Write-Output "OK: Python $versionStr >= 3.6"
# 步骤 3:调用 Python 详细检查
Write-Output ""
Write-Output "[3/3] 执行详细检查"
Write-Output "--------------------------------------------------"
$scriptDir = Split-Path $MyInvocation.MyCommand.Definition -Parent
$pythonScript = Join-Path $scriptDir "ensure_env.py"
if (-not (Test-Path $pythonScript)) {
Write-Output "FAIL: 未找到检查脚本: $pythonScript"
exit 1
}
try {
& $pythonPath.Path $pythonScript
$exitCode = $LASTEXITCODE
} catch {
Write-Output "FAIL: Python 脚本执行异常: $_"
exit 1
}
Write-Output ""
Write-Output "=================================================="
if ($exitCode -eq 0) {
Write-Output "✓ 环境检查通过"
exit 0
} else {
Write-Output "✗ 环境未就绪,请按提示修复"
exit $exitCode
}
#!/bin/bash
# 华为云资源查询 - 环境检查前置脚本
# 步骤 1:检查 Python 是否存在
echo ""
echo "[1/3] 检查 Python 环境"
PYTHON_CMD=""
# 优先使用项目 .venv 中的 Python
if [ -n "${BASH_SOURCE:-}" ]; then
SCRIPT_PATH="${BASH_SOURCE[0]}"
else
SCRIPT_PATH="$0"
fi
SCRIPT_DIR=$(cd "$(dirname "$SCRIPT_PATH")" >/dev/null 2>&1 && pwd)
PROJECT_ROOT=$(cd "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd)
VENV_PYTHON="${PROJECT_ROOT}/.venv/bin/python3"
if [ -f "$VENV_PYTHON" ]; then
PYTHON_CMD="$VENV_PYTHON"
else
for cmd in python3 python; do
if command -v "$cmd" &>/dev/null; then
test_ver=$("$cmd" --version 2>&1)
if echo "$test_ver" | grep -q "^Python [0-9]"; then
PYTHON_CMD="$cmd"
break
fi
fi
done
fi
if [ -z "$PYTHON_CMD" ]; then
echo "FAIL: 未检测到可用的 Python"
echo ""
echo "请先安装 Python 3.6+,根据当前系统参考:"
echo " macOS : brew install python"
echo " Ubuntu : sudo apt update && sudo apt install -y python3 python3-pip"
echo " CentOS : sudo yum install -y python3"
exit 1
fi
echo "OK: 找到 Python: ${PYTHON_CMD}"
# 步骤 2:检查 Python 版本
echo ""
echo "[2/3] 检查 Python 版本"
PYTHON_VERSION=$(${PYTHON_CMD} --version 2>&1 | awk '{print $2}')
if [ -z "${PYTHON_VERSION}" ]; then
echo "FAIL: 无法获取 Python 版本"
exit 1
fi
echo " 当前版本: ${PYTHON_VERSION}"
MAJOR=$(echo "${PYTHON_VERSION}" | cut -d'.' -f1)
MINOR=$(echo "${PYTHON_VERSION}" | cut -d'.' -f2)
if [ -z "${MAJOR}" ] || [ -z "${MINOR}" ]; then
echo "FAIL: 无法解析 Python 版本: ${PYTHON_VERSION}"
exit 1
fi
if [ "$MAJOR" -lt 3 ] || { [ "$MAJOR" -eq 3 ] && [ "$MINOR" -lt 6 ]; }; then
echo "FAIL: Python 版本过低 ($PYTHON_VERSION),需要 >= 3.6"
echo ""
echo "请升级 Python 后重试。"
exit 1
fi
echo "OK: Python ${PYTHON_VERSION} >= 3.6"
# 步骤 3:调用 Python 详细检查
echo ""
echo "[3/3] 执行详细检查"
echo "--------------------------------------------------"
PYTHON_SCRIPT="${SCRIPT_DIR}/ensure_env.py"
if [ ! -f "$PYTHON_SCRIPT" ]; then
echo "FAIL: 未找到检查脚本"
echo " 预期路径: $PYTHON_SCRIPT"
echo " 当前目录: $(pwd)"
exit 1
fi
"${PYTHON_CMD}" "${PYTHON_SCRIPT}"
EXIT_CODE=$?
echo ""
echo "=================================================="
if [ "${EXIT_CODE}" -eq 0 ]; then
echo "✓ 环境检查通过"
exit 0
else
echo "✗ 环境未就绪,请按提示修复"
exit 1
fi
import os
import urllib3
from urllib.parse import urlparse
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkcore.http.http_config import HttpConfig
# 抑制因 ignore_ssl_verification 产生的 InsecureRequestWarning
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def load_credentials():
"""从环境变量加载华为云凭据
支持永久 AK/SK 和临时 AK/SK(含 SecurityToken)。
设置 HW_SECURITY_TOKEN 环境变量即可启用临时凭证模式。
"""
ak = os.getenv("HW_ACCESS_KEY", "")
sk = os.getenv("HW_SECRET_KEY", "")
region = os.getenv("HW_REGION_NAME", "cn-north-4")
security_token = os.getenv("HW_SECURITY_TOKEN", "")
if not ak or not sk:
print("未配置 AK/SK,请设置环境变量 HW_ACCESS_KEY 和 HW_SECRET_KEY")
exit(-1)
return ak, sk, region, security_token
def _get_proxy_url():
"""获取代理 URL,优先级: HTTPS_PROXY > HTTP_PROXY"""
proxy_url = os.getenv("HTTPS_PROXY", "")
if proxy_url:
return proxy_url
proxy_url = os.getenv("HTTP_PROXY", "")
if proxy_url:
return proxy_url
return ""
def build_http_config():
"""构建 HTTP 配置,代理支持环境变量
代理 URL 来源(优先级从高到低):
1. HTTPS_PROXY
2. HTTP_PROXY
代理 URL 格式:
- http://host:port
- http://user:pass@host:port
"""
http_config = HttpConfig.get_default_config()
http_config.ignore_ssl_verification = True
http_config.timeout = (30, 60)
http_config.retry_times = 3
proxy_url = _get_proxy_url()
if proxy_url:
parsed = urlparse(proxy_url)
http_config.proxy_protocol = parsed.scheme or "http"
http_config.proxy_host = parsed.hostname or ""
http_config.proxy_port = parsed.port or 8080
http_config.proxy_user = parsed.username or ""
http_config.proxy_password = parsed.password or ""
return http_config
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListApiVersionsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
parser = argparse.ArgumentParser(description="查询API版本信息列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(versions):
if not versions:
print("没有找到API版本信息")
return
header = "id\tstatus"
output = header + "\n"
for v in versions:
vid = getattr(v, 'id', '')
status = getattr(v, 'status', '')
output += f"{vid}\t{status}\n"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListApiVersionsRequest()
response = client.list_api_versions(request)
values = getattr(response, 'versions', None)
items = getattr(values, 'values', []) if values else []
if not items:
print("没有找到API版本信息")
exit(0)
render(items)
except Exception as e:
print(f"dns.list_api_versions 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListCustomLineRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询自定义线路")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--line_id", type=str, help="自定义线路ID")
parser.add_argument("--name", type=str, help="自定义线路名称")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--show_detail", type=bool, help="是否显示详细信息,默认 false")
parser.add_argument("--status", type=str, help="自定义线路状态: ACTIVE/ERROR")
parser.add_argument("--ip", type=str, help="自定义线路的IP地址")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(lines):
total = len(lines)
if Offset >= total:
print(f"查询结果为空\n\n自定义线路列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "line_id\tname\tstatus\tcreated_at\tupdated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
line = lines[i]
line_id = getattr(line, 'line_id', '')
name = getattr(line, 'name', '')
status = getattr(line, 'status', '')
created_at = getattr(line, 'created_at', '')
updated_at = getattr(line, 'updated_at', '')
output += f"{line_id}\t{name}\t{status}\t{created_at}\t{updated_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n自定义线路列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListCustomLineRequest()
if args.line_id:
request.line_id = args.line_id
if args.name:
request.name = args.name
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
if args.show_detail is not None:
request.show_detail = args.show_detail
if args.status:
request.status = args.status
if args.ip:
request.ip = args.ip
response = client.list_custom_line(request)
lines = getattr(response, 'lines', []) or []
if not lines:
print("没有找到自定义线路")
exit(0)
render(lines)
except Exception as e:
print(f"dns.list_custom_line 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListEndpointIpaddressesRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
parser = argparse.ArgumentParser(description="查询IP地址列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--endpoint_id", type=str, required=True, help="终端节点ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(ipaddresses):
if not ipaddresses:
print("没有找到IP地址信息")
return
header = "id\tip\tstatus\tcreated_at\tupdated_at"
output = header + "\n"
for ipaddr in ipaddresses:
ipid = getattr(ipaddr, 'id', '')
ip_info = getattr(ipaddr, 'ip', None)
ip_val = getattr(ip_info, 'ip', '') if ip_info else ''
status = getattr(ipaddr, 'status', '')
created_at = getattr(ipaddr, 'created_at', '')
updated_at = getattr(ipaddr, 'updated_at', '')
output += f"{ipid}\t{ip_val}\t{status}\t{created_at}\t{updated_at}\n"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListEndpointIpaddressesRequest()
request.endpoint_id = args.endpoint_id
response = client.list_endpoint_ipaddresses(request)
ipaddresses = getattr(response, 'ipaddresses', []) or []
if not ipaddresses:
print(f"没有找到IP地址 (endpoint_id: {args.endpoint_id})")
exit(0)
render(ipaddresses)
except Exception as e:
print(f"dns.list_endpoint_ipaddresses 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListEndpointVpcsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询终端节点VPC列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--vpc_id", type=str, help="VPC ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(vpcs):
total = len(vpcs)
if Offset >= total:
print(f"查询结果为空\n\nVPC列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "vpc_id\tvpc_name\tregion"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
vpc = vpcs[i]
vpc_id = getattr(vpc, 'vpc_id', '')
vpc_name = getattr(vpc, 'vpc_name', '')
region = getattr(vpc, 'region', '')
output += f"{vpc_id}\t{vpc_name}\t{region}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\nVPC列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListEndpointVpcsRequest()
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
if args.vpc_id:
request.vpc_id = args.vpc_id
response = client.list_endpoint_vpcs(request)
vpcs = getattr(response, 'vpcs', []) or []
if not vpcs:
print("没有找到终端节点VPC")
exit(0)
render(vpcs)
except Exception as e:
print(f"dns.list_endpoint_vpcs 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListEndpointsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询终端节点列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--direction", type=str, required=True, choices=["inbound", "outbound"], help="终端节点方向: inbound/outbound")
parser.add_argument("--vpc_id", type=str, help="VPC ID")
parser.add_argument("--name", type=str, help="终端节点名称")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(endpoints):
total = len(endpoints)
if Offset >= total:
print(f"查询结果为空\n\n终端节点列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tname\tdirection\tstatus\tcreated_at\tupdated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
ep = endpoints[i]
epid = getattr(ep, 'id', '')
name = getattr(ep, 'name', '')
direction = getattr(ep, 'direction', '')
status = getattr(ep, 'status', '')
created_at = getattr(ep, 'created_at', '')
updated_at = getattr(ep, 'updated_at', '')
output += f"{epid}\t{name}\t{direction}\t{status}\t{created_at}\t{updated_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n终端节点列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListEndpointsRequest()
request.direction = args.direction
if args.vpc_id:
request.vpc_id = args.vpc_id
if args.name:
request.name = args.name
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
response = client.list_endpoints(request)
endpoints = getattr(response, 'endpoints', []) or []
if not endpoints:
print("没有找到终端节点")
exit(0)
render(endpoints)
except Exception as e:
print(f"dns.list_endpoints 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListInstancesRequest, ListInstancesRequestBody
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
parser = argparse.ArgumentParser(description="批量查询DNS解析量统计相关的资源")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--domain_id", type=str, help="域名ID")
parser.add_argument("--domain_name", type=str, help="域名名称")
parser.add_argument("--start_time", type=str, help="查询开始时间,格式 YYYY-MM-DD")
parser.add_argument("--end_time", type=str, help="查询结束时间,格式 YYYY-MM-DD")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(instances):
if not instances:
print("没有找到DNS解析量统计资源")
return
header = "id\tname\tstatus\tregion\tenterprise_project_id"
output = header + "\n"
for inst in instances:
iid = getattr(inst, 'id', '')
name = getattr(inst, 'name', '')
status = getattr(inst, 'status', '')
region = getattr(inst, 'region', '')
ep_id = getattr(inst, 'enterprise_project_id', '')
output += f"{iid}\t{name}\t{status}\t{region}\t{ep_id}\n"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListInstancesRequest()
body = ListInstancesRequestBody()
if args.domain_id:
body.domain_id = args.domain_id
if args.domain_name:
body.domain_name = args.domain_name
if args.start_time:
body.start_time = args.start_time
if args.end_time:
body.end_time = args.end_time
request.body = body
response = client.list_instances(request)
instances = getattr(response, 'instances', []) or []
if not instances:
print("没有找到DNS解析量统计资源")
exit(0)
render(instances)
except Exception as e:
print(f"dns.list_instances 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListLineGroupsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询线路分组列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--line_id", type=str, help="线路分组ID")
parser.add_argument("--name", type=str, help="线路分组名称")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(linegroups):
total = len(linegroups)
if Offset >= total:
print(f"查询结果为空\n\n线路分组列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "line_id\tname\tstatus\tdescription\tcreated_at\tupdated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
lg = linegroups[i]
line_id = getattr(lg, 'line_id', '')
name = getattr(lg, 'name', '')
status = getattr(lg, 'status', '')
description = getattr(lg, 'description', '')
created_at = getattr(lg, 'created_at', '')
updated_at = getattr(lg, 'updated_at', '')
output += f"{line_id}\t{name}\t{status}\t{description}\t{created_at}\t{updated_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n线路分组列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListLineGroupsRequest()
if args.line_id:
request.line_id = args.line_id
if args.name:
request.name = args.name
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
response = client.list_line_groups(request)
linegroups = getattr(response, 'linegroups', []) or []
if not linegroups:
print("没有找到线路分组")
exit(0)
render(linegroups)
except Exception as e:
print(f"dns.list_line_groups 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListNameServersRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
parser = argparse.ArgumentParser(description="查询名称服务器列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--type", type=str, choices=["public", "private"], help="域名类型: public/private")
parser.add_argument("--ns_region", type=str, help="区域,如 cn-north-4")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(nameservers):
if not nameservers:
print("没有找到名称服务器信息")
return
for ns in nameservers:
ns_type = getattr(ns, 'type', '')
ns_region = getattr(ns, 'region', '')
ns_records = getattr(ns, 'ns_records', []) or []
print(f"type: {ns_type}, region: {ns_region}")
if ns_records:
header = " hostname\tpriority\taddress"
print(header)
for record in ns_records:
hostname = getattr(record, 'hostname', '')
priority = str(getattr(record, 'priority', ''))
address = getattr(record, 'address', '')
print(f" {hostname}\t{priority}\t{address}")
print()
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListNameServersRequest()
if args.type:
request.type = args.type
if args.ns_region:
request.region = args.ns_region
response = client.list_name_servers(request)
nameservers = getattr(response, 'nameservers', []) or []
if not nameservers:
print("没有找到名称服务器信息")
exit(0)
render(nameservers)
except Exception as e:
print(f"dns.list_name_servers 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListPrivateZonesRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询内网域名列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--type", type=str, required=True, default="private", help="待查询域名的类型,取值: private")
parser.add_argument("--limit", type=int, required=True, default=50, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--tags", type=str, help="内网域名的标签,格式 key1,value1|key2,value2")
parser.add_argument("--name", type=str, help="域名名称,默认模糊搜索")
parser.add_argument("--id", type=str, help="域名ID")
parser.add_argument("--status", type=str, help="内网域名状态: ACTIVE/PENDING_CREATE/PENDING_UPDATE/PENDING_DELETE/FREEZE/DISABLE/ERROR 等")
parser.add_argument("--search_mode", type=str, choices=["like", "equal"], help="查询条件搜索模式: like(模糊搜索)/equal(精确搜索)")
parser.add_argument("--sort_key", type=str, choices=["name", "created_at", "updated_at"], help="排序字段,默认 created_at")
parser.add_argument("--sort_dir", type=str, choices=["desc", "asc"], help="排序方式,默认 desc")
parser.add_argument("--enterprise_project_id", type=str, help="企业项目ID")
parser.add_argument("--router_id", type=str, help="关联VPC的ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(zones):
total = len(zones)
if Offset >= total:
print(f"查询结果为空\n\n内网域名列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "zone_id\tname\tstatus\tzone_type\tttl\trecord_num\tenterprise_project_id\tcreated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
z = zones[i]
zid = getattr(z, 'id', '')
name = getattr(z, 'name', '')
status = getattr(z, 'status', '')
zone_type = getattr(z, 'zone_type', '')
ttl = str(getattr(z, 'ttl', ''))
record_num = str(getattr(z, 'record_num', ''))
ep_id = getattr(z, 'enterprise_project_id', '')
created_at = getattr(z, 'created_at', '')
output += f"{zid}\t{name}\t{status}\t{zone_type}\t{ttl}\t{record_num}\t{ep_id}\t{created_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n内网域名列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_zones = []
marker = ""
limit = 500
request = ListPrivateZonesRequest()
request.limit = limit
if args.type:
request.type = args.type
if args.tags:
request.tags = args.tags
if args.name:
request.name = args.name
if args.id:
request.id = args.id
if args.status:
request.status = args.status
if args.search_mode:
request.search_mode = args.search_mode
if args.sort_key:
request.sort_key = args.sort_key
if args.sort_dir:
request.sort_dir = args.sort_dir
if args.enterprise_project_id:
request.enterprise_project_id = args.enterprise_project_id
if args.router_id:
request.router_id = args.router_id
while True:
if marker:
request.marker = marker
response = client.list_private_zones(request)
zones = getattr(response, 'zones', []) or []
if not zones:
break
all_zones.extend(zones)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = zones[-1].id if zones else ""
if not all_zones:
print(f"没有找到内网域名 (区域: {Region})")
exit(0)
render(all_zones)
except Exception as e:
print(f"dns.list_private_zones 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListPtrRecordsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询弹性公网IP的反向解析记录列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--enterprise_project_id", type=str, help="企业项目ID")
parser.add_argument("--tags", type=str, help="资源标签,格式 key1,value1|key2,value2")
parser.add_argument("--status", type=str, help="反向解析状态: ACTIVE/ERROR/FREEZE/DISABLE")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(floatingips):
total = len(floatingips)
if Offset >= total:
print(f"查询结果为空\n\n反向解析列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\taddress\tptrdname\tstatus\tttl"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
fip = floatingips[i]
fid = getattr(fip, 'id', '')
address = getattr(fip, 'address', '')
ptrdname = getattr(fip, 'ptrdname', '')
status = getattr(fip, 'status', '')
ttl = str(getattr(fip, 'ttl', ''))
output += f"{fid}\t{address}\t{ptrdname}\t{status}\t{ttl}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n反向解析列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_floatingips = []
marker = ""
limit = 500
request = ListPtrRecordsRequest()
request.limit = limit
if args.enterprise_project_id:
request.enterprise_project_id = args.enterprise_project_id
if args.tags:
request.tags = args.tags
if args.status:
request.status = args.status
while True:
if marker:
request.marker = marker
response = client.list_ptr_records(request)
floatingips = getattr(response, 'floatingips', []) or []
if not floatingips:
break
all_floatingips.extend(floatingips)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = floatingips[-1].id if floatingips else ""
if not all_floatingips:
print(f"没有找到反向解析记录 (区域: {Region})")
exit(0)
render(all_floatingips)
except Exception as e:
print(f"dns.list_ptr_records 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListPtrsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询弹性公网IP的反向解析记录列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--enterprise_project_id", type=str, help="企业项目ID")
parser.add_argument("--tags", type=str, help="资源标签,格式 key1,value1|key2,value2")
parser.add_argument("--status", type=str, help="反向解析状态: ACTIVE/ERROR/FREEZE/DISABLE")
parser.add_argument("--resource_type", type=str, help="资源类型: publiczone")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(floatingips):
total = len(floatingips)
if Offset >= total:
print(f"查询结果为空\n\n反向解析列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\taddress\tptrdname\tstatus\tttl"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
fip = floatingips[i]
fid = getattr(fip, 'id', '')
address = getattr(fip, 'address', '')
ptrdname = getattr(fip, 'ptrdname', '')
status = getattr(fip, 'status', '')
ttl = str(getattr(fip, 'ttl', ''))
output += f"{fid}\t{address}\t{ptrdname}\t{status}\t{ttl}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n反向解析列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_floatingips = []
marker = ""
limit = 500
request = ListPtrsRequest()
request.limit = limit
if args.enterprise_project_id:
request.enterprise_project_id = args.enterprise_project_id
if args.tags:
request.tags = args.tags
if args.status:
request.status = args.status
if args.resource_type:
request.resource_type = args.resource_type
while True:
if marker:
request.marker = marker
response = client.list_ptrs(request)
floatingips = getattr(response, 'floatingips', []) or []
if not floatingips:
break
all_floatingips.extend(floatingips)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = floatingips[-1].id if floatingips else ""
if not all_floatingips:
print(f"没有找到反向解析记录 (区域: {Region})")
exit(0)
render(all_floatingips)
except Exception as e:
print(f"dns.list_ptrs 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListPublicZoneLinesRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询公网域名的线路列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--zone_id", type=str, required=True, help="公网域名的ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(lines):
total = len(lines)
if Offset >= total:
print(f"查询结果为空\n\n线路列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "line_id\tname\tip_segments\tcreated_at\tupdated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
line = lines[i]
line_id = getattr(line, 'line_id', '')
name = getattr(line, 'name', '')
ip_segments = getattr(line, 'ip_segments', []) or []
created_at = getattr(line, 'created_at', '')
updated_at = getattr(line, 'updated_at', '')
ip_str = '; '.join(ip_segments) if ip_segments else ''
output += f"{line_id}\t{name}\t{ip_str}\t{created_at}\t{updated_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n线路列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListPublicZoneLinesRequest()
request.zone_id = args.zone_id
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
response = client.list_public_zone_lines(request)
lines = getattr(response, 'lines', []) or []
if not lines:
print(f"没有找到公网域名线路 (zone_id: {args.zone_id})")
exit(0)
render(lines)
except Exception as e:
print(f"dns.list_public_zone_lines 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListPublicZonesRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询公网域名列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--type", type=str, help="待查询域名的类型,取值: public")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--tags", type=str, help="公网域名的标签,格式 key1,value1|key2,value2")
parser.add_argument("--name", type=str, help="域名名称,默认模糊搜索")
parser.add_argument("--id", type=str, help="域名ID")
parser.add_argument("--status", type=str, help="公网域名状态: ACTIVE/PENDING_CREATE/PENDING_UPDATE/PENDING_DELETE/FREEZE/DISABLE/ERROR 等")
parser.add_argument("--search_mode", type=str, choices=["like", "equal"], help="查询条件搜索模式: like(模糊搜索)/equal(精确搜索)")
parser.add_argument("--sort_key", type=str, choices=["name", "created_at", "updated_at"], help="排序字段,默认 created_at")
parser.add_argument("--sort_dir", type=str, choices=["desc", "asc"], help="排序方式,默认 desc")
parser.add_argument("--enterprise_project_id", type=str, help="企业项目ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(zones):
total = len(zones)
if Offset >= total:
print(f"查询结果为空\n\n公网域名列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "zone_id\tname\tstatus\tzone_type\tttl\trecord_num\tenterprise_project_id\tcreated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
z = zones[i]
zid = getattr(z, 'id', '')
name = getattr(z, 'name', '')
status = getattr(z, 'status', '')
zone_type = getattr(z, 'zone_type', '')
ttl = str(getattr(z, 'ttl', ''))
record_num = str(getattr(z, 'record_num', ''))
ep_id = getattr(z, 'enterprise_project_id', '')
created_at = getattr(z, 'created_at', '')
output += f"{zid}\t{name}\t{status}\t{zone_type}\t{ttl}\t{record_num}\t{ep_id}\t{created_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n公网域名列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_zones = []
marker = ""
limit = 500
request = ListPublicZonesRequest()
request.limit = limit
if args.type:
request.type = args.type
if args.tags:
request.tags = args.tags
if args.name:
request.name = args.name
if args.id:
request.id = args.id
if args.status:
request.status = args.status
if args.search_mode:
request.search_mode = args.search_mode
if args.sort_key:
request.sort_key = args.sort_key
if args.sort_dir:
request.sort_dir = args.sort_dir
if args.enterprise_project_id:
request.enterprise_project_id = args.enterprise_project_id
while True:
if marker:
request.marker = marker
response = client.list_public_zones(request)
zones = getattr(response, 'zones', []) or []
if not zones:
break
all_zones.extend(zones)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = zones[-1].id if zones else ""
if not all_zones:
print(f"没有找到公网域名 (区域: {Region})")
exit(0)
render(all_zones)
except Exception as e:
print(f"dns.list_public_zones 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListRecordSetsByZoneRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询域名下的记录集列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--zone_id", type=str, required=True, help="域名ID")
parser.add_argument("--search_mode", type=str, choices=["like", "equal"], help="查询条件搜索模式: like(模糊搜索)/equal(精确搜索)")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--tags", type=str, help="资源标签,格式 key1,value1|key2,value2")
parser.add_argument("--status", type=str, help="记录集状态: ACTIVE/ERROR/FREEZE/DISABLE")
parser.add_argument("--type", type=str, help="记录集类型,如 A/AAAA/MX/CNAME/TXT/NS/SRV/CAA/PTR 等")
parser.add_argument("--name", type=str, help="记录集名称")
parser.add_argument("--id", type=str, help="记录集ID")
parser.add_argument("--sort_key", type=str, choices=["name", "type", "created_at", "updated_at"], help="排序字段,默认 created_at")
parser.add_argument("--sort_dir", type=str, choices=["desc", "asc"], help="排序方式,默认 desc")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(recordsets):
total = len(recordsets)
if Offset >= total:
print(f"查询结果为空\n\n记录集列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tname\ttype\tstatus\tttl\trecords"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
rs = recordsets[i]
rsid = getattr(rs, 'id', '')
name = getattr(rs, 'name', '')
rtype = getattr(rs, 'type', '')
status = getattr(rs, 'status', '')
ttl = str(getattr(rs, 'ttl', ''))
records = getattr(rs, 'records', []) or []
records_str = '; '.join(records) if records else ''
output += f"{rsid}\t{name}\t{rtype}\t{status}\t{ttl}\t{records_str}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n记录集列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_recordsets = []
marker = ""
limit = 500
request = ListRecordSetsByZoneRequest()
request.zone_id = args.zone_id
request.limit = limit
if args.search_mode:
request.search_mode = args.search_mode
if args.tags:
request.tags = args.tags
if args.status:
request.status = args.status
if args.type:
request.type = args.type
if args.name:
request.name = args.name
if args.id:
request.id = args.id
if args.sort_key:
request.sort_key = args.sort_key
if args.sort_dir:
request.sort_dir = args.sort_dir
while True:
if marker:
request.marker = marker
response = client.list_record_sets_by_zone(request)
recordsets = getattr(response, 'recordsets', []) or []
if not recordsets:
break
all_recordsets.extend(recordsets)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = recordsets[-1].id if recordsets else ""
if not all_recordsets:
print(f"没有找到记录集 (zone_id: {args.zone_id})")
exit(0)
render(all_recordsets)
except Exception as e:
print(f"dns.list_record_sets_by_zone 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListRecordSetsWithLineRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询租户记录集列表(支持线路)")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--zone_type", type=str, choices=["public", "private"], help="域名类型: public/private")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--zone_id", type=str, help="域名ID")
parser.add_argument("--line_id", type=str, help="线路ID")
parser.add_argument("--tags", type=str, help="资源标签,格式 key1,value1|key2,value2")
parser.add_argument("--status", type=str, help="记录集状态: ACTIVE/ERROR/FREEZE/DISABLE")
parser.add_argument("--type", type=str, help="记录集类型,如 A/AAAA/MX/CNAME/TXT/NS/SRV/CAA/PTR 等")
parser.add_argument("--name", type=str, help="记录集名称")
parser.add_argument("--id", type=str, help="记录集ID")
parser.add_argument("--records", type=str, help="记录集的值")
parser.add_argument("--sort_key", type=str, choices=["name", "type", "created_at", "updated_at"], help="排序字段,默认 created_at")
parser.add_argument("--sort_dir", type=str, choices=["desc", "asc"], help="排序方式,默认 desc")
parser.add_argument("--health_check_id", type=str, help="健康检查ID")
parser.add_argument("--search_mode", type=str, choices=["like", "equal"], help="查询条件搜索模式: like(模糊搜索)/equal(精确搜索)")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(recordsets):
total = len(recordsets)
if Offset >= total:
print(f"查询结果为空\n\n记录集列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tname\ttype\tstatus\tttl\tzone_id\tzone_name\tline\tweight"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
rs = recordsets[i]
rsid = getattr(rs, 'id', '')
name = getattr(rs, 'name', '')
rtype = getattr(rs, 'type', '')
status = getattr(rs, 'status', '')
ttl = str(getattr(rs, 'ttl', ''))
zone_id = getattr(rs, 'zone_id', '')
zone_name = getattr(rs, 'zone_name', '')
line = getattr(rs, 'line', '')
weight = str(getattr(rs, 'weight', ''))
output += f"{rsid}\t{name}\t{rtype}\t{status}\t{ttl}\t{zone_id}\t{zone_name}\t{line}\t{weight}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n记录集列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_recordsets = []
marker = ""
limit = 500
request = ListRecordSetsWithLineRequest()
request.limit = limit
if args.zone_type:
request.zone_type = args.zone_type
if args.zone_id:
request.zone_id = args.zone_id
if args.line_id:
request.line_id = args.line_id
if args.tags:
request.tags = args.tags
if args.status:
request.status = args.status
if args.type:
request.type = args.type
if args.name:
request.name = args.name
if args.id:
request.id = args.id
if args.records:
request.records = args.records
if args.sort_key:
request.sort_key = args.sort_key
if args.sort_dir:
request.sort_dir = args.sort_dir
if args.health_check_id:
request.health_check_id = args.health_check_id
if args.search_mode:
request.search_mode = args.search_mode
while True:
if marker:
request.marker = marker
response = client.list_record_sets_with_line(request)
recordsets = getattr(response, 'recordsets', []) or []
if not recordsets:
break
all_recordsets.extend(recordsets)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = recordsets[-1].id if recordsets else ""
if not all_recordsets:
print(f"没有找到记录集 (区域: {Region})")
exit(0)
render(all_recordsets)
except Exception as e:
print(f"dns.list_record_sets_with_line 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListRecordSetsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询租户记录集列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--zone_type", type=str, choices=["public", "private"], help="域名类型: public/private")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--search_mode", type=str, choices=["like", "equal"], help="查询条件搜索模式: like(模糊搜索)/equal(精确搜索)")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--tags", type=str, help="资源标签,格式 key1,value1|key2,value2")
parser.add_argument("--status", type=str, help="记录集状态: ACTIVE/ERROR/FREEZE/DISABLE")
parser.add_argument("--type", type=str, help="记录集类型,如 A/AAAA/MX/CNAME/TXT/NS/SRV/CAA/PTR 等")
parser.add_argument("--name", type=str, help="记录集名称")
parser.add_argument("--id", type=str, help="记录集ID")
parser.add_argument("--records", type=str, help="记录集的值")
parser.add_argument("--sort_key", type=str, choices=["name", "type", "created_at", "updated_at"], help="排序字段,默认 created_at")
parser.add_argument("--sort_dir", type=str, choices=["desc", "asc"], help="排序方式,默认 desc")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(recordsets):
total = len(recordsets)
if Offset >= total:
print(f"查询结果为空\n\n记录集列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tname\ttype\tstatus\tttl\tzone_id\tzone_name"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
rs = recordsets[i]
rsid = getattr(rs, 'id', '')
name = getattr(rs, 'name', '')
rtype = getattr(rs, 'type', '')
status = getattr(rs, 'status', '')
ttl = str(getattr(rs, 'ttl', ''))
zone_id = getattr(rs, 'zone_id', '')
zone_name = getattr(rs, 'zone_name', '')
output += f"{rsid}\t{name}\t{rtype}\t{status}\t{ttl}\t{zone_id}\t{zone_name}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n记录集列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_recordsets = []
marker = ""
limit = 500
request = ListRecordSetsRequest()
request.limit = limit
if args.zone_type:
request.zone_type = args.zone_type
if args.search_mode:
request.search_mode = args.search_mode
if args.tags:
request.tags = args.tags
if args.status:
request.status = args.status
if args.type:
request.type = args.type
if args.name:
request.name = args.name
if args.id:
request.id = args.id
if args.records:
request.records = args.records
if args.sort_key:
request.sort_key = args.sort_key
if args.sort_dir:
request.sort_dir = args.sort_dir
while True:
if marker:
request.marker = marker
response = client.list_record_sets(request)
recordsets = getattr(response, 'recordsets', []) or []
if not recordsets:
break
all_recordsets.extend(recordsets)
links = getattr(response, 'links', None)
next_link = getattr(links, 'next', None) if links else None
if not next_link:
break
marker = recordsets[-1].id if recordsets else ""
if not all_recordsets:
print(f"没有找到记录集 (区域: {Region})")
exit(0)
render(all_recordsets)
except Exception as e:
print(f"dns.list_record_sets 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListResolverQueryLogConfigsRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询解析器访问日志列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
parser.add_argument("--vpc_id", type=str, help="VPC ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(configs):
total = len(configs)
if Offset >= total:
print(f"查询结果为空\n\n解析器访问日志列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tlts_group_id\tlts_topic_id\tvpc_ids"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
cfg = configs[i]
cid = getattr(cfg, 'id', '')
lts_group_id = getattr(cfg, 'lts_group_id', '')
lts_topic_id = getattr(cfg, 'lts_topic_id', '')
vpc_ids = getattr(cfg, 'vpc_ids', []) or []
vpc_str = '; '.join(vpc_ids) if vpc_ids else ''
output += f"{cid}\t{lts_group_id}\t{lts_topic_id}\t{vpc_str}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n解析器访问日志列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
all_configs = []
marker = ""
limit = 500
request = ListResolverQueryLogConfigsRequest()
request.limit = limit
if args.vpc_id:
request.vpc_id = args.vpc_id
while True:
if marker:
request.marker = marker
response = client.list_resolver_query_log_configs(request)
configs = getattr(response, 'resolver_query_log_configs', []) or []
if not configs:
break
all_configs.extend(configs)
page_info = getattr(response, 'page_info', None)
next_marker = getattr(page_info, 'next_marker', None) if page_info else None
if not next_marker:
break
marker = next_marker
if not all_configs:
print("没有找到解析器访问日志配置")
exit(0)
render(all_configs)
except Exception as e:
print(f"dns.list_resolver_query_log_configs 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ListResolverRulesRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
Offset = 0
parser = argparse.ArgumentParser(description="查询解析器转发规则列表")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--domain_name", type=str, help="转发规则域名")
parser.add_argument("--name", type=str, help="转发规则名称")
parser.add_argument("--endpoint_id", type=str, help="终端节点ID")
parser.add_argument("--id", type=str, help="转发规则ID")
parser.add_argument("--limit", type=int, help="分页查询时配置每页返回的资源个数,取值范围 0~500,默认 500")
parser.add_argument("--offset", type=int, help="分页查询起始偏移量,取值范围 0~2147483647,默认 0")
parser.add_argument("--marker", type=str, help="分页查询的起始资源ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
if args.offset is not None:
Offset = args.offset
if Offset < 0:
Offset = 0
def render(resolver_rules):
total = len(resolver_rules)
if Offset >= total:
print(f"查询结果为空\n\n转发规则列表共 {total} 个, 序号从 0 开始, offset必须 < {total}")
exit(0)
header = "id\tname\tdomain_name\tendpoint_id\tstatus\tcreated_at\tupdated_at"
output = header + "\n"
for i in range(Offset, min(total, Offset + 50)):
rule = resolver_rules[i]
rid = getattr(rule, 'id', '')
name = getattr(rule, 'name', '')
domain_name = getattr(rule, 'domain_name', '')
endpoint_id = getattr(rule, 'endpoint_id', '')
status = getattr(rule, 'status', '')
created_at = getattr(rule, 'created_at', '')
updated_at = getattr(rule, 'updated_at', '')
output += f"{rid}\t{name}\t{domain_name}\t{endpoint_id}\t{status}\t{created_at}\t{updated_at}\n"
end = min(total, Offset + 50) - 1
if total > 50 or Offset > 0:
output += f"\n转发规则列表共 {total} 个, 序号从 0 开始,当前显示第 {Offset}~{end} 个\n"
if end + 1 < total:
output += f"可以使用 --offset={end + 1} 参数继续获取后续数据"
print(output)
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ListResolverRulesRequest()
if args.domain_name:
request.domain_name = args.domain_name
if args.name:
request.name = args.name
if args.endpoint_id:
request.endpoint_id = args.endpoint_id
if args.id:
request.id = args.id
if args.limit:
request.limit = args.limit
if args.offset is not None:
request.offset = args.offset
if args.marker:
request.marker = args.marker
response = client.list_resolver_rules(request)
resolver_rules = getattr(response, 'resolver_rules', []) or []
if not resolver_rules:
print("没有找到解析器转发规则")
exit(0)
render(resolver_rules)
except Exception as e:
print(f"dns.list_resolver_rules 查询失败: {e}")
exit(1)
import argparse
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from config import load_credentials, build_http_config
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2 import DnsClient
from huaweicloudsdkdns.v2.model import ShowRetrievalVerificationRequest
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
AK, SK, Region, SecurityToken = load_credentials()
parser = argparse.ArgumentParser(description="查询公网域名找回结果")
parser.add_argument("--project_id", type=str, required=True, help="项目 ID,可通过 ../iam/get_project_id.py 获取")
parser.add_argument("--region", type=str, help="区域,默认 cn-north-4")
parser.add_argument("--id", type=str, required=True, help="找回任务ID")
args = parser.parse_args()
if args.region is not None:
Region = args.region
def render(resp):
zid = getattr(resp, 'id', '')
status = getattr(resp, 'status', '')
updated_at = getattr(resp, 'updated_at', '')
print(f"id: {zid}\nstatus: {status}\nupdated_at: {updated_at}")
try:
http_config = build_http_config()
client = DnsClient.new_builder().with_http_config(http_config).with_credentials(
BasicCredentials(AK, SK, args.project_id) if not SecurityToken else BasicCredentials(AK, SK, args.project_id).with_security_token(SecurityToken)).with_region(DnsRegion.value_of(Region)).build()
if not client:
print("无法获取 DNS 客户端")
exit(-1)
request = ShowRetrievalVerificationRequest()
request.id = args.id
response = client.show_retrieval_verification(request)
render(response)
except Exception as e:
print(f"dns.show_retrieval_verification 查询失败: {e}")
exit(1)