deploy_py/ ├── main.py # Main entry point of the deployment system ├── python/ # Python implementation directory │ ├── config_management/ # Configuration management modules │ ├── deploy/ # Deployment implementation │ ├── executor/ # Command execution modules │ ├── utils/ # Utility functions │ ├── common/ # Common modules (logging, constants, etc.) │ └── exceptions/ # Custom exception definitions └── shell/ # Shell scripts directory └── utils/ # Shell utility scripts
main.py
)The main entry point of the deployment system, responsible for:
Key Classes and Functions:
class MainApplication: """ Main application class that orchestrates the deployment process. Handles command-line arguments and coordinates different deployment modes. """ def __init__(self): """ Initialize the application with: - Command line arguments - OS information - Path management - Deployment manager - Command executor """ def parse_arguments(self): """ Parse command line arguments including: - deploy: Regular deployment mode - docker-deploy: Docker-based deployment - generate-conf: Configuration generation - os-info: Operating system information - docker-instance-num: Number of Docker instances """ def deploy_cluster_if_needed(self): """ Execute cluster deployment based on selected mode: - Regular deployment (bare metal/KVM) - Docker-based deployment """ def generate_conf_if_needed(self): """ Generate configuration files if requested - Converts base_conf.yml to detailed conf.yml - Generates necessary templates """
The configuration management module handles:
Key Components:
Handles the actual deployment process with two main modes:
Responsible for command execution and process management:
Shared functionality across the system:
sequenceDiagram participant User participant Main participant Config participant Deployment participant Executor User->>Main: Start deployment Main->>Config: Load configuration Config->>Config: Validate settings Main->>Deployment: Initialize deployment Deployment->>Executor: Prepare environment Executor->>Executor: Execute commands Deployment->>Deployment: Configure services Deployment->>Main: Report status Main->>User: Complete deployment
# Basic deployment configuration default_password: 'password' data_dirs: ["/data1", "/data2"] components_to_install: ["hdfs", "yarn", "hive"] # Host configuration hosts: - 192.168.1.101 node1 - 192.168.1.102 node2 # Docker specific settings docker_options: instance_num: 4 memory_limit: "16g"
# Detailed configuration generated from base_conf.yml cluster_config: name: "cluster_name" components: hdfs: data_dirs: ["/data1/hdfs", "/data2/hdfs"] yarn: resource_manager: "node1" node_managers: ["node2"]
The system implements comprehensive error handling:
Configuration Validation
Deployment Errors
Recovery Mechanisms
Configuration Management
Deployment Process
Troubleshooting
Code Structure
Error Handling
Testing