#!/usr/bin/env python3 import yaml from pathlib import Path repo_root = Path("d:/coding-area/devops/deploy/microservice-helm") chart_base = repo_root / "charts" # Get all service directories services = sorted([d.name for d in chart_base.iterdir() if d.is_dir() and d.name != "base"]) dubbo_services = {} for service_name in services: values_path = chart_base / service_name / "values.yaml" if not values_path.exists(): continue try: with open(values_path, 'r', encoding='utf-8') as f: values = yaml.safe_load(f) except Exception as e: print(f"ERROR reading {service_name}: {e}") continue # Check if service has dubbo configuration if values and 'config' in values and 'yml' in values['config']: config_yml = values['config']['yml'] # Look for dubbo protocol port if 'dubbo' in config_yml and 'protocol' in config_yml['dubbo']: protocol = config_yml['dubbo']['protocol'] if 'port' in protocol: dubbo_port = protocol['port'] http_port = values['service']['port'] dubbo_services[service_name] = { 'http_port': http_port, 'dubbo_port': dubbo_port } print(f"发现 {len(dubbo_services)} 个Dubbo服务:\n") for service_name in sorted(dubbo_services.keys()): info = dubbo_services[service_name] print(f"{service_name}:") print(f" HTTP Port: {info['http_port']}") print(f" Dubbo Port: {info['dubbo_port']}")