Commit Graph

93 Commits

Author SHA1 Message Date
openhands 1339b8bc55 Fix discovery service persistence issue
- Add discovery_results table to database schema
- Create persistent discovery service with database storage
- Update dashboard API to use persistent discovery service
- Initialize persistent discovery service on application startup
- Fix 404 errors when polling discovery scan results
2025-11-07 09:28:47 +00:00
openhands d0433f45d2 Fix dashboard JavaScript errors and add favicon
- Fixed syntax error in dashboard.js (missing closing bracket for DOMContentLoaded)
- Added favicon.ico file to static directory
- Added favicon link to dashboard HTML template
- All JavaScript errors should now be resolved
- Dashboard should load without console errors
2025-11-07 07:58:15 +00:00
openhands 11baac8f21 Fix deployment script health check bug
Fixed TypeError in SSHDeployer.execute_remote() method by adding 'silent' parameter
- Added silent parameter with default value False
- Modified print statements to respect silent mode
- Health checks now work correctly during deployment

This ensures the deployment script can properly wait for services to start and validate the deployment
2025-11-06 20:19:55 +00:00
openhands 2f94c083b9 Add comprehensive deployment documentation
Created detailed deployment guides:
- DEPLOYMENT.md: Complete step-by-step deployment guide with configuration and key management
- DEPLOYMENT_CHECKLIST.md: Quick reference checklist for deployment process

Both guides cover:
- SSH key configuration and management
- Environment setup and configuration
- Multiple deployment methods (Python SSH, shell script, manual)
- Post-deployment verification and health checks
- Troubleshooting and rollback procedures
- Security considerations

Documentation provides clear instructions for production, staging, and test deployments
2025-11-06 20:03:16 +00:00
openhands 2beb0d1436 Fix file references after repository reorganization
Updated references in:
- deploy/deploy-onprem.sh: Fixed paths for test-deployment.sh and test_dashboard_local.py
- deploy/validate-deployment.sh: Fixed path for test-e2e-deployment.py
- tests/integration/test-e2e-deployment.py: Fixed paths for mock servers

All file references now point to correct locations in the new organized structure
2025-11-06 19:56:13 +00:00
openhands 744e8f6946 Reorganize repository structure for better organization
Created organized directory structure:
- scripts/ - for utility scripts (test runners, etc.)
- tests/mocks/ - for mock servers
- deploy/ - for all deployment scripts
- src/dashboard/ - for dashboard assets

Moved files:
- Test runners: run_tests_by_system.py, run_tests_detailed.py, run_tests_with_db.sh → scripts/
- Deployment scripts: deploy-onprem.sh, setup-server.sh, etc. → deploy/
- Mock servers: mock-optimization-server.py, mock-scada-server.py → tests/mocks/
- Individual tests: test_*.py files → tests/
- Integration tests: test-e2e-deployment.py, test-remote-integration.py → tests/integration/
- Dashboard assets: fixed-dashboard.js → src/dashboard/

Deleted redundant files:
- pytest-mock.ini (redundant with pytest.ini)
- setup-server-backup.sh (duplicate of setup-server.sh)

Kept essential files in root:
- Core documentation (README.md, QUICKSTART.md, etc.)
- Environment templates
- Docker files
- Main test runner (run_tests.py)
- Application entry point (start_dashboard.py)
2025-11-06 19:53:39 +00:00
openhands 94da8687b1 Fix .gitignore formatting and add htmlcov exclusion 2025-11-06 19:40:51 +00:00
openhands 72c51d5ee6 Clean up repository by removing legacy files and temporary documents
Removed:
- Temporary test databases (*.db files)
- Coverage files (.coverage)
- Legacy planning documents (COMPLETION, SUMMARY, PLAN, VERIFICATION files)
- Duplicate test files (_debug, _direct, _fast, _v2, _fix variants)
- Temporary Python files (_modified.py)
- Redundant documentation files

Kept essential documentation:
- README.md, QUICKSTART.md, SECURITY.md
- Core documentation in docs/ directory
- Essential deployment guides
2025-11-06 19:39:35 +00:00
openhands d9481b7246 Add untracked test files and update deployment scripts
- Add discovery protocol test files for debugging and direct testing
- Add remote test integration scripts and configuration
- Update deployment and monitoring scripts with recent changes
- Include test-remote.yml configuration for remote testing
2025-11-06 19:29:21 +00:00
openhands 079ae7a1b2 Fix discovery API endpoints and JavaScript dashboard
- Updated discovery service import to use protocol_discovery_fast
- Fixed recent discoveries endpoint to properly extract endpoints from scan results
- Enhanced dashboard JavaScript with complete functionality
- Updated Docker configuration for discovery module inclusion
- Added remote deployment documentation

This resolves the discovery API 404 errors and ensures all dashboard features work correctly.
2025-11-06 14:31:50 +00:00
openhands d21804e3d9 feat: Implement protocol discovery service with auto-discovery capabilities
- Add ProtocolDiscoveryService with network scanning for all protocols
- Create discovery API endpoints for scan management and results
- Implement discovery UI components in dashboard
- Add comprehensive unit tests for discovery functionality
- Integrate discovery with configuration manager for automatic mapping creation
- Support background task execution for long-running discovery scans
- Include discovery status monitoring and recent discoveries endpoints
2025-11-04 10:01:28 +00:00
openhands 48a1a49384 Add comprehensive test suite for protocol mapping functionality
- Created 35 comprehensive tests covering ConfigurationManager, protocol validation, and database integration
- Added unit tests for ConfigurationManager with database persistence
- Added protocol-specific validation tests for all 4 protocols (Modbus TCP, Modbus RTU, OPC UA, REST API)
- Added integration tests for protocol server integration
- Enhanced existing API tests for protocol mapping endpoints
- Fixed database integration issues in ConfigurationManager
- Improved validation logic and error handling
- All tests passing with comprehensive coverage of Phase 1 functionality
2025-11-04 09:14:11 +00:00
openhands f55a4ccf68 Fix Modbus performance registers and add protocol architecture documentation
- Extended Modbus server input register range from 300 to 400 registers
- Fixed IllegalAddress errors for performance registers (400-499)
- Added timeout protection for Modbus operations in dashboard API
- Added protocol architecture diagram to documentation
- Confirmed both OPC UA and Modbus servers are running correctly
- Protocol clients now successfully read real data with 0% error rate

Test Results:
- OPC UA: 15/15 signals active, 0% error rate
- Modbus: 18/18 signals active, 0% error rate
- REST: 3/3 signals active, 0% error rate
2025-11-01 22:33:22 +00:00
openhands 3413ca4a85 Fix OPC UA server security policy configuration
- Use correct SecurityPolicyType enum values instead of strings
- Server now properly offers NoSecurity (0) policy endpoint
- Fixes 'No matching endpoints' error in client connections
2025-11-01 21:10:17 +00:00
openhands f2bedcd183 fix: Remove await from synchronous Modbus client disconnect call
The Modbus client disconnect method is synchronous, not async
2025-11-01 20:32:04 +00:00
openhands c53d224874 fix: Use actual Modbus client methods for reading registers
- Replace get_pump_data with direct register reads
- Read holding register 350 for pump speed
- Read input register 0 for flow rate
- Calculate derived values for power, pressure, and status
2025-11-01 20:29:54 +00:00
openhands 76eb59036b fix: Remove await from synchronous Modbus client connect call
The Modbus client connect method is synchronous, not async
2025-11-01 20:26:48 +00:00
openhands 4a3db6a3fc fix: Correct Modbus client class name in signals endpoint
Use correct class name 'ModbusClient' instead of 'ModbusTCPClient'
2025-11-01 20:24:04 +00:00
openhands 74a6f5e865 fix: Fix logging error in signals endpoint
Fix logger call to use proper string formatting instead of keyword arguments
2025-11-01 20:21:53 +00:00
openhands ea3ec2b3f9 feat: Restore protocol client integration for Modbus in signals endpoint
- Use real Modbus data when available
- Keep fallback for OPC UA until security policy issues are resolved
- Maintain graceful fallback to mock data if protocol clients fail
2025-11-01 20:20:08 +00:00
openhands 7917fb0968 fix: Fix OPC UA server security configuration
Only configure secure security policies when certificates are available. When certificates are not available, only offer the None security policy and skip certificate validation configuration.
2025-11-01 20:12:50 +00:00
openhands 9c92c5c47f fix: Remove explicit security policy setting from OPC UA client
Let the client automatically negotiate security policy with the server instead of trying to set it explicitly
2025-11-01 20:03:20 +00:00
openhands 2bad8c9ea0 fix: Fix OPC UA client async security policy setting and handle missing Modbus registers
- OPC UA client: Await set_security_string method call
- Modbus client: Handle case where performance metrics registers might not exist
2025-11-01 19:59:59 +00:00
openhands ac89d72aa9 fix: Update protocol clients to fix security policy mismatch and register address issues
- OPC UA client: Explicitly set security policy to 'None' to match server
- OPC UA client: Fix connection handling to check if connection succeeded
- Modbus client: Update register addresses to match server configuration
- Modbus client: Add proper connection success checking
2025-11-01 19:52:58 +00:00
openhands 7cf7ed928b fix: Simplify signals endpoint to use only fallback data to avoid protocol client issues 2025-11-01 19:27:45 +00:00
openhands b15b37658e fix: Add timeout handling to protocol clients to prevent hanging 2025-11-01 18:46:44 +00:00
openhands 400563ac28 fix: Add timeouts and fallback data to signals endpoint to prevent hanging 2025-11-01 18:16:02 +00:00
openhands 66e56eb70c fix: Update test deployment scripts to use port 8081 for test environment
- Updated test-deployment.sh to use port 8081 instead of 8080
- Updated test-e2e-deployment.py to use port 8081 instead of 8080
- Updated setup-test-environment.sh to use port 8081 instead of 8080
- All test scripts now work correctly with test environment configuration
2025-11-01 17:50:28 +00:00
openhands 2b52e27532 fix: Update test database connection to use host.docker.internal
- Changed DB_HOST from localhost to host.docker.internal
- Added extra_hosts configuration to enable host-gateway access
- This allows test container to connect to the existing PostgreSQL database
2025-11-01 17:08:11 +00:00
openhands beda7429c3 fix: Update test docker-compose to use port 8081
- Changed port mapping from 8080:8080 to 8081:8081
- Updated REST_API_PORT to 8081 in environment variables
- Updated HEALTH_MONITOR_PORT to 9091
- Set LOG_LEVEL to DEBUG for test environment
2025-11-01 16:52:26 +00:00
openhands 84fc7f66cb feat: Add test environment deployment support
- Created test.yml configuration file for test environment
- Created .env.test environment file with protocol servers enabled
- Updated deployment script to handle test environment
- Test environment uses port 8081 and enables protocol servers for testing
2025-11-01 16:49:24 +00:00
openhands ce08cf846d fix: Remove outer try-catch block from signals endpoint
- Removed the outer try-catch block that was catching HTTPException
- HTTPException now properly propagates to FastAPI error handler
- This ensures clear error messages are returned when protocol servers are disabled
2025-11-01 16:35:56 +00:00
openhands 28bf3ab246 fix: Properly handle HTTPException in signals endpoint
- Added specific exception handling for HTTPException to prevent double-wrapping
- HTTPException instances are now re-raised directly without modification
- This ensures clear error messages are returned to the client
2025-11-01 16:31:55 +00:00
openhands 26bcc8d83f fix: Remove mock data fallback in production for better error visibility
- Removed mock data fallback from /signals endpoint
- Now returns HTTP 503 with clear error messages when protocol servers are unavailable
- Protocol servers are disabled in production, so dashboard will show clear error messages
- This ensures we can properly test connectivity issues and don't mask real problems
2025-11-01 16:28:57 +00:00
openhands 98a3254c88 fix: Check protocol server status before attempting connections in signals endpoint
- Added check for settings.opcua_enabled and settings.modbus_enabled before initializing ProtocolDataCollector
- This prevents connection attempts when protocol servers are disabled in production
- Reduces error logs and improves performance
2025-11-01 16:10:55 +00:00
openhands 3d2abe9e70 fix: Update production database credentials to match existing setup
- Changed DB_USER from calejo_user to calejo
- Changed DB_NAME from calejo_production to calejo
- Updated docker-compose.production.yml to match
2025-11-01 16:06:01 +00:00
openhands 308972c265 feat: Add production configuration to disable internal protocol servers
- Created .env.production with OPCUA_ENABLED=false and MODBUS_ENABLED=false
- Created docker-compose.production.yml that uses production environment file
- Updated deployment script to use production docker-compose file when available
- This prevents connection issues when protocol servers are not available
2025-11-01 16:02:26 +00:00
openhands 80bb919a56 feat: Add protocol clients for dashboard to query real OPC UA and Modbus servers
- Created ProtocolDataCollector class to query OPC UA and Modbus servers
- Updated /signals endpoint to use real protocol data instead of mock data
- Added graceful fallback to mock data when protocol servers are unavailable
- Fixed Modbus client parameter issues and None value handling
- Enhanced dashboard to display real industrial data from protocol servers
2025-11-01 15:17:38 +00:00
openhands 769f64ad40 fix: Use consistent Modbus register addresses
- Fixed random register generation in signals endpoint
- Each pump now gets consistent register blocks (40011-40014, 40021-40024, etc.)
- Addresses now follow logical pattern for industrial SCADA systems
2025-11-01 14:12:05 +00:00
openhands c33f970b1c fix: Handle AutoDiscovery dependency in dashboard API
- Fixed signals endpoint to work without database dependency
- Fixed scada-config endpoint to use default stations and pumps
- Enhanced mock data now properly served from production server
2025-11-01 13:10:45 +00:00
openhands ecf717afdc feat: Replace mock data with enhanced mock services
- Enhanced OPC UA server with realistic pump simulation
- Enhanced Modbus server with simulated industrial data
- Updated SCADA API endpoints to query actual protocol servers
- Added realistic signal data based on actual stations and pumps
- Improved SCADA configuration with real device mapping
2025-11-01 13:00:32 +00:00
openhands 9f1de833a6 fix: Add missing SCADA API endpoints
- Add /api/v1/dashboard/scada-config GET endpoint
- Add /api/v1/dashboard/scada-config POST endpoint
- Add /api/v1/dashboard/test-scada endpoint
- Fix JavaScript errors for SCADA configuration buttons
- All SCADA functions now work properly
2025-11-01 12:36:23 +00:00
openhands 90d3a650b0 feat: Add comprehensive signal overview and dashboard improvements
- Add Signal Overview tab with protocol statistics and signal table
- Fix button visibility issues with improved CSS styling
- Add preconfigured Grafana dashboard with system monitoring
- Add signal export functionality (CSV download)
- Add protocol statistics cards (Modbus, OPC UA, Profinet, REST)
- Add signal filtering and search capabilities
- Update dashboard provisioning for Grafana
- Add mock signal data for demonstration
2025-11-01 12:06:23 +00:00
openhands d0a0c1c1d3 feat: Implement secure random password generation for Prometheus
- Add generate-monitoring-secrets.sh script that creates random passwords
- Auto-configure Prometheus with generated password hash
- Auto-configure Grafana datasource with same random password
- Update setup-server.sh to include monitoring setup
- Remove hardcoded Prometheus credentials from repository
- Keep Grafana default admin password for user configuration
- Generate secure 16-character random passwords for each deployment
- Store generated credentials in monitoring/.env.generated (gitignored)
2025-11-01 11:53:23 +00:00
openhands a5e421e864 security: Improve environment variable security for monitoring
- Remove hardcoded passwords from repository
- Add .env.example template for secure configuration
- Update docker-compose.yml to use environment variables with defaults
- Update Grafana datasource configuration to use secureJsonData
- Update setup scripts to load from .env file
- Add password hash generation for Prometheus web.yml
- Remove monitoring/web.yml from git tracking (contains password hash)
- Add security warnings about sensitive files
2025-11-01 11:43:18 +00:00
openhands b522c3d116 feat: Add Prometheus authentication and Grafana auto-configuration
- Add Prometheus web.yml configuration with basic authentication
- Update Grafana datasource to auto-configure with Prometheus credentials
- Create setup-monitoring.sh script for automated monitoring setup
- Add configure-grafana.sh script for API-based Grafana configuration
- Update docker-compose.yml with Prometheus authentication environment
- Update setup-server.sh to include monitoring URLs and credentials
- Ensure Grafana automatically connects to Prometheus with proper auth
2025-11-01 11:22:06 +00:00
openhands da82ab5d9f fix: Improve dashboard UI and add SCADA/hardware configuration
- Fix tab visibility issue with white-on-white background
- Add SCADA/Hardware configuration tab with comprehensive settings
- Add Modbus TCP configuration with port, slave ID, and baud rate
- Add OPC UA configuration with security mode options
- Add device mapping interface for SCADA device configuration
- Add SCADA status monitoring with connection details
- Add Prometheus authentication configuration (basic auth)
- Update JavaScript to handle new SCADA functionality
2025-11-01 11:12:12 +00:00
openhands d68fab1aab docs: Add default credentials documentation for Grafana, Prometheus, and PostgreSQL
- Document default Grafana credentials: admin/admin
- Document Prometheus access without authentication
- Document PostgreSQL credentials: calejo/password
- Add security note to change default passwords after first login
- Update README.md and QUICK_START.md with credential information
2025-11-01 10:35:25 +00:00
openhands 69b1752774 Complete production deployment with fixes
- Fixed PostgreSQL connection timeout parameter
- Fixed database host configuration for Docker networking
- Fixed SQL datetime syntax for PostgreSQL compatibility
- Fixed REST API binding to 0.0.0.0 for external access
- Added comprehensive documentation
- Enhanced deployment scripts
- Added dashboard configuration system
- Updated settings for production deployment
2025-11-01 10:28:25 +00:00
openhands 7372c5a161 Add standalone test script for mock services without Docker dependency 2025-10-30 14:24:45 +00:00